Support 2D in CoordTransform
MODIFY
src/spatial_ref/srs.rs
src/spatial_ref/srs.rs
@@ -2,7 +2,7 @@ use crate::utils::{_last_cpl_err, _last_null_pointer_err, _string};
use gdal_sys::{self, CPLErr, OGRCoordinateTransformationH, OGRErr, OGRSpatialReferenceH};
use libc::{c_char, c_int};
use std::ffi::{CStr, CString};
-use std::ptr;
+use std::ptr::{self, null_mut};
use std::str::FromStr;
use crate::errors::*;
@@ -42,7 +42,12 @@ impl CoordTransform {
nb_coords as c_int,
x.as_mut_ptr(),
y.as_mut_ptr(),
- z.as_mut_ptr(),
+ if z.is_empty() {
+ null_mut()
+ } else {
+ assert_eq!(nb_coords, z.len());
+ z.as_mut_ptr()
+ },
) == 1
};

MODIFY
src/spatial_ref/tests.rs
src/spatial_ref/tests.rs
@@ -81,7 +81,7 @@ fn transform_coordinates() {
let mut xs = [23.43, 23.50];
let mut ys = [37.58, 37.70];
transform
- .transform_coords(&mut xs, &mut ys, &mut [0.0, 0.0])
+ .transform_coords(&mut xs, &mut ys, &mut [])
.unwrap();
assert_almost_eq(xs[0], 5509543.1508097);
assert_almost_eq(ys[0], 1716062.1916192223);

Support 2D in CoordTransform