Unverified Commit cb62d3ae authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #8902 from DonLakeFlyer/ZoomTo23

Support map zoom to level 23
parents 5db0b39b b7dfacba
...@@ -4,6 +4,7 @@ Note: This file only contains high level features or important fixes. ...@@ -4,6 +4,7 @@ Note: This file only contains high level features or important fixes.
## 4.1 - Daily build ## 4.1 - Daily build
* Maps: Support zoom up to level 23 even if map provider doesn't provide tiles that high
* Settings/Mavlink: Add ability to forward mavlink traffic out specified UDP port * Settings/Mavlink: Add ability to forward mavlink traffic out specified UDP port
* Support mavlink terrain protocol which queries gcs for terrain height information. Allows planning missions with TERRAIN\_FRAME. * Support mavlink terrain protocol which queries gcs for terrain height information. Allows planning missions with TERRAIN\_FRAME.
* Fly: New instrument values display/editing support * Fly: New instrument values display/editing support
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
<file alias="gear-black.svg">resources/gear-black.svg</file> <file alias="gear-black.svg">resources/gear-black.svg</file>
<file alias="gear-white.svg">resources/gear-white.svg</file> <file alias="gear-white.svg">resources/gear-white.svg</file>
<file alias="helicoptericon.svg">resources/helicoptericon.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="JoystickBezel.png">resources/JoystickBezel.png</file>
<file alias="JoystickBezelLight.png">resources/JoystickBezelLight.png</file> <file alias="JoystickBezelLight.png">resources/JoystickBezelLight.png</file>
<file alias="land.svg">resources/land.svg</file> <file alias="land.svg">resources/land.svg</file>
......
...@@ -20,6 +20,9 @@ public: ...@@ -20,6 +20,9 @@ public:
~BingMapProvider() = default; ~BingMapProvider() = default;
bool _isBingProvider() const override { return true; }
protected: protected:
const QString _versionBingMaps = QStringLiteral("563"); const QString _versionBingMaps = QStringLiteral("563");
}; };
......
...@@ -89,10 +89,6 @@ int MapProvider::lat2tileY(const double lat, const int z) const { ...@@ -89,10 +89,6 @@ int MapProvider::lat2tileY(const double lat, const int z) const {
2.0 * pow(2.0, z))); 2.0 * pow(2.0, z)));
} }
bool MapProvider::_isElevationProvider() const {
return false;
}
QGCTileSet MapProvider::getTileCount(const int zoom, const double topleftLon, QGCTileSet MapProvider::getTileCount(const int zoom, const double topleftLon,
const double topleftLat, const double bottomRightLon, const double topleftLat, const double bottomRightLon,
const double bottomRightLat) const { const double bottomRightLat) const {
......
...@@ -45,7 +45,8 @@ public: ...@@ -45,7 +45,8 @@ public:
virtual int lat2tileY(const double lat, const int z) const; virtual int lat2tileY(const double lat, const int z) const;
virtual bool _isElevationProvider() const; virtual bool _isElevationProvider() const { return false; }
virtual bool _isBingProvider() const { return false; }
virtual QGCTileSet getTileCount(const int zoom, const double topleftLon, virtual QGCTileSet getTileCount(const int zoom, const double topleftLon,
const double topleftLat, const double bottomRightLon, const double topleftLat, const double bottomRightLon,
......
...@@ -155,6 +155,17 @@ QString UrlFactory::getTypeFromId(int id) { ...@@ -155,6 +155,17 @@ QString UrlFactory::getTypeFromId(int id) {
return ""; return "";
} }
MapProvider* UrlFactory::getMapProviderFromId(int id)
{
QString type = getTypeFromId(id);
if (!type.isEmpty()) {
if (_providersTable.find(type) != _providersTable.end()) {
return _providersTable[type];
}
}
return nullptr;
}
// Todo : qHash produce a uint bigger than max(int) // Todo : qHash produce a uint bigger than max(int)
// There is still a low probability for this to // There is still a low probability for this to
// generate similar hash for different types // generate similar hash for different types
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include "MapboxMapProvider.h" #include "MapboxMapProvider.h"
#include "ElevationMapProvider.h" #include "ElevationMapProvider.h"
#define MAX_MAP_ZOOM (20.0) #define MAX_MAP_ZOOM (23.0)
class UrlFactory : public QObject { class UrlFactory : public QObject {
Q_OBJECT Q_OBJECT
...@@ -48,6 +48,7 @@ public: ...@@ -48,6 +48,7 @@ public:
int getIdFromType(QString type); int getIdFromType(QString type);
QString getTypeFromId(int id); QString getTypeFromId(int id);
MapProvider* getMapProviderFromId(int id);
QGCTileSet getTileCount(int zoom, double topleftLon, double topleftLat, QGCTileSet getTileCount(int zoom, double topleftLon, double topleftLat,
double bottomRightLon, double bottomRightLat, double bottomRightLon, double bottomRightLat,
......
...@@ -53,7 +53,8 @@ ...@@ -53,7 +53,8 @@
#include <QFile> #include <QFile>
#include "TerrainTile.h" #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) 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) , _request(request)
, _networkManager(networkManager) , _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(_request.url().isEmpty()) {
if(!_badMapbox.size()) { if(!_badMapbox.size()) {
QFile b(":/res/notile.png"); QFile b(":/res/notile.png");
...@@ -122,7 +129,8 @@ QGeoTiledMapReplyQGC::networkReplyFinished() ...@@ -122,7 +129,8 @@ QGeoTiledMapReplyQGC::networkReplyFinished()
return; return;
} }
QByteArray a = _reply->readAll(); QByteArray a = _reply->readAll();
QString format = getQGCMapEngine()->urlFactory()->getImageFormat(tileSpec().mapId(), a); UrlFactory* urlFactory = getQGCMapEngine()->urlFactory();
QString format = urlFactory->getImageFormat(tileSpec().mapId(), a);
//-- Test for a specialized, elevation data (not map tile) //-- Test for a specialized, elevation data (not map tile)
if( getQGCMapEngine()->urlFactory()->isElevation(tileSpec().mapId())){ if( getQGCMapEngine()->urlFactory()->isElevation(tileSpec().mapId())){
a = TerrainTile::serialize(a); a = TerrainTile::serialize(a);
...@@ -135,11 +143,20 @@ QGeoTiledMapReplyQGC::networkReplyFinished() ...@@ -135,11 +143,20 @@ QGeoTiledMapReplyQGC::networkReplyFinished()
} }
emit terrainDone(a, QNetworkReply::NoError); emit terrainDone(a, QNetworkReply::NoError);
} else { } else {
//-- This is a map tile. Process and cache it if valid. MapProvider* mapProvider = urlFactory->getMapProviderFromId(tileSpec().mapId());
setMapImageData(a); if (mapProvider && mapProvider->_isBingProvider() && a.size() && _bingNoTileImage.size() && a == _bingNoTileImage) {
if(!format.isEmpty()) { // Bing doesn't return an error if you request a tile above supported zoom level
setMapImageFormat(format); // It instead returns an image of a missing tile graphic. We need to detect that
getQGCMapEngine()->cacheTile(getQGCMapEngine()->urlFactory()->getTypeFromId(tileSpec().mapId()), tileSpec().x(), tileSpec().y(), tileSpec().zoom(), a, format); // 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); setFinished(true);
} }
......
...@@ -81,6 +81,7 @@ private: ...@@ -81,6 +81,7 @@ private:
QByteArray _badMapbox; QByteArray _badMapbox;
QByteArray _badTile; QByteArray _badTile;
QTimer _timer; QTimer _timer;
static QByteArray _bingNoTileImage;
static int _requestCount; 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