-
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
ENH: Add CoordTransform::transform_bounds() #272
Conversation
I'd like to add an example to |
src/spatial_ref/srs.rs
Outdated
Ok([out_xmin, out_ymin, out_xmax, out_ymax]) | ||
} else { | ||
let err = _last_cpl_err(CPLErr::CE_Failure); | ||
let msg = if let GdalError::CplError { msg, .. } = err { |
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.
A match
might look nicer here (you can probably drop the trim
), but it probably doesn't matter too much.
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.
This was copy-pasted from transform_coords
for consistency; ideally both would get updated to be the same if match
is more appropriate. I can update just this one here and the other in a follow up PR, or both in a follow up PR.
I'd probably also want to invert the logic a little bit so that only the error case is in the conditional and have a bare Ok
:
if !ret_val {...handle error and return... }
Ok([out_xmin, out_ymin, out_xmax, out_ymax])
But didn't do so in this PR out of consistency.
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 update just this one here and the other in a follow up PR, or both in a follow up PR.
Right, it's fine either way.
Test failure seems unrelated:
|
/// None if there is an error. | ||
#[cfg(all(major_ge_3, minor_ge_4))] | ||
pub fn transform_bounds(&self, bounds: &[f64; 4], densify_pts: i32) -> Result<([f64; 4])> { | ||
let mut out_xmin: f64 = 0.; |
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.
You'll have to move the use
here to avoid the warning. Or you might be able to skip the casts, like in transform_coords
, I'm not sure.
Still a formatting error (try |
LGTM, I'll merge this tomorrow unless anyone else has objections. |
bors r+ |
Build succeeded: |
CHANGES.md
if knowledge of this change could be valuable to users.This wraps
OCTTransformBounds
to provideCoordTransform::transform_bounds()
for GDAL >= 3.4Output values were verified manually using rasterio.