JHMeusener / osm2xodr

converter for OpenStreetMaps to OpenDrive roads - for use with Carla or other things
GNU General Public License v3.0
165 stars 51 forks source link

version problem #7

Closed Laudarisd closed 3 years ago

Laudarisd commented 3 years ago

I was trying to convert osm to xodr but encountered following problem. Any suggestion?

Traceback (most recent call last):
  File "main.py", line 11, in <module>
    parseAll(osmPfad, bildpfad=topographieKartenPfad, minimumHeight = 163.0, maximumHeight= 192.0, curveRadius=12)
  File "/home/vision/Downloads/carla_1/osm2xodr/OSMParser/osmParsing.py", line 525, in parseAll
    topoParameter = convertTopoMap(bildpfad, pfad)
  File "/home/vision/Downloads/carla_1/osm2xodr/OSMParser/utils.py", line 122, in convertTopoMap
    topoParameter = giveMaxMinLongLat(osmpath)
  File "/home/vision/Downloads/carla_1/osm2xodr/OSMParser/utils.py", line 164, in giveMaxMinLongLat
    for entity in parse_file(osmpath):
  File "/home/vision/.local/lib/python3.8/site-packages/osmread/__init__.py", line 25, in parse_file
    for e in parser.parse_file(filename):
  File "/home/vision/.local/lib/python3.8/site-packages/osmread/parser/__init__.py", line 18, in parse_file
    for e in self.parse(fp):
  File "/home/vision/.local/lib/python3.8/site-packages/osmread/parser/xml.py", line 45, in parse
    _version = int(attrs['version'])
  File "src/lxml/etree.pyx", line 2479, in lxml.etree._Attrib.__getitem__
KeyError: 'version'

Thank you

JHMeusener commented 3 years ago

the osm-parser library i used expects the osm file to have the key "version" (and a few other not that relevant keys) inside it. Did you get your map directly from openstreetmaps or did you modify it with another program? Here is an example from an osm-file as it is expected:

`<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="CGImap 0.8.3 (1466920 spike-08.openstreetmap.org)" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/">
 <bounds minlat="51.2540200" minlon="7.1421200" maxlat="51.2551300" maxlon="7.1461000"/>
 <node id="692966" visible="true" version="8" changeset="50115597" timestamp="2017-07-07T18:36:13Z" user="bilderhobbit" uid="503347" lat="51.2546014" lon="7.1427466"/>
 <node id="692967" visi ......` 

as i said, the header and every node have keys that may not be relevant for reconstructing the map, but are expected by the osm-parser. You can just add them with some dummy data.

Laudarisd commented 3 years ago

Sorry for late reply. I had problem in my osm file. It didn't include nodes information.

Thank you for your reply. Have a nice time.