Simple is better
When representing junctions (a.k.a. intersections, cross roads, corners, etc.) between roads, we sometimes have to blur the lines between the physical and logical worlds. The primary goal should be to represent things as simply as possible and only introduce complexity to deal with an issue.
The Basics
Lets start with the very basic case of one road branching off from another. Most of the time they will probably meet at close to a 90 degree angle. This is the simplest situation to deal with since the physical and logical views of the roads match up very well.
But you will probably find roads that meet at odd angles as well. Even in urban areas with rigid grids, you will often find at least one road that has existed since prior to the establishment of the grid which cuts through town at strange angles. The initial urge will be to represent the junction as it is in the physical world - two lines running into each other at some angle.
But there are issues with this method. Depending on the angles, the client may give a "Keep Right" instruction to the driver when a "Turn Right" instruction is more appropriate. In some cases, it is even possible the angle may be such that no instruction is given at all. Or worse yet, the routing engine may determine that it isn't possible to make a very sharp angle and not suggest a turn (in the example image, headed south and then turning left to head east).
To eliminate ambiguity, we need to treat the junction from a logical point of view. Since we want to be given basic "Turn Left" and "Turn Right" instructions, we have to treat it like it was a basic 90 degree intersection. But how do we do that when the roads don't actually diverge at 90 degrees? What we need to do is to add some geometry nodes to make the branch road leave the main road at close to 90 degrees, then we gradually curve to match the true departure angle.
Now we have a junction that logically works like a basic 90 degree junction but it also fits the reality of the physical world.
A ramp to a highway is another good example where additional geometry nodes are helpful. Especially since most ramps diverge at a very small angle from the road.
The drawback in this case (which also exists for the side road example above!) is that it may be very hard to see and click on the turn restriction arrows in the editor.
But if we just add one more geometry node to make the departure angle at the junction itself closer to 45 degrees...
...now the arrows are visible and accessible.
We can easily scale the above approaches to a four way junction. Again we can expect to mostly see angles close to 90 degrees.
And if we have that odd street cutting across town at an odd angle, we again want to avoid the odd angle at the junction...
...and we want to use geometry nodes to bring the actual junction to 90 degrees. You can zoom in as close as you can and add a single geometry node on each side. This will give us the proper angle but make it virtually invisible to users so it looks just like the physical world.
The above image is what you would see zoomed in as close as possible. Zoomed back out, it looks just like the image showing the junction without any geometry nodes.
Controlling Turn Instructions
In the Basics section above, we touched on how to ensure a "Turn left/right" instruction would be given over a "Keep left/right" instruction.
Details of the mechanics behind this can be found on the How Waze determines turn / keep / exit maneuvers page, but here is a quick summary.
Geometry
Some of the complexity of the back-end algorithms can be avoided if we try to treat junctions with the logical view in mind as was done in the examples above. If all junctions you edit follow just a few basic forms, it will be much easier to predict the behavior of an individual junction.
- Approximately 90 degree departure angle = Turn
- Less than 45 degree departure angle = Keep (or Exit for Ramps)
This knowledge allows us to control how a junction behaves by modifying a single geometry node in most cases. This is often useful for At-Grade Connectors where sometimes we prefer a "Keep right/left" and other times a "Turn right/left" would be more appropriate.
If we keep the departure angle less than 45 degrees, we would get a "Keep Right" to follow the curved one-way connector:
But if we move one geometry node to create a 90 degree angle, now we would receive a "Turn Right" instruction.
Segment Naming and Type
Besides the geometry of the road segments, the names and types of the segments come into play.
A basic rule of thumb is that if you want a turn to be announced, having a different name will improve the chances that will happen. For the At-Grade Connector example above, the connector should have a different name than the road it is leaving (See the [to name the connector] section of the page on At-Grade Connectors).
Oddities
Offset Roads
Sometimes you will find two roads which cross where one does not quite line up exactly from one side to the other.
There are a few things we need to look at in this situation.
- Do the roads actually line up in reality? If so we need to modify the junction to be a basic 4 way junction.
- Do the roads ALMOST line up in reality? If you were giving instructions to a person and would tell them to go straight with no mention of any slight turn or jog, then we want to make it into a 4 way junction. You may need to "split the difference" and not follow the centerline of either road to achieve this. The angles are exaggerated in this next example to show how the junction is forced to be close to 90 degrees, then we taper to the true centerlines of the roads. In practice this can be much more gradual and/or only done while zoomed in very close.
- Finally, is there a true separation between the roads? Would you need to say for example "turn left then make an immediate right"? If so then we will want to leave the junction such that the two sides do not align. Since we want to avoid very short segments of road, it may be wise to shift the side roads as far apart from each other as possible with them still in the proper location (along the far curb lines for a residential street for example). This will maximize the length of the short segment between the side roads.