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-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.
'; --- 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($_REQUEST['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/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/servicealerts/importer.py +++ b/servicealerts/importer.py @@ -10,10 +10,12 @@ # http://esa.act.gov.au/feeds/currentincidents.xml # source: https://gist.github.com/322906/90dea659c04570757cccf0ce1e6d26c9d06f9283 +# to install python -m nltk.downloader punkt import nltk -import twitter import tweepy import psycopg2 +import pickle + from iniparse import INIConfig def insert_service_alert_sitewide(heading, message, url): @@ -79,16 +81,24 @@ # Print unique entity names print set(entity_names) + cfg = INIConfig(open('/tmp/aws.ini')) auth = tweepy.OAuthHandler(cfg.api_keys.twitter_consumer_key, cfg.api_keys.twitter_consumer_secret) auth.set_access_token(cfg.api_keys.twitter_access_token, cfg.api_keys.twitter_access_token_secret) -api = tweepy.API(auth) - +#api = tweepy.API(auth) +api = tweepy.API() # If the authentication was successful, you should # see the name of the account print out -print api.me().name +#print api.me().name # https://github.com/tweepy/tweepy/blob/master/tweepy/api.py -print api.user_timeline(screen_name="ACTPol_Traffic") -print api.update_status(status="test") +for status in api.user_timeline(screen_name="ACTPol_Traffic",exclude_replies='true'): + print status.text + print status.created_at + print extract_names(status.text) +# print api.update_status(status="test") + +last_tweet_ids = { "lion": "111", "kitty": "2222" } +pickle.dump( last_tweet_ids, open( "save.p", "wb" ) ) +last_tweet_ids = pickle.load( open( "save.p", "rb" ) ) --- /dev/null +++ b/servicealerts/punkt.zip --- a/stop.php +++ b/stop.php @@ -133,7 +133,7 @@ echo '
  • '; $destination = getTripDestination($trip['trip_id']); - echo '

    ' . $trip['route_short_name'] . " towards " . $destination['stop_name'] . "

    "; + echo '

    '. (service_period() == "Christmas2011" ? $trip['route_long_name'] : "") . $trip['route_short_name'] . " towards " . $destination['stop_name'] . "

    "; $viaPoints = viaPointNames($trip['trip_id'], $trip['stop_sequence']); if ($viaPoints != "") echo '
    Via: ' . $viaPoints . ''; --- a/trip.php +++ b/trip.php @@ -27,7 +27,7 @@ $tripid = $trip['trip_id']; } else { $trip = getTrip($tripid); - $similarRoutes = getRoutesByNumber($trip['route_short_name'], $trip['direction_id'], service_period_day($trip["service_id"])); + $similarRoutes = getRoutesByNumber($trip['route_short_name'], $trip['direction_id'], strtolower($trip["service_id"])); $routeids = Array(); foreach ($similarRoutes as $similarRoute) { $routeids[] = $similarRoute['route_id']; @@ -35,7 +35,7 @@ $routeids = array_unique($routeids); } $directionid = $trip['direction_id']; -$service_period = service_period_day($trip["service_id"]); +$service_period = strtolower($trip["service_id"]); $destination = getTripDestination($trip['trip_id']); include_header("Stops on " . $trip['route_short_name'] . ' ' . $destination['stop_name'], "trip"); trackEvent("Route/Trip View", "View Route", $trip['route_short_name'] . ' ' . $destination['stop_name'], $routeid); @@ -64,11 +64,11 @@ foreach (getRoutesByNumber($trip['route_short_name']) as $row) { foreach (getRouteHeadsigns($row['route_id']) as $headsign) { - if ( $headsign['direction_id'] != $directionid || service_period_day($headsign['service_id']) != $service_period) { - echo "{$headsign['direction_id']} != $directionid || ".service_period_day($headsign['service_id'])." != $service_period
    "; + if ( $headsign['direction_id'] != $directionid || strtolower($headsign['service_id']) != $service_period) { + echo "{$headsign['direction_id']} != $directionid || ".strtolower($headsign['service_id'])." != $service_period
    "; $start = $headsign['stop_name']; - $serviceday = service_period_day($headsign['service_id']); + $serviceday = strtolower($headsign['service_id']); $key = $row['route_short_name'] . "." . $headsign['direction_id']; if (isset($filteredRoutes[$key])) { $filteredRoutes[$key]['route_ids'][] = $row['route_id']; @@ -102,7 +102,7 @@ echo '