mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-25 07:25:47 +03:00
new test to make sure raw->map conversion is also deterministic, not just convert_osm
This commit is contained in:
parent
e755aeb4ef
commit
e150ce3aef
@ -55,8 +55,8 @@ pub fn remove_disconnected_roads(map: &mut raw_data::Map, timer: &mut Timer) {
|
||||
let mut roads: Vec<raw_data::Road> = Vec::new();
|
||||
for (idx, r) in map.roads.iter().enumerate() {
|
||||
if remove_roads.contains(&idx) {
|
||||
next_roads.remove(r.first_pt(), idx);
|
||||
next_roads.remove(r.last_pt(), idx);
|
||||
next_roads.remove(r.first_pt().to_hashable(), idx);
|
||||
next_roads.remove(r.last_pt().to_hashable(), idx);
|
||||
} else {
|
||||
roads.push(r.clone());
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
use abstutil::{deserialize_btreemap, serialize_btreemap};
|
||||
use std::collections::BTreeMap;
|
||||
use {Lane, LaneType, Road, RoadID};
|
||||
|
||||
@ -7,6 +8,10 @@ use {Lane, LaneType, Road, RoadID};
|
||||
pub struct RoadEdits {
|
||||
pub edits_name: String,
|
||||
// TODO detect when we wind up editing back to the original thing
|
||||
#[serde(
|
||||
serialize_with = "serialize_btreemap",
|
||||
deserialize_with = "deserialize_btreemap"
|
||||
)]
|
||||
pub(crate) roads: BTreeMap<RoadID, RoadEdit>,
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Copyright 2018 Google LLC, licensed under http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
use abstutil;
|
||||
use abstutil::{Error, Timer};
|
||||
use abstutil::{deserialize_btreemap, serialize_btreemap, Error, Timer};
|
||||
use edits::RoadEdits;
|
||||
use geom::{Bounds, GPSBounds, HashablePt2D, PolyLine, Pt2D};
|
||||
use make;
|
||||
@ -20,9 +20,17 @@ pub struct Map {
|
||||
roads: Vec<Road>,
|
||||
lanes: Vec<Lane>,
|
||||
intersections: Vec<Intersection>,
|
||||
#[serde(
|
||||
serialize_with = "serialize_btreemap",
|
||||
deserialize_with = "deserialize_btreemap"
|
||||
)]
|
||||
turns: BTreeMap<TurnID, Turn>,
|
||||
buildings: Vec<Building>,
|
||||
parcels: Vec<Parcel>,
|
||||
#[serde(
|
||||
serialize_with = "serialize_btreemap",
|
||||
deserialize_with = "deserialize_btreemap"
|
||||
)]
|
||||
bus_stops: BTreeMap<BusStopID, BusStop>,
|
||||
bus_routes: Vec<BusRoute>,
|
||||
areas: Vec<Area>,
|
||||
|
@ -1,10 +1,11 @@
|
||||
use abstutil;
|
||||
use convert_osm;
|
||||
use map_model;
|
||||
use runner::TestRunner;
|
||||
|
||||
pub fn run(t: &mut TestRunner) {
|
||||
t.run_slow(
|
||||
"convert_twice",
|
||||
"convert_osm_twice",
|
||||
Box::new(|_| {
|
||||
let flags = convert_osm::Flags {
|
||||
osm: "../data/input/montlake.osm".to_string(),
|
||||
@ -14,7 +15,7 @@ pub fn run(t: &mut TestRunner) {
|
||||
parking_shapes: "../data/shapes/blockface".to_string(),
|
||||
gtfs: "../data/input/google_transit_2018_18_08".to_string(),
|
||||
neighborhoods: "../data/input/neighborhoods.geojson".to_string(),
|
||||
output: "convert_twice".to_string(),
|
||||
output: "convert_osm_twice".to_string(),
|
||||
};
|
||||
|
||||
let map1 = convert_osm::convert(&flags, &mut abstutil::Timer::new("convert map"));
|
||||
@ -28,4 +29,27 @@ pub fn run(t: &mut TestRunner) {
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
t.run_slow(
|
||||
"raw_to_map_twice",
|
||||
Box::new(|_| {
|
||||
let map1 = map_model::Map::new(
|
||||
"../data/raw_maps/montlake.abst",
|
||||
map_model::RoadEdits::new(),
|
||||
&mut abstutil::Timer::new("raw to map"),
|
||||
).unwrap();
|
||||
let map2 = map_model::Map::new(
|
||||
"../data/raw_maps/montlake.abst",
|
||||
map_model::RoadEdits::new(),
|
||||
&mut abstutil::Timer::new("raw to map"),
|
||||
).unwrap();
|
||||
|
||||
if abstutil::to_json(&map1) != abstutil::to_json(&map2) {
|
||||
// TODO tmp files
|
||||
abstutil::write_json("map1.json", &map1).unwrap();
|
||||
abstutil::write_json("map2.json", &map2).unwrap();
|
||||
panic!("map1.json and map2.json differ");
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user