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

Convert data coordinates to pixel coordinates #295

Closed
aplavin opened this issue Dec 12, 2024 · 6 comments · Fixed by #297
Closed

Convert data coordinates to pixel coordinates #295

aplavin opened this issue Dec 12, 2024 · 6 comments · Fixed by #297

Comments

@aplavin
Copy link

aplavin commented Dec 12, 2024

For regular Makie axes, I've been using

fullproject(ax, p) = Makie.project(Makie.get_scene(ax), Makie.apply_transform(Makie.transform_func(ax), p)) + viewport(ax)[].origin

to convert from data coordinates to Figure pixel coordinates. But this function doesn't seem to work for GeoAxis, any suggestions on how to do this conversion?
For one usecase, see MakieExtra.zoom_lines!:
works correctly for regular axes
Image
but not for GeoAxes
Image

@asinghvi17
Copy link
Member

Hmm, looks like the problem is that Makie.transform_func on a GeoAxis returns identity. Will push a fix up shortly.

The fix is Makie.transform_func(ax::GeoAxis) = ax.transform_func[], if you want to use this immediately.

@asinghvi17
Copy link
Member

There could be some interesting extensions to that zoom_lines function (the rectangles could be in different spaces / projections) as well if you're interested in that...

@aplavin
Copy link
Author

aplavin commented Dec 12, 2024

Wow, cool, happy it can be fixed as easily! Can confirm that zoom_lines! work with this fix.

@aplavin
Copy link
Author

aplavin commented Dec 12, 2024

Yeah, ideally the rectangle sides shouldn't be straight, but follow the curvature instead... How hard would that be?
In practice, it doesn't matter much for my usecases (zoomed-in area a small fraction of the sphere), but would be nice for correctness.

@asinghvi17
Copy link
Member

It shouldn't be too complicated...you already have the lines in slines, so you can simply densify ("segmentize") them using GeometryOps (or just manually). This resampling would have to be done in the space of ax2.finallimits, and then the resulting points would be transformed by ax1.transform_func.

@aplavin
Copy link
Author

aplavin commented Dec 12, 2024

I see! The simple densification solution didn't occur to me, I was thinking about some option like poly!(..., follow_geodetics=true) :)

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 a pull request may close this issue.

2 participants