Clean up code and regenerate everything with new the consolidation algorithm... #654

Phinney gridlocks again; 68daa6884a was
too ambitious. Otherwise all fine!
This commit is contained in:
Dustin Carlino 2021-07-19 15:06:46 -07:00
parent c7b6c11e37
commit d10d8ceb33
7 changed files with 773 additions and 822 deletions

File diff suppressed because it is too large Load Diff

View File

@ -33,7 +33,7 @@ pub fn prebake_all() {
MapName::seattle("greenlake"),
MapName::seattle("montlake"),
MapName::seattle("lakeslice"),
MapName::seattle("phinney"),
//MapName::seattle("phinney"),
MapName::seattle("qa"),
MapName::seattle("rainier_valley"),
MapName::seattle("wallingford"),

View File

@ -597,8 +597,9 @@ fn recalculate_intersection_polygon(
intersection.orig_id,
intersection_roads,
&mut roads,
// For consolidated intersections, it appears we don't need to pass in
// trim_roads_for_merging. May revisit this later if needed.
&BTreeMap::new(),
//intersection.merged,
)
.unwrap()
.0;

View File

@ -95,15 +95,6 @@ pub fn intersection_polygon(
.collect::<Vec<_>>();
if !trim_roads_for_merging.is_empty() {
// TODO Keep this or not?
/*if let Some(fixed) = convex_hull_merged_intersection(
result.clone(),
intersection_id,
intersection_roads,
roads,
) {
return Ok((fixed, debug));
}*/
pretrimmed_geometry(roads, intersection_id, &lines)
} else if let Some(result) = on_off_ramp(roads, intersection_id, lines.clone()) {
Ok(result)
@ -647,36 +638,3 @@ fn on_off_ramp(
//let dummy = Circle::new(orig_lines[0].3.last_pt(), Distance::meters(3.0)).to_polygon();
//Some((close_off_polygon(dummy.into_points()), debug))
}
// The polygon produced by generalized_trim_back for merged intersections is usually jagged. A
// simple fix is to take the convex hull of the result. But this is only valid when the trimmed
// road center-lines still hit the polygon only at the border.
fn convex_hull_merged_intersection(
input: Polygon,
intersection_id: osm::NodeID,
intersection_roads: BTreeSet<OriginalRoad>,
roads: &BTreeMap<OriginalRoad, Road>,
) -> Option<Polygon> {
let candidate = Polygon::convex_hull(vec![input]);
let candidate_ring = candidate.clone().into_ring();
for id in intersection_roads {
let r = &roads[&id];
let trimmed_endpt = if r.src_i == intersection_id {
r.trimmed_center_pts.first_pt()
} else {
r.trimmed_center_pts.last_pt()
};
// If we wanted to be more paranoid here, we could also check the left and right shifted
// polylines.
// Assume the convex hull could only ever "grow" the input, never "shrink" it. So it should
// suffice to see if the trimmed endpoint is in the interior of the polygon.
if candidate.contains_pt(trimmed_endpt) && !candidate_ring.contains_pt(trimmed_endpt) {
// We could also trim this road based on the new hit. Except that would then require
// modifying the polygon a bit!
return None;
}
}
Some(candidate)
}

View File

@ -118,7 +118,6 @@ impl Map {
incoming_lanes: Vec::new(),
outgoing_lanes: Vec::new(),
roads: i.roads.iter().map(|id| road_id_mapping[id]).collect(),
// TODO Keep trim_roads_for_merging?
merged: !raw.intersections[&i.id].trim_roads_for_merging.is_empty(),
});
intersection_id_mapping.insert(i.id, id);

View File

@ -349,17 +349,17 @@ impl RawMap {
if let Some(pl) = self.trimmed_road_geometry(r) {
if r.i1 == i {
if trim_roads_for_merging.contains_key(&(r.osm_way_id, true)) {
panic!("ahhhh dupe for {}", r);
panic!("trim_roads_for_merging has an i1 duplicate for {}", r);
}
trim_roads_for_merging.insert((r.osm_way_id, true), pl.first_pt());
} else {
if trim_roads_for_merging.contains_key(&(r.osm_way_id, false)) {
panic!("ahhhh dupe for {}", r);
panic!("trim_roads_for_merging has an i2 duplicate for {}", r);
}
trim_roads_for_merging.insert((r.osm_way_id, false), pl.last_pt());
}
} else {
panic!("no trimmed_road_geometry for {}", r);
panic!("No trimmed_road_geometry at all for {}", r);
}
}
}

View File

@ -4,56 +4,49 @@
"scenario": "weekday",
"finished_trips": 76618,
"cancelled_trips": 0,
"total_trip_duration_seconds": 45457701.20759995
"total_trip_duration_seconds": 46047737.44350003
},
{
"map": "greenlake (in seattle (us))",
"scenario": "weekday",
"finished_trips": 136848,
"cancelled_trips": 30,
"total_trip_duration_seconds": 79580364.40930083
"total_trip_duration_seconds": 78232736.04019925
},
{
"map": "montlake (in seattle (us))",
"scenario": "weekday",
"finished_trips": 36723,
"cancelled_trips": 73,
"total_trip_duration_seconds": 19724275.440800197
"total_trip_duration_seconds": 19694209.279900048
},
{
"map": "lakeslice (in seattle (us))",
"scenario": "weekday",
"finished_trips": 260931,
"cancelled_trips": 4885,
"total_trip_duration_seconds": 204868704.89849666
},
{
"map": "phinney (in seattle (us))",
"scenario": "weekday",
"finished_trips": 138499,
"cancelled_trips": 0,
"total_trip_duration_seconds": 86802602.80429807
"total_trip_duration_seconds": 204353658.49570182
},
{
"map": "qa (in seattle (us))",
"scenario": "weekday",
"finished_trips": 53866,
"cancelled_trips": 0,
"total_trip_duration_seconds": 19805229.338499893
"total_trip_duration_seconds": 19769536.95049988
},
{
"map": "rainier_valley (in seattle (us))",
"scenario": "weekday",
"finished_trips": 68100,
"cancelled_trips": 0,
"total_trip_duration_seconds": 41738712.882400125
"total_trip_duration_seconds": 41603896.18329961
},
{
"map": "wallingford (in seattle (us))",
"scenario": "weekday",
"finished_trips": 133431,
"cancelled_trips": 0,
"total_trip_duration_seconds": 69044674.2322003
"total_trip_duration_seconds": 78316878.12640005
},
{
"map": "center (in poundbury (gb))",