mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-25 11:44:25 +03:00
try manually merging some intersections again, without needing to modify geometry
This commit is contained in:
parent
be9a9b86fe
commit
98ab06bd4e
@ -4,6 +4,7 @@ mod half_map;
|
||||
mod intersections;
|
||||
mod lanes;
|
||||
mod merge_intersections;
|
||||
mod old_merge_intersections;
|
||||
mod parcels;
|
||||
mod sidewalk_finder;
|
||||
mod turns;
|
||||
@ -12,4 +13,5 @@ pub use self::buildings::make_all_buildings;
|
||||
pub use self::bus_stops::{make_bus_stops, verify_bus_routes};
|
||||
pub use self::half_map::make_half_map;
|
||||
pub use self::lanes::{get_lane_types, RoadSpec};
|
||||
pub use self::old_merge_intersections::old_merge_intersections;
|
||||
pub use self::parcels::make_all_parcels;
|
||||
|
51
map_model/src/make/old_merge_intersections.rs
Normal file
51
map_model/src/make/old_merge_intersections.rs
Normal file
@ -0,0 +1,51 @@
|
||||
use crate::raw_data;
|
||||
use abstutil::Timer;
|
||||
|
||||
pub fn old_merge_intersections(data: &mut raw_data::Map, _timer: &mut Timer) {
|
||||
/*if true {
|
||||
return;
|
||||
}*/
|
||||
|
||||
// 15th and McGraw
|
||||
merge(data, raw_data::StableRoadID(59));
|
||||
|
||||
// 14th and Boston
|
||||
merge(data, raw_data::StableRoadID(389));
|
||||
merge(data, raw_data::StableRoadID(22));
|
||||
|
||||
// TODO When we want to find the roads to do this automatically, we can't use original road
|
||||
// length, since it effectively changes while we delete intersections...
|
||||
}
|
||||
|
||||
fn merge(data: &mut raw_data::Map, merge_road: raw_data::StableRoadID) {
|
||||
// Arbitrarily kill off the first intersection and keep the second one.
|
||||
let (delete_i, keep_i) = {
|
||||
let r = data.roads.remove(&merge_road).unwrap();
|
||||
(r.i1, r.i2)
|
||||
};
|
||||
data.intersections.remove(&delete_i);
|
||||
|
||||
for r in data.roads.values_mut() {
|
||||
if r.i1 == delete_i {
|
||||
r.i1 = keep_i;
|
||||
}
|
||||
if r.i2 == delete_i {
|
||||
r.i2 = keep_i;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO retain for btreemap, please!
|
||||
let mut remove_roads: Vec<raw_data::StableRoadID> = Vec::new();
|
||||
for (id, r) in &data.roads {
|
||||
if r.i1 == r.i2 {
|
||||
remove_roads.push(*id);
|
||||
}
|
||||
}
|
||||
for id in remove_roads {
|
||||
data.roads.remove(&id);
|
||||
}
|
||||
// TODO Not exactly sure WHEN this happens, but we can wind up creating some loop roads...
|
||||
// filter them out.
|
||||
// TODO Ah, we can also wind up with multiple roads between the same intersections here. Should
|
||||
// probably auto-remove those too.
|
||||
}
|
@ -64,7 +64,7 @@ impl Map {
|
||||
|
||||
pub fn create_from_raw(
|
||||
name: String,
|
||||
data: raw_data::Map,
|
||||
mut data: raw_data::Map,
|
||||
edits: MapEdits,
|
||||
timer: &mut Timer,
|
||||
) -> Map {
|
||||
@ -73,6 +73,8 @@ impl Map {
|
||||
let gps_bounds = data.get_gps_bounds();
|
||||
let bounds = gps_bounds.to_bounds();
|
||||
|
||||
make::old_merge_intersections(&mut data, timer);
|
||||
|
||||
let half_map = make::make_half_map(&data, &gps_bounds, &edits, timer);
|
||||
let mut m = Map {
|
||||
name,
|
||||
|
Loading…
Reference in New Issue
Block a user