use traffic signal data from new kml, not old shp that's no longer online

This commit is contained in:
Dustin Carlino 2018-11-27 12:40:03 -08:00
parent 5406593843
commit 149758d5ae
7 changed files with 25 additions and 59 deletions

View File

@ -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"

View File

@ -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);

View File

@ -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<Vec<LonLat>, Error> {
println!("Opening {}", path);
let reader = shp::ShpReader::open(path)?;
let file = reader.read();
let mut result: Vec<LonLat> = 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<PointShape>,
}

View File

@ -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...

View File

@ -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 \

View File

@ -33,7 +33,7 @@ pub struct ExtraShapes {
pub shapes: Vec<ExtraShape>,
}
#[derive(Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize)]
pub struct ExtraShape {
pub points: Vec<LonLat>,
pub attributes: BTreeMap<String, String>,

View File

@ -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(),