mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-28 12:12:00 +03:00
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:
parent
2e5649bf7e
commit
c971a732dd
20
data/fixes/misc_23rd.json
Normal file
20
data/fixes/misc_23rd.json
Normal 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
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -690,8 +690,11 @@ impl Model {
|
|||||||
// of lanes and can generate all the IDs.
|
// of lanes and can generate all the IDs.
|
||||||
self.road_deleted(id);
|
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));
|
self.world.delete(ID::Intersection(deleted_i));
|
||||||
for r in changed_roads {
|
for r in changed_roads {
|
||||||
self.road_deleted(r);
|
self.road_deleted(r);
|
||||||
|
@ -372,7 +372,9 @@ impl RawMap {
|
|||||||
let road = &self.roads[&id];
|
let road = &self.roads[&id];
|
||||||
let i1 = &self.intersections[&road.i1];
|
let i1 = &self.intersections[&road.i1];
|
||||||
let i2 = &self.intersections[&road.i2];
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,12 +393,17 @@ impl RawMap {
|
|||||||
true
|
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(
|
pub fn merge_short_road(
|
||||||
&mut self,
|
&mut self,
|
||||||
id: StableRoadID,
|
id: StableRoadID,
|
||||||
fixes: &mut MapFixes,
|
fixes: &mut MapFixes,
|
||||||
) -> Option<(StableIntersectionID, Vec<StableRoadID>)> {
|
) -> Option<(
|
||||||
|
StableIntersectionID,
|
||||||
|
StableIntersectionID,
|
||||||
|
Vec<StableRoadID>,
|
||||||
|
)> {
|
||||||
assert!(self.can_merge_short_road(id, fixes));
|
assert!(self.can_merge_short_road(id, fixes));
|
||||||
let (i1, i2) = {
|
let (i1, i2) = {
|
||||||
let r = self.roads.remove(&id).unwrap();
|
let r = self.roads.remove(&id).unwrap();
|
||||||
@ -408,8 +415,15 @@ impl RawMap {
|
|||||||
(i.point, i.orig_id)
|
(i.point, i.orig_id)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Arbitrarily keep i1 and destroy i2.
|
// Arbitrarily keep i1 and destroy i2. If the intersection types differ, upgrade the
|
||||||
self.intersections.remove(&i2).unwrap();
|
// 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.
|
// Fix up all roads connected to i2.
|
||||||
let mut fixed = Vec::new();
|
let mut fixed = Vec::new();
|
||||||
@ -430,7 +444,7 @@ impl RawMap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Some((i2, fixed))
|
Some((i1, i2, fixed))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn override_metadata(
|
pub fn override_metadata(
|
||||||
|
Loading…
Reference in New Issue
Block a user