From 0bd7daf73423bb3de51d46c5d9a5646bf7c8291e Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Thu, 14 Apr 2022 08:44:35 +0100 Subject: [PATCH] Some osm2lanes patches: - don't use osm2lanes widths yet - light rail - rewrite sidewalk=separate - no shoulders on motorways --- raw_map/src/lane_specs.rs | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/raw_map/src/lane_specs.rs b/raw_map/src/lane_specs.rs index 49c4aa08d0..74509aaa46 100644 --- a/raw_map/src/lane_specs.rs +++ b/raw_map/src/lane_specs.rs @@ -7,11 +7,32 @@ use geom::Distance; use crate::{Direction, DrivingSide, LaneSpec, LaneType, MapConfig}; pub fn get_lane_specs_ltr(orig_tags: &Tags, cfg: &MapConfig) -> Vec { + // Special cases first + if orig_tags.is_any("railway", vec!["light_rail", "rail"]) { + return vec![LaneSpec { + lt: LaneType::LightRail, + dir: Direction::Fwd, + width: LaneSpec::typical_lane_widths(LaneType::LightRail, orig_tags)[0].0, + }]; + } + let mut tags = osm2lanes::tag::Tags::default(); for (k, v) in orig_tags.inner() { - // Workaround common incorrect tagging if k == "sidewalk" && v == "none" { + // Workaround common incorrect tagging tags.checked_insert("sidewalk", "no").unwrap(); + } else if k == "sidewalk" && v == "separate" && cfg.inferred_sidewalks { + // Make blind guesses + let value = if orig_tags.is("oneway", "yes") { + if cfg.driving_side == DrivingSide::Right { + "right" + } else { + "left" + } + } else { + "both" + }; + tags.checked_insert("sidewalk", value).unwrap(); } else { tags.checked_insert(k.to_string(), v).unwrap(); } @@ -36,6 +57,22 @@ pub fn get_lane_specs_ltr(orig_tags: &Tags, cfg: &MapConfig) -> Vec { .flatten() .collect::>(); + // No shoulders on unwalkable roads + if orig_tags.is_any( + crate::osm::HIGHWAY, + vec!["motorway", "motorway_link", "construction"], + ) || orig_tags.is("foot", "no") + || orig_tags.is("access", "no") + || orig_tags.is("motorroad", "yes") + { + result.retain(|lane| lane.lt != LaneType::Shoulder); + } + + // Use our own widths for the moment + for lane in &mut result { + lane.width = LaneSpec::typical_lane_widths(lane.lt, orig_tags)[0].0; + } + // Fix direction on outer lanes for (idx, lane) in result.iter_mut().enumerate() { if lane.lt == LaneType::Sidewalk || lane.lt == LaneType::Shoulder {