Workaround #834, which was causing partitioning to infinite loop when

there are disconnected railway segments dangling around
This commit is contained in:
Dustin Carlino 2022-01-06 13:25:16 +00:00
parent cb3138dbfe
commit 85709b1e4f
3 changed files with 10 additions and 0 deletions

View File

@ -268,6 +268,13 @@ impl Perimeter {
pub fn collapse_deadends(&mut self) {
self.undo_invariant();
// TODO Workaround https://github.com/a-b-street/abstreet/issues/834. If this is a loop
// around a disconnected fragment of road, don't touch it
if self.roads.len() == 2 && self.roads[0].road == self.roads[1].road {
self.restore_invariant();
return;
}
// If the dead-end straddles the loop, it's confusing. Just rotate until that's not true.
while self.roads[0].road == self.roads.last().unwrap().road {
self.roads.rotate_left(1);

View File

@ -12,3 +12,5 @@ data/system/gb/bristol/maps/east.bin
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 (9 failures to blockify), 33 partial merges, 0 failures to blockify partitions
data/system/gb/london/maps/southwark.bin
3487 single blocks (5 failures to blockify), 42 partial merges, 1 failures to blockify partitions

View File

@ -256,6 +256,7 @@ fn test_blockfinding() -> Result<()> {
MapName::new("gb", "leeds", "north"),
MapName::new("gb", "bristol", "east"),
MapName::new("gb", "london", "camden"),
MapName::new("gb", "london", "southwark"),
] {
let map = map_model::Map::load_synchronously(name.path(), &mut timer);
let mut single_blocks = Perimeter::find_all_single_blocks(&map);