diff options
-rw-r--r-- | include/mbgl/style/sources/vector_source.hpp | 5 | ||||
-rw-r--r-- | platform/android/CHANGELOG.md | 1 | ||||
-rw-r--r-- | platform/ios/CHANGELOG.md | 1 | ||||
-rw-r--r-- | platform/macos/CHANGELOG.md | 1 | ||||
-rw-r--r-- | platform/node/CHANGELOG.md | 1 | ||||
-rw-r--r-- | src/mbgl/style/conversion/source.cpp | 21 | ||||
-rw-r--r-- | src/mbgl/style/sources/vector_source.cpp | 15 |
7 files changed, 38 insertions, 7 deletions
diff --git a/include/mbgl/style/sources/vector_source.hpp b/include/mbgl/style/sources/vector_source.hpp index ece7f5615a..97f0a7e5a8 100644 --- a/include/mbgl/style/sources/vector_source.hpp +++ b/include/mbgl/style/sources/vector_source.hpp @@ -12,7 +12,8 @@ namespace style { class VectorSource final : public Source { public: - VectorSource(std::string id, variant<std::string, Tileset> urlOrTileset); + VectorSource(std::string id, variant<std::string, Tileset> urlOrTileset, optional<float> maxZoom = nullopt, + optional<float> minZoom = nullopt); ~VectorSource() final; const variant<std::string, Tileset>& getURLOrTileset() const; @@ -31,6 +32,8 @@ private: const variant<std::string, Tileset> urlOrTileset; std::unique_ptr<AsyncRequest> req; mapbox::base::WeakPtrFactory<Source> weakFactory {this}; + optional<float> maxZoom; + optional<float> minZoom; }; template <> diff --git a/platform/android/CHANGELOG.md b/platform/android/CHANGELOG.md index a7fd332b65..734647e4c8 100644 --- a/platform/android/CHANGELOG.md +++ b/platform/android/CHANGELOG.md @@ -7,6 +7,7 @@ Mapbox welcomes participation and contributions from everyone. If you'd like to ### Bug fixes - Fixed constant repainting for the sources with invisible layers, caused by `RenderSource::hasFadingTiles()` returning `true` all the time. [#15600](https://github.com/mapbox/mapbox-gl-native/pull/15600) - Fixed an issue that caused the state of CompassView not up to date when `UiSettings.setCompassEnabled()` is set to true. [#15606](https://github.com/mapbox/mapbox-gl-native/pull/15606) + - Fixed an issue that `maxzoom` in style `Sources` option was ignored when URL resource is provided. It may cause problems such as extra tiles downloading at higher zoom level than `maxzoom`, or problems that wrong setting of `overscaledZ` in `OverscaledTileID` that will be passed to `SymbolLayout`, leading wrong rendering appearance. [#15581](https://github.com/mapbox/mapbox-gl-native/pull/15581) ## 8.4.0-alpha.2 - September 11, 2019 [Changes](https://github.com/mapbox/mapbox-gl-native/compare/android-v8.4.0-alpha.1...android-v8.4.0-alpha.2) since [Mapbox Maps SDK for Android v8.4.0-alpha.1](https://github.com/mapbox/mapbox-gl-native/releases/tag/android-v8.4.0-alpha.1): diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index 8515fd467f..f2394d1b84 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -6,6 +6,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT ### Styles and rendering * Added an `-[MGLMapSnapshotter startWithOverlayHandler:completionHandler:]` method to provide the snapshot's current `CGContext` in order to perform custom drawing on `MGLMapSnapShot` objects. ([#15530](https://github.com/mapbox/mapbox-gl-native/pull/15530)) +* Fixed an issue that `maxzoom` in style `Sources` option was ignored when URL resource is provided. It may cause problems such as extra tiles downloading at higher zoom level than `maxzoom`, or problems that wrong setting of `overscaledZ` in `OverscaledTileID` that will be passed to `SymbolLayout`, leading wrong rendering appearance. ([#15581](https://github.com/mapbox/mapbox-gl-native/pull/15581)) ### Performance improvements diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index da9a179ad3..888d4c5267 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -18,6 +18,7 @@ * Fixed a rendering issue of `collisionBox` when `text-translate` or `icon-translate` is enabled. ([#15467](https://github.com/mapbox/mapbox-gl-native/pull/15467)) * Fixed an issue of integer overflow when converting `tileCoordinates` to `LatLon`, which caused issues such as `queryRenderedFeatures` and `querySourceFeatures` returning incorrect coordinates at zoom levels 20 and higher. ([#15560](https://github.com/mapbox/mapbox-gl-native/pull/15560)) * Added an `-[MGLMapSnapshotter startWithOverlayHandler:completionHandler:]` method to provide the snapshot's current `CGContext` in order to perform custom drawing on `MGLMapSnapShot` objects. ([#15530](https://github.com/mapbox/mapbox-gl-native/pull/15530)) +* Fixed an issue that `maxzoom` in style `Sources` option was ignored when URL resource is provided. It may cause problems such as extra tiles downloading at higher zoom level than `maxzoom`, or problems that wrong setting of `overscaledZ` in `OverscaledTileID` that will be passed to `SymbolLayout`, leading wrong rendering appearance. ([#15581](https://github.com/mapbox/mapbox-gl-native/pull/15581)) ### Styles and rendering diff --git a/platform/node/CHANGELOG.md b/platform/node/CHANGELOG.md index 519f30aaad..486dd44e10 100644 --- a/platform/node/CHANGELOG.md +++ b/platform/node/CHANGELOG.md @@ -5,6 +5,7 @@ * Fixed a rendering issue of `collisionBox` when `text-translate` or `icon-translate` is enabled. ([#15467](https://github.com/mapbox/mapbox-gl-native/pull/15467)) * Fixed an issue of integer overflow when converting `tileCoordinates` to `LatLon`, which caused issues such as `queryRenderedFeatures` and `querySourceFeatures` returning incorrect coordinates at zoom levels 20 and higher. ([#15560](https://github.com/mapbox/mapbox-gl-native/pull/15560)) * Add typechecking while constructing legacy filter to prevent converting an unexpected filter type [#15389](https://github.com/mapbox/mapbox-gl-native/pull/15389). +* Fixed an issue that `maxzoom` in style `Sources` option was ignored when URL resource is provided. It may cause problems such as extra tiles downloading at higher zoom level than `maxzoom`, or problems that wrong setting of `overscaledZ` in `OverscaledTileID` that will be passed to `SymbolLayout`, leading wrong rendering appearance. ([#15581](https://github.com/mapbox/mapbox-gl-native/pull/15581)) # 4.2.0 - Add an option to set whether or not an image should be treated as a SDF ([#15054](https://github.com/mapbox/mapbox-gl-native/issues/15054)) diff --git a/src/mbgl/style/conversion/source.cpp b/src/mbgl/style/conversion/source.cpp index 5ecbd3b474..de41adc89f 100644 --- a/src/mbgl/style/conversion/source.cpp +++ b/src/mbgl/style/conversion/source.cpp @@ -86,8 +86,25 @@ static optional<std::unique_ptr<Source>> convertVectorSource(const std::string& if (!urlOrTileset) { return nullopt; } - - return { std::make_unique<VectorSource>(id, std::move(*urlOrTileset)) }; + auto maxzoomValue = objectMember(value, "maxzoom"); + optional<float> maxzoom; + if (maxzoomValue) { + maxzoom = toNumber(*maxzoomValue); + if (!maxzoom || *maxzoom < 0 || *maxzoom > std::numeric_limits<uint8_t>::max()) { + error.message = "invalid maxzoom"; + return nullopt; + } + } + auto minzoomValue = objectMember(value, "minzoom"); + optional<float> minzoom; + if (minzoomValue) { + minzoom = toNumber(*minzoomValue); + if (!minzoom || *minzoom < 0 || *minzoom > std::numeric_limits<uint8_t>::max()) { + error.message = "invalid minzoom"; + return nullopt; + } + } + return {std::make_unique<VectorSource>(id, std::move(*urlOrTileset), std::move(maxzoom), std::move(minzoom))}; } static optional<std::unique_ptr<Source>> convertGeoJSONSource(const std::string& id, diff --git a/src/mbgl/style/sources/vector_source.cpp b/src/mbgl/style/sources/vector_source.cpp index f103a7768f..a69ff632d8 100644 --- a/src/mbgl/style/sources/vector_source.cpp +++ b/src/mbgl/style/sources/vector_source.cpp @@ -11,10 +11,12 @@ namespace mbgl { namespace style { -VectorSource::VectorSource(std::string id, variant<std::string, Tileset> urlOrTileset_) +VectorSource::VectorSource(std::string id, variant<std::string, Tileset> urlOrTileset_, optional<float> maxZoom_, + optional<float> minZoom_) : Source(makeMutable<Impl>(std::move(id))), - urlOrTileset(std::move(urlOrTileset_)) { -} + urlOrTileset(std::move(urlOrTileset_)), + maxZoom(std::move(maxZoom_)), + minZoom(std::move(minZoom_)) {} VectorSource::~VectorSource() = default; @@ -61,7 +63,12 @@ void VectorSource::loadDescription(FileSource& fileSource) { observer->onSourceError(*this, std::make_exception_ptr(util::StyleParseException(error.message))); return; } - + if (maxZoom) { + tileset->zoomRange.max = *maxZoom; + } + if (minZoom) { + tileset->zoomRange.min = *minZoom; + } util::mapbox::canonicalizeTileset(*tileset, url, getType(), util::tileSize); bool changed = impl().tileset != *tileset; |