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

How can I find the closest way to a point with Overpass API?

1

Hello:

I want to find the closest way to a point defined by its geographic coordinates. I found out Overpass API which gave me a list of ways near a point. But I would like having one and only way.

Thank you.

asked 23 Feb '15, 16:19

osmccecsg's gravatar image

osmccecsg
46224
accept rate: 0%

edited 23 Feb '15, 23:14

aseerel4c26's gravatar image

aseerel4c26 ♦
32.6k18248554

that is the same question (if I assume you mean walkable/driveable "ways") as given-a-lat-lon-is-it-possible-to-find-the-closest-highwaystreet-record (or the linked questions there), isn't it? Update: ah, okay, specifically with Overpass here …

(23 Feb '15, 20:13) aseerel4c26 ♦

One Answer:

3

Sorting based on distance using Overpass API is already discussed in a Github issue, see [1] and [2]. Unfortunately, this feature is not yet available at this time.

I would suggest that you add this use case to the mentioned ticket (i.e. sorting by distance combined with top 1 result), so it doesn't get lost and could be considered for future development.

For the time being, you'd need to use your own logic and post process the Overpass API result to return the closest way only.

answered 23 Feb '15, 22:25

mmd's gravatar image

mmd
5.7k15388
accept rate: 37%

Source code available on GitHub .