Skip to content

Commit 84fbaf3

Browse files
committed
Move RasterIOExtraArg to raster::types
1 parent 520c17d commit 84fbaf3

File tree

2 files changed

+64
-62
lines changed

2 files changed

+64
-62
lines changed

src/raster/rasterband.rs

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::dataset::Dataset;
22
use crate::gdal_major_object::MajorObject;
33
use crate::metadata::Metadata;
4+
use crate::raster::types::RasterIOExtraArg;
45
use crate::raster::{Buffer, GdalDataType, GdalType, ResampleAlg};
56
use crate::utils::{_last_cpl_err, _last_null_pointer_err, _string};
67
use gdal_sys::{
@@ -50,67 +51,6 @@ impl GdalMaskFlags {
5051
}
5152
}
5253

53-
/// Extra options used to read a raster.
54-
///
55-
/// For documentation, see `gdal_sys::GDALRasterIOExtraArg`.
56-
#[derive(Debug)]
57-
#[allow(clippy::upper_case_acronyms)]
58-
pub struct RasterIOExtraArg {
59-
pub n_version: usize,
60-
pub e_resample_alg: ResampleAlg,
61-
pub pfn_progress: gdal_sys::GDALProgressFunc,
62-
p_progress_data: *mut libc::c_void,
63-
pub b_floating_point_window_validity: usize,
64-
pub df_x_off: f64,
65-
pub df_y_off: f64,
66-
pub df_x_size: f64,
67-
pub df_y_size: f64,
68-
}
69-
70-
impl Default for RasterIOExtraArg {
71-
fn default() -> Self {
72-
Self {
73-
n_version: 1,
74-
pfn_progress: None,
75-
p_progress_data: std::ptr::null_mut(),
76-
e_resample_alg: ResampleAlg::NearestNeighbour,
77-
b_floating_point_window_validity: 0,
78-
df_x_off: 0.0,
79-
df_y_off: 0.0,
80-
df_x_size: 0.0,
81-
df_y_size: 0.0,
82-
}
83-
}
84-
}
85-
86-
impl From<RasterIOExtraArg> for GDALRasterIOExtraArg {
87-
fn from(arg: RasterIOExtraArg) -> Self {
88-
let RasterIOExtraArg {
89-
n_version,
90-
e_resample_alg,
91-
pfn_progress,
92-
p_progress_data,
93-
b_floating_point_window_validity,
94-
df_x_off,
95-
df_y_off,
96-
df_x_size,
97-
df_y_size,
98-
} = arg;
99-
100-
GDALRasterIOExtraArg {
101-
nVersion: n_version as c_int,
102-
eResampleAlg: e_resample_alg.to_gdal(),
103-
pfnProgress: pfn_progress,
104-
pProgressData: p_progress_data,
105-
bFloatingPointWindowValidity: b_floating_point_window_validity as c_int,
106-
dfXOff: df_x_off,
107-
dfYOff: df_y_off,
108-
dfXSize: df_x_size,
109-
dfYSize: df_y_size,
110-
}
111-
}
112-
}
113-
11454
/// Represents a single band of a dataset.
11555
///
11656
/// This object carries the lifetime of the dataset that

src/raster/types.rs

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ use gdal_sys::{
44
GDALAdjustValueToDataType, GDALDataType, GDALDataTypeIsConversionLossy, GDALDataTypeIsFloating,
55
GDALDataTypeIsInteger, GDALDataTypeIsSigned, GDALDataTypeUnion, GDALFindDataTypeForValue,
66
GDALGetDataTypeByName, GDALGetDataTypeName, GDALGetDataTypeSizeBits, GDALGetDataTypeSizeBytes,
7-
GDALRIOResampleAlg,
7+
GDALRIOResampleAlg, GDALRasterIOExtraArg,
88
};
9+
use libc::c_int;
910
use std::ffi::CString;
1011
use std::fmt::{Debug, Display, Formatter};
1112

@@ -459,6 +460,67 @@ impl<T: GdalType> Buffer<T> {
459460

460461
pub type ByteBuffer = Buffer<u8>;
461462

463+
/// Extra options used to read a raster.
464+
///
465+
/// For documentation, see `gdal_sys::GDALRasterIOExtraArg`.
466+
#[derive(Debug)]
467+
#[allow(clippy::upper_case_acronyms)]
468+
pub struct RasterIOExtraArg {
469+
pub n_version: usize,
470+
pub e_resample_alg: ResampleAlg,
471+
pub pfn_progress: gdal_sys::GDALProgressFunc,
472+
pub p_progress_data: *mut libc::c_void,
473+
pub b_floating_point_window_validity: usize,
474+
pub df_x_off: f64,
475+
pub df_y_off: f64,
476+
pub df_x_size: f64,
477+
pub df_y_size: f64,
478+
}
479+
480+
impl Default for RasterIOExtraArg {
481+
fn default() -> Self {
482+
Self {
483+
n_version: 1,
484+
pfn_progress: None,
485+
p_progress_data: std::ptr::null_mut(),
486+
e_resample_alg: ResampleAlg::NearestNeighbour,
487+
b_floating_point_window_validity: 0,
488+
df_x_off: 0.0,
489+
df_y_off: 0.0,
490+
df_x_size: 0.0,
491+
df_y_size: 0.0,
492+
}
493+
}
494+
}
495+
496+
impl From<RasterIOExtraArg> for GDALRasterIOExtraArg {
497+
fn from(arg: RasterIOExtraArg) -> Self {
498+
let RasterIOExtraArg {
499+
n_version,
500+
e_resample_alg,
501+
pfn_progress,
502+
p_progress_data,
503+
b_floating_point_window_validity,
504+
df_x_off,
505+
df_y_off,
506+
df_x_size,
507+
df_y_size,
508+
} = arg;
509+
510+
GDALRasterIOExtraArg {
511+
nVersion: n_version as c_int,
512+
eResampleAlg: e_resample_alg.to_gdal(),
513+
pfnProgress: pfn_progress,
514+
pProgressData: p_progress_data,
515+
bFloatingPointWindowValidity: b_floating_point_window_validity as c_int,
516+
dfXOff: df_x_off,
517+
dfYOff: df_y_off,
518+
dfXSize: df_x_size,
519+
dfYSize: df_y_size,
520+
}
521+
}
522+
}
523+
462524
#[cfg(test)]
463525
mod tests {
464526
use super::*;

0 commit comments

Comments
 (0)