From b6272077e75e77d7828ff5752e7ea7c9ec4942e8 Mon Sep 17 00:00:00 2001
From: Jacek Kowalski <Jacek@jacekk.info>
Date: Fri, 21 Jun 2019 11:45:13 +0000
Subject: [PATCH] Move configuration of data sources to a separate file (config.php)
---
lib/mapper.php | 24 +++++-------------------
1 files changed, 5 insertions(+), 19 deletions(-)
diff --git a/lib/mapper.php b/lib/mapper.php
index 65987a4..42abecf 100644
--- a/lib/mapper.php
+++ b/lib/mapper.php
@@ -1,7 +1,4 @@
<?php
-require_once(__DIR__.'/../vendor/autoload.php');
-require_once(__DIR__.'/vehicle_types.php');
-
use transit_realtime\FeedMessage;
class Mapper {
@@ -42,8 +39,8 @@
continue;
}
}
- $this->ttssTrips[(int)$vehicle->tripId] = [
- 'id' => $vehicle->id,
+ $this->ttssTrips[(string)$vehicle->tripId] = [
+ 'id' => (string)$vehicle->id,
'latitude' => (float)$vehicle->latitude / 3600000.0,
'longitude' => (float)$vehicle->longitude / 3600000.0,
];
@@ -67,7 +64,7 @@
$trip = $vehiclePosition->getTrip();
$tripId = $trip->getTripId();
$this->gtfsrtTrips[self::convertTripId($tripId)] = [
- 'id' => $entity->getId(),
+ 'id' => (string)$entity->getId(),
'num' => $vehicle->getLicensePlate(),
'tripId' => $tripId,
'latitude' => $position->getLatitude(),
@@ -126,23 +123,12 @@
return $bestOffset;
}
- public function mapUsingOffset($offset, $mapper) {
+ public function mapUsingOffset($offset) {
$result = [];
foreach($this->gtfsrtTrips as $gtfsTripId => $gtfsTrip) {
$ttssTripId = $gtfsTripId + $offset;
if(isset($this->ttssTrips[$ttssTripId])) {
- $data = $mapper($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
- //$this->logger->warn('Got '.$num.', database has '.$data['num']);
- }
- $result[$this->ttssTrips[$ttssTripId]['id']] = $data;
+ $result[$this->ttssTrips[$ttssTripId]['id']] = $gtfsTrip['id'];
}
}
return $result;
--
Gitblit v1.9.1