Turn cost on via road

Hi

I wonder if anyone can advise, I have run into an issue where for many roads that have an island in the middle of the road the routing engine is able to perform u-turns because from the data’s perspective it is simply performing a right and then a right. see below example.

I would like to block this behavior using custom weighting or custom turn costs but the weighting and turns costs only have the current edge and the previous edge, not the current edge and the two previous ones that would be needed to bloc this kind of behavior.

Does anyone have any advice on how I could go about blocking this?

GraphHopper does special preprocessing of the graph (it adds artificial edges) for these cases, but only if there is a no-u-turn restriction relation. Handling this dynamically during query time would be very hard (unless you do not use CH). So if your data source does not have explicit u-turn restrictions for these junctions the easiest thing you can do would be adding them before importing the graph.

Thank you @easbar, we are looking into preprocessing on our data to add these restrictions,

just to confirm if we add a via restriction, i.e. a u-turn restriction from way A to way B via way C, into our data then graphopper will respect these?

Yes, if you use a recent version of GraphHopper (version 7.0 or higher, and this feature was extended to multiple via-ways in 10.0) and turn costs are enabled for your profile, of course.