use std::os::raw::{c_char, c_double, c_int, c_void};
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OxiGdalErrorCode {
Success = 0,
NullPointer = 1,
InvalidArgument = 2,
FileNotFound = 3,
IoError = 4,
UnsupportedFormat = 5,
OutOfBounds = 6,
AllocationFailed = 7,
InvalidUtf8 = 8,
DriverError = 9,
ProjectionError = 10,
Unknown = 99,
}
#[repr(C)]
pub struct OxiGdalDataset {
_private: [u8; 0],
}
#[repr(C)]
pub struct OxiGdalBand {
_private: [u8; 0],
}
#[repr(C)]
pub struct OxiGdalLayer {
_private: [u8; 0],
}
#[repr(C)]
pub struct OxiGdalFeature {
_private: [u8; 0],
}
#[repr(C)]
pub struct OxiGdalTile {
_private: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct OxiGdalMetadata {
pub width: c_int,
pub height: c_int,
pub band_count: c_int,
pub data_type: c_int,
pub epsg_code: c_int,
pub geotransform: [c_double; 6],
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct OxiGdalBbox {
pub min_x: c_double,
pub min_y: c_double,
pub max_x: c_double,
pub max_y: c_double,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct OxiGdalPoint {
pub x: c_double,
pub y: c_double,
pub z: c_double,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct OxiGdalTileCoord {
pub z: c_int,
pub x: c_int,
pub y: c_int,
}
#[repr(C)]
#[derive(Debug)]
pub struct OxiGdalBuffer {
pub data: *mut u8,
pub length: usize,
pub width: c_int,
pub height: c_int,
pub channels: c_int,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct OxiGdalEnhanceParams {
pub brightness: c_double,
pub contrast: c_double,
pub saturation: c_double,
pub gamma: c_double,
}
impl Default for OxiGdalEnhanceParams {
fn default() -> Self {
Self {
brightness: 1.0,
contrast: 1.0,
saturation: 1.0,
gamma: 1.0,
}
}
}
pub type OxiGdalString = *mut c_char;
pub type OxiGdalProgressCallback =
extern "C" fn(progress: c_double, message: *const c_char, user_data: *mut c_void) -> c_int;
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct OxiGdalVersion {
pub major: c_int,
pub minor: c_int,
pub patch: c_int,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct OxiGdalStats {
pub min: c_double,
pub max: c_double,
pub mean: c_double,
pub stddev: c_double,
pub valid_count: u64,
}
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum OxiGdalResampling {
Nearest = 0,
#[default]
Bilinear = 1,
Cubic = 2,
Lanczos = 3,
Average = 4,
}
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OxiGdalDataType {
Byte = 0,
UInt16 = 1,
Int16 = 2,
UInt32 = 3,
Int32 = 4,
Float32 = 5,
Float64 = 6,
}
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OxiGdalFilterType {
GaussianBlur = 0,
Sharpen = 1,
EdgeDetect = 2,
Emboss = 3,
}
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OxiGdalCompression {
None = 0,
Deflate = 1,
Lzw = 2,
Jpeg = 3,
Webp = 4,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_error_code_values() {
assert_eq!(OxiGdalErrorCode::Success as i32, 0);
assert_eq!(OxiGdalErrorCode::NullPointer as i32, 1);
assert_eq!(OxiGdalErrorCode::Unknown as i32, 99);
}
#[test]
fn test_metadata_size() {
assert!(std::mem::size_of::<OxiGdalMetadata>() < 256);
}
#[test]
fn test_enhance_params_default() {
let params = OxiGdalEnhanceParams::default();
assert_eq!(params.brightness, 1.0);
assert_eq!(params.contrast, 1.0);
assert_eq!(params.saturation, 1.0);
assert_eq!(params.gamma, 1.0);
}
#[test]
fn test_types_are_repr_c() {
let _: OxiGdalMetadata = unsafe { std::mem::zeroed() };
let _: OxiGdalBbox = unsafe { std::mem::zeroed() };
let _: OxiGdalPoint = unsafe { std::mem::zeroed() };
}
}