diff --git a/editor/color_scheme b/editor/color_scheme index 08fa97dcf8..eb8c159efa 100644 --- a/editor/color_scheme +++ b/editor/color_scheme @@ -112,12 +112,12 @@ 0.7, 0.7, 0.7, - 1.0 + 0.8 ], "BuildingPath": [ - 0.8, - 0.8, - 0.8, + 0.6, + 0.6, + 0.6, 1.0 ], "BuildingBoundary": [ diff --git a/geom/src/line.rs b/geom/src/line.rs index 95685da8d3..008289f2f8 100644 --- a/geom/src/line.rs +++ b/geom/src/line.rs @@ -20,6 +20,10 @@ impl Line { self.1 } + pub fn points(&self) -> Vec { + vec![self.0, self.1] + } + // TODO valid to do euclidean distance on world-space points that're formed from // Haversine? pub fn length(&self) -> si::Meter { diff --git a/map_model/src/make/buildings.rs b/map_model/src/make/buildings.rs index 210beab6e5..892a4ad25a 100644 --- a/map_model/src/make/buildings.rs +++ b/map_model/src/make/buildings.rs @@ -1,5 +1,5 @@ use geo; -use geom::{Bounds, Line, Pt2D}; +use geom::{Bounds, Line, Pt2D, PolyLine}; use geometry; use ordered_float::NotNaN; use raw_data; @@ -19,7 +19,7 @@ pub(crate) fn make_building( .map(|coord| Pt2D::from_gps(coord, bounds)) .collect(); //let front_path = find_front_path_using_street_names(&points, &b.osm_tags, lanes, roads); - let front_path = find_front_path(&points, lanes); + let front_path = trim_front_path(&points, find_front_path(&points, lanes)); Building { points, @@ -30,6 +30,17 @@ pub(crate) fn make_building( } } +// Adjust the path to start on the building's border, not center +fn trim_front_path(bldg_points: &Vec, path: Line) -> Line { + let poly = PolyLine::new(bldg_points.clone()); + if let Some(hit) = poly.intersection(&PolyLine::new(path.points())) { + Line::new(hit, path.pt2()) + } else { + // Just give up + path + } +} + fn find_front_path(bldg_points: &Vec, lanes: &Vec) -> Line { use geo::prelude::{ClosestPoint, EuclideanDistance};