User:PesachZ/algorithm View history

(→‎Best Continuation: replaced street name with segment name and road type with segment type)
(construction box WYSIWYG editor cleanup)
Line 1: Line 1:
A somewhat simplified description of this is covered in the [[Junction Style Guide|Junction Style Guide]]. Additional routing information is covered in the article [[Routing server|Routing server]].
{{Construction|contact=http://www.waze.com/forum/viewtopic.php?f=276&t=91105|contacttype=forum|draft=no|open=no|revision=yes}}
 
A somewhat simplified description of this is covered in the [[Junction Style Guide|Junction Style Guide]]. Additional routing information is covered in the article [[Routing server]].
 
The original text provided by Waze staff which inspired this page (and may be slightly inaccurate) is [[How Waze determines turn / keep / exit maneuvers|preserved here]].


== General comments ==
== General comments ==


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


== Definitions ==
== Definitions ==
Line 9: Line 13:
To better be able to put the algorithm into words, we have to name each of the road segments that connect to a junction. These are ''subjective names'', they are relative to which segment the junction is being approached from, and which segment the routing server wants to navigate to after passing through the junction.
To better be able to put the algorithm into words, we have to name each of the road segments that connect to a junction. These are ''subjective names'', they are relative to which segment the junction is being approached from, and which segment the routing server wants to navigate to after passing through the junction.


Start with the junction in the middle. 
Start with the junction in the middle.  


#'''s-in: '''The segment the vehicle is on as it approaches the junction will be called '''s-in'''.
#'''s-in: '''The segment the vehicle is on as it approaches the junction will be called '''s-in'''.
#'''s-out:&nbsp;'''The segment the vehicle is being routed onto after it passes through the junction will be called '''s-out'''. This can be any of the other segments connected to the junction, which will also be one of the segments named below as <span data-scaytid="85" data-scayt_word="s1">s1</span>, <span data-scaytid="87" data-scayt_word="s2">s2</span>, ... etc..
#'''s-out: '''The segment the vehicle is being routed onto after it passes through the junction will be called '''s-out'''. This can be any of the other segments connected to the junction, which will also be one of the segments named below as s1, s2, ... etc..
#'''<span data-scaytid="86" data-scayt_word="s1">s1</span>, <span data-scaytid="88" data-scayt_word="s2">s2</span>, <span data-scaytid="89" data-scayt_word="s3">s3</span>, <span data-scaytid="90" data-scayt_word="s4">s4</span>, etc.:&nbsp;'''All the segments connected to the same junction, (including s-out) will each be named consecutively as '''<span data-scaytid="91" data-scayt_word="s1">s1</span>, <span data-scaytid="92" data-scayt_word="s2">s2</span>, etc., '''''for as many segments as there are'''''… <span data-scaytid="93" data-scayt_word="sN">sN</span>'''. One of these numbered segments will also be s-out.
#'''s1, s2, s3, s4, etc.: '''All the segments connected to the same junction, (including s-out) will each be named consecutively as '''s1, s2, etc., '''''for as many segments as there are'''''… sN'''. One of these numbered segments will also be s-out.
#'''Best Continuation:&nbsp;'''One of the segments leaving the junction will be considered the 'Best Continuation'. This is the segment that <span data-scaytid="94" data-scayt_word="Waze">Waze</span> determines is what drivers would consider the "no turning path" or "going straight" through the intersection. The criteria <span data-scaytid="95" data-scayt_word="Waze">Waze</span> uses to determine which segment is the 'Best Continuation' is explained below.
#'''Best Continuation: '''One of the segments leaving the junction will be considered the 'Best Continuation'. This is the segment that Waze determines is what drivers would consider the "no turning path" or "going straight" through the intersection. The criteria Waze uses to determine which segment is the 'Best Continuation' is explained below.


[[File:S-in s-out definition.jpg|center|Visulaize how segments are subjectively named in the 'Best Continuation' Algorithm]]
[[File:S-in s-out definition.jpg|center|Visulaize how segments are subjectively named in the 'Best Continuation' Algorithm]]
Line 20: Line 24:
== Best Continuation ==
== Best Continuation ==


In order to determine if s-out is the 'real' continuation of s-in, <span data-scaytid="96" data-scayt_word="Waze">Waze</span> does the following:
In order to determine if s-out is the 'real' continuation of s-in, Waze does the following:


#If s-out has the same segment type & segment name it is selected as the real continuation.
#If s-out has the same segment type & segment name it is selected as the real continuation.
#If not, we look at the other segments: <span data-scaytid="97" data-scayt_word="s1">s1</span>, <span data-scaytid="98" data-scayt_word="s2">s2</span> … <span data-scaytid="99" data-scayt_word="sN">sN</span> (excluding s-out). One of those will be chosen as a better continuation than s-out if both following conditions are met:
#If not, we look at the other segments: s1, s2, sN (excluding s-out). 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 segment name & segment type wise than s-out (e.g.&nbsp;it has the same segment name and s-out doesn't; it has the same segment type as s-in, and s-out doesn't). Segment name is more important than segment type.
#*This segment has a better match segment name & segment type wise than s-out (e.g. it has the same segment name and s-out doesn't; it has the same segment type as s-in, and s-out doesn't). Segment name is more important than segment type.
#*The angle between this segment and s-in is smaller than the angle between s-out and s-in
#*The angle between this segment and s-in is smaller than the angle between s-out and s-in
#If both conditions are not met, then s-out is considered to be the 'best continuation'.
#If both conditions are not met, then s-out is considered to be the 'best continuation'.
Line 32: Line 36:
=== Special Considerations ===
=== Special Considerations ===


*In some situations at a [[Junction Style Guide#Y Intersections|Y-Intersection]] (where there are more than one segment leaving the junction node at less than a 45° angle), navigation to either segment will generate a 'KEEP RIGHT/LEFT" instruction. This will happen if none of the segments leading out at less than 45° are a better match for name or segment type, &nbsp;even if one of those has a departure angle of 0° from s-in. This is also mentioned in the [[Junction Style Guide#Wayfinder Segments|<span data-scaytid="100" data-scayt_word="wayfinder">wayfinder</span> section]].
*In some situations at a [[Junction Style Guide#Y Intersections|Y-Intersection]] (where there are more than one segment leaving the junction node at less than a 45° angle), navigation to either segment will generate a 'KEEP RIGHT/LEFT" instruction. This will happen if none of the segments leading out at less than 45° are a better match for name or segment type, even if one of those has a departure angle of 0° from s-in. This is also mentioned in the [[Junction Style Guide#Wayfinder Segments|wayfinder section]].
*A segment (<span data-scaytid="101" data-scayt_word="s1">s1</span>, <span data-scaytid="102" data-scayt_word="s2">s2</span>, ...sN) leaving the junction which has the turn into it from s-in [[Turn restrictions#Turn restrictions .28allowed turns.29|restricted]] in [[Waze Map Editor|<span data-scaytid="103" data-scayt_word="WME">WME</span>]]&nbsp;''may'' not be considered in this algorithm as a 'best continuation', even if it has&nbsp;a departure angle of 0° from s-in.
*A segment (s1, s2, ...sN) leaving the junction which has the turn into it from s-in [[Turn restrictions#Turn restrictions .28allowed turns.29|restricted]] in [[Waze Map Editor|WME]] ''may'' not be considered in this algorithm as a 'best continuation', even if it has a departure angle of 0° from s-in.


== The algorithm / list of conditions ==
== 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.<br/>The 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.


#If the junction has only 2 segments, the instruction is: ''''CONTINUE''''. <u>''By design the client does not give this instruction.''</u> <!--This is mentioned in [[Update_Requests_in_Waze_Map_Editor#Driven_and_Requested_Routes]] --><br/>In some cases, T junctions could be considered as only 2 segments. See explanation on 'T junctions' below.
The list of conditions:
#If the angle between s-out and the best continuation is larger than 45 and 180&nbsp;degrees, the instruction is: ''''TURN RIGHT''''. This is because we assume that on primary roads (minor highways, major highways and freeways), turn angles 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.
 
#If the junction has only 2 segments, the instruction is: ''''CONTINUE''''. <u>''By design the client does not give this instruction.''</u> <!--This is mentioned in [[Update_Requests_in_Waze_Map_Editor#Driven_and_Requested_Routes]] -->
 
In some cases, T junctions could be considered as only 2 segments. See explanation on 'T junctions' below.
#If the angle between s-out and the best continuation is larger than 45 and 180 degrees, the instruction is: ''''TURN RIGHT''''. This is because we assume that on primary roads (minor highways, major highways and freeways), turn angles 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.
#If s-out is determined to be the best continuation of s-in (see explanation on 'best continuation' above), the instruction is: ''''CONTINUE'''', which implies that the driver is not turning (i.e., going straight through the junction). <u>''By design the client does not give this instruction.''</u> <!--This is mentioned in [[Update_Requests_in_Waze_Map_Editor#Driven_and_Requested_Routes]] -->
#If s-out is determined to be the best continuation of s-in (see explanation on 'best continuation' above), the instruction is: ''''CONTINUE'''', which implies that the driver is not turning (i.e., going straight through the junction). <u>''By design the client does not give this instruction.''</u> <!--This is mentioned in [[Update_Requests_in_Waze_Map_Editor#Driven_and_Requested_Routes]] -->
#If s-in is a primary road and s-out is not a primary road (<span data-scaytid="104" data-scayt_word="mH">mH</span>, MH, FW), the instruction is: ''''EXIT RIGHT''''.
#If s-in is a primary road and s-out is not a primary road (mH, MH, FW), the instruction is: ''''EXIT RIGHT''''.
#If s-in is a ramp/exit and s-out is neither a primary road&nbsp;(<span data-scaytid="105" data-scayt_word="mH">mH</span>, MH, FW), nor a ramp/exit, the instruction is: ''''EXIT RIGHT''''.
#If s-in is a ramp/exit and s-out is neither a primary road (mH, MH, FW), nor a ramp/exit, the instruction is: ''''EXIT RIGHT''''.
#If none of the above conditions is met, the instruction is: ''''KEEP RIGHT''''.
#If none of the above conditions is met, the instruction is: ''''KEEP RIGHT''''.


== T junctions and one way roads ==
== T junctions and one way roads ==


In some cases, a junction node could have more than two segments, but the routing server will only consider two of them as valid and therefore, the maneuver will be 'Continue straight'. This happens when turns into some of the segments are [[Turn restrictions#Turn restrictions .28allowed turns.29|restricted]], the routing server then skips those segments and ingores them when determining the 'Best Continuation'.<br/>Turns can be [[Turn restrictions#Turn restrictions .28allowed turns.29|restricted or unrestricted]]. In specific scenarios you may not be able to see this in [[Waze Map Editor|<span data-scaytid="106" data-scayt_word="WME">WME</span>]] - see&nbsp;[[Reverse connectivity#Reverse Connectivity|<span data-scaytid="107" data-scayt_word="RevCons">RevCons</span>]]&nbsp;for more information.
In some cases, a junction node could have more than two segments, but the routing server will only consider two of them as valid and therefore, the maneuver will be 'Continue straight'. This happens when turns into some of the segments are [[Turn restrictions#Turn restrictions .28allowed turns.29|restricted]], the routing server then skips those segments and ingores them when determining the 'Best Continuation'.
 
Turns can be [[Turn restrictions#Turn restrictions .28allowed turns.29|restricted or unrestricted]]. In specific scenarios you may not be able to see this in [[Waze Map Editor|WME]] - see [[Reverse connectivity#Reverse Connectivity|RevCons]] for more information.


For example, in this case (image below) - assuming the node is restricted properly - heading south, the right turn will be considered 'Continue straight' as the routing server has no other option and there's only one possible segment to be s-out.
For example, in this case (image below) - assuming the node is restricted properly - heading south, the right turn will be considered 'Continue straight' as the routing server has no other option and there's only one possible segment to be s-out.


If the node was not restricted, it is most likely that <span data-scaytid="108" data-scayt_word="Waze">Waze</span> would tell you to turn right. Driving against the direction is a high&nbsp;[[Routing penalties|penalty]], and so is a left turn where a turn is not allowed. However, it would still have been an option, which is why the routing server would have called it 'turn right'.
If the node was not restricted, it is most likely that Waze would tell you to turn right. Driving against the direction is a high [[Routing penalties|penalty]], and so is a left turn where a turn is not allowed. However, it would still have been an option, which is why the routing server would have called it 'turn right'.


https://wiki.waze.com/wiki/images/0/00/Right_turn_1.png
[[File:Right_turn_1.png]]


This could be confusing, especially since there's no external indication on whether or not a node is restricted at the moment. There are external scripts which show this information (and some allow it to be easily corrected) - see&nbsp;[[Reverse connectivity#Reverse Connectivity|<span data-scaytid="109" data-scayt_word="RevCons">RevCons</span>]]&nbsp;for more information.
This could be confusing, especially since there's no external indication on whether or not a node is restricted at the moment. There are external scripts which show this information (and some allow it to be easily corrected) - see [[Reverse connectivity#Reverse Connectivity|RevCons]] for more information.

Revision as of 11:39, 8 June 2014

This revision of the page is currently undergoing modifications. The information and guidance is currently considered accurate enough to be followed now. Content is being prepared by one or more users. Do not make any changes before you post a message in this forum.

A somewhat simplified description of this is covered in the Junction Style Guide. Additional routing information is covered in the article Routing server.

The original text provided by Waze staff which inspired this page (and may be slightly inaccurate) is preserved here.

General comments

The description below fits a right turn in a Right-hand traffic country (e.g. the USA). Left turns are symmetrical to right turns.

Definitions

To better be able to put the algorithm into words, we have to name each of the road segments that connect to a junction. These are subjective names, they are relative to which segment the junction is being approached from, and which segment the routing server wants to navigate to after passing through the junction.

Start with the junction in the middle.

  1. s-in: The segment the vehicle is on as it approaches the junction will be called s-in.
  2. s-out: The segment the vehicle is being routed onto after it passes through the junction will be called s-out. This can be any of the other segments connected to the junction, which will also be one of the segments named below as s1, s2, ... etc..
  3. s1, s2, s3, s4, etc.: All the segments connected to the same junction, (including s-out) will each be named consecutively as s1, s2, etc., for as many segments as there are… sN. One of these numbered segments will also be s-out.
  4. Best Continuation: One of the segments leaving the junction will be considered the 'Best Continuation'. This is the segment that Waze determines is what drivers would consider the "no turning path" or "going straight" through the intersection. The criteria Waze uses to determine which segment is the 'Best Continuation' is explained below.
Visulaize how segments are subjectively named in the 'Best Continuation' Algorithm
Visulaize how segments are subjectively named in the 'Best Continuation' Algorithm

Best Continuation

In order to determine if s-out is the 'real' continuation of s-in, Waze does the following:

  1. If s-out has the same segment type & segment name it is selected as the real continuation.
  2. If not, we look at the other segments: s1, s2, sN (excluding s-out). 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 segment name & segment type wise than s-out (e.g. it has the same segment name and s-out doesn't; it has the same segment type as s-in, and s-out doesn't). Segment name is more important than segment type.
    • The angle between this segment and s-in is smaller than the angle between s-out and s-in
  3. If both conditions are not met, then s-out is considered to be the 'best continuation'.
Flowchart defining the steps the algorithm runs through.
Flowchart defining the steps the algorithm runs through.

Special Considerations

  • In some situations at a Y-Intersection (where there are more than one segment leaving the junction node at less than a 45° angle), navigation to either segment will generate a 'KEEP RIGHT/LEFT" instruction. This will happen if none of the segments leading out at less than 45° are a better match for name or segment type, even if one of those has a departure angle of 0° from s-in. This is also mentioned in the wayfinder section.
  • A segment (s1, s2, ...sN) leaving the junction which has the turn into it from s-in restricted in WME may not be considered in this algorithm as a 'best continuation', even if it has a departure angle of 0° from 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'. By design the client does not give this instruction.

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

  1. If the angle between s-out and the best continuation is larger than 45 and 180 degrees, the instruction is: 'TURN RIGHT'. This is because we assume that on primary roads (minor highways, major highways and freeways), turn angles 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.
  2. If s-out is determined to be the best continuation of s-in (see explanation on 'best continuation' above), the instruction is: 'CONTINUE', which implies that the driver is not turning (i.e., going straight through the junction). By design the client does not give this instruction.
  3. If s-in is a primary road and s-out is not a primary road (mH, MH, FW), the instruction is: 'EXIT RIGHT'.
  4. If s-in is a ramp/exit and s-out is neither a primary road (mH, MH, FW), nor a ramp/exit, the instruction is: 'EXIT RIGHT'.
  5. If none of the above conditions is met, the instruction is: 'KEEP RIGHT'.

T junctions and one way roads

In some cases, a junction node could have more than two segments, but the routing server will only consider two of them as valid and therefore, the maneuver will be 'Continue straight'. This happens when turns into some of the segments are restricted, the routing server then skips those segments and ingores them when determining the 'Best Continuation'.

Turns can be restricted or unrestricted. In specific scenarios you may not be able to see this in WME - see RevCons for more information.

For example, in this case (image below) - assuming the node is restricted properly - heading south, the right turn will be considered 'Continue straight' as the routing server has no other option and there's only one possible segment to be s-out.

If the node was not restricted, it is most likely that Waze would tell you to turn right. Driving against the direction is a high penalty, and so is a left turn where a turn is not allowed. However, it would still have been an option, which is why the routing server would have called it 'turn right'.

This could be confusing, especially since there's no external indication on whether or not a node is restricted at the moment. There are external scripts which show this information (and some allow it to be easily corrected) - see RevCons for more information.