def populate_trip_information(trip_id): """ Given a GTFS trip ID, populates information about that trip into the database. """ trip_info, stops, shape = db.getGTFSTripData(trip_id) arrive_times = map(lambda s: s['arrival_time_seconds'], stops) depart_times = map(lambda s: s['departure_time_seconds'], stops) if len(arrive_times) == 0: print "NO SCHEDULE DATA", trip_id return first_arrive = min(arrive_times) first_depart = min(depart_times) last_arrive = max(arrive_times) if first_depart is not None: trip_duration = last_arrive - first_depart else: trip_duration = last_arrive - first_arrive total_stops = len(stops) trip_length = populate_trip_stop_information(trip_id, stops) db.export_trip_information(trip_id, first_arrive, first_depart, trip_length, trip_duration, total_stops)
def populate_trip_information(trip_id): """ Given a GTFS trip ID, populates information about that trip into the database. """ trip_info,stops,shape = db.getGTFSTripData(trip_id); arrive_times = map(lambda s:s['arrival_time_seconds'],stops); depart_times = map(lambda s:s['departure_time_seconds'],stops); if len(arrive_times) == 0: print "NO SCHEDULE DATA",trip_id return first_arrive = min(arrive_times); first_depart = min(depart_times); last_arrive = max(arrive_times); if first_depart is not None: trip_duration = last_arrive - first_depart else: trip_duration = last_arrive - first_arrive total_stops = len(stops) trip_length = populate_trip_stop_information(trip_id,stops); db.export_trip_information(trip_id,first_arrive,first_depart, trip_length,trip_duration,total_stops);
def __load(self): (trip_data,self.stops,self.shape) = db.getGTFSTripData(self.trip_id); self.set_attributes(trip_data); route_data = db.getGTFSRouteData(self.route_id); self.set_attributes(route_data);