mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-25 23:43:25 +03:00
validation was wrong, and also panicking is bad right now
This commit is contained in:
parent
c89a4c6bb9
commit
8b975f5083
@ -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 {
|
||||
|
@ -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<Trip>, HashMap<BuildingID, Parcel>) {
|
||||
|
@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user