Skip to content

Commit

Permalink
Check output type in read_block
Browse files Browse the repository at this point in the history
  • Loading branch information
lnicola committed Dec 10, 2023
1 parent 30fea92 commit 6539681
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/raster/rasterband.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,11 @@ impl<'a> RasterBand<'a> {
/// # Notes
/// The Matrix shape is (rows, cols) and raster shape is (cols in x-axis, rows in y-axis).
pub fn read_block<T: Copy + GdalType>(&self, block_index: (usize, usize)) -> Result<Array2<T>> {
if T::gdal_ordinal() != self.band_type().into() {
return Err(GdalError::BadArgument(
"result array type must match band data type".to_string(),
));
}
let size = self.block_size();
let pixels = size.0 * size.1;
let mut data: Vec<T> = Vec::with_capacity(pixels);
Expand Down

0 comments on commit 6539681

Please sign in to comment.