From 4da05f590971c2dba850fcee4acda6e3ea27f387 Mon Sep 17 00:00:00 2001
From: Jacek Kowalski <Jacek@jacekk.info>
Date: Fri, 09 Dec 2022 17:38:51 +0000
Subject: [PATCH] Update bus types: -BH096 +DO201 +BH409 +KM490-KM499

---
 lib/Mapper.php |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/lib/Mapper.php b/lib/Mapper.php
index a36b4ef..7f0e701 100644
--- a/lib/Mapper.php
+++ b/lib/Mapper.php
@@ -4,6 +4,7 @@
 class Mapper {
 	private $ttssDate = NULL;
 	private $ttssTrips = [];
+	private $ttssVehicleToTrip = [];
 	private $gtfsrtDate = NULL;
 	private $gtfsrtTrips = [];
 	private $logger = NULL;
@@ -35,18 +36,15 @@
 			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);
 	}
@@ -57,6 +55,18 @@
 	
 	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) {
@@ -130,7 +140,7 @@
 		return $bestOffset;
 	}
 	
-	public function mapUsingOffset($offset) {
+	public function mapVehicleIdsUsingOffset($offset) {
 		$result = [];
 		foreach($this->gtfsrtTrips as $gtfsTripId => $gtfsTrip) {
 			$ttssTripId = $gtfsTripId + $offset;

--
Gitblit v1.9.1