From 906a647ade0db027ee07755b17a4a5eb8edf5eda Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Tue, 7 Jul 2020 07:37:02 -0700 Subject: [PATCH] better error messages for turn restrictions. fixes #146 --- convert_osm/src/osm_reader.rs | 17 +++++++++-------- convert_osm/src/split_ways.rs | 18 +++++++++--------- game/src/app.rs | 4 ++++ 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/convert_osm/src/osm_reader.rs b/convert_osm/src/osm_reader.rs index e7ca91bf05..2b0e4e09c5 100644 --- a/convert_osm/src/osm_reader.rs +++ b/convert_osm/src/osm_reader.rs @@ -21,10 +21,11 @@ pub fn extract_osm( HashSet, // OSM Node IDs HashMap, - // 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 )); } } diff --git a/convert_osm/src/split_ways.rs b/convert_osm/src/split_ways.rs index c212cb20de..7f6a4a9a44 100644 --- a/convert_osm/src/split_ways.rs +++ b/convert_osm/src/split_ways.rs @@ -20,8 +20,8 @@ pub fn split_up_roads( Vec<(i64, RawRoad)>, HashSet, HashMap, - 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 = 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; } diff --git a/game/src/app.rs b/game/src/app.rs index 91aedbeab4..f89cddd0da 100644 --- a/game/src/app.rs +++ b/game/src/app.rs @@ -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))