Junction penalties for foot profile

I’m using GH 3.0 as the basis for my application, which helps runners discover new running routes.

One issue I’ve noticed is that routes can be quite complex to follow whilst running, because they include lots of junctions. Often there is a slightly longer route that includes fewer junctions, which would be much easier to follow.

Is there any existing way to assign a penalty to junctions in GH?

My thinking is that if I added a small penalty to junctions, then I might be able to achieve my goal of slightly longer routes but with fewer junctions.

You probably don’t want to avoid junctions you want to avoid turns, I think?

This is currently not possible on two layers:

  • first you have to enable turn restriction support for foot (see e.g. car where this is possible)
  • implement what is a left and right turn and avoid those. See my experiments here: Flexible / Configurable Weighting Update

Avoiding junctions is also not yet possible. Still experiments have shown that this might lead to other problems: Interpret traffic lights · Issue #75 · graphhopper/graphhopper · GitHub

1 Like

Sorry, you’re right, I mean turns. I had avoided using the word “turns” because I know there’s already turn costs in GH, which seem to be specifically for u-turns, but I could be wrong there.

Thanks for the hints, I will experiment with these in the near future, and if I have any joy for foot profiles then I’ll submit a PR.

You don’t necessarily have to enable turn restrictions on the encoder level. You can also try to implement Weighting#calcTurnWeight(int inEdge, int viaNode, int outEdge);. You’d have to write some code to determine whether going from inEdge to outEdge is a ‘turn’ you would like to avoid. The instructions code has some similar logic where where we calculate angles between edges and so on.

2 Likes

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