From d7df50ab37e245228b1575b177876ca76da7da32 Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Tue, 12 May 2020 10:27:07 -0700 Subject: [PATCH] make a one-command version of the importer. remove barranquilla and LA, since they can just be handled by the oneshot tool, and arent being actively used yet --- .gitignore | 2 - convert_osm/src/lib.rs | 1 - .../barranquilla/polygons/barranquilla.poly | 13 ----- .../los_angeles/polygons/downtown_la.poly | 10 ---- docs/dev.md | 4 +- game/src/helpers.rs | 2 - importer/src/austin.rs | 3 +- importer/src/barranquilla.rs | 40 -------------- importer/src/los_angeles.rs | 40 -------------- importer/src/main.rs | 53 ++++++++++++++++--- importer/src/seattle.rs | 3 +- map_model/src/map.rs | 2 +- updater/src/main.rs | 2 - 13 files changed, 52 insertions(+), 123 deletions(-) delete mode 100644 data/input/barranquilla/polygons/barranquilla.poly delete mode 100644 data/input/los_angeles/polygons/downtown_la.poly delete mode 100644 importer/src/barranquilla.rs delete mode 100644 importer/src/los_angeles.rs diff --git a/.gitignore b/.gitignore index a5e188b7ea..c2d8e1acb6 100644 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,6 @@ data/config data/input/austin/osm -data/input/barranquilla/osm -data/input/los_angeles/osm data/input/seattle/blockface.bin data/input/seattle/google_transit diff --git a/convert_osm/src/lib.rs b/convert_osm/src/lib.rs index 8cd5a6d2d9..045be7a91c 100644 --- a/convert_osm/src/lib.rs +++ b/convert_osm/src/lib.rs @@ -14,7 +14,6 @@ const DIRECTED_ROAD_THICKNESS: Distance = Distance::const_meters(2.5); pub struct Options { pub osm_input: String, - pub output: String, pub city_name: String, pub name: String, diff --git a/data/input/barranquilla/polygons/barranquilla.poly b/data/input/barranquilla/polygons/barranquilla.poly deleted file mode 100644 index d4e21be40f..0000000000 --- a/data/input/barranquilla/polygons/barranquilla.poly +++ /dev/null @@ -1,13 +0,0 @@ -barranquilla -1 - -74.78668212890625 11.004472171347906 - -74.79517936706543 11.016014531982467 - -74.81174468994140 10.994277447565041 - -74.79861259460449 10.986926074732143 - -74.79105949401855 10.984229823318877 - -74.78217601776123 10.982018036194184 - -74.77623224258423 10.981049057567612 - -74.77277755737305 10.981554612030388 - -74.78668212890625 11.004472171347906 -END -END diff --git a/data/input/los_angeles/polygons/downtown_la.poly b/data/input/los_angeles/polygons/downtown_la.poly deleted file mode 100644 index ea05743b6e..0000000000 --- a/data/input/los_angeles/polygons/downtown_la.poly +++ /dev/null @@ -1,10 +0,0 @@ -downtown_la -1 - -118.24962615966797 34.079109226606356 - -118.29563140869140 34.03274552068691 - -118.23314666748047 34.0105502383134 - -118.19263458251952 34.04469442222683 - -118.21117401123047 34.08593364241354 - -118.24962615966797 34.079109226606356 -END -END diff --git a/docs/dev.md b/docs/dev.md index 86378d0a53..e657c19886 100644 --- a/docs/dev.md +++ b/docs/dev.md @@ -57,8 +57,8 @@ You can also opt into downloading updates for more cities by editing `data/config`. Opting into everything looks like this: ``` -runtime: seattle,huge_seattle,austin,barranquilla,los_angeles -input: seattle,huge_seattle,austin,barranquilla,los_angeles +runtime: seattle,huge_seattle,austin +input: seattle,huge_seattle,austin ``` `runtime` downloads new maps and scenarios in `data/system/`. `input` is used diff --git a/game/src/helpers.rs b/game/src/helpers.rs index c5ed90b3df..072ae2b634 100644 --- a/game/src/helpers.rs +++ b/game/src/helpers.rs @@ -104,9 +104,7 @@ pub fn nice_map_name(name: &str) -> &str { "udistrict" => "Univeristy District", "west_seattle" => "West Seattle", // Outside Seattle - "barranquilla" => "Barranquilla, Colombia", "downtown_atx" => "Downtown Austin", - "downtown_la" => "Los Angeles", "huge_austin" => "Austin (entire area)", _ => name, } diff --git a/importer/src/austin.rs b/importer/src/austin.rs index aecb1a6a48..4f350e2028 100644 --- a/importer/src/austin.rs +++ b/importer/src/austin.rs @@ -16,11 +16,9 @@ pub fn osm_to_raw(name: &str) { ); println!("- Running convert_osm"); - let output = format!("../data/input/raw_maps/{}.bin", name); let map = convert_osm::convert( convert_osm::Options { osm_input: format!("../data/input/austin/osm/{}.osm", name), - output: output.clone(), city_name: "austin".to_string(), name: name.to_string(), @@ -35,6 +33,7 @@ pub fn osm_to_raw(name: &str) { }, &mut abstutil::Timer::throwaway(), ); + let output = format!("../data/input/raw_maps/{}.bin", name); println!("- Saving {}", output); abstutil::write_binary(output, &map); } diff --git a/importer/src/barranquilla.rs b/importer/src/barranquilla.rs deleted file mode 100644 index 23a2d89661..0000000000 --- a/importer/src/barranquilla.rs +++ /dev/null @@ -1,40 +0,0 @@ -use crate::utils::{download, osmconvert}; - -fn input() { - download( - "../data/input/barranquilla/osm/colombia.osm.pbf", - "http://download.geofabrik.de/south-america/colombia-latest.osm.pbf", - ); -} - -pub fn osm_to_raw(name: &str) { - input(); - osmconvert( - "../data/input/barranquilla/osm/colombia.osm.pbf", - format!("../data/input/barranquilla/polygons/{}.poly", name), - format!("../data/input/barranquilla/osm/{}.osm", name), - ); - - println!("- Running convert_osm"); - let output = format!("../data/input/raw_maps/{}.bin", name); - let map = convert_osm::convert( - convert_osm::Options { - osm_input: format!("../data/input/barranquilla/osm/{}.osm", name), - output: output.clone(), - city_name: "barranquilla".to_string(), - name: name.to_string(), - - parking_shapes: None, - public_offstreet_parking: None, - private_offstreet_parking: convert_osm::PrivateOffstreetParking::FixedPerBldg(1), - sidewalks: None, - gtfs: None, - elevation: None, - clip: Some(format!("../data/input/barranquilla/polygons/{}.poly", name)), - drive_on_right: true, - }, - &mut abstutil::Timer::throwaway(), - ); - println!("- Saving {}", output); - abstutil::write_binary(output, &map); -} diff --git a/importer/src/los_angeles.rs b/importer/src/los_angeles.rs deleted file mode 100644 index 4cabb258ee..0000000000 --- a/importer/src/los_angeles.rs +++ /dev/null @@ -1,40 +0,0 @@ -use crate::utils::{download, osmconvert}; - -fn input() { - download( - "../data/input/los_angeles/osm/socal.osm.pbf", - "http://download.geofabrik.de/north-america/us/california/socal-latest.osm.pbf", - ); -} - -pub fn osm_to_raw(name: &str) { - input(); - osmconvert( - "../data/input/los_angeles/osm/socal.osm.pbf", - format!("../data/input/los_angeles/polygons/{}.poly", name), - format!("../data/input/los_angeles/osm/{}.osm", name), - ); - - println!("- Running convert_osm"); - let output = format!("../data/input/raw_maps/{}.bin", name); - let map = convert_osm::convert( - convert_osm::Options { - osm_input: format!("../data/input/los_angeles/osm/{}.osm", name), - output: output.clone(), - city_name: "los_angeles".to_string(), - name: name.to_string(), - - parking_shapes: None, - public_offstreet_parking: None, - private_offstreet_parking: convert_osm::PrivateOffstreetParking::FixedPerBldg(1), - sidewalks: None, - gtfs: None, - elevation: None, - clip: Some(format!("../data/input/los_angeles/polygons/{}.poly", name)), - drive_on_right: true, - }, - &mut abstutil::Timer::throwaway(), - ); - println!("- Saving {}", output); - abstutil::write_binary(output, &map); -} diff --git a/importer/src/main.rs b/importer/src/main.rs index 1cb94d40dd..db591d3b63 100644 --- a/importer/src/main.rs +++ b/importer/src/main.rs @@ -1,9 +1,8 @@ mod austin; -mod barranquilla; -mod los_angeles; mod seattle; mod soundcast; mod utils; + use std::thread; struct Job { @@ -14,6 +13,8 @@ struct Job { scenario_everyone: bool, only_map: Option, + + oneshot: Option, } fn main() { @@ -32,15 +33,29 @@ fn main() { // Only process one map. If not specified, process all maps defined by clipping polygons in // data/input/$city/polygons/. only_map: args.optional_free(), + + // Ignore other arguments and just convert the given .osm file to a Map. + oneshot: args.optional("--oneshot"), }; args.done(); - if !job.osm_to_raw && !job.raw_to_map && !job.scenario && !job.scenario_everyone { + if !job.osm_to_raw + && !job.raw_to_map + && !job.scenario + && !job.scenario_everyone + && job.oneshot.is_none() + { println!( - "Nothing to do! Pass some combination of --raw, --map, --scenario, --scenario_everyone" + "Nothing to do! Pass some combination of --raw, --map, --scenario, \ + --scenario_everyone or --oneshot" ); std::process::exit(1); } + if let Some(path) = job.oneshot { + oneshot(path); + return; + } + let names = if let Some(n) = job.only_map { println!("- Just working on {}", n); vec![n] @@ -54,8 +69,6 @@ fn main() { if job.osm_to_raw { match job.city.as_ref() { "austin" => austin::osm_to_raw(&name), - "barranquilla" => barranquilla::osm_to_raw(&name), - "los_angeles" => los_angeles::osm_to_raw(&name), "seattle" => seattle::osm_to_raw(&name), x => panic!("Unknown city {}", x), } @@ -92,3 +105,31 @@ fn main() { handle.join().unwrap(); } } + +fn oneshot(osm_path: String) { + let mut timer = abstutil::Timer::new("oneshot"); + println!("- Running convert_osm on {}", osm_path); + let name = abstutil::basename(&osm_path); + let raw = convert_osm::convert( + convert_osm::Options { + osm_input: osm_path, + city_name: "oneshot".to_string(), + name: name.clone(), + + parking_shapes: None, + public_offstreet_parking: None, + private_offstreet_parking: convert_osm::PrivateOffstreetParking::FixedPerBldg(1), + sidewalks: None, + gtfs: None, + elevation: None, + clip: None, + drive_on_right: true, + }, + &mut timer, + ); + let map = map_model::Map::create_from_raw(raw, &mut timer); + timer.start("save map"); + map.save(); + timer.stop("save map"); + println!("{} has been created", abstutil::path_map(&name)); +} diff --git a/importer/src/seattle.rs b/importer/src/seattle.rs index 624c29474a..14dba03072 100644 --- a/importer/src/seattle.rs +++ b/importer/src/seattle.rs @@ -42,11 +42,9 @@ pub fn osm_to_raw(name: &str) { ); println!("- Running convert_osm"); - let output = format!("../data/input/raw_maps/{}.bin", name); let map = convert_osm::convert( convert_osm::Options { osm_input: format!("../data/input/seattle/osm/{}.osm", name), - output: output.clone(), city_name: "seattle".to_string(), name: name.to_string(), @@ -66,6 +64,7 @@ pub fn osm_to_raw(name: &str) { }, &mut abstutil::Timer::throwaway(), ); + let output = format!("../data/input/raw_maps/{}.bin", name); println!("- Saving {}", output); abstutil::write_binary(output, &map); } diff --git a/map_model/src/map.rs b/map_model/src/map.rs index 13d855c077..c850c869e0 100644 --- a/map_model/src/map.rs +++ b/map_model/src/map.rs @@ -145,7 +145,7 @@ impl Map { } } - fn create_from_raw(raw: RawMap, timer: &mut Timer) -> Map { + pub fn create_from_raw(raw: RawMap, timer: &mut Timer) -> Map { timer.start("raw_map to InitialMap"); let gps_bounds = raw.gps_bounds.clone(); let bounds = gps_bounds.to_bounds(); diff --git a/updater/src/main.rs b/updater/src/main.rs index b0e5c787b8..533a5e417d 100644 --- a/updater/src/main.rs +++ b/updater/src/main.rs @@ -213,8 +213,6 @@ impl Manifest { } "huge_seattle" => map == "huge_seattle" || map == "west_seattle", "austin" => map == "downtown_atx" || map == "huge_austin", - "barranquilla" => map == "barranquilla", - "los_angeles" => map == "downtown_la", _ => panic!("Unknown city {}", city), } }