File indexing completed on 2024-05-12 04:42:56

0001 /*
0002     SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
0003     SPDX-License-Identifier: LGPL-2.0-or-later
0004 */
0005 
0006 function parseRealtime(response)
0007 {
0008     return {
0009         latitude: response.gpsLat,
0010         longitude: response.gpsLng,
0011         speed: response.speed,
0012         altitude: response.altitude
0013     };
0014 }
0015 
0016 function parseCurrent(response)
0017 {
0018     let section = {};
0019     section.mode = 'PublicTransport';
0020     section.route = {};
0021     section.route.line = {};
0022     section.route.line.name = response.name;
0023     section.route.line.mode = 'LongDistanceTrain';
0024     section.intermediateStops = [];
0025     for (s of response.connexionTimes) {
0026         let stop = {};
0027         stop.stopPoint = {};
0028         stop.stopPoint.type = 'Stop';
0029         stop.stopPoint.name = s.station.name;
0030         stop.stopPoint.latitude = s.station.gpsLat;
0031         stop.stopPoint.longitude = s.station.gpsLng;
0032         stop.stopPoint.locality = s.station.city.name;
0033         // TODO track/platform: present but null in existing samples
0034         stop.scheduledDepartureTime = s.timeDeparture;
0035         stop.scheduledArrivalTime = s.timeArrival;
0036         section.intermediateStops.push(stop);
0037     }
0038 
0039     let jny = {};
0040     jny.sections = [section];
0041     return jny;
0042 }