Exemplo n.º 1
0
<?php

require '../vendor/autoload.php';
date_default_timezone_set('America/Toronto');
$routes = json_decode(file_get_contents(__DIR__ . '/../data/routes.json'));
$list = new \LondonLive\CSVStopList();
$list->readFile('stops.csv');
$scrape_webwatch = false;
$scrape_stopids = false;
if ($scrape_webwatch) {
    $fetcher = new LondonLive\StopTimesParser(new LondonLive\HTTPStopTimesFetcher());
    $routes = json_decode(file_get_contents(__DIR__ . '/../data/routes.json'));
    $fetch_time = time();
    foreach ($routes->routes as $route) {
        echo "Fetching WebWatch data for {$route->id}\n";
        $route_data = $fetcher->get($route->id);
        foreach ($route_data['stops'] as $stop) {
            $csvStop = $list->getStop($stop['number']);
            $csvStop->latitude = $stop['latitude'];
            $csvStop->longitude = $stop['longitude'];
            $csvStop->name_webwatch = $stop['name'];
        }
        file_put_contents(__DIR__ . "/../tempdata/data-{$fetch_time}-{$route->id}.txt", json_encode($route_data));
    }
}
/**
 * Returns the rows as an array of an array of strings from the
 * first table in the document.
 *
 * @param DOMDocument $dom
 */
Exemplo n.º 2
0
<?php

require '../vendor/autoload.php';
$list = new \LondonLive\CSVStopList();
$list->readFile('stops.csv');
echo "Validating stops\n";
echo "\n";
echo "Checking or stops with empty names\n";
foreach ($list->stops as $stop) {
    // Skip stops with overridden names
    if (empty($stop->getPreferredName())) {
        echo "Stop #{$stop->id}: {$stop->getPreferredName()}\n";
    }
}
echo "\n";
echo "Checking for stops with all-capital names\n";
foreach ($list->stops as $stop) {
    // Skip stops with overridden names
    if ($stop->getPreferredName() == $stop->name_override) {
        continue;
    }
    if ($stop->getPreferredName() == strtoupper($stop->getPreferredName())) {
        echo "Stop #{$stop->id}: {$stop->getPreferredName()}\n";
    }
}
echo "\n";
echo "Checking for stops missing latitude or longitude\n";
foreach ($list->stops as $stop) {
    if (!$stop->latitude || !$stop->longitude) {
        echo "Stop #{$stop->id}: {$stop->getPreferredName()}\n";
    }