mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-24 15:02:59 +03:00
pass a flag to disable using mapfixes, since it's annoying to keep temporarily deleting these
This commit is contained in:
parent
814349b650
commit
1e903c6cee
@ -163,6 +163,7 @@ fn launch_test(test: &ABTest, ui: &mut UI, ctx: &mut EventCtx) -> ABTestMode {
|
||||
Flags {
|
||||
sim_flags: SimFlags {
|
||||
load: abstutil::path_map(&test.map_name),
|
||||
use_map_fixes: current_flags.sim_flags.use_map_fixes,
|
||||
rng_seed: current_flags.sim_flags.rng_seed,
|
||||
opts: SimOptions {
|
||||
run_name: format!("{} with {}", test.test_name, test.edits2_name),
|
||||
|
@ -52,6 +52,7 @@ impl UI {
|
||||
let include_bldgs = args.enabled("--bldgs");
|
||||
let edit_fixes = args.optional("--fixes");
|
||||
let intersection_geom = args.enabled("--geom");
|
||||
let no_fixes = args.enabled("--nofixes");
|
||||
args.done();
|
||||
|
||||
let model = if let Some(path) = load {
|
||||
@ -60,6 +61,7 @@ impl UI {
|
||||
include_bldgs,
|
||||
edit_fixes,
|
||||
intersection_geom,
|
||||
no_fixes,
|
||||
ctx.prerender,
|
||||
)
|
||||
} else {
|
||||
|
@ -47,6 +47,7 @@ impl Model {
|
||||
include_bldgs: bool,
|
||||
edit_fixes: Option<String>,
|
||||
intersection_geom: bool,
|
||||
no_fixes: bool,
|
||||
prerender: &Prerender,
|
||||
) -> Model {
|
||||
let mut timer = Timer::new("import map");
|
||||
@ -57,13 +58,15 @@ impl Model {
|
||||
model.fixes.gps_bounds = model.map.gps_bounds.clone();
|
||||
model.intersection_geom = intersection_geom;
|
||||
|
||||
let mut all_fixes = MapFixes::load(&mut timer);
|
||||
model.map.apply_fixes(&all_fixes, &mut timer);
|
||||
if let Some(ref name) = model.edit_fixes {
|
||||
if let Some(fixes) = all_fixes.remove(name) {
|
||||
model.fixes = fixes;
|
||||
if !model.fixes.gps_bounds.approx_eq(&model.map.gps_bounds) {
|
||||
panic!("Can't edit {} with this map; use the original map", name);
|
||||
if !no_fixes {
|
||||
let mut all_fixes = MapFixes::load(&mut timer);
|
||||
model.map.apply_fixes(&all_fixes, &mut timer);
|
||||
if let Some(ref name) = model.edit_fixes {
|
||||
if let Some(fixes) = all_fixes.remove(name) {
|
||||
model.fixes = fixes;
|
||||
if !model.fixes.gps_bounds.approx_eq(&model.map.gps_bounds) {
|
||||
panic!("Can't edit {} with this map; use the original map", name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -54,16 +54,16 @@ pub fn find_diffs(map: &RawMap) {
|
||||
}
|
||||
|
||||
// Fill out these tags.
|
||||
for tag_key in vec![
|
||||
for tag_key in &[
|
||||
osm::PARKING_LEFT,
|
||||
osm::PARKING_RIGHT,
|
||||
osm::PARKING_BOTH,
|
||||
osm::SIDEWALK,
|
||||
] {
|
||||
if let Some(value) = abst_tags.get(tag_key) {
|
||||
if let Some(value) = abst_tags.get(*tag_key) {
|
||||
osm_tags.insert(tag_key.to_string(), value.to_string());
|
||||
} else {
|
||||
osm_tags.remove(tag_key);
|
||||
osm_tags.remove(*tag_key);
|
||||
}
|
||||
}
|
||||
tree.children = other_children;
|
||||
|
@ -50,9 +50,11 @@ pub struct Map {
|
||||
}
|
||||
|
||||
impl Map {
|
||||
pub fn new(path: &str, timer: &mut Timer) -> Result<Map, io::Error> {
|
||||
pub fn new(path: &str, use_map_fixes: bool, timer: &mut Timer) -> Result<Map, io::Error> {
|
||||
let mut raw: RawMap = abstutil::read_binary(path, timer)?;
|
||||
raw.apply_fixes(&MapFixes::load(timer), timer);
|
||||
if use_map_fixes {
|
||||
raw.apply_fixes(&MapFixes::load(timer), timer);
|
||||
}
|
||||
// Do this after applying fixes, which might split off pieces of the map.
|
||||
make::remove_disconnected_roads(&mut raw, timer);
|
||||
Ok(Map::create_from_raw(raw, timer))
|
||||
|
@ -10,7 +10,7 @@ fn main() {
|
||||
|
||||
let mut timer = Timer::new(&format!("precompute {}", load));
|
||||
|
||||
let map = Map::new(&load, &mut timer).unwrap();
|
||||
let map = Map::new(&load, true, &mut timer).unwrap();
|
||||
timer.start("save map");
|
||||
map.save();
|
||||
timer.stop("save map");
|
||||
|
@ -8,6 +8,7 @@ use rand_xorshift::XorShiftRng;
|
||||
#[derive(Clone)]
|
||||
pub struct SimFlags {
|
||||
pub load: String,
|
||||
pub use_map_fixes: bool,
|
||||
pub rng_seed: Option<u8>,
|
||||
pub opts: SimOptions,
|
||||
}
|
||||
@ -18,6 +19,7 @@ impl SimFlags {
|
||||
load: args
|
||||
.optional_free()
|
||||
.unwrap_or_else(|| "../data/maps/montlake.bin".to_string()),
|
||||
use_map_fixes: !args.enabled("--nofixes"),
|
||||
rng_seed: args.optional_parse("--rng_seed", |s| s.parse()),
|
||||
opts: SimOptions {
|
||||
run_name: args
|
||||
@ -40,6 +42,7 @@ impl SimFlags {
|
||||
pub fn synthetic_test(map: &str, run_name: &str) -> SimFlags {
|
||||
SimFlags {
|
||||
load: abstutil::path_map(map),
|
||||
use_map_fixes: true,
|
||||
rng_seed: Some(42),
|
||||
opts: SimOptions::new(run_name),
|
||||
}
|
||||
@ -96,7 +99,7 @@ impl SimFlags {
|
||||
} else if self.load.starts_with("../data/raw_maps/") {
|
||||
timer.note(format!("Loading map {}", self.load));
|
||||
|
||||
let map = Map::new(&self.load, timer)
|
||||
let map = Map::new(&self.load, self.use_map_fixes, timer)
|
||||
.expect(&format!("Couldn't load map from {}", self.load));
|
||||
|
||||
timer.start("create sim");
|
||||
|
@ -30,11 +30,13 @@ pub fn run(t: &mut TestRunner) {
|
||||
t.run_slow("raw_to_map_twice", |_| {
|
||||
let map1 = map_model::Map::new(
|
||||
&abstutil::path_raw_map("montlake"),
|
||||
true,
|
||||
&mut abstutil::Timer::throwaway(),
|
||||
)
|
||||
.unwrap();
|
||||
let map2 = map_model::Map::new(
|
||||
&abstutil::path_raw_map("montlake"),
|
||||
true,
|
||||
&mut abstutil::Timer::throwaway(),
|
||||
)
|
||||
.unwrap();
|
||||
@ -50,6 +52,7 @@ pub fn run(t: &mut TestRunner) {
|
||||
t.run_slow("bigger_map_loads", |_| {
|
||||
map_model::Map::new(
|
||||
&abstutil::path_raw_map("23rd"),
|
||||
true,
|
||||
&mut abstutil::Timer::throwaway(),
|
||||
)
|
||||
.expect("23rd broke");
|
||||
@ -58,6 +61,7 @@ pub fn run(t: &mut TestRunner) {
|
||||
t.run_slow("biggest_map_loads", |_| {
|
||||
map_model::Map::new(
|
||||
&abstutil::path_raw_map("huge_seattle"),
|
||||
true,
|
||||
&mut abstutil::Timer::throwaway(),
|
||||
)
|
||||
.expect("huge_seattle broke");
|
||||
|
Loading…
Reference in New Issue
Block a user