Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build error on GDAL 3.1 #416

Merged
merged 2 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
- 3.4
- 3.3
- 3.2
- 3.1

runs-on: ubuntu-latest
container:
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changes

## Unreleased
- Fixed build error with GDAL 3.1

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

## 0.15
- **Breaking**: `RasterBand::actual_block_size` now takes two `usize` offsets instead of `(isize, isize)`
Expand Down
22 changes: 18 additions & 4 deletions src/raster/mdarray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ use gdal_sys::{
GDALGroupGetGroupNames, GDALGroupGetMDArrayNames, GDALGroupGetName, GDALGroupH,
GDALGroupOpenGroup, GDALGroupOpenMDArray, GDALGroupRelease, GDALMDArrayGetAttribute,
GDALMDArrayGetDataType, GDALMDArrayGetDimensionCount, GDALMDArrayGetDimensions,
GDALMDArrayGetNoDataValueAsDouble, GDALMDArrayGetSpatialRef, GDALMDArrayGetStatistics,
GDALMDArrayGetTotalElementsCount, GDALMDArrayGetUnit, GDALMDArrayH, GDALMDArrayRelease,
OSRDestroySpatialReference, VSIFree,
GDALMDArrayGetNoDataValueAsDouble, GDALMDArrayGetSpatialRef, GDALMDArrayGetTotalElementsCount,
GDALMDArrayGetUnit, GDALMDArrayH, GDALMDArrayRelease, OSRDestroySpatialReference, VSIFree,
};
use libc::c_void;
use std::ffi::CString;
Expand Down Expand Up @@ -387,6 +386,7 @@ impl<'a> MDArray<'a> {
///
/// TODO: add option to pass progress callback (`pfnProgress`)
///
#[cfg(any(all(major_is_3, minor_ge_2), major_ge_4))]
pub fn get_statistics(
&self,
force: bool,
Expand All @@ -401,7 +401,7 @@ impl<'a> MDArray<'a> {
};

let rv = unsafe {
GDALMDArrayGetStatistics(
gdal_sys::GDALMDArrayGetStatistics(
self.c_mdarray,
self.c_dataset,
libc::c_int::from(is_approx_ok),
Expand Down Expand Up @@ -805,6 +805,7 @@ mod tests {

#[test]
#[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)]
#[cfg(any(all(major_is_3, minor_ge_2), major_ge_4))]
fn test_root_group_name() {
let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip";

Expand All @@ -822,6 +823,7 @@ mod tests {

#[test]
#[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)]
#[cfg(any(all(major_is_3, minor_ge_2), major_ge_4))]
fn test_array_names() {
let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip";

Expand All @@ -843,6 +845,7 @@ mod tests {

#[test]
#[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)]
#[cfg(any(all(major_is_3, minor_ge_2), major_ge_4))]
fn test_n_dimension() {
let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip";

Expand All @@ -863,6 +866,7 @@ mod tests {

#[test]
#[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)]
#[cfg(any(all(major_is_3, minor_ge_2), major_ge_4))]
fn test_n_elements() {
let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip";

Expand All @@ -883,6 +887,7 @@ mod tests {

#[test]
#[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)]
#[cfg(any(all(major_is_3, minor_ge_2), major_ge_4))]
fn test_dimension_name() {
let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip";

Expand Down Expand Up @@ -918,6 +923,7 @@ mod tests {

#[test]
#[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)]
#[cfg(any(all(major_is_3, minor_ge_2), major_ge_4))]
fn test_dimension_size() {
let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip";

Expand All @@ -942,6 +948,7 @@ mod tests {

#[test]
#[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)]
#[cfg(any(all(major_is_3, minor_ge_2), major_ge_4))]
fn test_read_data() {
let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip";

Expand All @@ -968,6 +975,7 @@ mod tests {

#[test]
#[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)]
#[cfg(any(all(major_is_3, minor_ge_1), major_ge_4))]
fn test_read_string_array() {
// Beware https://github.com/georust/gdal/issues/299 if you want to reuse this
// This can't be Zarr because it doesn't support string arrays
Expand Down Expand Up @@ -1001,6 +1009,7 @@ mod tests {

#[test]
#[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)]
#[cfg(any(all(major_is_3, minor_ge_2), major_ge_4))]
fn test_datatype() {
let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip";

Expand All @@ -1027,6 +1036,7 @@ mod tests {

#[test]
#[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)]
#[cfg(any(all(major_is_3, minor_ge_2), major_ge_4))]
fn test_spatial_ref() {
let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip";

Expand All @@ -1052,6 +1062,7 @@ mod tests {

#[test]
#[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)]
#[cfg(any(all(major_is_3, minor_ge_2), major_ge_4))]
fn test_no_data_value() {
let fixture = "/vsizip/fixtures/byte_no_cf.zarr.zip";

Expand All @@ -1073,6 +1084,7 @@ mod tests {

#[test]
#[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)]
#[cfg(any(all(major_is_3, minor_ge_2), major_ge_4))]
fn test_attributes() {
let fixture = "/vsizip/fixtures/cf_nasa_4326.zarr.zip";

Expand Down Expand Up @@ -1124,6 +1136,7 @@ mod tests {

#[test]
#[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)]
#[cfg(any(all(major_is_3, minor_ge_2), major_ge_4))]
fn test_unit() {
let fixture = "/vsizip/fixtures/cf_nasa_4326.zarr.zip";

Expand Down Expand Up @@ -1164,6 +1177,7 @@ mod tests {

#[test]
#[cfg_attr(not(all(major_ge_3, minor_ge_4)), ignore)]
#[cfg(any(all(major_is_3, minor_ge_2), major_ge_4))]
fn test_stats() {
// make a copy to avoid writing the statistics into the original file
let fixture = TempFixture::fixture("byte_no_cf.zarr.zip");
Expand Down