# Difference between revisions of "Routing penalties/Controlling U-turn penalties"

Line 12: | Line 12: | ||

U-turns via a median segment are heavily [[Routing penalties|penalized]] when all three of the conditions below are met. This prevents U-turns at box- (#) and H-style intersections on divided highways and parallel roads. | U-turns via a median segment are heavily [[Routing penalties|penalized]] when all three of the conditions below are met. This prevents U-turns at box- (#) and H-style intersections on divided highways and parallel roads. | ||

− | # The forbidden U-turn is composed one incoming segment, one median segment, and one outgoing segment. | + | # The forbidden U-turn is composed of one incoming segment, one median segment, and one outgoing segment. |

# The length of the median segment is shorter than 15 m (49 feet). | # The length of the median segment is shorter than 15 m (49 feet). | ||

# The portion of those two segments closest to the median segment must be [[#Checking for parallel segments|within ±5° of exactly parallel]]. | # The portion of those two segments closest to the median segment must be [[#Checking for parallel segments|within ±5° of exactly parallel]]. |

## Revision as of 12:54, 17 August 2015

### Median U-turn penalty

For the latest discussion on this section please visit the wiki forum thread. |

It is possible for this method to fail to prevent a U-turn when it is the first segment of a route or reroute. If you observe this method to fail when it is implemented properly, please report it in this forum thread |

The Waze routing algorithm assesses a penalty for a double-left turn in right-hand traffic countries and a double-right in left-hand traffic countries.

#### Preventing median U-turns

U-turns via a median segment are heavily penalized when all three of the conditions below are met. This prevents U-turns at box- (#) and H-style intersections on divided highways and parallel roads.

- The forbidden U-turn is composed of one incoming segment, one median segment, and one outgoing segment.
- The length of the median segment is shorter than 15 m (49 feet).
- The portion of those two segments closest to the median segment must be within ±5° of exactly parallel.

#### Allowing median U-turns

To allow a U-turn through a median, ensure that any one of the above criteria are broken:

- To allow the median U-turn in both directions, it is simplest to make the median segment longer than 15 meters.
*(Breaking condition #2)* - To allow the U-turn in only one direction, it is simplest to adjust the turn angles in only for the segments of the allowed U-turn so they are wider than the ±5° allowance of exactly parallel. This is easily achieved without affecting the overall look of the map using a Micro-dogleg.

#### Checking for parallel segments

A convenient way to check if the two side segments are parallel is to use another segment as a reference tool. If the median segment has no geometry nodes, it can be the reference segment. Otherwise you can draw a new segment as a reference tool with no geometry which connects the A and B nodes of the median segment. *The reference segment can be deleted after the check is complete, if appropriate.*

Check two angles:

- X — the angle between the incoming one-way segment and the reference segment
- Y — the angle between the outgoing one-way segment and the reference segment.

If the sum of these two angles is within 5° of 180° (between 175-185°), then the roads are considered parallel.

In the example below, angle X is 102°, and angle Y is 75°. The sum is 177°, which is within 3° of 180°. Therefore these roads are considered parallel.