New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add wrapper for GDALGetRasterUnitType
#271
Conversation
@@ -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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't find this in the GDAL docs, can we have an assert_ne!(str_ptr, std::ptr::null())
or something like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, I love the undelimited numbers in that |
c05e8aa
to
fec5ccc
Compare
pub fn unit(&self) -> String { | ||
let str_ptr = unsafe { gdal_sys::GDALGetRasterUnitType(self.c_rasterband) }; | ||
|
||
if str_ptr.is_null() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
If you have another file at hand with a unit, I can use it. I just got one from the osgeo gdal repo. |
No, it's fine, I was just surprised that GDAL actually parses that. |
I'll wait a bit, then merge this, it's pretty trivial. |
@bors r+ |
bors r+ |
Build succeeded: |
CHANGES.md
if knowledge of this change could be valuable to users.I've added a wrapper for
GDALGetRasterUnitType
into rasterband. Since I had no test file that has a unit, I added a test file from the original GDAL repo: https://github.com/OSGeo/gdal/blob/96096ae1e61b1b7afdc686ab9a00ca4fee772ba6/autotest/gdrivers/data/usgsdem/114p01_0100_deme_truncated.dem