diff --git a/cli/src/main.rs b/cli/src/main.rs index 71a7824655..4f19ba558b 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -162,6 +162,10 @@ enum Command { /// Downgrade crosswalks not matching a `highway=crossing` OSM node into unmarked crossings. #[structopt(long)] filter_crosswalks: bool, + /// Generate a simple travel demand model based on 2011 UK commuting data. This will only + /// work if the boundary is in the UK. + #[structopt(long)] + create_uk_travel_demand_model: bool, }, /// Imports a one-shot A/B Street map from an .osm file in a single command. OneshotImport { @@ -177,6 +181,10 @@ enum Command { /// Downgrade crosswalks not matching a `highway=crossing` OSM node into unmarked crossings. #[structopt(long)] filter_crosswalks: bool, + /// Generate a simple travel demand model based on 2011 UK commuting data. This will only + /// work if the boundary is in the UK. + #[structopt(long)] + create_uk_travel_demand_model: bool, #[structopt(flatten)] opts: map_model::RawToMapOptions, }, @@ -263,6 +271,7 @@ async fn main() -> Result<()> { drive_on_left, use_geofabrik, filter_crosswalks, + create_uk_travel_demand_model, } => { one_step_import::run( geojson_path, @@ -270,6 +279,7 @@ async fn main() -> Result<()> { drive_on_left, use_geofabrik, filter_crosswalks, + create_uk_travel_demand_model, ) .await? } @@ -278,8 +288,19 @@ async fn main() -> Result<()> { clip_path, drive_on_left, filter_crosswalks, + create_uk_travel_demand_model, opts, - } => importer::oneshot(osm_input, clip_path, drive_on_left, filter_crosswalks, opts), + } => { + importer::oneshot( + osm_input, + clip_path, + drive_on_left, + filter_crosswalks, + create_uk_travel_demand_model, + opts, + ) + .await + } Command::RegenerateEverything { shard_num, num_shards, diff --git a/cli/src/one_step_import.rs b/cli/src/one_step_import.rs index f50799b0a2..028fc66ff9 100644 --- a/cli/src/one_step_import.rs +++ b/cli/src/one_step_import.rs @@ -11,6 +11,7 @@ pub async fn run( drive_on_left: bool, use_geofabrik: bool, filter_crosswalks: bool, + create_uk_travel_demand_model: bool, ) -> Result<()> { if name.contains(' ') || name.is_empty() { panic!( @@ -83,8 +84,10 @@ pub async fn run( Some("boundary0.poly".to_string()), !drive_on_left, filter_crosswalks, + create_uk_travel_demand_model, map_model::RawToMapOptions::default(), - ); + ) + .await; // Clean up temporary files. If we broke before this, deliberately leave them around for // debugging. diff --git a/importer/src/lib.rs b/importer/src/lib.rs index 3a8016f75b..f7f41d59ed 100644 --- a/importer/src/lib.rs +++ b/importer/src/lib.rs @@ -89,11 +89,12 @@ pub fn regenerate_all_maps() { } /// Transforms a .osm file to a map in one step. -pub fn oneshot( +pub async fn oneshot( osm_path: String, clip: Option, drive_on_right: bool, filter_crosswalks: bool, + create_uk_travel_demand_model: bool, opts: RawToMapOptions, ) { let mut timer = abstutil::Timer::new("oneshot"); @@ -133,6 +134,15 @@ pub fn oneshot( timer.start("save map"); map.save(); timer.stop("save map"); + + if create_uk_travel_demand_model { + timer.start("generating UK travel demand model"); + uk::generate_scenario(&map, &load_configuration(), &mut timer) + .await + .unwrap(); + timer.stop("generating UK travel demand model"); + } + println!("{} has been created", map.get_name().path()); } diff --git a/map_gui/src/tools/importer.rs b/map_gui/src/tools/importer.rs index 9e31de6d28..eab8776e6f 100644 --- a/map_gui/src/tools/importer.rs +++ b/map_gui/src/tools/importer.rs @@ -85,6 +85,7 @@ impl ImportCity { ), ]), Toggle::switch(ctx, "Filter crosswalks", None, false), + Toggle::switch(ctx, "Generate travel demand model (UK only)", None, false), ]) .section(ctx), ]) @@ -129,6 +130,12 @@ impl State for ImportCity { if self.panel.is_checked("Filter crosswalks") { args.push("--filter-crosswalks".to_string()); } + if self + .panel + .is_checked("Generate travel demand model (UK only)") + { + args.push("--create-uk-travel-demand-model".to_string()); + } match grab_geojson_from_clipboard() { Ok(()) => Transition::Push(crate::tools::RunCommand::new_state( ctx,