mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-25 23:43:25 +03:00
dont depend on sim in precompute crate
This commit is contained in:
parent
e2de3e208c
commit
a3b03952cf
@ -7,5 +7,5 @@ edition = "2018"
|
||||
[dependencies]
|
||||
abstutil = { path = "../abstutil" }
|
||||
log = "0.4.5"
|
||||
sim = { path = "../sim" }
|
||||
map_model = { path = "../map_model" }
|
||||
structopt = "0.2"
|
||||
|
@ -1,20 +1,43 @@
|
||||
use abstutil::{LogAdapter, Timer};
|
||||
use log::LevelFilter;
|
||||
use sim::SimFlags;
|
||||
use map_model::{Map, MapEdits};
|
||||
use structopt::StructOpt;
|
||||
|
||||
static LOG_ADAPTER: LogAdapter = LogAdapter;
|
||||
|
||||
#[derive(StructOpt)]
|
||||
#[structopt(name = "precompute")]
|
||||
struct Flags {
|
||||
/// Map
|
||||
#[structopt(name = "load")]
|
||||
load: String,
|
||||
|
||||
/// Name of map edits. Shouldn't be a full path or have the ".json"
|
||||
#[structopt(long = "edits_name")]
|
||||
edits_name: String,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
log::set_max_level(LevelFilter::Debug);
|
||||
log::set_logger(&LOG_ADAPTER).unwrap();
|
||||
|
||||
let flags = SimFlags::from_args();
|
||||
let flags = Flags::from_args();
|
||||
let mut timer = Timer::new(&format!(
|
||||
"precompute {} with {}",
|
||||
flags.load, flags.edits_name
|
||||
));
|
||||
let (map, _) = sim::load(flags, None, &mut timer);
|
||||
|
||||
let edits: MapEdits = if flags.edits_name == "no_edits" {
|
||||
MapEdits::new(&flags.load)
|
||||
} else {
|
||||
abstutil::read_json(&format!(
|
||||
"../data/edits/{}/{}.json",
|
||||
flags.load, flags.edits_name
|
||||
))
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
let map = Map::new(&flags.load, edits, &mut timer).unwrap();
|
||||
timer.start("save map");
|
||||
map.save();
|
||||
timer.stop("save map");
|
||||
|
Loading…
Reference in New Issue
Block a user