rip out gtfs code, cutover to osm. will revisit this later; gtfs and osm probably disagree on routes and stops, and gtfs has schedule. but for now, just osm.

This commit is contained in:
Dustin Carlino 2020-07-03 17:33:32 -07:00
parent 0dc42d7e19
commit 56cb59c3ac
16 changed files with 14 additions and 178 deletions

28
Cargo.lock generated
View File

@ -357,7 +357,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-integer 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -455,7 +454,6 @@ dependencies = [
"abstutil 0.1.0",
"byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"geom 0.1.0",
"gtfs 0.1.0",
"kml 0.1.0",
"map_model 0.1.0",
"osm-xml 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1258,17 +1256,6 @@ dependencies = [
"gl_generator 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gtfs"
version = "0.1.0"
dependencies = [
"abstutil 0.1.0",
"geom 0.1.0",
"itertools 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)",
"transitfeed 0.3.0 (git+https://github.com/dabreegster/transitfeed)",
]
[[package]]
name = "h2"
version = "0.2.5"
@ -1816,7 +1803,6 @@ dependencies = [
"abstutil 0.1.0",
"fast_paths 0.1.1-SNAPSHOT (git+https://github.com/easbar/fast_paths)",
"geom 0.1.0",
"gtfs 0.1.0",
"nbez 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"petgraph 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"seattle_traffic_signals 0.1.0 (git+https://github.com/dabreegster/seattle_traffic_signals)",
@ -3369,19 +3355,6 @@ name = "tower-service"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "transitfeed"
version = "0.3.0"
source = "git+https://github.com/dabreegster/transitfeed#8a8d11e3602fb99b8ed5af07274c877662bfff25"
dependencies = [
"chrono 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
"csv 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)",
"tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"zip 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "try-lock"
version = "0.2.2"
@ -4302,7 +4275,6 @@ dependencies = [
"checksum tokio-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499"
"checksum toml 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a"
"checksum tower-service 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860"
"checksum transitfeed 0.3.0 (git+https://github.com/dabreegster/transitfeed)" = "<none>"
"checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382"
"checksum ttf-parser 0.6.1 (git+https://github.com/RazrFalcon/ttf-parser?rev=df046dd)" = "<none>"
"checksum ttf-parser 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "52fbe7769f5af5d7d25aea74b9443b64e544a5ffb4d2b2968295ddea934f1a06"

View File

@ -6,7 +6,6 @@ members = [
"ezgui",
"game",
"geom",
"gtfs",
"headless",
"importer",
"kml",

View File

@ -8,7 +8,6 @@ edition = "2018"
abstutil = { path = "../abstutil" }
byteorder = "1.3.4"
geom = { path = "../geom" }
gtfs = { path = "../gtfs" }
kml = { path = "../kml" }
osm-xml = "0.6.2"
map_model = { path = "../map_model" }

View File

@ -21,7 +21,6 @@ pub struct Options {
pub public_offstreet_parking: Option<String>,
pub private_offstreet_parking: PrivateOffstreetParking,
pub sidewalks: Option<String>,
pub gtfs: Option<String>,
pub elevation: Option<String>,
pub clip: Option<String>,
pub drive_on_right: bool,
@ -68,11 +67,6 @@ pub fn convert(opts: Options, timer: &mut abstutil::Timer) -> RawMap {
if let Some(ref path) = opts.sidewalks {
use_sidewalk_hints(&mut map, path.clone(), timer);
}
if let Some(ref path) = opts.gtfs {
timer.start("load GTFS");
map.bus_routes = gtfs::load(path);
timer.stop("load GTFS");
}
if let Some(ref path) = opts.elevation {
use_elevation(&mut map, path, timer);
}

View File

@ -277,7 +277,7 @@ pub fn extract_osm(
);
}
} else if tags.get("type") == Some(&"route_master".to_string()) {
map.new_bus_routes
map.bus_routes
.extend(extract_route(&tags, rel, &doc, &id_to_way, &map.gps_bounds));
}
}

View File

@ -1,16 +1,16 @@
data/input/austin/osm/Austin.osm,7c8d72cf97072af34cee665006b1e9e6,https://www.dropbox.com/s/8bedio4fpt6yvhg/Austin.osm.zip?dl=0
data/input/austin/osm/downtown_atx.osm,a30b0f460a481598e494f16a9d07a822,https://www.dropbox.com/s/tbadw3f0ex2zzx7/downtown_atx.osm.zip?dl=0
data/input/austin/osm/huge_austin.osm,fb166029fc8006bd20dc959fbbbde3b6,https://www.dropbox.com/s/4x421o9o8px0m6o/huge_austin.osm.zip?dl=0
data/input/raw_maps/ballard.bin,e86dc091224aebad6e87c374cfdc0ae7,https://www.dropbox.com/s/aqrjfur2d7bqb2o/ballard.bin.zip?dl=0
data/input/raw_maps/downtown.bin,23a8f0e8d0adf61f1bede08f9e05c755,https://www.dropbox.com/s/wq2wm0gb62diz4x/downtown.bin.zip?dl=0
data/input/raw_maps/downtown_atx.bin,10952f03672526eab180c724af188809,https://www.dropbox.com/s/37jx8htloc5j5rr/downtown_atx.bin.zip?dl=0
data/input/raw_maps/huge_austin.bin,201d0aff6c9dde9c6f60a2af727d1b32,https://www.dropbox.com/s/jv8dhiebx35n0kg/huge_austin.bin.zip?dl=0
data/input/raw_maps/huge_seattle.bin,c497258745e278ad7d30b5801a66aaeb,https://www.dropbox.com/s/oikef0juh0iqmw3/huge_seattle.bin.zip?dl=0
data/input/raw_maps/lakeslice.bin,7ec24ec2860b91a7616cb8fe55afb3b8,https://www.dropbox.com/s/5tkypxuarkr65cd/lakeslice.bin.zip?dl=0
data/input/raw_maps/montlake.bin,e18c8a7f5992cb4af39843275f42125a,https://www.dropbox.com/s/2bn4k7axosjig4u/montlake.bin.zip?dl=0
data/input/raw_maps/south_seattle.bin,96303da5abeea874585e789eaaf4be51,https://www.dropbox.com/s/ql70xxsjgyuypd8/south_seattle.bin.zip?dl=0
data/input/raw_maps/udistrict.bin,0f876dc016f2f032c4b85395a1d73fa2,https://www.dropbox.com/s/bq38e79k7md98z5/udistrict.bin.zip?dl=0
data/input/raw_maps/west_seattle.bin,91b3ac23ceb67c81f8fc0ced172f915c,https://www.dropbox.com/s/vtdnt5zpchmdh0s/west_seattle.bin.zip?dl=0
data/input/raw_maps/ballard.bin,49d6b38ac39ef0c73ca7ab87cfedd095,https://www.dropbox.com/s/l202ox71mxkgmpr/ballard.bin.zip?dl=0
data/input/raw_maps/downtown.bin,0d91d5a5a09225c58cc930faa49b2bd7,https://www.dropbox.com/s/oja79syiyjyy7l6/downtown.bin.zip?dl=0
data/input/raw_maps/downtown_atx.bin,cf2cd0fea92b70e5555ac693b2d4a653,https://www.dropbox.com/s/02moxvh1gn41x5s/downtown_atx.bin.zip?dl=0
data/input/raw_maps/huge_austin.bin,d37364ac2da4e9d44de886457ba915ed,https://www.dropbox.com/s/updgay4ia9dsbot/huge_austin.bin.zip?dl=0
data/input/raw_maps/huge_seattle.bin,1bfac95781631cd169c18e7ea2e42b85,https://www.dropbox.com/s/tfru89wliqnekzc/huge_seattle.bin.zip?dl=0
data/input/raw_maps/lakeslice.bin,f630eaaee41b0f97b5bcdb32d115f340,https://www.dropbox.com/s/rqydln57segpxft/lakeslice.bin.zip?dl=0
data/input/raw_maps/montlake.bin,749507726d6acc94fbde892bf78bd137,https://www.dropbox.com/s/q7w9lwitdrv3ln2/montlake.bin.zip?dl=0
data/input/raw_maps/south_seattle.bin,79bec22c96156f3818a6143cf0cfe424,https://www.dropbox.com/s/tlavvkwjvlz71br/south_seattle.bin.zip?dl=0
data/input/raw_maps/udistrict.bin,bc2ca12fa404d6a33eecc7ba58310fd6,https://www.dropbox.com/s/rz9d2oxugyqqiap/udistrict.bin.zip?dl=0
data/input/raw_maps/west_seattle.bin,327141fa4a1e75f1ea9f6f56d71cbc16,https://www.dropbox.com/s/zcjq9ezbglkr81d/west_seattle.bin.zip?dl=0
data/input/screenshots/downtown/01x01.gif,873df007edd02e5967f3917cbe8f342f,https://www.dropbox.com/s/4209gvxkypinlqs/01x01.gif.zip?dl=0
data/input/screenshots/downtown/01x02.gif,ec8b579d6cb498a2a85bc2af8b51f390,https://www.dropbox.com/s/9x5qtp86h3uemzm/01x02.gif.zip?dl=0
data/input/screenshots/downtown/01x03.gif,c126afdf55a94993e6c9a909eb685f8c,https://www.dropbox.com/s/4ev4pepyvrl6bs4/01x03.gif.zip?dl=0
@ -334,18 +334,6 @@ data/input/screenshots/udistrict/combine.sh,ca086c089e56ebd7f32fe0bf5e3323c5,htt
data/input/seattle/N47W122.hgt,0db4e23e51f7680538b0bbbc72208e07,https://www.dropbox.com/s/mmb4mgutwotijdw/N47W122.hgt.zip?dl=0
data/input/seattle/blockface.bin,add872bab9040ae911366328a230f8b5,https://www.dropbox.com/s/rxd2care60tbe75/blockface.bin.zip?dl=0
data/input/seattle/blockface.kml,350bd9e59bf2af4e885a7c0741e6ee6b,https://www.dropbox.com/s/ukknmpjdvilncq9/blockface.kml.zip?dl=0
data/input/seattle/google_transit/agency.txt,75f564fcc06b1950b7b33acf9d61f696,https://www.dropbox.com/s/7k1ii8kswd6a9ul/agency.txt.zip?dl=0
data/input/seattle/google_transit/block.txt,b66cb4c0a24b2d038427aa6e1aa1954a,https://www.dropbox.com/s/zs5j2k8n7dvu3lo/block.txt.zip?dl=0
data/input/seattle/google_transit/block_trip.txt,9502d1a6e03a21c7e6987c036d5aea6f,https://www.dropbox.com/s/59rt9gfpseu4kwx/block_trip.txt.zip?dl=0
data/input/seattle/google_transit/calendar.txt,7211c370ecf3d8839ea0eb6651ed18e9,https://www.dropbox.com/s/jkecyztwks0x5t6/calendar.txt.zip?dl=0
data/input/seattle/google_transit/calendar_dates.txt,9d3deb093076d7eaf748114829802292,https://www.dropbox.com/s/7jejm1rz7zlzdcv/calendar_dates.txt.zip?dl=0
data/input/seattle/google_transit/fare_attributes.txt,ca5a7569e1af41e0046fe5e8865cf733,https://www.dropbox.com/s/z6tzowetcr4d47h/fare_attributes.txt.zip?dl=0
data/input/seattle/google_transit/fare_rules.txt,1800e4da804a8d9809d8b636742b9d00,https://www.dropbox.com/s/j6pawqjs1azvp0g/fare_rules.txt.zip?dl=0
data/input/seattle/google_transit/routes.txt,308c4e4ab385b7e8c1a1f75c4dc96e3f,https://www.dropbox.com/s/dm7mgrtya4nrt0t/routes.txt.zip?dl=0
data/input/seattle/google_transit/shapes.txt,33f4f1264b3c982f0d6922ce7fb45e73,https://www.dropbox.com/s/n78i0dj78m1ux6e/shapes.txt.zip?dl=0
data/input/seattle/google_transit/stop_times.txt,51dbf7a263fe5f0ea24e43c3aad3fec2,https://www.dropbox.com/s/p3yqw529ddz0z9m/stop_times.txt.zip?dl=0
data/input/seattle/google_transit/stops.txt,8610cdc491d036eee88c9b7ae24d692d,https://www.dropbox.com/s/v1ayguqtkv1x0cx/stops.txt.zip?dl=0
data/input/seattle/google_transit/trips.txt,8a4fbb3846249777afae319d64e6241e,https://www.dropbox.com/s/vpphfu9s5owan61/trips.txt.zip?dl=0
data/input/seattle/offstreet_parking.bin,a33c05e8962dfe10a7a14b9eb6413803,https://www.dropbox.com/s/7j2gwb18685kd5u/offstreet_parking.bin.zip?dl=0
data/input/seattle/offstreet_parking.kml,e24d1c308ca739df73621846c7b7847c,https://www.dropbox.com/s/dkkkpywob7cdo57/offstreet_parking.kml.zip?dl=0
data/input/seattle/osm/ballard.osm,ad11355d7c2c4948af91db8023342169,https://www.dropbox.com/s/yjj8ym5q251gz96/ballard.osm.zip?dl=0

View File

@ -145,7 +145,6 @@ takes a few seconds to load a serialized map.
dataset
- Match each sidewalk line to the nearest edge of a road
- Update the road to have a sidewalk on none, one, or both sides
- `lib.rs` using the `gtfs` crate: Load bus route info from GTFS
- `lib.rs` using the `srtm` module: Load (extremely poor quality) elevation data
## RawMap to InitialMap

View File

@ -112,7 +112,6 @@ Constructing the map:
- `convert_osm`: extract useful data from OpenStreetMap and other data sources,
emit intermediate map format
- `gtfs`: simple library to just extract coordinates of bus stops
- `kml`: extract shapes from KML shapefiles
- `map_model`: the final representation of the map, also conversion from the
intermediate map format into the final format

View File

@ -1,12 +0,0 @@
[package]
name = "gtfs"
version = "0.1.0"
authors = ["Dustin Carlino <dabreegster@gmail.com>"]
edition = "2018"
[dependencies]
abstutil = { path = "../abstutil" }
geom = { path = "../geom" }
itertools = "0.9.0"
serde = "1.0.110"
transitfeed = { git = "https://github.com/dabreegster/transitfeed" }

View File

@ -1,90 +0,0 @@
use geom::LonLat;
use itertools::Itertools;
use serde::{Deserialize, Serialize};
use std::collections::{BTreeSet, HashMap};
use transitfeed::GTFSIterator;
#[derive(Debug, Serialize, Deserialize, PartialEq)]
pub struct Route {
pub name: String,
pub stops: Vec<LonLat>,
}
pub fn load(dir_path: &str) -> Vec<Route> {
println!("Loading GTFS from {}", dir_path);
let mut route_id_to_name: HashMap<String, String> = HashMap::new();
for rec in GTFSIterator::<_, transitfeed::Route>::from_path(&format!("{}/routes.txt", dir_path))
.unwrap()
{
let rec = rec.unwrap();
route_id_to_name.insert(rec.route_id.clone(), rec.route_short_name.clone());
}
let mut stop_id_to_pt: HashMap<String, LonLat> = HashMap::new();
for rec in
GTFSIterator::<_, transitfeed::Stop>::from_path(&format!("{}/stops.txt", dir_path)).unwrap()
{
let rec = rec.unwrap();
stop_id_to_pt.insert(rec.stop_id.clone(), LonLat::new(rec.stop_lon, rec.stop_lat));
}
let mut trip_id_to_route_id_and_direction: HashMap<String, (String, bool)> = HashMap::new();
for rec in
GTFSIterator::<_, transitfeed::Trip>::from_path(&format!("{}/trips.txt", dir_path)).unwrap()
{
let rec = rec.unwrap();
trip_id_to_route_id_and_direction.insert(
rec.trip_id.clone(),
(
rec.route_id.clone(),
rec.direction_id.map(|d| d == "0").unwrap_or(true),
),
);
}
// Each (directed) route has many trips. Ignore all but the first and assume the list of stops
// is the same. Also assume that records with the same trip are contiguous and that
// stop_sequence is monotonic.
let mut directed_routes: HashMap<(String, bool), Vec<LonLat>> = HashMap::new();
for (key, group) in
GTFSIterator::<_, transitfeed::StopTime>::from_path(&format!("{}/stop_times.txt", dir_path))
.unwrap()
.map(|rec| rec.unwrap())
// TODO This only groups records with consecutive same trip ID. Might be a bug.
.group_by(|rec| rec.trip_id.clone())
.into_iter()
{
let (route_id, forwards) = trip_id_to_route_id_and_direction[&key].clone();
if directed_routes.contains_key(&(route_id.clone(), forwards)) {
continue;
}
directed_routes.insert(
(route_id, forwards),
group.map(|rec| stop_id_to_pt[&rec.stop_id]).collect(),
);
}
// Group together the pairs of directed routes
let route_ids: BTreeSet<String> = directed_routes
.keys()
.map(|(id, _)| id.to_string())
.collect();
let mut results = Vec::new();
for route_id in route_ids {
let mut stops = directed_routes
.remove(&(route_id.clone(), true))
.unwrap_or_else(Vec::new);
if let Some(more_stops) = directed_routes.remove(&(route_id.clone(), false)) {
stops.extend(more_stops);
}
assert!(!stops.is_empty());
results.push(Route {
name: route_id_to_name[&route_id].to_string(),
stops,
});
}
assert!(directed_routes.is_empty());
results
}

View File

@ -26,7 +26,6 @@ pub fn osm_to_raw(name: &str) {
public_offstreet_parking: None,
private_offstreet_parking: convert_osm::PrivateOffstreetParking::FixedPerBldg(1),
sidewalks: None,
gtfs: None,
elevation: None,
clip: Some(format!("../data/input/austin/polygons/{}.poly", name)),
drive_on_right: true,

View File

@ -163,7 +163,6 @@ fn oneshot(osm_path: String, clip: Option<String>, drive_on_right: bool) {
public_offstreet_parking: None,
private_offstreet_parking: convert_osm::PrivateOffstreetParking::FixedPerBldg(1),
sidewalks: None,
gtfs: None,
elevation: None,
clip,
drive_on_right,

View File

@ -3,10 +3,6 @@ use map_model::Map;
use sim::Scenario;
fn input() {
download(
"../data/input/seattle/google_transit/",
"https://metro.kingcounty.gov/GTFS/google_transit.zip",
);
download(
"../data/input/seattle/N47W122.hgt",
"https://dds.cr.usgs.gov/srtm/version2_1/SRTM1/Region_01/N47W122.hgt.zip",
@ -65,7 +61,6 @@ pub fn osm_to_raw(name: &str) {
),
// TODO These're buggy.
sidewalks: None,
gtfs: Some("../data/input/seattle/google_transit".to_string()),
elevation: Some("../data/input/seattle/N47W122.hgt".to_string()),
clip: Some(format!("../data/input/seattle/polygons/{}.poly", name)),
drive_on_right: true,

View File

@ -9,7 +9,6 @@ aabb-quadtree = "0.1.0"
abstutil = { path = "../abstutil" }
fast_paths = { git = "https://github.com/easbar/fast_paths" }
geom = { path = "../geom" }
gtfs = { path = "../gtfs" }
nbez = "0.1.0"
petgraph = "0.5.0"
serde = "1.0.110"

View File

@ -303,12 +303,11 @@ impl Map {
{
// Turn the two directions of each route into one loop. Need to do something better
// with borders later.
for r in &mut raw.new_bus_routes {
for r in &mut raw.bus_routes {
r.fwd_stops.extend(r.back_stops.drain(..));
}
let (stops, routes) =
bus_stops::make_bus_stops(&mut map, &raw.new_bus_routes, timer);
let (stops, routes) = bus_stops::make_bus_stops(&mut map, &raw.bus_routes, timer);
map.bus_stops = stops;
timer.start_iter("verify bus routes are connected", routes.len());

View File

@ -2,7 +2,6 @@ use crate::make::initial::lane_specs::get_lane_types;
use crate::{osm, AreaType, IntersectionType, RoadSpec};
use abstutil::{deserialize_btreemap, serialize_btreemap, Timer, Warn};
use geom::{Angle, Distance, GPSBounds, Line, PolyLine, Polygon, Pt2D};
use gtfs::Route;
use serde::{Deserialize, Serialize};
use std::collections::{BTreeMap, BTreeSet};
use std::fmt;
@ -26,8 +25,7 @@ pub struct RawMap {
deserialize_with = "deserialize_btreemap"
)]
pub buildings: BTreeMap<OriginalBuilding, RawBuilding>,
pub bus_routes: Vec<Route>,
pub new_bus_routes: Vec<RawBusRoute>,
pub bus_routes: Vec<RawBusRoute>,
pub areas: Vec<RawArea>,
pub parking_lots: Vec<RawParkingLot>,
pub parking_aisles: Vec<Vec<Pt2D>>,
@ -95,7 +93,6 @@ impl RawMap {
intersections: BTreeMap::new(),
buildings: BTreeMap::new(),
bus_routes: Vec::new(),
new_bus_routes: Vec::new(),
areas: Vec::new(),
parking_lots: Vec::new(),
parking_aisles: Vec::new(),