python imposm - XMLParser

时间:2014-05-06 16:08:32

标签: python xml openstreetmap imposm

我怀疑我误解了imposm的XMLParser读取的内容,以及我的XML格式错误。这是代码(Python):

from imposm.parser.xml.parser import XMLParser

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

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

这是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>

我从这个链接中获取了该文件:

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

这是python脚本的输出:

hello!
[]

显然,XMLParser无法解析文件。它格式不正确吗? XMLParser要么记录得很差,要么文档隐藏得非常好,因为我找不到任何关于它的信息。任何提示都会非常有用!谢谢!

0 个答案:

没有答案