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 initial projection support for interactors. #336

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

jheer
Copy link
Member

@jheer jheer commented Mar 21, 2024

This PR explores possible brushing support over projections instead of scales. It requires changes to Observable Plot to expose projections and sufficient information to perform inversion. This initial version supports brushing over projections that maintain an orthogonal separation between longitude (e.g., -> x) and latitude (e.g., -> y), including planar (identity, reflect-y), equirectangular, and mercator projections.

The code assumes that Plot projections are instead constructed in Plot's projection.js like so:

return {
  width: dx,
  height: dy,
  offset: [marginLeft + insetLeft, marginTop + insetTop],
  translate: [tx, ty],
  scale: k,
  invert: projection.invert,
  stream: (s) => projection.stream(transform.stream(clip(s)))
};

And then later exposed in plot.js similar to this:

figure.projection = () => context.projection;

If/when Plot issue observablehq/plot#1191 is addressed, we can visit this!

@Fil
Copy link

Fil commented Mar 22, 2024

We can't send an inverse projection function to the backend, but instead of sending separate bounds for lon and for lat, can we send a ST_geometry, and query with a filter ST_Within(datum, geometry)? Or would that be too slow anyway?

The geometry would have to correspond to "everything inside the brush, in source coordinates", which is (as a first approximation [1]) the inverse projection of the brush rectangle.

[1] It's more complicated than that since you might brush over points that are outside of the sphere, but that's a secondary issue.

@jheer
Copy link
Member Author

jheer commented Mar 25, 2024

Thanks @Fil. For the kind of brushing you're describing, we could probably get by processing the selected geometry in browser and creating a predicate over ids (that is, selecting by item rather than over intervals). That's on our TODO list.

This PR is focused on exploring support for interval selections. If we project in database perhaps we can just get by with "implicit" planar projections (where Plot still generates and exposes x/y scales). Nevertheless, this PR tries to push further for cases where explicit projections are defined and Plot does not expose any scales.

@Fil Fil mentioned this pull request Mar 26, 2024
4 tasks
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.

None yet

2 participants