Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support convert result ::=::,::geom=geom(),length=length(); #130

Open
tordans opened this issue Nov 15, 2021 · 1 comment
Open

Support convert result ::=::,::geom=geom(),length=length(); #130

tordans opened this issue Nov 15, 2021 · 1 comment

Comments

@tordans
Copy link

tordans commented Nov 15, 2021

In drolbr/Overpass-API#237 (comment) @drolbr showed this handy way to inject the length of a way into the tags of the osm-tags output.

Unfortunately, that breaks osmtogeojson. When I try to convert, I get an empty result

This works

https://olbricht.nrw/ovt/?Q=%5Bout%3Ajson%5D%3B%0Away%5B%22highway%22%3D%22service%22%5D(%7B%7Bbbox%7D%7D)%3B%0Aout%20geom%3B&C=41.89409;12.49391;20&R

[out:json];
way["highway"="service"]({{bbox}});
out geom;
Output
{
  "version": 0.6,
  "generator": "Overpass API 0.7.56.8 7d656e78",
  "osm3s": {
    "timestamp_osm_base": "2021-11-15T18:29:14Z",
    "copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL."
  },
  "elements": [

{
  "type": "way",
  "id": 23694377,
  "bounds": {
    "minlat": 41.8943972,
    "minlon": 12.4938181,
    "maxlat": 41.8948117,
    "maxlon": 12.4938504
  },
  "nodes": [
    3134209747,
    256573077,
    256573071
  ],
  "geometry": [
    { "lat": 41.8948117, "lon": 12.4938504 },
    { "lat": 41.8947155, "lon": 12.4938459 },
    { "lat": 41.8943972, "lon": 12.4938181 }
  ],
  "tags": {
    "foot": "yes",
    "highway": "service",
    "name": "Via Monte Polacco",
    "service": "alley",
    "surface": "sett"
  }
},
{
  "type": "way",
  "id": 140757469,
  "bounds": {
    "minlat": 41.8940306,
    "minlon": 12.4943443,
    "maxlat": 41.8942735,
    "maxlon": 12.4949911
  },
  "nodes": [
    1541394684,
    1541394687,
    1541394738,
    1541394751,
    3545433320,
    1541394743,
    3545433319,
    1541394616,
    1541394611,
    1541394620,
    1541394655,
    1541394668,
    1541394684
  ],
  "geometry": [
    { "lat": 41.8942435, "lon": 12.4943814 },
    { "lat": 41.8942381, "lon": 12.4945093 },
    { "lat": 41.8942386, "lon": 12.4947562 },
    { "lat": 41.8942735, "lon": 12.4949444 },
    { "lat": 41.8942665, "lon": 12.4949911 },
    { "lat": 41.8942443, "lon": 12.4949835 },
    { "lat": 41.8941869, "lon": 12.4948972 },
    { "lat": 41.8940349, "lon": 12.4945142 },
    { "lat": 41.8940306, "lon": 12.4944422 },
    { "lat": 41.8940584, "lon": 12.4943616 },
    { "lat": 41.8940992, "lon": 12.4943443 },
    { "lat": 41.8941506, "lon": 12.4943529 },
    { "lat": 41.8942435, "lon": 12.4943814 }
  ],
  "tags": {
    "access": "private",
    "highway": "service",
    "service": "parking_aisle",
    "surface": "asphalt"
  }
},
{
  "type": "way",
  "id": 140757481,
  "bounds": {
    "minlat": 41.8941137,
    "minlon": 12.4939823,
    "maxlat": 41.8942462,
    "maxlon": 12.4943814
  },
  "nodes": [
    1541394684,
    1541394734,
    1541394717,
    1541394666,
    1541394660
  ],
  "geometry": [
    { "lat": 41.8942435, "lon": 12.4943814 },
    { "lat": 41.8942462, "lon": 12.4943089 },
    { "lat": 41.8942317, "lon": 12.4942490 },
    { "lat": 41.8941404, "lon": 12.4940229 },
    { "lat": 41.8941137, "lon": 12.4939823 }
  ],
  "tags": {
    "access": "private",
    "highway": "service",
    "service": "driveway"
  }
},
{
  "type": "way",
  "id": 348410740,
  "bounds": {
    "minlat": 41.8937940,
    "minlon": 12.4938787,
    "maxlat": 41.8939344,
    "maxlon": 12.4942016
  },
  "nodes": [
    3545433304,
    3545433303,
    3545433301
  ],
  "geometry": [
    { "lat": 41.8939344, "lon": 12.4942016 },
    { "lat": 41.8939152, "lon": 12.4941676 },
    { "lat": 41.8937940, "lon": 12.4938787 }
  ],
  "tags": {
    "highway": "service"
  }
}

  ]
}

