-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lab 583 support vehicles #58
Changes from 57 commits
2c6748d
e8dfba2
5fb248e
b96582e
1771744
9d77efa
0cb0e57
a546c57
5a397be
1c53209
f79fc84
a20251f
04eae89
54e4445
830191b
7542a46
c9154bf
b6d9a75
665e218
e7adc50
e57289f
2f395a3
aad4b06
1c818fd
cd88f5f
fe2a7ed
9787cf7
bf00749
1782062
1652c36
d276dd8
4f16dec
160020e
97b5c22
5e192a5
2d3cdb1
82dcf73
22dbc9b
2a878c1
020eb6e
b1936e1
99dc7b0
9648330
f2ebf53
ba1d0e0
fb37bdc
2d2def9
2a988cf
344dd65
b48da91
8715a9e
d58c900
a5599d5
063d7e0
5aaf687
c3dd504
68fe517
e654d17
a227fd8
297076a
4090eed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
# form basis for vehicle modes in the schedule, used when reading in GTFS and present in the schedule | ||
# unless replaced by reading vehicles.xml file | ||
VEHICLE_TYPES: | ||
|
||
'bus': | ||
'capacity': | ||
'seats': | ||
'persons': '70' | ||
'standingRoom': | ||
'persons': '0' | ||
'length': | ||
'meter': '18.0' | ||
'width': | ||
'meter': '2.5' | ||
'accessTime': | ||
'secondsPerPerson': '0.5' | ||
'egressTime': | ||
'secondsPerPerson': '0.5' | ||
'doorOperation': | ||
'mode': 'serial' | ||
'passengerCarEquivalents': | ||
'pce': '2.8' | ||
|
||
'rail': | ||
'capacity': | ||
'seats': | ||
'persons': '1000' | ||
'standingRoom': | ||
'persons': '0' | ||
'length': | ||
'meter': '200.0' | ||
'width': | ||
'meter': '2.8' | ||
'accessTime': | ||
'secondsPerPerson': '0.25' | ||
'egressTime': | ||
'secondsPerPerson': '0.25' | ||
'doorOperation': | ||
'mode': 'serial' | ||
'passengerCarEquivalents': | ||
'pce': '27.1' | ||
|
||
'subway': | ||
'capacity': | ||
'seats': | ||
'persons': '1000' | ||
'standingRoom': | ||
'persons': '0' | ||
'length': | ||
'meter': '30.0' | ||
'width': | ||
'meter': '2.45' | ||
'accessTime': | ||
'secondsPerPerson': '0.1' | ||
'egressTime': | ||
'secondsPerPerson': '0.1' | ||
'doorOperation': | ||
'mode': 'serial' | ||
'passengerCarEquivalents': | ||
'pce': '4.4' | ||
|
||
'ferry': | ||
'capacity': | ||
'seats': | ||
'persons': '250' | ||
'standingRoom': | ||
'persons': '0' | ||
'length': | ||
'meter': '50.0' | ||
'width': | ||
'meter': '6.0' | ||
'accessTime': | ||
'secondsPerPerson': '0.5' | ||
'egressTime': | ||
'secondsPerPerson': '0.5' | ||
'doorOperation': | ||
'mode': 'serial' | ||
'passengerCarEquivalents': | ||
'pce': '7.1' | ||
|
||
'tram': | ||
'capacity': | ||
'seats': | ||
'persons': '180' | ||
'standingRoom': | ||
'persons': '0' | ||
'length': | ||
'meter': '36.0' | ||
'width': | ||
'meter': '2.4' | ||
'accessTime': | ||
'secondsPerPerson': '0.25' | ||
'egressTime': | ||
'secondsPerPerson': '0.25' | ||
'doorOperation': | ||
'mode': 'serial' | ||
'passengerCarEquivalents': | ||
'pce': '5.2' | ||
|
||
'funicular': | ||
'capacity': | ||
'seats': | ||
'persons': '180' | ||
'standingRoom': | ||
'persons': '0' | ||
'length': | ||
'meter': '36.0' | ||
'width': | ||
'meter': '2.4' | ||
'accessTime': | ||
'secondsPerPerson': '0.25' | ||
'egressTime': | ||
'secondsPerPerson': '0.25' | ||
'doorOperation': | ||
'mode': 'serial' | ||
'passengerCarEquivalents': | ||
'pce': '5.2' | ||
|
||
'gondola': | ||
'capacity': | ||
'seats': | ||
'persons': '250' | ||
'standingRoom': | ||
'persons': '0' | ||
'length': | ||
'meter': '50.0' | ||
'width': | ||
'meter': '6.0' | ||
'accessTime': | ||
'secondsPerPerson': '0.5' | ||
'egressTime': | ||
'secondsPerPerson': '0.5' | ||
'doorOperation': | ||
'mode': 'serial' | ||
'passengerCarEquivalents': | ||
'pce': '7.1' | ||
|
||
'cablecar': | ||
'capacity': | ||
'seats': | ||
'persons': '250' | ||
'standingRoom': | ||
'persons': '0' | ||
'length': | ||
'meter': '50.0' | ||
'width': | ||
'meter': '6.0' | ||
'accessTime': | ||
'secondsPerPerson': '0.5' | ||
'egressTime': | ||
'secondsPerPerson': '0.5' | ||
'doorOperation': | ||
'mode': 'serial' | ||
'passengerCarEquivalents': | ||
'pce': '7.1' |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,3 +60,10 @@ class StopIndexError(Exception): | |
Raised in case of Stop indexing inconsistency | ||
""" | ||
pass | ||
|
||
|
||
class InconsistentVehicleModeError(Exception): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm hooked now |
||
""" | ||
Raised when vehicles are shared between Routes with different modes | ||
""" | ||
pass |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import re | ||
import logging | ||
import networkx as nx | ||
import xml.etree.cElementTree as ET | ||
|
@@ -219,9 +220,15 @@ def write_transitLinesTransitRoute(transitLine, transitRoutes, transportMode): | |
|
||
route = [r_val['link']['refId'] for r_val in transitRoute_val['links']] | ||
|
||
trips = {} | ||
trips = { | ||
'trip_id': [], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a one-to-one relationship between trip IDs, trip departure times, and vehicle IDs? Or will these 3 lists each be of different sizes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah it's one to one, so at index There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ooh, first time I'm seeing this, I like! I'll add a jira card to that effect, thanks! |
||
'trip_departure_time': [], | ||
'vehicle_id': [] | ||
} | ||
for dep in transitRoute_val['departure_list']: | ||
trips[dep['departure']['id']] = dep['departure']['departureTime'] | ||
trips['trip_id'].append(dep['departure']['id']) | ||
trips['trip_departure_time'].append(dep['departure']['departureTime']) | ||
trips['vehicle_id'].append(dep['departure']['vehicleRefId']) | ||
|
||
r = Route( | ||
route_short_name=transitLine['transitLine']['name'], | ||
|
@@ -302,3 +309,27 @@ def write_transitLinesTransitRoute(transitLine, transitRoutes, transportMode): | |
write_transitLinesTransitRoute(transitLine, transitRoutes, transportMode) | ||
|
||
return services, minimalTransferTimes | ||
|
||
|
||
def read_vehicles(vehicles_path): | ||
vehicles = {} | ||
vehicle_types = {} | ||
v = {'capacity': {}} | ||
read_capacity = False | ||
for event, elem in ET.iterparse(vehicles_path): | ||
tag = re.sub('{http://www\.matsim\.org/files/dtd}', '', elem.tag) # noqa: W605 | ||
if tag == 'vehicle': | ||
_id = elem.attrib.pop('id') | ||
vehicles[_id] = elem.attrib | ||
read_capacity = False | ||
elif tag == 'vehicleType': | ||
vehicle_types[elem.attrib['id']] = v | ||
v = {'capacity': {}} | ||
read_capacity = False | ||
elif tag == 'capacity': | ||
read_capacity = True | ||
elif read_capacity: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this belong in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. took me a while to clock this 😂 , the capacity attributes get read before the capacity tag appears, the flag |
||
v[tag] = elem.attrib | ||
else: | ||
v['capacity'][tag] = elem.attrib | ||
return vehicles, vehicle_types |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,115 +98,3 @@ | |
# 'freespeedFactor': 1.0, | ||
'capacity': 9999.0} | ||
} | ||
|
||
|
||
MODE_DICT = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete is the best refactoring 😄 |
||
"tram": 'Tram', | ||
"subway": 'Subway', | ||
"rail": 'Rail', | ||
"bus": 'Bus', | ||
"ferry": 'Ferry', | ||
"cablecar": 'Cablecar', | ||
"gondola": 'Gondola', | ||
"funicular": 'Funicular' | ||
} | ||
|
||
|
||
VEHICLE_TYPES = { | ||
'Bus': { | ||
'capacity': { | ||
'seats': {'persons': '70'}, | ||
'standingRoom': {'persons': '0'} | ||
}, | ||
'length': {'meter': '18.0'}, | ||
'width': {'meter': '2.5'}, | ||
'accessTime': {'secondsPerPerson': '0.5'}, | ||
'egressTime': {'secondsPerPerson': '0.5'}, | ||
'doorOperation': {'mode': 'serial'}, | ||
'passengerCarEquivalents': {'pce': '2.8'} | ||
}, | ||
'Rail': { | ||
'capacity': { | ||
'seats': {'persons': '1000'}, | ||
'standingRoom': {'persons': '0'} | ||
}, | ||
'length': {'meter': '200.0'}, | ||
'width': {'meter': '2.8'}, | ||
'accessTime': {'secondsPerPerson': '0.25'}, | ||
'egressTime': {'secondsPerPerson': '0.25'}, | ||
'doorOperation': {'mode': 'serial'}, | ||
'passengerCarEquivalents': {'pce': '27.1'} | ||
}, | ||
'Subway': { | ||
'capacity': { | ||
'seats': {'persons': '1000'}, | ||
'standingRoom': {'persons': '0'} | ||
}, | ||
'length': {'meter': '30.0'}, | ||
'width': {'meter': '2.45'}, | ||
'accessTime': {'secondsPerPerson': '0.1'}, | ||
'egressTime': {'secondsPerPerson': '0.1'}, | ||
'doorOperation': {'mode': 'serial'}, | ||
'passengerCarEquivalents': {'pce': '4.4'} | ||
}, | ||
'Ferry': { | ||
'capacity': { | ||
'seats': {'persons': '250'}, | ||
'standingRoom': {'persons': '0'} | ||
}, | ||
'length': {'meter': '50.0'}, | ||
'width': {'meter': '6.0'}, | ||
'accessTime': {'secondsPerPerson': '0.5'}, | ||
'egressTime': {'secondsPerPerson': '0.5'}, | ||
'doorOperation': {'mode': 'serial'}, | ||
'passengerCarEquivalents': {'pce': '7.1'} | ||
}, | ||
'Tram': { | ||
'capacity': { | ||
'seats': {'persons': '180'}, | ||
'standingRoom': {'persons': '0'} | ||
}, | ||
'length': {'meter': '36.0'}, | ||
'width': {'meter': '2.4'}, | ||
'accessTime': {'secondsPerPerson': '0.25'}, | ||
'egressTime': {'secondsPerPerson': '0.25'}, | ||
'doorOperation': {'mode': 'serial'}, | ||
'passengerCarEquivalents': {'pce': '5.2'} | ||
}, | ||
'Funicular': { | ||
'capacity': { | ||
'seats': {'persons': '180'}, | ||
'standingRoom': {'persons': '0'} | ||
}, | ||
'length': {'meter': '36.0'}, | ||
'width': {'meter': '2.4'}, | ||
'accessTime': {'secondsPerPerson': '0.25'}, | ||
'egressTime': {'secondsPerPerson': '0.25'}, | ||
'doorOperation': {'mode': 'serial'}, | ||
'passengerCarEquivalents': {'pce': '5.2'} | ||
}, | ||
'Gondola': { | ||
'capacity': { | ||
'seats': {'persons': '250'}, | ||
'standingRoom': {'persons': '0'} | ||
}, | ||
'length': {'meter': '50.0'}, | ||
'width': {'meter': '6.0'}, | ||
'accessTime': {'secondsPerPerson': '0.5'}, | ||
'egressTime': {'secondsPerPerson': '0.5'}, | ||
'doorOperation': {'mode': 'serial'}, | ||
'passengerCarEquivalents': {'pce': '7.1'} | ||
}, | ||
'Cablecar': { | ||
'capacity': { | ||
'seats': {'persons': '250'}, | ||
'standingRoom': {'persons': '0'} | ||
}, | ||
'length': {'meter': '50.0'}, | ||
'width': {'meter': '6.0'}, | ||
'accessTime': {'secondsPerPerson': '0.5'}, | ||
'egressTime': {'secondsPerPerson': '0.5'}, | ||
'doorOperation': {'mode': 'serial'}, | ||
'passengerCarEquivalents': {'pce': '7.1'} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much easier to read
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And also much easier to edit! 👍