Search code examples
here-api

HERE API Calculate Route - avoid anything changes router behavior


Problem

If you choose to use avoidArea, exclueCountries or avoidLinks (and probably some more that I wasn't able to test) in your request router enforces fastest route mode.

Given is route from Poland to Germany.

Official testing client: http://refclient.ext.here.com/

First request (no avoids, no excludes, mode:shortest) was:

https://route.api.here.com/routing/7.2/calculateroute.json?app_code=pxIXqdtgOSwQDXSDfjLQpw&app_id=cgZPrYfgRePXzXC3PbBp&jsonattributes=41&language=en-us&legattributes=le&maneuverattributes=po,ti,pt,ac,di,fj,ix&metricsystem=metric&mode=shortest;car&routeattributes=sh&waypoint0=geo!stopOver!53.49012,18.80973&waypoint1=geo!stopOver!53.61957,12.43167

This resulted in a quite straightforward route like below. Route with no avoids

If we add now any country exclusion (e.g. GBR, CHE, CZE) the route is now routed via motorways like fastest mode was enforced.

https://route.api.here.com/routing/7.2/calculateroute.json?app_code=pxIXqdtgOSwQDXSDfjLQpw&app_id=cgZPrYfgRePXzXC3PbBp&avoidseasonalclosures=false&excludecountries=CHE,GBR,CZE&jsonattributes=41&language=pl-pl&legattributes=le&maneuverattributes=po,ti,pt,ac,di,fj,ix&metricsystem=metric&mode=shortest;car&routeattributes=sh,zo&waypoint0=geo!stopOver!53.49012,18.80973&waypoint1=geo!stopOver!53.61957,12.43167

enter image description here

EDIT 1 BEGIN

I checked out the new routing API and results are similar:

Without avoids:

https://route.ls.hereapi.com/routing/7.2/calculateroute.json?apiKey={API_KEY}=41&language=en-us&legattributes=le&maneuverattributes=po,ti,pt,ac,di,fj,ix&metricsystem=metric&mode=shortest;car&routeattributes=sh&waypoint0=geo!stopOver!53.49012,18.80973&waypoint1=geo!stopOver!53.61957,12.43167

enter image description here

With avoids:

https://route.ls.hereapi.com/routing/7.2/calculateroute.json?apiKey={API_KEY}&avoidseasonalclosures=false&excludecountries=CHE,GBR,CZE&jsonattributes=41&language=pl-pl&legattributes=le&maneuverattributes=po,ti,pt,ac,di,fj,ix&metricsystem=metric&mode=shortest;car&routeattributes=sh,zo&waypoint0=geo!stopOver!53.49012,18.80973&waypoint1=geo!stopOver!53.61957,12.43167

enter image description here

On a sidenote, http://refclient.ext.here.com/ doesn't have option to test new API

EDIT 1 END

Question

Why is it happening? Is it designed behavior? If not, when can we expect this to be fixed?


Solution

  • Ok, I've got an answer for you from engineering. I'm rewording a bit so any mistakes/confusion blame me, not him. :)

    So yes, the API here is ignoring your request to use shortest.

    Quote from developer: Specifically in this case, when using "shortest" mode and requesting additional "avoids", routes more than 300km or so are not "good". It does not fall back to "fastest" mode but another mode where "fastest" route shape has more of an influence.

    You mentioned wanting to avoid tolls, be aware that you can ask for that option when calling the API, so that may be a solution for you.

    I hope this helps a bit, and thank you for being patient.