25#include <QGeoRectangle>
29#include <QStandardPaths>
30#include <QTemporaryFile>
36#include "GlobalObject.h"
37#include "TileServer.h"
39#include "fileFormats/MBTILES.h"
41using namespace Qt::Literals::StringLiterals;
211 return m_availableRasterMaps.value();
220 return &m_availableRasterMaps;
257 [[nodiscard]] QByteArray
geoJSON()
const {
return m_combinedGeoJSON.value();}
269 [[nodiscard]] QStringList
oversizedMaps()
const {
return m_oversizedMaps.value();}
281 [[nodiscard]] QString
serverUrl() {
return m_tileServer.serverUrl();}
295 return m_terrainMapTiles;
401 [[nodiscard]] Q_INVOKABLE QList<GeoMaps::Waypoint>
nearbyWaypoints(
const QGeoCoordinate& position,
const QString& type);
428 void onAviationMapsChanged();
432 void onMBTILESChanged();
438 void onMBTILESAboutToChange(
const QString& fileName);
443 void serveRasterMap(
const QString& mapName);
452 struct WaypointIndex {
454 QHash<QString, int> rowByICAOCode;
456 QStringList searchKeys;
458 QList<std::pair<qint32, int>> cells;
460 struct aviationDataCacheResult {
464 QByteArray combinedGeoJSON;
466 aviationDataCacheResult fillAviationDataCache(QStringList JSONFileNames,
bool hideGlidingSectors);
470 static WaypointIndex buildWaypointIndex(
const QList<Waypoint>&
waypoints);
474 static qint32 cellOf(
const QGeoCoordinate& coordinate);
480 [[nodiscard]] std::optional<QList<int>> rowsNear(
const QGeoCoordinate& position,
double radiusM)
const;
485 QString _currentBaseMapPath;
486 QString _currentTerrainMapPath;
489 TileServer m_tileServer;
492 QPointer<QTemporaryFile> m_styleFile;
497 QFuture<GeoMaps::GeoMapProvider::aviationDataCacheResult> _aviationDataCacheFuture;
498 QTimer _aviationDataCacheTimer;
503 QList<QSharedPointer<FileFormats::MBTILES>> m_baseMapVectorTiles;
504 QProperty<QList<QSharedPointer<FileFormats::MBTILES>>> m_baseMapRasterTiles;
505 QList<QSharedPointer<FileFormats::MBTILES>> m_terrainMapTiles;
507 QProperty<QStringList> m_availableRasterMaps;
508 QStringList computeAvailableRasterMaps();
510 QProperty<QString> m_currentRasterMap {u
"non-empty place holder"_s};
511 QPropertyNotifier m_currentRasterMapNotifier;
512 QProperty<int> m_currentRasterMapTileSize {512};
515 QList<Waypoint> _waypoints_;
516 WaypointIndex m_waypointIndex;
517 QProperty<QList<Airspace>> m_airspaces;
523 static constexpr qint64 maxAviationMapFileSize = 50*1024*1024;
524 static constexpr qint64 maxGeoJSONCacheSize = 150*1024*1024;
528 QCache<qint64,QImage> terrainTileCache {6};
531 QString geoJSONCache {QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + u
"/aviationData.json"_s};
A very simple class that describes an airspace.
Provides geographic information.
~GeoMapProvider() override
Destructor.
QBindable< QString > bindableCurrentRasterMap() const
Getter function for the property with the same name.
QList< Waypoint > waypoints()
Getter function for the property with the same name.
Q_INVOKABLE QList< GeoMaps::Waypoint > nearbyWaypoints(const QGeoCoordinate &position, const QString &type)
void terrainMapTilesChanged()
Notification signal for the property with the same name.
void oversizedMapsChanged()
Notification signal for the property with the same name.
QStringList oversizedMaps() const
Getter function for the property with the same name.
QBindable< QList< GeoMaps::Airspace > > bindableAirspaces()
Getter function for the property with the same name.
QBindable< QByteArray > bindableGeoJSON()
Getter function for the property with the same name.
QList< QSharedPointer< FileFormats::MBTILES > > terrainMapTiles() const
Getter function for the property with the same name.
QBindable< QStringList > bindableAvailableRasterMaps() const
Getter function for the property with the same name.
QString serverUrl()
Getter function for the property with the same name.
QStringList availableRasterMaps
Available Raster Maps.
Q_INVOKABLE Waypoint findByID(const QString &icaoID)
QString currentRasterMap
Current Raster Map.
QString currentRasterMap() const
Getter function for the property with the same name.
static Q_INVOKABLE GeoMaps::Waypoint createWaypoint()
Create invalid waypoint.
Q_INVOKABLE QVariantList airspacesAtPosition(const QGeoCoordinate &position)
List of airspaces at a given position.
static Q_INVOKABLE QByteArray emptyGeoJSON()
Create empty GeoJSON document.
QByteArray geoJSON
Union of all aviation maps in GeoJSON format.
QBindable< QStringList > bindableOversizedMaps()
Getter function for the property with the same name.
void styleFileURLChanged()
Notification signal for the property with the same name.
Q_INVOKABLE Units::Distance terrainElevationAMSL(const QGeoCoordinate &coordinate)
Elevation of terrain at a given coordinate, above sea level.
QString serverUrl
URL under which this server is presently reachable.
GeoMapProvider(QObject *parent=nullptr)
Creates a new GeoMap provider.
void geoJSONChanged()
Notification signal for the property with the same name.
QBindable< int > bindableCurrentRasterMapTileSize() const
Getter function for the property with the same name.
QString styleFileURL()
Getter function for the property with the same name.
QString copyrightNotice
Copyright notice for the map.
QStringList waypointSearchKeys() const
Search keys of the waypoints.
QList< GeoMaps::Airspace > airspaces
Available Airspaces.
QStringList oversizedMaps
Names of installed aviation maps that are too large to load.
QByteArray geoJSON() const
Getter function for the property with the same name.
QList< GeoMaps::Waypoint > waypoints
Waypoints.
void serverUrlChanged()
Notification signal for the property with the same name.
QStringList availableRasterMaps() const
Getter function for the property with the same name.
void deferredInitialization() override
Non-constructor initialization.
int currentRasterMapTileSize
Current Raster Map Tile Size.
int currentRasterMapTileSize() const
Getter function for the property with the same name.
void waypointsChanged()
Notification signal for the property with the same name.
QString styleFileURL
URL where a style file for the base map can be retrieved.
void setCurrentRasterMap(const QString &mapName)
Setter function for the property with the same name.
QListQSharedPointer< FileFormats::MBTILES > terrainMapTiles
List of terrain map MBTILES.
Q_INVOKABLE GeoMaps::Waypoint closestWaypoint(QGeoCoordinate position, const QGeoCoordinate &distPosition)
Find closest waypoint to a given position.
static QString copyrightNotice()
Getter function for the property with the same name.
Waypoint, such as an airfield, a navaid station or a reporting point.
static Q_INVOKABLE GeoMaps::GeoMapProvider * geoMapProvider()
Pointer to appplication-wide static GeoMaps::GeoMapProvider instance.
GlobalObject(QObject *parent=nullptr)
Standard constructor.
Convenience class for distance computations.