Commit 285afe82 authored by DonLakeFlyer's avatar DonLakeFlyer

parent 665ef88d
......@@ -22,6 +22,7 @@
<file alias="gear-black.svg">resources/gear-black.svg</file>
<file alias="gear-white.svg">resources/gear-white.svg</file>
<file alias="helicoptericon.svg">resources/helicoptericon.svg</file>
<file alias="BingNoTileBytes.dat">resources/BingNoTileBytes.dat</file>
<file alias="JoystickBezel.png">resources/JoystickBezel.png</file>
<file alias="JoystickBezelLight.png">resources/JoystickBezelLight.png</file>
<file alias="land.svg">resources/land.svg</file>
......
......@@ -222,6 +222,15 @@ QGCMapEngine::cacheTile(QString type, const QString& hash, const QByteArray& ima
QString
QGCMapEngine::getTileHash(QString type, int x, int y, int z)
{
#if 0
int maxCachedZoom = 15;
if (z > maxCachedZoom) {
double unZoomFactor = qPow(2, z - maxCachedZoom);
x = (double)x / unZoomFactor;
y = (double)y / unZoomFactor;
z = maxCachedZoom;
}
#endif
return QString::asprintf("%010d%08d%08d%03d", getQGCMapEngine()->urlFactory()->getIdFromType(type), x, y, z);
}
......
......@@ -24,7 +24,7 @@
#include "MapboxMapProvider.h"
#include "ElevationMapProvider.h"
#define MAX_MAP_ZOOM (20.0)
#define MAX_MAP_ZOOM (23.0)
class UrlFactory : public QObject {
Q_OBJECT
......
......@@ -53,7 +53,8 @@
#include <QFile>
#include "TerrainTile.h"
int QGeoTiledMapReplyQGC::_requestCount = 0;
int QGeoTiledMapReplyQGC::_requestCount = 0;
QByteArray QGeoTiledMapReplyQGC::_bingNoTileImage;
//-----------------------------------------------------------------------------
QGeoTiledMapReplyQGC::QGeoTiledMapReplyQGC(QNetworkAccessManager *networkManager, const QNetworkRequest &request, const QGeoTileSpec &spec, QObject *parent)
......@@ -62,6 +63,12 @@ QGeoTiledMapReplyQGC::QGeoTiledMapReplyQGC(QNetworkAccessManager *networkManager
, _request(request)
, _networkManager(networkManager)
{
if (_bingNoTileImage.count() == 0) {
QFile file(":/res/BingNoTileBytes.dat");
file.open(QFile::ReadOnly);
_bingNoTileImage = file.readAll();
file.close();
}
if(_request.url().isEmpty()) {
if(!_badMapbox.size()) {
QFile b(":/res/notile.png");
......@@ -135,11 +142,19 @@ QGeoTiledMapReplyQGC::networkReplyFinished()
}
emit terrainDone(a, QNetworkReply::NoError);
} else {
//-- This is a map tile. Process and cache it if valid.
setMapImageData(a);
if(!format.isEmpty()) {
setMapImageFormat(format);
getQGCMapEngine()->cacheTile(getQGCMapEngine()->urlFactory()->getTypeFromId(tileSpec().mapId()), tileSpec().x(), tileSpec().y(), tileSpec().zoom(), a, format);
if (a == _bingNoTileImage) {
// Bing doesn't return an error if you request a tile above supported zoom level
// It instead returns an image of a missing tile graphic. We need to detect that
// and error out so Qt will deal with zooming correctly even if it doesn't have the tile.
// This allows us to zoom up to level 23 even though the tiles don't actually exist
setError(QGeoTiledMapReply::CommunicationError, "Bing tile above zoom level");
} else {
//-- This is a map tile. Process and cache it if valid.
setMapImageData(a);
if(!format.isEmpty()) {
setMapImageFormat(format);
getQGCMapEngine()->cacheTile(getQGCMapEngine()->urlFactory()->getTypeFromId(tileSpec().mapId()), tileSpec().x(), tileSpec().y(), tileSpec().zoom(), a, format);
}
}
setFinished(true);
}
......
......@@ -81,6 +81,7 @@ private:
QByteArray _badMapbox;
QByteArray _badTile;
QTimer _timer;
static QByteArray _bingNoTileImage;
static int _requestCount;
};
......
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