@@ -4,8 +4,9 @@ use gdal_sys::{
4
4
GDALAdjustValueToDataType , GDALDataType , GDALDataTypeIsConversionLossy , GDALDataTypeIsFloating ,
5
5
GDALDataTypeIsInteger , GDALDataTypeIsSigned , GDALDataTypeUnion , GDALFindDataTypeForValue ,
6
6
GDALGetDataTypeByName , GDALGetDataTypeName , GDALGetDataTypeSizeBits , GDALGetDataTypeSizeBytes ,
7
- GDALRIOResampleAlg ,
7
+ GDALRIOResampleAlg , GDALRasterIOExtraArg ,
8
8
} ;
9
+ use libc:: c_int;
9
10
use std:: ffi:: CString ;
10
11
use std:: fmt:: { Debug , Display , Formatter } ;
11
12
@@ -459,6 +460,67 @@ impl<T: GdalType> Buffer<T> {
459
460
460
461
pub type ByteBuffer = Buffer < u8 > ;
461
462
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
+
462
524
#[ cfg( test) ]
463
525
mod tests {
464
526
use super :: * ;
0 commit comments