diff --git a/src/mbgl/annotation/annotation_source.cpp b/src/mbgl/annotation/annotation_source.cpp index aa52e2e43..f246d7aed 100644 --- a/src/mbgl/annotation/annotation_source.cpp +++ b/src/mbgl/annotation/annotation_source.cpp @@ -8,6 +8,10 @@ AnnotationSource::AnnotationSource() : Source(SourceType::Annotations, AnnotationManager::SourceID, "", util::tileSize, std::make_unique()) { } +Range AnnotationSource::getZoomRange() { + return { 0, 22 }; +} + void AnnotationSource::load(FileSource&) { loaded = true; } diff --git a/src/mbgl/annotation/annotation_source.hpp b/src/mbgl/annotation/annotation_source.hpp index 565b9273d..830be519c 100644 --- a/src/mbgl/annotation/annotation_source.hpp +++ b/src/mbgl/annotation/annotation_source.hpp @@ -11,6 +11,7 @@ public: void load(FileSource&) final; private: + Range getZoomRange() final; std::unique_ptr createTile(const OverscaledTileID&, const style::UpdateParameters&) final; }; diff --git a/src/mbgl/style/source.cpp b/src/mbgl/style/source.cpp index 56063188a..086e0b745 100644 --- a/src/mbgl/style/source.cpp +++ b/src/mbgl/style/source.cpp @@ -100,13 +100,15 @@ bool Source::update(const UpdateParameters& parameters) { return allTilesUpdated; } + const Range zoomRange = getZoomRange(); + // Determine the overzooming/underzooming amounts and required tiles. int32_t overscaledZoom = util::coveringZoomLevel(parameters.transformState.getZoom(), type, tileSize); int32_t dataTileZoom = overscaledZoom; std::vector idealTiles; - if (overscaledZoom >= tileset->zoomRange.min) { - int32_t idealZoom = std::min(tileset->zoomRange.max, overscaledZoom); + if (overscaledZoom >= zoomRange.min) { + int32_t idealZoom = std::min(zoomRange.max, overscaledZoom); // Make sure we're not reparsing overzoomed raster tiles. if (type == SourceType::Raster) { @@ -150,7 +152,7 @@ bool Source::update(const UpdateParameters& parameters) { renderTiles.clear(); algorithm::updateRenderables(getTileFn, createTileFn, retainTileFn, renderTileFn, - idealTiles, tileset->zoomRange, dataTileZoom); + idealTiles, zoomRange, dataTileZoom); if (type != SourceType::Raster && type != SourceType::Annotations && cache.getSize() == 0) { size_t conservativeCacheSize = diff --git a/src/mbgl/style/source.hpp b/src/mbgl/style/source.hpp index 3bed992ca..862ee5206 100644 --- a/src/mbgl/style/source.hpp +++ b/src/mbgl/style/source.hpp @@ -85,6 +85,7 @@ private: void onTileError(Tile&, std::exception_ptr) override; void onNeedsRepaint() override; + virtual Range getZoomRange() = 0; virtual std::unique_ptr createTile(const OverscaledTileID&, const UpdateParameters&) = 0; protected: diff --git a/src/mbgl/style/sources/geojson_source.cpp b/src/mbgl/style/sources/geojson_source.cpp index d720e38e5..dbcef9534 100644 --- a/src/mbgl/style/sources/geojson_source.cpp +++ b/src/mbgl/style/sources/geojson_source.cpp @@ -53,7 +53,6 @@ std::unique_ptr GeoJSONSource::parse(const std::string& id, } else if (dataVal.IsObject()) { // We need to parse dataVal as a GeoJSON object geojsonvt = parseGeoJSON(dataVal); - tileset->zoomRange.max = geojsonvt->options.maxZoom; } else { Log::Error(Event::ParseStyle, "GeoJSON data must be a URL or an object"); return nullptr; @@ -72,6 +71,10 @@ GeoJSONSource::GeoJSONSource(std::string id_, GeoJSONSource::~GeoJSONSource() = default; +Range GeoJSONSource::getZoomRange() { + return { 0, geojsonvt->options.maxZoom }; +} + void GeoJSONSource::load(FileSource& fileSource) { if (url.empty()) { // If the URL is empty, the GeoJSON was specified inline in the stylesheet. diff --git a/src/mbgl/style/sources/geojson_source.hpp b/src/mbgl/style/sources/geojson_source.hpp index 08ccf8476..83f529087 100644 --- a/src/mbgl/style/sources/geojson_source.hpp +++ b/src/mbgl/style/sources/geojson_source.hpp @@ -30,6 +30,7 @@ public: void load(FileSource&) final; private: + Range getZoomRange() final; std::unique_ptr createTile(const OverscaledTileID&, const UpdateParameters&) final; std::unique_ptr geojsonvt; diff --git a/src/mbgl/style/tile_source.cpp b/src/mbgl/style/tile_source.cpp index 816bbe966..ef58d87eb 100644 --- a/src/mbgl/style/tile_source.cpp +++ b/src/mbgl/style/tile_source.cpp @@ -16,6 +16,10 @@ TileSource::TileSource(SourceType type_, TileSource::~TileSource() = default; +Range TileSource::getZoomRange() { + return tileset->zoomRange; +} + void TileSource::load(FileSource& fileSource) { if (url.empty()) { // If the URL is empty, the TileJSON was specified inline in the stylesheet. diff --git a/src/mbgl/style/tile_source.hpp b/src/mbgl/style/tile_source.hpp index bfabb838c..7fa2f8157 100644 --- a/src/mbgl/style/tile_source.hpp +++ b/src/mbgl/style/tile_source.hpp @@ -24,6 +24,8 @@ public: void load(FileSource&) final; private: + Range getZoomRange() final; + std::unique_ptr req; };