summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-06-13 14:45:22 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-06-14 11:25:45 -0700
commit6eab895bc0683881f793a3a751fa7470603ae9a0 (patch)
tree5e1b231702bb1c93e6a0c8823500a6e6980b0970
parent615a6685a47609310930890203f41815a5f19d48 (diff)
downloadqtlocation-mapboxgl-6eab895bc0683881f793a3a751fa7470603ae9a0.tar.gz
[core] Use Range<uint8_t> instead of full Tileset where possible
-rw-r--r--include/mbgl/storage/offline.hpp4
-rw-r--r--include/mbgl/util/range.hpp25
-rw-r--r--platform/default/mbgl/storage/offline.cpp6
-rw-r--r--platform/default/mbgl/storage/offline_download.cpp2
-rw-r--r--src/mbgl/algorithm/update_renderables.hpp14
-rw-r--r--src/mbgl/style/parser.cpp4
-rw-r--r--src/mbgl/style/source.cpp6
-rw-r--r--src/mbgl/style/sources/geojson_source.cpp4
-rw-r--r--src/mbgl/util/tileset.hpp4
-rw-r--r--test/algorithm/mock.hpp8
-rw-r--r--test/algorithm/update_renderables.cpp94
-rw-r--r--test/storage/offline.cpp24
-rw-r--r--test/style/style_parser.cpp8
13 files changed, 108 insertions, 95 deletions
diff --git a/include/mbgl/storage/offline.hpp b/include/mbgl/storage/offline.hpp
index bbd8674e5a..818cfe2ba5 100644
--- a/include/mbgl/storage/offline.hpp
+++ b/include/mbgl/storage/offline.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <mbgl/util/geo.hpp>
+#include <mbgl/util/range.hpp>
#include <mbgl/util/optional.hpp>
#include <mbgl/style/types.hpp>
#include <mbgl/storage/response.hpp>
@@ -12,7 +13,6 @@
namespace mbgl {
class TileID;
-class Tileset;
/*
* An offline region defined by a style URL, geographic bounding box, zoom range, and
@@ -30,7 +30,7 @@ public:
OfflineTilePyramidRegionDefinition(std::string, LatLngBounds, double, double, float);
/* Private */
- std::vector<CanonicalTileID> tileCover(SourceType, uint16_t tileSize, const Tileset&) const;
+ std::vector<CanonicalTileID> tileCover(SourceType, uint16_t tileSize, const Range<uint8_t>& zoomRange) const;
const std::string styleURL;
const LatLngBounds bounds;
diff --git a/include/mbgl/util/range.hpp b/include/mbgl/util/range.hpp
new file mode 100644
index 0000000000..d04164afb7
--- /dev/null
+++ b/include/mbgl/util/range.hpp
@@ -0,0 +1,25 @@
+#pragma once
+
+namespace mbgl {
+
+template <class T>
+class Range {
+public:
+ Range(const T& min_, const T& max_)
+ : min(min_), max(max_) {}
+
+ T min;
+ T max;
+};
+
+template <class T>
+inline bool operator==(const Range<T>& a, const Range<T>& b) {
+ return a.min == b.min && a.max == b.max;
+}
+
+template <class T>
+inline bool operator!=(const Range<T>& a, const Range<T>& b) {
+ return !(a == b);
+}
+
+} // namespace mbgl
diff --git a/platform/default/mbgl/storage/offline.cpp b/platform/default/mbgl/storage/offline.cpp
index 812e427157..fd2d47819b 100644
--- a/platform/default/mbgl/storage/offline.cpp
+++ b/platform/default/mbgl/storage/offline.cpp
@@ -23,9 +23,9 @@ OfflineTilePyramidRegionDefinition::OfflineTilePyramidRegionDefinition(
}
}
-std::vector<CanonicalTileID> OfflineTilePyramidRegionDefinition::tileCover(SourceType type, uint16_t tileSize, const Tileset& tileset) const {
- double minZ = std::max<double>(util::coveringZoomLevel(minZoom, type, tileSize), tileset.minZoom);
- double maxZ = std::min<double>(util::coveringZoomLevel(maxZoom, type, tileSize), tileset.maxZoom);
+std::vector<CanonicalTileID> OfflineTilePyramidRegionDefinition::tileCover(SourceType type, uint16_t tileSize, const Range<uint8_t>& zoomRange) const {
+ double minZ = std::max<double>(util::coveringZoomLevel(minZoom, type, tileSize), zoomRange.min);
+ double maxZ = std::min<double>(util::coveringZoomLevel(maxZoom, type, tileSize), zoomRange.max);
assert(minZ >= 0);
assert(maxZ >= 0);
diff --git a/platform/default/mbgl/storage/offline_download.cpp b/platform/default/mbgl/storage/offline_download.cpp
index 11ca862925..820e1cd223 100644
--- a/platform/default/mbgl/storage/offline_download.cpp
+++ b/platform/default/mbgl/storage/offline_download.cpp
@@ -74,7 +74,7 @@ std::vector<Resource> OfflineDownload::glyphResources(const style::Parser& parse
std::vector<Resource> OfflineDownload::tileResources(SourceType type, uint16_t tileSize, const Tileset& tileset) const {
std::vector<Resource> result;
- for (const auto& tile : definition.tileCover(type, tileSize, tileset)) {
+ for (const auto& tile : definition.tileCover(type, tileSize, tileset.zoomRange)) {
result.push_back(Resource::tile(tileset.tiles[0], definition.pixelRatio, tile.x, tile.y, tile.z));
}
diff --git a/src/mbgl/algorithm/update_renderables.hpp b/src/mbgl/algorithm/update_renderables.hpp
index eebabbd211..d47a919bae 100644
--- a/src/mbgl/algorithm/update_renderables.hpp
+++ b/src/mbgl/algorithm/update_renderables.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <mbgl/tile/tile_id.hpp>
+#include <mbgl/util/range.hpp>
#include <set>
@@ -11,14 +12,13 @@ template <typename GetTileFn,
typename CreateTileFn,
typename RetainTileFn,
typename RenderTileFn,
- typename IdealTileIDs,
- typename SourceInfo>
+ typename IdealTileIDs>
void updateRenderables(GetTileFn getTile,
CreateTileFn createTile,
RetainTileFn retainTile,
RenderTileFn renderTile,
const IdealTileIDs& idealTileIDs,
- const SourceInfo& info,
+ const Range<uint8_t>& zoomRange,
const uint8_t dataTileZoom) {
std::set<UnwrappedTileID> checked;
bool covered;
@@ -26,8 +26,8 @@ void updateRenderables(GetTileFn getTile,
// for (all in the set of ideal tiles of the source) {
for (const auto& idealRenderTileID : idealTileIDs) {
- assert(idealRenderTileID.canonical.z >= info.minZoom);
- assert(idealRenderTileID.canonical.z <= info.maxZoom);
+ assert(idealRenderTileID.canonical.z >= zoomRange.min);
+ assert(idealRenderTileID.canonical.z <= zoomRange.max);
assert(dataTileZoom >= idealRenderTileID.canonical.z);
const OverscaledTileID idealDataTileID(dataTileZoom, idealRenderTileID.canonical);
@@ -48,7 +48,7 @@ void updateRenderables(GetTileFn getTile,
retainTile(*data, true);
covered = true;
overscaledZ = dataTileZoom + 1;
- if (overscaledZ > info.maxZoom) {
+ if (overscaledZ > zoomRange.max) {
// We're looking for an overzoomed child tile.
const auto childDataTileID = idealDataTileID.scaledTo(overscaledZ);
data = getTile(childDataTileID);
@@ -76,7 +76,7 @@ void updateRenderables(GetTileFn getTile,
if (!covered) {
// We couldn't find child tiles that entirely cover the ideal tile.
- for (overscaledZ = dataTileZoom - 1; overscaledZ >= info.minZoom; --overscaledZ) {
+ for (overscaledZ = dataTileZoom - 1; overscaledZ >= zoomRange.min; --overscaledZ) {
const auto parentDataTileID = idealDataTileID.scaledTo(overscaledZ);
const auto parentRenderTileID =
parentDataTileID.unwrapTo(idealRenderTileID.wrap);
diff --git a/src/mbgl/style/parser.cpp b/src/mbgl/style/parser.cpp
index 8a677d29c8..1ca090643d 100644
--- a/src/mbgl/style/parser.cpp
+++ b/src/mbgl/style/parser.cpp
@@ -254,8 +254,8 @@ std::unique_ptr<Tileset> parseTileJSON(const std::string& json, const std::strin
std::unique_ptr<Tileset> parseTileJSON(const JSValue& value) {
auto tileset = std::make_unique<Tileset>();
parseTileJSONMember(value, tileset->tiles, "tiles");
- parseTileJSONMember(value, tileset->minZoom, "minzoom");
- parseTileJSONMember(value, tileset->maxZoom, "maxzoom");
+ parseTileJSONMember(value, tileset->zoomRange.min, "minzoom");
+ parseTileJSONMember(value, tileset->zoomRange.max, "maxzoom");
parseTileJSONMember(value, tileset->attribution, "attribution");
std::array<double, 4> array;
diff --git a/src/mbgl/style/source.cpp b/src/mbgl/style/source.cpp
index 639c563a64..56063188a0 100644
--- a/src/mbgl/style/source.cpp
+++ b/src/mbgl/style/source.cpp
@@ -105,8 +105,8 @@ bool Source::update(const UpdateParameters& parameters) {
int32_t dataTileZoom = overscaledZoom;
std::vector<UnwrappedTileID> idealTiles;
- if (overscaledZoom >= tileset->minZoom) {
- int32_t idealZoom = std::min<int32_t>(tileset->maxZoom, overscaledZoom);
+ if (overscaledZoom >= tileset->zoomRange.min) {
+ int32_t idealZoom = std::min<int32_t>(tileset->zoomRange.max, overscaledZoom);
// Make sure we're not reparsing overzoomed raster tiles.
if (type == SourceType::Raster) {
@@ -150,7 +150,7 @@ bool Source::update(const UpdateParameters& parameters) {
renderTiles.clear();
algorithm::updateRenderables(getTileFn, createTileFn, retainTileFn, renderTileFn,
- idealTiles, *tileset, dataTileZoom);
+ idealTiles, tileset->zoomRange, dataTileZoom);
if (type != SourceType::Raster && type != SourceType::Annotations && cache.getSize() == 0) {
size_t conservativeCacheSize =
diff --git a/src/mbgl/style/sources/geojson_source.cpp b/src/mbgl/style/sources/geojson_source.cpp
index d0a11ec0bc..d720e38e51 100644
--- a/src/mbgl/style/sources/geojson_source.cpp
+++ b/src/mbgl/style/sources/geojson_source.cpp
@@ -53,7 +53,7 @@ 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->maxZoom = geojsonvt->options.maxZoom;
+ tileset->zoomRange.max = geojsonvt->options.maxZoom;
} else {
Log::Error(Event::ParseStyle, "GeoJSON data must be a URL or an object");
return nullptr;
@@ -104,7 +104,7 @@ void GeoJSONSource::load(FileSource& fileSource) {
}
geojsonvt = style::parseGeoJSON(d);
- newTileset->maxZoom = geojsonvt->options.maxZoom;
+ newTileset->zoomRange.max = geojsonvt->options.maxZoom;
invalidateTiles();
diff --git a/src/mbgl/util/tileset.hpp b/src/mbgl/util/tileset.hpp
index 972fc51f8c..7e53850dfe 100644
--- a/src/mbgl/util/tileset.hpp
+++ b/src/mbgl/util/tileset.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <mbgl/util/constants.hpp>
+#include <mbgl/util/range.hpp>
#include <mbgl/util/geo.hpp>
#include <array>
@@ -13,8 +14,7 @@ namespace mbgl {
class Tileset {
public:
std::vector<std::string> tiles;
- uint8_t minZoom = 0;
- uint8_t maxZoom = 22;
+ Range<uint8_t> zoomRange { 0, 22 };
std::string attribution;
LatLng center;
double zoom = 0;
diff --git a/test/algorithm/mock.hpp b/test/algorithm/mock.hpp
index ff58499303..efa76f238e 100644
--- a/test/algorithm/mock.hpp
+++ b/test/algorithm/mock.hpp
@@ -7,16 +7,12 @@
#include <map>
#include <mbgl/tile/tile_id.hpp>
-
-struct MockSourceInfo {
- uint8_t maxZoom = 16;
- uint8_t minZoom = 0;
-};
+#include <mbgl/util/range.hpp>
struct MockTileData;
struct MockSource {
- MockSourceInfo info;
+ mbgl::Range<uint8_t> zoomRange { 0, 16 };
std::map<mbgl::OverscaledTileID, std::unique_ptr<MockTileData>> dataTiles;
std::set<mbgl::UnwrappedTileID> idealTiles;
diff --git a/test/algorithm/update_renderables.cpp b/test/algorithm/update_renderables.cpp
index 80e599f599..dcc43a83f3 100644
--- a/test/algorithm/update_renderables.cpp
+++ b/test/algorithm/update_renderables.cpp
@@ -132,7 +132,7 @@ TEST(UpdateRenderables, SingleTile) {
tile_1_1_1_1->renderable = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 1);
+ source.idealTiles, source.zoomRange, 1);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 1, { 1, 1, 1 } }, Found }, // found ideal tile
RetainTileDataAction{ { 1, { 1, 1, 1 } }, Required }, //
@@ -143,7 +143,7 @@ TEST(UpdateRenderables, SingleTile) {
// Check a repeated render with the same data.
log.clear();
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 1);
+ source.idealTiles, source.zoomRange, 1);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 1, { 1, 1, 1 } }, Found }, // found ideal tile
RetainTileDataAction{ { 1, { 1, 1, 1 } }, Required }, //
@@ -155,7 +155,7 @@ TEST(UpdateRenderables, SingleTile) {
log.clear();
source.idealTiles.emplace(UnwrappedTileID{ 1, 0, 1 });
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 1);
+ source.idealTiles, source.zoomRange, 1);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 1, { 1, 0, 1 } }, NotFound }, // missing ideal tile
CreateTileDataAction{ { 1, { 1, 0, 1 } } }, // create ideal tile
@@ -176,7 +176,7 @@ TEST(UpdateRenderables, SingleTile) {
log.clear();
source.dataTiles[{ 1, { 1, 0, 1 } }]->triedOptional = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 1);
+ source.idealTiles, source.zoomRange, 1);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 1, { 1, 0, 1 } }, Found }, // missing ideal tile
RetainTileDataAction{ { 1, { 1, 0, 1 } }, Required }, //
@@ -199,7 +199,7 @@ TEST(UpdateRenderables, SingleTile) {
auto tile_1_1_0_1 = source.createTileData(OverscaledTileID{ 1, 0, 1 });
tile_1_1_0_1->renderable = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 1);
+ source.idealTiles, source.zoomRange, 1);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 1, { 1, 0, 1 } }, Found }, // newly added tile
RetainTileDataAction{ { 1, { 1, 0, 1 } }, Required }, //
@@ -218,7 +218,7 @@ TEST(UpdateRenderables, SingleTile) {
auto tile_1_1_0_0 = source.createTileData(OverscaledTileID{ 1, 0, 0 });
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 1);
+ source.idealTiles, source.zoomRange, 1);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 1, { 1, 0, 0 } }, Found }, // found tile, not ready
RetainTileDataAction{ { 1, { 1, 0, 0 } }, Required }, //
@@ -244,7 +244,7 @@ TEST(UpdateRenderables, SingleTile) {
log.clear();
tile_1_1_0_0->renderable = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 1);
+ source.idealTiles, source.zoomRange, 1);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 1, { 1, 0, 0 } }, Found }, // found tile, now ready
RetainTileDataAction{ { 1, { 1, 0, 0 } }, Required }, //
@@ -277,7 +277,7 @@ TEST(UpdateRenderables, UseParentTile) {
auto tile_0_0_0_0 = source.createTileData(OverscaledTileID{ 0, 0, 0 });
tile_0_0_0_0->renderable = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 1);
+ source.idealTiles, source.zoomRange, 1);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 1, { 1, 0, 1 } }, NotFound }, // missing ideal tile
CreateTileDataAction{ { 1, { 1, 0, 1 } } }, //
@@ -320,7 +320,7 @@ TEST(UpdateRenderables, DontUseWrongParentTile) {
auto tile_1_1_1_0 = source.createTileData(OverscaledTileID{ 1, 1, 0 });
tile_1_1_1_0->renderable = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 2);
+ source.idealTiles, source.zoomRange, 2);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 2, { 2, 0, 0 } }, NotFound }, // missing ideal tile
CreateTileDataAction{ { 2, { 2, 0, 0 } } }, //
@@ -338,7 +338,7 @@ TEST(UpdateRenderables, DontUseWrongParentTile) {
log.clear();
source.dataTiles[{ 2, { 2, 0, 0 } }]->triedOptional = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 2);
+ source.idealTiles, source.zoomRange, 2);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 2, { 2, 0, 0 } }, Found }, // non-ready ideal tile
RetainTileDataAction{ { 2, { 2, 0, 0 } }, Required }, //
@@ -357,7 +357,7 @@ TEST(UpdateRenderables, DontUseWrongParentTile) {
log.clear();
source.idealTiles.emplace(UnwrappedTileID{ 2, 2, 0 });
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 2);
+ source.idealTiles, source.zoomRange, 2);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 2, { 2, 0, 0 } }, Found }, // non-ready ideal tile
RetainTileDataAction{ { 2, { 2, 0, 0 } }, Required }, //
@@ -402,7 +402,7 @@ TEST(UpdateRenderables, UseParentTileWhenChildNotReady) {
// Make sure that it renders the parent tile.
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 1);
+ source.idealTiles, source.zoomRange, 1);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 1, { 1, 0, 1 } }, Found }, // found, but not ready
RetainTileDataAction{ { 1, { 1, 0, 1 } }, Required }, //
@@ -420,7 +420,7 @@ TEST(UpdateRenderables, UseParentTileWhenChildNotReady) {
log.clear();
tile_1_1_0_1->renderable = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 1);
+ source.idealTiles, source.zoomRange, 1);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 1, { 1, 0, 1 } }, Found }, // found and ready
RetainTileDataAction{ { 1, { 1, 0, 1 } }, Required }, //
@@ -447,7 +447,7 @@ TEST(UpdateRenderables, UseOverlappingParentTile) {
tile_1_1_0_1->renderable = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 1);
+ source.idealTiles, source.zoomRange, 1);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 1, { 1, 0, 0 } }, NotFound }, // ideal tile not found
CreateTileDataAction{ { 1, { 1, 0, 0 } } }, //
@@ -483,7 +483,7 @@ TEST(UpdateRenderables, UseChildTiles) {
tile_1_1_1_0->renderable = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 0);
+ source.idealTiles, source.zoomRange, 0);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 0, { 0, 0, 0 } }, NotFound }, // ideal tile, missing
CreateTileDataAction{ { 0, { 0, 0, 0 } } }, //
@@ -517,7 +517,7 @@ TEST(UpdateRenderables, PreferChildTiles) {
tile_2_2_0_0->renderable = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 1);
+ source.idealTiles, source.zoomRange, 1);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 1, { 1, 0, 0 } }, NotFound }, // ideal tile, not found
CreateTileDataAction{ { 1, { 1, 0, 0 } } }, //
@@ -540,7 +540,7 @@ TEST(UpdateRenderables, PreferChildTiles) {
auto tile_2_2_0_1 = source.createTileData(OverscaledTileID{ 2, 0, 1 });
tile_2_2_0_1->renderable = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 1);
+ source.idealTiles, source.zoomRange, 1);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 1, { 1, 0, 0 } }, Found }, // ideal tile, not ready
// ideal tile was added in previous invocation, but is not yet ready
@@ -563,7 +563,7 @@ TEST(UpdateRenderables, PreferChildTiles) {
auto tile_2_2_1_0 = source.createTileData(OverscaledTileID{ 2, 1, 0 });
tile_2_2_1_0->renderable = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 1);
+ source.idealTiles, source.zoomRange, 1);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 1, { 1, 0, 0 } }, Found }, // ideal tile, not ready
// ideal tile was added in first invocation, but is not yet ready
@@ -589,7 +589,7 @@ TEST(UpdateRenderables, PreferChildTiles) {
auto tile_2_2_1_1 = source.createTileData(OverscaledTileID{ 2, 1, 1 });
tile_2_2_1_1->renderable = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 1);
+ source.idealTiles, source.zoomRange, 1);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 1, { 1, 0, 0 } }, Found }, // ideal tile, not ready
// ideal tile was added in first invocation, but is not yet ready
@@ -627,7 +627,7 @@ TEST(UpdateRenderables, UseParentAndChildTiles) {
// Check that it uses the child tile and the parent tile to cover the rest.
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 1);
+ source.idealTiles, source.zoomRange, 1);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 1, { 1, 0, 0 } }, NotFound }, // ideal tile, missing
CreateTileDataAction{ { 1, { 1, 0, 0 } } }, //
@@ -648,7 +648,7 @@ TEST(UpdateRenderables, UseParentAndChildTiles) {
log.clear();
source.dataTiles.erase(OverscaledTileID{ 2, 0, 0 });
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 1);
+ source.idealTiles, source.zoomRange, 1);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 1, { 1, 0, 0 } }, Found }, // ideal tile, not ready
RetainTileDataAction{ { 1, { 1, 0, 0 } }, Required }, //
@@ -671,14 +671,14 @@ TEST(UpdateRenderables, DontUseTilesLowerThanMinzoom) {
auto retainTileData = retainTileDataFn(log);
auto renderTile = renderTileFn(log);
- source.info.minZoom = 2;
+ source.zoomRange.min = 2;
source.idealTiles.emplace(UnwrappedTileID{ 2, 0, 0 });
auto tile_1_1_0_0 = source.createTileData(OverscaledTileID{ 1, 0, 0 });
tile_1_1_0_0->renderable = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 2);
+ source.idealTiles, source.zoomRange, 2);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 2, { 2, 0, 0 } }, NotFound }, // ideal tile, missing
CreateTileDataAction{ { 2, { 2, 0, 0 } } }, //
@@ -700,14 +700,14 @@ TEST(UpdateRenderables, UseOverzoomedTileAfterMaxzoom) {
auto retainTileData = retainTileDataFn(log);
auto renderTile = renderTileFn(log);
- source.info.maxZoom = 2;
+ source.zoomRange.max = 2;
source.idealTiles.emplace(UnwrappedTileID{ 2, 0, 0 });
// Add a child tile (that should never occur in practice) and make sure it's not selected.
auto tile_3_3_0_0 = source.createTileData(OverscaledTileID{ 3, 0, 0 });
tile_3_3_0_0->renderable = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 2);
+ source.idealTiles, source.zoomRange, 2);
EXPECT_EQ(
ActionLog({
GetTileDataAction{ { 2, { 2, 0, 0 } }, NotFound }, // ideal tile, missing
@@ -723,7 +723,7 @@ TEST(UpdateRenderables, UseOverzoomedTileAfterMaxzoom) {
log.clear();
source.dataTiles[{ 2, { 2, 0, 0 } }]->triedOptional = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 2);
+ source.idealTiles, source.zoomRange, 2);
EXPECT_EQ(
ActionLog({
GetTileDataAction{ { 2, { 2, 0, 0 } }, Found }, // ideal tile, missing
@@ -741,7 +741,7 @@ TEST(UpdateRenderables, UseOverzoomedTileAfterMaxzoom) {
auto tile_2_2_0_0 = source.createTileData(OverscaledTileID{ 2, { 2, 0, 0 } });
tile_2_2_0_0->renderable = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 3);
+ source.idealTiles, source.zoomRange, 3);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 3, { 2, 0, 0 } }, NotFound }, // ideal tile, missing
CreateTileDataAction{ { 3, { 2, 0, 0 } } }, //
@@ -758,7 +758,7 @@ TEST(UpdateRenderables, UseOverzoomedTileAfterMaxzoom) {
auto tile_3_2_0_0 = source.createTileData(OverscaledTileID{ 3, { 2, 0, 0 } });
tile_3_2_0_0->renderable = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 3);
+ source.idealTiles, source.zoomRange, 3);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 3, { 2, 0, 0 } }, Found }, //
RetainTileDataAction{ { 3, { 2, 0, 0 } }, Required }, //
@@ -769,7 +769,7 @@ TEST(UpdateRenderables, UseOverzoomedTileAfterMaxzoom) {
// Check that it's switching back to the tile that has the matching overzoom value.
log.clear();
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 2);
+ source.idealTiles, source.zoomRange, 2);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 2, { 2, 0, 0 } }, Found }, //
RetainTileDataAction{ { 2, { 2, 0, 0 } }, Required }, //
@@ -784,7 +784,7 @@ TEST(UpdateRenderables, UseOverzoomedTileAfterMaxzoom) {
// Use the overzoomed tile even though it doesn't match the zoom level.
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 2);
+ source.idealTiles, source.zoomRange, 2);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 2, { 2, 0, 0 } }, NotFound }, //
CreateTileDataAction{ { 2, { 2, 0, 0 } } }, //
@@ -804,14 +804,14 @@ TEST(UpdateRenderables, AscendToNonOverzoomedTiles) {
auto retainTileData = retainTileDataFn(log);
auto renderTile = renderTileFn(log);
- source.info.maxZoom = 2;
+ source.zoomRange.max = 2;
source.idealTiles.emplace(UnwrappedTileID{ 2, 0, 0 });
// Add a matching overzoomed tile and make sure it gets selected.
auto tile_3_2_0_0 = source.createTileData(OverscaledTileID{ 3, { 2, 0, 0 } });
tile_3_2_0_0->renderable = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 3);
+ source.idealTiles, source.zoomRange, 3);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 3, { 2, 0, 0 } }, Found }, //
RetainTileDataAction{ { 3, { 2, 0, 0 } }, Required }, //
@@ -826,7 +826,7 @@ TEST(UpdateRenderables, AscendToNonOverzoomedTiles) {
auto tile_2_2_0_0 = source.createTileData(OverscaledTileID{ 2, { 2, 0, 0 } });
tile_2_2_0_0->renderable = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 3);
+ source.idealTiles, source.zoomRange, 3);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 3, { 2, 0, 0 } }, NotFound }, //
CreateTileDataAction{ { 3, { 2, 0, 0 } } }, //
@@ -845,7 +845,7 @@ TEST(UpdateRenderables, AscendToNonOverzoomedTiles) {
auto tile_1_1_0_0 = source.createTileData(OverscaledTileID{ 1, { 1, 0, 0 } });
tile_1_1_0_0->renderable = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 3);
+ source.idealTiles, source.zoomRange, 3);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 3, { 2, 0, 0 } }, Found }, // ideal tile, not ready
RetainTileDataAction{ { 3, { 2, 0, 0 } }, Required }, //
@@ -861,7 +861,7 @@ TEST(UpdateRenderables, AscendToNonOverzoomedTiles) {
log.clear();
source.dataTiles[{ 3, { 2, 0, 0 } }]->triedOptional = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 3);
+ source.idealTiles, source.zoomRange, 3);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 3, { 2, 0, 0 } }, Found }, // ideal tile, not ready
RetainTileDataAction{ { 3, { 2, 0, 0 } }, Required }, //
@@ -888,7 +888,7 @@ TEST(UpdateRenderables, DoNotAscendMultipleTimesIfNotFound) {
source.idealTiles.emplace(UnwrappedTileID{ 8, 1, 0 });
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 8);
+ source.idealTiles, source.zoomRange, 8);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 8, { 8, 0, 0 } }, NotFound }, // ideal tile
CreateTileDataAction{ { 8, { 8, 0, 0 } } }, //
@@ -923,7 +923,7 @@ TEST(UpdateRenderables, DoNotAscendMultipleTimesIfNotFound) {
tile_4_0_0_0->renderable = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 8);
+ source.idealTiles, source.zoomRange, 8);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 8, { 8, 0, 0 } }, Found }, // ideal tile, not ready
RetainTileDataAction{ { 8, { 8, 0, 0 } }, Required }, //
@@ -963,7 +963,7 @@ TEST(UpdateRenderables, DontRetainUnusedNonIdealTiles) {
source.createTileData(OverscaledTileID{ 2, 0, 0 });
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 2);
+ source.idealTiles, source.zoomRange, 2);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 2, { 2, 0, 0 } }, Found }, // ideal tile, not ready
RetainTileDataAction{ { 2, { 2, 0, 0 } }, Required }, //
@@ -995,7 +995,7 @@ TEST(UpdateRenderables, WrappedTiles) {
tile_0_0_0_0->renderable = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 1);
+ source.idealTiles, source.zoomRange, 1);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 1, { 1, 1, 0 } }, NotFound }, // ideal tile 1/-1/0
CreateTileDataAction{ { 1, { 1, 1, 0 } } }, //
@@ -1051,7 +1051,7 @@ TEST(UpdateRenderables, RepeatedRenderWithMissingOptionals) {
source.idealTiles.emplace(UnwrappedTileID{ 6, 0, 0 });
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 6);
+ source.idealTiles, source.zoomRange, 6);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 6, { 6, 0, 0 } }, NotFound }, // ideal tile, not found
CreateTileDataAction{ { 6, { 6, 0, 0 } } }, //
@@ -1072,7 +1072,7 @@ TEST(UpdateRenderables, RepeatedRenderWithMissingOptionals) {
// Repeat.
log.clear();
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 6);
+ source.idealTiles, source.zoomRange, 6);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 6, { 6, 0, 0 } }, Found }, // ideal tile, not ready
RetainTileDataAction{ { 6, { 6, 0, 0 } }, Required }, //
@@ -1093,7 +1093,7 @@ TEST(UpdateRenderables, RepeatedRenderWithMissingOptionals) {
log.clear();
source.dataTiles[{ 6, { 6, 0, 0 } }]->triedOptional = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 6);
+ source.idealTiles, source.zoomRange, 6);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 6, { 6, 0, 0 } }, Found }, // ideal tile, not ready
RetainTileDataAction{ { 6, { 6, 0, 0 } }, Required }, //
@@ -1115,7 +1115,7 @@ TEST(UpdateRenderables, RepeatedRenderWithMissingOptionals) {
// Repeat.
log.clear();
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 6);
+ source.idealTiles, source.zoomRange, 6);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 6, { 6, 0, 0 } }, Found }, // ideal tile, not ready
RetainTileDataAction{ { 6, { 6, 0, 0 } }, Required }, //
@@ -1137,7 +1137,7 @@ TEST(UpdateRenderables, RepeatedRenderWithMissingOptionals) {
log.clear();
source.dataTiles[{ 5, { 5, 0, 0 } }]->triedOptional = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 6);
+ source.idealTiles, source.zoomRange, 6);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 6, { 6, 0, 0 } }, Found }, // ideal tile, not ready
RetainTileDataAction{ { 6, { 6, 0, 0 } }, Required }, //
@@ -1161,7 +1161,7 @@ TEST(UpdateRenderables, RepeatedRenderWithMissingOptionals) {
log.clear();
source.dataTiles[{ 4, { 4, 0, 0 } }]->triedOptional = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 6);
+ source.idealTiles, source.zoomRange, 6);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 6, { 6, 0, 0 } }, Found }, // ideal tile, not ready
RetainTileDataAction{ { 6, { 6, 0, 0 } }, Required }, //
@@ -1186,7 +1186,7 @@ TEST(UpdateRenderables, RepeatedRenderWithMissingOptionals) {
log.clear();
source.dataTiles[{ 3, { 3, 0, 0 } }]->triedOptional = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 6);
+ source.idealTiles, source.zoomRange, 6);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 6, { 6, 0, 0 } }, Found }, // ideal tile, not ready
RetainTileDataAction{ { 6, { 6, 0, 0 } }, Required }, //
@@ -1213,7 +1213,7 @@ TEST(UpdateRenderables, RepeatedRenderWithMissingOptionals) {
auto tile_3_3_0_0 = source.dataTiles[{ 3, { 3, 0, 0 } }].get();
tile_3_3_0_0->renderable = true;
algorithm::updateRenderables(getTileData, createTileData, retainTileData, renderTile,
- source.idealTiles, source.info, 6);
+ source.idealTiles, source.zoomRange, 6);
EXPECT_EQ(ActionLog({
GetTileDataAction{ { 6, { 6, 0, 0 } }, Found }, // ideal tile, not ready
RetainTileDataAction{ { 6, { 6, 0, 0 } }, Required }, //
diff --git a/test/storage/offline.cpp b/test/storage/offline.cpp
index 06789cd828..0faaabc298 100644
--- a/test/storage/offline.cpp
+++ b/test/storage/offline.cpp
@@ -1,5 +1,4 @@
#include <mbgl/storage/offline.hpp>
-#include <mbgl/util/tileset.hpp>
#include <mbgl/tile/tile_id.hpp>
#include <gtest/gtest.h>
@@ -14,49 +13,42 @@ static const LatLngBounds sanFranciscoWrapped =
TEST(OfflineTilePyramidRegionDefinition, TileCoverEmpty) {
OfflineTilePyramidRegionDefinition region("", LatLngBounds::empty(), 0, 20, 1.0);
- Tileset tileset;
- EXPECT_EQ((std::vector<CanonicalTileID>{}), region.tileCover(SourceType::Vector, 512, tileset));
+ EXPECT_EQ((std::vector<CanonicalTileID>{}), region.tileCover(SourceType::Vector, 512, { 0, 22 }));
}
TEST(OfflineTilePyramidRegionDefinition, TileCoverZoomIntersection) {
OfflineTilePyramidRegionDefinition region("", sanFrancisco, 2, 2, 1.0);
- Tileset tileset;
- tileset.minZoom = 0;
EXPECT_EQ((std::vector<CanonicalTileID>{ { 2, 0, 1 } }),
- region.tileCover(SourceType::Vector, 512, tileset));
+ region.tileCover(SourceType::Vector, 512, { 0, 22 }));
- tileset.minZoom = 3;
- EXPECT_EQ((std::vector<CanonicalTileID>{}), region.tileCover(SourceType::Vector, 512, tileset));
+ EXPECT_EQ((std::vector<CanonicalTileID>{}), region.tileCover(SourceType::Vector, 512, { 3, 22 }));
}
TEST(OfflineTilePyramidRegionDefinition, TileCoverTileSize) {
OfflineTilePyramidRegionDefinition region("", LatLngBounds::world(), 0, 0, 1.0);
- Tileset tileset;
EXPECT_EQ((std::vector<CanonicalTileID>{ { 0, 0, 0 } }),
- region.tileCover(SourceType::Vector, 512, tileset));
+ region.tileCover(SourceType::Vector, 512, { 0, 22 }));
EXPECT_EQ((std::vector<CanonicalTileID>{ { 1, 0, 0 }, { 1, 0, 1 }, { 1, 1, 0 }, { 1, 1, 1 } }),
- region.tileCover(SourceType::Vector, 256, tileset));
+ region.tileCover(SourceType::Vector, 256, { 0, 22 }));
}
TEST(OfflineTilePyramidRegionDefinition, TileCoverZoomRounding) {
OfflineTilePyramidRegionDefinition region("", sanFrancisco, 0.6, 0.7, 1.0);
- Tileset tileset;
EXPECT_EQ((std::vector<CanonicalTileID>{ { 0, 0, 0 } }),
- region.tileCover(SourceType::Vector, 512, tileset));
+ region.tileCover(SourceType::Vector, 512, { 0, 22 }));
EXPECT_EQ((std::vector<CanonicalTileID>{ { 1, 0, 0 } }),
- region.tileCover(SourceType::Raster, 512, tileset));
+ region.tileCover(SourceType::Raster, 512, { 0, 22 }));
}
TEST(OfflineTilePyramidRegionDefinition, TileCoverWrapped) {
OfflineTilePyramidRegionDefinition region("", sanFranciscoWrapped, 0, 0, 1.0);
- Tileset tileset;
EXPECT_EQ((std::vector<CanonicalTileID>{ { 0, 0, 0 } }),
- region.tileCover(SourceType::Vector, 512, tileset));
+ region.tileCover(SourceType::Vector, 512, { 0, 22 }));
}
diff --git a/test/style/style_parser.cpp b/test/style/style_parser.cpp
index aba5ec67bd..02a4077ab9 100644
--- a/test/style/style_parser.cpp
+++ b/test/style/style_parser.cpp
@@ -93,8 +93,8 @@ TEST(StyleParser, ParseTileJSONRaster) {
SourceType::Raster,
256);
- EXPECT_EQ(0, result->minZoom);
- EXPECT_EQ(15, result->maxZoom);
+ EXPECT_EQ(0, result->zoomRange.min);
+ EXPECT_EQ(15, result->zoomRange.max);
EXPECT_EQ("attribution", result->attribution);
#if !defined(__ANDROID__) && !defined(__APPLE__)
EXPECT_EQ("mapbox://tiles/mapbox.satellite/{z}/{x}/{y}{ratio}.webp", result->tiles[0]);
@@ -110,8 +110,8 @@ TEST(StyleParser, ParseTileJSONVector) {
SourceType::Vector,
256);
- EXPECT_EQ(0, result->minZoom);
- EXPECT_EQ(15, result->maxZoom);
+ EXPECT_EQ(0, result->zoomRange.min);
+ EXPECT_EQ(15, result->zoomRange.max);
EXPECT_EQ("attribution", result->attribution);
EXPECT_EQ("mapbox://tiles/mapbox.streets/{z}/{x}/{y}.vector.pbf", result->tiles[0]);
}