diff options
author | Asheem Mamoowala <asheem.mamoowala@mapbox.com> | 2018-01-05 06:35:31 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-05 06:35:31 -0800 |
commit | 10a44050f485a18f8dd6523aca6a7a9f82f7afc7 (patch) | |
tree | fea7f30e35b3228b5989250ff9db225e12bd10ed /src/mbgl/renderer/tile_pyramid.cpp | |
parent | bfa4cea24c2ab3973f845fda6da6d4a9e8f03e56 (diff) | |
download | qtlocation-mapboxgl-10a44050f485a18f8dd6523aca6a7a9f82f7afc7.tar.gz |
Support TileJSON bounds property (#10701)
* [core] Parse TileJSON bounds property
* [core] Add TileRange and LatLngBounds::contains(CanonicalTileID)
Move LatLngBounds::contains impl to cpp file
* [core] Skip tile creation outside of tileset bounds
* [core] Fix TileRange for wrapped bounds and use for CustomTileLoader instead of LatLngBounds comparisons for tiles.
Diffstat (limited to 'src/mbgl/renderer/tile_pyramid.cpp')
-rw-r--r-- | src/mbgl/renderer/tile_pyramid.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/mbgl/renderer/tile_pyramid.cpp b/src/mbgl/renderer/tile_pyramid.cpp index 6a711fb6d5..e474737f8d 100644 --- a/src/mbgl/renderer/tile_pyramid.cpp +++ b/src/mbgl/renderer/tile_pyramid.cpp @@ -7,6 +7,7 @@ #include <mbgl/map/transform.hpp> #include <mbgl/math/clamp.hpp> #include <mbgl/util/tile_cover.hpp> +#include <mbgl/util/tile_range.hpp> #include <mbgl/util/enum.hpp> #include <mbgl/util/logging.hpp> @@ -14,6 +15,7 @@ #include <mapbox/geometry/envelope.hpp> +#include <cmath> #include <algorithm> namespace mbgl { @@ -61,6 +63,7 @@ void TilePyramid::update(const std::vector<Immutable<style::Layer::Impl>>& layer const SourceType type, const uint16_t tileSize, const Range<uint8_t> zoomRange, + optional<LatLngBounds> bounds, std::function<std::unique_ptr<Tile> (const OverscaledTileID&)> createTile) { // If we need a relayout, abandon any cached tiles; they're now stale. if (needsRelayout) { @@ -135,7 +138,15 @@ void TilePyramid::update(const std::vector<Immutable<style::Layer::Impl>>& layer auto it = tiles.find(tileID); return it == tiles.end() ? nullptr : it->second.get(); }; + + optional<util::TileRange> tileRange = {}; + if (bounds) { + tileRange = util::TileRange::fromLatLngBounds(*bounds, std::min(tileZoom, (int32_t)zoomRange.max)); + } auto createTileFn = [&](const OverscaledTileID& tileID) -> Tile* { + if (tileRange && !tileRange->contains(tileID.canonical)) { + return nullptr; + } std::unique_ptr<Tile> tile = cache.get(tileID); if (!tile) { tile = createTile(tileID); |