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

Add a debug page for globe getBounds #12199

Merged
merged 1 commit into from
Aug 29, 2022
Merged

Conversation

mourner
Copy link
Member

@mourner mourner commented Aug 29, 2022

Adds debug/globe-bounds.html page for debugging getBounds with the globe projection, splitting the view into two maps, where blue is the outline of the view of the left map, and red is what getBounds returns (while ideally red should encompass blue), and also a marker that shows the same location when you move the mouse on the left.

image

Some points while investigating this for future reference:

  • Currently we calculate bounds based on a bbox of 4 corners of the view. Doing the same for globe doesn't work even if we extend the number of points (e.g. add the middle points on either side) — the extremums can be at any point of the side, especially when you take rotation and pitch into account. E.g. on the above screenshot, the topmost bbox latitude is somewhere in the bottom third of the screen near Svalbard.
  • If we want precise bounds, we'd likely need to calculate frustum plane vs sphere intersections. The math might get pretty complicated there — I couldn't come up with the right calculations here. Aside from maximum of 4 plane-sphere intersections, there might be up to 4 "arcs" (where you see the horizon of the globe).
  • Alternatively, we could do adaptive bounds calculation similar to the one happening in tile_transform.js for alternative projections — start with 4 corners, and delve recursively into midpoints while they stray too much from Euclidean midpoints. This might still produce a noticeable error, but will at least be a significant improvement to the current results. We should also be careful of the case where midpoint is in the middle but the line gets curvy on either side of the midpoint.

Launch Checklist

  • briefly describe the changes in this PR
  • include before/after visuals or gifs if this PR includes visual changes
  • manually test the debug page
  • apply changelog label ('bug', 'feature', 'docs', etc) or use the label 'skip changelog'

@mourner mourner added the skip changelog Used for PRs that do not need a changelog entry label Aug 29, 2022
@mourner mourner requested a review from karimnaaji August 29, 2022 13:43
Copy link
Contributor

@karimnaaji karimnaaji left a comment

Choose a reason for hiding this comment

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

Really useful 👍

@karimnaaji karimnaaji merged commit f514cb9 into main Aug 29, 2022
@karimnaaji karimnaaji deleted the globe-get-bounds-debug branch August 29, 2022 16:27
@stepankuzmin stepankuzmin mentioned this pull request Oct 7, 2022
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip changelog Used for PRs that do not need a changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants