Commit e74c14ff authored by Volker Krause's avatar Volker Krause
Browse files

Fall back to the airport database when we don't find a station IATA code

We can't use the coordinates in that case (those point to the airport and
thus are likely unusable for navigation/routing), but the airport is still
good enough for determining the country/timezone.
parent 0bb3810b
Pipeline #139486 passed with stages
in 2 minutes and 47 seconds
[
{
"@context": "http://schema.org",
"@type": "TrainReservation",
"modifiedTime": "2021-04-30T15:00:00Z",
"reservationFor": {
"@type": "TrainTrip",
"arrivalStation": {
"@type": "TrainStation",
"address": {
"@type": "PostalAddress",
"addressCountry": "FR"
},
"geo": {
"@type": "GeoCoordinates",
"latitude": 48.10329818725586,
"longitude": -1.6725000143051147
},
"identifier": "iata:ZFJ",
"name": "Rennes"
},
"arrivalTime": {
"@type": "QDateTime",
"@value": "2021-05-01T09:00:00+02:00",
"timezone": "Europe/Paris"
},
"departureDay": "2021-05-01",
"departureStation": {
"@type": "TrainStation",
"address": {
"@type": "PostalAddress",
"addressCountry": "FR"
},
"identifier": "iata:CDG",
"name": "Paris"
},
"departureTime": {
"@type": "QDateTime",
"@value": "2021-05-01T06:00:00+02:00",
"timezone": "Europe/Paris"
},
"trainNumber": "AF1234"
},
"reservationNumber": "XXX007",
"reservationStatus": "http://schema.org/ReservationConfirmed"
}
]
[
{
"@type": "TrainReservation",
"modifiedTime": "2021-04-30T15:00:00Z",
"reservationFor": {
"@type": "TrainTrip",
"arrivalStation": {
"@type": "TrainStation",
"identifier": "iata:ZFJ",
"name": "Rennes"
},
"arrivalTime": "2021-05-01T09:00:00.000",
"departureStation": {
"@type": "TrainStation",
"identifier": "iata:CDG",
"name": "Paris"
},
"departureTime": "2021-05-01T06:00:00.000",
"trainNumber": "AF1234"
},
"reservationNumber": "XXX007"
}
]
......@@ -17,6 +17,7 @@
#include "mergeutil.h"
#include "sortutil.h"
#include "knowledgedb/airportdb.h"
#include "knowledgedb/timezonedb.h"
#include "knowledgedb/trainstationdb.h"
......@@ -258,8 +259,12 @@ TrainStation ExtractorPostprocessorPrivate::processTrainStation(TrainStation sta
const auto record = KnowledgeDb::stationForVRStationCode(KnowledgeDb::VRStationCode(id.mid(5)));
applyStationData(record, station);
} else if (id.startsWith(QLatin1String("iata:")) && id.size() == 8) {
const auto record = KnowledgeDb::stationForIataCode(KnowledgeDb::IataCode(QStringView(id).mid(5)));
const auto iataCode = KnowledgeDb::IataCode(QStringView(id).mid(5));
const auto record = KnowledgeDb::stationForIataCode(iataCode);
applyStationData(record, station);
// fall back to the airport with the matching IATA code for the country information
// we cannot use the coordinate though, as that points to the actual airport, not the station
applyStationCountry(KnowledgeDb::countryForAirport(iataCode).toString(), station);
} else if (id.startsWith(QLatin1String("amtrak:")) && id.size() == 10) {
const auto record = KnowledgeDb::stationForAmtrakStationCode(KnowledgeDb::AmtrakStationCode(QStringView(id).mid(7)));
applyStationData(record, station);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment