From f745033cfa2e3348c9502e6dd7d480b325c7a43c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Sat, 23 Dec 2023 18:59:46 +0200 Subject: [PATCH] Drop support for GDAL pre-3.0 --- CHANGES.md | 12 ++++++++---- build.rs | 7 +++---- src/dataset.rs | 1 - src/options.rs | 5 ----- src/raster/rasterband.rs | 1 - src/raster/tests.rs | 1 - src/vector/ops/transformations.rs | 2 -- 7 files changed, 11 insertions(+), 18 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index cd0d98fe..51f8b426 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,11 +2,15 @@ ## Unreleased -- Added ability to convert between `Buffer` and `ndarray::Array2`. -- Implemented `IntoIterator`, `Index` and `IndexMut` for `Buffer`. +- **Breaking**: Drop support for GDAL 2.x + + - + +- Added ability to convert between `Buffer` and `ndarray::Array2`. +- Implemented `IntoIterator`, `Index` and `IndexMut` for `Buffer`. - **Breaking**: `Buffer::size` is now private and accessed via `Buffer::shape(). -- **Breaking**: `Buffer::data` is now private and accessed via `Buffer::data(). -- **Breaking**: Removed `Rasterband::read_as_array`, changed signature of `Rasterband::read_block` to return a `Buffer`. +- **Breaking**: `Buffer::data` is now private and accessed via `Buffer::data(). +- **Breaking**: Removed `Rasterband::read_as_array`, changed signature of `Rasterband::read_block` to return a `Buffer`. - **Breaking**: `Rasterband::write` and `Rasterband::write_block` now require a `&mut Buffer` to handle possible case of drivers temporarily mutating input buffer. - diff --git a/build.rs b/build.rs index 8e11ed96..d08e78dc 100644 --- a/build.rs +++ b/build.rs @@ -14,8 +14,8 @@ fn main() { let minor = (gdal_version - major * 1000000) / 10000; let patch = (gdal_version - major * 1000000 - minor * 10000) / 100; - if major < 2 { - panic!("The GDAL crate requires a GDAL version >= 2.0.0. Found {major}.{minor}.{patch}"); + if major < 3 { + panic!("The GDAL crate requires a GDAL version >= 3.0.0. Found {major}.{minor}.{patch}"); } println!("cargo:rustc-cfg=gdal_{major}"); @@ -26,8 +26,7 @@ fn main() { println!("cargo:rustc-cfg=minor_is_{minor}"); println!("cargo:rustc-cfg=patch_is_{patch}"); - // we only support GDAL >= 2.0. - for major in 2..=major { + for major in 3..=major { println!("cargo:rustc-cfg=major_ge_{major}"); } diff --git a/src/dataset.rs b/src/dataset.rs index 90ec8330..aa636948 100644 --- a/src/dataset.rs +++ b/src/dataset.rs @@ -30,7 +30,6 @@ pub struct Dataset { // See: https://gdal.org/api/raster_c_api.html#_CPPv48GDALOpenPKc10GDALAccess // Additionally, VRT Datasets are not safe before GDAL 2.3. // See: https://gdal.org/drivers/raster/vrt.html#multi-threading-issues -#[cfg(any(all(major_is_2, minor_ge_3), major_ge_3))] unsafe impl Send for Dataset {} /// Core dataset methods diff --git a/src/options.rs b/src/options.rs index 27124173..3e40ef53 100644 --- a/src/options.rs +++ b/src/options.rs @@ -12,7 +12,6 @@ pub struct DatasetOptions<'a> { } // These are skipped by bindgen and manually updated. -#[cfg(major_ge_2)] bitflags! { /// GDal extended open flags used by [`Dataset::open_ex`]. /// @@ -39,7 +38,6 @@ bitflags! { /// Allow vector drivers to be used. const GDAL_OF_VECTOR = 0x04; /// Allow gnm drivers to be used. - #[cfg(any( all(major_ge_2,minor_ge_1), major_ge_3 ))] const GDAL_OF_GNM = 0x08; /// Allow multidimensional raster drivers to be used. #[cfg(all(major_ge_3,minor_ge_1))] @@ -52,15 +50,12 @@ bitflags! { const GDAL_OF_INTERNAL = 0x80; /// Default strategy for cached blocks. - #[cfg(any( all(major_ge_2,minor_ge_1), major_ge_3 ))] const GDAL_OF_DEFAULT_BLOCK_ACCESS = 0; /// Array based strategy for cached blocks. - #[cfg(any( all(major_ge_2,minor_ge_1), major_ge_3 ))] const GDAL_OF_ARRAY_BLOCK_ACCESS = 0x100; /// Hashset based strategy for cached blocks. - #[cfg(any( all(major_ge_2,minor_ge_1), major_ge_3 ))] const GDAL_OF_HASHSET_BLOCK_ACCESS = 0x200; } } diff --git a/src/raster/rasterband.rs b/src/raster/rasterband.rs index 675e16e2..c9081a4e 100644 --- a/src/raster/rasterband.rs +++ b/src/raster/rasterband.rs @@ -786,7 +786,6 @@ impl<'a> RasterBand<'a> { /// Get actual block size (at the edges) when block size /// does not divide band size. - #[cfg(any(all(major_is_2, minor_ge_2), major_ge_3))] // GDAL 2.2 .. 2.x or >= 3 pub fn actual_block_size(&self, x: usize, y: usize) -> Result<(usize, usize)> { let offset_x = x.try_into().expect("`x` offset must fit in `c_int`"); let offset_y = y.try_into().expect("`y` offset must fit in `c_int`"); diff --git a/src/raster/tests.rs b/src/raster/tests.rs index 774de90c..3839664b 100644 --- a/src/raster/tests.rs +++ b/src/raster/tests.rs @@ -535,7 +535,6 @@ fn test_get_rasterband_block_size() { } #[test] -#[cfg(any(all(major_ge_2, minor_ge_2), major_ge_3))] // GDAL 2.2 .. 2.x or >= 3 fn test_get_rasterband_actual_block_size() { let dataset = Dataset::open(fixture("tinymarble.tif")).unwrap(); let rasterband = dataset.rasterband(1).unwrap(); diff --git a/src/vector/ops/transformations.rs b/src/vector/ops/transformations.rs index afe13d6b..57ded2ee 100644 --- a/src/vector/ops/transformations.rs +++ b/src/vector/ops/transformations.rs @@ -80,7 +80,6 @@ impl Geometry { Ok(unsafe { Geometry::with_c_geometry(c_geom, true) }) } - #[cfg(any(all(major_is_2, minor_ge_1), major_ge_3))] /// Return a [Delaunay triangulation of][dt] the vertices of the geometry. /// /// # Arguments @@ -229,7 +228,6 @@ mod tests { } #[test] - #[cfg(any(all(major_is_2, minor_ge_1), major_ge_3))] fn test_delaunay_triangulation() -> Result<()> { let square = Geometry::from_wkt("POLYGON ((0 1,1 1,1 0,0 0,0 1))")?; let triangles = Geometry::from_wkt(