Skip to content
This repository was archived by the owner on Jun 29, 2023. It is now read-only.

Commit 307c891

Browse files
authored
add means of transportation options to get_route()
adds option to disable UBahn, SBahn, Tram and Bus options in the route planning
1 parent e943888 commit 307c891

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

mvg_api/__init__.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,11 @@ def get_stations(station):
212212
def get_route(start, dest,
213213
time=None, arrival_time=False,
214214
max_walk_time_to_start=None, max_walk_time_to_dest=None,
215-
change_limit=None):
215+
change_limit=None,
216+
ubahn=True,
217+
bus=True,
218+
tram=True,
219+
sbahn=True):
216220
"""Plans a route from start to dest
217221
218222
Change in 1.3.2: accepts both 'old-style' integer IDs which were used
@@ -233,6 +237,14 @@ def get_route(start, dest,
233237
Maximum time of walking in minutes required to reach the start/dest.
234238
changeLimit : int, optional
235239
Specifies the maximum amount of changes.
240+
ubahn: bool, optional
241+
Specifies if the subway(UBahn) should be considered in the route
242+
bus: bool, optional
243+
Specifies if the bus should be considered in the route
244+
tram: bool, optional
245+
Specifies if the tram should be considered in the route
246+
sbahn: bool, optional
247+
Specifies if the SBahn should be considered in the route
236248
"""
237249
url = routing_url
238250
options = []
@@ -279,6 +291,15 @@ def get_route(start, dest,
279291
if isinstance(change_limit, int):
280292
options.append("changeLimit=" + str(change_limit))
281293

294+
if not ubahn:
295+
options.append("transportTypeUnderground=false")
296+
if not bus:
297+
options.append("transportTypeBus=false")
298+
if not tram:
299+
options.append("transportTypeTram=false")
300+
if not sbahn:
301+
options.append("transportTypeSBahn=false")
302+
282303
options_url = "&".join(options)
283304
url = routing_url + options_url
284305
results = _perform_api_request(url)

0 commit comments

Comments
 (0)