mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-23 17:07:12 +03:00
Workaround #834, which was causing partitioning to infinite loop when
there are disconnected railway segments dangling around
This commit is contained in:
parent
cb3138dbfe
commit
85709b1e4f
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user