From: Maxious Date: Sat, 07 Jan 2012 06:35:15 +0000 Subject: Kudos for GetMe2 Canberra X-Git-Url: https://maxious.lambdacomplex.org/git/?p=busui.git&a=commitdiff&h=9a4968545b00fca6f3eee2c73f89b35f8cc4c25c --- Kudos for GetMe2 Canberra --- --- a/about.php +++ b/about.php @@ -35,7 +35,8 @@ Some icons by Joseph Wain / glyphish.com
Native clients also available for iPhone(cbrTimetable by Sandor Kolotenko , ACT Buses by David Sullivan) - , Android (MyBus 2.0 by Imagine Team) + , Android (MyBus 2.0 by Imagine Team, GetMe2 Canberra by +Colin Thompson ) and Windows Phone 7 (TransHub Canberra by Soul Solutions) Other web clients include iTranzit.
GTFS-realtime API: --- a/include/common-session.inc.php +++ b/include/common-session.inc.php @@ -17,14 +17,6 @@ */ // you have to open the session to be able to modify or remove it session_start(); -if (isset($_REQUEST['service_period'])) { - $_SESSION['service_period'] = filter_var($_REQUEST['service_period'], FILTER_SANITIZE_STRING); - sessionUpdated(); -} -if (isset($_REQUEST['time'])) { - $_SESSION['time'] = filter_var($_REQUEST['time'], FILTER_SANITIZE_STRING); - sessionUpdated(); -} if (isset($_REQUEST['geolocate']) && $_REQUEST['geolocate'] != "Enter co-ordinates or address here") { $geocoded = false; if (isset($_REQUEST['lat']) && isset($_REQUEST['lon'])) { @@ -70,7 +62,7 @@ //debug(print_r($_SESSION, true) , "session"); function current_time() { - return ($_SESSION['time'] ? $_SESSION['time'] : date("H:i:s")); + return ($_REQUEST['time'] ? $_REQUEST['time'] : date("H:i:s")); } ?> --- a/include/common-template.inc.php +++ b/include/common-template.inc.php @@ -175,7 +175,7 @@
'; if ($GTFSREnabled) { $overrides = getServiceOverride(); - if ($overrides['service_id']) { + if (isset($overrides['service_id'])) { if ($overrides['service_id'] == "noservice") { echo '
Buses are not running today due to industrial action/public holiday. See http://www.action.act.gov.au for details.
'; @@ -212,9 +212,37 @@ } echo "\n
"; } - +function timeSettings() { + global $service_periods; +echo '
+

Change Time (' . (isset($_REQUEST['time']) ? $_REQUEST['time'] : "Current Time,") . ' ' . ucwords(service_period()) . ')...

