We're using osm2geojson to retrieve route details for public transport in Moldova. There's a problem we encounter with some routes, which appear to have gaps in them, even though they look correct in OSM itself.
Here is an example:
Go to https://overpass-turbo.eu/ and run this query relation (7390177); >>; out geom; - note that it looks ok and is continuous throughout the entire length (the relevant fragment is shown in the second image).
We then take the returned XML and process it with osm2geojson.xml2geojson() and save it to a file.
For comparison, this is what that area looks like in Overpass Turbo (the circles are speed limit signs are cameras, I believe these are not relevant in this case, but who knows...):
Osm2GeoJSON appears to stumble upon something, here are possibly relevant log entries from our tool:
INFO - Processing single route specified by relation 7390177
INFO - Self-intersection at or near point 28.843157115089561 47.000713289675019
Invalid geometry! Try to fix with 0 buffer
Geometry fixed!
INFO - Done
with open(os.path.join(target_path, TEMPLATE_SEGMENTS % upstream_id), 'w') as f:
geojson_segments = osm2geojson.xml2geojson(segments)
geojson_segments = json.dumps(geojson_segments, indent=4)
f.write(geojson_segments)
What is causing these gaps, and how can this be addressed?
There is a corresponding issue in our project https://github.com/roataway/infrastructure-data/issues/8, with some additional details. Note that it describes another issue besides the gaps - if you have any hints about resolving that, we'd greatly appreciate it.
We're using
osm2geojson
to retrieve route details for public transport in Moldova. There's a problem we encounter with some routes, which appear to have gaps in them, even though they look correct in OSM itself.Here is an example:
relation (7390177); >>; out geom;
- note that it looks ok and is continuous throughout the entire length (the relevant fragment is shown in the second image).osm2geojson.xml2geojson()
and save it to a file.For comparison, this is what that area looks like in Overpass Turbo (the circles are speed limit signs are cameras, I believe these are not relevant in this case, but who knows...):
Osm2GeoJSON appears to stumble upon something, here are possibly relevant log entries from our tool:
And the relevant part of its source code https://github.com/roataway/infrastructure-data/blob/updated-route30/tools/getRoute#L44:
What is causing these gaps, and how can this be addressed?
There is a corresponding issue in our project https://github.com/roataway/infrastructure-data/issues/8, with some additional details. Note that it describes another issue besides the gaps - if you have any hints about resolving that, we'd greatly appreciate it.
Thanks!