mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-25 23:43:25 +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.sort_by_key(|roads| roads.len());
|
||||||
partitions.reverse();
|
partitions.reverse();
|
||||||
println!("Main partition has {} roads", partitions[0].len());
|
println!("Main partition has {} roads", partitions[0].len());
|
||||||
|
let mut remove_roads = HashSet::new();
|
||||||
for p in partitions.iter().skip(1) {
|
for p in partitions.iter().skip(1) {
|
||||||
println!("Removing disconnected partition with {} roads", p.len());
|
println!("Removing disconnected partition with {} roads", p.len());
|
||||||
for idx in p {
|
for idx in p {
|
||||||
println!("TODO: remove road {:?}", map.roads[*idx].osm_tags);
|
remove_roads.insert(idx);
|
||||||
|
}
|
||||||
// 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);*/ }
|
|
||||||
}
|
}
|
||||||
|
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
|
// Remove intersections without any roads
|
||||||
map.intersections
|
map.intersections
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# TODO for Phase 1 (Basemap)
|
# 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
|
- road with many lanes
|
||||||
- maybe also the time to split into different lane types? what's similar/not between them?
|
- maybe also the time to split into different lane types? what's similar/not between them?
|
||||||
|
Loading…
Reference in New Issue
Block a user