+
+ + + + +
+
+ + + Current Time? +
+
+ + + +
+ + +
+
'; +} function placeSettings() { - global $service_periods; + $geoerror = false; $geoerror = !isset($_SESSION['lat']) || !isset($_SESSION['lat']) || $_SESSION['lat'] == "" || $_SESSION['lon'] == ""; --- a/include/common-transit.inc.php +++ b/include/common-transit.inc.php @@ -18,43 +18,63 @@ $service_periods = Array( 'sunday', 'saturday', - 'weekday' + 'weekday', + "Christmas2011","EndOfYearHolidays" ); -function service_period_day ($spid) { - $idParts = explode("-",$spid); - return strtolower($idParts[2]); -} + function service_period($date = "") { - if (isset($_SESSION['service_period'])) - return $_SESSION['service_period']; + if (isset($_REQUEST['service_period'])) { + return $_REQUEST['service_period']; + } + $override = getServiceOverride($date); - if ($override['service_id']) { - return service_period_day ($override['service_id']); - } - - switch (date('w', ($date != "" ? $date : time()))) { - case 0: - return 'sunday'; - case 6: - return 'saturday'; - default: - return 'weekday'; - } -} + if (isset($override['service_id'])) { + return strtolower($override['service_id']); + } + $date = ($date != "" ? $date : time()); +// christmas special cases + $ymd = date('Ymd', $date); + $dow = date('w', $date); + if ($ymd == "20111225") { + return "Christmas2011"; + } if ($ymd == "20111228" || $ymd == "20111229" || $ymd == "20111230") { + return "EndOfYearHolidays"; + } else if (intval($ymd) < "20120203" && $dow != 0 && $dow != 6) { + return "Weekday-SchoolVacation"; + } else { + switch ($dow) { + case 0: + return 'sunday'; + case 6: + return 'saturday'; + default: + return 'weekday'; + } + } +} + function service_ids($service_period) { switch ($service_period) { case 'sunday': - return Array("2010-TUGGSUN-Sunday-20","2010-BELCSUN-Sunday-19"); + return Array("Sunday", "Sunday"); case 'saturday': - return Array("2010-BELCSAT-Saturday-19","2010-TUGGSAT-Saturday-19"); + return Array("Saturday", "Saturday"); + case "Christmas2011": + return Array("Christmas2011", "Christmas2011"); + case "EndOfYearHolidays": + return Array("Weekday-EndOfYearHolidays", "Weekday-EndOfYearHolidays"); + case "Weekday-SchoolVacation": + return Array("Weekday", "Weekday-SchoolVacation"); default: //return 'weekday'; - return Array("2010-BELCMAST-Weekday-15","2010-TUGGMAST-Weekday-14"); - } -} + return Array("Weekday", "Weekday"); + } +} + function valid_service_ids() { - return array_merge(service_ids(""),service_ids('saturday'),service_ids('sunday')); + return array_merge(service_ids(""), service_ids('saturday'), service_ids('sunday'), + Array("Christmas2011","Weekday-EndOfYearHolidays","Weekday-SchoolVacation")); } function midnight_seconds($time = "") { --- a/include/db/route-dao.inc.php +++ b/include/db/route-dao.inc.php @@ -46,11 +46,11 @@ function getRouteHeadsigns($routeID) { global $conn; - $query = "select stops.stop_name, direction_id,max(service_id) as service_id, count(*) + $query = "select stops.stop_name, trip_headsign, direction_id,max(service_id) as service_id, count(*) from routes join trips on trips.route_id = routes.route_id join stop_times on stop_times.trip_id = trips.trip_id join stops on stop_times.stop_id = stops.stop_id where trips.route_id = :routeID -and stop_times.stop_sequence = 1 group by stops.stop_name, direction_id having count(*) > 2"; +and stop_times.stop_sequence = 1 group by stops.stop_name, trip_headsign, direction_id having count(*) > 2"; debug($query, "database"); $query = $conn->prepare($query); $query->bindParam(":routeID", $routeID); @@ -260,25 +260,24 @@ $service_ids = service_ids($service_period); $sidA = $service_ids[0]; $sidB = $service_ids[1]; + global $conn; $query = "SELECT DISTINCT service_id,trips.route_id,route_short_name,route_long_name FROM stop_times join trips on trips.trip_id = stop_times.trip_id join routes on trips.route_id = routes.route_id join stops on stops.stop_id = stop_times.stop_id -WHERE zone_id LIKE ':suburb AND (service_id=:service_periodA OR service_id=:service_periodB) +WHERE stop_desc LIKE :suburb AND (service_id=:service_periodA OR service_id=:service_periodB) ORDER BY route_short_name"; debug($query, "database"); $query = $conn->prepare($query); $query->bindParam(":service_periodA", $sidA); $query->bindParam(":service_periodB", $sidB); - $query->bindParam(":service_period", $service_period); - $suburb = "%" . $suburb . ";%"; + $suburb = "%Suburb: %" . $suburb . "%"; $query->bindParam(":suburb", $suburb); $query->execute(); - if (!$query) { - databaseError($conn->errorInfo()); - return Array(); - } + + databaseError($conn->errorInfo()); + return $query->fetchAll(); } --- a/index.php +++ b/index.php @@ -20,7 +20,7 @@
-

busness time


Canberra Bus Timetables and Trip Planner +

busness time


Canberra Bus Timetables and Trip Planner
Launch Trip Planner... @@ -38,8 +38,12 @@
  • Nearby Routes
  • Busness R&D'; echo ' MyWay Balance and Timeliness Survey Results'; + include_footer(true) ?> --- a/routeList.php +++ b/routeList.php @@ -18,6 +18,7 @@ include ('include/common.inc.php'); function navbar() { + echo '
      @@ -28,6 +29,42 @@
    '; +} + +function displayRoutes($routes) { + global $nearby; + echo ' '; -} else if (isset($nearby) || isset($suburb)) { - $routes = Array(); +} else if (isset($suburb)) { + if ($suburb) { include_header($suburb . " - " . ucwords(service_period()), "routeList"); navbar(); - timePlaceSettings(); + timeSettings(); trackEvent("Route Lists", "Routes By Suburb", $suburb); - $routes = getRoutesBySuburb($suburb); + displayRoutes(getRoutesBySuburb($suburb)); } - if (isset($nearby)) { - include_header("Routes Nearby", "routeList", true, true); - trackEvent("Route Lists", "Routes Nearby", $_SESSION['lat'] . "," . $_SESSION['lon']); - navbar(); - placeSettings(); - if (!isset($_SESSION['lat']) || !isset($_SESSION['lat']) || $_SESSION['lat'] == "" || $_SESSION['lon'] == "") { - include_footer(); - die(); - } - $routes = getRoutesNearby($_SESSION['lat'], $_SESSION['lon']); +} else if (isset($nearby)) { + $routes = Array(); + include_header("Routes Nearby", "routeList", true, true); + trackEvent("Route Lists", "Routes Nearby", $_SESSION['lat'] . "," . $_SESSION['lon']); + navbar(); + placeSettings(); + if (!isset($_SESSION['lat']) || !isset($_SESSION['lat']) || $_SESSION['lat'] == "" || $_SESSION['lon'] == "") { + include_footer(); + die(); } - echo '