Class GridRegion
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
rowStartint?First row to sample (inclusive), or null for row 0.
rowEndint?Row at which sampling stops (exclusive), or null for the grid's row count.
colStartint?First column to sample (inclusive), or null for column 0.
colEndint?Column at which sampling stops (exclusive), or null for the grid's column count.
rowStrideintSample every
rowStride-th row;1samples every row.colStrideintSample every
colStride-th column;1samples 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
Full
A region covering the whole grid at stride 1. Returns a new instance on each access.
public static GridRegion Full { get; }
Property Value
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
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
viewportViewportThe current display area (EPSG:4326 bounding box + pixel dimensions).
gridGridMetadataThe coverage's GridMetadata. Its
Origin*andSpacing*fields are interpreted in the grid's native CRS (degrees for EPSG:4326, metres for projected CRSs such as UTM).gridCrsstringThe grid's native CRS, e.g.
"EPSG:4326"or"EPSG:32608". Defaults to"EPSG:4326".wgs84ToNativeICrsTransformOptional transform from EPSG:4326 (viewport CRS) to the grid's native CRS. Required when
gridCrsis not"EPSG:4326". Ignored when the grid CRS is EPSG:4326 or the supplied transform reports IsIdentity. Obtain viafactory.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 == RowEndorColStart == 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).
-
Row/col bounds clamped to the grid dimensions. When the viewport
does not intersect the grid at all the region is empty
(
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
gridCrsis not EPSG:4326 and nowgs84ToNativetransform 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)