0

I have following Overpass api quer that takes the name of the road and give back entire road coordinates

http://overpass-api.de/api/interpreter?data=[out:json][timeout:25];(node["name"="%@"];way["name"="%@"];relation["name"="%@"];);(node["ref"="%@"];way["ref"="%@"];relation["ref"="%@"];);out body;>;out skel qt;

I am using following query to get the name of road from coordinates

http://nominatim.openstreetmap.org/reverse?format=json&lat=%f&lon=%f&zoom=18&addressdetails=1


 NSDictionary *dict = [response JSONValue];
 //NSString *placeId = [dict objectForKey:@"place_id"];
 //NSString *osmId   = [dict objectForKey:@"osm_id"];

 NSDictionary *roadDict = [dict objectForKey:@"address"];
 NSString *roadName = [roadDict objectForKey:@"road"];

Currently i have an example of Roadname @"John F Foran Freeway" using coordinates

[[CLLocation alloc] initWithLatitude:37.731267 longitude:-122.423580];

When i use this roadname in my overpass api. I get no results. Why its not detecting the road? Sometimes on few roadnames it work but mostly it don't recognize the road name. What is wrong?

http://overpass-api.de/api/interpreter?data=[out:json][timeout:25];(node["name"="John F Foran Freeway"];way["name"="John F Foran Freeway"];relation["name"="John F Foran Freeway"];);(node["ref"="John F Foran Freeway"];way["ref"="John F Foran Freeway"];relation["ref"="John F Foran Freeway"];);out body;>;out skel qt;
  • Can you provide an URL with the exact query that fails? – scai Feb 10 '15 at 10:53
  • @scai just replace %@ with John F Foran Freeway. It doesn't give any error, it just return empty set. the query is fine. The road names just don't match. Sometimes they do match but are quite rare. I am not sure where Overpass api is getting names – Muhammad Umar Feb 10 '15 at 17:31
1

You didn't tell us how name and ref are related in your query but in case you want to get all objects with a specific name AND ref value then try this query:

[out:json]
[timeout:25]
;
(
  node
    ["name"="John F Foran Freeway"]
    ["ref"="I 280"];
  way
    ["name"="John F Foran Freeway"]
    ["ref"="I 280"];
  relation
    ["name"="John F Foran Freeway"]
    ["ref"="I 280"];
);
out body;
>;
out skel qt;

You can view the result on overpass turbo.

If you want to get all roads with a specific name OR ref value then use this query instead:

[out:json]
[timeout:25]
;
(
  node["name"="John F Foran Freeway"];
  way["name"="John F Foran Freeway"];
  relation["name"="John F Foran Freeway"];
  node["ref"="I 280"];
  way["ref"="I 280"];
  relation["ref"="I 280"];
);
out body;
>;
out skel qt;

You can view the result on overpass turbo.

But it seems like your reverse geocoding step is unnecessary if you just want to retrieve roads in your current location. Instead of specifying the name of the road just query for all ways with the highway tag in a given bounding box:

[out:json]
[timeout:25]
;
(
  way
    ["highway"]
    (37.79396544487583,-122.3838801383972,37.80200543920775,-122.37458467483522);
);
out body;
>;
out skel qt;

Again, you can view the result on overpass turbo.

See the Overpass API language guide for more information.

  • you didn't get my point. Yes the query is fine. However u have added Ref, Using my reverse geo coding i can only get Road name. THere is no I 280 anywhere using openstreet geocoding – Muhammad Umar Feb 10 '15 at 17:45
  • No I didn't add ref, it is already present in the query from your question. You have to tell us the exact query that is failing for your if the query in your question is not the one you are talking about. – scai Feb 10 '15 at 17:46
  • ok, let me paste it out – Muhammad Umar Feb 10 '15 at 17:48
  • i see i am passing in Ref same values as name. – Muhammad Umar Feb 10 '15 at 17:50
  • please check the edits – Muhammad Umar Feb 10 '15 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.