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