maproulette / maproulette3

MapRoulette, the micro-tasking tool for OpenStreetMap
https://maproulette.org
MIT License
120 stars 32 forks source link

How to import relations with a line-by-line file #1917

Open KristjanESPERANTO opened 1 year ago

KristjanESPERANTO commented 1 year ago

I can now successfully create challenges via line-by-line GeoJSON file with nodes and ways. But I can't figure out how to handle relations.

I treat nodes as a point:

{"type":"FeatureCollection","features":[{"type": "Feature", "geometry": {"type": "Point", "coordinates": [25.1455115, 60.2065814]}, "properties": {"id": 73112175, "type": "node", "name": "Ravintola Fregatti"}}]}

I treat ways as a LineString:

{"type":"FeatureCollection","features":[{"type": "Feature", "geometry": {"type": "LineString", "coordinates": [[0.6121083, 51.5524867]]}, "properties": {"id": 1120565578, "type": "way", "name": "mall road"}}]}

I tried to import relations as GeometryCollections, MultiLineStrings and also as LineString, but it didn't work.

{"type":"FeatureCollection","features":[{"type": "Feature", "geometry": {"type": "GeometryCollections", "coordinates": [[-1.5343954, 52.4027155]]}, "properties": {"id": 14906323, "type": "relation", "name": "The Old Clarence"}}]}

What am I missing?

atiannicelli commented 11 months ago

This isn't necessarily a relation issue. It is an issue with adding multiple geometries to a single task.

Try this for your geometry: "geometry": {"type": "GeometryCollection", "geometries": [{"type": "LineString", "coordinates": [[-58.7810037, -27.5199102], [-58.7809956, -27.5199463], [-58.7812341, -27.5203813], [-58.7812558, -27.5204126], [-58.7813054, -27.5204831], [-58.7816364, -27.5211127]]}, {"type": "Point", "coordinates": [-58.78144588, -27.5207503]}, {"type": "LineString", "coordinates": [[-58.7802055, -27.5187263], [-58.7822493, -27.5220613]]}]}

Here is a full line: {"type": "FeatureCollection", "features": [{"type": "Feature", "properties": {"highway": "residential", "identifier": "w1088492002@2", "osmIdentifier": "way/1088492002", "instructions": "Way 1088492002 intersects with 1055973572 at POINT (-58.78144587552386 -27.520750300573482) without a shared node."}, "geometry": {"type": "GeometryCollection", "geometries": [{"type": "LineString", "coordinates": [[-58.7810037, -27.5199102], [-58.7809956, -27.5199463], [-58.7812341, -27.5203813], [-58.7812558, -27.5204126], [-58.7813054, -27.5204831], [-58.7816364, -27.5211127]]}, {"type": "Point", "coordinates": [-58.78144588, -27.5207503]}, {"type": "LineString", "coordinates": [[-58.7802055, -27.5187263], [-58.7822493, -27.5220613]]}]}}]}

KristjanESPERANTO commented 11 months ago

I don't have the time to adapt it to my use case at the moment. But it looks promising. Thanks!

I think it would be nice if we improve the documentation on this: https://learn.maproulette.org/documentation/line-by-line-geojson/