Skip to content

Commit

Permalink
Add wrapper for GDALGetRasterUnitType
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianBeilschmidt committed May 12, 2022
1 parent 8380387 commit c05e8aa
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions fixtures/114p01_0100_deme_truncated.dem
@@ -0,0 +1 @@
114p01DEMe Base Mapping and Geomatic Services - B.C. Gov. - Victoria -13615 0.0000 59 0 0.00009 BC 1 1 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 3 2 4 -4.905000e+05 2.124000e+05 -4.905000e+05 2.133000e+05 -4.896000e+05 2.133000e+05 -4.896000e+05 2.124000e+05 -3.276700e+04 -3.276700e+04 0.0 07.500000e-017.500000e-011.000000e+00 1 1 1 4 1 1 1201 1 -4.905000000000000e+05 2.124000000000000e+05 0.000000000000000e+00 -3.276700000000000e+04 -3.276700000000000e+04-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767 -32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767 -32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767 -32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767 -32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767 -32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767 -32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767 -32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767-32767
7 changes: 7 additions & 0 deletions src/raster/rasterband.rs
Expand Up @@ -449,6 +449,13 @@ impl<'a> RasterBand<'a> {
Ok(RasterBand::from_c_rasterband(self.dataset, overview))
}
}

/// Return the unit of the rasterband.
/// If there is no unit, the empty string is returned.
pub fn unit(&self) -> String {
let str_ptr = unsafe { gdal_sys::GDALGetRasterUnitType(self.c_rasterband) };
_string(str_ptr)
}
}

impl<'a> MajorObject for RasterBand<'a> {
Expand Down
13 changes: 13 additions & 0 deletions src/raster/tests.rs
Expand Up @@ -592,3 +592,16 @@ fn test_color_interp_names() {
ColorInterpretation::Undefined
);
}

#[test]
fn test_rasterband_unit() {
let dataset = Dataset::open(fixture!("tinymarble.tif")).unwrap();
let rasterband = dataset.rasterband(1).unwrap();

assert!(rasterband.unit().is_empty());

let dataset = Dataset::open(fixture!("114p01_0100_deme_truncated.dem")).unwrap();
let rasterband = dataset.rasterband(1).unwrap();

assert_eq!(rasterband.unit(), "m".to_string());
}

0 comments on commit c05e8aa

Please sign in to comment.