Recommended routing not taking direct route

Using Directions Post (json or geojson) or with just two points with these coordinates the routing goes into highway directly taking a longer route;

[[0.069354, 43.234675], [1.233384, 43.59861]]

But using Graphhopper (or PTV API) with heavy vehicle profile it takes the desired routing;

Note the recommended route for ORS is the longest (both distance and time). Knowing this particular route, I believe a heavy vehicle will never the ORS recommended route.

It seems ORS favors highways for heavy vehicle, sadly highways go with tolls in many countries.

Thus my question: why ORS is suggesting the longest and most inappropriate route for a heavy vehicule as recommended?

hi @hamzarhaiem,

regarding toll roads(tollways): they can easily be avoidedwith ors by using the options.avoid_features parameter or in the client checking the toll roads checkbox (under avoid road types) and you will actually end up with a similar route (altough different travel times, as it is calculated differently)

Regarding the heavy vehicle preferring highways, it is intended to do that (see hgv flagencoder) as it is generally recommended for HGVs to drive on highways when possible (and not e.g. through more rural areas)

If you want to avoid highways you can do exactly as described above for toll roads in both the client and the api.

Still iā€™m not sure that it should make a 23 minute detour for this, comparing these two routes

Mabye someone from the backend could give his opinion on this? @andrzej @takb @adam


The recommended route is based on a heuristic which prioritizes main roads and highways. Occasionally this might result in a longer route, both in terms of distance and time, as in the provided example. Note that the travel time is just an estimate. In this very example the road avoiding the highway seems to be quite windy and include lots of climb, so in practice it might actually take longer to travel than the recommended one taking the highway.

1 Like

Hi @amandus,

Thanks for your reply, could you point the main classes that impact he behavior of routings regarding the usage or avoidance of highway? Are they involved at generation time or at runtime or both?

Hi @andrzej,

Thanks for your reply, in Germany, it is a normal practice to favor highways for trucks, and it has no influence on cost because German highways are free. In France and Spain and Italy, most of highways have tolls, so people use them when the benefit is justified. Say, people are happy with a 50ā‚¬ toll to save one hour but not for a gain limited to a few minutes (this is not a percentage of the total trip, just an absolute time gain).

So without using any WS avoid_tool param at runtime we would like the Direction Service to favor a route with highways when the benefit in distance or/and time is good enough compared to a route without tolls. Would this require yet-another-WS param to define such a benefit ratio? Or should we always invoke the Direction Service twice, a first time without avoid_highway then a second time with it, then compare the time gain?

Hi @hamzarhaiem,

thanks for your feedback! Openrouteservice relies mostly on OSM annotations and these typically include just the information on the type of toll, but not the actual cost. Therefore, the calculation of the cost for a given route is not implemented. At the moment it is not possible to use the cost as an additional parameter which would influence the route calculation.


1 Like

Hi @andrzej,

Note that the price detail is not yet important, however we would like the recommended route to be consistent (not longer in time and distance than a non highway route). We have found out in that a higher weighting is given to highway segments.
Are there other routing influencers to be aware of ? Are they involved at generation time or runtime ?