mvexel / overpass-api-python-wrapper

Python bindings for the OpenStreetMap Overpass API
Apache License 2.0
360 stars 89 forks source link

Example bounding box map query call does not contain all the nodes #70

Closed daeilkim closed 7 years ago

daeilkim commented 7 years ago

I've noticed that using the example in the readme that there are missing nodes for node ids referenced in ways . For example running this in Python:

api = overpass.API(timeout=600)
map_query = overpass.MapQuery(50.746,7.154,50.748,7.157)
response = api.Get(map_query, responseformat="json")
unique_nodes = []
way_nodes = []
for element in response['elements']:
    if element['type'] == 'way':
        way_nodes.extend([str(x) for x in element['nodes']])
    if element['type'] == 'node':
        id = str(element['id'])
        unique_nodes.append(id)
diff = list(set(way_nodes) - set(unique_nodes))
print diff

results in a set of node ids that are not found from the response call. Any thoughts on this?

Missing Nodes:

['1212226190', '2661510421', '4245927048', '1212226047', '2661537835', '2661510427', '1212226113', '1212226110', '4245927044', '4245927046', '2658130490', '2658130496', '1212226181', '4245926776', '1212226052', '1558201832', '2661510414', '2661510416', '1558201823', '1558201825', '1558201826', '1558201827', '291092263', '96140183', '4241842210', '2658130489', '1212226024', '2661510278', '2661510404', '4241842209', '4241842208', '1558201836', '1212226130', '1212226131', '1558201831', '96133778', '96133776', '1212226220', '2661510260', '2661510266', '96133775', '1212226038', '2661537867', '1212226031', '1212226030', '274246241', '1212226107', '1212226125', '32346787', '4241842211', '4083385469', '2658130507', '2661537830', '2661537832', '1212226085', '1212226159', '2464702124', '2464702125', '2464702122', '1212226042', '2464702129', '1212226203', '1212226139', '2661537846', '2661537849', '291089398', '291089396', '96133777', '96133774', '1647008854', '470930365', '2464702134', '2464702130', '2464702133', '2464702132', '2661537863', '2464702123', '2661537823', '4246007583', '4246007580', '1647095994', '2519501893', '1212226067', '2519501898', '1558201815', '2661537824', '1558201812', '291438873', '291438871', '2661537825', '291438874', '1212226166', '33078442', '2661538021', '2519501886', '2661537826', '291435959', '291435958', '4245927053', '2661537828', '4245927051', '1212226061', '4245927055']

mmd-osm commented 7 years ago

That's expected if you look at how MapQuery is implemented: https://github.com/mvexel/overpass-api-python-wrapper/blob/master/overpass/queries.py#L7

MapQuery first gets all nodes in the bbox, and then finds associated ways/relations. As ways are not cut in the same way on the bbox, some nodes are missing.

You can see the same effect here: http://overpass-turbo.eu/s/kCE