From 80b8b4dc5167802f227d9557d4159eb76152e5d3 Mon Sep 17 00:00:00 2001 From: rmanoka Date: Wed, 15 Sep 2021 21:51:57 +0530 Subject: [PATCH] Fix typos, add tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Laurențiu Nicola Add trivial test for z coordinate. --- src/spatial_ref/srs.rs | 4 ++-- src/spatial_ref/tests.rs | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/spatial_ref/srs.rs b/src/spatial_ref/srs.rs index 4ee9aa16..7367f0b0 100644 --- a/src/spatial_ref/srs.rs +++ b/src/spatial_ref/srs.rs @@ -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() ); @@ -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() ); diff --git a/src/spatial_ref/tests.rs b/src/spatial_ref/tests.rs index 8a59f471..0079920c 100644 --- a/src/spatial_ref/tests.rs +++ b/src/spatial_ref/tests.rs @@ -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] @@ -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() {