Search code examples
here-api

HERE API for dirt road navigation


TLDR

Is it possible to make an app with HERE API/SDK, that will plot car routes on dirt roads as much as possible, and using other/better road types only if there is no other options - like when entering a city?

This is not a questing about how to avoid dirt road in the generated routes. I would like to achieve an exact opposite - use dirt roads as much as possible. Yes, that would be a terribly slow and inefficient route - I'm aware of that.


At first I tried native HERE SDK - but I did not found there any option to prioritize dirt roads. I could only set up to avoid any other road type - which generated routes with 99% of highway/paved roads. Generated route from Alaska geocenter to Texas geocenter had only like 50km of dirt road type, while having thousands km of other road types, mostly highways.


Then, I tried HERE REST API. There is an option to set up a priority/penalty for road type: RouteFeatureWeightType, that can be used to strictExclude, softExclude, and avoid road types. But whenever I set up weight of motorway type to avoid or worse - REST API returns only NGEO_ERROR_GRAPH_DISCONNECTED_CHECK_OPTIONS error.

Example request: https://route.ls.hereapi.com/routing/7.2/calculateroute.json?apiKey=APIKEY&mode=fastest;car;tollroad:-1,motorway:-1,boatFerry:-1,railFerry:-1,tunnel:-1,dirtRoad:0&waypoint0=geo!37.77713,-122.41964&waypoint1=geo!39.76691,-86.14996

Notice -1 weight on everything except dirt road - as I understand, this should avoid any road type except dirt - not strictExclude them, which is a -3 value. I have also tried -2 value with the same error result.


After that, I did some experiments with REST API. My best result was when I changed request vehicle type from car to truck. Not only it was capable of using my initial weight setup without breaking into errors, it was actually not following these huge, multi-lane interstate roads. But that route is following a highway-type road still, even while there is an obvious alternative dirt roads running parallel to highway. Which is possibly a limitation of the truck mode.

Example: https://route.ls.hereapi.com/routing/7.2/calculateroute.json?apiKey=APIKEY&mode=fastest;truck;tollroad:-3,motorway:-3,boatFerry:-2,railFerry:-3,tunnel:-2,dirtRoad:0&waypoint0=geo!37.77713,-122.41964&waypoint1=geo!39.76691,-86.14996


So, is there any options in the HERE REST API/SDK, that allows and prefers generation of obviously ineffective, terribly slow routes with dangerous road angles for cars/trucks?


Solution

  • In general no, there is no option available from the API or SDK which would prefer dirt roads when calculating routes.

    In theory you could block some roads with the feature like avoidArea (in REST API) and dynamic penalty (in Mobile SDK) , of-course this has the downside that you would need to have this areas known before hand.