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 /** Icomera GoMedia position API. 0007 * @see https://github.com/derhuerst/live-gomedia-position/ 0008 */ 0009 function parsePosition(response) 0010 { 0011 return { 0012 latitude: response.latitude, 0013 longitude: response.longitude, 0014 speed: response.speed 0015 }; 0016 } 0017 0018 function parseJourney(response) 0019 { 0020 let section = {}; 0021 section.mode = 'PublicTransport'; 0022 section.intermediateStops = []; 0023 for (s of response.journey.calling_points) { 0024 let stop = {}; 0025 stop.stopPoint = {}; 0026 stop.stopPoint.type = 'Stop'; 0027 stop.stopPoint.name = Object.values(s.display_name.values)[0]; // TODO pick the right language 0028 stop.stopPoint.identifier = { uic: s.calling_point.id.id }; 0029 stop.stopPoint.timezone = s.calling_point.timezone; 0030 stop.scheduledDepartureTime = s.calling_point.departure_times.scheduled_time; 0031 stop.expectedDepartureTime = s.calling_point.departure_times.actual_time; 0032 stop.scheduledArrivalTime = s.calling_point.arrival_times.scheduled_time; 0033 stop.expectedArrivalTime = s.calling_point.arrival_times.actual_time; 0034 stop.scheduledPlatform = s.calling_point.platform; 0035 section.intermediateStops.push(stop); 0036 } 0037 0038 return { sections: [section] }; 0039 }