-
Notifications
You must be signed in to change notification settings - Fork 96
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
Made mapping between ResampleAlg
and GDALRIOResampleAlg
more direct.
#309
Conversation
Before the private function `map_resample_alg` was the only way to get the expected GDAL enumeration value.
} | ||
|
||
fn map_resample_alg(alg: &ResampleAlg) -> u32 { |
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.
Note: this was not private before, so there was no easy way to map values when calling into lower level gdal-sys
functions.
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.
Also, the return type should have been GDALRIOResampleAlg::Type
.
#[derive(Debug, Copy, Clone)] | ||
#[repr(u32)] |
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.
Not entirely sure about this value, or even if it should be specified.
GDALRIOResampleAlg::Type
is libc::c_uint
, which is u32
on *nix. The repr options maybe suggest #[repr(C)]
should be used instead, and the right value will be selected based on the discriminant values? Advice appreciated.
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 don't think we need the #[repr]
, given the cast in to_gdal
. Or does the compiler pick isize
there?
EDIT: yeah, I think u32
is fine here. We could also keep the match
in to_gdal
.
/// assert!(buf.data.iter().all(|c| (c - stats.mean).abs() < stats.std_dev / 2.0)); | ||
/// # Ok(()) | ||
/// # } | ||
/// ``` |
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.
Bonus documentation while I was in there :)
bors r+ |
🔒 Permission denied Existing reviewers: click here to make metasim a reviewer |
bors r+ |
Build succeeded: |
Before the private function
map_resample_alg
was the only way to get the expected GDAL enumeration value.CHANGES.md
if knowledge of this change could be valuable to users.Before this change, you had to copy
map_resample_alg
(because it was private) when calling intogdal-sys
functions needing the resampling algorithm (e.g.GDALAutoCreateWarpedVRT
). Instead of makingpub fn map_resample_alg ...
, took the approach that more tightly binds the C-side types to the Rust enum. Makes the association more clear, and less error prone in the future.