mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 09:24:26 +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();
|
let mut roads: Vec<raw_data::Road> = Vec::new();
|
||||||
for (idx, r) in map.roads.iter().enumerate() {
|
for (idx, r) in map.roads.iter().enumerate() {
|
||||||
if remove_roads.contains(&idx) {
|
if remove_roads.contains(&idx) {
|
||||||
next_roads.remove(r.first_pt(), idx);
|
next_roads.remove(r.first_pt().to_hashable(), idx);
|
||||||
next_roads.remove(r.last_pt(), idx);
|
next_roads.remove(r.last_pt().to_hashable(), idx);
|
||||||
} else {
|
} else {
|
||||||
roads.push(r.clone());
|
roads.push(r.clone());
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use abstutil::{deserialize_btreemap, serialize_btreemap};
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use {Lane, LaneType, Road, RoadID};
|
use {Lane, LaneType, Road, RoadID};
|
||||||
|
|
||||||
@ -7,6 +8,10 @@ use {Lane, LaneType, Road, RoadID};
|
|||||||
pub struct RoadEdits {
|
pub struct RoadEdits {
|
||||||
pub edits_name: String,
|
pub edits_name: String,
|
||||||
// TODO detect when we wind up editing back to the original thing
|
// 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>,
|
pub(crate) roads: BTreeMap<RoadID, RoadEdit>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2018 Google LLC, licensed under http://www.apache.org/licenses/LICENSE-2.0
|
// Copyright 2018 Google LLC, licensed under http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
use abstutil;
|
use abstutil;
|
||||||
use abstutil::{Error, Timer};
|
use abstutil::{deserialize_btreemap, serialize_btreemap, Error, Timer};
|
||||||
use edits::RoadEdits;
|
use edits::RoadEdits;
|
||||||
use geom::{Bounds, GPSBounds, HashablePt2D, PolyLine, Pt2D};
|
use geom::{Bounds, GPSBounds, HashablePt2D, PolyLine, Pt2D};
|
||||||
use make;
|
use make;
|
||||||
@ -20,9 +20,17 @@ pub struct Map {
|
|||||||
roads: Vec<Road>,
|
roads: Vec<Road>,
|
||||||
lanes: Vec<Lane>,
|
lanes: Vec<Lane>,
|
||||||
intersections: Vec<Intersection>,
|
intersections: Vec<Intersection>,
|
||||||
|
#[serde(
|
||||||
|
serialize_with = "serialize_btreemap",
|
||||||
|
deserialize_with = "deserialize_btreemap"
|
||||||
|
)]
|
||||||
turns: BTreeMap<TurnID, Turn>,
|
turns: BTreeMap<TurnID, Turn>,
|
||||||
buildings: Vec<Building>,
|
buildings: Vec<Building>,
|
||||||
parcels: Vec<Parcel>,
|
parcels: Vec<Parcel>,
|
||||||
|
#[serde(
|
||||||
|
serialize_with = "serialize_btreemap",
|
||||||
|
deserialize_with = "deserialize_btreemap"
|
||||||
|
)]
|
||||||
bus_stops: BTreeMap<BusStopID, BusStop>,
|
bus_stops: BTreeMap<BusStopID, BusStop>,
|
||||||
bus_routes: Vec<BusRoute>,
|
bus_routes: Vec<BusRoute>,
|
||||||
areas: Vec<Area>,
|
areas: Vec<Area>,
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
use abstutil;
|
use abstutil;
|
||||||
use convert_osm;
|
use convert_osm;
|
||||||
|
use map_model;
|
||||||
use runner::TestRunner;
|
use runner::TestRunner;
|
||||||
|
|
||||||
pub fn run(t: &mut TestRunner) {
|
pub fn run(t: &mut TestRunner) {
|
||||||
t.run_slow(
|
t.run_slow(
|
||||||
"convert_twice",
|
"convert_osm_twice",
|
||||||
Box::new(|_| {
|
Box::new(|_| {
|
||||||
let flags = convert_osm::Flags {
|
let flags = convert_osm::Flags {
|
||||||
osm: "../data/input/montlake.osm".to_string(),
|
osm: "../data/input/montlake.osm".to_string(),
|
||||||
@ -14,7 +15,7 @@ pub fn run(t: &mut TestRunner) {
|
|||||||
parking_shapes: "../data/shapes/blockface".to_string(),
|
parking_shapes: "../data/shapes/blockface".to_string(),
|
||||||
gtfs: "../data/input/google_transit_2018_18_08".to_string(),
|
gtfs: "../data/input/google_transit_2018_18_08".to_string(),
|
||||||
neighborhoods: "../data/input/neighborhoods.geojson".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"));
|
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