Skip to content

Commit

Permalink
Merge #416
Browse files Browse the repository at this point in the history
416: Fix build error on GDAL 3.1 r=metasim a=lnicola

- [x] I agree to follow the project's [code of conduct](https://github.com/georust/gdal/blob/master/CODE_OF_CONDUCT.md).
- [x] I added an entry to `CHANGES.md` if knowledge of this change could be valuable to users.
---

~~I didn't add it to CI because one of the tests SIGSEGVs for some reason (probably that NetCDF thing)~~

Co-authored-by: Laurențiu Nicola <[email protected]>
  • Loading branch information
bors[bot] and lnicola authored Jun 5, 2023
2 parents fdbb4f5 + 4b8bc54 commit 26236ba
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
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

0 comments on commit 26236ba

Please sign in to comment.