mirror of
https://github.com/a-b-street/abstreet.git
synced 2025-01-01 10:57:17 +03:00
automatically merge all short roads
This commit is contained in:
parent
e150ce3aef
commit
e4e1eb139e
@ -99,7 +99,12 @@ fn tooltip_lines(obj: ID, map: &Map, sim: &Sim, draw_map: &DrawMap) -> Text {
|
||||
"Lane goes from {} to {}",
|
||||
i1.elevation, i2.elevation
|
||||
));
|
||||
txt.add_line(format!("Lane is {} long", l.length()));
|
||||
txt.add_line(format!(
|
||||
"Lane is {} long, parent {} is {} long",
|
||||
l.length(),
|
||||
r.id,
|
||||
r.center_pts.length()
|
||||
));
|
||||
for (k, v) in &r.osm_tags {
|
||||
txt.add_line(format!("{} = {}", k, v));
|
||||
}
|
||||
|
@ -6,13 +6,30 @@ use std::collections::{HashMap, HashSet};
|
||||
type IntersectionID = usize;
|
||||
type RoadID = usize;
|
||||
|
||||
pub fn merge_intersections(data: &mut raw_data::Map, map_name: &str, _timer: &mut Timer) {
|
||||
if map_name == "montlake" {
|
||||
merge(data, 423); // 23rd and Shelby
|
||||
merge(data, 419); // 23rd and Hamlin
|
||||
merge(data, 258); // 23rd and Louisa
|
||||
merge(data, 42); // 25th and Lynn
|
||||
const MIN_ROAD_LENGTH_METERS: f64 = 15.0;
|
||||
|
||||
pub fn merge_intersections(data: &mut raw_data::Map, timer: &mut Timer) {
|
||||
timer.start_iter("merge short roads", data.roads.len());
|
||||
|
||||
let mut merged = 0;
|
||||
for i in 0..data.roads.len() {
|
||||
timer.next();
|
||||
// We destroy roads and shorten this list as we go. Don't break, so the timer finishes.
|
||||
if i >= data.roads.len() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let mut length = 0.0;
|
||||
for pair in data.roads[i].points.windows(2) {
|
||||
length += pair[0].gps_dist_meters(pair[1]);
|
||||
}
|
||||
if length < MIN_ROAD_LENGTH_METERS {
|
||||
merge(data, i);
|
||||
merged += 1;
|
||||
}
|
||||
}
|
||||
|
||||
info!("Merged {} short roads", merged);
|
||||
}
|
||||
|
||||
fn merge(data: &mut raw_data::Map, merge_road: RoadID) {
|
||||
|
@ -66,7 +66,7 @@ impl Map {
|
||||
) -> Map {
|
||||
timer.start("raw_map to Map");
|
||||
|
||||
make::merge_intersections(&mut data, &name, timer);
|
||||
make::merge_intersections(&mut data, timer);
|
||||
|
||||
let gps_bounds = data.get_gps_bounds();
|
||||
let bounds = gps_bounds.to_bounds();
|
||||
|
Loading…
Reference in New Issue
Block a user