diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-06-13 15:00:57 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-06-14 11:25:45 -0700 |
commit | 755cc80edfc53a680030a88a661afe1d9edd1f75 (patch) | |
tree | 2edaf1b7a0b717102c2be73a74d4520925501cb5 | |
parent | 6eab895bc0683881f793a3a751fa7470603ae9a0 (diff) | |
download | qtlocation-mapboxgl-755cc80edfc53a680030a88a661afe1d9edd1f75.tar.gz |
[core] Add virtual Source::getZoomRange()
-rw-r--r-- | src/mbgl/annotation/annotation_source.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/annotation/annotation_source.hpp | 1 | ||||
-rw-r--r-- | src/mbgl/style/source.cpp | 8 | ||||
-rw-r--r-- | src/mbgl/style/source.hpp | 1 | ||||
-rw-r--r-- | src/mbgl/style/sources/geojson_source.cpp | 5 | ||||
-rw-r--r-- | src/mbgl/style/sources/geojson_source.hpp | 1 | ||||
-rw-r--r-- | src/mbgl/style/tile_source.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/style/tile_source.hpp | 2 |
8 files changed, 22 insertions, 4 deletions
diff --git a/src/mbgl/annotation/annotation_source.cpp b/src/mbgl/annotation/annotation_source.cpp index aa52e2e434..f246d7aed8 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<Tileset>()) { } +Range<uint8_t> 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 565b9273d6..830be519c2 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<uint8_t> getZoomRange() final; std::unique_ptr<Tile> createTile(const OverscaledTileID&, const style::UpdateParameters&) final; }; diff --git a/src/mbgl/style/source.cpp b/src/mbgl/style/source.cpp index 56063188a0..086e0b745c 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<uint8_t> 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<UnwrappedTileID> idealTiles; - if (overscaledZoom >= tileset->zoomRange.min) { - int32_t idealZoom = std::min<int32_t>(tileset->zoomRange.max, overscaledZoom); + if (overscaledZoom >= zoomRange.min) { + int32_t idealZoom = std::min<int32_t>(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 3bed992cab..862ee52068 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<uint8_t> getZoomRange() = 0; virtual std::unique_ptr<Tile> 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 d720e38e51..dbcef95344 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> 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<uint8_t> 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 08ccf84760..83f5290873 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<uint8_t> getZoomRange() final; std::unique_ptr<Tile> createTile(const OverscaledTileID&, const UpdateParameters&) final; std::unique_ptr<mapbox::geojsonvt::GeoJSONVT> geojsonvt; diff --git a/src/mbgl/style/tile_source.cpp b/src/mbgl/style/tile_source.cpp index 816bbe9667..ef58d87eb5 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<uint8_t> 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 bfabb838c0..7fa2f8157e 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<uint8_t> getZoomRange() final; + std::unique_ptr<AsyncRequest> req; }; |