File indexing completed on 2024-11-24 04:45:05
0001 /* 0002 SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "knowledgedb.h" 0010 #include "osmairportdb.h" 0011 #include "timezones.h" 0012 0013 #include <QHash> 0014 #include <QMap> 0015 #include <QUrl> 0016 0017 class QIODevice; 0018 0019 namespace KItinerary { 0020 namespace Generator { 0021 0022 /** Generate airport database from Wikidata. */ 0023 class AirportDbGenerator 0024 { 0025 public: 0026 bool generate(QIODevice *out); 0027 0028 struct Airport 0029 { 0030 QUrl uri; 0031 QString iataCode; 0032 QString icaoCode; 0033 QString label; 0034 QString alias; 0035 QString country; 0036 QByteArray tz; 0037 QList<QString> fragments; // name string fragments used for indexing 0038 int tzOffset; 0039 KnowledgeDb::Coordinate coord; 0040 }; 0041 0042 OSMAirportDb osmDb; 0043 0044 private: 0045 bool fetchAirports(); 0046 bool fetchCountries(); 0047 void merge(Airport &lhs, const Airport &rhs); 0048 void improveCoordinates(); 0049 void indexNames(); 0050 0051 QHash<QUrl, Airport> m_airportMap; 0052 QMap<QString, QUrl> m_iataMap; 0053 // mapping IATA codes to indexed string fragments 0054 QMap<QString, QList<QString>> m_labelMap; 0055 0056 int m_iataCollisions = 0; 0057 int m_coordinateConflicts = 0; 0058 int m_countryConflicts = 0; 0059 int m_timezoneLoopupFails = 0; 0060 }; 0061 0062 } 0063 } 0064