From: maxious Date: Sun, 28 Nov 2010 11:34:48 +0000 Subject: Upgrade origin-src to google transit feed 1.2.6 X-Git-Url: https://maxious.lambdacomplex.org/git/?p=bus.git&a=commitdiff&h=37252563b03abca4a228babcdb3291e400553929 --- Upgrade origin-src to google transit feed 1.2.6 --- --- a/origin-src/transitfeed-1.2.5/COPYING +++ /dev/null @@ -1,203 +1,1 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - --- a/origin-src/transitfeed-1.2.5/INSTALL +++ /dev/null @@ -1,22 +1,1 @@ -INSTALL file for transitfeed distribution - - -To download and install in one step make sure you have easy-install installed and run -easy_install transitfeed - - - -Since you got this far chances are you have downloaded a copy of the source -code. Install with the command - -python setup.py install - - - -If you don't want to install you may be able to run the scripts from this -directory. For example, try running - -./feedvalidator.py -n test/data/good_feed.zip - - --- a/origin-src/transitfeed-1.2.5/PKG-INFO +++ /dev/null @@ -1,21 +1,1 @@ -Metadata-Version: 1.0 -Name: transitfeed -Version: 1.2.5 -Summary: Google Transit Feed Specification library and tools -Home-page: http://code.google.com/p/googletransitdatafeed/ -Author: Tom Brown -Author-email: tom.brown.code@gmail.com -License: Apache License, Version 2.0 -Download-URL: http://googletransitdatafeed.googlecode.com/files/transitfeed-1.2.5.tar.gz -Description: This module provides a library for reading, writing and validating Google Transit Feed Specification files. It includes some scripts that validate a feed, display it using the Google Maps API and the start of a KML importer and exporter. -Platform: OS Independent -Classifier: Development Status :: 4 - Beta -Classifier: Intended Audience :: Developers -Classifier: Intended Audience :: Information Technology -Classifier: Intended Audience :: Other Audience -Classifier: License :: OSI Approved :: Apache Software License -Classifier: Operating System :: OS Independent -Classifier: Programming Language :: Python -Classifier: Topic :: Scientific/Engineering :: GIS -Classifier: Topic :: Software Development :: Libraries :: Python Modules --- a/origin-src/transitfeed-1.2.5/README +++ /dev/null @@ -1,19 +1,1 @@ -README file for transitfeed distribution - - -This distribution contains a library to help you parse and generate Google -Transit Feed files. It also contains some sample tools that demonstrate the -library and are useful in their own right when maintaining Google -Transit Feed files. You may fetch the specification from -http://code.google.com/transit/spec/transit_feed_specification.htm - - -See INSTALL for installation instructions - -The most recent source can be downloaded from our subversion repository at -http://googletransitdatafeed.googlecode.com/svn/trunk/python/ - -See http://code.google.com/p/googletransitdatafeed/wiki/TransitFeedDistribution -for more information. - --- a/origin-src/transitfeed-1.2.5/build/lib/gtfsscheduleviewer/__init__.py +++ /dev/null @@ -1,9 +1,1 @@ -__doc__ = """ -Package holding files for Google Transit Feed Specification Schedule Viewer. -""" -# This package contains the data files for schedule_viewer.py, a script that -# comes with the transitfeed distribution. According to the thread -# "[Distutils] distutils data_files and setuptools.pkg_resources are driving -# me crazy" this is the easiest way to include data files. My experience -# agrees. - Tom 2007-05-29 --- a/origin-src/transitfeed-1.2.5/build/lib/gtfsscheduleviewer/files/index.html +++ /dev/null @@ -1,706 +1,1 @@ - - - - - [agency] - - - - - - - - - -
-
- ... -
-
-
[agency]
-
-
- - -
-
- -
bottom bar
- - - - --- a/origin-src/transitfeed-1.2.5/build/lib/gtfsscheduleviewer/files/labeled_marker.js +++ /dev/null @@ -1,186 +1,1 @@ -/* -* LabeledMarker Class -* -* Copyright 2007 Mike Purvis (http://uwmike.com) -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* This class extends the Maps API's standard GMarker class with the ability -* to support markers with textual labels. Please see articles here: -* -* http://googlemapsbook.com/2007/01/22/extending-gmarker/ -* http://googlemapsbook.com/2007/03/06/clickable-labeledmarker/ -*/ -/** - * Constructor for LabeledMarker, which picks up on strings from the GMarker - * options array, and then calls the GMarker constructor. - * - * @param {GLatLng} latlng - * @param {GMarkerOptions} Named optional arguments: - * opt_opts.labelText {String} text to place in the overlay div. - * opt_opts.labelClass {String} class to use for the overlay div. - * (default "markerLabel") - * opt_opts.labelOffset {GSize} label offset, the x- and y-distance between - * the marker's latlng and the upper-left corner of the text div. - */ -function LabeledMarker(latlng, opt_opts){ - this.latlng_ = latlng; - this.opts_ = opt_opts; - - this.initText_ = opt_opts.labelText || ""; - this.labelClass_ = opt_opts.labelClass || "markerLabel"; - this.labelOffset_ = opt_opts.labelOffset || new GSize(0, 0); - - this.clickable_ = opt_opts.clickable || true; - - if (opt_opts.draggable) { - // This version of LabeledMarker doesn't support dragging. - opt_opts.draggable = false; - } - - GMarker.apply(this, arguments); -} - - -// It's a limitation of JavaScript inheritance that we can't conveniently -// inherit from GMarker without having to run its constructor. In order for -// the constructor to run, it requires some dummy GLatLng. -LabeledMarker.prototype = new GMarker(new GLatLng(0, 0)); - -/** - * Is called by GMap2's addOverlay method. Creates the text div and adds it - * to the relevant parent div. - * - * @param {GMap2} map the map that has had this labeledmarker added to it. - */ -LabeledMarker.prototype.initialize = function(map) { - // Do the GMarker constructor first. - GMarker.prototype.initialize.apply(this, arguments); - - this.map_ = map; - this.setText(this.initText_); -} - -/** - * Create a new div for this label. - */ -LabeledMarker.prototype.makeDiv_ = function(map) { - if (this.div_) { - return; - } - this.div_ = document.createElement("div"); - this.div_.className = this.labelClass_; - this.div_.style.position = "absolute"; - this.div_.style.cursor = "pointer"; - this.map_.getPane(G_MAP_MARKER_PANE).appendChild(this.div_); - - if (this.clickable_) { - /** - * Creates a closure for passing events through to the source marker - * This is located in here to avoid cluttering the global namespace. - * The downside is that the local variables from initialize() continue - * to occupy space on the stack. - * - * @param {Object} object to receive event trigger. - * @param {GEventListener} event to be triggered. - */ - function newEventPassthru(obj, event) { - return function() { - GEvent.trigger(obj, event); - }; - } - - // Pass through events fired on the text div to the marker. - var eventPassthrus = ['click', 'dblclick', 'mousedown', 'mouseup', 'mouseover', 'mouseout']; - for(var i = 0; i < eventPassthrus.length; i++) { - var name = eventPassthrus[i]; - GEvent.addDomListener(this.div_, name, newEventPassthru(this, name)); - } - } -} - -/** - * Return the html in the div of this label, or "" if none is set - */ -LabeledMarker.prototype.getText = function(text) { - if (this.div_) { - return this.div_.innerHTML; - } else { - return ""; - } -} - -/** - * Set the html in the div of this label to text. If text is "" or null remove - * the div. - */ -LabeledMarker.prototype.setText = function(text) { - if (this.div_) { - if (text) { - this.div_.innerHTML = text; - } else { - // remove div - GEvent.clearInstanceListeners(this.div_); - this.div_.parentNode.removeChild(this.div_); - this.div_ = null; - } - } else { - if (text) { - this.makeDiv_(); - this.div_.innerHTML = text; - this.redraw(); - } - } -} - -/** - * Move the text div based on current projection and zoom level, call the redraw() - * handler in GMarker. - * - * @param {Boolean} force will be true when pixel coordinates need to be recomputed. - */ -LabeledMarker.prototype.redraw = function(force) { - GMarker.prototype.redraw.apply(this, arguments); - - if (this.div_) { - // Calculate the DIV coordinates of two opposite corners of our bounds to - // get the size and position of our rectangle - var p = this.map_.fromLatLngToDivPixel(this.latlng_); - var z = GOverlay.getZIndex(this.latlng_.lat()); - - // Now position our div based on the div coordinates of our bounds - this.div_.style.left = (p.x + this.labelOffset_.width) + "px"; - this.div_.style.top = (p.y + this.labelOffset_.height) + "px"; - this.div_.style.zIndex = z; // in front of the marker - } -} - -/** - * Remove the text div from the map pane, destroy event passthrus, and calls the - * default remove() handler in GMarker. - */ - LabeledMarker.prototype.remove = function() { - this.setText(null); - GMarker.prototype.remove.apply(this, arguments); -} - -/** - * Return a copy of this overlay, for the parent Map to duplicate itself in full. This - * is part of the Overlay interface and is used, for example, to copy everything in the - * main view into the mini-map. - */ -LabeledMarker.prototype.copy = function() { - return new LabeledMarker(this.latlng_, this.opt_opts_); -} - --- a/origin-src/transitfeed-1.2.5/build/lib/gtfsscheduleviewer/files/style.css +++ /dev/null @@ -1,162 +1,1 @@ -html { overflow: hidden; } -html, body { - margin: 0; - padding: 0; - height: 100%; -} - -body { margin: 5px; } - -#content { - position: relative; - margin-top: 5px; -} - -#map-wrapper { - position: relative; - height: 100%; - width: auto; - left: 0; - top: 0; - z-index: 100; -} - -#map { - position: relative; - height: 100%; - width: auto; - border: 1px solid #aaa; -} - -#sidebar-wrapper { - position: absolute; - height: 100%; - width: 220px; - top: 0; - border: 1px solid #aaa; - overflow: auto; - z-index: 300; -} - -#sidebar { - position: relative; - width: auto; - padding: 4px; - overflow: hidden; -} - -#topbar { - position: relative; - padding: 2px; - border: 1px solid #aaa; - margin: 0; -} - -#topbar h1 { - white-space: nowrap; - overflow: hidden; - font-size: 14pt; - font-weight: bold; - font-face: - margin: 0; -} - - -body.sidebar-right #map-wrapper { margin-right: 229px; } -body.sidebar-right #sidebar-wrapper { right: 0; } - -body.sidebar-left #map { margin-left: 229px; } -body.sidebar-left #sidebar { left: 0; } - -body.nosidebar #map { margin: 0; } -body.nosidebar #sidebar { display: none; } - -#bottombar { - position: relative; - padding: 2px; - border: 1px solid #aaa; - margin-top: 5px; - display: none; -} - -/* holly hack for IE to get position:bottom right - see: http://www.positioniseverything.net/abs_relbugs.html - \*/ -* html #topbar { height: 1px; } -/* */ - -body { - font-family:helvetica,arial,sans, sans-serif; -} -h1 { - margin-top: 0.5em; - margin-bottom: 0.5em; -} -h2 { - margin-top: 0.2em; - margin-bottom: 0.2em; -} -h3 { - margin-top: 0.2em; - margin-bottom: 0.2em; -} -.tooltip { - white-space: nowrap; - padding: 2px; - color: black; - font-size: 12px; - background-color: white; - border: 1px solid black; - cursor: pointer; - filter:alpha(opacity=60); - -moz-opacity: 0.6; - opacity: 0.6; -} -#routeList { - border: 1px solid black; - overflow: auto; -} -.shortName { - font-size: bigger; - font-weight: bold; -} -.routeChoice,.tripChoice,.routeChoiceSelected,.tripChoiceSelected { - white-space: nowrap; - cursor: pointer; - padding: 0px 2px; - color: black; - line-height: 1.4em; - font-size: smaller; - overflow: hidden; -} -.tripChoice { - color: blue; -} -.routeChoiceSelected,.tripChoiceSelected { - background-color: blue; - color: white; -} -.tripSection { - padding-left: 0px; - font-size: 10pt; - background-color: lightblue; -} -.patternSection { - margin-left: 8px; - padding-left: 2px; - border-bottom: 1px solid grey; -} -.unusualPattern { - background-color: #aaa; - color: #444; -} -/* Following styles are used by location_editor.py */ -#edit { - visibility: hidden; - float: right; - font-size: 80%; -} -#edit form { - display: inline; -} --- a/origin-src/transitfeed-1.2.5/build/lib/gtfsscheduleviewer/files/svgcheck.vbs +++ /dev/null @@ -1,8 +1,1 @@ -' Copyright 1999-2000 Adobe Systems Inc. All rights reserved. Permission to redistribute -' granted provided that this file is not modified in any way. This file is provided with -' absolutely no warranties of any kind. -Function isSVGControlInstalled() - on error resume next - isSVGControlInstalled = IsObject(CreateObject("Adobe.SVGCtl")) -end Function --- a/origin-src/transitfeed-1.2.5/build/lib/gtfsscheduleviewer/marey_graph.py +++ /dev/null @@ -1,470 +1,1 @@ -#!/usr/bin/python2.5 -# -# Copyright (C) 2007 Google Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Output svg/xml data for a marey graph - -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. - -""" - -import itertools -import transitfeed - - -class MareyGraph: - """Produces and caches marey graph from transit feed data.""" - - _MAX_ZOOM = 5.0 # change docstring of ChangeScaleFactor if this changes - _DUMMY_SEPARATOR = 10 #pixel - - def __init__(self): - # Timetablerelated state - self._cache = str() - self._stoplist = [] - self._tlist = [] - self._stations = [] - self._decorators = [] - - # TODO: Initialize default values via constructor parameters - # or via a class constants - - # Graph properties - self._tspan = 30 # number of hours to display - self._offset = 0 # starting hour - self._hour_grid = 60 # number of pixels for an hour - self._min_grid = 5 # number of pixels between subhour lines - - # Canvas properties - self._zoomfactor = 0.9 # svg Scaling factor - self._xoffset = 0 # move graph horizontally - self._yoffset = 0 # move graph veritcally - self._bgcolor = "lightgrey" - - # height/width of graph canvas before transform - self._gwidth = self._tspan * self._hour_grid - - def Draw(self, stoplist=None, triplist=None, height=520): - """Main interface for drawing the marey graph. - - 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. - " - - - - - - - """ % (self._gwidth + self._xoffset + 20, self._gheight + 15, - self._offset, self._gheight + 10, - self._xoffset, self._yoffset, self._zoomfactor) - - return svg_header - - def _DrawFooter(self): - return "" - - def _DrawDecorators(self): - """Used to draw fancy overlays on trip graphs.""" - return " ".join(self._decorators) - - def _DrawBox(self): - tmpstr = """ - """ % (0, 0, self._gwidth + 20, self._gheight, self._bgcolor) - return tmpstr - - def _BuildStations(self, stoplist): - """Dispatches the best algorithm for calculating station line position. - - 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] - """ - stations = [] - dists = self._EuclidianDistances(stoplist) - stations = self._CalculateYLines(dists) - return stations - - def _EuclidianDistances(self,slist): - """Calculate euclidian distances between stops. - - 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] - """ - e_dists2 = [transitfeed.ApproximateDistanceBetweenStops(stop, tail) for - (stop,tail) in itertools.izip(slist, slist[1:])] - - return e_dists2 - - def _CalculateYLines(self, dists): - """Builds a list with y-coordinates for the horizontal lines in the graph. - - 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] - """ - tot_dist = sum(dists) - if tot_dist > 0: - pixel_dist = [float(d * (self._gheight-20))/tot_dist for d in dists] - pixel_grid = [0]+[int(pd + sum(pixel_dist[0:i])) for i,pd in - enumerate(pixel_dist)] - else: - pixel_grid = [] - - return pixel_grid - - def _TravelTimes(self,triplist,index=0): - """ Calculate distances and plot stops. - - 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] - """ - - def DistanceInTravelTime(dep_secs, arr_secs): - t_dist = arr_secs-dep_secs - if t_dist<0: - t_dist = self._DUMMY_SEPARATOR # min separation - return t_dist - - if not triplist: - return [] - - if 0 < index < len(triplist): - trip = triplist[index] - else: - trip = triplist[0] - - t_dists2 = [DistanceInTravelTime(stop[3],tail[2]) for (stop,tail) - in itertools.izip(trip.GetTimeStops(),trip.GetTimeStops()[1:])] - return t_dists2 - - def _AddWarning(self, str): - print str - - def _DrawTrips(self,triplist,colpar=""): - """Generates svg polylines for each transit trip. - - Args: - # Class Trip is defined in transitfeed.py - [Trip, Trip, ...] - - Returns: - # A string containing a polyline tag for each trip - ' 0 and not colpar: - color="purple" - scriptcall = 'onmouseover="LineClick(\'%s\',\'Trip %s starting %s\')"' % (t.trip_id, - t.trip_id, transitfeed.FormatSecondsSinceMidnight(t.GetStartTime())) - tmpstrhead = '') - return "".join(tmpstrs) - - def _Uniform(self, triplist): - """Fallback to assuming uniform distance between stations""" - # This should not be neseccary, but we are in fallback mode - longest = max([len(t.GetTimeStops()) for t in triplist]) - return [100] * longest - - def _DrawStations(self, color="#aaa"): - """Generates svg with a horizontal line for each station/stop. - - Args: - # Class Stop is defined in transitfeed.py - stations: [Stop, Stop, ...] - - Returns: - # A string containing a polyline tag for each stop - " ' %(color,20,20+y+.5,self._gwidth+20,20+y+.5)) - return "".join(tmpstrs) - - def _DrawHours(self): - """Generates svg to show a vertical hour and sub-hour grid - - Returns: - # A string containing a polyline tag for each grid line - " ' \ - % (i + .5 + 20, 20, i + .5 + 20, self._gheight)) - tmpstrs.append('%d' - % (i + 20, 20, - (i / self._hour_grid + self._offset) % 24)) - else: - tmpstrs.append('' \ - % (i + .5 + 20, 20, i + .5 + 20, self._gheight)) - return "".join(tmpstrs) - - def AddStationDecoration(self, index, color="#f00"): - """Flushes existing decorations and highlights the given station-line. - - Args: - # Integer, index of stop to be highlighted. - index: 4 - # An optional string with a html color code - color: "#fff" - """ - tmpstr = str() - num_stations = len(self._stations) - ind = int(index) - if self._stations: - if 0 0 and float(newfactor) < self._MAX_ZOOM: - self._zoomfactor = newfactor - - def ScaleLarger(self): - """Increases the zoom of the graph one step (0.1 units).""" - newfactor = self._zoomfactor + 0.1 - if float(newfactor) > 0 and float(newfactor) < self._MAX_ZOOM: - self._zoomfactor = newfactor - - def ScaleSmaller(self): - """Decreases the zoom of the graph one step(0.1 units).""" - newfactor = self._zoo