Skip to content

Commit

Permalink
Added GDAL version cfg barriers on WarpResampleAlg options.
Browse files Browse the repository at this point in the history
  • Loading branch information
metasim committed Dec 29, 2023
1 parent 9c9dd15 commit c6438bb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/raster/warp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
6 changes: 5 additions & 1 deletion src/raster/warp/resample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand All @@ -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!(
Expand Down

0 comments on commit c6438bb

Please sign in to comment.