Pass_through on /navigate/directions to restrict u-turns

Hi there,

I’m working on an Android application that uses Maplibre and Graphhopper to get routes that have multiple waypoints.

I need to ensure that users aren’t recommended to perform u-turns unless necessary. I understand that default behaviour at waypoints is if the most optimal route is to turn around, then it will say to do so. I also know that this can be turned off in the /route endpoint by providing pass_through=true in the params. My app uses /navigate/directions though and it seems to be ignoring this.

If my understanding is correct, the endpoint I’m using forces pass_through to be false in calcRoute at line 179.

putHint(Parameters.Routing.PASS_THROUGH, false);

Is my understanding correct, and is there any alternative that I can use to get my desired behavior?

Thanks!

Yes, your understanding is correct and true can be used to change this behaviour. You could create a pull request to change this (although we would need to set it to true only if it is a motor vehicle profile, for all the other false is probably fine)

Another possibility could be if you are using the POST /navigate endpoint which I proposed recently here. For this request type you have full control from the client side and the response is still mapbox/osrm-alike.

Thank you for confirming.

Given that I’ve been using the Maplibre navigation module I’m not sure that the post method will be easy to move to as I do not directly call the endpoint, rather a builder takes in details and forms the request for me so I would need a function available in that builder to change the request type.

I have a config.yml that enables u-turn costs for the car profile, so if I were to make a pull request I’d like to make this functionality available via a param or a server config.