# Changes

## Conversations

, 5 years ago
Replacing page content with new draft information a/p http://www.waze.com/forum/viewtopic.php?f=276&t=91105
A somewhat simplified description of this is covered in the [[Junction_Style_Guide#Controlling_Turn_Instructions|Junction Style Guide]]. Additional routing information is covered in the article [[Routing server]].

The description below fits a right turn in a [[right-hand traffic]] country (e.g. not England). Left turns are symmetrical to right turns.

== Definitions ==

* s-in: the segment going into the junction; this is the segment the driver is on before reaching the junction
* s-out: the segment going out of the junction; this is the segment we want the driver to traverse to
* s1, s2 … sN: all the segments connected to the same junction, which includes s-out
* Best continuation is one of the segments, and is the one that Waze determines is what drivers would consider the "no turning path" through the intersection - see expanded description below

== What is the 'best continuation'? ==

In order to determine if s-out is the 'real' continuation of s-in, we do the following:
* if s-out has the same road type & street name it is selected as the real continuation.
* if not, we look at the other segments: s3, s4 … sN. One of those will be chosen as a better continuation than s-out if both following conditions are met:

:* this segment has a better match street name & road type wise than s-out (e.g. it has the same street name and s-out doesn't; it has the same road type as s-in, and s-out doesn't). Street name is more important than road type.
:* the angle between this segment and s-in is smaller than the angle between s-out and s-in

== The algorithm / list of conditions ==

The algorithm iterates over a list of conditions. As soon as a condition is met, the relevant instruction is determined, and the algorithm terminates.

The list of conditions:

1. if the junction has only 2 segments, the instruction is: 'CONTINUE'.

1.1. In some cases, T junctions could be considered as only 2 segments. See explanation on 'T junctions' below.

2. if the angle between s-out and the best continuation is larger than 45 degrees (and less than 180), the instruction is: 'TURN RIGHT' - this is because we assume that on primary roads (minor highways, major highways and freeways), turn angles which are no more than 45 degrees (no sharp turns on higher-throughput roads); therefore, you never have something called an "exit" that has such an angle, and the instruction should be TURN, not EXIT

3. if s-out is determined to be the best continuation of s-in (explanation on 'best continuation' above), the instruction is: 'CONTINUE', which implies that the driver is not turning (i.e., going straight through the junction)

4. if s-in is a primary road and s-out is not a primary road, the instruction is: 'EXIT RIGHT'

5. if s-in is a ramp/exit and s-out is neither primary nor ramp/exit, the instruction is: 'EXIT RIGHT'

6. if none of the above conditions is met, the instruction is: 'KEEP RIGHT'

== T junctions and one way roads ==

In some cases, a node could have more than 2 segments, but the routing server will consider only 2 of them as valid and therefore, the maneuver will be 'Continue straight'.