Skip to content

Commit

Permalink
Download GTFS for Seattle and SF. #372
Browse files Browse the repository at this point in the history
Not uploading the downloaded files yet, on a weird connection.
  • Loading branch information
dabreegster committed Nov 19, 2021
1 parent 244e965 commit 258ed1c
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 7 deletions.
2 changes: 2 additions & 0 deletions convert_osm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ pub struct Options {
pub skip_local_roads: bool,
/// Only include crosswalks that match a `highway=crossing` OSM node.
pub filter_crosswalks: bool,
/// Configure public transit using this URL to a static GTFS feed in .zip format.
pub gtfs_url: Option<String>,
}

/// What roads will have on-street parking lanes? Data from
Expand Down
5 changes: 1 addition & 4 deletions importer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ pub fn oneshot(
extra_buildings: None,
skip_local_roads: false,
filter_crosswalks,
gtfs_url: None,
},
&mut timer,
);
Expand Down Expand Up @@ -208,10 +209,6 @@ impl Job {
for name in names {
timer.start(name.describe());
if self.osm_to_raw {
if name.city == CityName::seattle() {
seattle::input(&config, timer).await;
}

if !built_raw_huge_seattle || name != MapName::seattle("huge_seattle") {
let raw = utils::osm_to_raw(name.clone(), timer, &config).await;

Expand Down
8 changes: 8 additions & 0 deletions importer/src/map_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,13 @@ pub fn config_for_map(name: &MapName) -> convert_osm::Options {
extra_buildings,
skip_local_roads: name == &MapName::new("us", "phoenix", "loop101"),
filter_crosswalks: false,
// https://www.transit.land is a great place to find the static GTFS URLs
gtfs_url: if name.city == CityName::seattle() {
Some("http://metro.kingcounty.gov/GTFS/google_transit.zip".to_string())
} else if name.city == CityName::new("us", "san_francisco") {
Some("https://gtfs.sfmta.com/transitdata/google_transit.zip".to_string())
} else {
None
},
}
}
1 change: 0 additions & 1 deletion importer/src/seattle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ pub async fn ensure_popdat_exists(
}

if !abstio::file_exists(abstio::path_raw_map(&huge_name)) {
input(config, timer).await;
crate::utils::osm_to_raw(MapName::seattle("huge_seattle"), timer, config).await;
*built_raw_huge_seattle = true;
}
Expand Down
12 changes: 10 additions & 2 deletions importer/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::path::Path;
use std::process::Command;

use abstio::MapName;
use abstio::{CityName, MapName};
use abstutil::{must_run_cmd, Timer};
use map_model::raw::RawMap;
use map_model::RawToMapOptions;
Expand Down Expand Up @@ -118,6 +118,14 @@ pub async fn osm_to_raw(
timer: &mut abstutil::Timer<'_>,
config: &ImporterConfiguration,
) -> RawMap {
if name.city == CityName::seattle() {
crate::seattle::input(config, timer).await;
}
let opts = crate::map_config::config_for_map(&name);
if let Some(ref url) = opts.gtfs_url {
download(config, name.city.input_path("gtfs/"), url).await;
}

let boundary_polygon = format!(
"importer/config/{}/{}/{}.poly",
name.city.country, name.city.city, name.map
Expand Down Expand Up @@ -148,7 +156,7 @@ pub async fn osm_to_raw(
name.city.input_path(format!("osm/{}.osm", name.map)),
name.clone(),
Some(boundary_polygon),
crate::map_config::config_for_map(&name),
opts,
timer,
);
map.save();
Expand Down
1 change: 1 addition & 0 deletions tests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ fn import_map(path: String) -> Map {
extra_buildings: None,
skip_local_roads: false,
filter_crosswalks: false,
gtfs_url: None,
},
&mut timer,
);
Expand Down

0 comments on commit 258ed1c

Please sign in to comment.