Input and output data from Network 10
[bus.git] / origin-src / transitfeed-1.2.5 / gtfsscheduleviewer / marey_graph.pyc
1
maxious 2
3
4 Marey graphs are a visualization form typically used for timetables. Time
5 is on the x-axis and position on the y-axis. This module reads data from a
6 transitfeed.Schedule and creates a marey graph in svg/xml format. The graph
7 shows the speed between stops for each trip of a route.
8
9 TODO: This module was taken from an internal Google tool. It works but is not
10 well intergrated into transitfeed and schedule_viewer. Also, it has lots of
11 ugly hacks to compensate set canvas size and so on which could be cleaned up.
12
13 For a little more information see (I didn't make this URL ;-)
14 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
15
16 MareyGraph: Class, keeps cache of graph data and graph properties
17 and draws marey graphs in svg/xml format on request.
18
19
20
21
22
23
24
25
26 g}n|p
27
28
29
30 If called without arguments, the data generated in the previous call
31 will be used. New decorators can be added between calls.
32
33 Args:
34 # Class Stop is defined in transitfeed.py
35 stoplist: [Stop, Stop, ...]
36 # Class Trip is defined in transitfeed.py
37 triplist: [Trip, Trip, ...]
38
39 Returns:
40 # A string that contain a svg/xml web-page with a marey graph.
41 " <svg width="1440" height="520" version="1.1" ... "
42 s %s %s %s %s(RRt_gheightRt_slistRt_BuildStationsRt_DrawBoxt
43 _DrawHourst _DrawStationst
44 _DrawTripst _DrawHeadert_DrawDecoratorst _DrawFooter(Rtstoplistttriplisttheighttoutput((sK/var/www/bus/origin-src/transitfeed-1.2.5/gtfsscheduleviewer/marey_graph.pytDrawHs( 
45 
46          cCsKd|i|id|id|i|id|i|i|if}|S(NsY
47 <svg width="%s" height="%s" version="1.1"
48 xmlns="http://www.w3.org/2000/svg">
49 <script type="text/ecmascript"><![CDATA[
50 function init(evt) {
51 if ( window.svgDocument == null )
52 svgDocument = evt.target.ownerDocument;
53 }
54 var oldLine = 0;
55 var oldStroke = 0;
56 var hoffset= %s; // Data from python
57
58 function parseLinePoints(pointnode){
59 var wordlist = pointnode.split(" ");
60 var xlist = new Array();
61 var h;
62 var m;
63 // TODO: add linebreaks as appropriate
64 var xstr = " Stop Times :";
65 for (i=0;i<wordlist.length;i=i+2){
66 var coord = wordlist[i].split(",");
67 h = Math.floor(parseInt((coord[0])-20)/60);
68 m = parseInt((coord[0]-20))%%60;
69 xstr = xstr +" "+ (hoffset+h) +":"+m;
70 }
71
72 return xstr;
73 }
74
75 function LineClick(tripid, x) {
76 var line = document.getElementById(tripid);
77 if (oldLine)
78 oldLine.setAttribute("stroke",oldStroke);
79 oldLine = line;
80 oldStroke = line.getAttribute("stroke");
81
82 line.setAttribute("stroke","#fff");
83
84 var dynTxt = document.getElementById("dynamicText");
85 var tripIdTxt = document.createTextNode(x);
86 while (dynTxt.hasChildNodes()){
87 dynTxt.removeChild(dynTxt.firstChild);
88 }
89 dynTxt.appendChild(tripIdTxt);
90 }
91 ]]> </script>
92 <style type="text/css"><![CDATA[
93 .T { fill:none; stroke-width:1.5 }
94 .TB { fill:none; stroke:#e20; stroke-width:2 }
95 .Station { fill:none; stroke-width:1 }
96 .Dec { fill:none; stroke-width:1.5 }
97 .FullHour { fill:none; stroke:#eee; stroke-width:1 }
98 .SubHour { fill:none; stroke:#ddd; stroke-width:1 }
99 .Label { fill:#aaa; font-family:Helvetica,Arial,sans;
100 text-anchor:middle }
101 .Info { fill:#111; font-family:Helvetica,Arial,sans;
102 text-anchor:start; }
103 ]]></style>
104 <text class="Info" id="dynamicText" x="0" y="%d"></text>
105 <g id="mcanvas" transform="translate(%s,%s)">
106 <g id="zcanvas" transform="scale(%s)">
107
108 iii
109 (RR RR RR (Rt
110
111 fill="lightgrey" stroke="%s" stroke-width="2" />
112
113
114 Args:
115 # Class Stop is defined in transitfeed.py
116 stoplist: [Stop, Stop, ...]
117 # Class Trip is defined in transitfeed.py
118 triplist: [Trip, Trip, ...]
119
120 Returns:
121 # One integer y-coordinate for each station normalized between
122 # 0 and X, where X is the height of the graph in pixels
123 [0, 33, 140, ... , X]
124
125
126 Uses the stoplists long/lats to approximate distances
127 between stations and build a list with y-coordinates for the
128 horizontal lines in the graph.
129
130 Args:
131 # Class Stop is defined in transitfeed.py
132 stoplist: [Stop, Stop, ...]
133
134 Returns:
135 # One integer for each pair of stations
136 # indicating the approximate distance
137 [0,33,140, ... ,X]
138
139
140
141 Args:
142 # One integer for each pair of stations
143 # indicating the approximate distance
144 dists: [0,33,140, ... ,X]
145
146 Returns:
147 # One integer y-coordinate for each station normalized between
148 # 0 and X, where X is the height of the graph in pixels
149 [0, 33, 140, ... , X]
150 ii(tsumtfloatRt enumeratetint(
151 RR)ttot_distR/tdt
152 pixel_distt_[2]titpdt
153
154
155 Uses a timetable to approximate distances
156 between stations
157
158 Args:
159 # Class Trip is defined in transitfeed.py
160 triplist: [Trip, Trip, ...]
161 # (Optional) Index of Triplist prefered for timetable Calculation
162 index: 3
163
164 Returns:
165 # One integer for each pair of stations
166 # indicating the approximate distance
167 [0,33,140, ... ,X]
168
169   iiii(tlenR*R+t GetTimeStops( RRtindexRBttripR/R0R1tt_dists2((RsK/var/www/bus/origin-src/transitfeed-1.2.5/gtfsscheduleviewer/marey_graph.pyt _TravelTimess$
170 McCs |GHdS(N((RR((sK/var/www/bus/origin-src/transitfeed-1.2.5/gtfsscheduleviewer/marey_graph.pyt _AddWarning&stc
171
172
173
174 d
175
176
177 Args:
178 # Class Trip is defined in transitfeed.py
179 [Trip, Trip, ...]
180
181 Returns:
182 # A string containing a polyline tag for each trip
183 ' <polyline class="T" stroke="#336633" points="433,0 ...'
184
185 service_idtappendR6RERCthexRDR5ttrip_idR,tFormatSecondsSinceMidnightt GetStartTimeRtNoneR
186 R R$(RRtcolparR(ttmpstrstservlisttttshadetcolort start_offsetst
187 first_stoptjt freq_offsett
188 scriptcallt
189 tmpstrheadR;tstarr_ttdep_ttarr_xtdep_x((sK/var/www/bus/origin-src/transitfeed-1.2.5/gtfsscheduleviewer/marey_graph.pyR)sV 
190  
191    *  
192    
193 
194
195
196 Args:
197 # Class Stop is defined in transitfeed.py
198 stations: [Stop, Stop, ...]
199
200 Returns:
201 # A string containing a polyline tag for each stop
202 " <polyline class="Station" stroke="#336633" points="20,0 ..."
203
204
205 Returns:
206 # A string containing a polyline tag for each grid line
207 " <polyline class="FullHour" points="20,0 ..."
208
209 RNRR R$(RRUR;((sK/var/www/bus/origin-src/transitfeed-1.2.5/gtfsscheduleviewer/marey_graph.pyR{s ' 
210
211
212
213 Args:
214 # Integer, index of stop to be highlighted.
215 index: 4
216 # An optional string with a html color code
217 color: "#fff"
218
219
220
221 Args:
222 # Class Trip is defined in transitfeed.py
223 triplist: [Trip, Trip, ...]