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 raster creation options #193

Merged
merged 21 commits into from
Jun 22, 2021

Conversation

geohardtke
Copy link
Contributor

@geohardtke geohardtke commented Jun 11, 2021

  • 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.

Please review the additions I made (related to #190 ).

Also, I think there may be a bug in dataset.metadata_item(); which makes the test test_create_with_band_type_with_options() fail, since I can see the COMPRESSION field in the image structure metadata when using gdalinfo. Or am I missing something?

gdalinfo output:

Files: /tmp/test.tif
Size is 256, 256
Image Structure Metadata:
  COMPRESSION=LZW
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,  256.0)
Upper Right (  256.0,    0.0)
Lower Right (  256.0,  256.0)
Center      (  128.0,  128.0)
Band 1 Block=128x64 Type=Byte, ColorInterp=Gray

test error:

thread 'raster::tests::test_create_with_band_type_with_options' panicked at 'assertion failed: `(left == right)`
  left: `None`,
 right: `Some("LZW")`', src/raster/tests.rs:273:5

@geohardtke
Copy link
Contributor Author

It was not a bug in dataset.metadata_item(). The dataset needs to be explicitly dropped before being able to retrieve the metadata. Tests are passing now.

src/driver.rs Outdated Show resolved Hide resolved
src/driver.rs Outdated Show resolved Hide resolved
src/driver.rs Outdated Show resolved Hide resolved
CHANGES.md Outdated Show resolved Hide resolved
CHANGES.md Outdated Show resolved Hide resolved
src/raster/tests.rs Outdated Show resolved Hide resolved
#[test]
fn test_create_with_band_type_with_options() {
let driver = Driver::get("GTiff").unwrap();
let options = vec![
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
let options = vec![
let options = [

src/raster/tests.rs Outdated Show resolved Hide resolved
src/raster/tests.rs Outdated Show resolved Hide resolved
@geohardtke
Copy link
Contributor Author

Thanks for reviewing my changes and your suggestions to improve them, I guess I still have a lot to learn!

Sorry I made a bit of a mess incorporating your suggestions! I didn't see the "commit suggestion" button at first (we use gitlab at work and the workflow is a bit different), I'll be more careful next time.

@lnicola
Copy link
Member

lnicola commented Jun 16, 2021

Yeah, don't worry about the commit attribution (I'd squash these anyway if it was my PR), and sorry for taking so long to review. Tests seem to fail now because of some extra bit of whitespace or something like that.

Unfortunately, I can't merge it (well, I can, but we use bors instead of merging from the GitHub UI), so someone else must take a look.

@lnicola
Copy link
Member

lnicola commented Jun 16, 2021

Just testing:

bors d+

Oh, maybe it isn't set up here?

@bors
Copy link
Contributor

bors bot commented Jun 16, 2021

🔒 Permission denied

Existing reviewers: click here to make lnicola a reviewer

@geohardtke
Copy link
Contributor Author

yes, it seems to be an extra space in the test. I'll fix it now.

@lnicola
Copy link
Member

lnicola commented Jun 16, 2021

PS: you can add your (presumably) other email address to your GitHub account so that you don't show as two different people.

@lnicola
Copy link
Member

lnicola commented Jun 16, 2021

Can you add a link to the PR in the changelog?

@lnicola
Copy link
Member

lnicola commented Jun 16, 2021

r? @jdroenner

@lnicola
Copy link
Member

lnicola commented Jun 18, 2021

So if you want to look into a builder API in the meanwhile, it would be awesome :-).

@geohardtke
Copy link
Contributor Author

Sure, I can open another issue and we discuss there.

Copy link
Member

@jdroenner jdroenner left a comment

Choose a reason for hiding this comment

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

i like the feature. will test it this weekend :)

@@ -89,7 +120,7 @@ impl Driver {
size_y as c_int,
bands as c_int,
T::gdal_type(),
null_mut(),
options_c as *mut *mut i8,
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't this be a *mut * mut char?

Copy link
Member

@lnicola lnicola Jun 18, 2021

Choose a reason for hiding this comment

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

You mean c_char?

Seen as char** from C and const char* const* from C++

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, options_c as *mut *mut i8 is correct. I'm not sure how it ended up being null_mut() again, sorry.

Copy link
Member

Choose a reason for hiding this comment

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

It's not null_mut(), it's options_c as *mut *mut i8, jdroenner is asking if it should be options_c as *mut *mut c_char.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh, sorry! my bad. Blame Friday night.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

gdal_sys::GDALCreate expects *mut *mut i8.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, it's defined as char** in the GDAL headers. We might be able to improve the bindings, but I think we shouldn't block merging this.

Copy link
Contributor Author

@geohardtke geohardtke Jun 21, 2021

Choose a reason for hiding this comment

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

Any thoughts @jdroenner? Do the bindings need to be updated before merging this? I think I don't have enough knowledge to do that.

Copy link
Member

Choose a reason for hiding this comment

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

no its fine. i just assumed it to be a char in the bindings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool! Thanks!

@jdroenner jdroenner merged commit 36e9365 into georust:master Jun 22, 2021
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.

3 participants