mvexel / overpass-api-python-wrapper

Python bindings for the OpenStreetMap Overpass API
Apache License 2.0
367 stars 90 forks source link

Error key error with center #58

Closed Xevib closed 6 years ago

Xevib commented 8 years ago

With the following code I get

q = '(node["amenity"="restaurant"](around:10000,41.978436,2.813442);way["amenity"="restaurant"](around:10000,41.978436,2.813442);relation["amenity"="restaurant"](around:10000,41.978436,2.813442););out body center;'
print(api.Get(q))

this exception Traceback (most recent call last): File "/home/xevi/gits/overpass-api-python-wrapper/overpass/cli.py", line 29, in print(api.Get(q)) File "/home/xevi/gits/overpass-api-python-wrapper/overpass/api.py", line 65, in Get return self._asGeoJSON(response["elements"]) File "/home/xevi/gits/overpass-api-python-wrapper/overpass/api.py", line 131, in _asGeoJSON for coords in elem["geometry"]: KeyError: 'geometry'

lwatt commented 8 years ago

I believe this is because your query includes the 'out body center;' part at the end, and then the 'out body geom;' which is appended by the module is ignored by the server, and so the necessary geometry is not returned for ways. The fix for this is up to @mvexel, how they wish to handle the parsing of the last part of the query, perhaps by the addition of the option for modificators, similar to the verbosity options. This relates to issue #54 as well.

mvexel commented 6 years ago

It works as of 0.6.0.