You are not logged in.
- Topics: Active | Unanswered
Announcement
Please create new topics on the new site at community.openstreetmap.org. We expect the migration of data will take a few weeks, you can follow its progress here.***
Pages: 1
#1 2013-09-29 11:31:21
- AndriiArtemenko
- Member
- Registered: 2013-09-29
- Posts: 5
How to find nearest road(API)
Hi people!
I am a java developer and I need to quickly solve the problem. I need to find the nearest road(highway) of the user location(GPS point). This is possible with the OpenStreetMap? I'm tried to read API docs, but have not found anything similar.
Thanks.
Offline
#2 2013-09-29 12:56:56
- rayquaza
- Member

- From: DE-BW
- Registered: 2012-11-18
- Posts: 2,007
Re: How to find nearest road(API)
Offline
#3 2013-09-30 09:35:56
- AndriiArtemenko
- Member
- Registered: 2013-09-29
- Posts: 5
Re: How to find nearest road(API)
Thank you!
I understood that I need to write a query, but it does not work.
<query type="node">
<has-kv k="highway" v="road"/>
<around lat="47.992822" lon="37.80517" radius="1000.0"/>
</query>
<print/>Can you help me?
Offline
#4 2013-09-30 10:07:08
- rayquaza
- Member

- From: DE-BW
- Registered: 2012-11-18
- Posts: 2,007
Re: How to find nearest road(API)
What API are you using? OverpassAPI?
Offline
#5 2013-09-30 14:04:29
- AndriiArtemenko
- Member
- Registered: 2013-09-29
- Posts: 5
Re: How to find nearest road(API)
What API are you using? OverpassAPI?
Yes, I am use http://wiki.openstreetmap.org/wiki/Over … uage_Guide for construct query.
Offline
#6 2013-09-30 16:20:05
- stephan75
- Member
- Registered: 2008-05-28
- Posts: 2,918
Re: How to find nearest road(API)
Thank you!
I understood that I need to write a query, but it does not work.
<query type="node"> <has-kv k="highway" v="road"/> <around lat="47.992822" lon="37.80517" radius="1000.0"/> </query> <print/>Can you help me?
This looks like querying for a NODE which has highway=road ... that will fail!
Because you have to look for WAYS ... and a tag with the key "highway" can have different values, not only "road"
Read much at the OSM wiki, especially at http://wiki.openstreetmap.org/wiki/Elements and http://wiki.openstreetmap.org/wiki/Key:highway
Success?
Offline
#7 2013-10-01 06:44:37
- drolbr
- Member
- Registered: 2013-05-12
- Posts: 59
Re: How to find nearest road(API)
I would like to suggest this one:
(
way
[highway~"^(primary|secondary|tertiary|residential)$"]
[name];
(around:100,47.9928,37.8052)
>;);out;This query in action: http://overpass-turbo.eu/s/19s.
As already mentioned, roads are represented by ways in osm. Roads useful for cars are tagged with highway and one of the values "primary", "secondary", "tertiary", "residential", and so other values probably not applicable to your region. If you would like to include also footways, please add "pedestrian" to the list.
I've added a conditional "[name]" to restrict the result to ways that have a name. This excludes unnamed by-lanes, serviceways, footways and so on. It makes sense when you would like to do something with the name of the road afterwards. Drop this condition if you want also unnamed streets.
The "around" finally has got a smaller radius. It is fine to ask again for the same coordinate with bigger radius if you find nothing, but asking for a whole kilometer in advance will in a city center deliver several metabytes of data. There is unfortunately no "just one element" feature yet, so asking again if the result was empty is the best approximation to this.
Offline
#8 2013-10-01 08:41:54
- AndriiArtemenko
- Member
- Registered: 2013-09-29
- Posts: 5
Re: How to find nearest road(API)
I would like to suggest this one:
Thank you very much!
Offline
#9 2013-10-04 12:03:54
- AndriiArtemenko
- Member
- Registered: 2013-09-29
- Posts: 5
Re: How to find nearest road(API)
Maybe somebody knows the java library for this task?
Offline
#10 2015-03-06 17:26:44
- karussell
- Member
- Registered: 2012-07-26
- Posts: 104
Re: How to find nearest road(API)
If you just need the name and the geometry you can use GraphHopper for this
Update
Ups, sorry for bringing this again up I was just browsing and didn't recognize its that old - feel free to delete this message
Last edited by karussell (2015-03-06 17:30:01)
graphhopper.com route planning for your software
Offline
Pages: 1