File indexing completed on 2024-05-12 04:42:56
0001 /* 0002 SPDX-FileCopyrightText: 2023 Volker Krause <vkrause@kde.org> 0003 SPDX-License-Identifier: LGPL-2.0-or-later 0004 */ 0005 0006 function parseGps(response) 0007 { 0008 return { 0009 latitude: response.Latitude, 0010 longitude: response.Longitude, 0011 speed: response.JSON ? response.JSON.speed : undefined 0012 }; 0013 } 0014 0015 function parseJourney(response) 0016 { 0017 let section = {}; 0018 section.mode = 'PublicTransport'; 0019 section.route = {}; 0020 section.route.line = {}; 0021 section.route.line.name = response.trainType + ' ' + response.lineNumber; 0022 section.route.line.mode = 'LongDistanceTrain'; 0023 section.intermediateStops = []; 0024 const dt = response.latestStatus.dateTime.substr(0, 11); 0025 for (s of response.stations) { 0026 let stop = {}; 0027 stop.stopPoint = {}; 0028 stop.stopPoint.type = 'Stop'; 0029 stop.stopPoint.name = s.name.de; 0030 stop.stopPoint.identifier = { ibnr: s.id }; 0031 stop.scheduledDepartureTime = dt + s.departure.scheduled; 0032 stop.expectedDepartureTime = dt + s.departure.forecast; 0033 stop.scheduledArrivalTime = dt + s.arrival.scheduled; 0034 stop.expectedArrivalTime = dt + s.arrival.forecast; 0035 stop.expectedPlatform = s.track; 0036 section.intermediateStops.push(stop); 0037 } 0038 0039 let jny = {}; 0040 jny.sections = [section]; 0041 return jny; 0042 }