apply intersection merging EVERYWHERE... but actually, keep it disabled.
seeing some other bug.
use crate::make::half_map::HalfMap;
use crate::{Intersection, IntersectionID, Lane, LaneID, Road, RoadID, Turn, TurnID};
use abstutil::Timer;
+use dimensioned::si;
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
+use std::marker;
-const MIN_ROAD_LENGTH_METERS: f64 = 15.0;
+const MIN_ROAD_LENGTH: si::Meter<f64> = si::Meter {
+ value_unsafe: 15.0,
+ _marker: marker::PhantomData,
+};
pub fn merge_intersections(mut m: HalfMap, timer: &mut Timer) -> HalfMap {
- //m = merge(RoadID(428), m);
- //m = merge(RoadID(422), m);
-
m = merge(RoadID(422), m);
m = merge(RoadID(427), m);
- m
-
- /*
- timer.start_iter("merge short roads", data.roads.len());
+ // TODO Hits a bug. Figure it out next.
+ if false {
+ timer.start_iter("merge short roads", m.roads.len());
let mut merged = 0;
- for i in 0..data.roads.len() {
+ for i in 0..m.roads.len() {
timer.next();
// We destroy roads and shorten this list as we go. Don't break, so the timer finishes.
- if i >= data.roads.len() {
+ if i >= m.roads.len() {
continue;
}
- let mut length = 0.0;
- for pair in data.roads[i].points.windows(2) {
- length += pair[0].gps_dist_meters(pair[1]);
- }
- if length < MIN_ROAD_LENGTH_METERS {
- merge(data, i);
+ if m.roads[i].center_pts.length() < MIN_ROAD_LENGTH {
+ m = merge(RoadID(i), m);
merged += 1;
}
}
info!("Merged {} short roads", merged);
- */
+ }
+
+ m
}
fn merge(delete_r: RoadID, mut m: HalfMap) -> HalfMap {
