--- a/schedule_viewer.py +++ b/schedule_viewer.py @@ -316,8 +316,19 @@ except: print "Error for GetStartTime of trip #" + t.trip_id + sys.exc_info()[0] else: - result.append ( (starttime, t.trip_id) ) - return sorted(result, key=lambda trip: trip[0]) + cursor = t._schedule._connection.cursor() + cursor.execute( + 'SELECT arrival_secs,departure_secs FROM stop_times WHERE ' + 'trip_id=? ORDER BY stop_sequence DESC LIMIT 1', (t.trip_id,)) + (arrival_secs, departure_secs) = cursor.fetchone() + if arrival_secs != None: + endtime = arrival_secs + elif departure_secs != None: + endtime = departure_secs + else: + endtime =0 + result.append ( (starttime, t.trip_id, endtime) ) + return sorted(result, key=lambda trip: trip[2]) def handle_json_GET_triprows(self, params): """Return a list of rows from the feed file that are related to this @@ -494,8 +505,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): @@ -526,6 +537,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