-
Notifications
You must be signed in to change notification settings - Fork 47
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
Add ability to convert 3d coordinates #176
base: main
Are you sure you want to change the base?
Conversation
Hi @PaulWagener, thanks for the PR! As ever with 2D -> 3D, there's likely to be some discussion… At minimum, I don't think we can remove the As for Even more radically: we could adopt Rust-Geodesy's coordinate struct… |
As long as 3D coordinates will be supported I will be happy :) |
What more is needed for this feature to be added ? I'd be happy to help. |
I just wanted to bring up that this issue hurt me on a recent project. It would be great to see a solution to 3d transformations, or at least allowing transformation into ECEF, into the project and released. |
@lx-88 - does using this branch work for you? |
A new struct or a new trait? I thought the whole "bring your own struct" thing was kind of nice, so users don't have to first convert their data to an intermediate proj-crate format. Just brainstorming... if avoiding api-breakage is a concern, could we introduce the new 3d method with a default impl? trait Coord {
...
+ #[deprecated(note = "implement from_xyz instead, this method will be removed in a future release")]
fn from_xy(x: f64, y: f64, z:f64) -> Self;
// at some point we'd remove the default impl, which would be a breaking release - presumably in the same release as we remove `from_xy`
+ fn from_xyz(x: f64, y: f64, z:f64) -> Self {
+ Self::from_xy(x, y)
+ }
} |
Hello! I know that it is very difficult to do this, but what is the reason that this PR has not been merged? |
This is great! I'll use it as a reference! |
incorporated the contents of this PR into my fork. https://github.com/nokonoko1203/proj/blob/f643a9a197921fc7f31571972f522bbd5149a20e/src/proj.rs#L1330 #[test]
fn test_3d_crs() {
let from = "EPSG:6677";
let to = "EPSG:6697";
let proj = Proj::new_known_crs(from, to, None).unwrap();
let (x, y, z) = (-5998.998, -35838.918, 3.901);
let (lng, lat, height) = proj.convert((x, y, z)).unwrap();
assert_relative_eq!(lng, 139.76706139226548, epsilon = 1e-3);
assert_relative_eq!(lat, 35.67694831658619, epsilon = 1e-3);
assert_relative_eq!(height, 3.901, epsilon = 1e-3);
let from = "EPSG:6697";
let to = "EPSG:4979";
let proj = Proj::new_known_crs(from, to, None).unwrap();
let (lng, lat, height) = proj.convert((lng, lat, height)).unwrap();
assert_relative_eq!(lng, 139.76706139226548, epsilon = 1e-3);
assert_relative_eq!(lat, 35.67694831658619, epsilon = 1e-3);
assert_relative_eq!(height, 40.53393140934767, epsilon = 1e-3);
let from = "EPSG:4979";
let to = "EPSG:4978";
let proj = Proj::new_known_crs(from, to, None).unwrap();
let (x, y, z) = proj.convert((lng, lat, height)).unwrap();
assert_relative_eq!(x, -3959898.9249523925, epsilon = 1e-3);
assert_relative_eq!(y, 3350278.1607454875, epsilon = 1e-3);
assert_relative_eq!(z, 3699157.243055472, epsilon = 1e-3);
} |
Fixes #150
This PR adds the ability to convert 3d coordinates.
The
Coord
trait is changed to add a Z coordinate so at least a minor version bump is warranted with this change.