How do I find the road distance between two locations? - here-api

I am using HERE Developer API key. I want to calculate the road distance between 2 lats & longs. Can anybody help me on this with PHP code.

When using the Routing API, if you ask for summary or travelSummary in the result, you get a length result which is in meter. For example:
"travelSummary": {
"duration": 20973,
"length": 619962,
"baseDuration": 20316
},

Related

How to interpret "nearest source location" in the cumulativeCost-function of Google Earth Engine?

I am wondering what the documentation of cumulativeCost() in GEE exactly means by "nearest source location".
"nearest" in terms of "the closest starting pixel, linearly computed" or
"nearest" in terms of "the closest in terms of cumulative cost" ?
For my analysis I would like to know if the algorithm already reduces the number of potential routes in advance (by choosing only 1 starting point in advance) OR if it first tries the routes from one pixel to all possible starting points, and then takes the value to the starting pixel with the lowest total cost. Does anyone have more detailed information on how the algorithm works in that case? Thanks.

HereAPI inconsistent cost matrix result for the same locations pair from/to

We experience different/inconsistent results calling HereAPI calculate matrix:
https://developer.here.com/documentation/routing/dev_guide/topics/resource-calculate-matrix.html
Those two requests would get different results getting the cost matrix (https://matrix.route.api.here.com/routing/7.2/calculatematrix.json) for the location pair:
from: start2=[49.5874311604988,6.36225600752937]
to: destination4=[49.6199640866961,6.0752615082501]
req1Params =
{app_id=[abc], app_code=[xxx], mode=[fastest;truck;traffic:disabled], summaryAttributes=[traveltime,costfactor,distance], limitedWeight=[3.5], height=[2.815], width=[2.426], length=[6.945], start0=[49.99432,6.09711], start1=[50.04874,6.11873], start2=[49.5874311604988,6.36225600752937], start3=[50.1567001905827,6.0488119628559], start4=[49.6199640866961,6.0752615082501], start5=[50.05481,6.02723], destination0=[49.99432,6.09711], destination1=[50.04874,6.11873], destination2=[49.5874311604988,6.36225600752937], destination3=[50.1567001905827,6.0488119628559], destination4=[49.6199640866961,6.0752615082501], destination5=[50.05481,6.02723]}
matrix result for start2 -> destination4:
{"startIndex":2,"destinationIndex":4,"summary":{"distance":41400,"travelTime":3136,"costFactor":3176}}
req2Params =
{app_id=[abc], app_code=[xxx], mode=[fastest;truck;traffic:disabled], summaryAttributes=[traveltime,costfactor,distance], limitedWeight=[3.5], height=[2.815], width=[2.426], length=[6.945], start0=[49.630539,6.13332], start1=[49.8302,5.84841], start2=[49.5874311604988,6.36225600752937], start3=[49.8503553810064,6.12768609880935], start4=[49.6199640866961,6.0752615082501], start5=[49.84435496244089,6.0966557264328], start6=[49.85112,6.09573], destination0=[49.630539,6.13332], destination1=[49.8302,5.84841], destination2=[49.5874311604988,6.36225600752937], destination3=[49.8503553810064,6.12768609880935], destination4=[49.6199640866961,6.0752615082501], destination5=[49.84435496244089,6.0966557264328], destination6=[49.85112,6.09573]}
matrix result for start2 -> destination4:
{"startIndex":2,"destinationIndex":4,"summary":{"distance":30737,"travelTime":2122,"costFactor":2162}}
Has someone experienced something similar? Is it a bug or can someone explain why we have those inconsistent results?
update: add response details.
The underlying algorithm is using heuristic which drives search depending on the number of start/destinations. Different matrix sizes may give different results and this is expected. We are not able to ensure the same results for different sizes of matrices until we use this heuristic.
If you shorten a bit distance, the route will lead through different segments. This is because short distance may render more precise search in this case.

Is it possible to retrieve duration of less than 1 second from the Google Maps Distance Matrix API?

I'm trying to reduce uncertainty when using the Google Maps Distance Matrix API to extract journey time and distance data between a start and end node on the road network to calculate average speeds over fairly short distances (30m to 500m).
I am using the Python Googlemaps library
The standard journey time provided by the API is at 1 second i.e. integer resolution. Does anyone know if there is a command to extract the journey time at a finer temporal resolution of e.g 0.1 seconds when calling journey distance and duration data from the API?
According to the "unit systems" section in the API documentation,
duration: The length of time it takes to travel this route, expressed in seconds (the value field) and as text. The textual representation is localized according to the query's language parameter.
There are no Required or Optional parameters that can change this setting to return values expressed as fractions of a second.

Usa calculate Tolls cost using here maps

Using this example https://developer.here.com/documentation/toll-cost/topics/example-tollcost.html
and description from here https://developer.here.com/documentation/toll-cost/topics/resource-tollcost-input-interface.html trying to calculate tolls on usa roads
First found paid road to be sure to have it on the route - found here https://www.sixt.com/toll-roads/usa/ - rout in Florida from Punta Gorda, FL, United States to Islamorada, FL, United States
From route received two links
0: {linkId: "-91500228", mappedPosition: {latitude: 26.9336687, longitude: -82.0531188},…}
1: {linkId: "+897488196", mappedPosition: {latitude: 24.9598652, longitude: -80.5699824},…}
Then do tolls request
https://tce.api.here.com/2/tollcost.json
?app_id=my_app_id
&app_code=my_code
&tollVehicleType=3
&vehicleNumberAxles=2
&emissionType=6
&height=3.5m
&vehicleWeight=10.0t
&limitedWeight=10.0t
&passengersCount=1
&tiresCount=8
&route=-91500228;897488196
&detail=1
In response always receive:
{"errors":[],"warnings":[{"category":1,"context":"Old response format is deprecated, please use request parameter &rollup"}],"countries":[],"onError":false}
Tried different locations in usa, no matter what - always empty countries array
Please advice what I'm missing, thank you
Here is a working example:
https://tce.cit.api.here.com/2/calculateroute.json?jsonAttributes=41&waypoint0=26.13442,-81.68696&detail=1&waypoint1=26.08104,-80.36682&routelegattributes=li&routeattributes=gr&maneuverattributes=none&linkattributes=none,rt,fl&legattributes=none,li,sm&currency=EUR&departure=&tollVehicleType=3&emissionType=5&height=3.8m&vehicleWeight=11000&limitedWeight=11t&passengersCount=1&tiresCount=4&commercial=1&heightAbove1stAxle=1m&width=2.55&length=10&mode=fastest;truck;traffic:enabled&rollup=none,country;tollsys&app_id=yyy&app_code=xxx
In general is the parameter rollup missing in your request. This one need to be added in any case. Besides of that is the route you try to calculate quite far over islands with a truck with a specific size and weight. It is quite difficult to get an idea within the pure HTTPRest request. Maybe this demo page helps a bit for debugging such cases:
https://tcs.ext.here.com/examples/v3/route_with_tce

here-api matrix route summary is different than the one you get when calling getroute with the same routeId - why is that?

I'm calling the matrix routing API:
https://matrix.route.api.here.com/routing/7.2/calculatematrix.json?app_id=my_app_id&app_code=my_app_code&start0=41.63146,-87.619662&destination0=41.905806,-87.630023&mode=fastest;car;traffic:disabled&matrixAttributes=summary&summaryAttributes=traveltime,distance,routeId&departure=2018-08-13T06:47:30-05:00
and getting a distance of 41698, and the routeId if I want to see further details on this route:
{"summary":{"distance":41698,"travelTime":2471,"costFactor":2511,"routeId":"AIEACAAAAB4AAABaAAAAmgAAAJ8AAAB42mOYz8DAxMQABKeCNzquODYrlgEKcibcFHVjFLJh+P8fIvBhPwMS4ALiyy4nXJgY3hWsd5TecQauMfvCHdHzvHg1XmB8spIRaDFccMeSjE9TQQxFB6YGhhRGCUd/JgMQv4EJADjbIRoCEs8U"}}
I then call get getroute with the routeId I got:
https://route.api.here.com/routing/7.2/getroute.json?app_id=my_app_id&app_code=my_app_code&routeId=AIEACAAAAB4AAABaAAAAmgAAAJ8AAAB42mOYz8DAxMQABKeCNzquODYrlgEKcibcFHVjFLJh+P8fIvBhPwMS4ALiyy4nXJgY3hWsd5TecQauMfvCHdHzvHg1XmB8spIRaDFccMeSjE9TQQxFB6YGhhRGCUd/JgMQv4EJADjbIRoCEs8U
and now I get a distance of 38650:
"summary":{"distance":38650,"trafficTime":5066,"baseTime":2401,"flags":["tunnel","motorway","builtUpArea"],"text":"The trip takes <span class=\"length\">38.7 km</span> and <span class=\"time\">40 mins</span>.","travelTime":2401,"_type":"RouteSummaryType"}}
is this the expected behaviour? why?
MxN Matrix Routing and 1xN Routing are not using same algorithm thus you won’t get exact same result.
Matrix Routing is doing some local “simplification” to go faster in computing the whole matrix.

Resources