-
-
Notifications
You must be signed in to change notification settings - Fork 779
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
Transform specific projectPoint
#5267
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5267 +/- ##
==========================================
- Coverage 91.84% 91.83% -0.01%
==========================================
Files 281 281
Lines 38856 38864 +8
Branches 6793 6795 +2
==========================================
+ Hits 35686 35690 +4
- Misses 3043 3046 +3
- Partials 127 128 +1 ☔ View full report in Codecov by Sentry. |
While this may solve this case, I'm not sure it will solve the cases for other layers. maplibre-gl-js/src/source/query_features.ts Lines 61 to 70 in 9fc7e73
It is part of the code path that causes this bug as far as I understand. |
I've tried to test this code with: |
@@ -462,6 +462,11 @@ export interface IReadonlyTransform extends ITransformGetters { | |||
*/ | |||
projectTileCoordinates(x: number, y: number, unwrappedTileID: UnwrappedTileID, getElevation: (x: number, y: number) => number): PointProjection; | |||
|
|||
/** | |||
* Projects a point in screen coordinates to tile coordinates |
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.
I'm confused by this doccomment, I think the implementation in vertical_perspective_transform.ts
does something different than what this comment states it should do.
I've taken a look at the queryFeatures code and this is what I found:
The main problem is that the projection from tile coordinates to screen pixels cannot be described by a matrix when globe projection is active, so all the queryFeatures-related code needs to be changed to get correct results. |
I think that instead of correctly projecting all features to screen space for globe, a better appoach would be to project the query geometry to mercator coordinates or tile space and approximate it with some polygon (since it will get curved by the projection), and then query features against that. The reason is that projecting from tile space to globe is slower than projecting from tile space to mercator coordinates, so we want to prefer the other projection where possible, and bulk of the projecting will be done for the features. |
The question is about all kind of transformation related to screen space like circle radius, circle offset, the padding that is used in pixels, all of those are in screen space so there is a conversation back and forth. I added some comments recently to help understand in which domain the coordinates are, but it's confusing. |
This PR is my first take on fixing #5255
It moves circle-layer specific projection code to each transform to make it transform-aware.
Globe projection is implemented using the view projection matrix, which works as a simple approximation
Before (Notice how the cursor changes to a hand when the underlying feature is detected)
Screen.Recording.2024-12-24.at.18.13.16.mov
After
Screen.Recording.2024-12-24.at.18.11.10__.mov
@kubapelc I'd love if you could take this PR and follow along with a more exact implementation if you have time
Launch Checklist
CHANGELOG.md
under the## main
section.