mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-01 02:33:54 +03:00
Codify some different strategies for merging short roads
This commit is contained in:
parent
175f5d411a
commit
a38228d5da
@ -345,6 +345,26 @@ impl RawMap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When we delete the short road, we modify the polyline of all of the connected surviving
|
||||||
|
// roads. There are a bunch of ways we could modify them, and also decide which ones to
|
||||||
|
// even modify. These combinations are captured here.
|
||||||
|
#[allow(dead_code)]
|
||||||
|
enum ModifyGeom {
|
||||||
|
AddOnePoint,
|
||||||
|
// Destructive -- this often dramatically warps the angle of connecting roads
|
||||||
|
ChangeEndpoint,
|
||||||
|
AddAllPoints,
|
||||||
|
}
|
||||||
|
#[allow(dead_code)]
|
||||||
|
enum ModifyWhichRoads {
|
||||||
|
None,
|
||||||
|
All,
|
||||||
|
ArbitrarilyOne,
|
||||||
|
OnlyNormalRoads,
|
||||||
|
}
|
||||||
|
let modify_geom = ModifyGeom::AddOnePoint;
|
||||||
|
let modify_which = ModifyWhichRoads::All;
|
||||||
|
|
||||||
// Fix up all roads connected to i2. Delete them and create a new copy; the ID changes,
|
// Fix up all roads connected to i2. Delete them and create a new copy; the ID changes,
|
||||||
// since one intersection changes.
|
// since one intersection changes.
|
||||||
let mut deleted = vec![short];
|
let mut deleted = vec![short];
|
||||||
@ -358,22 +378,45 @@ impl RawMap {
|
|||||||
if r.i1 == i2 {
|
if r.i1 == i2 {
|
||||||
new_id.i1 = i1;
|
new_id.i1 = i1;
|
||||||
|
|
||||||
if false {
|
if match modify_which {
|
||||||
// Destructive -- this often dramatically warps the angle of connecting roads
|
ModifyWhichRoads::None => false,
|
||||||
road.center_points[0] = i1_pt;
|
ModifyWhichRoads::All => true,
|
||||||
} else {
|
ModifyWhichRoads::ArbitrarilyOne => created.is_empty(),
|
||||||
// TODO More extreme: All of the points of the short road. Except there usually
|
ModifyWhichRoads::OnlyNormalRoads => {
|
||||||
// aren't many, since they're short.
|
!road.osm_tags.is("junction", "intersection")
|
||||||
road.center_points.insert(0, i1_pt);
|
}
|
||||||
|
} {
|
||||||
|
match modify_geom {
|
||||||
|
ModifyGeom::AddOnePoint => {
|
||||||
|
road.center_points.insert(0, i1_pt);
|
||||||
|
}
|
||||||
|
ModifyGeom::ChangeEndpoint => {
|
||||||
|
road.center_points[0] = i1_pt;
|
||||||
|
}
|
||||||
|
ModifyGeom::AddAllPoints => todo!(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assert_eq!(r.i2, i2);
|
assert_eq!(r.i2, i2);
|
||||||
new_id.i2 = i1;
|
new_id.i2 = i1;
|
||||||
|
|
||||||
if false {
|
if match modify_which {
|
||||||
*road.center_points.last_mut().unwrap() = i1_pt;
|
ModifyWhichRoads::None => false,
|
||||||
} else {
|
ModifyWhichRoads::All => true,
|
||||||
road.center_points.push(i1_pt);
|
ModifyWhichRoads::ArbitrarilyOne => created.is_empty(),
|
||||||
|
ModifyWhichRoads::OnlyNormalRoads => {
|
||||||
|
!road.osm_tags.is("junction", "intersection")
|
||||||
|
}
|
||||||
|
} {
|
||||||
|
match modify_geom {
|
||||||
|
ModifyGeom::AddOnePoint => {
|
||||||
|
road.center_points.push(i1_pt);
|
||||||
|
}
|
||||||
|
ModifyGeom::ChangeEndpoint => {
|
||||||
|
*road.center_points.last_mut().unwrap() = i1_pt;
|
||||||
|
}
|
||||||
|
ModifyGeom::AddAllPoints => todo!(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
old_to_new.insert(r, new_id);
|
old_to_new.insert(r, new_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user