I'm running a local OSRM instance with c++. Is there a way to get NodeID for a location specified by Longitudes and Latitudes? Also, for 2 nodeIDs how can I find the distance and duration between the two nodes?
Is there a way to get NodeID for a location specified by Longitudes and Latitudes?
Yes using the nearest
service.
Example: http://router.project-osrm.org/nearest/v1/driving/13.388860,52.517037
Will return:
{"waypoints":[{"nodes":[2264199819,2045820592],"hint":"KRMKgOFPZoYfAAAAOgAAAAsAAAAAAAAAHwAAADoAAAALAAAAAAAAAP3nAAAATMwAqVghAzxMzACtWCEDAQDfCv6mfdg=","distance":4.085340532788629,"name":"Friedrichstraße","location":[13.3888,52.517033]}],"code":"Ok"}
Where the nodes
properties includes the OSM ids.
Also, for 2 nodeIDs how can I find the distance and duration between the two nodes?
There is currently no way to use OSM Node ID directly as input for OSRM. You will have to obtain the coordinate first, maybe using the OSM API?