From 7a49c585cfad5d6c98e7f22d6f186427a64464cf Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Tue, 18 Jun 2019 14:49:04 -0700 Subject: [PATCH] remove building_type and stop reading the residential permit shapefile --- convert_osm/src/lib.rs | 51 --------------------------------- convert_osm/src/osm.rs | 1 - docs/design/notes/map_model.md | 2 -- editor/src/helpers.rs | 3 -- import.sh | 10 +------ map_model/src/building.rs | 9 ------ map_model/src/lib.rs | 2 +- map_model/src/make/buildings.rs | 33 ++------------------- map_model/src/raw_data.rs | 1 - synthetic/src/lib.rs | 1 - tests/src/map_conversion.rs | 1 - 11 files changed, 4 insertions(+), 110 deletions(-) diff --git a/convert_osm/src/lib.rs b/convert_osm/src/lib.rs index b8f4dbf241..969f436193 100644 --- a/convert_osm/src/lib.rs +++ b/convert_osm/src/lib.rs @@ -13,7 +13,6 @@ use std::io::{BufRead, BufReader}; use structopt::StructOpt; const MAX_DIST_BTWN_INTERSECTION_AND_SIGNAL: Distance = Distance::const_meters(50.0); -const MAX_DIST_BTWN_BLDG_PERMIT_AND_BLDG: Distance = Distance::const_meters(10.0); #[derive(StructOpt, Debug)] #[structopt(name = "convert_osm")] @@ -26,10 +25,6 @@ pub struct Flags { #[structopt(long = "traffic_signals", default_value = "")] pub traffic_signals: String, - /// KML with residential building permits. Optional. - #[structopt(long = "residential_buildings", default_value = "")] - pub residential_buildings: String, - /// ExtraShapes file with blockface, produced using the kml crate. Optional. #[structopt(long = "parking_shapes", default_value = "")] pub parking_shapes: String, @@ -67,9 +62,6 @@ pub fn convert(flags: &Flags, timer: &mut abstutil::Timer) -> raw_data::Map { // Do this after removing stuff. map.compute_gps_bounds(); - if !flags.residential_buildings.is_empty() { - handle_residences(&mut map, &flags.residential_buildings, timer); - } if !flags.parking_shapes.is_empty() { use_parking_hints(&mut map, &flags.parking_shapes, timer); } @@ -175,49 +167,6 @@ fn handle_traffic_signals(map: &mut raw_data::Map, path: &str, timer: &mut Timer timer.stop("handle traffic signals"); } -fn handle_residences(map: &mut raw_data::Map, path: &str, timer: &mut Timer) { - timer.start("match residential permits with buildings"); - - let mut closest: FindClosest = FindClosest::new(&map.gps_bounds.to_bounds()); - for (idx, b) in map.buildings.iter().enumerate() { - // TODO Ew, have to massage into Pt2D. - closest.add_gps(idx, &b.points, &map.gps_bounds); - } - - let shapes = kml::load(path, &map.gps_bounds, timer) - .expect("loading residential buildings failed") - .shapes; - timer.start_iter("handle residential permits", shapes.len()); - for shape in shapes.into_iter() { - timer.next(); - if shape.points.len() > 1 { - panic!( - "Residential building permit has multiple points: {:?}", - shape - ); - } - let pt = shape.points[0]; - if !map.gps_bounds.contains(pt) { - continue; - } - if let Some(num) = shape - .attributes - .get("net_units") - .and_then(|n| usize::from_str_radix(n, 10).ok()) - { - if let Some((idx, _)) = closest.closest_pt( - Pt2D::from_gps(pt, &map.gps_bounds).unwrap(), - MAX_DIST_BTWN_BLDG_PERMIT_AND_BLDG, - ) { - // Just blindly override with the latest point. The dataset says multiple permits - // per building might exist. - map.buildings[idx].num_residential_units = Some(num); - } - } - } - timer.stop("match residential permits with buildings"); -} - fn read_osmosis_polygon(path: &str) -> Vec { let mut pts: Vec = Vec::new(); for (idx, maybe_line) in BufReader::new(File::open(path).unwrap()) diff --git a/convert_osm/src/osm.rs b/convert_osm/src/osm.rs index 6c92be1fd8..4bf2138772 100644 --- a/convert_osm/src/osm.rs +++ b/convert_osm/src/osm.rs @@ -63,7 +63,6 @@ pub fn osm_to_raw_roads( osm_way_id: way.id, points: pts, osm_tags: tags, - num_residential_units: None, }); } else if let Some(at) = get_area_type(&tags) { areas.push(raw_data::Area { diff --git a/docs/design/notes/map_model.md b/docs/design/notes/map_model.md index d89b2d0f40..77d6d5289a 100644 --- a/docs/design/notes/map_model.md +++ b/docs/design/notes/map_model.md @@ -93,8 +93,6 @@ is the source of truth. - Neighborhood boundaries - http://data-seattlecitygis.opendata.arcgis.com/datasets/blockface - Blockfaces, used to determine where on-street parking lanes are -- https://data-seattlecitygis.opendata.arcgis.com/datasets/residential-building-permits-issued-and-final - - Number of units per residential building ## Conversion process diff --git a/editor/src/helpers.rs b/editor/src/helpers.rs index 4ef83fa605..b581926b24 100644 --- a/editor/src/helpers.rs +++ b/editor/src/helpers.rs @@ -154,9 +154,6 @@ impl ID { "Dist along sidewalk: {}", b.front_path.sidewalk.dist_along() )); - if let Some(units) = b.num_residential_units { - txt.add_line(format!("{} residential units", units)); - } styled_kv(&mut txt, &b.osm_tags); } ID::Car(id) => { diff --git a/import.sh b/import.sh index 5b1cba416f..10c5da9fb8 100755 --- a/import.sh +++ b/import.sh @@ -35,13 +35,6 @@ if [ ! -f data/input/neighborhoods.geojson ]; then data/input/neighborhoods.geojson; fi -if [ ! -f data/input/residential_buildings.kml ]; then - # From https://data-seattlecitygis.opendata.arcgis.com/datasets/residential-building-permits-issued-and-final - get_if_needed \ - https://opendata.arcgis.com/datasets/cb8c492055a44f2f9de427e0518f9246_0.kml \ - data/input/residential_buildings.kml; -fi - if [ ! -f data/input/Seattle.osm ]; then get_if_needed \ http://download.bbbike.org/osm/bbbike/Seattle/Seattle.osm.gz \ @@ -95,7 +88,6 @@ for poly in `ls ../data/polygons/`; do RUST_BACKTRACE=1 cargo run --release -- \ --osm=../data/input/$name.osm \ --traffic_signals=../data/input/traffic_signals.kml \ - --residential_buildings=../data/input/residential_buildings.kml \ --parking_shapes=../data/shapes/blockface.bin \ --gtfs=../data/input/google_transit_2018_18_08 \ --neighborhoods=../data/input/neighborhoods.geojson \ @@ -103,4 +95,4 @@ for poly in `ls ../data/polygons/`; do --output=../data/raw_maps/$name.bin done -# To run manually: cargo run -- --osm=../data/input/montlake.osm --traffic_signals=../data/input/traffic_signals.kml --residential_buildings=../data/input/residential_buildings.kml --parking_shapes=../data/shapes/blockface.bin --gtfs=../data/input/google_transit_2018_18_08 --neighborhoods=../data/input/neighborhoods.geojson --clip=../data/polygons/montlake.poly --output=../data/raw_maps/montlake.bin --fast_dev +# To run manually: cargo run -- --osm=../data/input/montlake.osm --traffic_signals=../data/input/traffic_signals.kml --parking_shapes=../data/shapes/blockface.bin --gtfs=../data/input/google_transit_2018_18_08 --neighborhoods=../data/input/neighborhoods.geojson --clip=../data/polygons/montlake.poly --output=../data/raw_maps/montlake.bin --fast_dev diff --git a/map_model/src/building.rs b/map_model/src/building.rs index b3f6528b41..95d0093dce 100644 --- a/map_model/src/building.rs +++ b/map_model/src/building.rs @@ -23,21 +23,12 @@ pub struct FrontPath { pub line: Line, } -#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] -pub enum BuildingType { - Residence, - Business, - Unknown, -} - #[derive(Serialize, Deserialize, Debug)] pub struct Building { pub id: BuildingID, - pub building_type: BuildingType, pub polygon: Polygon, pub osm_tags: BTreeMap, pub osm_way_id: i64, - pub num_residential_units: Option, pub front_path: FrontPath, } diff --git a/map_model/src/lib.rs b/map_model/src/lib.rs index b5d1118667..822d101caf 100644 --- a/map_model/src/lib.rs +++ b/map_model/src/lib.rs @@ -16,7 +16,7 @@ mod traversable; mod turn; pub use crate::area::{Area, AreaID, AreaType}; -pub use crate::building::{Building, BuildingID, BuildingType, FrontPath}; +pub use crate::building::{Building, BuildingID, FrontPath}; pub use crate::bus_stop::{BusRoute, BusRouteID, BusStop, BusStopID}; pub use crate::edits::MapEdits; pub use crate::intersection::{Intersection, IntersectionID, IntersectionType}; diff --git a/map_model/src/make/buildings.rs b/map_model/src/make/buildings.rs index c4bd476bc7..e78d3b564c 100644 --- a/map_model/src/make/buildings.rs +++ b/map_model/src/make/buildings.rs @@ -1,8 +1,8 @@ use crate::make::sidewalk_finder::find_sidewalk_points; -use crate::{raw_data, Building, BuildingID, BuildingType, FrontPath, Lane}; +use crate::{raw_data, Building, BuildingID, FrontPath, Lane}; use abstutil::Timer; use geom::{Bounds, Distance, GPSBounds, HashablePt2D, Line, Polygon, Pt2D}; -use std::collections::{BTreeMap, HashSet}; +use std::collections::HashSet; pub fn make_all_buildings( results: &mut Vec, @@ -46,7 +46,6 @@ pub fn make_all_buildings( let id = BuildingID(results.len()); results.push(Building { id, - building_type: classify(input[idx].num_residential_units, &input[idx].osm_tags), polygon: Polygon::new(&points), osm_tags: input[idx].osm_tags.clone(), osm_way_id: input[idx].osm_way_id, @@ -55,7 +54,6 @@ pub fn make_all_buildings( sidewalk: *sidewalk_pos, line, }, - num_residential_units: input[idx].num_residential_units, }); } } @@ -83,30 +81,3 @@ fn trim_front_path(bldg_points: &Vec, path: Line) -> Line { // Just give up path } - -fn classify(num_residential_units: Option, tags: &BTreeMap) -> BuildingType { - if num_residential_units.is_some() { - return BuildingType::Residence; - } - if tags.get("building") == Some(&"apartments".to_string()) { - return BuildingType::Residence; - } - if tags.get("building") == Some(&"residential".to_string()) { - return BuildingType::Residence; - } - if tags.get("building") == Some(&"house".to_string()) { - return BuildingType::Residence; - } - - if tags.contains_key(&"shop".to_string()) || tags.contains_key(&"amenity".to_string()) { - return BuildingType::Business; - } - if tags.get("building") == Some(&"commercial".to_string()) { - return BuildingType::Business; - } - if tags.get("building") == Some(&"retail".to_string()) { - return BuildingType::Business; - } - - BuildingType::Unknown -} diff --git a/map_model/src/raw_data.rs b/map_model/src/raw_data.rs index b16893dffd..f9a6a74270 100644 --- a/map_model/src/raw_data.rs +++ b/map_model/src/raw_data.rs @@ -162,7 +162,6 @@ pub struct Building { pub points: Vec, pub osm_tags: BTreeMap, pub osm_way_id: i64, - pub num_residential_units: Option, } #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] diff --git a/synthetic/src/lib.rs b/synthetic/src/lib.rs index 0171167b3c..f68a734b06 100644 --- a/synthetic/src/lib.rs +++ b/synthetic/src/lib.rs @@ -365,7 +365,6 @@ impl Model { points: b.polygon().points().iter().map(|p| pt(*p)).collect(), osm_tags, osm_way_id: idx as i64, - num_residential_units: None, }); } diff --git a/tests/src/map_conversion.rs b/tests/src/map_conversion.rs index 169107cff4..6da4340f8a 100644 --- a/tests/src/map_conversion.rs +++ b/tests/src/map_conversion.rs @@ -8,7 +8,6 @@ pub fn run(t: &mut TestRunner) { let flags = convert_osm::Flags { osm: "../data/input/montlake.osm".to_string(), traffic_signals: "../data/input/traffic_signals.kml".to_string(), - residential_buildings: "../data/input/residential_buildings.kml".to_string(), parking_shapes: "../data/shapes/blockface.bin".to_string(), gtfs: "../data/input/google_transit_2018_18_08".to_string(), neighborhoods: "../data/input/neighborhoods.geojson".to_string(),