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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
Marey graphs are a visualization form typically used for timetables. Time
is on the x-axis and position on the y-axis. This module reads data from a
transitfeed.Schedule and creates a marey graph in svg/xml format. The graph
shows the speed between stops for each trip of a route.
TODO: This module was taken from an internal Google tool. It works but is not
well intergrated into transitfeed and schedule_viewer. Also, it has lots of
ugly hacks to compensate set canvas size and so on which could be cleaned up.
For a little more information see (I didn't make this URL ;-)
http://transliteracies.english.ucsb.edu/post/research-project/research-clearinghouse-individual/research-reports/the-indexical-imagination-marey%e2%80%99s-graphic-method-and-the-technological-transformation-of-writing-in-the-nineteenth-century
MareyGraph: Class, keeps cache of graph data and graph properties
and draws marey graphs in svg/xml format on request.
g } n | p
If called without arguments, the data generated in the previous call
will be used. New decorators can be added between calls.
Args:
# Class Stop is defined in transitfeed.py
stoplist: [Stop, Stop, ...]
# Class Trip is defined in transitfeed.py
triplist: [Trip, Trip, ...]
Returns:
# A string that contain a svg/xml web-page with a marey graph.
" <svg width="1440" height="520" version="1.1" ... "
s %s %s %s %s( R R t _gheightR t _slistR t _BuildStationsR t _DrawBoxt
_DrawHourst
_DrawStationst
_DrawTripst _DrawHeadert _DrawDecoratorst _DrawFooter( R t stoplistt triplistt heightt output( ( sO /var/www/busstop/origin-src/transitfeed-1.2.5/gtfsscheduleviewer/marey_graph.pyt DrawH s(
c C sK d | i | i d | i d | i | i d | i | i | i f } | S( NsY
<svg width="%s" height="%s" version="1.1"
xmlns="http://www.w3.org/2000/svg">
<script type="text/ecmascript"><![CDATA[
function init(evt) {
if ( window.svgDocument == null )
svgDocument = evt.target.ownerDocument;
}
var oldLine = 0;
var oldStroke = 0;
var hoffset= %s; // Data from python
function parseLinePoints(pointnode){
var wordlist = pointnode.split(" ");
var xlist = new Array();
var h;
var m;
// TODO: add linebreaks as appropriate
var xstr = " Stop Times :";
for (i=0;i<wordlist.length;i=i+2){
var coord = wordlist[i].split(",");
h = Math.floor(parseInt((coord[0])-20)/60);
m = parseInt((coord[0]-20))%%60;
xstr = xstr +" "+ (hoffset+h) +":"+m;
}
return xstr;
}
function LineClick(tripid, x) {
var line = document.getElementById(tripid);
if (oldLine)
oldLine.setAttribute("stroke",oldStroke);
oldLine = line;
oldStroke = line.getAttribute("stroke");
line.setAttribute("stroke","#fff");
var dynTxt = document.getElementById("dynamicText");
var tripIdTxt = document.createTextNode(x);
while (dynTxt.hasChildNodes()){
dynTxt.removeChild(dynTxt.firstChild);
}
dynTxt.appendChild(tripIdTxt);
}
]]> </script>
<style type="text/css"><![CDATA[
.T { fill:none; stroke-width:1.5 }
.TB { fill:none; stroke:#e20; stroke-width:2 }
.Station { fill:none; stroke-width:1 }
.Dec { fill:none; stroke-width:1.5 }
.FullHour { fill:none; stroke:#eee; stroke-width:1 }
.SubHour { fill:none; stroke:#ddd; stroke-width:1 }
.Label { fill:#aaa; font-family:Helvetica,Arial,sans;
text-anchor:middle }
.Info { fill:#111; font-family:Helvetica,Arial,sans;
text-anchor:start; }
]]></style>
<text class="Info" id="dynamicText" x="0" y="%d"></text>
<g id="mcanvas" transform="translate(%s,%s)">
<g id="zcanvas" transform="scale(%s)">
i i i
( R R
R R R R ( R t
fill="lightgrey" stroke="%s" stroke-width="2" />
Args:
# Class Stop is defined in transitfeed.py
stoplist: [Stop, Stop, ...]
# Class Trip is defined in transitfeed.py
triplist: [Trip, Trip, ...]
Returns:
# One integer y-coordinate for each station normalized between
# 0 and X, where X is the height of the graph in pixels
[0, 33, 140, ... , X]
Uses the stoplists long/lats to approximate distances
between stations and build a list with y-coordinates for the
horizontal lines in the graph.
Args:
# Class Stop is defined in transitfeed.py
stoplist: [Stop, Stop, ...]
Returns:
# One integer for each pair of stations
# indicating the approximate distance
[0,33,140, ... ,X]
Args:
# One integer for each pair of stations
# indicating the approximate distance
dists: [0,33,140, ... ,X]
Returns:
# One integer y-coordinate for each station normalized between
# 0 and X, where X is the height of the graph in pixels
[0, 33, 140, ... , X]
i i ( t sumt floatR t enumeratet int(
R R) t tot_distR/ t dt
pixel_distt _[2]t it pdt
Uses a timetable to approximate distances
between stations
Args:
# Class Trip is defined in transitfeed.py
triplist: [Trip, Trip, ...]
# (Optional) Index of Triplist prefered for timetable Calculation
index: 3
Returns:
# One integer for each pair of stations
# indicating the approximate distance
[0,33,140, ... ,X]
i i i i ( t lenR* R+ t GetTimeStops( R R t indexRB t tripR/ R0 R1 t t_dists2( ( R sO /var/www/busstop/origin-src/transitfeed-1.2.5/gtfsscheduleviewer/marey_graph.pyt _TravelTimes s $
Mc C s | GHd S( N( ( R R ( ( sO /var/www/busstop/origin-src/transitfeed-1.2.5/gtfsscheduleviewer/marey_graph.pyt _AddWarning& s t c
d
Args:
# Class Trip is defined in transitfeed.py
[Trip, Trip, ...]
Returns:
# A string containing a polyline tag for each trip
' <polyline class="T" stroke="#336633" points="433,0 ...'
service_idt appendR6 RE RC t hexRD R5 t trip_idR, t FormatSecondsSinceMidnightt GetStartTimeR t NoneR
R R$ ( R R t colparR( t tmpstrst servlistt tt shadet colort
start_offsetst
first_stopt jt freq_offsett
scriptcallt
tmpstrheadR; t st arr_tt dep_tt arr_xt dep_x( ( sO /var/www/busstop/origin-src/transitfeed-1.2.5/gtfsscheduleviewer/marey_graph.pyR ) sV
*
Args:
# Class Stop is defined in transitfeed.py
stations: [Stop, Stop, ...]
Returns:
# A string containing a polyline tag for each stop
" <polyline class="Station" stroke="#336633" points="20,0 ..."
Returns:
# A string containing a polyline tag for each grid line
" <polyline class="FullHour" points="20,0 ..."
RN R R R$ ( R RU R; ( ( sO /var/www/busstop/origin-src/transitfeed-1.2.5/gtfsscheduleviewer/marey_graph.pyR { s '
Args:
# Integer, index of stop to be highlighted.
index: 4
# An optional string with a html color code
color: "#fff"
Args:
# Class Trip is defined in transitfeed.py
triplist: [Trip, Trip, ...]
# An optional string with a html color code
color: "#fff"
1.0 is the original canvas size.
Args:
# float value between 0.0 and 5.0
newfactor: 0.7
N( t __name__t
__module__t __doc__Rm R> |