From 8ceaf296ebed015865626ab4256f5dcb08226be8 Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Thu, 27 May 2021 10:09:22 -0700 Subject: [PATCH] Allow u-turns at merged intersections when the turn lane is explicitly tagged in OSM. This makes the infamous U-turn from Montlake to 520 WB work! The inferred signal timing isn't great, but ah well. Not regenerating yet --- map_model/src/make/turns.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/map_model/src/make/turns.rs b/map_model/src/make/turns.rs index c94a8dfa1e..714bebb375 100644 --- a/map_model/src/make/turns.rs +++ b/map_model/src/make/turns.rs @@ -37,8 +37,19 @@ pub fn make_all_turns(map: &Map, i: &Intersection) -> Vec { if i.merged { filtered_turns.retain(|turn| { if turn.turn_type == TurnType::UTurn { - warn!("Removing u-turn from merged intersection: {}", turn.id); - false + let src_lane = map.get_l(turn.id.src); + // U-turns at divided highways are sometimes legal (and a common movement -- + // https://www.openstreetmap.org/way/361443212), so let OSM turn:lanes override. + if src_lane + .get_lane_level_turn_restrictions(map.get_r(src_lane.parent), false) + .map(|set| !set.contains(&TurnType::UTurn)) + .unwrap_or(true) + { + warn!("Removing u-turn from merged intersection: {}", turn.id); + false + } else { + true + } } else { true }