dont depend on sim in precompute crate

This commit is contained in:
Dustin Carlino 2019-02-11 15:52:00 -08:00
parent e2de3e208c
commit a3b03952cf
2 changed files with 27 additions and 4 deletions

View File

@ -7,5 +7,5 @@ edition = "2018"
[dependencies] [dependencies]
abstutil = { path = "../abstutil" } abstutil = { path = "../abstutil" }
log = "0.4.5" log = "0.4.5"
sim = { path = "../sim" } map_model = { path = "../map_model" }
structopt = "0.2" structopt = "0.2"

View File

@ -1,20 +1,43 @@
use abstutil::{LogAdapter, Timer}; use abstutil::{LogAdapter, Timer};
use log::LevelFilter; use log::LevelFilter;
use sim::SimFlags; use map_model::{Map, MapEdits};
use structopt::StructOpt; use structopt::StructOpt;
static LOG_ADAPTER: LogAdapter = LogAdapter; 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() { fn main() {
log::set_max_level(LevelFilter::Debug); log::set_max_level(LevelFilter::Debug);
log::set_logger(&LOG_ADAPTER).unwrap(); log::set_logger(&LOG_ADAPTER).unwrap();
let flags = SimFlags::from_args(); let flags = Flags::from_args();
let mut timer = Timer::new(&format!( let mut timer = Timer::new(&format!(
"precompute {} with {}", "precompute {} with {}",
flags.load, flags.edits_name 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"); timer.start("save map");
map.save(); map.save();
timer.stop("save map"); timer.stop("save map");