コード例 #1
0
function printPageForStop($stop)
{
    $agency = $stop[0];
    $sid = $stop[1];
    $stopId1 = $stop[0];
    $result = getJson("http://atlanta.onebusaway.org/api/api/where/schedule-for-stop/" . $stopId1 . ".json?key=TEST&date=2015-09-08");
    // weekday
    $stopName = $result['data']['references']['stops'][0]['name'];
    if (isset($_REQUEST['stopNameOverride']) && $_REQUEST['stopNameOverride'] != "") {
        $stopName = $_REQUEST['stopNameOverride'];
    }
    $routes = $result['data']['references']['routes'];
    $stopSchedules = array();
    $groupedSchedules = array();
    // FIRST bus stop
    // get weekday schedules
    createSchedules($result, $stopSchedules, 'wkday');
    // get saturday schedules
    $result = getJson("http://atlanta.onebusaway.org/api/api/where/schedule-for-stop/" . $stopId1 . ".json?key=TEST&date=2015-04-04");
    // saturday
    createSchedules($result, $stopSchedules, 'sat');
    // get sunday schedules
    $result = getJson("http://atlanta.onebusaway.org/api/api/where/schedule-for-stop/" . $stopId1 . ".json?key=TEST&date=2015-04-05");
    // sunday
    createSchedules($result, $stopSchedules, 'sun');
    // SECOND BUS STOP if available
    $stopId2 = $stop[1];
    if ($stopId2 != "") {
        // get weekday schedules
        $result = getJson("http://atlanta.onebusaway.org/api/api/where/schedule-for-stop/" . $stopId2 . ".json?key=TEST&date=2015-09-08");
        // weekday
        createSchedules($result, $stopSchedules, 'wkday');
        // get saturday schedules
        $result = getJson("http://atlanta.onebusaway.org/api/api/where/schedule-for-stop/" . $stopId2 . ".json?key=TEST&date=2015-04-04");
        // saturday
        createSchedules($result, $stopSchedules, 'sat');
        // get sunday schedules
        $result = getJson("http://atlanta.onebusaway.org/api/api/where/schedule-for-stop/" . $stopId2 . ".json?key=TEST&date=2015-04-05");
        // sunday
        createSchedules($result, $stopSchedules, 'sun');
    }
    $groupedSchedules = createMergedSchedules($stopSchedules);
    // Above we marked certain headsigns as "AMBIGUOUS"
    // b/c the same text might be used for multiple directions of travel.
    // Merge 'AMBIGUOUS' schedules with another schedule of the same route (MARTA 12).
    $deleteCandidates = array();
    foreach ($groupedSchedules as $ss) {
        if ($ss['direction2'] == 'AMBIGUOUS') {
            foreach ($groupedSchedules as &$ss1) {
                if ($ss1['name'] == $ss['name'] && $ss1['direction2'] != 'AMBIGUOUS') {
                    array_push($deleteCandidates, $ss);
                    $ss1['wkday'] = array_merge($ss1['wkday'], $ss['wkday']);
                    $ss1['sat'] = array_merge($ss1['sat'], $ss['sat']);
                    $ss1['sun'] = array_merge($ss1['sun'], $ss['sun']);
                    sort($ss1['wkday']);
                    sort($ss1['sat']);
                    sort($ss1['sun']);
                    break;
                }
            }
        }
    }
    foreach ($deleteCandidates as $dc) {
        unset($groupedSchedules[$dc['finalDestination']]);
    }
    // print
    echo "<div class='page'>";
    echo "<div id='fold'></div>";
    printPageHeader($stopName);
    //echo "<div id='pageBody'>";
    echo "<div id='mapFold'>";
    echo "<img src='img/fakemap.png' style='width:100%; height:75%;' />";
    echo "</div>";
    echo "<div id='scheduleFold'>";
    echo "<div class='buses'>";
    //echo "<ul>";
    foreach ($stopSchedules as $ss) {
        //echo "<li>" . $ss['direction2'] . "</li>";
        //printRouteInfo($ss);
    }
    foreach ($groupedSchedules as $ss) {
        //echo "<li>" . $ss['direction2'] . "</li>";
        printRouteInfo($ss);
    }
    //echo "</ul>";
    echo "</div>";
    echo <<<EOT
\t<div class='disclaimer'>
\t\t*Trip times are approximate, may change without notice, and may vary with road conditions, events, and holidays. Data provided by MARTA and OneBusAway.
\t\t<br /><span class='alt-lang'>*Los horarios son indicativos, pueden cambiar sin aviso previo y cambiar en funci&oacute;n de las condiciones de circulaci&oacute;n, eventos, y d&iacute;as festivos.</span> 
\t</div>
EOT;
    echo "</div>";
    //echo "</div><!-- pageBody -->";
    printPageFooter($sid);
    echo "</div>";
    echo "<div style='clear:both; page-break-after: always;'><" . "/div>";
}
コード例 #2
0
function printPageForStop($sign)
{
    echo "<div class='page12'>";
    printPageHeader($sign);
    $stopid = $sign->sid;
    echo "<div class='map-container' id='map_{$stopid}'></div>";
    echo "<div class='buses'>";
    $groupedSchedules = $sign->groupedSchedules;
    foreach ($groupedSchedules as $ss) {
        printRouteInfo($ss);
    }
    echo "</div>";
    // </.buses>
    printPageFooter($sign);
    echo "<div style='clear:both; page-break-after: always;'></div>";
}