mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-29 17:34:58 +03:00
cant delete roads involving turn restrictions
This commit is contained in:
parent
ffc8050623
commit
cfa21d4cc3
@ -400,5 +400,5 @@ impl GUI for UI {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
ezgui::run("Synthetic map editor", 1024.0, 768.0, |ctx| UI::new(ctx));
|
||||
ezgui::run("Synthetic map editor", 1800.0, 800.0, |ctx| UI::new(ctx));
|
||||
}
|
||||
|
@ -455,8 +455,15 @@ impl Model {
|
||||
|
||||
pub fn delete_r(&mut self, id: StableRoadID) {
|
||||
assert!(self.showing_pts != Some(id));
|
||||
self.road_deleted(id);
|
||||
self.map.delete_road(id, &mut self.fixes);
|
||||
if self.map.can_delete_road(id) {
|
||||
self.road_deleted(id);
|
||||
self.map.delete_road(id, &mut self.fixes);
|
||||
} else {
|
||||
println!(
|
||||
"Can't delete {}, it must have turn restriction from/to it",
|
||||
id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_road_spec(&self, id: StableRoadID) -> String {
|
||||
|
@ -225,7 +225,24 @@ impl RawMap {
|
||||
|
||||
// Mutations
|
||||
impl RawMap {
|
||||
pub fn can_delete_road(&self, r: StableRoadID) -> bool {
|
||||
if !self.get_turn_restrictions(r).is_empty() {
|
||||
return false;
|
||||
}
|
||||
// Brute force search the other direction
|
||||
let osm_id = self.roads[&r].orig_id.osm_way_id;
|
||||
for restrictions in self.turn_restrictions.values() {
|
||||
for (_, to) in restrictions {
|
||||
if *to == osm_id {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
pub fn delete_road(&mut self, r: StableRoadID, fixes: &mut MapFixes) {
|
||||
assert!(self.can_delete_road(r));
|
||||
let road = self.roads.remove(&r).unwrap();
|
||||
if !road.synthetic() {
|
||||
fixes.delete_roads.push(road.orig_id);
|
||||
|
Loading…
Reference in New Issue
Block a user