| | |
| | | class Mapper { |
| | | private $ttssDate = NULL; |
| | | private $ttssTrips = []; |
| | | private $ttssVehicleToTrip = []; |
| | | private $gtfsrtDate = NULL; |
| | | private $gtfsrtTrips = []; |
| | | private $logger = NULL; |
| | |
| | | if(!isset($vehicle->latitude) || !$vehicle->latitude) continue; |
| | | if(!isset($vehicle->longitude) || !$vehicle->longitude) continue; |
| | | list($line, $direction) = explode(' ', $vehicle->name, 2); |
| | | foreach($this->specialNames as $specialName) { |
| | | if(substr($vehicle->name, -strlen($specialName)) == $specialName) { |
| | | continue; |
| | | } |
| | | } |
| | | $this->ttssTrips[(string)$vehicle->tripId] = [ |
| | | $trip = [ |
| | | 'id' => (string)$vehicle->id, |
| | | 'line' => $line, |
| | | 'direction' => $direction, |
| | | 'latitude' => (float)$vehicle->latitude / 3600000.0, |
| | | 'longitude' => (float)$vehicle->longitude / 3600000.0, |
| | | ]; |
| | | $this->ttssTrips[(string)$vehicle->tripId] = $trip; |
| | | $this->ttssVehicleToTrip[(string)$vehicle->id] = $trip; |
| | | } |
| | | ksort($this->ttssTrips); |
| | | } |
| | |
| | | |
| | | public function getTTSSTrips() { |
| | | return $this->ttssTrips; |
| | | } |
| | | |
| | | public function getTTSSVehicleToTrip() { |
| | | return $this->ttssVehicleToTrip; |
| | | } |
| | | |
| | | public function getTTSSTrip($id) { |
| | | return $this->ttssTrips[$id] ?? NULL; |
| | | } |
| | | |
| | | public function getTTSSVehicleTrip($id) { |
| | | return $this->ttssVehicleToTrip[$id] ?? NULL; |
| | | } |
| | | |
| | | public function loadGTFSRT($file) { |
| | |
| | | return $bestOffset; |
| | | } |
| | | |
| | | public function mapUsingOffset($offset) { |
| | | public function mapVehicleIdsUsingOffset($offset) { |
| | | $result = []; |
| | | foreach($this->gtfsrtTrips as $gtfsTripId => $gtfsTrip) { |
| | | $ttssTripId = $gtfsTripId + $offset; |