I’m trying to enable turn costs in my graphhopper index (to see if it makes my routing times more realistic) and I’m a little confused by the docs. I’m happy to submit patches with better language if someone can help me understand it better.
My other confusion is with config-example.yml, this whole section is confusing me
To enable turn-costs in speed mode (contraction hierarchies) edge-based graph traversal and a more elaborate
pre-processing is required. Using this option you can either turn off the edge-based pre-processing (choose ‘off’),
use edge-based pre-processing for all encoders/vehicles with turn_costs=true (choose ‘edge_or_node’) or use node-based
pre-processing for all encoders/vehicles and additional edge-based pre-processing for all encoders/vehicles with
turn_costs=true (choose ‘edge_and_node’).
question: why doesn’t it mention prepare.ch.turn_costs like the docs do?
question: am I supposed to set this to true or on or something else?
question: how is prepare.ch.edge_based relatd to prepare.ch.turn_costs?
Btw ‘enabling turn costs’ currently only means two things:
turn restrictions (like ‘left only’ or ‘no right turn’) from OSM will be respected
u-turns will either be forbidden or there will be a time penalty whenever a route takes a u-turn. note that without turn restrictions there would not be any u-turns anyway
So currently using turn costs does not necessarily lead to more realistic routing times (except the fact that the routes no longer involve forbidden turns). This is something that will hopefully be improved in the future (its mostly a matter of modeling the turn costs and the refactoring needed for this).
Yes there is a query time option: turn_costs=true/false.
Using edge_and_node allows you to choose between edge- and node-based routing on each request. Choosing between the two can be useful, because edge-based allows including turn costs, while node-based is faster.
node+turn_costs is not possible (that is the whole reason why there is edge-based)
Given the other thread about build times, it seems like building node_or_edge+CH for planet.osm is … impractical. I’m at about 48 hours and the graph still has 40 million nodes to go.
If I want to build a global routing index that does take into account turn costs and have it finish in some reasonable amount of time, it seems like I need to try building an index without contraction hierarchies, is that right? Would I want hybrid mode? I’m a little confused by the config-example docs again for this.
See this discussion for differences between open source and hosted version:
The example you are showing does not include a turn restriction, you can try adding an intermediate stop and you will see that the result will be the same route you get locally, but with another estimated time of arrival.
If you want to try the effects of turn restrictions you do not need to build an index at all. Just disable speed or hybrid mode and you can still perform route calculations (they will just be much slower). And yes using hybrid mode would be a compromise between getting the full speed of Contraction Hierarchies and a faster index building time.