When turning a perimeter into a block polygon, don't insist on tracing

along the perimeter of broken intersections.

There are cases where intersection geometry is a little bit broken,
jutting out a bit and touching a road. It's more robust to still produce
a reasonably shaped block in these cases, instead of totally give up.

Visual inspection and the goldenfile VASTLY improved!
This commit is contained in:
Dustin Carlino 2022-01-06 11:22:06 +00:00
parent e1d88f10ad
commit cb3138dbfe
2 changed files with 23 additions and 15 deletions

View File

@ -462,6 +462,10 @@ impl Block {
//
// Note this logic is similar to how we find SharedSidewalkCorners. Don't rely on that
// existing, since the outermost lane mightn't be a sidewalk.
//
// If the ring.doubles_back(), don't bother. If we tried to trace the boundary, it
// usually breaks the final Ring we produce. Better to skip bad intersection polygons
// and still produce a reasonable looking block.
let prev_i = if keep_lane_orientation {
lane1.src_i
} else {
@ -473,11 +477,13 @@ impl Block {
if let Some(last_pt) = pts.last() {
let prev_i = map.get_i(prev_i);
if let Some(ring) = prev_i.polygon.get_outer_ring() {
// 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());
if !ring.doubles_back() {
// 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)
{
pts.extend(slice.into_points());
}
}
}
}
@ -488,9 +494,11 @@ impl Block {
// the first time.
let first_intersection = map.get_i(first_intersection.unwrap());
if let Some(ring) = first_intersection.polygon.get_outer_ring() {
let longer = first_intersection.is_deadend();
if let Some(slice) = ring.get_slice_between(*pts.last().unwrap(), pts[0], longer) {
pts.extend(slice.into_points());
if !ring.doubles_back() {
let longer = first_intersection.is_deadend();
if let Some(slice) = ring.get_slice_between(*pts.last().unwrap(), pts[0], longer) {
pts.extend(slice.into_points());
}
}
}
pts.push(pts[0]);

View File

@ -1,14 +1,14 @@
data/system/us/seattle/maps/montlake.bin
158 single blocks (1 failures to blockify), 1 partial merges, 0 failures to blockify partitions
158 single blocks (0 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
1449 single blocks (0 failures to blockify), 10 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
1033 single blocks (2 failures to blockify), 5 partial merges, 1 failures to blockify partitions
data/system/us/phoenix/maps/tempe.bin
407 single blocks (8 failures to blockify), 1 partial merges, 0 failures to blockify partitions
407 single blocks (0 failures to blockify), 4 partial merges, 0 failures to blockify partitions
data/system/gb/leeds/maps/north.bin
2589 single blocks (17 failures to blockify), 10 partial merges, 1 failures to blockify partitions
2589 single blocks (4 failures to blockify), 18 partial merges, 0 failures to blockify partitions
data/system/gb/bristol/maps/east.bin
1061 single blocks (9 failures to blockify), 6 partial merges, 1 failures to blockify partitions
1061 single blocks (1 failures to blockify), 7 partial merges, 1 failures to blockify partitions
data/system/gb/london/maps/camden.bin
3519 single blocks (27 failures to blockify), 23 partial merges, 3 failures to blockify partitions
3519 single blocks (9 failures to blockify), 33 partial merges, 0 failures to blockify partitions