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 parseGps(response) 0007 { 0008 return { 0009 latitude: response.latitude, 0010 longitude: response.longitude, 0011 speed: response.speed * 3.6, // m/s -> km/h 0012 heading: response.heading, 0013 altitude: response.altitude 0014 }; 0015 } 0016 0017 function parseDetails(response) 0018 { 0019 let section = {}; 0020 section.mode = 'PublicTransport'; 0021 section.route = {}; 0022 section.route.line = {}; 0023 section.route.line.name = response.carrier + ' ' + response.number; 0024 section.route.line.mode = 'LongDistanceTrain'; 0025 section.intermediateStops = []; 0026 for (s of response.stops) { 0027 let stop = {}; 0028 stop.stopPoint = {}; 0029 stop.stopPoint.type = 'Stop'; 0030 stop.stopPoint.name = s.label; 0031 stop.stopPoint.latitude = s.coordinates.latitude; 0032 stop.stopPoint.longitude = s.coordinates.longitude; 0033 stop.stopPoint.identifier = {}; 0034 stop.stopPoint.identifier.sncf = s.code; 0035 stop.scheduledDepartureTime = s.theoricDate; 0036 stop.expectedDepartureTime = s.realDate; 0037 section.intermediateStops.push(stop); 0038 } 0039 0040 const idx = section.intermediateStops.length - 1; 0041 section.intermediateStops[idx].scheduledArrivalTime = section.intermediateStops[idx].scheduledDepartureTime; 0042 section.intermediateStops[idx].expectedArrivalTime = section.intermediateStops[idx].expectedDepartureTime; 0043 0044 let jny = {}; 0045 jny.sections = [section]; 0046 return jny; 0047 }