VIA Waypoints placed on intersections do not have the correct direction instructions

Hello devs !

I’m facing a problem with VIA waypoints for my routing results.

As a router user, I would like to force my route passing through some points.
Any if given VIA waypoints are placed on a intersection or roundabout, I would like to have instructions to keep my way through those waypoints.

Here is an example with Graphhopper Maps of waypoints, placed on intersections. We can see there is no turn instructions.

Here is the POST request for Graphhopper Explorer

{
  "profile": "car",
  "instructions": true,
  "calc_points": true,
  "points_encoded": false,
  "points": [
    [
      4.666282,
      50.395271
    ],
    [
      4.664855,
      50.395102
    ],
    [
      4.664728,
      50.392962
    ],
    [
      4.662106301466996,
      50.392818231570885
    ]
  ]
}

Do you have any idea how to prevent this Graphhopper’s behavior ?

Thanks a lot,
Cheers !

1 Like

Do you have found a solution for this ?

I have the same use case. I need to specify the points I want to pass through, but later in the instructions I didn’t use the waypoints, I just want correct turn instruction

1 Like

@Tatayoyoh / @Clement_BK

I did a few tests using the same coordinates, and I think the behavior might be related to the angle between the way segments around the VIA points.
When the points are placed almost perfectly on a straight line, GraphHopper probably doesn’t detect a significant change in direction so it skips generating an extra “turn” or “continue” instruction.

Out of curiosity, I slightly offset the VIA points by just a few meters, and the instructions appeared as expected:

So it seems the issue could be more geometric than configuration-related.

I might be missing something, but it looks like a small angle threshold effect. Curious to hear what others think!

Hi @Clement_BK and @Dev-Pablo,
Since august I have investigated Graphhopper’s source code and it’s realy simple to understand the behavior happening.

For this explaination example, I want to start from A location, to D final destination. B and C are VIA waypoints given to route request.

The POST request would be someting like

{
  ”profile”: “car”,
  ”points”: [[ A.lon, A.lat] , [B.lon, B.lat] , [C.lon, C.lat] , [D.lon, D.lat]]
  …
}

Each A->B , B->C, C->D is considered as a path. Each of those 3 paths have a final destination point, like D would have, but for A->B and B->C, Destination Instructions are removed and replaced by a VIA Instruction (PathMerge.java through doWork() function)

So obiously, when you start to calculate the next Path Instructions, route algorithm have no idea of the angle of the previous Path because i’ts simply not considered in code (InstructionsFromEdges.java through next() function).

That’s the point !

So like @Dev-Pablo said, if the VIA is some meters AFTER the map’s “turn”, it will be considered in Path Instructions calculation, because it’s part of the Path (between start Path coordinate and final Path coordinate). But if the map’s “turn” IS the VIA point itself (that’s what we want here), it’s at the moment ignored because it’s a Path Destination, and so not an Instruction to calculate because the Path has arrive to it destination. That produce “go strait” > “VIA” > “go strait” instructions.

I’m working on it, I will share some code. We get in touch :+1:

1 Like

@Tatayoyoh

have you seen this discussion ? Add U-Turns #1073
We’ve been exploring improvements around turn instructions and VIA handling there — it might give some context or ideas related to your case.

Thanks for the share !

Studying U-turn at VIA point case should help indeed, I remember comments on this into the code :+1:

1 Like