<?php | <?php |
include ('include/common.inc.php'); | include ('include/common.inc.php'); |
include_header("About", "about") | include_header("About", "about") |
?> | ?> |
<p> | <p> |
Busness Time - An ACT bus timetable webapp<br /> | Busness Time - An ACT bus timetable webapp<br /> |
Based on the maxious-canberra-transit-feed (<a | Based on the maxious-canberra-transit-feed (<a |
href="http://s3-ap-southeast-1.amazonaws.com/busresources/cbrfeed.zip">download</a>, | href="http://s3-ap-southeast-1.amazonaws.com/busresources/cbrfeed.zip">download</a>, |
last updated <?php | last updated <?php |
echo date("F d Y.", @filemtime('cbrfeed.zip')); ?>)<br /> | echo date("F d Y.", @filemtime('cbrfeed.zip')); ?>)<br /> |
Source code for the <a | Source code for the <a |
href="https://github.com/maxious/ACTBus-data">transit | href="https://github.com/maxious/ACTBus-data">transit |
feed</a> and <a href="https://github.com/maxious/ACTBus-ui">this | feed</a> and <a href="https://github.com/maxious/ACTBus-ui">this |
site</a> available from github.<br /> | site</a> available from github.<br /> |
Uses jQuery Mobile, PHP, Ruby, Python, Google Transit Feed Specification tools, OpenTripPlanner, OpenLayers, OpenStreetMap, Cloudmade Geocoder and Tile Service<br /> | Uses jQuery Mobile, PHP, PostgreSQL, OpenTripPlanner, OpenLayers, OpenStreetMap, Cloudmade Geocoder and Tile Service<br /> |
<br /> | <br /> |
Feedback encouraged; contact maxious@lambdacomplex.org<br /> | Feedback encouraged; contact maxious@lambdacomplex.org<br /> |
<br /> | <br /> |
Some icons by Joseph Wain / glyphish.com<br /> | Some icons by Joseph Wain / glyphish.com<br /> |
<br /> | <br /> |
<small>Disclaimer: The content of this website is of a general and informative nature. Please check with printed timetables or those available on http://action.act.gov.au before your trip. | <small>Disclaimer: The content of this website is of a general and informative nature. Please check with printed timetables or those available on http://action.act.gov.au before your trip. |
Whilst every effort has been made to ensure the high quality and accuracy of the Site, the Author makes no warranty, | Whilst every effort has been made to ensure the high quality and accuracy of the Site, the Author makes no warranty, |
express or implied concerning the topicality, correctness, completeness or quality of the information, which is provided | express or implied concerning the topicality, correctness, completeness or quality of the information, which is provided |
"as is". The Author expressly disclaims all warranties, including but not limited to warranties of fitness for a particular purpose and warranties of merchantability. | "as is". The Author expressly disclaims all warranties, including but not limited to warranties of fitness for a particular purpose and warranties of merchantability. |
All offers are not binding and without obligation. The Author expressly reserves the right, in his discretion, to suspend, | All offers are not binding and without obligation. The Author expressly reserves the right, in his discretion, to suspend, |
change, modify, add or remove portions of the Site and to restrict or terminate the use and accessibility of the Site | change, modify, add or remove portions of the Site and to restrict or terminate the use and accessibility of the Site |
without prior notice. </small> | without prior notice. </small> |
<? | <? |
include_footer(); | include_footer(); |
?> | ?> |
#!/bin/bash | |
#this script should be run from a fresh git checkout from http://maxious.lambdacomplex.org | |
#ami base must have yum install lighttpd-fastcgi, git, tomcat6 | |
#screen php-cli php-gd tomcat6-webapps tomcat6-admin-webapps svn maven2 | |
#http://www.how2forge.org/installing-lighttpd-with-php5-and-mysql-support-on-fedora-12 | |
cp /root/aws.php /tmp/ | |
mkdir /var/www/lib/staticmaplite/cache | |
chcon -h system_u:object_r:httpd_sys_content_t /var/www | |
chcon -R -h root:object_r:httpd_sys_content_t /var/www/* | |
chcon -R -t httpd_sys_content_rw_t /var/www/lib/staticmaplite/cache | |
chmod -R 777 /var/www/lib/staticmaplite/cache | |
wget http://s3-ap-southeast-1.amazonaws.com/busresources/cbrfeed.zip \ | |
-O /var/www/cbrfeed.zip | |
easy_install transitfeed | |
easy_install simplejson | |
screen -S viewsh -X quit | |
screen -S viewsh -d -m /var/www/view.sh | |
wget http://s3-ap-southeast-1.amazonaws.com/busresources/Graph.obj \ | |
-O /tmp/Graph.obj | |
rm -rfv /usr/share/tomcat6/webapps/opentripplanner* | |
wget http://s3-ap-southeast-1.amazonaws.com/busresources/opentripplanner-webapp.war \ | |
-O /usr/share/tomcat6/webapps/opentripplanner-webapp.war | |
wget http://s3-ap-southeast-1.amazonaws.com/busresources/opentripplanner-api-webapp.war \ | |
-O /usr/share/tomcat6/webapps/opentripplanner-api-webapp.war | |
/etc/init.d/tomcat6 restart | |
<?php | <?php |
$service_periods = Array( | $service_periods = Array( |
'sunday', | 'sunday', |
'saturday', | 'saturday', |
'weekday' | 'weekday' |
); | ); |
function service_period() | function service_period() |
{ | { |
if (isset($_SESSION['service_period'])) return $_SESSION['service_period']; | if (isset($_SESSION['service_period'])) return $_SESSION['service_period']; |
switch (date('w')) { | switch (date('w')) { |
case 0: | case 0: |
return 'sunday'; | return 'sunday'; |
case 6: | case 6: |
return 'saturday'; | return 'saturday'; |
default: | default: |
return 'weekday'; | return 'weekday'; |
} | } |
} | } |
function midnight_seconds() | function midnight_seconds() |
{ | { |
// from http://www.perturb.org/display/Perlfunc__Seconds_Since_Midnight.html | // from http://www.perturb.org/display/Perlfunc__Seconds_Since_Midnight.html |
if (isset($_SESSION['time'])) { | if (isset($_SESSION['time'])) { |
$time = strtotime($_SESSION['time']); | $time = strtotime($_SESSION['time']); |
return (date("G", $time) * 3600) + (date("i", $time) * 60) + date("s", $time); | return (date("G", $time) * 3600) + (date("i", $time) * 60) + date("s", $time); |
} | } |
return (date("G") * 3600) + (date("i") * 60) + date("s"); | return (date("G") * 3600) + (date("i") * 60) + date("s"); |
} | } |
function midnight_seconds_to_time($seconds) | function midnight_seconds_to_time($seconds) |
{ | { |
if ($seconds > 0) { | if ($seconds > 0) { |
$midnight = mktime(0, 0, 0, date("n") , date("j") , date("Y")); | $midnight = mktime(0, 0, 0, date("n") , date("j") , date("Y")); |
return date("h:ia", $midnight + $seconds); | return date("h:ia", $midnight + $seconds); |
} | } |
else { | else { |
return ""; | return ""; |
} | } |
} | } |
function viaPoints($tripid, $stopid, $timingPointsOnly = false) | |
{ | |
global $APIurl; | |
$url = $APIurl . "/json/tripstoptimes?trip=" . $tripid; | |
$json = json_decode(getPage($url)); | |
debug(print_r($json, true)); | |
$stops = $json[0]; | |
$times = $json[1]; | |
$foundStop = false; | |
$viaPoints = Array(); | |
foreach ($stops as $key => $row) { | |
if ($foundStop) { | |
if (!$timingPointsOnly || !startsWith($row[5], "Wj")) { | |
$viaPoints[] = Array( | |
"id" => $row[0], | |
"name" => $row[1], | |
"time" => $times[$key] | |
); | |
} | |
} | |
else { | |
if ($row[0] == $stopid) $foundStop = true; | |
} | |
} | |
return $viaPoints; | |
} | |
function viaPointNames($tripid, $stopid) | |
{ | |
$points = viaPoints($tripid, $stopid, true); | |
$pointNames = Array(); | |
foreach ($points as $point) { | |
$pointNames[] = $point['name']; | |
} | |
return implode(", ", $pointNames); | |
} | |
?> | ?> |
<?php | |
function getRoute($routeID) { | |
/* | |
def handle_json_GET_routerow(self, params): | |
schedule = self.server.schedule | |
route = schedule.GetRoute(params.get('route', None)) | |
return [transitfeed.Route._FIELD_NAMES, route.GetFieldValuesTuple()] | |
*/ | |
} | |
function getRoutes() { | |
/* def handle_json_GET_routes(self, params): | |
"""Return a list of all routes.""" | |
schedule = self.server.schedule | |
result = [] | |
for r in schedule.GetRouteList(): | |
servicep = None | |
for t in schedule.GetTripList(): | |
if t.route_id == r.route_id: | |
servicep = t.service_period | |
break | |
result.append( (r.route_id, r.route_short_name, r.route_long_name, servicep.service_id) ) | |
result.sort(key = lambda x: x[1:3]) | |
return result | |
*/ | |
} | |
function findRouteByNumber($routeNumber) { | |
/* | |
def handle_json_GET_routesearch(self, params): | |
"""Return a list of routes with matching short name.""" | |
schedule = self.server.schedule | |
routeshortname = params.get('routeshortname', None) | |
result = [] | |
for r in schedule.GetRouteList(): | |
if r.route_short_name == routeshortname: | |
servicep = None | |
for t in schedule.GetTripList(): | |
if t.route_id == r.route_id: | |
servicep = t.service_period | |
break | |
result.append( (r.route_id, r.route_short_name, r.route_long_name, servicep.service_id) ) | |
result.sort(key = lambda x: x[1:3]) | |
return result | |
*/ | |
} | |
function getRouteNextTrip($routeID) { | |
/* | |
def handle_json_GET_routetrips(self, params): | |
""" Get a trip for a route_id (preferablly the next one) """ | |
schedule = self.server.schedule | |
query = params.get('route_id', None).lower() | |
result = [] | |
for t in schedule.GetTripList(): | |
if t.route_id == query: | |
try: | |
starttime = t.GetStartTime() | |
except: | |
print "Error for GetStartTime of trip #" + t.trip_id + sys.exc_info()[0] | |
else: | |
cursor = t._schedule._connection.cursor() | |
cursor.execute( | |
'SELECT arrival_secs,departure_secs FROM stop_times WHERE ' | |
'trip_id=? ORDER BY stop_sequence DESC LIMIT 1', (t.trip_id,)) | |
(arrival_secs, departure_secs) = cursor.fetchone() | |
if arrival_secs != None: | |
endtime = arrival_secs | |
elif departure_secs != None: | |
endtime = departure_secs | |
else: | |
endtime =0 | |
result.append ( (starttime, t.trip_id, endtime) ) | |
return sorted(result, key=lambda trip: trip[2]) | |
*/ | |
} | |
?> |
<?php | |
/* def StopZoneToTuple(stop): | |
"""Return tuple as expected by javascript function addStopMarkerFromList""" | |
return (stop.stop_id, stop.stop_name, float(stop.stop_lat), | |
float(stop.stop_lon), stop.location_type, stop.stop_code, stop.zone_id) | |
*/ | |
function getStop($stopID) { | |
} | |
function getStops($timingPointsOnly = false) { | |
} | |
function stopsNear($lat,$lng,$limit) { | |
/* | |
-- Show a distance query and note, London is outside the 1000km tolerance | |
SELECT name FROM global_points WHERE ST_DWithin(location, ST_GeographyFromText('SRID=4326;POINT(-110 29)'), 1000000, FALSE); | |
// All the geography functions have the option of using a sphere calculation, by setting a final boolean parameter to 'FALSE'. This will somewhat speed up calculations, particularly for cases where the geometries are very simple. | |
*/ | |
} | |
function stopsBySuburb($suburb) { | |
} | |
function stopRoutes($stopID,$service_period) | |
/* | |
def handle_json_GET_stoproutes(self, params): | |
"""Given a stop_id return all routes to visit the stop.""" | |
schedule = self.server.schedule | |
stop = schedule.GetStop(params.get('stop', None)) | |
service_period = params.get('service_period', None) | |
trips = stop.GetTrips(schedule) | |
result = {} | |
for trip in trips: | |
route = schedule.GetRoute(trip.route_id) | |
if service_period == None or trip.service_id == service_period: | |
if not route.route_short_name+route.route_long_name+trip.service_id in result: | |
result[route.route_short_name+route.route_long_name+trip.service_id] = (route.route_id, route.route_short_name, route.route_long_name, trip.trip_id, trip.service_id) | |
return result | |
*/ | |
function stopTrips($stopID) { | |
/* | |
def handle_json_GET_stopalltrips(self, params): | |
"""Given a stop_id return all trips to visit the stop (without times).""" | |
schedule = self.server.schedule | |
stop = schedule.GetStop(params.get('stop', None)) | |
service_period = params.get('service_period', None) | |
trips = stop.GetTrips(schedule) | |
result = [] | |
for trip in trips: | |
if service_period == None or trip.service_id == service_period: | |
result.append((trip.trip_id, trip.service_id)) | |
return result | |
*/ | |
} | |
function stopTripsWithTimes($stopID, $time, $service_period) { | |
/* | |
def handle_json_GET_stoptrips(self, params): | |
"""Given a stop_id and time in seconds since midnight return the next | |
trips to visit the stop.""" | |
schedule = self.server.schedule | |
stop = schedule.GetStop(params.get('stop', None)) | |
requested_time = int(params.get('time', 0)) | |
limit = int(params.get('limit', 15)) | |
service_period = params.get('service_period', None) | |
time_range = int(params.get('time_range', 24*60*60)) | |
filtered_time_trips = [] | |
for trip, index in stop._GetTripIndex(schedule): | |
tripstarttime = trip.GetStartTime() | |
if tripstarttime > requested_time and tripstarttime < (requested_time + time_range): | |
time, stoptime, tp = trip.GetTimeInterpolatedStops()[index] | |
if time > requested_time and time < (requested_time + time_range): | |
bisect.insort(filtered_time_trips, (time, (trip, index), tp)) | |
result = [] | |
for time, (trip, index), tp in filtered_time_trips: | |
if len(result) > limit: | |
break | |
route = schedule.GetRoute(trip.route_id) | |
trip_name = '' | |
if route.route_short_name: | |
trip_name += route.route_short_name | |
if route.route_long_name: | |
if len(trip_name): | |
trip_name += " - " | |
trip_name += route.route_long_name | |
if service_period == None or trip.service_id == service_period: | |
result.append((time, (trip.trip_id, trip_name, trip.service_id), tp)) | |
return result | |
*/ | |
} | |
?> |
<?php | |
function getTrip($tripID) { | |
/* def handle_json_GET_triprows(self, params): | |
"""Return a list of rows from the feed file that are related to this | |
trip.""" | |
schedule = self.server.schedule | |
try: | |
trip = schedule.GetTrip(params.get('trip', None)) | |
except KeyError: | |
# if a non-existent trip is searched for, the return nothing | |
return | |
route = schedule.GetRoute(trip.route_id) | |
trip_row = dict(trip.iteritems()) | |
route_row = dict(route.iteritems()) | |
return [['trips.txt', trip_row], ['routes.txt', route_row]] | |
*/ | |
} | |
function getTripShape() { | |
/* def handle_json_GET_tripstoptimes(self, params): | |
schedule = self.server.schedule | |
try: | |
trip = schedule.GetTrip(params.get('trip')) | |
except KeyError: | |
# if a non-existent trip is searched for, the return nothing | |
return | |
time_stops = trip.GetTimeInterpolatedStops() | |
stops = [] | |
times = [] | |
for arr,ts,is_timingpoint in time_stops: | |
stops.append(StopToTuple(ts.stop)) | |
times.append(arr) | |
return [stops, times] | |
def handle_json_GET_tripshape(self, params): | |
schedule = self.server.schedule | |
try: | |
trip = schedule.GetTrip(params.get('trip')) | |
except KeyError: | |
# if a non-existent trip is searched for, the return nothing | |
return | |
points = [] | |
if trip.shape_id: | |
shape = schedule.GetShape(trip.shape_id) | |
for (lat, lon, dist) in shape.points: | |
points.append((lat, lon)) | |
else: | |
time_stops = trip.GetTimeStops() | |
for arr,dep,stop in time_stops: | |
points.append((stop.stop_lat, stop.stop_lon)) | |
return points*/ | |
} | |
function tripStopTimes($tripID, $after_time, $limit) { | |
/* rv = [] | |
&nbs |