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

Make PjInfo struct public #133

Merged
merged 14 commits into from
Jun 23, 2022
Merged

Make PjInfo struct public #133

merged 14 commits into from
Jun 23, 2022

Conversation

urschrei
Copy link
Member

Fixes #131

src/proj.rs Outdated
@@ -1018,6 +1018,8 @@ impl convert::TryFrom<(&str, &str)> for Proj {
}
}

/// Info about the current PROJ definition
#[derive(Copy, Clone, Debug)]
struct PjInfo {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
struct PjInfo {
pub struct PjInfo {

😉

Also, I don't think it can be Copy - only Clone - because of the String fields.

Copy link
Member Author

Choose a reason for hiding this comment

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

🤦 night-PR strikes again

src/proj.rs Show resolved Hide resolved
Co-authored-by: Corey Farwell <[email protected]>
src/proj.rs Outdated
///
/// [PROJ reference documentation](https://proj.org/development/reference/datatypes.html?highlight=has_inverse#c.PJ_PROJ_INFO)
#[derive(Clone, Debug)]
pub struct PjInfo {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
pub struct PjInfo {
pub struct ProjInfo {

Since this was private, we can freely change the name. I think it's nice to match the upstream name, or at least idiomatically translate them.

This is completely subjective, so feel free to take it or leave it.

Copy link
Member

Choose a reason for hiding this comment

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

We already have a Projinfo: https://docs.rs/proj/latest/proj/struct.Projinfo.html

...which comes from PJ_INFO. Agreed that your naming more accurately maps to the underlying structures

Copy link
Member

@michaelkirk michaelkirk Jun 13, 2022

Choose a reason for hiding this comment

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

ahah oh darn, good point @frewsxcv.

With perfect hindsight, maybe an idiomatic conversion would map PJ_INFO to proj::Info and PJ_PROJ_INFO to proj::ProjInfo

But, I'd understand if doing that whole swap is more work/confusion than it's worth.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yes, and I've broken the build. Swapping will be a breaking change, won't it? (Not necessarily a reason not to do it…)

Copy link
Member

@michaelkirk michaelkirk Jun 13, 2022

Choose a reason for hiding this comment

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

6f89e01 👀

Oh no. 😆

Well @urschrei, if you want to see this through - maybe:

- pub struct Projinfo {
+ pub struct Info {
...
  }

+ #[deprecated(message = "renamed to Info")]
+ pub type Projinfo = Info

Copy link
Member

Choose a reason for hiding this comment

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

Swapping will be a breaking change, won't it?

I don't think so? I think you'd just need to correspondingly rename the (here-to-fore private) usages of PjInfo.

Copy link
Member Author

Choose a reason for hiding this comment

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

We can't use Info because we have a public trait named Info: https://github.com/georust/proj/blob/main/src/proj.rs#L231

😭

Anyone got a good suggestion for an alternative name?

Copy link
Member

Choose a reason for hiding this comment

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

oh my gosh what a pjckle. I surrender. 🏳️

Copy link
Member

Choose a reason for hiding this comment

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

Ok wait, I think I have a proposal. One minute.

Copy link
Member

Choose a reason for hiding this comment

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

Proposal: #134

I think it puts us in a nice place, but it's got some downsides - I know you're no fan of macros, and it's potentially confusing to replace a trait with a struct of the same name, so no hard feelings if you'd prefer to just leave the names as they are.

urschrei and others added 3 commits June 13, 2022 21:33
Co-authored-by: Michael Kirk <[email protected]>
`use proj::Info` to have access to these methods.

This is a nice convenience, but especially important because we want to
have `use proj::Info` refer to the newly renamed `Info` struct, not the
legacy `Info` trait.

So now, instead of legacy people getting a confusing method for trying
to use the legacy trait, they'll just see an "unused import" warning.
@urschrei
Copy link
Member Author

I've merged #134, but even though there's now a proj::proj_info method which returns a proj::ProjInfo struct, it's not visible in docs, and neither is the struct definition. I feel like I'm losing my mind.

@michaelkirk
Copy link
Member

michaelkirk commented Jun 21, 2022

even though there's now a proj::proj_info method which returns a proj::ProjInfo struct, it's not visible in docs, and neither is the struct definition.

Addressed in #136

I feel like I'm losing my mind.

Yes, this is pretty maddening. 😆 I know it was my suggestion, but upon reflection, even though it's an idiomatic translation, proj.info() is a pretty rough name. What would you think about renaming proj.info() to something like proj.lib_info()?

I think that would contrast better with proj.proj_info().

// get details about the libproj installation
proj.lib_info();

// get details about this specific transformation
proj.proj_info();

@urschrei
Copy link
Member Author

Yeah I think that's much clearer! Do you want to leave #136 as is, and I'll merge it tomorrow then do the rename in here?

@michaelkirk
Copy link
Member

SGTM!

@urschrei
Copy link
Member Author

OK, this is done!

CHANGES.md Outdated Show resolved Hide resolved
///
/// # Safety
/// This method contains unsafe code.
pub fn lib_info(&self) -> Result<Info, ProjError> {
Copy link
Member

@michaelkirk michaelkirk Jun 22, 2022

Choose a reason for hiding this comment

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

I guess this is a breaking change now, but I think it's the right thing to do now that there is another *info method. I also don't expect very many people are actually using it.

Probably worth a new release note though - something like:

BREAKING: Getting information about the version of libproj installed was renamed from proj.info() to proj.lib_info()

@urschrei
Copy link
Member Author

bors r+

@bors
Copy link
Contributor

bors bot commented Jun 23, 2022

Build succeeded:

@bors bors bot merged commit 8fe1f0a into main Jun 23, 2022
bors bot added a commit that referenced this pull request Jun 23, 2022
135: Bump proj-sys to use PROJ 9.0.1 r=urschrei a=urschrei

This will be rebased against #133 when it merges – there are no changes to `proj`.

This PR bumps `PROJ` to v9.0.1. It's a bugfix release. Full list of fixes is here: https://github.com/OSGeo/PROJ/releases/tag/9.0.1

Note that I haven't bumped the CI PROJ versions as there should be no compat issues (although we're about to find out): The EPSG version has also been updated so we may initially see some test errors in `proj` where the bundled binary is in use.

Co-authored-by: Stephan Hügel <[email protected]>
@michaelkirk
Copy link
Member

Good job getting this merged! Sorry for turning it into such an odyssey. 😬

@urschrei
Copy link
Member Author

No, I'm very happy with where it ended up, so def worth it, I think!

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.

Expose PjInfo struct
3 participants