Skip to content

Commit

Permalink
Fix typos, add tests
Browse files Browse the repository at this point in the history
Co-authored-by: Laurențiu Nicola <[email protected]>

Add trivial test for z coordinate.
  • Loading branch information
rmanoka committed Sep 15, 2021
1 parent b0ebbde commit 80b8b4d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/spatial_ref/srs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl CoordTransform {
assert_eq!(
nb_coords,
y.len(),
"transform coordinate slices have different length: {} != {}",
"transform coordinate slices have different lengths: {} != {}",
nb_coords,
y.len()
);
Expand All @@ -60,7 +60,7 @@ impl CoordTransform {
assert_eq!(
nb_coords,
z.len(),
"transform coordinate slices have different length: {} != {}",
"transform coordinate slices have different lengths: {} != {}",
nb_coords,
z.len()
);
Expand Down
7 changes: 4 additions & 3 deletions src/spatial_ref/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ fn transform_coordinates() {
let transform = CoordTransform::new(&spatial_ref1, &spatial_ref2).unwrap();
let mut xs = [23.43, 23.50];
let mut ys = [37.58, 37.70];
let mut zs = [32.0, 20.0];
transform
.transform_coords(&mut xs, &mut ys, &mut [])
.transform_coords(&mut xs, &mut ys, &mut zs)
.unwrap();
assert_almost_eq(xs[0], 5509543.1508097);
assert_almost_eq(ys[0], 1716062.1916192223);
assert_almost_eq(zs[0], 32.0);
}

#[test]
Expand Down Expand Up @@ -169,10 +171,9 @@ fn failing_transformation() {

let mut x = [1000000.0];
let mut y = [1000000.0];
let mut z = [0.0];

let trafo = CoordTransform::new(&wgs84, &webmercator).unwrap();
let r = trafo.transform_coords(&mut x, &mut y, &mut z);
let r = trafo.transform_coords(&mut x, &mut y, &mut []);

assert!(r.is_err());
if let GdalError::InvalidCoordinateRange { .. } = r.unwrap_err() {
Expand Down

0 comments on commit 80b8b4d

Please sign in to comment.