QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
TerrainTileManager.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <QtCore/QMutex>
6#include <QtCore/QObject>
7#include <QtCore/QQueue>
8#include <QtPositioning/QGeoCoordinate>
9
10class TerrainTile;
11class QNetworkAccessManager;
12
13class TerrainTileManager : public QObject
14{
15 Q_OBJECT
16public:
17 explicit TerrainTileManager(QObject *parent = nullptr);
19
21
25 bool getAltitudesForCoordinates(const QList<QGeoCoordinate> &coordinates, QList<double> &altitudes, bool &error);
26
27 void addCoordinateQuery(TerrainQueryInterface *terrainQueryInterface, const QList<QGeoCoordinate> &coordinates);
28 void addPathQuery(TerrainQueryInterface *terrainQueryInterface, const QGeoCoordinate &startPoint, const QGeoCoordinate &endPoint);
29 void addCarpetQuery(TerrainQueryInterface *terrainQueryInterface, const QGeoCoordinate &swCoord, const QGeoCoordinate &neCoord, bool statsOnly);
30
31private slots:
32 void _terrainDone();
33
34private:
36 static QList<QGeoCoordinate> _pathQueryToCoords(const QGeoCoordinate &fromCoord, const QGeoCoordinate &toCoord, double &distanceBetween, double &finalDistanceBetween);
37 void _tileFailed();
38 void _cacheTile(const QByteArray &data, const QString &hash);
39 TerrainTile *_getCachedTile(const QString &hash);
40 bool _isFailedTile(const QString &hash);
41 bool _recordFailedTile(const QString &hash);
42 void _clearFailedTile(const QString &hash);
43 static void _processCarpetResults(const QList<double> &altitudes, int gridSizeLat, int gridSizeLon,
44 bool statsOnly, double &minHeight, double &maxHeight, QList<QList<double>> &carpet);
45
46 struct QueuedRequestInfo_t {
47 QPointer<TerrainQueryInterface> terrainQueryInterface;
49 double distanceBetween;
50 double finalDistanceBetween;
51 QList<QGeoCoordinate> coordinates;
52 bool carpetStatsOnly;
53 int carpetGridSizeLat;
54 int carpetGridSizeLon;
55 };
56
57 QQueue<QueuedRequestInfo_t> _requestQueue;
59
60 QMutex _tilesMutex;
61 QHash<QString, TerrainTile*> _tiles;
62 QHash<QString, qint64> _failedTiles;
63 qint64 _lastFailedTileSweepMs = 0;
64
65 QNetworkAccessManager *_networkManager = nullptr;
66
67 static constexpr qint64 kFailedTileBackoffMs = 5000;
68};
Error error
Base class for offline/online terrain queries.
bool getAltitudesForCoordinates(const QList< QGeoCoordinate > &coordinates, QList< double > &altitudes, bool &error)
void addPathQuery(TerrainQueryInterface *terrainQueryInterface, const QGeoCoordinate &startPoint, const QGeoCoordinate &endPoint)
void addCarpetQuery(TerrainQueryInterface *terrainQueryInterface, const QGeoCoordinate &swCoord, const QGeoCoordinate &neCoord, bool statsOnly)
static TerrainTileManager * instance()
void addCoordinateQuery(TerrainQueryInterface *terrainQueryInterface, const QList< QGeoCoordinate > &coordinates)