When tracing perimeters, allow doubling back at a dead-end with exactly

1 lane (usually a cycleway or footway). This correctly produces a few
more blocks in some maps -- as the goldenfile diff (and manual
verificaton) shows!

Also allow jumping from LTN browse to debug mode, to conveniently work
on blockfinding problems.
This commit is contained in:
Dustin Carlino 2022-01-06 10:16:11 +00:00
parent 5caccf6aab
commit 2356cee1db
4 changed files with 21 additions and 20 deletions

View File

@ -3,12 +3,13 @@ use geom::Distance;
use map_gui::tools::{CityPicker, DrawRoadLabels, Navigator, URLManager};
use widgetry::mapspace::{World, WorldOutcome};
use widgetry::{
Color, EventCtx, GfxCtx, HorizontalAlignment, Key, Outcome, Panel, State, TextExt,
lctrl, Color, EventCtx, GfxCtx, HorizontalAlignment, Key, Outcome, Panel, State, TextExt,
VerticalAlignment, Widget,
};
use super::Neighborhood;
use crate::app::{App, Transition};
use crate::debug::DebugMode;
use crate::ltn::partition::{NeighborhoodID, Partitioning};
pub struct BrowseNeighborhoods {
@ -88,6 +89,10 @@ impl State<App> for BrowseNeighborhoods {
));
}
if ctx.input.pressed(lctrl(Key::D)) {
return Transition::Push(DebugMode::new_state(ctx, app));
}
Transition::Keep
}

View File

@ -22,19 +22,19 @@ impl Ring {
bail!("Can't make a ring with mismatching first/last points");
}
if pts.windows(2).any(|pair| pair[0] == pair[1]) {
bail!("Ring has ~dupe adjacent pts");
if let Some(pair) = pts.windows(2).find(|pair| pair[0] == pair[1]) {
bail!("Ring has duplicate adjacent points near {}", pair[0]);
}
let result = Ring { pts };
let mut seen_pts = HashSet::new();
for pt in result.pts.iter().skip(1) {
if seen_pts.contains(&pt.to_hashable()) {
bail!("Ring has repeat non-adjacent points near {}", pt);
}
seen_pts.insert(pt.to_hashable());
}
if seen_pts.len() != result.pts.len() - 1 {
bail!("Ring has repeat non-adjacent points");
}
Ok(result)
}

View File

@ -423,15 +423,10 @@ impl Block {
let lane1 = pair[0].get_outermost_lane(map);
let road1 = map.get_parent(lane1.id);
let lane2 = pair[1].get_outermost_lane(map);
// TODO What about tracing along a road with exactly one lane? False error. I'm not
// sure looking at lanes here is helpful at all...
if lane1.id == lane2.id {
bail!(
"Perimeter road has duplicate adjacent roads at {}: {:?}",
lane1.id,
perimeter.roads
);
}
// If lane1 and lane2 are the same, then it just means we found a dead-end road with
// exactly one lane, which is usually a footway or cycleway that legitimately is a
// dead-end, or connects to some other road we didn't import. We'll just trace around
// it like a normal dead-end road.
let mut pl = match pair[0].side {
SideOfRoad::Right => road1.center_pts.must_shift_right(road1.get_half_width()),
SideOfRoad::Left => road1.center_pts.must_shift_left(road1.get_half_width()),
@ -481,6 +476,7 @@ impl Block {
// At dead-ends, trace around the intersection on the longer side
let longer = prev_i.is_deadend();
if let Some(slice) = ring.get_slice_between(*last_pt, pl.first_pt(), longer) {
// TODO Only if it doesn't have repeat points?
pts.extend(slice.into_points());
}
}

View File

@ -1,14 +1,14 @@
data/system/us/seattle/maps/montlake.bin
158 single blocks (2 failures to blockify), 1 partial merges, 0 failures to blockify partitions
158 single blocks (1 failures to blockify), 1 partial merges, 0 failures to blockify partitions
data/system/us/seattle/maps/downtown.bin
1449 single blocks (21 failures to blockify), 8 partial merges, 0 failures to blockify partitions
data/system/us/seattle/maps/lakeslice.bin
1033 single blocks (4 failures to blockify), 5 partial merges, 1 failures to blockify partitions
data/system/us/phoenix/maps/tempe.bin
407 single blocks (9 failures to blockify), 1 partial merges, 0 failures to blockify partitions
407 single blocks (8 failures to blockify), 1 partial merges, 0 failures to blockify partitions
data/system/gb/leeds/maps/north.bin
2589 single blocks (20 failures to blockify), 10 partial merges, 1 failures to blockify partitions
2589 single blocks (17 failures to blockify), 10 partial merges, 1 failures to blockify partitions
data/system/gb/bristol/maps/east.bin
1061 single blocks (13 failures to blockify), 6 partial merges, 1 failures to blockify partitions
1061 single blocks (9 failures to blockify), 6 partial merges, 1 failures to blockify partitions
data/system/gb/london/maps/camden.bin
3519 single blocks (32 failures to blockify), 23 partial merges, 3 failures to blockify partitions
3519 single blocks (27 failures to blockify), 23 partial merges, 3 failures to blockify partitions