Skip to content

fix: support GDAL 3.13 (GDT_Byte to GDT_UInt8, bOperateInBufType)#714

Open
AlexanderWillner wants to merge 2 commits into
georust:masterfrom
AlexanderWillner:fix/gdal-3.13-compat
Open

fix: support GDAL 3.13 (GDT_Byte to GDT_UInt8, bOperateInBufType)#714
AlexanderWillner wants to merge 2 commits into
georust:masterfrom
AlexanderWillner:fix/gdal-3.13-compat

Conversation

@AlexanderWillner

Copy link
Copy Markdown

Summary

GDAL 3.13 renamed GDT_Byte to GDT_UInt8 in the C API enum and added bOperateInBufType to GDALRasterIOExtraArg. This broke the Rust bindings at both compile and link time.

Changes

  • gdal-sys/Cargo.toml: Add missing bindgen feature (bindgen = ["dep:bindgen"]) so bindings can be generated at build time
  • src/raster/types.rs: Gate all GDT_Byte references behind #[cfg(not(all(major_ge_3, minor_ge_13)))] with GDT_UInt8 fallback for >= 3.13 (enum discriminant, TryFrom, GdalType impl, test match arms)
  • src/raster/rasterband.rs: Add bOperateInBufType: 0 field to GDALRasterIOExtraArg struct init for >= 3.13
  • src/raster/mdarray.rs: Gate GDT_Byte in test assertion with GDT_UInt8 fallback

Testing

Built and tested against GDAL 3.13.0 on macOS aarch64 with cargo test --features bindgen:

  • 279 passed, 2 failed (pre-existing GDAL 3.13 behavioral changes, not API compat):
    • test_slope: floating point precision difference in DEM slope calculation
    • test_make_valid_invalid: make_valid no longer errors on that input

GDAL 3.13 renamed GDT_Byte to GDT_UInt8 and added
bOperateInBufType to GDALRasterIOExtraArg.

- Add cfg-gated GDT_UInt8 fallback for GDAL >= 3.13 in types.rs
- Add bOperateInBufType field in rasterband.rs struct init
- Add bindgen feature to gdal-sys (was missing)
- Fix GDT_Byte reference in mdarray.rs test
@lnicola

lnicola commented May 16, 2026

Copy link
Copy Markdown
Member

Thanks. The GDT_Byte thing is really annoying, I don't think we can easily inject it without introducing an extra nested submodule :(.

Comment thread src/raster/types.rs
impl GdalType for u8 {
fn gdal_ordinal() -> GDALDataType::Type {
GDALDataType::GDT_Byte
#[cfg(not(all(major_ge_3, minor_ge_13)))]

@lnicola lnicola May 16, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add some newlines here or run cargo fmt?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 2f7da56. Applied cargo fmt.

Comment thread gdal-sys/Cargo.toml Outdated

[features]
default = []
bindgen = ["dep:bindgen"]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think this does anything? You can already run cargo check --features bindgen or cargo check -p gdal-sys --features bindgen.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

You're right, removed in 2f7da56. Cargo auto-creates the feature from the optional dep.

Remove redundant bindgen feature from gdal-sys/Cargo.toml (optional
dep already auto-creates it). Apply cargo fmt to cfg-gated blocks.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@gabe-lepo

Copy link
Copy Markdown

Thanks @AlexanderWillner ! Im just getting into GDAL recently and ran into this issue. Pointing my project's dep at your branch and its working well.

@lukehsiao

lukehsiao commented Jun 12, 2026

Copy link
Copy Markdown

Upstream now released gdal 3.13.1. Anything I can do to help this PR?

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.

4 participants