Skip to content

Commit

Permalink
Switched to single set_no_data_value method, introducing a breaking…
Browse files Browse the repository at this point in the history
… change.
  • Loading branch information
metasim committed Sep 8, 2022
1 parent b53d0f9 commit 2a5abc3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

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

- Added ability to delete no-data when `None` is passed to `RasterBand::set_no_data(&mut self, no_data: Option<f64>))`
- **Breaking** `RasterBand::set_no_data_value` takes `Option<f64>` instead of `f64` so that no _no-data_ can be set.
Also makes it symmetric with `RasterBand::no_data_value` which returns `Option<f64>`.

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

Expand Down
9 changes: 1 addition & 8 deletions src/raster/rasterband.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,15 +432,8 @@ impl<'a> RasterBand<'a> {

/// Set the no data value of this band.
///
/// See [`set_no_data`](Self::set_no_data) for similar function
/// where _no-data_ can also be deleted.
pub fn set_no_data_value(&mut self, no_data: f64) -> Result<()> {
self.set_no_data(Some(no_data))
}

/// Set the no data state of this band.
/// If `no_data` is `None`, any existing no-data value is deleted.
pub fn set_no_data(&mut self, no_data: Option<f64>) -> Result<()> {
pub fn set_no_data_value(&mut self, no_data: Option<f64>) -> Result<()> {
let rv = if let Some(no_data) = no_data {
unsafe { gdal_sys::GDALSetRasterNoDataValue(self.c_rasterband, no_data) }
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/raster/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,9 +557,9 @@ fn test_set_no_data_value() {
let dataset = driver.create("", 20, 10, 1).unwrap();
let mut rasterband = dataset.rasterband(1).unwrap();
assert_eq!(rasterband.no_data_value(), None);
assert!(rasterband.set_no_data_value(1.23).is_ok());
assert!(rasterband.set_no_data_value(Some(1.23)).is_ok());
assert_eq!(rasterband.no_data_value(), Some(1.23));
assert!(rasterband.set_no_data(None).is_ok());
assert!(rasterband.set_no_data_value(None).is_ok());
assert_eq!(rasterband.no_data_value(), None);
}

Expand Down

0 comments on commit 2a5abc3

Please sign in to comment.