0

I suspect that I'm misunderstanding what the XMLParser for imposm is meant to read, and that my XML is in the wrong format. Here's the code (Python):

from imposm.parser.xml.parser import XMLParser

def parseExits(ways):
  print 'hello!'
  print ways

p = XMLParser(ways_callback=parseExits)
p.parse('osm.xml')

Here's osm.xml:

<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="Overpass API">
<note>The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.</note>
<meta osm_base="2014-05-06T15:36:02Z"/>

  <node id="633064865" lat="35.9654701" lon="-83.9331538">
    <tag k="highway" v="motorway_junction"/>
    <tag k="ref" v="387"/>
  </node>
  <node id="633073161" lat="35.9671764" lon="-83.9308793">
    <tag k="exit_to" v="Convention Center;East Tennessee History Center;Museum of Art"/>
    <tag k="highway" v="motorway_junction"/>
    <tag k="ref" v="388"/>
  </node>
  <node id="633073540" lat="35.9696598" lon="-83.9263839">
    <tag k="highway" v="motorway_junction"/>
    <tag k="ref" v="387A"/>
  </node>
  <node id="633079780" lat="35.9733917" lon="-83.9321537">
    <tag k="highway" v="motorway_junction"/>
    <tag k="noref" v="yes"/>
  </node>
  <node id="633135831" lat="35.9754882" lon="-83.9337192">
    <tag k="highway" v="motorway_junction"/>
    <tag k="ref" v="1A"/>
  </node>

</osm>

I fetched that file from this link:

http://overpass-api.de/api/interpreter?data=node[\"highway\"=\"motorway_junction\"](35.96225504283211,-83.9349889755249,35.976043972301575,-83.92046213150024);out;

And here's the output from the python script:

hello!
[]

Clearly, the XMLParser isn't managing to parse the file. Is it not formatted correctly? The XMLParser is either very poorly documented or that documentation is extremely well hidden, because I can't find any information on it. Any tips would be wildly helpful! Thanks!

Andrew LaPrise
  • 3,373
  • 4
  • 32
  • 50
  • 3
    I have no particular knowledge about how this Parser is meant to be used, but if I were you, I would check if the `ways_callback` option is really the one that you want to use here (note that in OSM `way` ≠ `node`). Maybe there is also some kind of `nodes_callback`‽ – tyr May 06 '14 at 16:55
  • Please restart with this [simple example](http://imposm.org/docs/imposm.parser/1.0.5/) and tell us if it's working for your data. – MaM May 06 '14 at 17:27
  • @tyr, you were right on the money. Thanks so much for your help! – Andrew LaPrise May 06 '14 at 17:31
  • Agreed, terrible documentation. – Max von Hippel Oct 23 '16 at 11:07

0 Answers0