Skip to content

Commit

Permalink
Drop support for GDAL pre-3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lnicola committed Dec 23, 2023
1 parent aebb751 commit f745033
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 18 deletions.
12 changes: 8 additions & 4 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

## Unreleased

- Added ability to convert between `Buffer<T>` and `ndarray::Array2<T>`.
- Implemented `IntoIterator`, `Index` and `IndexMut` for `Buffer<T>`.
- **Breaking**: Drop support for GDAL 2.x

- <https://github.com/georust/gdal/pull/504>

- Added ability to convert between `Buffer<T>` and `ndarray::Array2<T>`.
- Implemented `IntoIterator`, `Index` and `IndexMut` for `Buffer<T>`.
- **Breaking**: `Buffer<T>::size` is now private and accessed via `Buffer<T>::shape().
- **Breaking**: `Buffer<T>::data` is now private and accessed via `Buffer<T>::data().
- **Breaking**: Removed `Rasterband::read_as_array`, changed signature of `Rasterband::read_block` to return a `Buffer<T>`.
- **Breaking**: `Buffer<T>::data` is now private and accessed via `Buffer<T>::data().
- **Breaking**: Removed `Rasterband::read_as_array`, changed signature of `Rasterband::read_block` to return a `Buffer<T>`.
- **Breaking**: `Rasterband::write` and `Rasterband::write_block` now require a `&mut Buffer<T>` to handle possible case of drivers temporarily mutating input buffer.

- <https://github.com/georust/gdal/pull/494>
Expand Down
7 changes: 3 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
Expand All @@ -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}");
}

Expand Down
1 change: 0 additions & 1 deletion src/dataset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`].
///
Expand All @@ -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))]
Expand All @@ -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;
}
}
Expand Down
1 change: 0 additions & 1 deletion src/raster/rasterband.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`");
Expand Down
1 change: 0 additions & 1 deletion src/raster/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 0 additions & 2 deletions src/vector/ops/transformations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit f745033

Please sign in to comment.