Jacek Kowalski
2019-06-17 9970fbd17d1a67efad67f3dafaa07730f83210b5
Add mapping function as Mapper::mapUsingOffset() parameter
2 files modified
7 ■■■■■ changed files
lib/mapper.php 4 ●●●● patch | view | raw | blame | history
parse.php 3 ●●●● patch | view | raw | blame | history
lib/mapper.php
@@ -126,12 +126,12 @@
        return $bestOffset;
    }
    
    public function mapUsingOffset($offset) {
    public function mapUsingOffset($offset, $mapper) {
        $result = [];
        foreach($this->gtfsrtTrips as $gtfsTripId => $gtfsTrip) {
            $ttssTripId = $gtfsTripId + $offset;
            if(isset($this->ttssTrips[$ttssTripId])) {
                $data = numToTypeB($gtfsTrip['id']);
                $data = $mapper($gtfsTrip['id']);
                $num = $gtfsTrip['num'];
                if(!is_array($data) || !isset($data['num'])) {
                    $data = [
parse.php
@@ -13,6 +13,7 @@
        'ttss_file' => 'vehicles_A.json',
        'database' => 'mapping_A.sqlite3',
        'result' => 'mapping_A.json',
        'mapper' => 'numToTypeB',
    ],
];
@@ -58,7 +59,7 @@
        }
        
        $logger->info('Got offset '.$offset.', creating mapping...');
        $mapping = $mapper->mapUsingOffset($offset);
        $mapping = $mapper->mapUsingOffset($offset, $source['mapper']);
        
        $logger->info('Checking the data for correctness...');
        $weight = count($mapping);