-
Notifications
You must be signed in to change notification settings - Fork 94
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
GCP Transformer and create_and_reproject warp. #177
base: master
Are you sure you want to change the base?
Conversation
eba90c9
to
6378737
Compare
6378737
to
5561935
Compare
Fixed all clippy issues. Should be good to go now. |
gdal_sys::GDALCreateAndReprojectImage( | ||
src.c_dataset(), | ||
null(), | ||
CString::new(psz_dst_filename)?.as_ptr(), |
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 is a use-after-free: the CString
is destroyed before GDALCreateAndReprojectImage
runs.
/// # Examples | ||
/// | ||
/// ```no_run | ||
/// use std::path::Path; |
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.
Does rustdoc
still compile this without rust
in fence suffix. i.e. does this need to be rust, no_run
?
/// use gdal::Dataset; | ||
/// use gdal::alg::transform::Transformer; | ||
/// | ||
/// let path = Path::new("/path/to/dataset"); |
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.
Can we use a file in fixtures
to demo this? If no, can we construct a very small example file with GCPs and save it there?
} | ||
|
||
impl Transformer { | ||
/// Construct a ```Transformer``` from a valid C GDAL pointer to a transformer instance. |
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.
/// Construct a ```Transformer``` from a valid C GDAL pointer to a transformer instance. | |
/// Construct a [`Transformer`] from a valid C GDAL pointer to a transformer instance. |
/// | ||
/// # Arguments | ||
/// | ||
/// * `dataset` - The `Dataset` to extract Ground Control Points from. |
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.
/// * `dataset` - The `Dataset` to extract Ground Control Points from. | |
/// * `dataset` - The [`Dataset`] to extract Ground Control Points from. |
) -> Result<()> { | ||
let psz_dst_filename = dst_path | ||
.to_str() | ||
.expect("Destination path must be supplied."); |
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.
Won't this panic
? Can you return an Err
instead?
let psz_dst_filename = dst_path | ||
.to_str() | ||
.expect("Destination path must be supplied."); | ||
let psz_dst_wkt = dst_srs.to_wkt().expect("Failed to obtain WKT for SRS."); |
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.
ditto?
}; | ||
|
||
gdal_sys::GDAL_GCP { | ||
pszId: CString::new(p.id.clone()).unwrap().into_raw(), |
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.
Is this use after free?
Instead of unwrap
, should an Err
be returned?
CHANGES.md
if knowledge of this change could be valuable to users.This change adds a wrapper for the GDAL Transformer abstraction. An initial implementation of the GCP based polynomial transformer has also been added. Future versions should look to extend the Transformer abstraction to include other implementations such as:
Also included in the change set is an implementation of GDALCreateAndReprojectImage function.