Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Commit 667a08f

Browse files
committed
[core] Tile cover LOD: lod covers single level tile cover
Unit test verifies that, with different camera parameters combinations LOD tile cover covers all tiles returned by single level tileCover.
1 parent b128895 commit 667a08f

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/mbgl/util/tile_cover.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ std::vector<UnwrappedTileID> tileCoverWithLOD(const TransformState& state, int32
181181

182182
const auto offset = state.getCenterOffset();
183183
constexpr double zoomDiff = 1.0;
184+
// Explanation on 0.55: mathematically, it is 0.5 used in calculation of
185+
// the next LOD. 0.55 is chosen to avoid using LOD for less than 60 degrees
186+
// pitch.
184187
constexpr double coefLOD[] = {
185188
0.55 * zoomDiff / (zoomDiff + 1),
186189
0.55 * (zoomDiff + 1) / (zoomDiff + 2),

test/util/tile_cover.test.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,35 @@ TEST(TileCover, PitchWithLargerResultSet) {
7878
}), (std::vector<UnwrappedTileID> { cover.begin(), cover.begin() + 16}) );
7979
}
8080

81+
TEST(TileCover, TileCoverLODCoversSingleLevelTileCover) {
82+
Transform transform;
83+
transform.resize({ 512, 768 });
84+
85+
std::vector<EdgeInsets> padding = { EdgeInsets { 0, 100, 0, 0 }, EdgeInsets { 800, 0, 0, 0 } };
86+
std::vector<int32_t> zoom = { 14, 22 };
87+
std::vector<double> bearing = { 2, 45, -22.5 };
88+
std::vector<double> pitch = { 0, 30, 90 };
89+
90+
for (auto pad : padding) {
91+
for (auto z : zoom) {
92+
for (auto bear : bearing) {
93+
for (auto p : pitch) {
94+
transform.jumpTo(CameraOptions().withCenter(LatLng { 0.1, -0.1 })
95+
.withPadding(pad).withZoom(z).withBearing(bear).withPitch(p));
96+
auto singleLevelCover = util::tileCover(transform.getState(), z);
97+
auto lodTileCover = util::tileCoverWithLOD(transform.getState(), z, z / 10 * 10);
98+
for (auto tile: singleLevelCover) {
99+
EXPECT_NE(lodTileCover.cend(), std::find_if(lodTileCover.cbegin(), lodTileCover.cend(),
100+
[&tile] (auto parent) { return tile == parent || tile.isChildOf(parent); })) << "for padding: ["
101+
<< pad.top() << ", " << pad.left() << ", 0, 0] zoom:" << z << " bearing:"
102+
<< bear << " and pitch:" << p;
103+
}
104+
}
105+
}
106+
}
107+
}
108+
}
109+
81110
TEST(TileCover, WorldZ1) {
82111
EXPECT_EQ((std::vector<UnwrappedTileID>{
83112
{ 1, 0, 0 }, { 1, 0, 1 }, { 1, 1, 0 }, { 1, 1, 1 },

0 commit comments

Comments
 (0)