Problem
I have a route geometry in the format:
- OSM node-1 coordinates
- OSM node-2 coordinates
- OSM node-3 coordinates
- ...
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?
- fyi: The geometries' route is always "connected" by shared way nodes.
e.g.:
- input: geometry = [node102, node103, node104, node303, node304]
- output: wayIds = [way1, way2, way3]
- where way1 is e.g. [node101, node102, node103, node104, node105]
- where way2 is e.g. [node104, node303]
- where way3 is e.g. [node303, node304, node305]
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)Using 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.