GCP Transformer and create_and_reproject warp.#177
GCP Transformer and create_and_reproject warp.#177michaeljfazio wants to merge 1 commit intogeorust:masterfrom
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.
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.
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.
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.
| /// 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.
| /// * `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.
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."); |
| }; | ||
|
|
||
| gdal_sys::GDAL_GCP { | ||
| pszId: CString::new(p.id.clone()).unwrap().into_raw(), |
There was a problem hiding this comment.
Is this use after free?
Instead of unwrap, should an Err be returned?
CHANGES.mdif 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.