Skip to content

Conversation

@urschrei
Copy link
Member

  • I agree to follow the project's code of conduct.
  • I added an entry to the project's change log file if knowledge of this change could be valuable to users.
    • Usually called CHANGES.md or CHANGELOG.md
    • Prefix changelog entries for breaking changes with "BREAKING: "

@urschrei urschrei force-pushed the shugel/push-psuusutrpusr branch from 9ce8b72 to 9058601 Compare April 14, 2025 13:40
@urschrei urschrei requested a review from Copilot April 14, 2025 14:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Copy link
Member

@michaelkirk michaelkirk left a comment

Choose a reason for hiding this comment

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

This seems important and I'd be glad to see it merged!

It's a little rough around the edges, but if I understand correctly, that seems due to the underlying proj implementation.

/// # Safety
/// This method contains unsafe code.
pub fn coordinate_metadata_get_epoch(&self) -> f64 {
unsafe { proj_coordinate_metadata_get_epoch(self.ctx, self.c_proj) }
Copy link
Member

Choose a reason for hiding this comment

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

Have you had any more luck than me (zero) finding documentation for these methods?

https://github.com/search?q=repo%3AOSGeo%2FPROJ%20proj_coordinate_metadata_get_epoch&type=code

Is epoch in any particular units or are those units specific to each projection?

Copy link
Member Author

Choose a reason for hiding this comment

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

"Just" floats of the form year.month,and month can be 0: 2010.3 and 2014.0 are both valid values.

Copy link
Member

@michaelkirk michaelkirk Apr 15, 2025

Choose a reason for hiding this comment

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

I couldn't find it documented in proj, but in gdal, which I'm comfortable assuming has the same semantics:

https://gdal.org/en/stable/user/coordinate_epoch.html#coordinate-epoch-support

coordinateEpoch Coordinate epoch as decimal year (e.g. 2021.3), or 0 if not set, or relevant.

So 2021.3 is April 2021.

/// about the coordinates, such as the epoch they are referenced to.
///
/// # Note
/// Only **transformation objects** (e.g. those created by calling [`new()`](fn@Proj::new())) can be
Copy link
Member

Choose a reason for hiding this comment

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

If you do the wrong thing and try to create coordinate metadata for a pipeline, than you'll hit this, right?:

called Result::unwrap() on an Err value: ProjError("Unknown error (code 4096)")

Should we try to be a "better proj than proj" and encode this in the type system?

I'm ok either way for now.

Copy link
Member Author

@urschrei urschrei Apr 15, 2025

Choose a reason for hiding this comment

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

I played around with that idea a bit last night. The fundamental issue is that we don't distinguish between a pipeline and a standard transformation object at the type level (neither does libproj), which means we can't get fancy with a bound (I don't think…): everything's a Proj. We have some runtime options:

  1. Catch the libproj error and return something more informative;
  2. Check whether the input is a pipeline using proj_info, and return an informative error if kind is Some("Pipeline").

Copy link
Member

Choose a reason for hiding this comment

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

Right - I was thinking of introducing a bound.

As I understand it, the two "flavors" of the Proj struct have distinct creation methods, right? So we could feasibly return a differently flavored type from each of those methods. Something like Proj<Transform> | Proj<Pipeline>

I'm not sure it's worth the complication though!

Copy link
Member

Choose a reason for hiding this comment

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

Having a runtime check like you described could be a good compromise. We could at least produce a useful error message.

Copy link
Member Author

Choose a reason for hiding this comment

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

I am very much open to something compile-time. But it would be very much a breaking change, right?

Copy link
Member

Choose a reason for hiding this comment

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

Oh hell yes. We could maybe minimize it by having a default? But definitely breaking.

Copy link
Member

Choose a reason for hiding this comment

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

I'm also fine to not do it (or do it later).

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, we've got a more informative error message. I think rather than breaking everyone for the sake of an operation that isn't required by most users, this will do for now.

@urschrei urschrei force-pushed the shugel/push-psuusutrpusr branch from 7776a51 to 68e582c Compare April 15, 2025 21:03
@urschrei urschrei added this pull request to the merge queue Apr 15, 2025
Merged via the queue into georust:main with commit 17276a8 Apr 15, 2025
28 checks passed
@urschrei urschrei deleted the shugel/push-psuusutrpusr branch April 15, 2025 21:14
github-merge-queue bot pushed a commit that referenced this pull request Apr 16, 2025
- [x] I agree to follow the project's [code of
conduct](https://github.com/georust/.github/blob/main/CODE_OF_CONDUCT.md).
- [x] I added an entry to the project's change log file if knowledge of
this change could be valuable to users.
  - Usually called `CHANGES.md` or `CHANGELOG.md`
  - Prefix changelog entries for breaking changes with "BREAKING: "
---

<s>Draft for now, </s>pls land #226 first.
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