-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotes.txt
137 lines (118 loc) · 3.45 KB
/
notes.txt
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
THESE ARE OLD, DO NOT REFERENCE
file structure for bus data:
routesShort.json
- route_id: route name
routes.json
- route_id: object
- - route_short_name: route name
- - route_long_name: route name
- - route_color: route color
- - route_text_color: route text color
- - segments: list of segment ids and forward/backward
(explore what this means)
- - stops: list of stop ids
stops.json
- stop_id: object
- - stop_name: stop name
- - stop_location: 2 element list of lat/long
- - stop_routes: list of route ids
- - stop_code: 4 digit code which doesn't seem to be used
segments.json
- segment_id: list of 2 element lists of lat/long (list of points in the segment)
busData.json
- last_updated: timestamp
- bus_data: list of objects
# things that never change:
- - vehicle_id
- - bus_number
# things that rarely change?
- - route_id
- - status: up/down (could be deduced from update timestamps but use less frequent update thing here)
( keep as a list with timestamp so we can see when it changes )
# things that change often:
- - location: 2 element list of lat/long
- - heading: degrees
- - speed: km/h
( keep as a list with timestamp so we can see when it changes )
key:
t: timestamp
r_id: route_id
stat: status
l: location
h: heading
s: speed
forgot about this!
c: capacity
p: segment
busData should look like this:
{
'metadata': {
'last_updated': 1234567890
},
'data': {
'busList': {
'12312332': {
'perm': {
'bus_number': 1234
}
'semiperm': [
{
't': 1234567890,
'r_id': 1234,
'stat': 'up',
}
]
'temp': {
'1234567890': {
'l': [123.123, 123.123],
'h': 123,
's': 123
},
'1234567891': {
'l': [123.123, 123.123],
'h': 123,
's': 123
},
'1234567892': {
'l': [123.123, 123.123],
'h': 123,
's': 123
}
}
}
}
},
'timestamps': {
'1234567890': 'good',
'1234567891': 'good',
'1234567892': 'err: no network'
'1234567893': 'err: timeout'
}
}
let's just make a new file every "day"
"day" means from 4am to 2am
store files as:
YYYY-MM-DD_busData.json
store files in local directory
so the overall process is:
- create or open the file for the current day (at 3:50am to give 10
minutes to get the data)
- read the file
- at 4:00am, request bus data from the server every 5 seconds
- - with this data:
- - - check if valid list
- - - - if not, just add to timestamp with error message
- - - - if so, add to timestamp with 'good'
- - - for each bus:
- - - - call function addBusData(vehicle_id)
- - - - - if vehicle_id is not in busList:
- - - - - - add vehicle_id to busList
- - - - - - - set perm
- - - - - - - set up semiperm with timestamp
- - - - - - - set up temp with timestamp
- - - - - if vehicle_id is in busList:
- - - - - - check if semiperm is different
- - - - - - - if it is: add to semiperm with timestamp
- - - - - - add to temp with timestamp
and every 5 minutes:
- change contents of current file to current data