--- a/busui/schedule_viewer.py +++ b/busui/schedule_viewer.py @@ -264,7 +264,19 @@ schedule = self.server.schedule route = schedule.GetRoute(params.get('route', None)) return [transitfeed.Route._FIELD_NAMES, route.GetFieldValuesTuple()] - + + def handle_json_GET_routetrips(self, params): + """ Get a trip for a route_id (preferablly the next one) """ + schedule = self.server.schedule + query = params.get('route_id', None).lower() + result = [] + for t in schedule.GetTripList(): + if t.route_id == query: + result.append ( (t.GetStartTime(), t.trip_id) ) + """ UGH fails for 300s """ + """return result""" + return sorted(result, key=lambda trip: trip[0]) + def handle_json_GET_triprows(self, params): """Return a list of rows from the feed file that are related to this trip.""" @@ -337,6 +349,14 @@ def handle_json_GET_stops(self, params): schedule = self.server.schedule return [StopToTuple(s) for s in schedule.GetStopList()] + + def handle_json_GET_timingpoints(self, params): + schedule = self.server.schedule + matches = [] + for s in schedule.GetStopList(): + if s.stop_code.find("Wj") == -1: + matches.append(StopToTuple(s)) + return matches def handle_json_GET_stopsearch(self, params): schedule = self.server.schedule @@ -361,6 +381,7 @@ schedule = self.server.schedule stop = schedule.GetStop(params.get('stop', None)) time = int(params.get('time', 0)) + service_period = params.get('service_period', None) time_trips = stop.GetStopTimeTrips(schedule) time_trips.sort() # OPT: use bisect.insort to make this O(N*ln(N)) -> O(N) # Keep the first 15 after param 'time'. @@ -389,8 +410,8 @@ trip_name += route.route_long_name if headsign: trip_name += " (Direction: %s)" % headsign - - result.append((time, (trip.trip_id, trip_name, trip.service_id), tp)) + 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_GET_ttablegraph(self,params):