This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

Getting the Id of a Way from coordinates and inserting into another query

-1

Hello, I am making an application that uses the Overpass API.

I want a query that returns the roads for any given way that connect to that road.

Is there a way to retrieve a single way id for a given coordinate/ boundary box, then storing this in a variable and running it in another query?

Here is an example query:

way(4419793);
(way(around:0)[highway~"."][highway!~"path|track|cycleway|footway|service|residential|bridleway"];(._;>;))->.a;
(way(around:0)[highway~"."][highway!~"unclassified|path|track|cycleway|footway|residential|service|bridleway"];(._;>;))->.b;
(way(around:0)[highway~"."][highway!~"unclassified|path|track|cycleway|footway|residential|service|bridleway"];(._;>;))->.c;
(way(around:0)[highway~"."][highway!~"unclassified|path|track|cycleway|footway|residential|service|bridleway"];(._;>;))->.d;
(.a;.b;.c;.d;);out;

What I want to do is find a way to get the way id automatically from a bounding box/ pair of coordinates and run the new query in the form:

.var =  (node(51.249,7.148,51.251,7.152);<;);out;

way(.var);

(and the .var contains the first returned way id for example) ....

Cheers.

This question is marked "community wiki".

asked 23 May '14, 16:09

gmeister4's gravatar image

gmeister4
608812
accept rate: 0%

edited 23 May '14, 18:39

tyr_asd's gravatar image

tyr_asd
1.2k51927

Source code available on GitHub .