diff --git a/convert_osm/src/clip.rs b/convert_osm/src/clip.rs index 6aa3974c87..6b50c9dd6c 100644 --- a/convert_osm/src/clip.rs +++ b/convert_osm/src/clip.rs @@ -50,7 +50,7 @@ pub fn clip_map(map: &mut raw_data::Map, path: &str, timer: &mut Timer) -> GPSBo if map .roads .values() - .filter(|r2| r2.i1 == move_i || r2.i1 == move_i) + .filter(|r2| r2.i1 == move_i || r2.i2 == move_i) .count() > 1 { diff --git a/editor/src/objects.rs b/editor/src/objects.rs index efb242efcd..969c7882e7 100644 --- a/editor/src/objects.rs +++ b/editor/src/objects.rs @@ -94,7 +94,7 @@ impl ID { ID::Lane(id) => map.maybe_get_l(id).map(|l| l.first_pt()), ID::Intersection(id) => map.maybe_get_i(id).map(|i| i.point), ID::Turn(id) => map.maybe_get_i(id.parent).map(|i| i.point), - ID::Building(id) => map.maybe_get_b(id).map(|b| Pt2D::center(&b.points)), + ID::Building(id) => map.maybe_get_b(id).map(|b| b.polygon.center()), ID::Car(id) => sim.get_draw_car(id, map).map(|c| c.body.last_pt()), ID::Pedestrian(id) => sim.get_draw_ped(id, map).map(|p| p.pos), // TODO maybe_get_es diff --git a/editor/src/render/building.rs b/editor/src/render/building.rs index 3d6b3e6387..dd948cffcb 100644 --- a/editor/src/render/building.rs +++ b/editor/src/render/building.rs @@ -7,6 +7,7 @@ use map_model::{Building, BuildingID, BuildingType, LANE_THICKNESS}; pub struct DrawBuilding { pub id: BuildingID, + // TODO Stop storing a copy here pub fill_polygon: Polygon, front_path: Polygon, @@ -26,7 +27,6 @@ impl DrawBuilding { front_path_line.dist_along(len - trim_back), ); } - let fill_polygon = Polygon::new(&bldg.points); let front_path = front_path_line.make_polygons(Distance::meters(1.0)); let default_draw = prerender.upload_borrowed(vec![ @@ -42,14 +42,14 @@ impl DrawBuilding { cs.get_def("unknown building", Color::rgb_f(0.7, 0.7, 0.7)) } }, - &fill_polygon, + &bldg.polygon, ), (cs.get_def("building path", Color::grey(0.6)), &front_path), ]); DrawBuilding { id: bldg.id, - fill_polygon, + fill_polygon: bldg.polygon.clone(), front_path, default_draw, } diff --git a/halloween/src/render.rs b/halloween/src/render.rs index 369982f69d..9e01aec669 100644 --- a/halloween/src/render.rs +++ b/halloween/src/render.rs @@ -92,7 +92,7 @@ impl DrawBuilding { fn new(b: &Building) -> DrawBuilding { DrawBuilding { id: b.id, - polygon: Polygon::new(&b.points), + polygon: b.polygon.clone(), line: b.front_path.line.reverse(), } } diff --git a/map_model/src/building.rs b/map_model/src/building.rs index 9d192af0f7..f799240e4d 100644 --- a/map_model/src/building.rs +++ b/map_model/src/building.rs @@ -1,6 +1,6 @@ use crate::{LaneID, Position}; use abstutil; -use geom::{Line, Pt2D}; +use geom::{Line, Polygon}; use serde_derive::{Deserialize, Serialize}; use std::collections::BTreeMap; use std::fmt; @@ -34,7 +34,7 @@ pub enum BuildingType { pub struct Building { pub id: BuildingID, pub building_type: BuildingType, - pub points: Vec, + pub polygon: Polygon, pub osm_tags: BTreeMap, pub osm_way_id: i64, pub num_residential_units: Option, diff --git a/map_model/src/make/buildings.rs b/map_model/src/make/buildings.rs index 16e54a5559..d90d9a60ae 100644 --- a/map_model/src/make/buildings.rs +++ b/map_model/src/make/buildings.rs @@ -1,7 +1,7 @@ use crate::make::sidewalk_finder::find_sidewalk_points; use crate::{raw_data, Building, BuildingID, BuildingType, FrontPath, Lane}; use abstutil::Timer; -use geom::{Bounds, Distance, GPSBounds, HashablePt2D, Line, Pt2D}; +use geom::{Bounds, Distance, GPSBounds, HashablePt2D, Line, Polygon, Pt2D}; use std::collections::{BTreeMap, HashSet}; pub fn make_all_buildings( @@ -47,7 +47,7 @@ pub fn make_all_buildings( results.push(Building { id, building_type: classify(input[idx].num_residential_units, &input[idx].osm_tags), - points, + polygon: Polygon::new(&points), osm_tags: input[idx].osm_tags.clone(), osm_way_id: input[idx].osm_way_id, front_path: FrontPath { diff --git a/map_model/src/neighborhood.rs b/map_model/src/neighborhood.rs index 98329cf6d9..bd59ba00fe 100644 --- a/map_model/src/neighborhood.rs +++ b/map_model/src/neighborhood.rs @@ -83,7 +83,7 @@ impl Neighborhood { pub fn find_matching_buildings(&self, map: &Map) -> Vec { let mut results: Vec = Vec::new(); for b in map.all_buildings() { - if self.polygon.contains_pt(Pt2D::center(&b.points)) { + if self.polygon.contains_pt(b.polygon.center()) { results.push(b.id); } } diff --git a/tests/src/map_conversion.rs b/tests/src/map_conversion.rs index b4748ac217..0c96677330 100644 --- a/tests/src/map_conversion.rs +++ b/tests/src/map_conversion.rs @@ -14,6 +14,7 @@ pub fn run(t: &mut TestRunner) { parking_shapes: "../data/shapes/blockface".to_string(), gtfs: "../data/input/google_transit_2018_18_08".to_string(), neighborhoods: "../data/input/neighborhoods.geojson".to_string(), + clip: "../data/polygons/montlake.poly".to_string(), output: "convert_osm_twice".to_string(), fast_dev: false, };