diff --git a/src/location/maps/qgeotilefetcher.cpp b/src/location/maps/qgeotilefetcher.cpp index 0e0e81caa4045cb569971af8a597234eec7f2111..955839cbb66f4d563bf21b7c1105a526e0682edf 100644 --- a/src/location/maps/qgeotilefetcher.cpp +++ b/src/location/maps/qgeotilefetcher.cpp @@ -109,8 +109,12 @@ void QGeoTileFetcher::requestNextTile() return; QGeoTileSpec ts = d->queue_.takeFirst(); + if (d->queue_.isEmpty()) + d->timer_.stop(); QGeoTiledMapReply *reply = getTileImage(ts); + if (!reply) + return; if (reply->isFinished()) { handleReply(reply, ts); @@ -123,9 +127,6 @@ void QGeoTileFetcher::requestNextTile() d->invmap_.insert(ts, reply); } - - if (d->queue_.isEmpty()) - d->timer_.stop(); } void QGeoTileFetcher::finished() diff --git a/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp b/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp index 0d7fa58e7ea39644499e745a7b1391d6eb176933..c7de7cc958a67e50c7f6608ef29750b22b602cc3 100644 --- a/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp +++ b/src/plugins/geoservices/osm/qgeotilefetcherosm.cpp @@ -121,6 +121,9 @@ QGeoTiledMapReply *QGeoTileFetcherOsm::getTileImage(const QGeoTileSpec &spec) } id -= 1; // TODO: make OSM map ids start from 0. + if (spec.zoom() > m_providers[id]->maximumZoomLevel() || spec.zoom() < m_providers[id]->minimumZoomLevel()) + return Q_NULLPTR; + const QUrl url = m_providers[id]->tileAddress(spec.x(), spec.y(), spec.zoom()); QNetworkRequest request; request.setHeader(QNetworkRequest::UserAgentHeader, m_userAgent); diff --git a/src/plugins/geoservices/osm/qgeotileproviderosm.cpp b/src/plugins/geoservices/osm/qgeotileproviderosm.cpp index afa8e45f46fc36c002a3484d5a4baefb93845064..684ac43c77b564375a75c6676b2b1afc580cab39 100644 --- a/src/plugins/geoservices/osm/qgeotileproviderosm.cpp +++ b/src/plugins/geoservices/osm/qgeotileproviderosm.cpp @@ -99,6 +99,20 @@ QString QGeoTileProviderOsm::format() const return m_provider->format(); } +int QGeoTileProviderOsm::minimumZoomLevel() const +{ + if (m_status != Resolved || !m_provider) + return 0; + return m_provider->minimumZoomLevel(); +} + +int QGeoTileProviderOsm::maximumZoomLevel() const +{ + if (m_status != Resolved || !m_provider) + return 20; + return m_provider->maximumZoomLevel(); +} + const QGeoMapType &QGeoTileProviderOsm::mapType() const { return m_mapType; @@ -332,7 +346,7 @@ void TileProvider::onNetworkReplyFinished() * unavailable, without making the osm plugin fire requests to it. Default is true. * * MinimumZoomLevel and MaximumZoomLevel are also optional, and allow to prevent invalid tile - * requests to the providers, if they do not support the specific ZL. Default is 0 and 19, + * requests to the providers, if they do not support the specific ZL. Default is 0 and 20, * respectively. * * <server address template> is required, and is the tile url template, with %x, %y and %z as @@ -401,7 +415,7 @@ void TileProvider::onNetworkReplyFinished() m_copyRightStyle = copyRightStyle.toString(); m_minimumZoomLevel = 0; - m_maximumZoomLevel = 19; + m_maximumZoomLevel = 20; const QJsonValue minZoom = json.value(QLatin1String("MinimumZoomLevel")); if (minZoom.isDouble()) m_minimumZoomLevel = qBound(0, int(minZoom.toDouble()), maxValidZoom); @@ -517,6 +531,16 @@ QString TileProvider::format() const return m_format; } +int TileProvider::minimumZoomLevel() const +{ + return m_minimumZoomLevel; +} + +int TileProvider::maximumZoomLevel() const +{ + return m_maximumZoomLevel; +} + void TileProvider::setStyleCopyRight(const QString ©right) { m_copyRightStyle = copyright; diff --git a/src/plugins/geoservices/osm/qgeotileproviderosm.h b/src/plugins/geoservices/osm/qgeotileproviderosm.h index d9f80482b9b7914e7ab071a27364bcbfdf05f07e..3e887965f0fd69056793ad3e349c657211e1264b 100644 --- a/src/plugins/geoservices/osm/qgeotileproviderosm.h +++ b/src/plugins/geoservices/osm/qgeotileproviderosm.h @@ -87,6 +87,8 @@ public: inline QString dataCopyRight() const; inline QString styleCopyRight() const; inline QString format() const; + inline int minimumZoomLevel() const; + inline int maximumZoomLevel() const; QUrl tileAddress(int x, int y, int z) const; // Optional properties, not needed to construct a provider @@ -141,6 +143,8 @@ public: QString dataCopyRight() const; QString styleCopyRight() const; QString format() const; + int minimumZoomLevel() const; + int maximumZoomLevel() const; const QGeoMapType &mapType() const; bool isValid() const; bool isResolved() const;