From 8b71885b0463df411976facb5867ba1c68fa7998 Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Sat, 21 May 2022 13:20:57 +0100 Subject: [PATCH] Optionally skip removing disconnected streets from the graph. For osm2streets tests, often our small clipped area looks very disconnected. https://github.com/a-b-street/osm2streets/issues/8 --- apps/map_editor/src/app.rs | 2 +- map_model/src/make/mod.rs | 2 +- raw_map/src/transform/mod.rs | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/map_editor/src/app.rs b/apps/map_editor/src/app.rs index c4ad009e84..59227bf9cd 100644 --- a/apps/map_editor/src/app.rs +++ b/apps/map_editor/src/app.rs @@ -270,7 +270,7 @@ impl State for MainState { } "simplify RawMap" => { ctx.loading_screen("simplify", |ctx, timer| { - app.model.map.run_all_simplifications(false, timer); + app.model.map.run_all_simplifications(false, true, timer); app.model.recreate_world(ctx, timer); }); } diff --git a/map_model/src/make/mod.rs b/map_model/src/make/mod.rs index 3ec60a4546..8eaf1b31cc 100644 --- a/map_model/src/make/mod.rs +++ b/map_model/src/make/mod.rs @@ -43,7 +43,7 @@ pub struct RawToMapOptions { impl Map { pub fn create_from_raw(mut raw: RawMap, opts: RawToMapOptions, timer: &mut Timer) -> Map { - raw.run_all_simplifications(opts.consolidate_all_intersections, timer); + raw.run_all_simplifications(opts.consolidate_all_intersections, true, timer); timer.start("raw_map to InitialMap"); let gps_bounds = raw.gps_bounds.clone(); diff --git a/raw_map/src/transform/mod.rs b/raw_map/src/transform/mod.rs index 9abc13f5fd..6cc84b1947 100644 --- a/raw_map/src/transform/mod.rs +++ b/raw_map/src/transform/mod.rs @@ -11,6 +11,8 @@ mod shrink_roads; mod snappy; impl RawMap { + // TODO I suspect we'll soon take a full struct of options, maybe even a list of transformation + // enums to run in order /// Run a sequence of transformations to the RawMap before converting it to a full Map. /// /// We don't want to run these during the OSM->RawMap import stage, because we want to use the @@ -18,6 +20,7 @@ impl RawMap { pub fn run_all_simplifications( &mut self, consolidate_all_intersections: bool, + remove_disconnected: bool, timer: &mut Timer, ) { timer.start("simplify RawMap"); @@ -36,7 +39,9 @@ impl RawMap { collapse_intersections::trim_deadends(self); timer.stop("trimming dead-end cycleways (round 2)"); - remove_disconnected::remove_disconnected_roads(self, timer); + if remove_disconnected { + remove_disconnected::remove_disconnected_roads(self, timer); + } timer.start("merging short roads"); find_short_roads::find_short_roads(self, consolidate_all_intersections);