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

GCP Transformer and create_and_reproject warp. #177

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

michaeljfazio
Copy link

  • [X ] I agree to follow the project's code of conduct.
  • [X ] I added an entry to 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.

@michaeljfazio michaeljfazio force-pushed the gcp-transform branch 2 times, most recently from eba90c9 to 6378737 Compare March 29, 2021 13:36
@michaeljfazio
Copy link
Author

Fixed all clippy issues. Should be good to go now.

gdal_sys::GDALCreateAndReprojectImage(
src.c_dataset(),
null(),
CString::new(psz_dst_filename)?.as_ptr(),
Copy link
Member

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;
Copy link
Contributor

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");
Copy link
Contributor

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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// 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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// * `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.");
Copy link
Contributor

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.");
Copy link
Contributor

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(),
Copy link
Contributor

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?

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.

None yet

4 participants