Allow reading block-size of Rasters
1. implemented GetBlockSize
2. added feature flag "gdal_2_2" to enable recent GDAL
functions.
3. implemented GetActualBlockSize (behind "gdal_2_2" flag)
MODIFY
Cargo.toml
Cargo.toml
@@ -12,6 +12,7 @@ documentation = "https://georust.github.io/gdal/"
[features]
bindgen = ["gdal-sys/bindgen"]
+gdal_2_2 = ["gdal-sys/min_gdal_version_2_2"]
[dependencies]
failure = "0.1"

MODIFY
src/raster/rasterband.rs
src/raster/rasterband.rs
@@ -150,6 +150,35 @@ impl <'a> RasterBand<'a> {
}
None
}
+
+ pub fn block_size(&self) -> (usize, usize) {
+ let mut block_size_x = 0;
+ let mut block_size_y = 0;
+ unsafe { gdal_sys::GDALGetBlockSize(
+ self.c_rasterband,
+ &mut block_size_x,
+ &mut block_size_y,
+ )}
+ (block_size_x as usize, block_size_y as usize)
+ }
+
+ #[cfg(feature = "gdal_2_2")]
+ pub fn actual_block_size(&self, offset: (isize, isize))
+ -> Result<(usize, usize)>{
+ let mut block_size_x = 0;
+ let mut block_size_y = 0;
+ let rv = unsafe { gdal_sys::GDALGetActualBlockSize(
+ self.c_rasterband,
+ offset.0 as libc::c_int,
+ offset.1 as libc::c_int,
+ &mut block_size_x,
+ &mut block_size_y,
+ )};
+ if rv != CPLErr::CE_None {
+ Err(_last_cpl_err(rv))?;
+ }
+ Ok((block_size_x as usize, block_size_y as usize))
+ }
}
impl<'a> MajorObject for RasterBand<'a> {

Allow reading block-size of Rasters

1. implemented GetBlockSize
2. added feature flag "gdal_2_2" to enable recent GDAL
functions.
3. implemented GetActualBlockSize (behind "gdal_2_2" flag)