Table of Contents

Class GridRegion

Namespace
EncDotNet.S100.Pipelines.Coverage
Assembly
EncDotNet.S100.Core.dll

A rectangular subset of a coverage grid plus a sampling stride, passed to Sample(GridRegion, CancellationToken). Bounds are zero-based cell indices with inclusive starts and exclusive ends; a null bound means the corresponding grid edge.

public class GridRegion
Inheritance
GridRegion
Inherited Members

Constructors

GridRegion(int?, int?, int?, int?, int, int)

Creates a grid region.

public GridRegion(int? rowStart, int? rowEnd, int? colStart, int? colEnd, int rowStride, int colStride)

Parameters

rowStart int?

First row to sample (inclusive), or null for row 0.

rowEnd int?

Row at which sampling stops (exclusive), or null for the grid's row count.

colStart int?

First column to sample (inclusive), or null for column 0.

colEnd int?

Column at which sampling stops (exclusive), or null for the grid's column count.

rowStride int

Sample every rowStride-th row; 1 samples every row.

colStride int

Sample every colStride-th column; 1 samples every column.

Properties

ColEnd

Column at which sampling stops (exclusive), or null for the grid's column count.

public int? ColEnd { get; }

Property Value

int?

ColStart

First column to sample (inclusive), or null for column 0.

public int? ColStart { get; }

Property Value

int?

ColStride

Column downsampling stride; 1 samples every column.

public int ColStride { get; }

Property Value

int

Full

A region covering the whole grid at stride 1. Returns a new instance on each access.

public static GridRegion Full { get; }

Property Value

GridRegion

RowEnd

Row at which sampling stops (exclusive), or null for the grid's row count.

public int? RowEnd { get; }

Property Value

int?

RowStart

First row to sample (inclusive), or null for row 0.

public int? RowStart { get; }

Property Value

int?

RowStride

Row downsampling stride; 1 samples every row.

public int RowStride { get; }

Property Value

int

Methods

FromViewport(Viewport, GridMetadata, string, ICrsTransform?)

Computes the GridRegion that samples only the cells the supplied viewport can display, at a stride matched to the viewport's ground resolution.

public static GridRegion FromViewport(Viewport viewport, GridMetadata grid, string gridCrs = "EPSG:4326", ICrsTransform? wgs84ToNative = null)

Parameters

viewport Viewport

The current display area (EPSG:4326 bounding box + pixel dimensions).

grid GridMetadata

The coverage's GridMetadata. Its Origin* and Spacing* fields are interpreted in the grid's native CRS (degrees for EPSG:4326, metres for projected CRSs such as UTM).

gridCrs string

The grid's native CRS, e.g. "EPSG:4326" or "EPSG:32608". Defaults to "EPSG:4326".

wgs84ToNative ICrsTransform

Optional transform from EPSG:4326 (viewport CRS) to the grid's native CRS. Required when gridCrs is not "EPSG:4326". Ignored when the grid CRS is EPSG:4326 or the supplied transform reports IsIdentity. Obtain via factory.Create("EPSG:4326", gridCrs).

Returns

GridRegion

A concrete GridRegion (no null bounds) with:

  • Row/col bounds clamped to the grid dimensions. When the viewport does not intersect the grid at all the region is empty (RowStart == RowEnd or ColStart == ColEnd), which the grid sources handle as a zero-cell sample without allocation.
  • Stride derived from the ratio of viewport ground resolution to grid cell size, floored to an integer and clamped to ≥ 1. When the viewport resolves each cell to less than one screen pixel the stride collapses to 1 (do not oversample below the display).

Remarks

This is the render-time entry point for viewport-scoped coverage sampling (issue #487). Assumes the viewport does not cross the antimeridian.

Exceptions

ArgumentException

Thrown when gridCrs is not EPSG:4326 and no wgs84ToNative transform is supplied.

Resolve(int, int)

Resolves nullable bounds against actual grid dimensions. Returns (rowStart, rowEnd, colStart, colEnd) with null replaced by grid extents.

public (int RowStart, int RowEnd, int ColStart, int ColEnd) Resolve(int numRows, int numColumns)

Parameters

numRows int
numColumns int

Returns

(int RowStart, int RowEnd, int ColStart, int ColEnd)