convert all synthetic maps during precompute.sh; they keep getting out of sync with map format changes

This commit is contained in:
Dustin Carlino 2019-02-21 09:54:28 -08:00
parent 5e9d4ca7f7
commit 70cfcc9b45
8 changed files with 38 additions and 8 deletions

View File

@ -162,7 +162,7 @@ fn populate_world(start: LaneID, map: &Map) -> new_des_model::World {
vehicle_len,
max_speed,
path.clone(),
Duration::seconds(1.0) * (i as f64),
Duration::seconds(1.0) * f64::from(i),
rand_dist(&mut rng, vehicle_len, len),
rand_dist(
&mut rng,
@ -205,7 +205,7 @@ fn densely_populate_world(map: &Map) -> new_des_model::World {
vehicle_len,
max_speed,
path,
Duration::seconds(1.0) * (i as f64),
Duration::seconds(1.0) * f64::from(i),
rand_dist(&mut rng, vehicle_len, len),
rand_dist(&mut rng, Distance::ZERO, map.get_l(last_lane).length()),
map,

View File

@ -234,7 +234,9 @@ impl<S: UIState> GUI<RenderingHints> for UI<S> {
ctx.input.populate_osd(&mut hints.osd);
// TODO a plugin should do this, even though it's such a tiny thing
if ctx.input.action_chosen("screenshot everything") {
if self.state.get_state().enable_debug_controls
&& ctx.input.action_chosen("screenshot everything")
{
let bounds = self.state.get_state().primary.map.get_bounds();
assert!(bounds.min_x == 0.0 && bounds.min_y == 0.0);
hints.mode = EventLoopMode::ScreenCaptureEverything {

View File

@ -110,6 +110,15 @@ impl GPSBounds {
}
}
pub fn get_corners(&self) -> Vec<LonLat> {
vec![
LonLat::new(self.min_lon, self.min_lat),
LonLat::new(self.max_lon, self.min_lat),
LonLat::new(self.max_lon, self.max_lat),
LonLat::new(self.min_lon, self.max_lat),
]
}
// TODO cache this
pub fn get_max_world_pt(&self) -> Pt2D {
let width = LonLat::new(self.min_lon, self.min_lat)

View File

@ -33,3 +33,9 @@ for map_path in `ls data/raw_maps/`; do
done
fi
done
# Re-export all synthetic maps from scratch.
cd precompute;
for path in `ls ../data/synthetic_maps/*`; do
RUST_BACKTRACE=1 cargo run $release_mode $path --edits_name=no_edits;
done

View File

@ -8,3 +8,4 @@ edition = "2018"
abstutil = { path = "../abstutil" }
map_model = { path = "../map_model" }
structopt = "0.2"
synthetic = { path = "../synthetic" }

View File

@ -31,7 +31,15 @@ fn main() {
.unwrap()
};
let map = Map::new(&flags.load, edits, &mut timer).unwrap();
let raw_map_path = if flags.load.contains("synthetic") {
let model: synthetic::Model =
abstutil::read_json(&flags.load).expect(&format!("Couldn't load {}", &flags.load));
model.export()
} else {
flags.load
};
let map = Map::new(&raw_map_path, edits, &mut timer).unwrap();
timer.start("save map");
map.save();
timer.stop("save map");

View File

@ -309,7 +309,8 @@ impl Model {
println!("Saved {}", path);
}
pub fn export(&self) {
// Returns path to raw map
pub fn export(&self) -> String {
let mut map = raw_data::Map::blank();
map.coordinates_in_world_space = true;
@ -369,12 +370,17 @@ impl Model {
});
}
map.boundary_polygon = map.get_gps_bounds().get_corners();
// Close off the polygon
map.boundary_polygon.push(map.boundary_polygon[3]);
let path = format!(
"../data/raw_maps/{}.abst",
self.name.as_ref().expect("Model hasn't been named yet")
);
abstutil::write_binary(&path, &map).expect(&format!("Saving {} failed", path));
println!("Exported {}", path);
path
}
// TODO Directly use raw_data and get rid of Model? Might be more maintainable long-term.

View File

@ -1,11 +1,9 @@
mod model;
use crate::model::{BuildingID, Direction, Model, ID};
use aabb_quadtree::QuadTree;
use ezgui::{Color, EventCtx, EventLoopMode, GfxCtx, Key, Text, Wizard, GUI};
use geom::{Distance, Line};
use map_model::raw_data::{StableIntersectionID, StableRoadID};
use std::{env, process};
use synthetic::{BuildingID, Direction, Model, ID};
struct UI {
model: Model,