-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set tile#queryPadding per layer #6909
Conversation
src/source/tile.js
Outdated
@@ -434,7 +435,8 @@ class Tile { | |||
|
|||
bucket.update(sourceLayerStates, sourceLayer); | |||
if (painter && painter.style) { | |||
this.queryPadding = Math.max(this.queryPadding, painter.style.getLayer(bucket.layerIds[0]).queryRadius(bucket)); | |||
const index = bucket.layerIds.indexOf(id); | |||
this.queryPadding = Math.max(this.queryPadding, painter.style.getLayer(bucket.layerIds[index]).queryRadius(bucket)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
layerIds[layerIds.indexOf(id)]
is simply id
, so no need to do indexOf
lookups in both places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a query integration test for this as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix looks good but I have a question about the query test.
What is the query test trying to cover? Would it need multiple layers with different line-widths or something like that in order to test the bug this pr fixes?
The query test isn't working as is @ansis. I committed it just to have my most up to date work in the PR. I haven't written one before and was confused about some of the behavior and what would be the best way to write it. I'm definitely open to suggestions on the best way to test this. I assumed that |
1a885bc
to
1f19d34
Compare
@ansis I finally got around to fixing the query test for this. It's just checking that a feature is found under the query geometry in the case where you have two features in the same bucket. I verified that this test is correct by reverting the fix and confirming that the test fails. So I think this PR is good to go now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Query Tests are 👍
9c613f6
to
a99c168
Compare
Launch Checklist
queryPadding
was always being calculated based on the first layer in a bucket which resulted in a bug in which two layers using the same source could introduce the bug seen in the ticketqueryPadding
to be calculated for each layer in a bucket