Use weighting: curvature and custom

How would i configure the config.yaml to use the curvature weighting and be able to on a per request basis avoid for example tolls or ferries? As i understand the docs this is not possible without modifying the java. https://github.com/graphhopper/graphhopper/blob/master/docs/core/profiles.md. My question would be am i understanding it correctly? And if so how would i need to modify it?

To avoid tolls or ferries per request you can use custom weighting. For example with this custom model:

{
  "priority": [
     {
        "if": "road_environment == FERRY",
        "multiply_by": 0.05
     }
  ]
}

But obviously if you are using curvature weighting you cannot use custom weighting. If you want to keep using the curvature weighting and avoid ferries/tolls you need to get a reference to the road environment (and toll) encoded values in CurvatureWeighting.java (just like we do for the road access encoded value in FastestWeighting) and use to adjust the edge weights. You will have to create separate weightings that avoid toll/ferry and use different names for them (like “curvature_avoid_toll_weighting” etc.). Then add them to DefaultWeightingFactory and create a profile for each.

The other approach would be using custom weighting and use the motorcycle$curvature encoded value in your custom model, but you will only be able to multiply the priority with a constant factor based on the curvature value. You cannot use the curvature value on the right hand side of the equation, yet. There is no log function as it is used in curvature weighting yet either.

Btw @karussell did some work towards right-hand side encoded values in custom models in this branch: https://github.com/graphhopper/graphhopper/tree/variable_rhs

The other approach would be using custom weighting and use the motorcycle$curvature encoded value in your custom model,

We should probably make this encoded value a standalone EncodedValue, otherwise one would have to enable motorcycle only to use this value. And this might be very useful not only to motorcylces or bicycle (where you would likely prefer these roads) but also for large trucks where you would probably try to avoid or even exclude them.

Thanks for the answers!
I think i will try use the customWeighting and add curvature as a EncodedValue. And maybe later try to implement the branch https://github.com/graphhopper/graphhopper/tree/variable_rhs to have a more accurate value. Is the variable_rhs branch fully functional or just a start? @karussell

For my specific case it worked at that time - so you tell me :wink:

The main problem why it isn’t merged yet is that the landmark algorithm has a special property which can be violated with this feature and so it is only available on the server-side. (with a bit effort it can be made available for at least the A* algorithm and with a bit more effort the landmark property can be checked)

Update: the branch is now called text_value_rhs and close to be mergable.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.