Commit 964f926c authored by Cosmin Marc's avatar Cosmin Marc

Improve codestyle and const correctness. Remove useless patch file.

parent f36047c0
/****************************************************************************
*
* (c) 2009-2019 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include "MapProvider.h"
MapProvider::MapProvider(QString referrer, QString imageFormat,
quint32 averageSize, QGeoMapType::MapStyle mapType,QObject* parent)
: QObject(parent), _referrer(referrer), _imageFormat(imageFormat),
_averageSize(averageSize), _mapType(mapType) {
QStringList langs = QLocale::system().uiLanguages();
MapProvider::MapProvider(const QString &referrer, const QString &imageFormat,
const quint32 averageSize, const QGeoMapType::MapStyle mapType, QObject* parent)
: QObject(parent)
, _referrer(referrer)
, _imageFormat(imageFormat)
, _averageSize(averageSize)
, _mapType(mapType)
{
const QStringList langs = QLocale::system().uiLanguages();
if (langs.length() > 0) {
_language = langs[0];
}
}
QNetworkRequest MapProvider::getTileURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager) {
QNetworkRequest MapProvider::getTileURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) {
//-- Build URL
QNetworkRequest request;
QString url = _getURL(x, y, zoom, networkManager);
const QString url = _getURL(x, y, zoom, networkManager);
if (url.isEmpty()) {
return request;
}
......@@ -25,15 +40,15 @@ QNetworkRequest MapProvider::getTileURL(int x, int y, int zoom,
return request;
}
QString MapProvider::getImageFormat(const QByteArray& image) {
QString MapProvider::getImageFormat(const QByteArray& image) const {
QString format;
if (image.size() > 2) {
if (image.startsWith(reinterpret_cast<const char*>(pngSignature)))
format = "png";
format = QStringLiteral("png");
else if (image.startsWith(reinterpret_cast<const char*>(jpegSignature)))
format = "jpg";
format = QStringLiteral("jpg");
else if (image.startsWith(reinterpret_cast<const char*>(gifSignature)))
format = "gif";
format = QStringLiteral("gif");
else {
return _imageFormat;
}
......@@ -41,11 +56,11 @@ QString MapProvider::getImageFormat(const QByteArray& image) {
return format;
}
QString MapProvider::_tileXYToQuadKey(int tileX, int tileY, int levelOfDetail) {
QString MapProvider::_tileXYToQuadKey(const int tileX, const int tileY, const int levelOfDetail) {
QString quadKey;
for (int i = levelOfDetail; i > 0; i--) {
char digit = '0';
int mask = 1 << (i - 1);
const int mask = 1 << (i - 1);
if ((tileX & mask) != 0) {
digit++;
}
......@@ -58,16 +73,16 @@ QString MapProvider::_tileXYToQuadKey(int tileX, int tileY, int levelOfDetail) {
return quadKey;
}
int MapProvider::_getServerNum(int x, int y, int max) {
int MapProvider::_getServerNum(const int x, const int y, const int max) {
return (x + 2 * y) % max;
}
int MapProvider::long2tileX(double lon, int z) {
int MapProvider::long2tileX(const double lon, const int z) const {
return static_cast<int>(floor((lon + 180.0) / 360.0 * pow(2.0, z)));
}
//-----------------------------------------------------------------------------
int MapProvider::lat2tileY(double lat, int z) {
int MapProvider::lat2tileY(const double lat, const int z) const {
return static_cast<int>(floor(
(1.0 -
log(tan(lat * M_PI / 180.0) + 1.0 / cos(lat * M_PI / 180.0)) / M_PI) /
......@@ -76,9 +91,9 @@ int MapProvider::lat2tileY(double lat, int z) {
bool MapProvider::_isElevationProvider() { return false; }
QGCTileSet MapProvider::getTileCount(int zoom, double topleftLon,
double topleftLat, double bottomRightLon,
double bottomRightLat) {
QGCTileSet MapProvider::getTileCount(const int zoom, const double topleftLon,
const double topleftLat, const double bottomRightLon,
const double bottomRightLat) const {
QGCTileSet set;
set.tileX0 = long2tileX(topleftLon, zoom);
set.tileY0 = lat2tileY(topleftLat, zoom);
......
#pragma once
/****************************************************************************
*
* (c) 2009-2019 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#include <cmath>
#include "QGCTileSet.h"
#pragma once
#include <QByteArray>
#include <QNetworkProxy>
#include <QNetworkReply>
#include <QString>
#include <cmath>
#include "QGCTileSet.h"
#include <QtLocation/private/qgeomaptype_p.h>
static const unsigned char pngSignature[] = {0x89, 0x50, 0x4E, 0x47, 0x0D,
0x0A, 0x1A, 0x0A, 0x00};
static const unsigned char pngSignature[] = {0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00};
static const unsigned char jpegSignature[] = {0xFF, 0xD8, 0xFF, 0x00};
static const unsigned char gifSignature[] = {0x47, 0x49, 0x46, 0x38, 0x00};
const quint32 AVERAGE_TILE_SIZE = 13652;
const quint32 AVERAGE_TILE_SIZE = 13652;
class QNetworkRequest;
class QNetworkAccessManager;
class MapProvider : public QObject {
Q_OBJECT
public:
MapProvider(
QString referrer, QString imageFormat, quint32 averageSize,
QGeoMapType::MapStyle _mapType = QGeoMapType::CustomMap, QObject* parent = nullptr);
QNetworkRequest getTileURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager);
public:
MapProvider(const QString& referrer, const QString& imageFormat, const quint32 averageSize,
const QGeoMapType::MapStyle _mapType = QGeoMapType::CustomMap, QObject* parent = nullptr);
QString getImageFormat(const QByteArray& image);
QNetworkRequest getTileURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager);
quint32 getAverageSize(){return _averageSize;}
QString getImageFormat(const QByteArray& image) const;
QGeoMapType::MapStyle getMapStyle(){return _mapType;}
quint32 getAverageSize() const { return _averageSize; }
virtual int long2tileX(double lon, int z);
QGeoMapType::MapStyle getMapStyle() { return _mapType; }
virtual int lat2tileY(double lat, int z);
virtual int long2tileX(const double lon, const int z) const;
virtual bool _isElevationProvider();
virtual int lat2tileY(const double lat, const int z) const;
virtual QGCTileSet getTileCount(int zoom, double topleftLon,
double topleftLat, double bottomRightLon,
double bottomRightLat);
virtual bool _isElevationProvider();
virtual QGCTileSet getTileCount(const int zoom, const double topleftLon,
const double topleftLat, const double bottomRightLon,
const double bottomRightLat) const;
protected:
QString _tileXYToQuadKey(int tileX, int tileY, int levelOfDetail);
int _getServerNum(int x, int y, int max);
QString _tileXYToQuadKey(const int tileX, const int tileY, const int levelOfDetail);
int _getServerNum(const int x, const int y, const int max);
// Define the url to Request
virtual QString _getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) = 0;
// Define Referrer for Request RawHeader
QString _referrer;
......@@ -54,7 +65,4 @@ class MapProvider : public QObject {
QString _language;
QGeoMapType::MapStyle _mapType;
// Define the url to Request
virtual QString _getURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager) = 0;
};
diff --git a/libs/mavlink/include/mavlink/v2.0 b/libs/mavlink/include/mavlink/v2.0
--- a/libs/mavlink/include/mavlink/v2.0
+++ b/libs/mavlink/include/mavlink/v2.0
@@ -1 +1 @@
-Subproject commit 68869da6575d4ca61b92e9081b7c81587f157ed6
+Subproject commit 68869da6575d4ca61b92e9081b7c81587f157ed6-dirty
diff --git a/src/Terrain/TerrainQueryManager.cc b/src/Terrain/TerrainQueryManager.cc
index 59ec2d4..c38a870 100644
--- a/src/Terrain/TerrainQueryManager.cc
+++ b/src/Terrain/TerrainQueryManager.cc
@@ -3,17 +3,20 @@
TerrainQueryManager::TerrainQueryManager(QObject* parent)
: TerrainQueryInterface(parent)
{
- _providerAirMap = new TerrainOfflineAirMapQuery(parent);
+ connect(&_providerAirMap, &TerrainQueryInterface::coordinateHeightsReceived, this, &TerrainQueryInterface::coordinateHeightsReceived);
+ connect(&_providerAirMap, &TerrainQueryInterface::pathHeightsReceived, this, &TerrainQueryInterface::pathHeightsReceived);
+ connect(&_providerAirMap, &TerrainQueryInterface::carpetHeightsReceived, this, &TerrainQueryInterface::carpetHeightsReceived);
}
void TerrainQueryManager::requestCoordinateHeights(const QList<QGeoCoordinate>& coordinates){
- _providerAirMap->requestCoordinateHeights(coordinates);
+ _providerAirMap.requestCoordinateHeights(coordinates);
}
void TerrainQueryManager::requestPathHeights(const QGeoCoordinate& fromCoord, const QGeoCoordinate& toCoord){
- _providerAirMap->requestPathHeights(fromCoord,toCoord);
+ _providerAirMap.requestPathHeights(fromCoord,toCoord);
}
void TerrainQueryManager::requestCarpetHeights(const QGeoCoordinate& swCoord, const QGeoCoordinate& neCoord, bool statsOnly){
- _providerAirMap->requestCarpetHeights(swCoord,neCoord,statsOnly);
+ _providerAirMap.requestCarpetHeights(swCoord,neCoord,statsOnly);
}
+
diff --git a/src/Terrain/TerrainQueryManager.h b/src/Terrain/TerrainQueryManager.h
index 2921679..9b4494c 100644
--- a/src/Terrain/TerrainQueryManager.h
+++ b/src/Terrain/TerrainQueryManager.h
@@ -27,12 +27,12 @@ public:
/// @param neCoord North-East bound of rectangular area to query
/// @param statsOnly true: Return only stats, no carpet data
void requestCarpetHeights(const QGeoCoordinate& swCoord, const QGeoCoordinate& neCoord, bool statsOnly);
-
+
signals:
void coordinateHeightsReceived(bool success, QList<double> heights);
void pathHeightsReceived(bool success, double latStep, double lonStep, const QList<double>& heights);
void carpetHeightsReceived(bool success, double minHeight, double maxHeight, const QList<QList<double>>& carpet);
private:
- TerrainOfflineAirMapQuery * _providerAirMap;
+ TerrainOfflineAirMapQuery _providerAirMap;
};
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