Upgrade origin-src to google transit feed 1.2.6
[bus.git] / origin-src / marey_graph.pyc
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



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.










    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(RRt_gheightRt_slistRt_BuildStationsRt_DrawBoxt
_DrawHourst
_DrawStationst
_DrawTripst_DrawHeadert_DrawDecoratorst_DrawFooter(Rtstoplistttriplisttheighttoutput((sK/var/www/bus/origin-src/transitfeed-1.2.5/gtfsscheduleviewer/marey_graph.pytDrawHs(										cCsKd|j|jd|jd|j|jd|j|j|jf}|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)">

       iii
(RR
RR	RR(Rt

                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]
    ii(tsumtfloatRt	enumeratetint(RR)ttot_disttdt
pixel_disttitpdt



    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]

iiii(tlenR*R+tGetTimeStops(RRtindexR@ttripR/R0tt_dists2((RsK/var/www/bus/origin-src/transitfeed-1.2.5/gtfsscheduleviewer/marey_graph.pyt_TravelTimess"






    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_idtappendR5RCRAthexRBR4ttrip_idR,tFormatSecondsSinceMidnighttGetStartTimeRtNoneR
R	R$(RRtcolparR(ttmpstrstservlisttttshadetcolort
start_offsetst
first_stoptjtfreq_offsett
scriptcallt
tmpstrheadR9tstarr_ttdep_ttarr_xtdep_x((sK/var/www/bus/origin-src/transitfeed-1.2.5/gtfsscheduleviewer/marey_graph.pyR)sP	
	

	
*			





    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 ..."

RLRR	R$(RRSR9((sK/var/www/bus/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__RkR<RRQR!RRRRRR&R'RFRGRRJRRRiRjRmRnRoRpRrRz(((sK/var/www/bus/origin-src/transitfeed-1.2.5/gtfsscheduleviewer/marey_graph.pyR(s4	)	E						$	:							((R}R*R,R(((sK/var/www/bus/origin-src/transitfeed-1.2.5/gtfsscheduleviewer/marey_graph.pyt<module>"s