mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 01:15:12 +03:00
remove building_type and stop reading the residential permit shapefile
This commit is contained in:
parent
04021f9fd1
commit
7a49c585cf
@ -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<usize> = 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<LonLat> {
|
||||
let mut pts: Vec<LonLat> = Vec::new();
|
||||
for (idx, maybe_line) in BufReader::new(File::open(path).unwrap())
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
||||
|
@ -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) => {
|
||||
|
10
import.sh
10
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
|
||||
|
@ -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<String, String>,
|
||||
pub osm_way_id: i64,
|
||||
pub num_residential_units: Option<usize>,
|
||||
|
||||
pub front_path: FrontPath,
|
||||
}
|
||||
|
@ -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};
|
||||
|
@ -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<Building>,
|
||||
@ -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<Pt2D>, path: Line) -> Line {
|
||||
// Just give up
|
||||
path
|
||||
}
|
||||
|
||||
fn classify(num_residential_units: Option<usize>, tags: &BTreeMap<String, String>) -> 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
|
||||
}
|
||||
|
@ -162,7 +162,6 @@ pub struct Building {
|
||||
pub points: Vec<LonLat>,
|
||||
pub osm_tags: BTreeMap<String, String>,
|
||||
pub osm_way_id: i64,
|
||||
pub num_residential_units: Option<usize>,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
|
||||
|
@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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(),
|
||||
|
Loading…
Reference in New Issue
Block a user