--- a/schedule_viewer.py +++ b/schedule_viewer.py @@ -281,6 +281,23 @@ result.append( (r.route_id, r.route_short_name, r.route_long_name, servicep.service_id) ) result.sort(key = lambda x: x[1:3]) return result + + def handle_json_GET_routesearch(self, params): + """Return a list of routes with matching short name.""" + schedule = self.server.schedule + routeshortname = params.get('routeshortname', None) + result = [] + for r in schedule.GetRouteList(): + if r.route_short_name == routeshortname: + servicep = None + for t in schedule.GetTripList(): + if t.route_id == r.route_id: + servicep = t.service_period + break + result.append( (r.route_id, r.route_short_name, r.route_long_name, servicep.service_id) ) + result.sort(key = lambda x: x[1:3]) + return result + def handle_json_GET_routerow(self, params): schedule = self.server.schedule @@ -477,8 +494,8 @@ result = {} for trip in trips: route = schedule.GetRoute(trip.route_id) - if not trip.route_short_name+route.route_long_name in result: - result[trip.route_short_name+route.route_long_name] = (route.route_id, route.route_short_name, route.route_long_name, trip.trip_id) + if not route.route_short_name+route.route_long_name+trip.service_id in result: + result[route.route_short_name+route.route_long_name+trip.service_id] = (route.route_id, route.route_short_name, route.route_long_name, trip.trip_id, trip.service_id) return result def handle_json_GET_stopalltrips(self, params): @@ -509,6 +526,8 @@ if service_period == None or trip.service_id == service_period: result.append((time, (trip.trip_id, trip_name, trip.service_id), tp)) return result + + def handle_json_GET_stoptrips(self, params): """Given a stop_id and time in seconds since midnight return the next