From 759c515f8c4a76519a5a80573012fa54c0548942 Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Fri, 5 Apr 2024 16:20:29 +0100 Subject: [PATCH] Improve block classification, by only looking at the lane touching the block, not the entire road --- osm2streets/src/block.rs | 11 ++++------- tests/src/lib.rs | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/osm2streets/src/block.rs b/osm2streets/src/block.rs index fed52354..fb31f8bd 100644 --- a/osm2streets/src/block.rs +++ b/osm2streets/src/block.rs @@ -272,15 +272,12 @@ fn classify_block(streets: &StreetNetwork, boundary: &Vec) -> BlockK let mut has_sidewalk = false; for road_side in boundary { - // TODO All of this logic is wrong. Look at the outermost lane, not the whole road. - let road = &streets.roads[&road_side.road]; - if road.is_driveable() { - // TODO Or bus lanes? + let lt = road_side.get_outermost_lane(streets).lt; + if lt == LaneType::Driving || lt == LaneType::Bus { has_road = true; - } else if road.lane_specs_ltr.len() == 1 && road.lane_specs_ltr[0].lt == LaneType::Biking { + } else if lt == LaneType::Biking { has_cycle_lane = true; - } else if road.lane_specs_ltr.len() == 1 && road.lane_specs_ltr[0].lt == LaneType::Sidewalk - { + } else if lt == LaneType::Sidewalk { has_sidewalk = true; } } diff --git a/tests/src/lib.rs b/tests/src/lib.rs index dd3f18ac..454b18e7 100644 --- a/tests/src/lib.rs +++ b/tests/src/lib.rs @@ -69,7 +69,7 @@ mod tests { } // Manually enable to do diff-testing on blocks. - if true { + if false { let prior_blocks = std::fs::read_to_string(format!("{path}/blocks.json")) .unwrap_or_else(|_| String::new()); std::fs::write(