[Core] Fix wrong maxzoom setting of tileSet when using URL source (#15581)
* [core] Take max/min zoom option from style if they are set * [core] std::move input value * [Core] Add changelogs * [Core] Fix clang-format reported error * [Core] fix clang-tidy reported error
This commit is contained in:
@@ -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 <>
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user