Skip to main content

ChunkOptions

Struct ChunkOptions 

Source
#[non_exhaustive]
pub struct ChunkOptions {
Show 16 fields pub alg: ResampleAlg, pub scaling: KernelScaling, pub memory_limit: f64, pub src_pixel_bits: f64, pub dst_pixel_bits: f64, pub min_fill_ratio: f64, pub min_split_size: usize, pub dst_block_size: Option<[usize; 2]>, pub special_points: Vec<[f64; 2]>, pub sample_grid: bool, pub sample_steps: SampleSteps, pub source_extra: Option<usize>, pub scale_origin: ScaleOrigin, pub pad_for_fixed_scale: bool, pub split_antimeridian: bool, pub round_trip: Option<RoundTrip>,
}
Expand description

Options for plan_chunks and ChunkPlanner. Build with ChunkOptions::new or ChunkOptions::gdalwarp and the with_ methods.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§alg: ResampleAlg

The resampling method: its kernel radius pads source windows.

§scaling: KernelScaling

How each chunk’s kernel scale is chosen: estimated per chunk (KernelScaling::WidenWhenDownsampling), given (KernelScaling::Fixed, GDAL’s XSCALE/YSCALE) or 1 (KernelScaling::Point).

§memory_limit: f64

Bytes of working memory a chunk may take before it is split (gdalwarp’s -wm). Default DEFAULT_MEMORY_LIMIT.

§src_pixel_bits: f64

Bits of working memory per source pixel, masks included (GDAL’s GetWorkingMemoryForWindow). See ChunkOptions::set_pixel_cost.

§dst_pixel_bits: f64

Bits of working memory per target pixel, masks included.

§min_fill_ratio: f64

A chunk whose source fill ratio is above 0 and below this is split (GDAL: 0.5; 0 turns the heuristic off, as SRC_FILL_RATIO_HEURISTICS=NO).

§min_split_size: usize

… if either side of it is longer than this (GDAL: 100).

§dst_block_size: Option<[usize; 2]>

Block size of the target dataset, for GDAL’s OPTIMIZE_SIZE=AUTO, which splits on block boundaries when the target is at least two blocks each way. None (GDAL with no target dataset, as with an in-memory or striped target) never applies it.

§special_points: Vec<[f64; 2]>

Target pixel positions that force grid sampling of every chunk when one falls in the target (0 <= x <= width, 0 <= y <= height). GDAL uses longitude 0 at latitudes -89.9999 and 89.9999 of the source’s geographic CRS, transformed to target pixels; the caller computes them, as they need the CRS. For a source CRS that is itself geographic in degrees, GDAL 3.6 and later skip the reprojection (GDALTransformLonLatToDestGenImgProjTransformer) and apply the target’s inverse geotransform to (0, -89.9999) and (0, 89.9999) as if they were target coordinates; to match gdalwarp, do the same.

§sample_grid: bool

Sample a grid over each chunk from the start (SAMPLE_GRID=YES).

§sample_steps: SampleSteps

Points per edge (SAMPLE_STEPS).

§source_extra: Option<usize>

Pixels added to every side of each source window (SOURCE_EXTRA). None: 10 when any sample point failed to transform, as GDAL does.

§scale_origin: ScaleOrigin

Where each chunk’s kernel scale is estimated. Default ScaleOrigin::Chunk; GDAL’s is ScaleOrigin::Output.

§pad_for_fixed_scale: bool

With KernelScaling::Fixed, pad source windows for the smaller of the given and the estimated scale, so a kernel stretched by the given scale is not clipped at the window edge. GDAL pads for the estimate only. Default true.

§split_antimeridian: bool

When a chunk’s source window spans the whole source width (GDAL’s 90% rule, as at the antimeridian), find the target columns where source x jumps and split the chunk there, into compact windows either side. The few columns at the jump (the gap) map near both source edges: they become two chunks on the same target window, one window at each edge, so nothing reads the whole width. GDAL does not split (its fill ratio stays high); off by default. Independent of the fill ratio split, apart from its minimum chunk size. Where there is no jump (a window that spans the width because the target covers it), or splitting at it reads no less (round a pole), the chunk is planned by GDAL’s rule, memory and fill ratio both, so the plan is gdalwarp’s plus the splits at jumps.

§round_trip: Option<RoundTrip>

A round-trip check on the forward probe; None (GDAL) checks nothing.

Implementations§

Source§

impl ChunkOptions

Source

pub fn new(alg: ResampleAlg) -> Self

rwarp’s defaults for alg: gdalwarp’s planning with a Byte, one-band, nodata-free working memory cost, except for ScaleOrigin::Chunk and ChunkOptions::pad_for_fixed_scale.

Source

pub fn gdalwarp(alg: ResampleAlg) -> Self

gdalwarp’s planning exactly: ScaleOrigin::Output and no padding for a fixed scale beyond GDAL’s.

Source

pub fn with_alg(self, alg: ResampleAlg) -> Self

Source

pub fn with_scaling(self, scaling: KernelScaling) -> Self

Source

pub fn with_memory_limit(self, bytes: f64) -> Self

Source

pub fn with_pixel_cost( self, working: DataType, nbands: usize, src_nodata: bool, dst_nodata: bool, ) -> Self

Source

pub fn with_fill_ratio_split( self, min_fill_ratio: f64, min_split_size: usize, ) -> Self

Source

pub fn with_dst_block_size(self, block: Option<[usize; 2]>) -> Self

Source

pub fn with_special_points(self, points: Vec<[f64; 2]>) -> Self

Source

pub fn with_sample_grid(self, grid: bool) -> Self

Source

pub fn with_sample_steps(self, steps: SampleSteps) -> Self

Source

pub fn with_source_extra(self, extra: Option<usize>) -> Self

Source

pub fn with_scale_origin(self, origin: ScaleOrigin) -> Self

Source

pub fn with_pad_for_fixed_scale(self, pad: bool) -> Self

Source

pub fn with_split_antimeridian(self, split: bool) -> Self

Source

pub fn with_round_trip(self, round_trip: Option<RoundTrip>) -> Self

Source

pub fn set_pixel_cost( &mut self, working: DataType, nbands: usize, src_nodata: bool, dst_nodata: bool, )

Set the working memory cost per pixel as GDAL counts it for nbands bands in the working type, with a per-band validity mask when the source or the target has nodata. gdalwarp gives the target the source’s nodata unless told otherwise. Add 32 bits to ChunkOptions::src_pixel_bits for a source alpha band or a cutline, 1 for a per-dataset mask; 32 to ChunkOptions::dst_pixel_bits for a target alpha band.

Trait Implementations§

Source§

impl Clone for ChunkOptions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ChunkOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ChunkOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for ChunkOptions

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ChunkOptions

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.