mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-27 00:12:55 +03:00
Workaround maps with broken partitioning. #960
Let most of the tool work -- just no boundary adjustment. Selecting the neighbourhood that's broken would also crash, except it has no polygon, so it can't be selected!
This commit is contained in:
parent
ed342b39d4
commit
ab3c0cd44f
@ -36,6 +36,7 @@ pub struct Partitioning {
|
||||
block_to_neighbourhood: BTreeMap<BlockID, NeighbourhoodID>,
|
||||
|
||||
use_expensive_blockfinding: bool,
|
||||
pub broken: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
@ -68,6 +69,7 @@ impl Partitioning {
|
||||
block_to_neighbourhood: BTreeMap::new(),
|
||||
|
||||
use_expensive_blockfinding: false,
|
||||
broken: false,
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,6 +145,7 @@ impl Partitioning {
|
||||
neighbourhood_id_counter,
|
||||
block_to_neighbourhood: BTreeMap::new(),
|
||||
use_expensive_blockfinding,
|
||||
broken: false,
|
||||
};
|
||||
|
||||
// TODO We could probably build this up as we go
|
||||
@ -159,10 +162,11 @@ impl Partitioning {
|
||||
continue 'METHOD;
|
||||
}
|
||||
// This will break everything downstream, so bail out immediately
|
||||
panic!(
|
||||
"Block doesn't belong to any neighbourhood?! {:?}",
|
||||
error!(
|
||||
"Block still doesn't belong to any neighbourhood, even with expensive checks. Continuing without boundary adjustment. {:?}",
|
||||
p.get_block(id).perimeter
|
||||
);
|
||||
p.broken = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ use anyhow::Result;
|
||||
use geom::Polygon;
|
||||
use map_gui::tools::DrawSimpleRoadLabels;
|
||||
use widgetry::mapspace::{World, WorldOutcome};
|
||||
use widgetry::tools::Lasso;
|
||||
use widgetry::tools::{Lasso, PopupMsg};
|
||||
use widgetry::{
|
||||
Drawable, EventCtx, GeomBatch, GfxCtx, Key, Line, Outcome, Panel, State, Text, TextExt, Widget,
|
||||
};
|
||||
@ -40,6 +40,17 @@ impl SelectBoundary {
|
||||
app: &mut App,
|
||||
id: NeighbourhoodID,
|
||||
) -> Box<dyn State<App>> {
|
||||
if app.session.partitioning.broken {
|
||||
return PopupMsg::new_state(
|
||||
ctx,
|
||||
"Error",
|
||||
vec![
|
||||
"Sorry, you can't adjust any boundaries on this map.",
|
||||
"This is a known problem without any workaround yet.",
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// Make sure we clear this state if we ever modify neighbourhood boundaries
|
||||
if let EditMode::Shortcuts(ref mut maybe_focus) = app.session.edit_mode {
|
||||
*maybe_focus = None;
|
||||
|
Loading…
Reference in New Issue
Block a user