From 45b7eba2cf3654667bf79c35c5525e2674c38341 Mon Sep 17 00:00:00 2001
From: Jacek Kowalski <Jacek@jacekk.info>
Date: Sat, 22 Jun 2019 20:05:33 +0000
Subject: [PATCH] Fix tram (HZ)250 which is really HL410
---
lib/output.php | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/lib/output.php b/lib/output.php
index d3fd6d9..4d05b40 100644
--- a/lib/output.php
+++ b/lib/output.php
@@ -1,4 +1,21 @@
<?php
+function createMapping($db, $mapFunction, $saveConfig = FALSE) {
+ $mapping = [];
+ foreach($db->getAll() as $vehicle) {
+ $mapping[$vehicle['id']] = $mapFunction($vehicle['num']);
+ }
+
+ if($saveConfig) {
+ $json = json_encode($mapping);
+ if(!file_put_contents($saveConfig['result_temp'], $json)) {
+ throw new Exception('Result save failed');
+ }
+ rename($saveConfig['result_temp'], $saveConfig['result']);
+ }
+
+ return $mapping;
+}
+
function createVehiclesList($trips, $mapping, $saveConfig = FALSE) {
$lines = [];
foreach($trips as $trip) {
--
Gitblit v1.9.1