-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerator.py
84 lines (61 loc) · 3.06 KB
/
generator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import pandas as pd
import numpy as np
import pytz
import MySQLdb
from google.transit import gtfs_realtime_pb2
import urllib
import datetime
import helper
import sys
import logging
import transit_agencies
import tablefunctions
def interpret(agency, static_feed, trip_update_feed, alert_feed, vehicle_position_feed):
tables = {}
trip2pattern = {}
trip2vehicle = {}
agency_id = transit_agencies.get(agency, "id") #for bart
#Agencies
tablefunctions.agencies(tables, static_feed, trip_update_feed, alert_feed, vehicle_position_feed, agency_id=agency_id)
#Stops
tablefunctions.stops(tables, static_feed, trip_update_feed, alert_feed, vehicle_position_feed, agency_id=agency_id)
#Routes
tablefunctions.routes(tables, static_feed, trip_update_feed, alert_feed, vehicle_position_feed, agency_id=agency_id)
#Route Stop Seq
tablefunctions.route_stop_seq(tables, static_feed, trip_update_feed, alert_feed, vehicle_position_feed, agency_id=agency_id, trip2pattern=trip2pattern)
#Run Pattern
tablefunctions.runPattern(tables=tables, static_feed=static_feed, agency_id=agency_id)
###Schedules: gets some data from RunPattern table
tablefunctions.schedules(tables, static_feed, trip_update_feed, alert_feed, vehicle_position_feed, agency_id=agency_id, trip2pattern=trip2pattern)
#Table Points
tablefunctions.points(tables, static_feed, trip_update_feed, alert_feed, vehicle_position_feed, agency_id=agency_id, trip2pattern=trip2pattern)
tablefunctions.big_points(tables, static_feed, trip_update_feed, alert_feed, vehicle_position_feed, agency_id=agency_id, trip2pattern=trip2pattern)
#Table Route_point_Seq
tablefunctions.route_point_seq(tables, static_feed, trip_update_feed, alert_feed, vehicle_position_feed, agency_id=agency_id, trip2pattern=trip2pattern)
### ----- Task 2 ----------
#Table Transfers
tablefunctions.transfers(tables, static_feed, trip_update_feed, alert_feed, vehicle_position_feed, agency_id=agency_id, trip2pattern=trip2pattern)
### ---- Task 3 -----------------
#Table GPS FIXES
tablefunctions.gps_fixes(tables, static_feed, trip_update_feed, alert_feed, vehicle_position_feed, agency_id=agency_id, trip2pattern=trip2pattern)
#Table Transit ETA
tablefunctions.transit_eta(tables, static_feed, trip_update_feed, alert_feed, vehicle_position_feed, agency_id=agency_id, trip2pattern=trip2pattern)
def main(argv):
agencies = []
print "Length of args: " + str(len(argv))
if len(argv) == 1:
logging.error("Not enough arguments")
return
agency = argv[1]
#get the agencies's informatio
static_feed = helper.get_static(agency)
trip_update_feed = helper.get_realtime(agency, mode="trip_update")
alert_feed = helper.get_realtime(agency, mode="alert")
vehicle_position_feed = helper.get_realtime(agency, mode="vehicle_position")
#Process The data
interpret(agency, static_feed, trip_update_feed, alert_feed, vehicle_position_feed)
if __name__ == "__main__":
main(sys.argv)