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

Interval Selection for Projection #3587

Open
kanitw opened this issue Mar 30, 2018 · 1 comment
Open

Interval Selection for Projection #3587

kanitw opened this issue Mar 30, 2018 · 1 comment

Comments

@kanitw
Copy link
Member

kanitw commented Mar 30, 2018

From slack conversation with @arvind, interval selection of geographically a projected plot is quite tricky. Here is my interpretation of the problem:

Plots without Projection

For plots with normal x/y scales (without projection), we apply predicate in data space so it's easier to reapply predicate to other subplots.

From user's visual selection like

5 <= x <= 10 && 0 <= y <= 5

we can apply scale inversion to perform the predicate in the data space instead.

invert_x_scale(5) <= invert_x_scale(x) <= invert_x_scale(10) && invert_y_scale(5) <= invert_y_scale(y) <= invert_y_scale(10)

which is simply:

invert_x_scale(5) <=x_field <= invert_x_scale(10) && invert_y_scale(0) <=y_field <= invert_y_scale(5)

This is possible because our quantitative scales are all monotonic* so applying inversion on both side of inequalities will preserve the inequalities.

Note: * For the derivation above, it actually has to be monotonically increasing, but if the scale is monotonically decreasing, then we just need to flip the inequality so it still works.

Plots with Geographic Projection

For geographic projection, from user's visual selection like

5 <= x <= 10 && 0 <= y <= 5

where x = project_x(projection_name, lat, long) and y = project_y(projection_name, lat, long).

However, we can't just apply inversion and preserve the inequality since projection inversion is not always monotonic (and is mostly not). Doing so means the selection won't match the rectangle boundary like in this screenshot:

image

(It could be even worse for more complicated projections.)

There are probably two solutions:

a) For projection, apply the predicate in visual space. For example, we can still do

5 <= project_x(projection_name, lat, long) <= 10 && 0 <= project_y(projection_name, lat, long) <= 5

but this will require a lot of refactor as our existing code always perform selection in the data space.

b) Invent a way to convert the whole inequality statement in visual space to statements in data space.
(This is probably result in a complex path inclusion checking rather than two simple statements.)

cc: @jheer @domoritz

@arvind -- please feel free to add / correct if there are parts that are unclear or if you don't agree :)

@kanitw kanitw added this to the 2.x Interaction Patches milestone Apr 22, 2018
@arvind arvind modified the milestones: x.x Interaction Patches, 4.0 May 17, 2019
@kanitw kanitw modified the milestones: 4.1, 4.x Dec 4, 2019
@kanitw kanitw modified the milestones: 4.x, soon?, 5.0? (or 5.x) May 15, 2020
@arvind
Copy link
Member

arvind commented Jan 7, 2021

Will be implemented with #6953, but will likely only be completed for v5.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants