Understanding Turn Costs > 1

Hi, I want to enable turn costs for route calculation (using Graphhopper 0.7.0). For now I already used turn restrictions (turn costs = 1).

But how does it work with the costs of left and right turns? Meaning to turn sharp left takes more time than slight left turns.

If I set my CarFlagEncoder(8,1,1) to CarFlagEncoder(8,1,31) to reserve bits for turn costs, nothing changes.
Do I need something else? E.g. feeding the turn cost data myself?

Thanks a lot for your help!

This is currently not implemented. You could add the turn costs on your own to every junction e.g. after import via analyzing a junction.

Okay, do you have any tips what’s the best way to go?

There is already an EncodedValue named turnCostEncoder in AbstractFlagEncoder. Is it the easiest to extend this one?
Or does it make no sense?

And another question regarding this:
One edge has flags describing its properties (weighing, …), right?. And I have to distinguish between left and right turn costs in both directions for one edge. Can I save this information in the flags as well?

No need to fiddle with the encoder. You increase the bits to 3 and then you can add turn cost information for every junction (where you specify which edges are effected). But that requires that you know what left and right is. Have played with this some time ago, can look if I find the source.

Update: see here: Change priority based on turn preference - #4 by karussell

Thanks for your quick response. You mean the turnCost bits like: CarFlagEncoder(8,1,3) ? Yes, would be nice to have some code :slight_smile: … For left and right I thought about comparing the angles like it is done in calcInstructions.

Yes

Sorry, cannot find it where I expected it :frowning:

For left and right I thought about comparing the angles like it is done in calcInstructions.

Yes, but this sounds easier than it is - we would love to have something like this in the core as well. So if you share your findings this would be highly appreciated!