DataServiceData::recordStats("Get Next ETA"); exit; case 'get_all_eta': echo $data_service->getAllEta($route_id, $shuttle_id, $stop_id); DataServiceData::recordStats("Get All ETA"); exit; case 'get_all_extra_eta': echo $data_service->getAllExtraEta($route_id, $shuttle_id, $stop_id); DataServiceData::recordStats("Get Extra ETA"); exit; case 'get_shuttle_positions': echo $data_service->getShuttlePositions(); DataServiceData::recordStats("Get Shuttle Positions"); exit; case 'get_eta_and_positions': echo $data_service->getNextEta($stop_id) . $data_service->getShuttlePositions(); DataServiceData::recordStats("Get Shuttle Positions and ETA"); exit; default: echo "Command not supported."; } exit; /* the above is the URL interface. if you use this for a website on the same server, then you could just do this in your program: $data_service = new DataService(); $data = $data_service->getData($shuttleNo); then format $data array returned as you wish */
function drawExtraETA($route, $stop) { $etas = DataServiceData::getAllExtraEta($route, "", $stop); ?> <ul data-role="listview" data-theme="c"> <li><h3><?php echo $etas["name"]; ?> </h3><p><?php if ($route == 1) { echo "West Route"; } else { echo "East Route"; } ?> </p></li> <?php if (is_array($etas) && count($etas)) { foreach ($etas["eta"] as $eta_id => $eta) { ?> <li><?php echo date("h:ia", time() + $eta / 1000); ?> </li> <?php } } else { echo "<li>You broke it!</li>"; } ?> </ul> <?php }
<?php include_once "application.php"; include_once "apps/data_service.php"; include_once "apps/routecoorddistances.php"; header("Content-Type: application/json"); echo DataService::displayETAs(); DataServiceData::recordStats("Get Next ETA");