osm-python-tools
osm-python-tools copied to clipboard
Overpass returns every way twice
I was trying to find all runways within a bounding box, and noticed that I get every runway (mapped as a way with aeroway=runway
) twice. Here's a test code:
from OSMPythonTools import overpass
query = overpass.overpassQueryBuilder(bbox=[-6.05, 144.95, -6, 145], elementType="way",
selector='"aeroway"="runway"', out="body", includeCenter=True)
result = overpass.Overpass().query(query).ways()
for e in result:
print(e, e.tags())
which prints:
[overpass] downloading data: [timeout:25][out:json];(way["aeroway"="runway"](-6.05,144.95,-6,145);); out center; out body;
<OSMPythonTools.element.Element object at 0x7fb7a11704c0> {'aeroway': 'runway', 'ele': '1516', 'length': '1015', 'name': '03/21', 'source': 'Bing', 'surface': 'paved'}
<OSMPythonTools.element.Element object at 0x7fb7a11700d0> {'aeroway': 'runway', 'ele': '1516', 'length': '1015', 'name': '03/21', 'source': 'Bing', 'surface': 'paved'}
You can see that I got two different Elements
holding the exact same data. Here's the test area in OSM
And Overpass-turbo shows that there is in fact only one way tagged ´aeroway=runway´ in that area.
If I remove includeCenter=True
it works.
Okay, played around a bit with Overpass-Turbo and this module, and the problem is that with includeCenter=True
, out body;
becomes ´out center; out body;whereas it should only be
out center;´ then. To bypass this issue, one can use out="center"
instead.
If the data is returned twice here, I would assume that it is already returned twice by Overpass. I recommend to run the query directly in Overpass and check the output. If this confirms my assumption, I advise to read their documentation.
I did run the query directly in Overpass, and I found that for every ´out´ keyword all matches are outputted once - if there's both ´out body;and
out center´, then first normal body response is returned and then the same thing again, just with additional center
keys for each way - so out center;
implies ´out body;, and I think the
overpassQueryBuildershould account for that by only putting one
out` keyword into the query string.
Oh, I see. I have to check the logics in detail. Stay tuned (might take some days).
no problem, thanks ! :)