summaryrefslogtreecommitdiffstats
path: root/src/location/maps
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2017-04-07 11:23:55 +0200
committerPaolo Angelelli <paolo.angelelli@qt.io>2017-04-12 11:18:29 +0000
commitae2329252e84a4931b321cacf529a13a3f06a0d5 (patch)
tree06d9a3dbb84491489e25dcabbee3fb2b1e717e66 /src/location/maps
parentb82f9dd722e21fd7694221147dc0dccc94b2ad60 (diff)
Bound check QGeoTileSpec against min/max ZL before requesting it
Until now we have not honored the min/max zoom levels specified in QGeoCameraCapabilities when requesting tiles. As a result we have often fired requests for non-existing tile layers. This change complements the added support for individual camera caps for each map type, and makes the tile fetcher honor the bounds defined in the camera capabilities. This also allows to set larger zoom levels in the renderer, overzooming existing tiles, without the fetcher firing requests for invalid resources Change-Id: Ic8a523a114147109f7ef8af3510a3ab78d06d714 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/location/maps')
-rw-r--r--src/location/maps/qgeotilefetcher.cpp15
-rw-r--r--src/location/maps/qgeotilefetcher_p.h4
-rw-r--r--src/location/maps/qgeotilefetcher_p_p.h4
3 files changed, 17 insertions, 6 deletions
diff --git a/src/location/maps/qgeotilefetcher.cpp b/src/location/maps/qgeotilefetcher.cpp
index 34bf686c..70ebbcd1 100644
--- a/src/location/maps/qgeotilefetcher.cpp
+++ b/src/location/maps/qgeotilefetcher.cpp
@@ -45,22 +45,24 @@
QT_BEGIN_NAMESPACE
-QGeoTileFetcher::QGeoTileFetcher(QObject *parent)
+QGeoTileFetcher::QGeoTileFetcher(QGeoMappingManagerEngine *parent)
: QObject(*new QGeoTileFetcherPrivate(), parent)
{
Q_D(QGeoTileFetcher);
d->enabled_ = true;
+ d->engine_ = parent;
// if (!d->queue_.isEmpty())
// d->timer_.start(0, this);
}
-QGeoTileFetcher::QGeoTileFetcher(QGeoTileFetcherPrivate &dd, QObject *parent)
+QGeoTileFetcher::QGeoTileFetcher(QGeoTileFetcherPrivate &dd, QGeoMappingManagerEngine *parent)
: QObject(dd,parent)
{
Q_D(QGeoTileFetcher);
d->enabled_ = true;
+ d->engine_ = parent;
// if (!d->queue_.isEmpty())
// d->timer_.start(0, this);
@@ -120,6 +122,13 @@ void QGeoTileFetcher::requestNextTile()
if (d->queue_.isEmpty())
d->timer_.stop();
+ // Check against min/max zoom to prevent sending requests for not existing objects
+ const QGeoCameraCapabilities & cameraCaps = d->engine_->cameraCapabilities(ts.mapId());
+ // the ZL in QGeoTileSpec is relative to the native tile size of the provider.
+ // It gets denormalized in QGeoTiledMap.
+ if (ts.zoom() < cameraCaps.minimumZoomLevel() || ts.zoom() > cameraCaps.maximumZoomLevel())
+ return;
+
QGeoTiledMapReply *reply = getTileImage(ts);
if (!reply)
return;
@@ -202,7 +211,7 @@ void QGeoTileFetcher::handleReply(QGeoTiledMapReply *reply, const QGeoTileSpec &
*******************************************************************************/
QGeoTileFetcherPrivate::QGeoTileFetcherPrivate()
-: QObjectPrivate(), enabled_(false)
+: QObjectPrivate(), enabled_(false), engine_(0)
{
}
diff --git a/src/location/maps/qgeotilefetcher_p.h b/src/location/maps/qgeotilefetcher_p.h
index f9a84209..23adac77 100644
--- a/src/location/maps/qgeotilefetcher_p.h
+++ b/src/location/maps/qgeotilefetcher_p.h
@@ -68,7 +68,7 @@ class Q_LOCATION_PRIVATE_EXPORT QGeoTileFetcher : public QObject
Q_DECLARE_PRIVATE(QGeoTileFetcher)
public:
- QGeoTileFetcher(QObject *parent = 0);
+ QGeoTileFetcher(QGeoMappingManagerEngine *parent);
virtual ~QGeoTileFetcher();
public Q_SLOTS:
@@ -84,7 +84,7 @@ Q_SIGNALS:
void tileError(const QGeoTileSpec &spec, const QString &errorString);
protected:
- QGeoTileFetcher(QGeoTileFetcherPrivate &dd, QObject *parent = 0);
+ QGeoTileFetcher(QGeoTileFetcherPrivate &dd, QGeoMappingManagerEngine *parent);
void timerEvent(QTimerEvent *event);
QAbstractGeoTileCache::CacheAreas cacheHint() const;
diff --git a/src/location/maps/qgeotilefetcher_p_p.h b/src/location/maps/qgeotilefetcher_p_p.h
index 7e9db527..8e955563 100644
--- a/src/location/maps/qgeotilefetcher_p_p.h
+++ b/src/location/maps/qgeotilefetcher_p_p.h
@@ -50,6 +50,7 @@
#include <QtCore/private/qobject_p.h>
#include <QtLocation/private/qlocationglobal_p.h>
+#include <QtLocation/private/qgeotiledmappingmanagerengine_p.h>
#include <QSize>
#include <QList>
#include <QMap>
@@ -64,7 +65,7 @@ QT_BEGIN_NAMESPACE
class QGeoTileSpec;
class QGeoTiledMapReply;
-class QGeoTiledMappingManagerEngine;
+class QGeoMappingManagerEngine;
class Q_LOCATION_PRIVATE_EXPORT QGeoTileFetcherPrivate : public QObjectPrivate
{
@@ -78,6 +79,7 @@ public:
QMutex queueMutex_;
QList<QGeoTileSpec> queue_;
QHash<QGeoTileSpec, QGeoTiledMapReply *> invmap_;
+ QGeoMappingManagerEngine *engine_;
private:
Q_DISABLE_COPY(QGeoTileFetcherPrivate)