1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#[macro_use]
extern crate anyhow;
#[macro_use]
extern crate log;
use serde::{Deserialize, Serialize};
use abstutil::{deserialize_usize, serialize_usize};
use map_model::PathConstraints;
pub use self::borders::{MapBorder, MapBorders};
pub use self::counts::TrafficCounts;
pub use self::endpoint::TripEndpoint;
pub use self::external::{ExternalPerson, ExternalTrip, ExternalTripEndpoint};
pub use self::modifier::ScenarioModifier;
pub use self::scenario::{IndividTrip, PersonSpec, Scenario, TripPurpose};
mod borders;
mod counts;
mod endpoint;
mod external;
mod modifier;
mod scenario;
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Clone, Copy, PartialOrd, Ord)]
pub enum TripMode {
Walk,
Bike,
Transit,
Drive,
}
impl TripMode {
pub fn all() -> Vec<TripMode> {
vec![
TripMode::Walk,
TripMode::Bike,
TripMode::Transit,
TripMode::Drive,
]
}
pub fn verb(self) -> &'static str {
match self {
TripMode::Walk => "walk",
TripMode::Bike => "bike",
TripMode::Transit => "use transit",
TripMode::Drive => "drive",
}
}
pub fn ongoing_verb(self) -> &'static str {
match self {
TripMode::Walk => "walking",
TripMode::Bike => "biking",
TripMode::Transit => "using transit",
TripMode::Drive => "driving",
}
}
pub fn noun(self) -> &'static str {
match self {
TripMode::Walk => "Pedestrian",
TripMode::Bike => "Bike",
TripMode::Transit => "Bus",
TripMode::Drive => "Car",
}
}
pub fn to_constraints(self) -> PathConstraints {
match self {
TripMode::Walk => PathConstraints::Pedestrian,
TripMode::Bike => PathConstraints::Bike,
TripMode::Transit => PathConstraints::Bus,
TripMode::Drive => PathConstraints::Car,
}
}
pub fn from_constraints(c: PathConstraints) -> TripMode {
match c {
PathConstraints::Pedestrian => TripMode::Walk,
PathConstraints::Bike => TripMode::Bike,
PathConstraints::Bus | PathConstraints::Train => TripMode::Transit,
PathConstraints::Car => TripMode::Drive,
}
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct OrigPersonID(
#[serde(
serialize_with = "serialize_usize",
deserialize_with = "deserialize_usize"
)]
pub usize,
#[serde(
serialize_with = "serialize_usize",
deserialize_with = "deserialize_usize"
)]
pub usize,
);