summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-02-25 15:16:38 +0100
committerKonstantin Käfer <mail@kkaefer.com>2016-02-25 15:24:45 +0100
commitf9fd748547ce49d6e1b7174d7f511ccc2264166a (patch)
treee32bdf018d247172ab6dce2e32ada0bf55e6dc68 /src
parenta5b39f5ae1a96cc2cb5555709053bc53968e824a (diff)
downloadqtlocation-mapboxgl-f9fd748547ce49d6e1b7174d7f511ccc2264166a.tar.gz
[core] abort searching children when lower bound has different w
When looking for child tiles that cover a parent tile, we're computing the lower bound of the child tile in the set of tiles. Three things can happen: - all remaining tiles are sorted before the child tile we're looking for. in that case, there can not be a child tile. - the lower bound is the child tile; in this case, we want to continue checking the other children of the parent tile. - the lower bound isn't the child tile we're looking for, but there are still tiles sorted after the tile we were looking for. these could be four children of the child tile we're looking for, so we're recursively descending. what the current algorithm didn't take into account so far is that tiles with a higher w number (i.e. tiles that are outside the "main" tile pyramid of 0/0/0) were always sorted *after* the current w number. this meant that we thought there were still remaining children to be checked, so continued our recursive descent until eventually the number overflowed and we aborted our search. unfortunately, on Android this recursive descent and accompanying overflow caused a crash. this patch fixes this by making sure that before we're continuing to descent, we're sure that the w numbers match: all tiles with a different (= higher) w number essentially mean the same as "all remaining tiles are sorted before the child tile we're looking for" for the purpose of finding covering children
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/util/clip_id.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/mbgl/util/clip_id.cpp b/src/mbgl/util/clip_id.cpp
index 47a5877bb6..0da8a890ce 100644
--- a/src/mbgl/util/clip_id.cpp
+++ b/src/mbgl/util/clip_id.cpp
@@ -101,7 +101,7 @@ template <typename Container>
bool coveredByChildren(const TileID& id, const Container& container) {
for (const auto& child : id.children()) {
const auto lower = container.lower_bound(child);
- if (lower == container.end() ||
+ if (lower == container.end() || lower->first.w != child.w ||
(lower->first != child && !coveredByChildren(child, container))) {
return false;
}