public static function init() {
    self::reset_query();
    if (!self::$routeCache) {
      ShuttleSchedule::init();
      // this is part of a hack to correct 
      // saferide route names that nextbus gets wrong
      $combined_routes = Array(
        'saferidebostone' => 'saferidebostonall',
	'saferidebostonw' => 'saferidebostonall',
	'saferidecambeast' => 'saferidecamball',
	'saferidecambwest' => 'saferidecamball',
	);

      // query nextbus to see what routes are available
      self::set_command('routeList');
      $xml = self::query();
      if ($xml) {
	self::$unmodifiedRouteList = Array();

	foreach ($xml->getElementsByTagName('route') as $route) {
	  $routeName = $route->getAttribute('tag');
	  self::$unmodifiedRouteList[] = $routeName;

	  // if nextbus' route list is not consistent with the published schedule
	  // use the published route list

	  if (!ShuttleSchedule::is_running_today($routeName)
	      && array_key_exists($routeName, $combined_routes)
              && ShuttleSchedule::is_running_today($combined_routes[$routeName])) {
	    $routeName = $combined_routes[$routeName];
	  }

	  if (!self::$routeCache[$routeName] = self::read_route_cache($routeName)) {
	    self::$routeCache[$routeName] = Array();
	  }
	}

      } else {
	// query failed; get {routeName}s from cached filenames
	foreach (scandir(CACHE_DIR) as $filename) {
	  if (strpos($filename, self::$routeCachePrefix) == 0) {
	    $routeName = substr($filename, 0, strlen(self::$routeCachePrefix));
	    self::$routeCache[$routeName] = self::read_route_cache($routeName);
	  }
	}
      }

    }
  }
Esempio n. 2
0
/**
 * Copyright (c) 2009 West Virginia University
 * 
 * Licensed under the MIT License
 * Redistributions of files must retain the above copyright notice.
 * 
 */


require "lib/ShuttleSchedule.php";
require "../page_builder/page_header.php";
require "lib/schedule_lib.php";
require "../../config.gen.inc.php";
require "data/data.inc.php";

$schedule = new ShuttleSchedule();

//include all the shuttle schedule data
require "data/".$bus_schedule;

if($search_terms = $_REQUEST["a"]) {
} else {
  $search_terms = "";
}

$short_shuttles = array();
$short_shuttles['blue'] = 'blue_line';
$short_shuttles['bgc'] = 'blue_and_gold_connector';

$sms_route = $short_shuttles[$_REQUEST['a']];
$route = $schedule->getRoute($sms_route);
<?


require_once "mobi_lib_constants.php";
require_once(LIB_ROOT . 'ShuttleSchedule.php');

//print_r(ShuttleSchedule::get_route_list());
$routes = ShuttleSchedule::get_active_routes();
//$routes = Array('boston_all');
//print_r($routes);
//$routes = Array('boston_east');
foreach ($routes as $route) {
  echo ShuttleSchedule::get_title($route) . '(' . $route . ")\n";
  //print_r(ShuttleSchedule::get_next_scheduled_loop($route));
  //echo 'is running: ' . ShuttleSchedule::is_running($route) . "\n";
}

