Skip to content
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

Merged
merged 3 commits into from May 12, 2022

Conversation

ChristianBeilschmidt
Copy link
Contributor

@ChristianBeilschmidt ChristianBeilschmidt commented May 12, 2022

  • I agree to follow the project's code of conduct.
  • I added an entry to 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

@@ -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.
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lnicola
Copy link
Member

lnicola commented May 12, 2022

Wow, I love the undelimited numbers in that .dem file.

pub fn unit(&self) -> String {
let str_ptr = unsafe { gdal_sys::GDALGetRasterUnitType(self.c_rasterband) };

if str_ptr.is_null() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ChristianBeilschmidt
Copy link
Contributor Author

Wow, I love the undelimited numbers in that .dem file.

If you have another file at hand with a unit, I can use it. I just got one from the osgeo gdal repo.

@lnicola
Copy link
Member

lnicola commented May 12, 2022

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.

@lnicola
Copy link
Member

lnicola commented May 12, 2022

I'll wait a bit, then merge this, it's pretty trivial.

@lnicola
Copy link
Member

lnicola commented May 12, 2022

@bors r+

@lnicola
Copy link
Member

lnicola commented May 12, 2022

bors r+

@bors
Copy link
Contributor

bors bot commented May 12, 2022

Build succeeded:

@bors bors bot merged commit d8aa19a into georust:master May 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants