Repository navigation
Fix queryRenderedFeatures for symbol features - #3459
Conversation
|
Possible fix for #2647. |
mourner
left a comment
There was a problem hiding this comment.
Looks great to me, let's 🚢 after addressing my minor remarks.
| sourceLayerFeatures[sourceLayer] = {}; | ||
| } | ||
| return sourceLayerFeatures[sourceLayer][featureIndex] === true; | ||
| } |
There was a problem hiding this comment.
Since this function does not need any variables from the outer scope (it gets everything it needs from arguments), move it out to the top level scope. This way you avoid the cost of setting up a closure on every call of queryRenderedSymbols.
| // Check if feature is rendered (collision free) at current scale. | ||
| function visibleAtScale(blocking, roundedScale) { | ||
| return roundedScale >= blocking.placementScale && roundedScale <= blocking.maxScale; | ||
| } |
| new Point(x1, y2) | ||
| ]; | ||
| return intersectionTests.polygonIntersectsPolygon(rotatedQuery, bbox); | ||
| } |
There was a problem hiding this comment.
And this one too, if you pass bbox as an argument.
| @@ -0,0 +1,52 @@ | |||
| 'use strict'; | |||
There was a problem hiding this comment.
Can these be consolidated with util/intersection_tests.js?
There was a problem hiding this comment.
Oh my - totally missed this - yes we can certainly reuse it 👍
af691b4 to
b1cb5a0
Compare
b1cb5a0 to
b876b1b
Compare
|
Thank you @mourner and @jfirebaugh for the review - I've addressed the requested changes. |
b876b1b to
c8d04a6
Compare
c8d04a6 to
b68f607
Compare
|
@mourner it turns out those functions made more sense in GL native context because we were using them as predicates for |
Use the query geometry as polygon for intersecting with symbol features collision box. Fixes situations where e.g. unseen features were returned or vice-versa.
This PR is a port from GL native (see mapbox/mapbox-gl-native#6773).
Query test
symbol-features-in/pitched-screen(#3447) should be passing now, but because the feature order differs from GL native, the test fails. We should probably sort features by latitude/longitude prior to JSON comparison.Benchmark reports are within standard deviation:

/cc @ansis @jfirebaugh @mourner