From ee4bbb765e9a3ccfc9f5943d253290e3fc24484c Mon Sep 17 00:00:00 2001 From: Paolo Angelelli Date: Mon, 15 Aug 2016 14:44:22 +0200 Subject: OSM: Honor min/max zoom level limits coming from the provider records This patch prevents the tile fetcher from requesting tiles with a z values that is outside the range defined in the provider record. If the provider record does not specify these values, the default values are used (0 and 20) Change-Id: I5c3f7be8bbd2b2ce6c8c8d6d8d81431237e60f5b Reviewed-by: Alex Blasche --- .../geoservices/osm/qgeotileproviderosm.cpp | 28 ++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'src/plugins/geoservices/osm/qgeotileproviderosm.cpp') diff --git a/src/plugins/geoservices/osm/qgeotileproviderosm.cpp b/src/plugins/geoservices/osm/qgeotileproviderosm.cpp index afa8e45f..684ac43c 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. * * 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; -- cgit v1.2.1