From 8b975f5083de65cf9fb2038f8e4902a4771d0ab4 Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Mon, 20 Apr 2020 16:12:09 -0700 Subject: [PATCH] validation was wrong, and also panicking is bad right now --- popdat/src/lib.rs | 2 +- popdat/src/trips.rs | 13 +------------ sim/src/make/scenario.rs | 20 +++++++++++++++----- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/popdat/src/lib.rs b/popdat/src/lib.rs index 7ae1f1fd80..13c015f4ac 100644 --- a/popdat/src/lib.rs +++ b/popdat/src/lib.rs @@ -3,7 +3,7 @@ mod trips; use serde_derive::{Deserialize, Serialize}; use std::collections::BTreeMap; -pub use trips::{clip_trips, trips_to_scenario, Trip, TripEndpt}; +pub use trips::trips_to_scenario; #[derive(Serialize, Deserialize)] pub struct PopDat { diff --git a/popdat/src/trips.rs b/popdat/src/trips.rs index 902df9af12..39feba852d 100644 --- a/popdat/src/trips.rs +++ b/popdat/src/trips.rs @@ -1,7 +1,7 @@ use crate::psrc::{Endpoint, Mode, Parcel, Purpose}; use crate::PopDat; use abstutil::{prettyprint_usize, MultiMap, Timer}; -use geom::{Distance, Duration, LonLat, Polygon, Pt2D, Time}; +use geom::{Distance, Duration, LonLat, Pt2D, Time}; use map_model::{BuildingID, IntersectionID, Map, PathConstraints}; use sim::{DrivingGoal, IndividTrip, PersonID, PersonSpec, Scenario, SidewalkSpot, SpawnTrip}; use std::collections::HashMap; @@ -31,10 +31,6 @@ pub enum TripEndpt { } impl Trip { - pub fn end_time(&self) -> Time { - self.depart_at + self.trip_time - } - fn to_spawn_trip(&self, map: &Map) -> SpawnTrip { match self.mode { Mode::Drive => match self.from { @@ -124,13 +120,6 @@ impl TripEndpt { } } } - - pub fn polygon<'a>(&self, map: &'a Map) -> &'a Polygon { - match self { - TripEndpt::Building(b) => &map.get_b(*b).polygon, - TripEndpt::Border(i, _) => &map.get_i(*i).polygon, - } - } } pub fn clip_trips(map: &Map, timer: &mut Timer) -> (Vec, HashMap) { diff --git a/sim/src/make/scenario.rs b/sim/src/make/scenario.rs index 337804d3b1..9d01c0c112 100644 --- a/sim/src/make/scenario.rs +++ b/sim/src/make/scenario.rs @@ -217,14 +217,24 @@ impl Scenario { timer.next(); // Verify that the trip start/endpoints of each person match up for pair in person.trips.iter().zip(person.trips.iter().skip(1)) { - let end = pair.0.trip.end(); - let start = pair.1.trip.start(map); - if end != start { + // Once off-map, re-enter via any border node. + let end_bldg = match pair.0.trip.end() { + TripEndpoint::Bldg(b) => Some(b), + TripEndpoint::Border(_) => None, + }; + let start_bldg = match pair.1.trip.start(map) { + TripEndpoint::Bldg(b) => Some(b), + TripEndpoint::Border(_) => None, + }; + if end_bldg != start_bldg { println!("{} warps between some trips:", person.id); for trip in &person.trips { - println!("- {:?}", trip); + println!(" - {:?}", trip); } - panic!("Ends at {:?}, then starts at {:?}", end, start); + println!( + "{} ends at {:?}, then starts at {:?}", + person.id, end_bldg, start_bldg + ); } } }