diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2018-07-11 22:32:51 +0300 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2018-07-24 09:18:19 +0300 |
commit | 1683da3225d0cbed3bb6238fd292fa288f6a32d6 (patch) | |
tree | 5069a3e1e29fc99e27f3a7d7decb6abb8bee9bb7 /src/mbgl | |
parent | bcc93baeb152bf3f0b5540cfd08e989bc1b032a7 (diff) | |
download | qtlocation-mapboxgl-1683da3225d0cbed3bb6238fd292fa288f6a32d6.tar.gz |
[core] coveredByChildren is false if at least one child is uncovered
Diffstat (limited to 'src/mbgl')
-rw-r--r-- | src/mbgl/algorithm/covered_by_children.hpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/mbgl/algorithm/covered_by_children.hpp b/src/mbgl/algorithm/covered_by_children.hpp index ad2f1dd5dd..fe5af3f3db 100644 --- a/src/mbgl/algorithm/covered_by_children.hpp +++ b/src/mbgl/algorithm/covered_by_children.hpp @@ -8,15 +8,23 @@ namespace algorithm { template <typename Iterator> bool coveredByChildren(const UnwrappedTileID& id, Iterator it, const Iterator& end) { for (const auto& child : id.children()) { - it = std::lower_bound(it, end, child, [](auto& a, auto& b) { return std::get<0>(a) < b; }); + it = std::lower_bound(it, end, child, [](const auto& a, const auto& b) { return std::get<0>(a) < b; }); + + // Child is not present, neither its grandchildren. if (it == end) { return false; - } else if (std::get<0>(*it) != child) { - return coveredByChildren(child, it, end); + } + + // Child is not present, but its grandchildren are. + if (std::get<0>(*it) != child) { + // This child is not covered by its grandchildren. + if (!coveredByChildren(child, it, end)) { + return false; + } } } - // We looked at all four immediate children and verified that they're covered. + // We looked at all four children (recursively) and verified that they're covered. return true; } |