Commit 68164ca8 authored by Cosmin Marc's avatar Cosmin Marc

Map providers cleanup.

parent 964f926c
/****************************************************************************
*
* (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 "BingMapProvider.h"
#if defined(DEBUG_GOOGLE_MAPS)
#include <QFile>
#include <QStandardPaths>
#endif
#include "QGCMapEngine.h"
BingMapProvider::BingMapProvider(QString imageFormat, quint32 averageSize,
QGeoMapType::MapStyle mapType, QObject* parent)
: MapProvider(QString("https://www.bing.com/maps/"), imageFormat,
averageSize, mapType, parent) {}
BingMapProvider::~BingMapProvider() {}
QString BingRoadMapProvider::_getURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager) {
Q_UNUSED(networkManager);
QString key = _tileXYToQuadKey(x, y, zoom);
return QString("http://ecn.t%1.tiles.virtualearth.net/tiles/"
"r%2.png?g=%3&mkt=%4")
.arg(_getServerNum(x, y, 4))
.arg(key)
.arg(_versionBingMaps)
.arg(_language);
BingMapProvider::BingMapProvider(const QString &imageFormat, const quint32 averageSize,
const QGeoMapType::MapStyle mapType, QObject* parent)
: MapProvider(QStringLiteral("https://www.bing.com/maps/"), imageFormat, averageSize, mapType, parent) {}
static const QString RoadMapUrl = QStringLiteral("http://ecn.t%1.tiles.virtualearth.net/tiles/r%2.png?g=%3&mkt=%4");
QString BingRoadMapProvider::_getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) {
Q_UNUSED(networkManager)
const QString key = _tileXYToQuadKey(x, y, zoom);
return RoadMapUrl.arg(QString::number(_getServerNum(x, y, 4)), key, _versionBingMaps, _language);
}
QString
BingSatelliteMapProvider::_getURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager) {
Q_UNUSED(networkManager);
QString key = _tileXYToQuadKey(x, y, zoom);
return QString("http://ecn.t%1.tiles.virtualearth.net/tiles/"
"a%2.jpeg?g=%3&mkt=%4")
.arg(_getServerNum(x, y, 4))
.arg(key)
.arg(_versionBingMaps)
.arg(_language);
static const QString SatteliteMapUrl = QStringLiteral("http://ecn.t%1.tiles.virtualearth.net/tiles/a%2.jpeg?g=%3&mkt=%4");
QString BingSatelliteMapProvider::_getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) {
Q_UNUSED(networkManager)
const QString key = _tileXYToQuadKey(x, y, zoom);
return SatteliteMapUrl.arg(QString::number(_getServerNum(x, y, 4)) ,key ,_versionBingMaps ,_language);
}
QString BingHybridMapProvider::_getURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager) {
Q_UNUSED(networkManager);
QString key = _tileXYToQuadKey(x, y, zoom);
return QString("http://ecn.t%1.tiles.virtualearth.net/tiles/"
"h%2.jpeg?g=%3&mkt=%4")
.arg(_getServerNum(x, y, 4))
.arg(key)
.arg(_versionBingMaps)
.arg(_language);
static const QString HybridMapUrl = QStringLiteral("http://ecn.t%1.tiles.virtualearth.net/tiles/h%2.jpeg?g=%3&mkt=%4");
QString BingHybridMapProvider::_getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) {
Q_UNUSED(networkManager)
const QString key = _tileXYToQuadKey(x, y, zoom);
return HybridMapUrl.arg(QString::number(_getServerNum(x, y, 4)), key, _versionBingMaps, _language);
}
/****************************************************************************
*
* (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.
*
****************************************************************************/
#pragma once
#include "MapProvider.h"
#include <QByteArray>
#include <QMutex>
#include <QNetworkProxy>
#include <QNetworkReply>
#include <QPoint>
#include <QString>
class BingMapProvider : public MapProvider {
Q_OBJECT
public:
BingMapProvider(QString imageFormat, quint32 averageSize,
QGeoMapType::MapStyle mapType, QObject* parent);
~BingMapProvider();
public:
BingMapProvider(const QString &imageFormat, const quint32 averageSize,
const QGeoMapType::MapStyle mapType, QObject* parent = nullptr);
protected:
// Define the url to Request
virtual QString _getURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager) = 0;
~BingMapProvider() = default;
const QString _versionBingMaps = "563";
protected:
const QString _versionBingMaps = QStringLiteral("563");
};
const quint32 AVERAGE_BING_STREET_MAP = 1297;
const quint32 AVERAGE_BING_SAT_MAP = 19597;
static const quint32 AVERAGE_BING_STREET_MAP = 1297;
static const quint32 AVERAGE_BING_SAT_MAP = 19597;
// -----------------------------------------------------------
// Bing Road Map
class BingRoadMapProvider : public BingMapProvider {
Q_OBJECT
public:
BingRoadMapProvider(QObject* parent)
: BingMapProvider(QString("png"), AVERAGE_BING_STREET_MAP, QGeoMapType::StreetMap,
parent) {}
protected:
QString _getURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager);
public:
BingRoadMapProvider(QObject* parent = nullptr)
: BingMapProvider(QStringLiteral("png"), AVERAGE_BING_STREET_MAP, QGeoMapType::StreetMap, parent) {}
QString _getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) override;
};
// -----------------------------------------------------------
......@@ -48,14 +45,12 @@ class BingRoadMapProvider : public BingMapProvider {
class BingSatelliteMapProvider : public BingMapProvider {
Q_OBJECT
public:
BingSatelliteMapProvider(QObject* parent)
: BingMapProvider(QString("jpg"), AVERAGE_BING_SAT_MAP, QGeoMapType::SatelliteMapDay,
parent) {}
protected:
QString _getURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager);
public:
BingSatelliteMapProvider(QObject* parent = nullptr)
: BingMapProvider(QStringLiteral("jpg"), AVERAGE_BING_SAT_MAP, QGeoMapType::SatelliteMapDay, parent) {}
QString _getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) override;
};
// -----------------------------------------------------------
......@@ -63,12 +58,9 @@ class BingSatelliteMapProvider : public BingMapProvider {
class BingHybridMapProvider : public BingMapProvider {
Q_OBJECT
public:
BingHybridMapProvider(QObject* parent)
: BingMapProvider(QString("jpg"),AVERAGE_BING_SAT_MAP, QGeoMapType::HybridMap,
parent) {}
protected:
QString _getURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager);
public:
BingHybridMapProvider(QObject* parent = nullptr)
: BingMapProvider(QStringLiteral("jpg"),AVERAGE_BING_SAT_MAP, QGeoMapType::HybridMap, parent) {}
QString _getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) override;
};
......@@ -5,42 +5,34 @@
#endif
#include "QGCMapEngine.h"
ElevationProvider::ElevationProvider(QString imageFormat, quint32 averageSize,
QGeoMapType::MapStyle mapType,
QObject* parent)
: MapProvider(QString("https://api.airmap.com/"), imageFormat, averageSize,
mapType, parent) {}
ElevationProvider::~ElevationProvider() {}
ElevationProvider::ElevationProvider(const QString& imageFormat, quint32 averageSize, QGeoMapType::MapStyle mapType, QObject* parent)
: MapProvider(QStringLiteral("https://api.airmap.com/"), imageFormat, averageSize, mapType, parent) {}
//-----------------------------------------------------------------------------
int AirmapElevationProvider::long2tileX(double lon, int z) {
Q_UNUSED(z);
int AirmapElevationProvider::long2tileX(const double lon, const int z) const {
Q_UNUSED(z)
return static_cast<int>(floor((lon + 180.0) / srtm1TileSize));
}
//-----------------------------------------------------------------------------
int AirmapElevationProvider::lat2tileY(double lat, int z) {
Q_UNUSED(z);
int AirmapElevationProvider::lat2tileY(const double lat, const int z) const {
Q_UNUSED(z)
return static_cast<int>(floor((lat + 90.0) / srtm1TileSize));
}
QString
AirmapElevationProvider::_getURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager) {
Q_UNUSED(networkManager);
Q_UNUSED(zoom);
return QString("https://api.airmap.com/elevation/v1/ele/"
"carpet?points=%1,%2,%3,%4")
QString AirmapElevationProvider::_getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) {
Q_UNUSED(networkManager)
Q_UNUSED(zoom)
return QString("https://api.airmap.com/elevation/v1/ele/carpet?points=%1,%2,%3,%4")
.arg(static_cast<double>(y) * srtm1TileSize - 90.0)
.arg(static_cast<double>(x) * srtm1TileSize - 180.0)
.arg(static_cast<double>(y + 1) * srtm1TileSize - 90.0)
.arg(static_cast<double>(x + 1) * srtm1TileSize - 180.0);
}
QGCTileSet AirmapElevationProvider::getTileCount(int zoom, double topleftLon,
double topleftLat,
double bottomRightLon,
double bottomRightLat) {
QGCTileSet AirmapElevationProvider::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(bottomRightLat, zoom);
......
......@@ -10,24 +10,17 @@
#include <QPoint>
#include <QString>
const quint32 AVERAGE_AIRMAP_ELEV_SIZE = 2786;
static const quint32 AVERAGE_AIRMAP_ELEV_SIZE = 2786;
//-----------------------------------------------------------------------------
const double srtm1TileSize = 0.01;
static const double srtm1TileSize = 0.01;
class ElevationProvider : public MapProvider {
Q_OBJECT
public:
ElevationProvider(QString imageFormat, quint32 averageSize,
QGeoMapType::MapStyle mapType, QObject* parent);
ElevationProvider(const QString& imageFormat, quint32 averageSize,
QGeoMapType::MapStyle mapType, QObject* parent = nullptr);
~ElevationProvider();
bool _isElevationProvider(){return true;}
protected:
// Define the url to Request
virtual QString _getURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager) = 0;
virtual bool _isElevationProvider() const override { return true; }
};
// -----------------------------------------------------------
......@@ -36,19 +29,19 @@ class ElevationProvider : public MapProvider {
class AirmapElevationProvider : public ElevationProvider {
Q_OBJECT
public:
AirmapElevationProvider(QObject* parent)
: ElevationProvider(QString("bin"), AVERAGE_AIRMAP_ELEV_SIZE,
AirmapElevationProvider(QObject* parent = nullptr)
: ElevationProvider(QStringLiteral("bin"), AVERAGE_AIRMAP_ELEV_SIZE,
QGeoMapType::StreetMap, parent) {}
int long2tileX(double lon, int z);
int lat2tileY(double lat, int z);
QGCTileSet getTileCount(int zoom, double topleftLon,
double topleftLat, double bottomRightLon,
double bottomRightLat);
int long2tileX(const double lon, const int z) const override;
int lat2tileY(const double lat, const int z) const override;
QGCTileSet getTileCount(const int zoom, const double topleftLon,
const double topleftLat, const double bottomRightLon,
const double bottomRightLat) const override;
protected:
QString _getURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager);
QString _getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) override;
};
/****************************************************************************
*
* (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 "EsriMapProvider.h"
#include "QGCApplication.h"
#include "QGCMapEngine.h"
#include "SettingsManager.h"
QNetworkRequest
EsriMapProvider::getTileURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager) {
EsriMapProvider::EsriMapProvider(const quint32 averageSize, const QGeoMapType::MapStyle mapType, QObject *parent)
: MapProvider(QString(), QString(), averageSize, mapType, parent) {}
QNetworkRequest EsriMapProvider::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;
}
request.setUrl(QUrl(url));
request.setRawHeader("Accept", "*/*");
QByteArray token = qgcApp()
->toolbox()
->settingsManager()
->appSettings()
->esriToken()
->rawValue()
.toString()
.toLatin1();
request.setRawHeader("User-Agent",
QByteArrayLiteral("Qt Location based application"));
request.setRawHeader("User-Token", token);
request.setRawHeader(QByteArrayLiteral("Accept"), QByteArrayLiteral("*/*"));
const QByteArray token = qgcApp()->toolbox()->settingsManager()->appSettings()->esriToken()->rawValue().toString().toLatin1();
request.setRawHeader(QByteArrayLiteral("User-Agent"), QByteArrayLiteral("Qt Location based application"));
request.setRawHeader(QByteArrayLiteral("User-Token"), token);
return request;
}
QString
EsriWorldStreetMapProvider::_getURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager) {
Q_UNUSED(networkManager);
return QString("http://services.arcgisonline.com/ArcGIS/rest/services/"
"World_Street_Map/MapServer/tile/%1/%2/%3")
.arg(zoom)
.arg(y)
.arg(x);
static const QString WorldStreetMapUrl = QStringLiteral("http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/%1/%2/%3");
QString EsriWorldStreetMapProvider::_getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) {
Q_UNUSED(networkManager)
return WorldStreetMapUrl.arg(zoom).arg(y).arg(x);
}
QString
EsriWorldSatelliteMapProvider::_getURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager) {
Q_UNUSED(networkManager);
return QString("http://server.arcgisonline.com/ArcGIS/rest/"
"services/World_Imagery/MapServer/tile/%1/%2/%3")
.arg(zoom)
.arg(y)
.arg(x);
static const QString WorldSatelliteMapUrl = QStringLiteral("http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/%1/%2/%3");
QString EsriWorldSatelliteMapProvider::_getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) {
Q_UNUSED(networkManager)
return WorldSatelliteMapUrl.arg(zoom).arg(y).arg(x);
}
QString EsriTerrainMapProvider::_getURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager) {
Q_UNUSED(networkManager);
return QString("http://server.arcgisonline.com/ArcGIS/rest/services/"
"World_Terrain_Base/MapServer/tile/%1/%2/%3")
.arg(zoom)
.arg(y)
.arg(x);
static const QString TerrainMapUrl = QStringLiteral("http://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer/tile/%1/%2/%3");
QString EsriTerrainMapProvider::_getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) {
Q_UNUSED(networkManager)
return TerrainMapUrl.arg(zoom).arg(y).arg(x);
}
/****************************************************************************
*
* (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.
*
****************************************************************************/
#pragma once
#include "MapProvider.h"
#include <QByteArray>
#include <QMutex>
#include <QNetworkProxy>
#include <QNetworkReply>
#include <QPoint>
#include <QString>
class EsriMapProvider : public MapProvider {
Q_OBJECT
public:
using MapProvider::MapProvider;
EsriMapProvider(const quint32 averageSize, const QGeoMapType::MapStyle mapType, QObject* parent = nullptr);
QNetworkRequest getTileURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager);
QNetworkRequest getTileURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) override;
};
class EsriWorldStreetMapProvider : public EsriMapProvider {
Q_OBJECT
public:
EsriWorldStreetMapProvider(QObject* parent)
: EsriMapProvider(QString(""), QString(""), AVERAGE_TILE_SIZE,
QGeoMapType::StreetMap, parent) {}
QString _getURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager);
EsriWorldStreetMapProvider(QObject* parent = nullptr)
: EsriMapProvider(AVERAGE_TILE_SIZE, QGeoMapType::StreetMap, parent) {}
QString _getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) override;
};
class EsriWorldSatelliteMapProvider : public EsriMapProvider {
Q_OBJECT
public:
EsriWorldSatelliteMapProvider(QObject* parent)
: EsriMapProvider(QString(""), QString(""), AVERAGE_TILE_SIZE,
QGeoMapType::SatelliteMapDay, parent) {}
QString _getURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager);
EsriWorldSatelliteMapProvider(QObject* parent = nullptr)
: EsriMapProvider(AVERAGE_TILE_SIZE, QGeoMapType::SatelliteMapDay, parent) {}
QString _getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) override;
};
class EsriTerrainMapProvider : public EsriMapProvider {
Q_OBJECT
public:
EsriTerrainMapProvider(QObject* parent)
: EsriMapProvider(QString(""), QString(""), AVERAGE_TILE_SIZE,
QGeoMapType::TerrainMap, parent) {}
QString _getURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager);
EsriTerrainMapProvider(QObject* parent = nullptr)
: EsriMapProvider(AVERAGE_TILE_SIZE, QGeoMapType::TerrainMap, parent) {}
QString _getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) override;
};
/****************************************************************************
*
* (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 "GenericMapProvider.h"
#include "QGCMapEngine.h"
QString StatkartMapProvider::_getURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager) {
Q_UNUSED(networkManager);
return QString("http://opencache.statkart.no/gatekeeper/gk/"
"gk.open_gmaps?layers=topo4&zoom=%1&x=%2&y=%3")
.arg(zoom)
.arg(x)
.arg(y);
static const QString StatkartMapUrl = QStringLiteral("http://opencache.statkart.no/gatekeeper/gk/gk.open_gmaps?layers=topo4&zoom=%1&x=%2&y=%3");
QString StatkartMapProvider::_getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) {
Q_UNUSED(networkManager)
return StatkartMapUrl.arg(zoom).arg(x).arg(y);
}
QString EniroMapProvider::_getURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager) {
Q_UNUSED(networkManager);
return QString("http://map.eniro.com/geowebcache/service/tms1.0.0/map/%1/"
"%2/%3.png")
.arg(zoom)
.arg(x)
.arg((1 << zoom) - 1 - y);
static const QString EniroMapUrl = QStringLiteral("http://map.eniro.com/geowebcache/service/tms1.0.0/map/%1/%2/%3.png");
QString EniroMapProvider::_getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) {
Q_UNUSED(networkManager)
return EniroMapUrl.arg(zoom).arg(x).arg((1 << zoom) - 1 - y);
}
QString MapQuestMapMapProvider::_getURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager) {
Q_UNUSED(networkManager);
char letter = "1234"[_getServerNum(x, y, 4)];
return QString("http://otile%1.mqcdn.com/tiles/1.0.0/map/%2/%3/%4.jpg")
.arg(letter)
.arg(zoom)
.arg(x)
.arg(y);
static const QString MapQuestMapUrl = QStringLiteral("http://otile%1.mqcdn.com/tiles/1.0.0/map/%2/%3/%4.jpg");
QString MapQuestMapMapProvider::_getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) {
Q_UNUSED(networkManager)
return MapQuestMapUrl.arg(_getServerNum(x, y, 4)).arg(zoom).arg(x).arg(y);
}
QString MapQuestSatMapProvider::_getURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager) {
Q_UNUSED(networkManager);
char letter = "1234"[_getServerNum(x, y, 4)];
return QString("http://otile%1.mqcdn.com/tiles/1.0.0/sat/%2/%3/%4.jpg")
.arg(letter)
.arg(zoom)
.arg(x)
.arg(y);
static const QString MapQuestSatUrl = QStringLiteral("http://otile%1.mqcdn.com/tiles/1.0.0/sat/%2/%3/%4.jpg");
QString MapQuestSatMapProvider::_getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) {
Q_UNUSED(networkManager)
return MapQuestSatUrl.arg(_getServerNum(x, y, 4)).arg(zoom).arg(x).arg(y);
}
QString
VWorldStreetMapProvider::_getURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager) {
Q_UNUSED(networkManager);
int gap = zoom - 6;
int x_min = 53 * pow(2, gap);
int x_max = 55 * pow(2, gap) + (2 * gap - 1);
int y_min = 22 * pow(2, gap);
int y_max = 26 * pow(2, gap) + (2 * gap - 1);
QString VWorldStreetMapProvider::_getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) {
Q_UNUSED(networkManager)
const int gap = zoom - 6;
const int x_min = int(53 * pow(2, gap));
const int x_max = int(55 * pow(2, gap) + (2 * gap - 1));
const int y_min = int(22 * pow(2, gap));
const int y_max = int(26 * pow(2, gap) + (2 * gap - 1));
if (zoom > 19) {
return {};
} else if (zoom > 5 && x >= x_min && x <= x_max && y >= y_min &&
y <= y_max) {
return QString(
"http://xdworld.vworld.kr:8080/2d/Base/service/%1/%2/%3.png")
.arg(zoom)
.arg(x)
.arg(y);
return QString();
} else if (zoom > 5 && x >= x_min && x <= x_max && y >= y_min && y <= y_max) {
return QString(QStringLiteral("http://xdworld.vworld.kr:8080/2d/Base/service/%1/%2/%3.png")).arg(zoom, x, y);
} else {
QString key = _tileXYToQuadKey(x, y, zoom);
return QString("http://ecn.t%1.tiles.virtualearth.net/tiles/"
"r%2.png?g=%3&mkt=%4")
.arg(_getServerNum(x, y, 4))
.arg(key)
.arg(_versionBingMaps)
.arg(_language);
const QString key = _tileXYToQuadKey(x, y, zoom);
return QString(QStringLiteral("http://ecn.t%1.tiles.virtualearth.net/tiles/r%2.png?g=%3&mkt=%4"))
.arg(_getServerNum(x, y, 4)).arg(key, _versionBingMaps, _language);
}
}
QString VWorldSatMapProvider::_getURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager) {
Q_UNUSED(networkManager);
int gap = zoom - 6;
int x_min = 53 * pow(2, gap);
int x_max = 55 * pow(2, gap) + (2 * gap - 1);
int y_min = 22 * pow(2, gap);
int y_max = 26 * pow(2, gap) + (2 * gap - 1);
QString VWorldSatMapProvider::_getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) {
Q_UNUSED(networkManager)
const int gap = zoom - 6;
const int x_min = int(53 * pow(2, gap));
const int x_max = int(55 * pow(2, gap) + (2 * gap - 1));
const int y_min = int(22 * pow(2, gap));
const int y_max = int(26 * pow(2, gap) + (2 * gap - 1));
if (zoom > 19) {
return {};
} else if (zoom > 5 && x >= x_min && x <= x_max && y >= y_min &&
y <= y_max) {
return QString("http://xdworld.vworld.kr:8080/2d/Satellite/service/%1/"
"%2/%3.jpeg")
.arg(zoom)
.arg(x)
.arg(y);
return QString();
} else if (zoom > 5 && x >= x_min && x <= x_max && y >= y_min && y <= y_max) {
return QString("http://xdworld.vworld.kr:8080/2d/Satellite/service/%1/%2/%3.jpeg").arg(zoom, x, y);
} else {
QString key = _tileXYToQuadKey(x, y, zoom);
return QString("http://ecn.t%1.tiles.virtualearth.net/tiles/"
"a%2.jpeg?g=%3&mkt=%4")
.arg(_getServerNum(x, y, 4))
.arg(key)
.arg(_versionBingMaps)
.arg(_language);
const QString key = _tileXYToQuadKey(x, y, zoom);
return QString("http://ecn.t%1.tiles.virtualearth.net/tiles/a%2.jpeg?g=%3&mkt=%4")
.arg(_getServerNum(x, y, 4)).arg(key, _versionBingMaps, _language);
}
}
/****************************************************************************
*
* (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.
*
****************************************************************************/
#pragma once
#include "MapProvider.h"
#include <cmath>
#include <QByteArray>
#include <QMutex>
#include <QNetworkProxy>
#include <QNetworkReply>
#include <QPoint>
#include <QString>
class StatkartMapProvider : public MapProvider {
Q_OBJECT
public:
StatkartMapProvider(QObject* parent)
: MapProvider(QString("https://www.norgeskart.no/"), QString("png"),
StatkartMapProvider(QObject* parent = nullptr)
: MapProvider(QStringLiteral("https://www.norgeskart.no/"), QStringLiteral("png"),
AVERAGE_TILE_SIZE, QGeoMapType::StreetMap, parent) {}
QString _getURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager);
QString _getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) override;
};
class EniroMapProvider : public MapProvider {
Q_OBJECT
public:
EniroMapProvider(QObject* parent)
: MapProvider(QString("https://www.eniro.se/"), QString("png"),
EniroMapProvider(QObject* parent = nullptr)
: MapProvider(QStringLiteral("https://www.eniro.se/"), QStringLiteral("png"),
AVERAGE_TILE_SIZE, QGeoMapType::StreetMap, parent) {}
QString _getURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager);
QString _getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) override;
};
class MapQuestMapMapProvider : public MapProvider {
Q_OBJECT
public:
MapQuestMapMapProvider(QObject* parent)