Skip to content

Commit

Permalink
Some osm2lanes patches:
Browse files Browse the repository at this point in the history
- don't use osm2lanes widths yet
- light rail
- rewrite sidewalk=separate
- no shoulders on motorways
  • Loading branch information
dabreegster committed Apr 14, 2022
1 parent f015f06 commit 0bd7daf
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion raw_map/src/lane_specs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<LaneSpec> {
// 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();
}
Expand All @@ -36,6 +57,22 @@ pub fn get_lane_specs_ltr(orig_tags: &Tags, cfg: &MapConfig) -> Vec<LaneSpec> {
.flatten()
.collect::<Vec<_>>();

// 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 {
Expand Down

0 comments on commit 0bd7daf

Please sign in to comment.