[core] only show parent XOR child tiles

Since label rendering isn't clipped, having a parent tile, and only a handful of child tiles loaded may result in some labels being rendered twice (from the parent tile, and the up to three child tiles that necessitate the parent tile remaining in the list). This patch makes sure that in one location, it only ever renders one set of labels, by favoring the parent tile until all required child tiles have been loaded.
This commit is contained in:
Konstantin Käfer
2015-10-12 14:46:47 +02:00
parent 3f6422ea64
commit e3d9fb1715

View File

@@ -352,6 +352,25 @@ std::vector<RenderItem> Painter::determineRenderOrder(const Style& style) {
continue;
}
// We're not clipping symbol layers, so when we have both parents and children of symbol
// layers, we drop all children in favor of their parent to avoid duplicate labels.
// See https://github.com/mapbox/mapbox-gl-native/issues/2482
if (layer.type == StyleLayerType::Symbol) {
bool skip = false;
// Look back through the buckets we decided to render to find out whether there is
// already a bucket from this layer that is a parent of this tile. Tiles are ordered
// by zoom level when we obtain them from getTiles().
for (auto it = order.rbegin(); it != order.rend() && (&it->layer == &layer); ++it) {
if (tile->id.isChildOf(it->tile->id)) {
skip = true;
break;
}
}
if (skip) {
continue;
}
}
auto bucket = tile->data->getBucket(layer);
if (bucket) {
order.emplace_back(layer, tile, bucket);