drolbr / overpass-doc

The user manual for Overpass API
https://dev.overpass-api.de/overpass-doc/
MIT License
8 stars 9 forks source link

Add more documentation about creation of derived objects (convert item function) #11

Open MurzNN opened 3 years ago

MurzNN commented 3 years ago

I've caught a problem that convertion of Overpass to GeoJSON result format resets all id of objects to counter from 1, so I can't get original id of object.

I use the example query from https://dev.overpass-api.de/overpass-doc/en/targets/formats.html#json

Here it is: https://overpass-turbo.eu/?lat=51.4775&lon=0.0&zoom=16&Q=%5Bout%3Ajson%5D%3B%0A%28%20way%2851%2E477%2C%2D0%2E001%2C51%2E478%2C0%2E001%29%5Bname%3D%22Blackheath%20Avenue%22%5D%3B%0A%20%20node%28w%29%3B%0A%20%20relation%2851%2E477%2C%2D0%2E001%2C51%2E478%2C0%2E001%29%3B%20%29%3B%0Aconvert%20item%20%3A%3A%3D%3A%3A%2C%3A%3Ageom%3Dgeom%28%29%2C%5Fosm%5Ftype%3Dtype%28%29%3B%0Aout%20geom%3B

In results I see those elements with id, starting from 1:

{
  "type": "item",
  "id": 1,
  "geometry": {
    "type": "Point",
    "coordinates": [ -0.0001831, 51.4770916 ]
  },
  "tags": {
    "_osm_type": "node"
  }
},
{
  "type": "item",
  "id": 2,
  "geometry": {
    "type": "Point",
    "coordinates": [ -0.0000192, 51.4768989 ]
  },
  "tags": {
    "_osm_type": "node"
  }
},

Also I need to keep members with role="admin_centre", that disappears after this conversion.

Maybe I need to add some magic to this query line:

convert item ::=::,::geom=geom(),_osm_type=type();

but link to documentation (from first documentation) shows not so much useful info: https://dev.overpass-api.de/overpass-doc/en/counting/index.html

Can you please add more documentation how the convert item works? Thanks!

mmd-osm commented 2 years ago

You need to add ::id=id() to the convert statement.

https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_API_by_Example has a few examples, search for „id()“