@@ -67,32 +67,40 @@ def get_stations(station):
6767 stations .append (result )
6868 return stations
6969
70- def get_route (from_station_id , to_station_id , time = None , arrival_time = False , max_time_to_start = None , max_time_to_dest = None ):
70+ def get_route (start , dest , time = None , arrival_time = False , max_walk_time_to_start = None , max_walk_time_to_dest = None ):
7171 """
7272 returns connectionList = [] of possible routes.
7373 Adds departure_datetime and arrival_datetime to array as datetime objects.
7474 """
7575 url = routing_url
7676 options = []
77- if from_station_id :
78- options .append ("fromStation=" + str (from_station_id ))
77+
78+ if isinstance (start , int ):
79+ options .append ("fromStation=" + str (start ))
80+ elif isinstance (start , tuple ) and len (start ) == 2 :
81+ options .append ("fromLatitude=" + str (start [0 ]))
82+ options .append ("fromLongitude=" + str (start [1 ]))
7983 else :
80- raise ValueError ("A starting station must be given" )
81- if to_station_id :
82- options .append ("toStation=" + str (to_station_id ))
84+ raise ValueError ("A start must be given; either int station id or tuple latitude longitude" )
85+
86+ if isinstance (dest , int ):
87+ options .append ("toStation=" + str (dest ))
88+ elif isinstance (dest , tuple ) and len (dest ) == 2 :
89+ options .append ("toLatitude=" + str (dest [0 ]))
90+ options .append ("toLongitude=" + str (dest [1 ]))
8391 else :
84- raise ValueError ("An ending station must be given" )
92+ raise ValueError ("A destination must be given; either int station id or tuple latitude longitude " )
8593
8694 if time :
8795 if isinstance (time , datetime .datetime ):
8896 time = _convert_time (time )
8997 options .append ("time=" + str (time ))
9098 if arrival_time :
9199 options .append ("arrival=true" )
92- if max_time_to_start :
93- options .append ("maxTravelTimeFootwayToStation=" + str (max_time_to_start ))
94- if max_time_to_dest :
95- options .append ("maxTravelTimeFootwayToDestination=" + str (max_time_to_dest ))
100+ if max_walk_time_to_start :
101+ options .append ("maxTravelTimeFootwayToStation=" + str (max_walk_time_to_start ))
102+ if max_walk_time_to_dest :
103+ options .append ("maxTravelTimeFootwayToDestination=" + str (max_walk_time_to_dest ))
96104
97105 options_url = "&" .join (options )
98106 url = routing_url + options_url
0 commit comments