?>
function list_stop_times($route, $time, $gps_active, $singleStopId=NULL) {

  $stops = Array();

  $schedStops = ShuttleSchedule::get_next_scheduled_loop($route, $time);
  $nbStopsInfo = NextBusReader::get_route_info($route);
  $interval = ShuttleSchedule::get_interval($route);
  $end_time = ShuttleSchedule::get_last_run($route, $time) + $interval;

  // this array will contain the stops to be highlighted
  $upcoming_stops = Array();
  $previous_time = 0;

  if ($gps_active) {
    $nbPredictions = NextBusReader::get_predictions($route, $time);
  }

  if (!$nbPredictions) {
    // this condition might occur because we have a delay in 
    // deciding the gps is offline after the bus has actually
    // gone out of service
    $gps_active = FALSE;
  }

  // this gives an array of seconds until next arrival
  // at each stop
  foreach ($schedStops as $index => $stop) {
    $stopData = Array();
    $stopId = $stop['nextBusId'];
    $stopData['id'] = $stopId;
    $stopData['title'] = $stop['title'];
    $stopData['lat'] = $nbStopsInfo[$stopId]['lat'];
    $stopData['lon'] = $nbStopsInfo[$stopId]['lon'];
    $stopData['next'] = $stop['nextScheduled'];
    if ($gps_active && $stopData['next'] !== 0) {
      $stopData['predictions'] = Array();
      if (!$nbPredictions[$stopId]) {
	error_log("no predictions for $stopId on route $route. predictions:" . serialize($nbPredictions));
	continue;
      }
      sort($nbPredictions[$stopId]);
      $firstPrediction = array_shift($nbPredictions[$stopId]);
      $stopData['next'] = $time + $firstPrediction;
      foreach ($nbPredictions[$stopId] as $prediction) {
	if ($time + (int) $prediction > $end_time) {
	  break;
	}
	$stopData['predictions'][] = $prediction - $firstPrediction;
      }
    }

    // short circuit if a single stop is requested
    if ($stopId == $singleStopId) {
      return $stopData;
    }

    if ($stopData['next'] < $previous_time && $stopData['next'] - $time < $interval) {
      $stopData['upcoming'] = TRUE;
    }

    $stops[] = $stopData;
    $previous_time = $stopData['next'];
  }
  if ($stops[0]['next'] < $stops[count($stops) - 1]['next'] && $stops[0]['next'] - $time < $interval) {
    $stops[0]['upcoming'] = TRUE;
  }
  return $stops;
}
Esempio n. 5
0
	$stop_id = $row['stop_id'];
	$next_seconds = -1;
	$source = 'null';

	$route_preds = ShuttleSchedule::getNextLoop($route_id);
	if (array_key_exists('lastUpdate', $route_preds)) {
	  unset($route_preds['lastUpdate']);
	  $source = 'nextbus';
	} else {
	  $source = 'schedule';
	}

	$stop_preds = $route_preds[$stop_id];
	$next_time = $stop_preds[0];
	$next_seconds = $next_time - $time;
	$stopname = ShuttleSchedule::getStop($stop_id)->name;

	if ($next_seconds > 0 && $next_seconds < SHUTTLE_NOTIFY_THRESHOLD) {
	  $shuttle = $route->long_name;
	  $minutes = intval($next_seconds / 60);
	  $timestr = date('g:ia', $next_time);

	  switch ($source) {
	  case 'nextbus':
	    $message = "$shuttle arriving at $stopname in $minutes minutes ($timestr)";
	    break;
	  case 'schedule':
	    $message = "$shuttle (NOT GPS TRACKED) scheduled to arrive at $stopname in $minutes minutes ($timestr)";
	    break;
	  }
  echo "$route_id: ";
  foreach ($times as $time) {
    var_dump($time);
  }
  echo "\n";
}

//$mit = ShuttleSchedule::getAgency('mit');
//$saferide = ShuttleSchedule::getAgency('saferide');

//$mit = NextBusReader::agency('mit');
//$saferide = NextBusReader::agency('saferide');
//$mbta = NextBusReader::agency('mbta');

//$mit->routeList();
//print_r($saferide->routeList());

//print_r($mit->getAllStops());
//print_r($mit->routeConfig('tech'));
//print_r($mit->predictionsForRoute('tech'));
//print_r($mit->vehicleLocations('tech'));
//print_r($mit->predictionsForStop('mass84_d'));

$route = ShuttleSchedule::getRoute('tech');

$trip = $route->anyTrip(time());
$tag = ShuttleSchedule::image_tag(200, $trip, array('kendsq_d'));
var_dump($tag);

?>
Esempio n. 7
0
<?
/**
 * Copyright (c) 2008 Massachusetts Institute of Technology
 * 
 * Licensed under the MIT License
 * Redistributions of files must retain the above copyright notice.
 * 
 */

require "lib/ShuttleSchedule.php";
require "../page_builder/page_header.php";
require "lib/schedule_lib.php";
require "../../config.gen.inc.php";
require "data/data.inc.php";

$schedule = new ShuttleSchedule();

//include all the shuttle schedule data
require "data/".$bus_schedule;
$schedule->initRoutesCache();

$now = time();
$day = date('D', $now);
$hour = date('H', $now);
$minute = date('i', $now);
  
$day_routes = array();
foreach($day_keys as $key) {
  $day_routes[$key] = $schedule->getRoute($key);
}
	      $next_time = $stop_time['nextScheduled'];
	      $next_seconds = $next_time - $time;
	      $stopname = $stop_time['title'];
	      break;
	    }
	  }
	}

	if ($next_seconds > 0 && $next_seconds < SHUTTLE_NOTIFY_THRESHOLD) {
	  $shuttle = ShuttleSchedule::get_title($route_id);
	  $minutes = intval($next_seconds / 60);
	  $timestr = date('g:ia', $next_time);

	  switch ($source) {
	  case 'nextbus':
	    $stopname = ShuttleSchedule::get_stop_title($route_id, $stop_id);
	    $message = "$shuttle arriving at $stopname in $minutes minutes ($timestr)";

	    break;
	  case 'schedule':
	    // $stopname was defined earlier
	    $message = "$shuttle (NOT GPS TRACKED) scheduled to arrive at $stopname in $minutes minutes ($timestr)";
	    break;
	  }

	  //$stopname = ShuttleSchedule::get_stop_title($route_id, $stop_id);
	  switch ($row['device_type']) {
	  case 'apple':
	    $aps = array('aps' => 
			 array('alert' => $message,
			       'sound' => 'default'));
Esempio n. 9
0
<?php

/**
 * Copyright (c) 2008 Massachusetts Institute of Technology
 * 
 * Licensed under the MIT License
 * Redistributions of files must retain the above copyright notice.
 * 
 */
require_once "ShuttleSchedule.php";
require_once "../config.gen.inc.php";
$schedule = new ShuttleSchedule();
require $bus_schedule;
foreach ($schedule->getRoutes() as $route) {
    $route->populate_db();
}
<?
/**
 * Copyright (c) 2008 Massachusetts Institute of Technology
 * 
 * Licensed under the MIT License
 * Redistributions of files must retain the above copyright notice.
 * 
 */

require_once "/apache/htdocs/Mobi-Demo/web/shuttleschedule/lib/ShuttleSchedule.php";

$schedule = new ShuttleSchedule();

$schedule
     ->route("Blue Line", "blue_line")
     ->summary("Runs Monday through Saturday, all year round")
     ->perHour(1)
     ->stops(
	    st("Depot Leave"             ,"depotl"     , "frdpot", '00'),
        st("Unity Manor"             ,"unitymanor" , "frdpot", '02'),
        st("Richwood & Charles"      ,"randc"      , "frdpot", '05'),
        st("DMV (Outbound)"          ,"dmvo"       , "frdpot", '10'),
        st("Airport & Mileground"    ,"aandm"      , "frdpot", '15'),
        st("Easton Hill (Outbound)"  ,"eastonhillo", "frdpot", '20'),
        st("University High School"  ,"uhs"        , "frdpot", '30'),
        st("Canyon Dairy Mart"       ,"cdmart"     , "todpot", '32'),
        st("Lakeside Canyon"         ,"lakecanyon" , "todpot", '35'),
        st("Crest Point"             ,"crestpoint" , "todpot", '37'),
        st("Easton Hill (Inbound)"   ,"eastonhilli", "todpot", '38'),
        st("DMV (Inbound)"           ,"dmvi"       , "todpot", '47'),
        st("Depot Return"            ,"depotr"     , "todpot", '55'))    
Esempio n. 11
0
$route = $_REQUEST['route'];
if (!in_array($route, ShuttleSchedule::get_active_routes())) {
    $routeName = ucwords(str_replace('_', ' ', $_REQUEST['route']));
    $not_found_text = '<p>The route ' . $routeName . ' is not currently in service.  Please update your bookmarks accordingly.  For more information see the <a href="help.php">help page</a>.</p>';
    $page->prepare_error_page('Shuttle Schedule', 'shuttle', $not_found_text);
} else {
    $now = time();
    $routeName = ShuttleSchedule::get_title($route);
    $interval = ShuttleSchedule::get_interval($route);
    $loop_time = $interval / 60;
    $summary = ShuttleSchedule::get_summary($route);
    if ($page->branch != 'Basic') {
        // format: 9:05AM -> 9:05<span class="ampm">AM</span>
        $summary = preg_replace('/(\\d)(AM|PM)/', '$1<span class="ampm">$2</span>', $summary);
    }
    $gps_active = ShuttleSchedule::is_running($route) && NextBusReader::gps_active($route);
    $stops = list_stop_times($route, $now, $gps_active);
    $upcoming_stops = array();
    foreach ($stops as $index => $stop) {
        if ($stop['upcoming']) {
            $upcoming_stops[] = $index;
        }
    }
    // determine size of route map to display on each device
    switch ($page->branch) {
        case 'Webkit':
            $size = 270;
            break;
        case 'Touch':
            $size = 200;
            break;
Esempio n. 12
0
<?php

/**
 * Copyright (c) 2008 Massachusetts Institute of Technology
 * 
 * Licensed under the MIT License
 * Redistributions of files must retain the above copyright notice.
 * 
 */
require_once "ShuttleSchedule.php";
$schedule = new ShuttleSchedule();
$schedule->route("Cambridge East", "saferidecambeast", "SafeRide")->summary("Runs every evening, all year round")->perHour(2)->stops(st("84 Mass. Ave", "mass84_d", "frcamp", '00'), st("NW10 / Edgerton", "nw10", "frcamp", '03'), st("NW30 / Warehouse", "nw30", "frcamp", '04'), st("NW86 / 70 Pacific", "nw86", "frcamp", '05'), st("NW61 / Random Hall", "nw61", "frcamp", '06'), st("Main St @ Windsor St", "mainwinds", "frcamp", '09'), st("Portland St @ Hampshire St", "porthamp", "frcamp", '10'), st("638 Cambridge St", "camb638", "frcamp", '13'), st("Cambridge St @ Fifth St", "camb5th", "frcamp", '14'), st("Sixth @ Charles St", "6thcharl", "tocamp", '15'), st("East Lot on Main St", "elotmain", "tocamp", '17'), st("Bld 66 (Ames St)", "amesbld66", "tocamp", '18'), st("MIT Medical / 34 Carleton", "mitmed", "tocamp", '20'), st("Kendall T", "kendsq", "tocamp", '22'), st("E40 / Wadsworth", "wadse40", "tocamp", '23'), st("77 Mass. Ave", "mass77", "tocamp", '26'))->addHours("Thu-Sat", hours("18-22")->append(delay(5, "23 0 1 2 3:1")))->addHours("Sun-Wed", hours("18-21")->append(delay(5, "22 23 0 1 2:1")));
$schedule->route("Cambridge West", "saferidecambwest", "SafeRide")->summary("Runs every evening, all year round")->perHour(2)->stops(st("84 Mass. Ave", "mass84_d", "frcamp", '00'), st("W4 / McCormick", "mccrmk", "frcamp", '01'), st("W51 / Burton", "burtho", "frcamp", '02'), st("W70 / New House", "newho", "frcamp", '03'), st("W85 / Tang / Westgate", "tangwest", "frcamp", '04'), st("W79 / Simmons", "simmhl", "frcamp", '06'), st("WW15 (Request)", "ww15", "frcamp", '07'), st("Brookline St @ Chestnut St", "brookchest", "frcamp", '09'), st("Putnum Ave @ Magazine St", "putmag", "frcamp", '10'), st("River St @ Fairmont St", "rivfair", "frcamp", '12'), st("River St @ Upton St", "rivpleas", "frcamp", '13'), st("River St @ Franklin St", "rivfrank", "tocamp", '14'), st("Sydney @ Green St", "sydgreen", "tocamp", '16'), st("NW86 / 70 Pacific St", "paci70", "tocamp", '18'), st("NW30 / Warehouse", "whou", "tocamp", '19'), st("NW10 / Edgerton", "edge", "tocamp", '20'))->addHours("Thu-Sat", hours("18-22")->append(delay(5, "23 0 1 2 3:1")))->addHours("Sun-Wed", hours("18-21")->append(delay(5, "22 23 0 1 2:1")));
$schedule->route("Boston West", "saferidebostonw", "SafeRide")->summary("Runs every evening, all year round")->perHour(2)->stops(st("84 Mass Ave", "mass84_d", "boston", '15'), st("Mass Ave @ Beacon St", "massbeac", "boston", '18'), st("528 Beacon St", "beac528", "boston", '19'), st("487 Comm Ave", "comm487", "boston", '21'), st("64 Baystate", "bays64", "boston", '23'), st("111 Baystate", "bays111", "boston", '24'), st("155 Baystate", "bays155", "boston", '25'), st("259 St Paul St (ET)", "stpaul259", "boston", '32'), st("58 Manchester (ZBT)", "manc58", "mass84", '34'), st("550 Memorial Drive", "memo550", "mass84", '40'), st("Simmons Hall", "simmhl", "mass84", '41'))->addHours("Thu-Sat", hours("18-22")->append(delay(5, "23 0 1 2 3:1")))->addHours("Sun-Wed", hours("18-21")->append(delay(5, "22 23 0 1 2:1")));
$schedule->route("Boston East", "saferidebostone", "SafeRide")->summary("Runs every evening, all year round")->perHour(2)->stops(st("84 Mass. Ave", "mass84_d", "boston", '00'), st("Mass. Ave / Beacon St", "massbeac", "boston", '02'), st("478 Comm. Ave", "comm478", "boston", '04'), st("Vanderbilt (Request)", NULL, NULL, '06'), st("28 Fenway", "fenw28", "boston", '10'), st("Prudential Center", "prud", "boston", '12'), st("229 Comm Ave", "comm229", "boston", '15'), st("253 Comm Ave", "comm253", "mass84", '16'), st("32 Hereford St", "here32", "mass84", '17'), st("450 Beacon St", "beac450", "mass84", '18'), st("Beacon St @ Mass. Ave", "beacmass", "mass84", '19'))->addHours("Thu-Sat", hours("18-22")->append(delay(5, "23 0 1 2 3:1")))->addHours("Sun-Wed", hours("18-21")->append(delay(5, "22 23 0 1 2:1")));
$schedule->route("Tech Shuttle", "tech")->summary("Runs weekdays 7AM-6PM, all year round")->except_holidays()->perHour(3)->stops(st("Kendall Square T", "kendsq_d", "wcamp", '15'), st("Amherst/Wadsworth", "amhewads", "wcamp", '17'), st("Media Lab", "medilb", "wcamp", '18'), st("Building 39", "build39", "wcamp", '20'), st("84 Mass Avenue", "mass84", "wcamp", '22'), st("Burton House", "burtho", "wcamp", '24'), st("Audrey Street", "tangwest", "wcamp", '26'), st("Simmons Hall", "simmhl", "kendsq", '27'), st("Vassar/Mass Ave", "vassmass", "kendsq", '29'), st("Stata", "statct", "kendsq", '30'))->addHours("Mon-Fri", hours("7-18"), delay(30, "7-9"), delay(-10, "16-17"));
$schedule->route("Northwest Shuttle", "northwest")->summary("Runs weekdays 7AM-6PM, all year round")->except_holidays()->perHour(3)->stops(st("Kendall Square T", "kendsq_d", "nwcamp", '25'), st("Amherst/Wadsworth", "amhewads", "nwcamp", '27'), st("77 Mass Avenue", "mass77", "nwcamp", '30'), st("MIT Museum (N52)", "mitmus", "nwcamp", '32'), st("70 Pacific Street (NW86)", "paci70", "kendsq", '34'), st("The Warehouse (NW30)", "whou", "kendsq", '35'), st("Edgarton (NW10)", "edge", "kendsq", '36'), st("Vassar/Mass Ave", "vassmass", "kendsq", '39'), st("Stata", "statct", "kendsq", '41'))->addHours("Mon-Fri", hours("7-17 18:1"), delay(10, "7-9"));
$schedule->route("Boston Daytime", "boston")->summary("Runs weekdays 8AM-6PM, Sep-May")->except_holidays()->perHour(3)->stops(st("84 Mass. Ave.", "mass84_d", "boston", '07'), st("Mass. Ave. / Beacon", "massbeac", "cambridge", '09'), st("487 Comm. Ave. (PSK)", "comm487", "cambridge", '10'), st("64 Bay State (TXI)", "bays64", "cambridge", '11'), st("478 Comm. Ave.", "comm478", "cambridge", '14'), st("450 Beacon St.", "beac450", "cambridge", '19'), st("77 Mass. Ave.", "mass77", "cambridge", '23'))->addHours("Mon-Fri", hours("8-17"));
Esempio n. 13
0
<?php

require_once "../config/mobi_web_constants.php";
require_once PAGE_HEADER;
require_once LIBDIR . "ShuttleSchedule.php";
require_once LIBDIR . "NextBusReader.php";
NextBusReader::init();
$now = time();
$routes = ShuttleSchedule::get_active_routes();
$day_routes = array();
$night_routes = array();
foreach ($routes as $route) {
    if (ShuttleSchedule::is_safe_ride($route)) {
        $night_routes[] = $route;
    } else {
        $day_routes[] = $route;
    }
}
require "{$page->branch}/index.html";
$page->output();
Esempio n. 14
0
<?php
$docRoot = getenv("DOCUMENT_ROOT");

require_once $docRoot . "/mobi-config/mobi_web_constants.php";
require_once WEBROOT . "page_builder/page_header.php";
require_once LIBDIR . "GTFSReader.php";

$now = time();

$day_routes = ShuttleSchedule::getActiveRoutes('mit');
$day_routes = array_merge($day_routes, ShuttleSchedule::getActiveRoutes('charles-river'));
$night_routes = ShuttleSchedule::getActiveRoutes('saferide');

require "$page->branch/index.html";
$page->output();
?>
Esempio n. 15
0
  public static function init() {
    if (!self::$gtfs) {
      self::$gtfs = new GTFSReader(SHUTTLE_GTFS_FEED, 'r');
      self::$gtfs->parse();

      self::$agencies = array(
        'mit' => new NextBusAgency('mit'),
	'charles-river' => new NextBusAgency('charles-river'),
        'saferide' => new NextBusAgency('mit', 'saferide'),
	);

      $saferide = array(
        'saferidebostone', 'saferidebostonw', 'saferidebostonall',
	'saferidecambeast', 'saferidecambwest', 'saferidecamball',
	);

      // the 'mit' agency should catch new routes from nextbus
      self::$agencies['mit']->blackList($saferide);
      self::$agencies['saferide']->whiteList($saferide);

      $time = time();
      foreach (self::$agencies as $agency_id => $nbAgency) {
        $gtfsAgency = self::$gtfs->getAgency($agency_id);
	foreach ($gtfsAgency->routes as $route_id => $route) {
	  if ($route->isInService($time)) {
	    $nbAgency->addRoute($route);
	  }
	}
	foreach ($nbAgency->getAllStops() as $stop_id => $stop) {
	  self::$gtfs->setStop($stop_id, $stop);
	}
      }

      // start writing contents if we can sync up
      // nextbus direction id's with trip id's
      //self::$gtfs->write('routes.txt');
      //self::$gtfs->write('trips.txt');
      //self::$gtfs->write('stop_times.txt');
    }
  }
Esempio n. 16
0
/**
 * Copyright (c) 2008 Massachusetts Institute of Technology
 * 
 * Licensed under the MIT License
 * Redistributions of files must retain the above copyright notice.
 * 
 */


require "/apache/htdocs/Mobi-Demo/web/shuttleschedule/lib/ShuttleSchedule.php";
require "../page_builder/page_header.php";
require "/apache/htdocs/Mobi-Demo/web/shuttleschedule/lib/schedule_lib.php";
require "../../config.gen.inc.php";
require "/apache/htdocs/Mobi-Demo/web/shuttleschedule/data/data.inc.php";

$schedule = new ShuttleSchedule();

//include all the shuttle schedule data
require "/apache/htdocs/Mobi-Demo/web/shuttleschedule/data/".$bus_schedule;

$route = $schedule->getRoute($_REQUEST['route']);

$now = time();
$day = date('D', $now);
$hour = date('H', $now);
$minute = date('i', $now);
$seconds = date('s', $now);
$stops = $route->getCurrentStops($day, $hour, $minute);
$routeName = $route->getName();

function selfURL() {
Esempio n. 17
0
function get_route_metadata($route) {
  $metadata = Array();
  $metadata['route_id'] = $route;
  $metadata['title'] = ShuttleSchedule::get_title($route);
  $metadata['interval'] = ShuttleSchedule::get_interval($route) / 60;
  $metadata['isSafeRide'] = ShuttleSchedule::is_safe_ride($route);
  $metadata['isRunning'] = ShuttleSchedule::is_running($route);
  $metadata['summary'] = ShuttleSchedule::get_summary($route);
  return $metadata;
}
Esempio n. 18
0
function get_route_metadata($route_id) {
  $route = ShuttleSchedule::getRoute($route_id);
  $metadata = Array();
  $metadata['route_id'] = $route->id;
  $metadata['title'] = $route->long_name;
  $metadata['interval'] = $route->anyTrip(time())->duration() / 60;
  $metadata['isSafeRide'] = $route->agency_id == 'saferide';
  $metadata['isRunning'] = $route->isRunning(time());
  $metadata['summary'] = $route->desc;
  return $metadata;
}
Esempio n. 19
0
  // determine size of route map to display on each device
  switch ($page->branch) {
  case 'Webkit':
    $size = 270;
    break;
  case 'Touch':
    $size = 200;
    break;
  case 'Basic':
    $size = 200;
    break;
  }

  // produce url to google static maps image
  $image_tag = ShuttleSchedule::image_tag($size, $trip, $highlighted_stops);  

  // device-dependent time formatting function
  if ($page->branch == 'Basic') {
    function format_shuttle_time($tstamp) {
      if ($tstamp === 0) return 'finished';
      return date('g:i', $tstamp) . substr(date('a', $tstamp), 0, 1);
    }
  } else {
    function format_shuttle_time($tstamp) {
      if ($tstamp === 0) return 'finished';
      return date('g:i', $tstamp) . '<span class="ampm">' . date('A', $tstamp) . '</span>';
    }
  }

  require "$page->branch/times.html";