From 1073190b7eaff62c16d3792273b2fb5744511c14 Mon Sep 17 00:00:00 2001
From: Jacek Kowalski <Jacek@jacekk.info>
Date: Fri, 01 Feb 2019 10:34:17 +0000
Subject: [PATCH] Add safeguard against unknown vehicle types

---
 parse.php |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/parse.php b/parse.php
index afa57b0..df4e100 100644
--- a/parse.php
+++ b/parse.php
@@ -117,10 +117,16 @@
 			if(isset($this->jsonTrips[$jsonTripId])) {
 				$data = numToTypeB($gtfsTrip['id']);
 				$num = $gtfsTrip['num'];
-				if($data['num'] != $num) {
-					fwrite(STDERR, 'Got '.$num.', database has '.$data['num']."\n");
+				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[$jsonTripId] = $data;
+				$result[$this->jsonTrips[$jsonTripId]['id']] = $data;
 			}
 		}
 		return $result;

--
Gitblit v1.9.1