more flexibly merge short roads with stop sign and traffic signal. use it to fix a stuck part of 23rd.

This commit is contained in:
Dustin Carlino 2019-09-29 20:50:14 -07:00
parent 2e5649bf7e
commit c971a732dd
3 changed files with 44 additions and 7 deletions

20
data/fixes/misc_23rd.json Normal file
View File

@ -0,0 +1,20 @@
{
"gps_bounds": {
"min_lon": -122.31036966897095,
"min_lat": 47.597290174872846,
"max_lon": -122.29152725418099,
"max_lat": 47.65513966206871
},
"override_metadata": [],
"delete_roads": [],
"delete_intersections": [],
"add_intersections": [],
"add_roads": [],
"merge_short_roads": [
{
"osm_way_id": 6460085,
"node1": 53211697,
"node2": 53211698
}
]
}

View File

@ -690,8 +690,11 @@ impl Model {
// of lanes and can generate all the IDs.
self.road_deleted(id);
let (deleted_i, changed_roads) = self.map.merge_short_road(id, &mut self.fixes).unwrap();
let (retained_i, deleted_i, changed_roads) =
self.map.merge_short_road(id, &mut self.fixes).unwrap();
self.world.delete(ID::Intersection(retained_i));
self.intersection_added(retained_i, prerender);
self.world.delete(ID::Intersection(deleted_i));
for r in changed_roads {
self.road_deleted(r);

View File

@ -372,7 +372,9 @@ impl RawMap {
let road = &self.roads[&id];
let i1 = &self.intersections[&road.i1];
let i2 = &self.intersections[&road.i2];
if i1.intersection_type != i2.intersection_type {
if i1.intersection_type == IntersectionType::Border
|| i2.intersection_type == IntersectionType::Border
{
return false;
}
@ -391,12 +393,17 @@ impl RawMap {
true
}
// (the deleted intersection, list of modified roads connected to deleted intersection)
// (the surviving intersection, the deleted intersection, list of modified roads connected to
// deleted intersection)
pub fn merge_short_road(
&mut self,
id: StableRoadID,
fixes: &mut MapFixes,
) -> Option<(StableIntersectionID, Vec<StableRoadID>)> {
) -> Option<(
StableIntersectionID,
StableIntersectionID,
Vec<StableRoadID>,
)> {
assert!(self.can_merge_short_road(id, fixes));
let (i1, i2) = {
let r = self.roads.remove(&id).unwrap();
@ -408,8 +415,15 @@ impl RawMap {
(i.point, i.orig_id)
};
// Arbitrarily keep i1 and destroy i2.
self.intersections.remove(&i2).unwrap();
// Arbitrarily keep i1 and destroy i2. If the intersection types differ, upgrade the
// surviving interesting.
{
let i = self.intersections.remove(&i2).unwrap();
if i.intersection_type == IntersectionType::TrafficSignal {
self.intersections.get_mut(&i1).unwrap().intersection_type =
IntersectionType::TrafficSignal;
}
}
// Fix up all roads connected to i2.
let mut fixed = Vec::new();
@ -430,7 +444,7 @@ impl RawMap {
}
}
Some((i2, fixed))
Some((i1, i2, fixed))
}
pub fn override_metadata(