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

Expansion of Warp API bindings #508

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Conversation

metasim
Copy link
Contributor

@metasim metasim commented Dec 28, 2023

  • I agree to follow the project's code of conduct.
  • I added an entry to CHANGES.md if knowledge of this change could be valuable to users.

  • Extract replicated methods in *Options types into macros.
  • Figure out why warp::tests::test_create_reproject fails on GDAL < 3.4 due to statistics seemingly not respecting no-data values.

@metasim metasim force-pushed the feature/warp branch 2 times, most recently from 9e9ba71 to c6438bb Compare December 29, 2023 15:52
CHANGES.md Show resolved Hide resolved
driver.c_driver(),
ptr::null_mut(),
warp_options.resampling_alg().to_gdal(),
warp_options.memory_limit() as f64,
Copy link
Member

Choose a reason for hiding this comment

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

I wonder why this is double 😄.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤷

/// Set the datatype used during processing.
///
/// If unset, the algorithm picks the datatype.
pub fn with_working_datatype(&mut self, dt: GdalDataType) -> &mut Self {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: do we use datatype or data_type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're not consistent by any stretch:

❯ rg --count-matches --ignore-case datatype --glob '*.rs' src
src/driver.rs:12
src/errors.rs:2
src/raster/tests.rs:6
src/raster/types.rs:177
src/raster/mod.rs:4
src/raster/rasterize.rs:1
src/raster/rasterband.rs:9
src/raster/mdarray.rs:76
❯ rg --count-matches --ignore-case 'data[-_]type' --glob '*.rs' src
src/raster/mdarray.rs:25
src/errors.rs:2
src/driver.rs:2
src/raster/types.rs:3

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have a bias toward the one word "datatype" form.

Since Wiktionary is our authoritative source for justifying our own spelling biases, I think I'm justified! 🤣

https://en.wiktionary.org/wiki/datatype

let dt: GdalDataType = c_dt.try_into().ok()?;

// Default is `Unknown`, so we consider that "unspecified".
if dt == GdalDataType::Unknown {
Copy link
Member

Choose a reason for hiding this comment

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

This might be a little confusing, should we drop the Option?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we did, would we change this

let dt: GdalDataType = c_dt.try_into().ok()?;

to

let dt: GdalDataType = c_dt.try_into().unwrap_or(GdalDataType::Unknown);

?

src/xml.rs Outdated Show resolved Hide resolved
}
}

impl Display for GdalXmlNode {
Copy link
Member

Choose a reason for hiding this comment

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

Should this also implement ToString?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've tended to conflate Display and ToString (since Display is ToString). Any advice on how to decide?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting... Docs say this:

image

@lnicola
Copy link
Member

lnicola commented Jan 3, 2024

Looks pretty good, but I only checked the first two commits.

@lnicola
Copy link
Member

lnicola commented Jan 3, 2024

I do wonder, though, if we shouldn't go straight for GDALWarp. It's not that much harder to use, and I think that mailing list reply suggested that it's the most powerful API.

@metasim
Copy link
Contributor Author

metasim commented Jan 3, 2024

I do wonder, though, if we shouldn't go straight for GDALWarp. It's not that much harder to use, and I think that mailing list reply suggested that it's the most powerful API.

Good point. I'll research. At first glance it looked like it required a bunch more work, but maybe I jumped to conclusions there.

@lnicola
Copy link
Member

lnicola commented Jan 3, 2024

It's a lot of work to write the bindings for, it's similar to gdaldem.

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

2 participants