diff --git a/convert_osm/Cargo.toml b/convert_osm/Cargo.toml index 8b15cd1555..a455991dcc 100644 --- a/convert_osm/Cargo.toml +++ b/convert_osm/Cargo.toml @@ -17,6 +17,5 @@ ordered-float = "0.5.0" osm-xml = "0.5.1" map_model = { path = "../map_model" } pretty_assertions = "0.5.1" -shp = "0.1.1" sim = { path = "../sim" } structopt = "0.2" diff --git a/convert_osm/src/lib.rs b/convert_osm/src/lib.rs index 6cfc937dbf..d32e1d15be 100644 --- a/convert_osm/src/lib.rs +++ b/convert_osm/src/lib.rs @@ -10,7 +10,6 @@ extern crate kml; extern crate map_model; extern crate ordered_float; extern crate osm_xml; -extern crate shp; // TODO To serialize Neighborhoods. Should probably lift this into the map_model layer instead of // have this weird dependency. extern crate sim; @@ -23,7 +22,6 @@ mod osm; mod remove_disconnected; mod split_ways; mod srtm; -mod traffic_signals; use dimensioned::si; use geom::{GPSBounds, PolyLine, Pt2D}; @@ -46,7 +44,7 @@ pub struct Flags { #[structopt(long = "elevation")] pub elevation: String, - /// SHP with traffic signals + /// KML with traffic signals #[structopt(long = "traffic_signals")] pub traffic_signals: String, @@ -105,10 +103,16 @@ pub fn convert(flags: &Flags, timer: &mut abstutil::Timer) -> raw_data::Map { } group_parcels::group_parcels(&gps_bounds, &mut map.parcels); - for pt in traffic_signals::extract(&flags.traffic_signals) + for shape in kml::load(&flags.traffic_signals, &gps_bounds, timer) .expect("loading traffic signals failed") + .shapes .into_iter() { + // See https://www.seattle.gov/Documents/Departments/SDOT/GIS/Traffic_Signals_OD.pdf + if shape.points.len() > 1 { + panic!("Traffic signal has multiple points: {:?}", shape); + } + let pt = shape.points[0]; if gps_bounds.contains(pt) { let distance = |i: &raw_data::Intersection| pt.gps_dist_meters(i.point); diff --git a/convert_osm/src/traffic_signals.rs b/convert_osm/src/traffic_signals.rs deleted file mode 100644 index 704dd4c028..0000000000 --- a/convert_osm/src/traffic_signals.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2018 Google LLC, licensed under http://www.apache.org/licenses/LICENSE-2.0 - -use geom::LonLat; -use shp; -use std; -use std::io::Error; - -// Returns the location of traffic signals -pub fn extract(path: &str) -> Result, Error> { - println!("Opening {}", path); - - let reader = shp::ShpReader::open(path)?; - let file = reader.read(); - let mut result: Vec = Vec::new(); - for r in &file.records { - if let shp::ShpRecordContent::MultiPoint(ref raw_shape) = r.content { - // The shp crate doesn't expose the struct fields as public. Send a PR later, do this - // workaround for now. - let shape = unsafe { - std::mem::transmute::<&shp::MultiPointShape, &MultiPointShape>(raw_shape) - }; - // Some intersections have multiple points, which shows complicated intersections. For - // now, don't handle these. - result.push(LonLat::new(shape.points[0].x, shape.points[0].y)); - } else { - println!("Unexpected shp record: {:?}", r.content); - } - } - - Ok(result) -} - -struct PointShape { - x: f64, - y: f64, -} - -struct MultiPointShape { - _xmin: f64, - _xmax: f64, - _ymin: f64, - _ymax: f64, - _num_points: i32, - points: Vec, -} diff --git a/docs/design/intersections.md b/docs/design/intersections.md index fe96115176..f0afede022 100644 --- a/docs/design/intersections.md +++ b/docs/design/intersections.md @@ -1,5 +1,9 @@ # Intersection-related design notes +## Nice diagrams + +http://streetsillustrated.seattle.gov/design-standards/intersections/pedcrossing/ + ## Stop sign editor Stop signs are FIFO, except that many intersections only have a stop sign for @@ -30,6 +34,12 @@ visually. - could draw an unaligned signal box with 3 circles in the middle of the intersection, but what does it represent? maybe just an initial indicator of what's going on; not full detail. - similarly, draw a single stop sign in the middle of other intersections? :P +- http://streetsillustrated.seattle.gov/design-standards/intersections/its/ probably has hints on cycle duration +- https://ops.fhwa.dot.gov/publications/fhwahop08024/chapter4.htm + - ring and barrier diagrams +- https://www.webpages.uidaho.edu/TrafficSignalSystems/traffic/instructor/ch3a.pdf +- http://iamtraffic.org/evaluation/the-six-way/ + ## Intersection policies for pedestrians ## Before figuring out how pedestrians will deterministically use intersections alongside cars, recall how cars currently work... diff --git a/import.sh b/import.sh index 2d4226a5d7..dd1318150f 100755 --- a/import.sh +++ b/import.sh @@ -29,13 +29,11 @@ if [ ! -d data/input/google_transit_2018_18_08/ ]; then rm -f data/input/google_transit_2018_18_08.zip; fi -if [ ! -f data/input/TrafficSignals.shp ]; then +if [ ! -f data/input/traffic_signals.kml ]; then + # From https://data.seattle.gov/Transportation/Traffic-Signals/nr6x-wnd5 get_if_needed \ - https://data.seattle.gov/download/dr6d-ejex/application%2Fzip \ - data/input/TrafficSignals.shp.zip; - unzip -d data/input data/input/TrafficSignals.shp.zip; - mv data/input/Traffic\ Signals/WGS84/TrafficSignals.shp data/input; - rm -rf data/input/Traffic\ Signals data/input/TrafficSignals.shp.zip; + http://data-seattlecitygis.opendata.arcgis.com/datasets/ff97a6eb8ac84356beea09138c6e1ec3_0.kml \ + data/input/traffic_signals.kml; fi if [ ! -f data/input/neighborhoods.geojson ]; then @@ -91,7 +89,7 @@ for poly in `ls ../data/polygons/`; do cargo run --release -- \ --osm=../data/input/$name.osm \ --elevation=../data/input/N47W122.hgt \ - --traffic_signals=../data/input/TrafficSignals.shp \ + --traffic_signals=../data/input/traffic_signals.kml \ --parcels=../data/shapes/parcels \ --parking_shapes=../data/shapes/blockface \ --gtfs=../data/input/google_transit_2018_18_08 \ diff --git a/kml/src/lib.rs b/kml/src/lib.rs index 5cb3d4a383..88f6de25f1 100644 --- a/kml/src/lib.rs +++ b/kml/src/lib.rs @@ -33,7 +33,7 @@ pub struct ExtraShapes { pub shapes: Vec, } -#[derive(Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize)] pub struct ExtraShape { pub points: Vec, pub attributes: BTreeMap, diff --git a/tests/src/map_conversion.rs b/tests/src/map_conversion.rs index 2143d0fb89..bd2cb9900b 100644 --- a/tests/src/map_conversion.rs +++ b/tests/src/map_conversion.rs @@ -9,7 +9,7 @@ pub fn run(t: &mut TestRunner) { let flags = convert_osm::Flags { osm: "../data/input/montlake.osm".to_string(), elevation: "../data/input/N47W122.hgt".to_string(), - traffic_signals: "../data/input/TrafficSignals.shp".to_string(), + traffic_signals: "../data/input/traffic_signals.kml".to_string(), parcels: "../data/shapes/parcels".to_string(), parking_shapes: "../data/shapes/blockface".to_string(), gtfs: "../data/input/google_transit_2018_18_08".to_string(),