HERE api, How to ignore traffic in all calculations

Viewed 128

At my company, we calculate travel time for jobs based upon a website that gives the distance and time as if the driver was at the speed limit and there is no other traffic on the road. This is a mandatory requirement as the time of the day in which the calculation is done is rarely going to allow traffic patterns to align.

I am working to make the process faster by creating an internal website with a database containing all the relevant addresses. To do this I have written a web app using the HERE routing api in javascript; however, the travel time listed constantly changes despite my setting "'route_mode': 'shortest'" and "'traffic': 'disabled'".

Is there another setting that I have not found that would allow me to completely disregard traffic conditions in all my calculations?

If it helps, here is the function call:

async function get_distance_and_time(origin_coord,des_coord){
var dis;
var time;

var routingParameters = {
  'route_mode': 'fastest',
  'traffic': 'disabled',
  'transportMode': 'car',
  // The start point of the route:
  'origin': origin_coord,
  // The end point of the route:
  'destination': des_coord,
  // Include the route shape in the response
  'return': 'summary'
};

var onResult = await function(result) {
    if (result.routes.length) {
        dis = result.routes[0].sections[0].summary.length;
        time = result.routes[0].sections[0].summary.baseDuration;
        console.log(result.routes[0].sections[0].summary);
        
    }
    
}
var router = await platform.getRoutingService(null, 8);
await router.calculateRoute(routingParameters, onResult,
  function(error) {
    alert(error.message);
  });

var return_data = [dis,time];
return return_data;
1 Answers

BTW:

'route_mode': 'fastest', 'traffic': 'disabled' are incorrect.

Instead of 'route_mode' use please 'routingMode'

The parameter 'traffic' doesn't exist in the Routing API v8


Regarding with https://developer.here.com/documentation/routing-api/8.9.1/dev_guide/topics/use-cases/departure-time.html you can read:

Begin Route At Different Times

The default departure time for a route is the time of the route request. In your request for a route, you can use the departureTime parameter to specify a different time.

A different departureTime will have various effects ranging from different traffic impact to road closures.

If you specify departureTime as any, the route calculation will not take traffic flow and other time-dependent effects into account. This can be useful when it is not certain that you're taking this route at a fixed time.

departureTime=any

that allow you to completely disregard traffic conditions in all your calculations.


Please use our playgrounds:

http://demo.routing.ext.here.com/

http://refclient.ext.here.com/

Related