From aa885ca1c973b6323a246dbe7a7a6421eeadda7e Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Tue, 28 Feb 2023 09:56:27 +0000 Subject: [PATCH] Fix map_editor, broken by osm2streets API update --- apps/map_editor/src/model.rs | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/apps/map_editor/src/model.rs b/apps/map_editor/src/model.rs index ffca91765b..08de32c560 100644 --- a/apps/map_editor/src/model.rs +++ b/apps/map_editor/src/model.rs @@ -498,30 +498,14 @@ impl Model { } pub fn merge_r(&mut self, ctx: &EventCtx, id: RoadID) { - self.stop_showing_pts(id); - - let (retained_i, deleted_i) = match self.map.streets.collapse_short_road(id) { - Ok(pair) => pair, - Err(err) => { - warn!("Can't merge this road: {}", err); - self.show_r_points(ctx, id); - return; - } - }; - - self.world - .delete_before_replacement(ID::Intersection(retained_i)); - self.intersection_added(ctx, retained_i); - - self.world.delete(ID::Intersection(deleted_i)); - - self.world.delete(ID::Road(id)); - // Geometry might've changed for roads connected to the endpoints - for r in self.map.streets.intersections[&retained_i].roads.clone() { - self.road_added(ctx, r); + if let Err(err) = self.map.streets.collapse_short_road(id) { + warn!("Can't merge this road: {}", err); + return; } - info!("Merged {id}"); + + // This is very blunt and slow. Multiple roads and intersections might've vanished. + self.recreate_world(ctx, &mut Timer::throwaway()); } pub fn toggle_junction(&mut self, ctx: &EventCtx, id: RoadID) {