Skip to content

Commit

Permalink
Improve block classification, by only looking at the lane touching th…
Browse files Browse the repository at this point in the history
…e block, not the entire road
  • Loading branch information
dabreegster committed Apr 5, 2024
1 parent d1e0e8c commit 759c515
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
11 changes: 4 additions & 7 deletions osm2streets/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,12 @@ fn classify_block(streets: &StreetNetwork, boundary: &Vec<RoadSideID>) -> 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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 759c515

Please sign in to comment.