better error messages for turn restrictions. fixes #146

This commit is contained in:
Dustin Carlino 2020-07-07 07:37:02 -07:00
parent 476e0e101f
commit 906a647ade
3 changed files with 22 additions and 17 deletions

View File

@ -21,10 +21,11 @@ pub fn extract_osm(
HashSet<HashablePt2D>,
// OSM Node IDs
HashMap<HashablePt2D, i64>,
// Simple turn restrictions: (restriction type, from way ID, via node ID, to way ID)
Vec<(RestrictionType, i64, i64, i64)>,
// Complicated turn restrictions: (from way ID, via way ID, to way ID)
Vec<(i64, i64, i64)>,
// Simple turn restrictions: (relation ID, restriction type, from way ID, via node ID, to way
// ID)
Vec<(i64, RestrictionType, i64, i64, i64)>,
// Complicated turn restrictions: (relation ID, from way ID, via way ID, to way ID)
Vec<(i64, i64, i64, i64)>,
// Amenities (location, name, amenity type)
Vec<(Pt2D, String, String)>,
) {
@ -230,16 +231,16 @@ pub fn extract_osm(
if let Some(rt) = RestrictionType::new(restriction) {
if let (Some(from), Some(via), Some(to)) = (from_way_id, via_node_id, to_way_id)
{
simple_turn_restrictions.push((rt, from, via, to));
simple_turn_restrictions.push((rel.id, rt, from, via, to));
} else if let (Some(from), Some(via), Some(to)) =
(from_way_id, via_way_id, to_way_id)
{
if rt == RestrictionType::BanTurns {
complicated_turn_restrictions.push((from, via, to));
complicated_turn_restrictions.push((rel.id, from, via, to));
} else {
timer.warn(format!(
"Weird complicated turn restriction from {} to {} via {}: {}",
from, to, via, restriction
"Weird complicated turn restriction \"{}\" from way {} to way {} via way {}: https://www.openstreetmap.org/relation/{}",
restriction, from, to, via, rel.id
));
}
}

View File

@ -20,8 +20,8 @@ pub fn split_up_roads(
Vec<(i64, RawRoad)>,
HashSet<HashablePt2D>,
HashMap<HashablePt2D, i64>,
Vec<(RestrictionType, i64, i64, i64)>,
Vec<(i64, i64, i64)>,
Vec<(i64, RestrictionType, i64, i64, i64)>,
Vec<(i64, i64, i64, i64)>,
Vec<(Pt2D, String, String)>,
),
timer: &mut Timer,
@ -108,7 +108,7 @@ pub fn split_up_roads(
// Resolve simple turn restrictions (via a node)
let mut restrictions = Vec::new();
for (restriction, from_osm, via_osm, to_osm) in simple_turn_restrictions {
for (rel_osm, restriction, from_osm, via_osm, to_osm) in simple_turn_restrictions {
let roads = map.roads_per_intersection(OriginalIntersection {
osm_node_id: via_osm,
});
@ -121,8 +121,8 @@ pub fn split_up_roads(
}
_ => {
timer.warn(format!(
"Couldn't resolve {:?} from {} to {} via node {}",
restriction, from_osm, to_osm, via_osm
"Couldn't resolve {:?} from way {} to way {} via node {}: see https://www.openstreetmap.org/relation/{}",
restriction, from_osm, to_osm, via_osm, rel_osm
));
}
}
@ -138,7 +138,7 @@ pub fn split_up_roads(
// Resolve complicated turn restrictions (via a way). TODO Only handle via ways immediately
// connected to both roads, for now
let mut complicated_restrictions = Vec::new();
for (from_osm, via_osm, to_osm) in complicated_turn_restrictions {
for (rel_osm, from_osm, via_osm, to_osm) in complicated_turn_restrictions {
let via_candidates: Vec<OriginalRoad> = map
.roads
.keys()
@ -147,9 +147,9 @@ pub fn split_up_roads(
.collect();
if via_candidates.len() != 1 {
timer.warn(format!(
"Couldn't resolve turn restriction from {} to {} via way {}. Candidate roads for \
via: {:?}",
from_osm, to_osm, via_osm, via_candidates
"Couldn't resolve turn restriction from way {} to way {} via way {}. Candidate roads for \
via: {:?}. See https://www.openstreetmap.org/relation/{}",
from_osm, to_osm, via_osm, via_candidates, rel_osm
));
continue;
}

View File

@ -104,6 +104,10 @@ impl App {
"- intersection_thruput: {} bytes",
prettyprint_usize(serialized_size_bytes(&a.intersection_thruput))
);
println!(
"- demand : {} bytes",
prettyprint_usize(serialized_size_bytes(&a.demand))
);
println!(
"- bus_arrivals : {} bytes",
prettyprint_usize(serialized_size_bytes(&a.bus_arrivals))