Geographic Information Systems Asked on November 1, 2021
Problem
I have a route geometry in the format:
And I need to know which OSM ways were "used" by the route.
Question
Is there an Overpass query which can return me the ways which are required to "form" the route geometry with one request?
e.g.:
Context
I’m using a routing API which only returns the Geometry of the Route (OSM node coordinates) but no ids.
The problem is that I need to know which OSM ways were used to construct this route.
What I’ve tried so far
I can get all the node id from the node coordinates using node(around:0,lat,lon)
Thanks to this I can get the ways which contain a set of nodes using
node(around:0,latNode1,lonNode1,latNode2,lonNode2)->.allnodes;
way(bn.allnodes)->.ways;
foreach .ways -> .singleway (
node.allnodes(w.singleway);
way.singleway(bn)(if:count(nodes) == allnodes.count(nodes));
out geom;
);
Unfortunately I don’t know how many nodes of a way were used by the route. Right now I only can think of:
a. find all ways for node1, node2
b. if more than one way found –> add another node to (a) and try again
c. when I found the way, search the next way with the geometries next node pair which is not part of the way I just found (i.e. continue with (a))
But this approach would require me to make many request to the Overpass API. I can’t figure out how to write this logic as Overpass Query. I’m running my own overpass server.
The solution I picked was:
map-match the route (again) with Valhalla Map-Matching mode trace_attributes
and algorithm shape_match:edge_walk
The edge_walk
algorithm takes into account that the input route was already matched close to the OSM ways.
This mode returns the way ids used by the matched route.
With these wayIds I can query Overpass with one simple, fast query to get all the other way data for all ways: way(id:1, 2, 3, 4, ...)
Answered by hb0 on November 1, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP