2

I need to do the following task: to retrieve the road type (highway, bridge, track, pedestrian and others) by coordinates, query a remote service (via HTTP).

I'm looking at the different major solutions available on the web (OpenStreetMap, Google Maps, Bing Maps, HERE Maps, Apple Maps), trying to compare them to better identify their limitations, but I need help completing this list.

At the moment, I just scouted OpenStreetMap service: using OverpassAPI or a 2-queries method: using Nominatim + XAPI

What about the other services?

Google Maps: ??? Bing Maps: ??? HERE Maps: ??? Apple Maps: ???

  • So you are looking for Reverse Geocoding? Most of the API's you list support it but for addresses not roads – Mapperz Apr 22 '15 at 15:42
  • Google Maps json response maps.google.com/maps/api/geocode/… – Mapperz Apr 22 '15 at 15:47
  • Yes, I'm looking for reverse geocoding. What you pasted here is the link to the location (address) retrieved by the service by coordinates. Instead, I need the road type information (e.g.: the road at [23.0043673, 72.5411868999996] is a dirt road). For Google Maps, I found this link which says version 2 is NOT capable to get the information about the road type. Is it still impossible to get in current version 3? – ForzaZanzi Apr 23 '15 at 6:56
2

It probably depend on what you want to do with these informations and on the number of points on which you want apply this.

1) If you have not many points you can maybe try to do this with the overpass API. Trying to get the closest road around your pair of coordinates. It might look like this :

[out:json];
way["highway"~"."](around:5,50.7528080,2.0377858);
out geom;

You can take a small radius (like 1) and increasing it if you dont have result. Depending on what you want to do with your data, but this should provide you the infos you want (if you dont need geometry you can use out; instead of out geom;). It might be useful to have some basics in a scripting language to make the queries (increasing the radius if no result, etc.) and to process the data retrieved (or/and you can use a library like overpy which provide python bindings for the overpass API).

2) If you have many points, maybe you can have a look on the photon project, it's a geocoder based on elasticsearch and nominatim. I think you can make a reverse geocoding request and get the road type (at least the value for the key "highway" and the corresping osm id) with a local instance of this geocoder. The reverse API is not really documented on the main page but here.

Hope that it can help you.

0

It can be done in two steps:

  1. Make a request to: http://osrm.mapzen.com/car/nearest?loc=lat,lon
  2. Make a request to: http://open.mapquestapi.com/nominatim/v1/reverse.php?format=json&lat=lat&lon=lon&addressdetails=1&zoom=18

Examples:

http://osrm.mapzen.com/car/nearest?loc=-25.462418345343607,-49.2237473700912

Returns: [-25.462494,-49.224087] then

http://open.mapquestapi.com/nominatim/v1/reverse.php?format=json&lat=-25.462494&lon=-49.224087&addressdetails=1&zoom=18

0

My solution requires running your own instance of OSRM, but once you have that, you can apply a patch such as this to profiles/lib/way_handlers.lua to hide the road-type in the name (I chose to hide it there by encoding it as json). Then, when you request http://localhost:5000/car/nearest?loc=lat,lon, you will get the road "name" in the response, from which you can extract the type. If you're only interested in the type, you could just skip the json encoding and replace the name with the road type.

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.