mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-25 07:25:47 +03:00
fixed the disconnected partition removal algorithm; it was just plain wrong
This commit is contained in:
parent
36bfa9cfdf
commit
70c571c9bc
@ -45,16 +45,23 @@ pub fn remove_disconnected_roads(map: &mut raw_data::Map) {
|
||||
partitions.sort_by_key(|roads| roads.len());
|
||||
partitions.reverse();
|
||||
println!("Main partition has {} roads", partitions[0].len());
|
||||
let mut remove_roads = HashSet::new();
|
||||
for p in partitions.iter().skip(1) {
|
||||
println!("Removing disconnected partition with {} roads", p.len());
|
||||
for idx in p {
|
||||
println!("TODO: remove road {:?}", map.roads[*idx].osm_tags);
|
||||
|
||||
// TODO this is expensive
|
||||
/*let old_r = map.roads.remove(*idx);
|
||||
next_roads.remove(old_r.first_pt(), *idx);
|
||||
next_roads.remove(old_r.last_pt(), *idx);*/ }
|
||||
remove_roads.insert(idx);
|
||||
}
|
||||
}
|
||||
let mut roads: Vec<raw_data::Road> = Vec::new();
|
||||
for (idx, r) in map.roads.iter().enumerate() {
|
||||
if remove_roads.contains(&idx) {
|
||||
next_roads.remove(r.first_pt(), idx);
|
||||
next_roads.remove(r.last_pt(), idx);
|
||||
} else {
|
||||
roads.push(r.clone());
|
||||
}
|
||||
}
|
||||
map.roads = roads;
|
||||
|
||||
// Remove intersections without any roads
|
||||
map.intersections
|
||||
|
@ -1,6 +1,6 @@
|
||||
# TODO for Phase 1 (Basemap)
|
||||
|
||||
- remove disconnected parts of the map (to speed up spawning things)
|
||||
- trim buidings and parcels that're nowhere near roads (aka, the bbox is kinda wrong)
|
||||
|
||||
- road with many lanes
|
||||
- maybe also the time to split into different lane types? what's similar/not between them?
|
||||
|
Loading…
Reference in New Issue
Block a user