Don't filter deadends

(You told me about nowhere, sounds like someplace I'd like to go)
This commit is contained in:
Dustin Carlino 2022-06-23 10:29:51 -05:00
parent c978affdd5
commit 966dd7955d
4 changed files with 12 additions and 1 deletions

View File

@ -52,7 +52,7 @@ impl FreehandFilters {
}
let road = app.map.get_r(*r);
// Don't show error messages
if road.oneway_for_driving().is_some() {
if road.oneway_for_driving().is_some() || road.is_deadend(&app.map) {
continue;
}
if let Some((pt, _)) = road.center_pts.intersection(&path) {

View File

@ -98,6 +98,9 @@ pub fn handle_world_outcome(
if road.oneway_for_driving().is_some() {
return EditOutcome::error(ctx, "A one-way street can't have a filter");
}
if road.is_deadend(&app.map) {
return EditOutcome::error(ctx, "You can't filter a dead-end");
}
app.session.modal_filters.before_edit();
if app.session.modal_filters.roads.remove(&r).is_none() {

View File

@ -51,6 +51,9 @@ pub fn handle_world_outcome(
if app.session.modal_filters.roads.contains_key(&r) {
return EditOutcome::error(ctx, "A one-way street can't have a filter");
}
if app.map.get_r(r).is_deadend(&app.map) {
return EditOutcome::error(ctx, "A dead-end street can't be one-way");
}
let leftmost_dir = if app.map.get_config().driving_side == DrivingSide::Right {
Direction::Back

View File

@ -615,6 +615,11 @@ impl Road {
pub fn oneway_for_driving(&self) -> Option<Direction> {
LaneSpec::oneway_for_driving(&self.lane_specs())
}
/// Does either end of this road lead nowhere?
pub fn is_deadend(&self, map: &Map) -> bool {
map.get_i(self.src_i).is_deadend() || map.get_i(self.dst_i).is_deadend()
}
}
// TODO All of this is kind of deprecated? Some callers seem to really need to still handle lanes