mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-29 17:34:58 +03:00
prune unrouteable bus routes in map model layer
This commit is contained in:
parent
7b3069a1a1
commit
da550910c7
@ -5,7 +5,8 @@ use make::sidewalk_finder::find_sidewalk_points;
|
|||||||
use multimap::MultiMap;
|
use multimap::MultiMap;
|
||||||
use ordered_float::NotNaN;
|
use ordered_float::NotNaN;
|
||||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||||
use {BusRoute, BusStop, BusStopID, Lane, LaneID, Road};
|
use std::iter;
|
||||||
|
use {BusRoute, BusStop, BusStopID, Lane, LaneID, Map, Pathfinder, Road};
|
||||||
|
|
||||||
pub fn make_bus_stops(
|
pub fn make_bus_stops(
|
||||||
lanes: &mut Vec<Lane>,
|
lanes: &mut Vec<Lane>,
|
||||||
@ -78,3 +79,30 @@ pub fn make_bus_stops(
|
|||||||
}
|
}
|
||||||
(bus_stops, routes)
|
(bus_stops, routes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn verify_bus_routes(map: &Map, routes: Vec<BusRoute>) -> Vec<BusRoute> {
|
||||||
|
routes
|
||||||
|
.into_iter()
|
||||||
|
.filter(|r| {
|
||||||
|
let mut ok = true;
|
||||||
|
for (stop1, stop2) in r
|
||||||
|
.stops
|
||||||
|
.iter()
|
||||||
|
.zip(r.stops.iter().skip(1))
|
||||||
|
.chain(iter::once((r.stops.last().unwrap(), &r.stops[0])))
|
||||||
|
{
|
||||||
|
let bs1 = map.get_bs(*stop1);
|
||||||
|
let bs2 = map.get_bs(*stop2);
|
||||||
|
if Pathfinder::shortest_distance(map, bs1.driving_lane, bs2.driving_lane).is_none()
|
||||||
|
{
|
||||||
|
debug!(
|
||||||
|
"Removing route {} since {:?} and {:?} aren't connected",
|
||||||
|
r.name, bs1, bs2
|
||||||
|
);
|
||||||
|
ok = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ok
|
||||||
|
}).collect()
|
||||||
|
}
|
||||||
|
@ -7,7 +7,7 @@ mod trim_lines;
|
|||||||
mod turns;
|
mod turns;
|
||||||
|
|
||||||
pub(crate) use self::buildings::make_all_buildings;
|
pub(crate) use self::buildings::make_all_buildings;
|
||||||
pub(crate) use self::bus_stops::make_bus_stops;
|
pub(crate) use self::bus_stops::{make_bus_stops, verify_bus_routes};
|
||||||
pub(crate) use self::lanes::get_lane_specs;
|
pub(crate) use self::lanes::get_lane_specs;
|
||||||
pub(crate) use self::parcels::make_all_parcels;
|
pub(crate) use self::parcels::make_all_parcels;
|
||||||
pub(crate) use self::trim_lines::trim_lines;
|
pub(crate) use self::trim_lines::trim_lines;
|
||||||
|
@ -166,7 +166,6 @@ impl Map {
|
|||||||
let (stops, routes) =
|
let (stops, routes) =
|
||||||
make::make_bus_stops(&mut m.lanes, &m.roads, &data.bus_routes, &bounds);
|
make::make_bus_stops(&mut m.lanes, &m.roads, &data.bus_routes, &bounds);
|
||||||
m.bus_stops = stops;
|
m.bus_stops = stops;
|
||||||
m.bus_routes = routes;
|
|
||||||
|
|
||||||
for i in &m.intersections {
|
for i in &m.intersections {
|
||||||
for t in make::make_all_turns(i, &m) {
|
for t in make::make_all_turns(i, &m) {
|
||||||
@ -205,6 +204,11 @@ impl Map {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
let _guard = flame::start_guard(format!("verify {} bus routes", routes.len()));
|
||||||
|
m.bus_routes = make::verify_bus_routes(&m, routes);
|
||||||
|
}
|
||||||
|
|
||||||
m
|
m
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user