Commit 5ba79984 authored by Pierre TILAK's avatar Pierre TILAK

Airmap Elevation working again

parent 46d61652
......@@ -10,17 +10,16 @@ ElevationProvider::ElevationProvider(QString imageFormat, quint32 averageSize,
QObject* parent)
: MapProvider(QString("https://api.airmap.com/"), imageFormat, averageSize,
mapType, parent) {}
ElevationProvider::~ElevationProvider() {}
//-----------------------------------------------------------------------------
int ElevationProvider::long2tileX(double lon, int z) {
int AirmapElevationProvider::long2tileX(double lon, int z) {
Q_UNUSED(z);
return static_cast<int>(floor((lon + 180.0) / srtm1TileSize));
}
//-----------------------------------------------------------------------------
int ElevationProvider::lat2tileY(double lat, int z) {
int AirmapElevationProvider::lat2tileY(double lat, int z) {
Q_UNUSED(z);
return static_cast<int>(floor((lat + 90.0) / srtm1TileSize));
}
......
......@@ -21,8 +21,6 @@ class ElevationProvider : public MapProvider {
~ElevationProvider();
int long2tileX(double lon, int z);
int lat2tileY(double lat, int z);
protected:
// Define the url to Request
......@@ -40,6 +38,10 @@ class AirmapElevationProvider : public ElevationProvider {
: ElevationProvider(QString("bin"), AVERAGE_AIRMAP_ELEV_SIZE,
QGeoMapType::StreetMap, parent) {}
int long2tileX(double lon, int z);
int lat2tileY(double lat, int z);
protected:
QString _getURL(int x, int y, int zoom,
QNetworkAccessManager* networkManager);
......
......@@ -29,9 +29,9 @@ class MapProvider : public QObject {
QGeoMapType::MapStyle getMapStyle(){return _mapType;}
int long2tileX(double lon, int z);
virtual int long2tileX(double lon, int z);
int lat2tileY(double lat, int z);
virtual int lat2tileY(double lat, int z);
protected:
QString _tileXYToQuadKey(int tileX, int tileY, int levelOfDetail);
......
......@@ -236,28 +236,37 @@ QGCMapEngine::hashToType(const QString& hash)
}
//-----------------------------------------------------------------------------
QGCFetchTileTask*
QGCFetchTileTask*
QGCMapEngine::createFetchTileTask(QString type, int x, int y, int z)
{
QString hash = getTileHash(type, x, y, z);
QGCFetchTileTask* task = new QGCFetchTileTask(hash);
return task;
QString hash = getTileHash(type, x, y, z);
QGCFetchTileTask* task = new QGCFetchTileTask(hash);
return task;
}
//-----------------------------------------------------------------------------
QGCTileSet
QGCTileSet
QGCMapEngine::getTileCount(int zoom, double topleftLon, double topleftLat, double bottomRightLon, double bottomRightLat, QString mapType)
{
if(zoom < 1) zoom = 1;
if(zoom > MAX_MAP_ZOOM) zoom = MAX_MAP_ZOOM;
QGCTileSet set;
set.tileX0 = getQGCMapEngine()->urlFactory()->long2tileX(mapType, topleftLon, zoom);
set.tileY0 = getQGCMapEngine()->urlFactory()->lat2tileY(mapType, topleftLat, zoom);
set.tileX1 = getQGCMapEngine()->urlFactory()->long2tileX(mapType, bottomRightLon, zoom);
set.tileY1 = getQGCMapEngine()->urlFactory()->lat2tileY(mapType, bottomRightLat, zoom);
set.tileCount = (static_cast<quint64>(set.tileX1) - static_cast<quint64>(set.tileX0) + 1) * (static_cast<quint64>(set.tileY1) - static_cast<quint64>(set.tileY0) + 1);
set.tileSize = getQGCMapEngine()->urlFactory()->averageSizeForType(mapType) * set.tileCount;
return set;
if(zoom < 1) zoom = 1;
if(zoom > MAX_MAP_ZOOM) zoom = MAX_MAP_ZOOM;
QGCTileSet set;
if(mapType != "Airmap Elevation"){
set.tileX0 = getQGCMapEngine()->urlFactory()->long2tileX(mapType, topleftLon, zoom);
set.tileY0 = getQGCMapEngine()->urlFactory()->lat2tileY(mapType, topleftLat, zoom);
set.tileX1 = getQGCMapEngine()->urlFactory()->long2tileX(mapType, bottomRightLon, zoom);
set.tileY1 = getQGCMapEngine()->urlFactory()->lat2tileY(mapType, bottomRightLat, zoom);
}else{
set.tileX0 = getQGCMapEngine()->urlFactory()->long2tileX(mapType, topleftLon, zoom);
set.tileY0 = getQGCMapEngine()->urlFactory()->lat2tileY(mapType, bottomRightLat, zoom);
set.tileX1 = getQGCMapEngine()->urlFactory()->long2tileX(mapType, bottomRightLon, zoom);
set.tileY1 = getQGCMapEngine()->urlFactory()->lat2tileY(mapType, topleftLat, zoom);
}
set.tileCount = (static_cast<quint64>(set.tileX1) - static_cast<quint64>(set.tileX0) + 1) * (static_cast<quint64>(set.tileY1) - static_cast<quint64>(set.tileY0) + 1);
qDebug() << "getTileCount : " << set.tileCount;
set.tileSize = getQGCMapEngine()->urlFactory()->averageSizeForType(mapType) * set.tileCount;
return set;
}
......
......@@ -72,6 +72,8 @@ UrlFactory::UrlFactory() : _timeout(5 * 1000) {
_providersTable["VWorld Street Map"] = new VWorldStreetMapProvider(this);
_providersTable["VWorld Satellite Map"] = new VWorldSatMapProvider(this);
_providersTable["Airmap Elevation"] = new AirmapElevationProvider(this);
}
void UrlFactory::registerProvider(QString name, MapProvider* provider) {
......@@ -121,16 +123,6 @@ QNetworkRequest UrlFactory::getTileURL(QString type, int x, int y, int zoom,
qCDebug(QGCMapUrlEngineLog) << "getTileURL : map not registered :" << type;
return QNetworkRequest(QUrl());
}
#if 0
case AirmapElevation:
{
}
break;
//-----------------------------------------------------------------------------
#endif
//-----------------------------------------------------------------------------
quint32 UrlFactory::averageSizeForType(QString type) {
......
......@@ -22,6 +22,7 @@
#include "GenericMapProvider.h"
#include "EsriMapProvider.h"
#include "MapboxMapProvider.h"
#include "ElevationMapProvider.h"
#define MAX_MAP_ZOOM (20.0)
......
......@@ -463,7 +463,7 @@ Item {
Row {
spacing: ScreenTools.defaultFontPixelWidth
anchors.horizontalCenter: parent.horizontalCenter
visible: !_defaultSet && mapType !== "Airmap Elevation Data"
visible: !_defaultSet && mapType !== "Airmap Elevation"
QGCLabel { text: qsTr("Zoom Levels:"); width: infoView._labelWidth; }
QGCLabel { text: offlineMapView._currentSelection ? (offlineMapView._currentSelection.minZoom + " - " + offlineMapView._currentSelection.maxZoom) : ""; horizontalAlignment: Text.AlignRight; width: infoView._valueWidth; }
}
......
......@@ -233,7 +233,6 @@ QGCMapEngineManager::mapTypeList(QString provider)
{
// Extract type name from MapName ( format : "Provider Type")
QStringList mapList = getQGCMapEngine()->getMapNameList();
qDebug()<< "mapTypeList : " << provider;
mapList = mapList.filter(QRegularExpression(provider));
mapList.replaceInStrings(QRegExp("^([^\\ ]*) (.*)$"),"\\2");
mapList.removeDuplicates();
......
......@@ -426,13 +426,13 @@ bool TerrainTileManager::_getAltitudesForCoordinates(const QList<QGeoCoordinate>
}
} else {
if (_state != State::Downloading) {
QNetworkRequest request = getQGCMapEngine()->urlFactory()->getTileURL("AirmapElevation", getQGCMapEngine()->urlFactory()->long2tileX("Airmap Elevation",coordinate.longitude(), 1), getQGCMapEngine()->urlFactory()->lat2tileY("Airmap Elevation", coordinate.latitude(), 1), 1, &_networkManager);
QNetworkRequest request = getQGCMapEngine()->urlFactory()->getTileURL("Airmap Elevation", getQGCMapEngine()->urlFactory()->long2tileX("Airmap Elevation",coordinate.longitude(), 1), getQGCMapEngine()->urlFactory()->lat2tileY("Airmap Elevation", coordinate.latitude(), 1), 1, &_networkManager);
qCDebug(TerrainQueryLog) << "TerrainTileManager::_getAltitudesForCoordinates query from database" << request.url();
QGeoTileSpec spec;
spec.setX(getQGCMapEngine()->urlFactory()->long2tileX("Airmap Elevation", coordinate.longitude(), 1));
spec.setY(getQGCMapEngine()->urlFactory()->lat2tileY("Airmap Elevation", coordinate.latitude(), 1));
spec.setZoom(1);
spec.setMapId(getQGCMapEngine()->urlFactory()->getIdFromType("AirmapElevation"));
spec.setMapId(getQGCMapEngine()->urlFactory()->getIdFromType("Airmap Elevation"));
QGeoTiledMapReplyQGC* reply = new QGeoTiledMapReplyQGC(&_networkManager, request, spec);
connect(reply, &QGeoTiledMapReplyQGC::terrainDone, this, &TerrainTileManager::_terrainDone);
_state = State::Downloading;
......@@ -473,7 +473,7 @@ void TerrainTileManager::_terrainDone(QByteArray responseBytes, QNetworkReply::N
// remove from download queue
QGeoTileSpec spec = reply->tileSpec();
QString hash = QGCMapEngine::getTileHash("AirmapElevation", spec.x(), spec.y(), spec.zoom());
QString hash = QGCMapEngine::getTileHash("Airmap Elevation", spec.x(), spec.y(), spec.zoom());
// handle potential errors
if (error != QNetworkReply::NoError) {
......@@ -539,7 +539,11 @@ void TerrainTileManager::_terrainDone(QByteArray responseBytes, QNetworkReply::N
QString TerrainTileManager::_getTileHash(const QGeoCoordinate& coordinate)
{
QString ret = QGCMapEngine::getTileHash("AirmapElevation", getQGCMapEngine()->urlFactory()->long2tileX("Airmap Elevation", coordinate.longitude(), 1), getQGCMapEngine()->urlFactory()->lat2tileY("Airmap Elevation", coordinate.latitude(), 1), 1);
QString ret = QGCMapEngine::getTileHash(
"Airmap Elevation",
getQGCMapEngine()->urlFactory()->long2tileX("Airmap Elevation", coordinate.longitude(), 1),
getQGCMapEngine()->urlFactory()->lat2tileY("Airmap Elevation", coordinate.latitude(), 1),
1);
qCDebug(TerrainQueryVerboseLog) << "Computing unique tile hash for " << coordinate << ret;
return ret;
......
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