Add mapping function as Mapper::mapUsingOffset() parameter
| | |
| | | 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 = [ |
| | |
| | | 'ttss_file' => 'vehicles_A.json', |
| | | 'database' => 'mapping_A.sqlite3', |
| | | 'result' => 'mapping_A.json', |
| | | 'mapper' => 'numToTypeB', |
| | | ], |
| | | ]; |
| | | |
| | |
| | | } |
| | | |
| | | $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); |