Skip to content

Commit

Permalink
Include bucketIndex in queryRenderedSymbols duplicate feature filter
Browse files Browse the repository at this point in the history
Fixes issue #5172: items from multiple layers but sharing a common source feature would only show up in queryRenderedSymbols results for one of the layers.
  • Loading branch information
ChrisLoer committed Nov 17, 2017
1 parent 46b8566 commit 6156297
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/symbol/collision_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,18 @@ class CollisionIndex {
const blocking = collisionBoxArray.get(thisTileFeatures[i]);
const sourceLayer = blocking.sourceLayerIndex;
const featureIndex = blocking.featureIndex;
const bucketIndex = blocking.bucketIndex;

// Skip already seen features.
if (sourceLayerFeatures[sourceLayer] === undefined) {
sourceLayerFeatures[sourceLayer] = {};
}
if (sourceLayerFeatures[sourceLayer][featureIndex]) continue;

if (sourceLayerFeatures[sourceLayer][featureIndex] === undefined) {
sourceLayerFeatures[sourceLayer][featureIndex] = {};
}
if (sourceLayerFeatures[sourceLayer][featureIndex][bucketIndex]) {
continue;
}

// Check if query intersects with the feature box
// "Collision Circles" for line labels are treated as boxes here
Expand All @@ -292,9 +297,11 @@ class CollisionIndex {
new Point(x2, y2),
new Point(x1, y2)
];
if (!intersectionTests.polygonIntersectsPolygon(query, bbox)) continue;
if (!intersectionTests.polygonIntersectsPolygon(query, bbox)) {
continue;
}

sourceLayerFeatures[sourceLayer][featureIndex] = true;
sourceLayerFeatures[sourceLayer][featureIndex][bucketIndex] = true;
result.push(thisTileFeatures[i]);
}

Expand Down

0 comments on commit 6156297

Please sign in to comment.