maps: route over motorway/trunk/primary _link ramps in graph ingest
- Commit
58845a56fc3a9530199ac0ba58b4177ea2ba26ee- Author
- vayun-mathur <[email protected]>
- When
- 2026-10-25 00:39 UTC (1 month ago)
- Parents
12ecab9
Diff
scripts/maps/osm_ingest/src/roads.rs
diff --git a/scripts/maps/osm_ingest/src/roads.rs b/scripts/maps/osm_ingest/src/roads.rsindex 5b11ddd5b1..5964ad517c 100644--- a/scripts/maps/osm_ingest/src/roads.rs+++ b/scripts/maps/osm_ingest/src/roads.rs@@ -93,10 +93,8 @@ pub struct RoadTags<'a> { /// /// A slip road IS its parent class as far as drawing goes -- it is the same asphalt at /// the same width, and a map that omits interchange ramps has holes in every-/// motorway junction. [`crate::tags::get_hw_id`] has no id for one, and cannot be-/// given one: those numbers are an on-disk contract with-/// `maps/src/main/rust/src/graph.rs` and renumbering them would reinterpret every-/// edge in an already-built graph. So the suffix is dropped here instead.+/// motorway junction. [`crate::tags::get_hw_id`] maps the five real `*_link` values+/// itself; stripping here as well keeps the parent check for any other suffix. pub fn base_highway(value: Option<&str>) -> Option<&str> { let v = value?; Some(v.strip_suffix("_link").unwrap_or(v))
scripts/maps/osm_ingest/src/tags.rs
diff --git a/scripts/maps/osm_ingest/src/tags.rs b/scripts/maps/osm_ingest/src/tags.rsindex 66f3c23694..f369af65e3 100644--- a/scripts/maps/osm_ingest/src/tags.rs+++ b/scripts/maps/osm_ingest/src/tags.rs@@ -24,13 +24,18 @@ pub const LANE_MERGE_TO_RIGHT: u16 = 1 << 10; /// Road type number for a `highway=*` value; 0 means "not a routable road", and /// such ways are skipped entirely.+///+/// A `*_link` slip road takes its parent's number. Without that every motorway+/// interchange ramp was dropped from the routing graph, so changing freeways+/// meant leaving them on surface roads (I-15 to I-70 at Cove Fort routed over+/// Fremont Canyon Road, 173 km instead of ~110 km). pub fn get_hw_id(value: Option<&str>) -> u8 { match value.unwrap_or("") {- "motorway" => 1,- "trunk" => 2,- "primary" => 3,- "secondary" => 4,- "tertiary" => 5,+ "motorway" | "motorway_link" => 1,+ "trunk" | "trunk_link" => 2,+ "primary" | "primary_link" => 3,+ "secondary" | "secondary_link" => 4,+ "tertiary" | "tertiary_link" => 5, "unclassified" => 6, "residential" => 7, "service" => 8,@@ -334,6 +339,10 @@ mod tests { assert_eq!(get_hw_id(Some("motorway")), 1); assert_eq!(get_hw_id(Some("steps")), 15); assert_eq!(get_hw_id(Some("residential")), 7);+ // Slip roads are routable as their parent class.+ assert_eq!(get_hw_id(Some("motorway_link")), 1);+ assert_eq!(get_hw_id(Some("tertiary_link")), 5);+ assert_eq!(get_hw_id(Some("raceway_link")), 0); // Unroutable / absent -> 0, which makes the caller skip the way. assert_eq!(get_hw_id(Some("proposed")), 0); assert_eq!(get_hw_id(Some("")), 0);