summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksandar Stojiljkovic <aleksandar.stojiljkovic@mapbox.com>2019-08-05 18:16:26 +0300
committerAleksandar Stojiljkovic <aleksandar.stojiljkovic@mapbox.com>2019-08-05 20:40:30 +0300
commit667a08f6fc19e7b9ca679298ad33f1986e93efd9 (patch)
treed8791213177cd5bb02d1852b425581702b17de8f
parentb12889539e9e92a48360e536d11abf95b6513690 (diff)
downloadqtlocation-mapboxgl-upstream/astojilj-lod.tar.gz
[core] Tile cover LOD: lod covers single level tile coverupstream/astojilj-lod
Unit test verifies that, with different camera parameters combinations LOD tile cover covers all tiles returned by single level tileCover.
-rw-r--r--src/mbgl/util/tile_cover.cpp3
-rw-r--r--test/util/tile_cover.test.cpp29
2 files changed, 32 insertions, 0 deletions
diff --git a/src/mbgl/util/tile_cover.cpp b/src/mbgl/util/tile_cover.cpp
index 11e1a97f4c..32e76c4214 100644
--- a/src/mbgl/util/tile_cover.cpp
+++ b/src/mbgl/util/tile_cover.cpp
@@ -181,6 +181,9 @@ std::vector<UnwrappedTileID> tileCoverWithLOD(const TransformState& state, int32
const auto offset = state.getCenterOffset();
constexpr double zoomDiff = 1.0;
+ // Explanation on 0.55: mathematically, it is 0.5 used in calculation of
+ // the next LOD. 0.55 is chosen to avoid using LOD for less than 60 degrees
+ // pitch.
constexpr double coefLOD[] = {
0.55 * zoomDiff / (zoomDiff + 1),
0.55 * (zoomDiff + 1) / (zoomDiff + 2),
diff --git a/test/util/tile_cover.test.cpp b/test/util/tile_cover.test.cpp
index e35e6e2e99..1bafc8b4ec 100644
--- a/test/util/tile_cover.test.cpp
+++ b/test/util/tile_cover.test.cpp
@@ -78,6 +78,35 @@ TEST(TileCover, PitchWithLargerResultSet) {
}), (std::vector<UnwrappedTileID> { cover.begin(), cover.begin() + 16}) );
}
+TEST(TileCover, TileCoverLODCoversSingleLevelTileCover) {
+ Transform transform;
+ transform.resize({ 512, 768 });
+
+ std::vector<EdgeInsets> padding = { EdgeInsets { 0, 100, 0, 0 }, EdgeInsets { 800, 0, 0, 0 } };
+ std::vector<int32_t> zoom = { 14, 22 };
+ std::vector<double> bearing = { 2, 45, -22.5 };
+ std::vector<double> pitch = { 0, 30, 90 };
+
+ for (auto pad : padding) {
+ for (auto z : zoom) {
+ for (auto bear : bearing) {
+ for (auto p : pitch) {
+ transform.jumpTo(CameraOptions().withCenter(LatLng { 0.1, -0.1 })
+ .withPadding(pad).withZoom(z).withBearing(bear).withPitch(p));
+ auto singleLevelCover = util::tileCover(transform.getState(), z);
+ auto lodTileCover = util::tileCoverWithLOD(transform.getState(), z, z / 10 * 10);
+ for (auto tile: singleLevelCover) {
+ EXPECT_NE(lodTileCover.cend(), std::find_if(lodTileCover.cbegin(), lodTileCover.cend(),
+ [&tile] (auto parent) { return tile == parent || tile.isChildOf(parent); })) << "for padding: ["
+ << pad.top() << ", " << pad.left() << ", 0, 0] zoom:" << z << " bearing:"
+ << bear << " and pitch:" << p;
+ }
+ }
+ }
+ }
+ }
+}
+
TEST(TileCover, WorldZ1) {
EXPECT_EQ((std::vector<UnwrappedTileID>{
{ 1, 0, 0 }, { 1, 0, 1 }, { 1, 1, 0 }, { 1, 1, 1 },