| | |
| | | <?php |
| | | require_once 'vendor/autoload.php'; |
| | | require('vendor/autoload.php'); |
| | | require('common.php'); |
| | | |
| | | use transit_realtime\FeedMessage; |
| | | |
| | |
| | | $trip = $vehiclePosition->getTrip(); |
| | | $tripId = $trip->getTripId(); |
| | | $this->gtfsTrips[self::convertTripId($tripId)] = [ |
| | | 'id' => $entity->getId(), |
| | | 'num' => $vehicle->getLicensePlate(), |
| | | 'tripId' => $tripId, |
| | | 'latitude' => $position->getLatitude(), |
| | |
| | | } |
| | | |
| | | if($options != 1) { |
| | | fwrite(STDERR, 'Found '.$options.' possible mappings!'."\n"); |
| | | return FALSE; |
| | | } |
| | | return $bestOffset; |
| | |
| | | foreach($this->gtfsTrips as $gtfsTripId => $gtfsTrip) { |
| | | $jsonTripId = $gtfsTripId + $offset; |
| | | if(isset($this->jsonTrips[$jsonTripId])) { |
| | | $result[$jsonTripId] = [ |
| | | 'num' => $gtfsTrip['num'], |
| | | ]; |
| | | $data = numToTypeB($gtfsTrip['id']); |
| | | $num = $gtfsTrip['num']; |
| | | if(!is_array($data) || !isset($data['num'])) { |
| | | $data = [ |
| | | 'num' => $num, |
| | | 'low' => 2, |
| | | ]; |
| | | } elseif($data['num'] != $num) { |
| | | // Ignore due to incorrect depot markings in the data |
| | | //fwrite(STDERR, 'Got '.$num.', database has '.$data['num']."\n"); |
| | | } |
| | | $result[$this->jsonTrips[$jsonTripId]['id']] = $data; |
| | | } |
| | | } |
| | | return $result; |