-
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
Fix incorrect textPixelRatio argument #6135
Conversation
Closes #6075 `textPixelRatio` is used to scale tile coordinates to viewport coordinates; the value that was being passed here, EXTENT / tileSize, was the reciprocal of the ratio needed -- we were passing 16 instead of 0.0625. As a result, the corners of the viewport-projected collision box that we reconstructed here, https://github.com/mapbox/mapbox-gl-js/blob/f13c86ea356c384fdab31855b9152f5bf5ef97b8/src/symbol/collision_index.js#L322-L325, were 16^2 times farther from the anchor than they should have been. With `icon-offset: [0, 0]`, this didn't matter, because the incorrectly large box would contain the (much smaller) correct box. But when there's an offset, it too gets scaled too much, and so we run out of luck.
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.
🤦♂️ Good catch @anandthakker. This textPixelRatio
has always been incorrect, but it used to be masked by us inverting the tileToViewport
parameter. When I fixed that in #5913, I missed this.
Although this change is the simplest fix, it's worth noting that on gl-native we skipped this issue entirely by storing viewport coordinates in the |
* Add failing test for issue mapbox#6075 * Fix incorrect textPixelRatio argument Closes mapbox#6075 `textPixelRatio` is used to scale tile coordinates to viewport coordinates; the value that was being passed here, EXTENT / tileSize, was the reciprocal of the ratio needed -- we were passing 16 instead of 0.0625. As a result, the corners of the viewport-projected collision box that we reconstructed here, https://github.com/mapbox/mapbox-gl-js/blob/f13c86ea356c384fdab31855b9152f5bf5ef97b8/src/symbol/collision_index.js#L322-L325, were 16^2 times farther from the anchor than they should have been. With `icon-offset: [0, 0]`, this didn't matter, because the incorrectly large box would contain the (much smaller) correct box. But when there's an offset, it too gets scaled too much, and so we run out of luck.
* Add failing test for issue mapbox#6075 * Fix incorrect textPixelRatio argument Closes mapbox#6075 `textPixelRatio` is used to scale tile coordinates to viewport coordinates; the value that was being passed here, EXTENT / tileSize, was the reciprocal of the ratio needed -- we were passing 16 instead of 0.0625. As a result, the corners of the viewport-projected collision box that we reconstructed here, https://github.com/mapbox/mapbox-gl-js/blob/f13c86ea356c384fdab31855b9152f5bf5ef97b8/src/symbol/collision_index.js#L322-L325, were 16^2 times farther from the anchor than they should have been. With `icon-offset: [0, 0]`, this didn't matter, because the incorrectly large box would contain the (much smaller) correct box. But when there's an offset, it too gets scaled too much, and so we run out of luck.
Closes #6075
textPixelRatio
is used to scale tile coordinates to viewport coordinates; the value that was being passed here, EXTENT / tileSize, was the reciprocal of the ratio needed -- we were passing 16 instead of 0.0625.As a result, the corners of the viewport-projected collision box that we reconstructed here,
mapbox-gl-js/src/symbol/collision_index.js
Lines 322 to 325 in f13c86e
icon-offset: [0, 0]
, this didn't matter, because the incorrectly large box would contain the (much smaller) correct box. But when there's an offset, it too gets scaled too much, and so we run out of luck.