summaryrefslogtreecommitdiff
path: root/src/mbgl
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl')
-rw-r--r--src/mbgl/style/custom_tile_loader.cpp11
-rw-r--r--src/mbgl/util/tile_range.hpp5
2 files changed, 12 insertions, 4 deletions
diff --git a/src/mbgl/style/custom_tile_loader.cpp b/src/mbgl/style/custom_tile_loader.cpp
index 76248b84bd..1c587302b8 100644
--- a/src/mbgl/style/custom_tile_loader.cpp
+++ b/src/mbgl/style/custom_tile_loader.cpp
@@ -1,5 +1,6 @@
#include <mbgl/style/custom_tile_loader.hpp>
#include <mbgl/tile/custom_geometry_tile.hpp>
+#include <mbgl/util/tile_range.hpp>
namespace mbgl {
namespace style {
@@ -79,9 +80,15 @@ void CustomTileLoader::invalidateTile(const CanonicalTileID& tileID) {
}
void CustomTileLoader::invalidateRegion(const LatLngBounds& bounds, Range<uint8_t> ) {
+ std::map<uint8_t, util::TileRange> tileRanges;
+
for (auto idtuple= tileCallbackMap.begin(); idtuple != tileCallbackMap.end(); idtuple++) {
- const LatLngBounds tileBounds(idtuple->first);
- if (tileBounds.intersects(bounds, LatLng::Wrapped) || bounds.contains(tileBounds, LatLng::Wrapped) || tileBounds.contains(bounds, LatLng::Wrapped)) {
+ auto zoom = idtuple->first.z;
+ auto tileRange = tileRanges.find(zoom);
+ if(tileRange == tileRanges.end()) {
+ tileRange = tileRanges.emplace(std::make_pair(zoom, util::TileRange::fromLatLngBounds(bounds, zoom))).first;
+ }
+ if (tileRange->second.contains(idtuple->first)) {
for (auto iter = idtuple->second.begin(); iter != idtuple->second.end(); iter++) {
auto actor = std::get<2>(*iter);
actor.invoke(&CustomGeometryTile::invalidateTileData);
diff --git a/src/mbgl/util/tile_range.hpp b/src/mbgl/util/tile_range.hpp
index 2a6f6b848c..eb7d2916c5 100644
--- a/src/mbgl/util/tile_range.hpp
+++ b/src/mbgl/util/tile_range.hpp
@@ -28,8 +28,9 @@ public:
bool contains(const CanonicalTileID& tileID) {
return z == tileID.z &&
- tileID.x < range.max.x &&
- tileID.x >= range.min.x &&
+ (range.min.x >= range.max.x ? //For wrapped bounds
+ tileID.x >= range.min.x || tileID.x < range.max.x :
+ tileID.x < range.max.x && tileID.x >= range.min.x) &&
tileID.y < range.max.y &&
tileID.y >= range.min.y;
}