Browse Source

Support map zoom to level 23

QGC4.4
DonLakeFlyer 5 years ago
parent
commit
285afe827d
  1. 1
      qgcresources.qrc
  2. BIN
      resources/BingNoTileBytes.dat
  3. 9
      src/QtLocationPlugin/QGCMapEngine.cpp
  4. 2
      src/QtLocationPlugin/QGCMapUrlEngine.h
  5. 15
      src/QtLocationPlugin/QGeoMapReplyQGC.cpp
  6. 1
      src/QtLocationPlugin/QGeoMapReplyQGC.h

1
qgcresources.qrc

@ -22,6 +22,7 @@ @@ -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>

BIN
resources/BingNoTileBytes.dat

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

9
src/QtLocationPlugin/QGCMapEngine.cpp

@ -222,6 +222,15 @@ QGCMapEngine::cacheTile(QString type, const QString& hash, const QByteArray& ima @@ -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);
}

2
src/QtLocationPlugin/QGCMapUrlEngine.h

@ -24,7 +24,7 @@ @@ -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

15
src/QtLocationPlugin/QGeoMapReplyQGC.cpp

@ -54,6 +54,7 @@ @@ -54,6 +54,7 @@
#include "TerrainTile.h"
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 @@ -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,12 +142,20 @@ QGeoTiledMapReplyQGC::networkReplyFinished() @@ -135,12 +142,20 @@ QGeoTiledMapReplyQGC::networkReplyFinished()
}
emit terrainDone(a, QNetworkReply::NoError);
} else {
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);
}
_clearReply();

1
src/QtLocationPlugin/QGeoMapReplyQGC.h

@ -81,6 +81,7 @@ private: @@ -81,6 +81,7 @@ private:
QByteArray _badMapbox;
QByteArray _badTile;
QTimer _timer;
static QByteArray _bingNoTileImage;
static int _requestCount;
};

Loading…
Cancel
Save