Skip to content

Commit

Permalink
Only run placement for first layer per SymbolBucket.
Browse files Browse the repository at this point in the history
Fixes issue #6548.
Restores behavior from before PR #5150 -- all layers that share the same bucket (and thus same layout properties) share the same placement.
Before this fix, two layers with the same layout properties could collide against each other, and because they shared CrossTileIDs, _both_ layers could end up hidden.
  • Loading branch information
ChrisLoer committed Apr 25, 2018
1 parent a56e6c7 commit dfed05e
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/symbol/cross_tile_symbol_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ class CrossTileSymbolIndex {

for (const tile of tiles) {
const symbolBucket = ((tile.getBucket(styleLayer): any): SymbolBucket);
if (!symbolBucket) continue;
if (!symbolBucket || styleLayer.id !== symbolBucket.layerIds[0])
continue;

if (!symbolBucket.bucketInstanceId) {
symbolBucket.bucketInstanceId = ++this.maxBucketInstanceId;
Expand Down
4 changes: 2 additions & 2 deletions src/symbol/placement.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class Placement {
placeLayerTile(styleLayer: StyleLayer, tile: Tile, showCollisionBoxes: boolean, seenCrossTileIDs: { [string | number]: boolean }) {
const symbolBucket = ((tile.getBucket(styleLayer): any): SymbolBucket);
const bucketFeatureIndex = tile.latestFeatureIndex;
if (!symbolBucket || !bucketFeatureIndex)
if (!symbolBucket || !bucketFeatureIndex || styleLayer.id !== symbolBucket.layerIds[0])
return;

const collisionBoxArray = tile.collisionBoxArray;
Expand Down Expand Up @@ -306,7 +306,7 @@ export class Placement {

for (const tile of tiles) {
const symbolBucket = ((tile.getBucket(styleLayer): any): SymbolBucket);
if (symbolBucket && tile.latestFeatureIndex) {
if (symbolBucket && tile.latestFeatureIndex && styleLayer.id === symbolBucket.layerIds[0]) {
this.updateBucketOpacities(symbolBucket, seenCrossTileIDs, tile.collisionBoxArray);
}
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"version": 8,
"metadata": {
"test": {
"height": 64,
"width": 128
}
},
"center": [
0,
0
],
"zoom": 0,
"sources": {
"point": {
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
0,
0
]
}
}
]
}
}
},
"glyphs": "local://glyphs/{fontstack}/{range}.pbf",
"layers": [
{
"id": "text1",
"type": "symbol",
"source": "point",
"layout": {
"text-field": "Rendered Twice",
"text-font": [
"Open Sans Semibold",
"Arial Unicode MS Bold"
]
}
},
{
"id": "text2",
"type": "symbol",
"source": "point",
"layout": {
"text-field": "Rendered Twice",
"text-font": [
"Open Sans Semibold",
"Arial Unicode MS Bold"
]
}
}
]
}
3 changes: 2 additions & 1 deletion test/unit/symbol/cross_tile_symbol_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ function makeSymbolInstance(x, y, key) {

function makeTile(tileID, symbolInstances) {
const bucket = {
symbolInstances: symbolInstances
symbolInstances: symbolInstances,
layerIds: ['test']
};
return {
tileID: tileID,
Expand Down

0 comments on commit dfed05e

Please sign in to comment.