exclude cul-de-sacs

This commit is contained in:
Dustin Carlino 2018-11-13 14:13:32 -08:00
parent 88334d50ca
commit 8f15eccf8d
3 changed files with 21 additions and 4 deletions

View File

@ -261,6 +261,7 @@ I thought I had a list of these somewhere else?
- min length for lanes, turns - min length for lanes, turns
- connectivity - connectivity
- no loop lanes (same src and dst endpt)... but what about cul-de-sacs then?
## Border nodes ## Border nodes

View File

@ -108,9 +108,9 @@ impl Map {
let mut counter = 0; let mut counter = 0;
timer.start_iter("expand roads to lanes", data.roads.len()); timer.start_iter("expand roads to lanes", data.roads.len());
for (idx, r) in data.roads.iter().enumerate() { for (_, r) in data.roads.iter().enumerate() {
timer.next(); timer.next();
let road_id = RoadID(idx); let road_id = RoadID(m.roads.len());
let road_center_pts = PolyLine::new( let road_center_pts = PolyLine::new(
r.points r.points
.iter() .iter()
@ -120,6 +120,12 @@ impl Map {
let i1 = pt_to_intersection[&HashablePt2D::from(road_center_pts.first_pt())]; let i1 = pt_to_intersection[&HashablePt2D::from(road_center_pts.first_pt())];
let i2 = pt_to_intersection[&HashablePt2D::from(road_center_pts.last_pt())]; let i2 = pt_to_intersection[&HashablePt2D::from(road_center_pts.last_pt())];
if i1 == i2 {
// TODO Cul-de-sacs should be valid, but it really makes pathfinding screwy
error!("OSM way {} is a loop on {}, skipping", r.osm_way_id, i1);
continue;
}
m.roads.push(Road { m.roads.push(Road {
id: road_id, id: road_id,
osm_tags: r.osm_tags.clone(), osm_tags: r.osm_tags.clone(),

View File

@ -378,8 +378,18 @@ fn validate(map: &Map, steps: &Vec<PathStep>) {
error!("All steps in invalid path:"); error!("All steps in invalid path:");
for s in steps { for s in steps {
match s { match s {
PathStep::Lane(l) => error!(" {:?} from {} to {}", s, map.get_l(*l).src_i, map.get_l(*l).dst_i), PathStep::Lane(l) => error!(
PathStep::ContraflowLane(l) => error!(" {:?} from {} to {}", s, map.get_l(*l).dst_i, map.get_l(*l).src_i), " {:?} from {} to {}",
s,
map.get_l(*l).src_i,
map.get_l(*l).dst_i
),
PathStep::ContraflowLane(l) => error!(
" {:?} from {} to {}",
s,
map.get_l(*l).dst_i,
map.get_l(*l).src_i
),
PathStep::Turn(_) => error!(" {:?}", s), PathStep::Turn(_) => error!(" {:?}", s),
} }
} }