From c6438bb965009c87d67521f45c09abc7cc5ecc7c Mon Sep 17 00:00:00 2001 From: "Simeon H.K. Fitch" Date: Fri, 29 Dec 2023 10:43:11 -0500 Subject: [PATCH] Added GDAL version `cfg` barriers on WarpResampleAlg options. --- src/raster/warp/mod.rs | 4 +++- src/raster/warp/resample.rs | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/raster/warp/mod.rs b/src/raster/warp/mod.rs index dc619800..413f3a04 100644 --- a/src/raster/warp/mod.rs +++ b/src/raster/warp/mod.rs @@ -169,10 +169,12 @@ mod tests { use crate::spatial_ref::SpatialRef; use crate::test_utils::{fixture, InMemoryFixture, TempFixture}; use crate::{assert_near, Dataset}; - use std::path::Path; + // TODO: For some unknown reason this test fails on GDAL < 3.4 + #[cfg(any(all(major_ge_3, minor_ge_4), major_ge_4))] #[test] fn test_create_reproject() -> Result<()> { + use std::path::Path; let dst_srs = SpatialRef::from_epsg(4269)?; let source = TempFixture::fixture("labels.tif"); diff --git a/src/raster/warp/resample.rs b/src/raster/warp/resample.rs index 0adeafd0..6ac260b6 100644 --- a/src/raster/warp/resample.rs +++ b/src/raster/warp/resample.rs @@ -31,8 +31,10 @@ pub enum WarpResampleAlg { Q1 = GDALResampleAlg::GRA_Q1, /// Q3 (selects third quartile of all non-NODATA contributing pixels) Q3 = GDALResampleAlg::GRA_Q3, - /// Sum (weighed sum of all non-NODATA contributing pixels). Added in GDAL 3.1 + #[cfg(any(all(major_ge_3, minor_ge_1), major_ge_4))] + /// Sum (weighed sum of all non-NODATA contributing pixels). Sum = GDALResampleAlg::GRA_Sum, + #[cfg(any(all(major_ge_3, minor_ge_3), major_ge_4))] /// RMS (weighted root mean square (quadratic mean) of all non-NODATA contributing pixels) RMS = GDALResampleAlg::GRA_RMS, } @@ -55,7 +57,9 @@ impl WarpResampleAlg { GDALResampleAlg::GRA_Med => WarpResampleAlg::Med, GDALResampleAlg::GRA_Q1 => WarpResampleAlg::Q1, GDALResampleAlg::GRA_Q3 => WarpResampleAlg::Q3, + #[cfg(any(all(major_ge_3, minor_ge_1), major_ge_4))] GDALResampleAlg::GRA_Sum => WarpResampleAlg::Sum, + #[cfg(any(all(major_ge_3, minor_ge_3), major_ge_4))] GDALResampleAlg::GRA_RMS => WarpResampleAlg::RMS, o => { return Err(GdalError::BadArgument(format!(