georust / proj

Rust bindings for the latest stable release of PROJ
https://docs.rs/proj
Apache License 2.0
137 stars 44 forks source link

Port transform trait from geo and add a mutable flavor #109

Closed michaelkirk closed 2 years ago

michaelkirk commented 2 years ago

Fixes #101, #108

An alternative to #106, but as proposed in #108, I've done so by porting the Transform trait from geo to proj so that we won't need similar-but-different code in two places.

I chose to double down on a trait-based approach since it seemed idiomatic to our other georust code. However, like proposed in #106, I leveraged proj_array in more places.

/cc @x4d3

corresponding PRs:

michaelkirk commented 2 years ago

I think we get that for free from: https://doc.rust-lang.org/src/core/result.rs.html#500

On Feb 16, 2022, at 1:36 AM, Xavier Delamotte @.***> wrote:

@x4d3 commented on this pull request.

In src/transform.rs https://github.com/georust/proj/pull/109#discussion_r807725200:

+let point = geo_types::point!(x: -36.508f32, y: -54.2815f32); +let proj = Proj::new("+proj=axisswap +order=2,1,3,4").expect("invalid proj string"); + +assert_relative_eq!(

  • point.transformed(&proj).unwrap(),
  • geo_types::point!(x: -54.2815f32, y: -36.508f32) +);
  • +// original point is untouched +assert_relative_eq!(

  • point,
  • geo_types::point!(x: -36.508f32, y: -54.2815f32) +); +``` +"##)]
  • fn transformed(&self, proj: &Proj) -> Result<Self::Output, ProjError>; Should we add must_use https://rust-lang.github.io/rfcs/1940-must-use-functions.html here ?

— Reply to this email directly, view it on GitHub https://github.com/georust/proj/pull/109#pullrequestreview-884218684, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABU7YPVCJJVFVXBTTMGM7TU3NV3BANCNFSM5OPWQXJA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you authored the thread.

frewsxcv commented 2 years ago

bors r+

bors[bot] commented 2 years ago

Build succeeded: