File indexing completed on 2024-11-24 04:45:05

0001 /*
0002     SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "osm/datatypes.h"
0010 #include "osm/element.h"
0011 
0012 #include <QPolygonF>
0013 
0014 #include <map>
0015 #include <vector>
0016 
0017 struct OSMAirportData
0018 {
0019     QString source; // OSM URL, for diagnostics only
0020     OSM::BoundingBox bbox;
0021 
0022     QPolygonF airportPolygon;
0023 
0024     std::vector<OSM::Element> terminals;
0025     std::vector<OSM::Coordinate> terminalEntrances;
0026     std::vector<OSM::Element> stations;
0027 };
0028 
0029 /** OSM airport database for optimizing geo coordinates. */
0030 class OSMAirportDb
0031 {
0032 public:
0033     void load(const QString &path);
0034     OSM::Coordinate lookup(const QString &iata, float lat, float lon);
0035 
0036 private:
0037     void loadAirport(OSM::Element elem);
0038     void loadAirport(OSM::Element elem, const QString &iataCode);
0039     void loadTerminal(OSM::Element elem);
0040     void filterTerminals(OSMAirportData &airport);
0041     void loadStation(OSM::Element elem);
0042     void filterStations(OSMAirportData &airport);
0043 
0044     OSM::DataSet m_dataset;
0045     std::map<QString, OSMAirportData> m_iataMap;
0046 };
0047