And transforming it via http://tyrasd.github.io/osmtogeojson/ works.

This does not work

https://olbricht.nrw/ovt/?Q=%5Bout%3Ajson%5D%3B%0Away%5B%22highway%22%3D%22service%22%5D(%7B%7Bbbox%7D%7D)%3B%0Aconvert%20result%20%3A%3A%3D%3A%3A%2C%3A%3Ageom%3Dgeom()%2Clength%3Dlength()%3B%0Aout%20geom%3B&C=41.89409;12.49391;20&R

[out:json];
way["highway"="service"]({{bbox}});
convert result ::=::,::geom=geom(),length=length();
out geom;
Output
{
  "version": 0.6,
  "generator": "Overpass API 0.7.57 93a4d346",
  "osm3s": {
    "timestamp_osm_base": "2021-11-15T18:16:02Z",
    "copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL."
  },
  "elements": [

{
  "type": "result",
  "id": 1,
  "geometry": {
    "type": "LineString",
    "coordinates": [
      [12.4942016, 41.8939344],
      [12.4941676, 41.8939152],
      [12.4938787, 41.8937940]
    ]
  },
  "tags": {
    "highway": "service",
    "length": "30.959"
  }
},
{
  "type": "result",
  "id": 2,
  "geometry": {
    "type": "LineString",
    "coordinates": [
      [12.4938504, 41.8948117],
      [12.4938459, 41.8947155],
      [12.4938181, 41.8943972]
    ]
  },
  "tags": {
    "foot": "yes",
    "highway": "service",
    "name": "Via Monte Polacco",
    "service": "alley",
    "surface": "sett",
    "length": "46.137"
  }
},
{
  "type": "result",
  "id": 3,
  "geometry": {
    "type": "LineString",
    "coordinates": [
      [12.4943814, 41.8942435],
      [12.4945093, 41.8942381],
      [12.4947562, 41.8942386],
      [12.4949444, 41.8942735],
      [12.4949911, 41.8942665],
      [12.4949835, 41.8942443],
      [12.4948972, 41.8941869],
      [12.4945142, 41.8940349],
      [12.4944422, 41.8940306],
      [12.4943616, 41.8940584],
      [12.4943443, 41.8940992],
      [12.4943529, 41.8941506],
      [12.4943814, 41.8942435]
    ]
  },
  "tags": {
    "access": "private",
    "highway": "service",
    "service": "parking_aisle",
    "surface": "asphalt",
    "length": "133.432"
  }
},
{
  "type": "result",
  "id": 4,
  "geometry": {
    "type": "LineString",
    "coordinates": [
      [12.4943814, 41.8942435],
      [12.4943089, 41.8942462],
      [12.4942490, 41.8942317],
      [12.4940229, 41.8941404],
      [12.4939823, 41.8941137]
    ]
  },
  "tags": {
    "access": "private",
    "highway": "service",
    "service": "driveway",
    "length": "36.969"
  }
}

  ]
}

Transforming it via http://tyrasd.github.io/osmtogeojson/ returns:

{
"type": "FeatureCollection",
"features": [

]
}
@tordans
Copy link
Author

tordans commented Feb 10, 2022

Update in case someone finds this in search for a workaround: I build my own GeoJSON transformation.

I was using the stats workaround described in drolbr/Overpass-API#237 (comment) before and used this script https://github.com/FixMyBerlin/osm-scripts/blob/7c70603210bc4dbf9f334e61f7dedb5da70cb4c4/ZESPlus/utils/transpose/_addLenghtFromOverpassStatsResultToGeoJson.ts to re-add the length as properties to the OSM-ways.

However, that had bad performance. I am now using convert approach described above and use a custom transformation to create GeoJSON from the output.

For this ticket, this also means, that it is not easy to just support the generated JSON since essential info (OSM id and OSM type) are missing by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant