Exemplo n.º 1
0
log_api('shuttles');

require_once LIBDIR . "GTFSReader.php";
$data = Array();
$command = $_REQUEST['command'];

switch ($command) {
 case 'stops':
   $data = ShuttleSchedule::getAllStops();
   break;
 case 'stopInfo':
   $stop_id = $_REQUEST['id'];
   $time = time();

   $data['stops'] = ShuttleSchedule::getTimesForStop($stop_id);
   $data['now'] = $time;

   break;
 case 'routes': // static info about all routes
   $route_ids = ShuttleSchedule::getActiveRoutes();
   foreach ($route_ids as $route_id) {
     $routeInfo = get_route_metadata($route_id);

     if (!$_REQUEST['compact']) {
       $routeInfo['stops'] = ShuttleSchedule::list_stop_times($route_id);
       $route = ShuttleSchedule::getRoute($route_id);
       $path = array();
       foreach ($route->anyTrip(time())->shape->points as $point) {
	 $path[] = array('lat' => $point[0], 'lon' => $point[1]);
       }
    }
    unset($stops[$lastIndex]);

    echo 'NextBus GPS is ' 
      . ($gps_active ? '' : 'not ') . "avaliable on route $route_id\n";
    foreach ($stops as $stopData) {
      $rawtime = $stopData['next'];
      $time = date('m/d G:i:s', $rawtime);
      echo $stopData['id'] . ': ' . "$rawtime ($time)\n";
    }

    echo "\n";
  }
}

$stopTimes = ShuttleSchedule::getTimesForStop('kendsq_d');
foreach ($stopTimes as $route_id => $times) {
  var_dump($times);
  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');