-
Notifications
You must be signed in to change notification settings - Fork 0
/
const.py
167 lines (128 loc) · 4.29 KB
/
const.py
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Constants
@author: ai6644
"""
from enum import Enum
maxLat = 55.84911
maxLon = 14.41956
minLat = 55.36272
minLon = 13.44177
class LegMode(object):
CAR = 'CAR'
WALK = 'WALK'
BUS = 'BUS'
RAIL = 'RAIL'
BICYCLE = 'BICYCLE'
TRAM = 'TRAM'
SUBWAY = 'SUBWAY'
CAR_PARK = 'CAR_PARK'
BICYCLE_PARK = 'BICYCLE_PARK'
BICYCLE_RENT = 'BICYCLE_RENT'
DRT = 'DRT'
_DICT = ['CAR', 'WALK', 'BUS', 'RAIL', 'BICYCLE', 'TRAM', 'SUBWAY',
'CAR_PARK', 'BICYCLE_PARK', 'BICYCLE_RENT', 'DRT']
_MAIN_MODES = ['CAR', 'BICYCLE', 'BUS', 'RAIL', 'WALK']
@staticmethod
def get_all_modes():
return [LegMode.__dict__.get(item) for item in LegMode._DICT]
@staticmethod
def get_main_modes():
return [LegMode.__dict__.get(item) for item in LegMode._MAIN_MODES]
@staticmethod
def contains(other):
return other in LegMode._DICT
@staticmethod
def get_mode(string):
if LegMode.contains(string):
return LegMode
else:
raise Exception('unsupported mode {}'.format(string))
class OtpMode(object):
CAR = 'CAR'
WALK = 'WALK'
TRANSIT = 'TRANSIT,WALK'
BUS = 'BUS,WALK'
RAIL = 'TRAM,RAIL,SUBWAY,FUNICULAR,GONDOLA,WALK'
BICYCLE = 'BICYCLE'
BICYCLE_TRANSIT = 'TRANSIT,BICYCLE'
PARK_RIDE = 'CAR_PARK,WALK,TRANSIT'
KISS_RIDE = 'CAR_DROPOFF,WALK,TRANSIT'
RIDE_KISS = 'TRANSIT,WALK,CAR_PICKUP'
BIKE_RIDE = 'BICYCLE_PARK,WALK,TRANSIT'
RENTED_BICYCLE = 'WALK,BICYCLE_RENT'
TRANSIT_RENTED_BICYCLE = 'TRANSIT,WALK,BICYCLE_RENT'
DRT = 'DRT'
DRT_TRANSIT = 'DRT_TRANSIT'
_DICT = ['CAR', 'WALK', 'TRANSIT', 'BUS', 'RAIL', 'BICYCLE', 'BICYCLE_TRANSIT', 'PARK_RIDE', 'KISS_RIDE',
'RIDE_KISS', 'BIKE_RIDE', 'RENTED_BICYCLE', 'TRANSIT_RENTED_BICYCLE', 'DRT', 'DRT_TRANSIT']
_MAIN_MODES = ['CAR', 'BICYCLE', 'TRANSIT', 'WALK']
_DRT_MODES = ['DRT', 'DRT_TRANSIT']
_PT_MODES = ['TRANSIT', 'BUS', 'RAIL']
@staticmethod
def get_all_modes():
return [OtpMode.__dict__.get(item) for item in OtpMode._DICT]
@staticmethod
def get_main_modes():
return [OtpMode.__dict__.get(item) for item in OtpMode._MAIN_MODES]
@staticmethod
def contains(other):
return other in OtpMode._DICT
@staticmethod
def get_pt_modes():
return OtpMode._PT_MODES
@staticmethod
def get_drt_modes():
return OtpMode._DRT_MODES
@staticmethod
def get_mode(string):
if OtpMode.contains(string):
return OtpMode.__getattribute__(OtpMode(), string)
else:
raise Exception('unsupported mode {}'.format(string))
class TravelType(Enum):
WITHIN = 'within'
IN = 'in'
OUT = 'out'
class CapacityDimensions(object):
"""jsprit requires capacity dimensions to be integers
"""
SEATS = 0
WHEELCHAIRS = 1
class VehicleCost(object):
DISTANCE = 'distance'
FIXED = 'fixed'
TIME = 'time'
WAIT = 'wait'
class ActivityType(Enum):
HOME = 'HOME'
WORK = 'WORK'
def __str__(self):
return self.name
@staticmethod
def contains(other):
return other in ActivityType.__dict__
@staticmethod
def get_activity(string):
if ActivityType.contains(string):
return ActivityType.__getitem__(string)
else:
raise Exception('unsupported mode {}'.format(string))
class PersAttr(Enum):
ID = 'ID'
AGE = 'AGE'
class TripAttr(Enum):
TIME = 'TIME'
MODE = 'MODE'
DIST = 'DIST'
class DrtStatus(Enum):
routed = 'routed' # normal DRT operation, currently all routed trips are executed
undeliverable = 'undeliverable' # request cannot be delivered due to OTP errors (if no path found)
unassigned = 'unassigned' # request went to jsprit, but it was unable to route it
overnight_trip = 'overnight_trip'
no_stop = 'no_stop' # no stop for extra-zonal DRT trip found (either too close, or outside of DRT boundaries)
one_leg = 'one_leg' # only one leg returned by DRT, most likely OD coordinates are close to PT stops
too_short_drt_leg = 'too_short_local'
too_late_request = 'too_late_request'
too_long_pt_trip = 'too_long_pt_trip' # when the whole DRT_TRANSIT trip is more than max time window (direct*1.5)