pub struct RasterWindow {
pub col_off: u32,
pub row_off: u32,
pub width: u32,
pub height: u32,
}Expand description
A sub-region window into a raster dataset. Defines a rectangular area for reading/writing a portion of raster data.
Fields§
§col_off: u32Column offset from the left edge (0-based)
row_off: u32Row offset from the top edge (0-based)
width: u32Width of the window in pixels
height: u32Height of the window in pixels
Implementations§
Source§impl RasterWindow
impl RasterWindow
Sourcepub fn new(col_off: u32, row_off: u32, width: u32, height: u32) -> Result<Self>
pub fn new(col_off: u32, row_off: u32, width: u32, height: u32) -> Result<Self>
Create a new window. Validates that width and height are > 0.
Sourcepub fn full(raster_width: u32, raster_height: u32) -> Result<Self>
pub fn full(raster_width: u32, raster_height: u32) -> Result<Self>
Create a window covering the full extent of a raster.
Sourcepub fn fits_within(&self, raster_width: u32, raster_height: u32) -> bool
pub fn fits_within(&self, raster_width: u32, raster_height: u32) -> bool
Check if this window fits within a raster of the given dimensions.
Sourcepub fn validate_bounds(
&self,
raster_width: u32,
raster_height: u32,
) -> Result<()>
pub fn validate_bounds( &self, raster_width: u32, raster_height: u32, ) -> Result<()>
Validate that this window fits within the given raster dimensions. Returns an error if any part is out of bounds.
Sourcepub fn pixel_count(&self) -> u64
pub fn pixel_count(&self) -> u64
Total number of pixels in this window.
Sourcepub fn intersection(&self, other: &RasterWindow) -> Option<RasterWindow>
pub fn intersection(&self, other: &RasterWindow) -> Option<RasterWindow>
Intersect this window with another, returning the overlapping region. Returns None if they don’t overlap.
Sourcepub fn union_bounds(&self, other: &RasterWindow) -> RasterWindow
pub fn union_bounds(&self, other: &RasterWindow) -> RasterWindow
Compute the union bounding box of this window and another.
Sourcepub fn contains_pixel(&self, col: u32, row: u32) -> bool
pub fn contains_pixel(&self, col: u32, row: u32) -> bool
Check if this window contains the given pixel coordinates.
Sourcepub fn subdivide(
&self,
tile_width: u32,
tile_height: u32,
) -> Result<Vec<RasterWindow>>
pub fn subdivide( &self, tile_width: u32, tile_height: u32, ) -> Result<Vec<RasterWindow>>
Subdivide this window into tiles of the given size. The last tiles in each row/column may be smaller.
Sourcepub fn to_global(&self, local_col: u32, local_row: u32) -> Result<(u32, u32)>
pub fn to_global(&self, local_col: u32, local_row: u32) -> Result<(u32, u32)>
Convert a pixel coordinate from window-local to global raster coordinates.
Sourcepub fn to_local(&self, global_col: u32, global_row: u32) -> Option<(u32, u32)>
pub fn to_local(&self, global_col: u32, global_row: u32) -> Option<(u32, u32)>
Convert a pixel coordinate from global raster to window-local coordinates. Returns None if the global coordinate is outside this window.
Trait Implementations§
Source§impl Clone for RasterWindow
impl Clone for RasterWindow
Source§fn clone(&self) -> RasterWindow
fn clone(&self) -> RasterWindow
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more