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
This commit is contained in:
Dustin Carlino 2020-05-12 10:27:07 -07:00
parent e61cf5f8c3
commit d7df50ab37
13 changed files with 52 additions and 123 deletions

2
.gitignore vendored
View File

@ -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

View File

@ -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,

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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,
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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<String>,
oneshot: Option<String>,
}
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));
}

View File

@ -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);
}

View File

@ -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();

View File

@ -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),
}
}