mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 01:15:12 +03:00
Optionally generate a scenario for one-shot imported UK maps. #842
This commit is contained in:
parent
0203de046d
commit
deffc35fd7
@ -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,
|
||||
|
@ -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.
|
||||
|
@ -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<String>,
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -85,6 +85,7 @@ impl<A: AppLike + 'static> ImportCity<A> {
|
||||
),
|
||||
]),
|
||||
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<A: AppLike + 'static> State<A> for ImportCity<A> {
|
||||
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,
|
||||
|
Loading…
Reference in New Issue
Block a user