aspectumapp / osm2geojson

Convert OSM and Overpass XML/JSON to GeoJSON
MIT License
100 stars 14 forks source link

Gaps in ways when converting to GeoJSON #4

Closed ralienpp closed 4 years ago

ralienpp commented 4 years ago

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:

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...): image

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

And the relevant part of its source code https://github.com/roataway/infrastructure-data/blob/updated-route30/tools/getRoute#L44:

    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.

Thanks!

rapkin commented 4 years ago

Problem was with recursive relations. I made changes to support this.

ralienpp commented 4 years ago

Thank you, I can confirm that the results are correct now.