Skip to main content

RasterSource

Trait RasterSource 

Source
pub trait RasterSource {
    // Required methods
    fn width(&self) -> usize;
    fn height(&self) -> usize;
    fn read_window(
        &self,
        x: usize,
        y: usize,
        w: usize,
        h: usize,
    ) -> Result<Vec<f32>, RasterError>;
}
Expand description

Trait for raster data sources that can be read in rectangular windows.

Implementations must provide row-major f32 data for any sub-window. Out-of-bounds accesses (when x + w > width or y + h > height) must be zero-padded rather than returning an error, to support halo reads at raster boundaries.

Required Methods§

Source

fn width(&self) -> usize

Total width of the raster in pixels.

Source

fn height(&self) -> usize

Total height of the raster in pixels.

Source

fn read_window( &self, x: usize, y: usize, w: usize, h: usize, ) -> Result<Vec<f32>, RasterError>

Read a rectangular window of pixels into a Vec<f32>, row-major order.

(x, y) is the top-left corner of the window. The returned vector always has exactly w * h elements. Pixels that fall outside the raster extent are returned as 0.0 (zero-padding for halo support).

Returns Err(RasterError::OutOfBounds) when the origin (x, y) is completely outside the raster (i.e. x >= width || y >= height).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§