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

Match GlobeView projection parameters with Maplibre v5 #9201

Open
wants to merge 3 commits into
base: x/globe-test-app
Choose a base branch
from

Conversation

Pessimistress
Copy link
Collaborator

For #9199

globe

Grid lines are rendered by Maplibre, points are rendered by deck.gl.

Change List

  • Match GlobeViewport's scale, nearZ, farZ with maplibre's GlobeTransform
  • GlobeView switch to WebMercatorViewport at zoom>=12. maplibre performs interpolation between the two projections at z [11, 12]. We may need to do the same, but the difference is honestly very subtle.
  • Some golden images are updated because the zoom -> scale mapping has changed. The new implementation uses an adaptive scale that depends on the latitude of the viewport center.

Copy link
Collaborator

@felixpalmer felixpalmer left a comment

Choose a reason for hiding this comment

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

Looks promising, but I get the page freezing after playing with the controls when viewing the full globe

@@ -9,6 +9,9 @@ import {MapState, MapStateProps} from './map-controller';
import {mod} from '../utils/math-utils';
import LinearInterpolator from '../transitions/linear-interpolator';

// matches Web Mercator projection limit
const MAX_VALID_LATITUDE = 85.051129;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if math.gl shouldn't export this - it is used in a number of places

@@ -9,6 +9,9 @@ import {MapState, MapStateProps} from './map-controller';
import {mod} from '../utils/math-utils';
import LinearInterpolator from '../transitions/linear-interpolator';

// matches Web Mercator projection limit
const MAX_VALID_LATITUDE = 85.051129;

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm seeing strange things when moving near the poles

Screen.Recording.2024-10-04.at.10.40.03.mov


constructor(opts: GlobeViewportOptions = {}) {
const {
latitude = 0,
longitude = 0,
zoom = 0,
nearZMultiplier = 0.1,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you document somewhere how you updated these defaults? Is there some magic formula?

@@ -275,7 +275,7 @@ const TEST_CASES = [
viewState: {
longitude: -6,
latitude: 58,
zoom: 1.5
zoom: 1.5 + 0.7353406094252244 // Math.log2(1 / Math.PI / Math.cos(58 / 180 * Math.PI))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel it is better to update the image than having some weird constant here. There is a significant change in output anyway

fovy = altitudeToFovy(altitude);
}
// Used to match globe and web mercator projection at high zoom
const scaleAdjust = 1 / Math.PI / Math.cos((latitude * Math.PI) / 180);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Worth guarding against division by 0? Despite this, the viewport could still be manually constructed with the pole value

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.

2 participants