Skip to content

feat(core): Orhtographic fitBounds() #9595

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

Closed
wants to merge 1 commit into from

Conversation

ibgreen
Copy link
Collaborator

@ibgreen ibgreen commented Apr 22, 2025

Closes #

Background

For discussion...

  • We don't seem to have fitBounds() for our non-geospatial views, so I created one for Orthographic views.
  • My first thought was to follow WebMercatorViewport and add a OrthographicViewport.fitBounds(),
  • but that would be rather awkward in use, since I need this function for updating viewState not viewports
  • and viewports have a lot of "irrelevant" props that makes extracting viewState props from them feel hacky.

Change List

@coveralls
Copy link

Coverage Status

coverage: 91.638% (+0.006%) from 91.632%
when pulling 159ded6 on ib/orthographic-fitbounds
into a1300ab on master.

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.

WebMercator fitBounds just calls imports the implementation from math.gl, perhaps better to do the same here?

height: 200
});

t.ok(!Number.isFinite(result.zoom[0]), 'zoomX is infinite for zero width');
Copy link
Collaborator

Choose a reason for hiding this comment

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

A bit nervous about these infinities, could we cap the zoom?

@ibgreen
Copy link
Collaborator Author

ibgreen commented Apr 23, 2025

WebMercator fitBounds just calls imports the implementation from math.gl, perhaps better to do the same here?

Yes perhaps math.gl is the best place. But not immediately clear how to do it / where to put it.

  • There is a long legacy behind the web-mercator code, which was a completely independent module, then moved into math.gl, then decomposed so that deck can build its own viewport from its primitives.
  • But there isn't any natural module or support for other viewports, apart from things like Matrix4.ortho() in the core module.
  • Should there be a new math.gl/views module that provides such things for a variety of view types?

@ibgreen
Copy link
Collaborator Author

ibgreen commented Jul 13, 2025

I did not find a natural way to expose this function at this time.
I have landed this in deck.gl-community where we can iterate a bit more before potentially upstreaming it to deck.gl or perhaps math.gl

@ibgreen ibgreen closed this Jul 13, 2025
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