Skip to content
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 text placement line hit detection for pixelRatio !== 1 #15001

Merged

Conversation

ahocevar
Copy link
Member

@ahocevar ahocevar commented Aug 12, 2023

This pull request makes the recently added tests for hit detection of line placement texts better readable.

This pull request fixes the pixel ratio problem identified by the new text fill tests.

@github-actions
Copy link

📦 Preview the website for this branch here: https://deploy-preview-15001--ol-site.netlify.app/.

@mike-000
Copy link
Contributor

mike-000 commented Aug 12, 2023

First test has no fill but detects wide stroke
Second test has no fill and thin stroke, detects nothing
Third test detects transparent fill

For the tests to pass use pixelRatio: 1 in the map options.

@ahocevar
Copy link
Member Author

@mike-000 This looks fishy. Only the third test fails. If there is something wrong with pixel ratio handling for text hit detection, I would expect all three tests to fail on a device with a pixel ratio of 2.

@ahocevar ahocevar force-pushed the text-placement-line-transparent-fill branch from 7021250 to 070d860 Compare August 12, 2023 21:49
@mike-000
Copy link
Contributor

@mike-000 This looks fishy. Only the third test fails. If there is something wrong with pixel ratio handling for text hit detection, I would expect all three tests to fail on a device with a pixel ratio of 2.

The wide stroke in the first test would extend outwards as well as into the center of the character - just enough to get a hit a [50, 50] even though the hit detection image was misplaced. Increase the pixel ratio beyond 2 the misplacement increases and it also would fail.

@ahocevar
Copy link
Member Author

@mike-000 Nevermind. I'm looking into a fix for the pixel ratio issue now.

@ahocevar ahocevar changed the title Improve readability of text placement line hit detection test Fix text placement line hit detection for pixelRatio !== 1 Aug 13, 2023
@ahocevar
Copy link
Member Author

This is now ready for review. For those who have been following: I re-purposed this pull request to not only make the tests more readable, but fix the pixel ratio issue I encountered when running the tests on a system with a device pixel ratio other than 1.

Copy link
Member

@tschaub tschaub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work on this, @ahocevar

@ahocevar ahocevar merged commit 22651fc into openlayers:main Aug 13, 2023
@ahocevar ahocevar deleted the text-placement-line-transparent-fill branch August 13, 2023 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants