I’m building a React Native app and having issues with creating routes with the avoid highways setting. Even when there are alternative routes, it still offers up a primarily highway/motorway route. Anyway able to review the code below and see where I’m messing up please?
Thank you very much.
const avoidFeatures = ;if (avoidMotorways) {avoidFeatures.push(‘highways’); // ‘highways’ is the correct value for driving profiles}if (avoidTolls) {avoidFeatures.push(‘tollways’);}
Hi,
Thanks for reaching out! Which openrouteservice instance are you using for querying the routes: openrouteservice public API, or a self hosted one? Please note that there has been a bug in version 9.4.0 that prevented the avoidance of highways. However, the affected version has never been used in the public API, and the bug has been fixed since version 9.5.0.
I’ve skimmed through your code and nothing obvious has caught my eye. The request body seems perfectly fine as well, as I was able to successfully use it to query for routes from a terminal via CURL.
However, for the provided coordinates indeed different routes are being found depending on the "avoid_features":["highways"]} setting, see the attached screens. This is due to algorithmic differences on how the route is being computed depending on the presence or absence of this very setting. In the latter case, a faster algorithm is used that does not take turning restrictions into account, resulting in a faster, albeit incorrect, route. Could this be the difference you are referring to?
Please note that highway avoidance means excluding ways tagged as highway = motorway or highway = motorway-link from routing. There are no such ways in the area in question.