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

feat: add projections #39

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

jorisvandenbossche
Copy link
Contributor

Moving the lnglat() projection definition (which is currently already used in the geoarrow import/export) to its own file, so we can easily add more (without making geoarrow.cc unwieldy large).

Will add additional ones in a next commit.

}

S2::Projection* mercator() {
static S2::MercatorProjection projection(20037508.3427892);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a need to make this configurable? (maybe since it is in R s2?) Currently just took the value from the s2 code, which I think matches the reported projected bounds of EPSG:3857 (https://epsg.io/3857)

Copy link
Owner

Choose a reason for hiding this comment

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

I am not sure the degree to which that's ever been used in R/s2, so you're free give this a better name or make this configurable (or not include it!). Probably safer to refer to this as pseudo_mercator() and make it align with EPSG:3857 (I think Google has an internal version of this that uses -2pi...2pi instead of a range in meters, but probably nobody else needs that).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think including (Web)Mercator could still be useful to enable plotting (e.g. for combining with tiles where you want to use WebMercator and not something like Orthographic), without requiring some PROJ bindings (of course, for something like spherely, we could also easily have an optional dependency on pyproj for those use cases)

Copy link
Owner

Choose a reason for hiding this comment

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

You probably want this here regardless of PROJ, since PROJ won't handle the wraparound situation here (and S2's projections will!)

Comment on lines 63 to 66
S2::Projection* orthographic(const S2LatLng& centre) {
static OrthographicProjection projection(centre);
return &projection;
}
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think you want this global state here, which won't work, for example, if two threads are trying to plot a spinning globe (plotting a spinning globe is the reason I added this 🙂 ). You probably need this to return a std::unique_ptr<S2::Projection>.

(That begs the question of whether the options class should be parameterized as S2::Projection* or std::unique_ptr<S2::Projection>. Probably the latter is more flexible).

Copy link
Contributor Author

@jorisvandenbossche jorisvandenbossche Nov 4, 2024

Choose a reason for hiding this comment

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

Ah, yes of course, I was just blindly copying the code of the others.
Returning a unique_ptr for all of them will be the easiest then I suppose

Copy link
Contributor Author

@jorisvandenbossche jorisvandenbossche Nov 5, 2024

Choose a reason for hiding this comment

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

I tried using a unique_ptr, but ran into the issue that it is then not copyable, and because the Options class also holds the projection, it then makes the Options class not copyable (AFAIU?), which is then a bit annoying to use that.
So used a shared_ptr instead. Does that look good, or should I be able to get it working with a unique_ptr as well?

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