Class CoverageSampling
Samples one or more ICoverageSamplers at a point: chooses the
dataset and site that answer, applies the time handling, and reads it.
Shared by the sample_coverage tools and by
CoverageSamplerExtensions, so every product treats time the
same way.
public static class CoverageSampling
- Inheritance
-
CoverageSampling
- Inherited Members
Remarks
Site selection: grid nodes win over stations. Among stations only the nearest (and others within a metre of it, such as one station reported by two runs) are considered. "Nearest cell" is the cell whose centre is closest to the point; no interpolation is performed.
Time handling: of the candidate sites, those whose time range contains the requested time are preferred, and the best-ranked of them wins (finest grid or nearest station, then newest run). A request within one time-step interval of either end of a range counts as in range. The nearest time step is read; ties go to the earlier step. A single instant outside every candidate's range is CoverageSampleOutcome<TSource>.TimeOutOfRange unless the caller opts into the nearest step, in which case the result's TimeStatus says which end was used. A windowed query prefers a candidate spanning the whole window, then the one covering most of it; it returns the covered part, flagged truncated, and is out of range only when there is no overlap at all (issue #789).
Methods
SampleAlong<TSource>(IReadOnlyList<CoverageSamplerEntry<TSource>>, IEnumerable<(double Latitude, double Longitude)>, ICrsTransformFactory, DateTimeOffset?, bool)
Samples at each vertex of a polyline, at the same time, in vertex order.
public static IReadOnlyList<CoverageSampleOutcome<TSource>> SampleAlong<TSource>(IReadOnlyList<CoverageSamplerEntry<TSource>> samplers, IEnumerable<(double Latitude, double Longitude)> vertices, ICrsTransformFactory transforms, DateTimeOffset? time = null, bool nearestWhenOutOfRange = false)
Parameters
samplersIReadOnlyList<CoverageSamplerEntry<TSource>>The datasets to choose from, in the host's order.
verticesIEnumerable<(double Latitude, double Longitude)>The polyline's vertices (decimal degrees, WGS-84).
transformsICrsTransformFactoryReprojects each vertex into a dataset's native CRS.
timeDateTimeOffset?The requested time, applied to every vertex;
nullfor the first step.nearestWhenOutOfRangebool
Returns
- IReadOnlyList<CoverageSampleOutcome<TSource>>
Type Parameters
TSourceThe host's handle for a dataset.
SampleAt<TSource>(IReadOnlyList<CoverageSamplerEntry<TSource>>, CoverageSampleQuery, DateTimeOffset?, bool)
Samples at a single instant (or the first step when time is null).
public static CoverageSampleOutcome<TSource> SampleAt<TSource>(IReadOnlyList<CoverageSamplerEntry<TSource>> samplers, CoverageSampleQuery query, DateTimeOffset? time, bool nearestWhenOutOfRange = false)
Parameters
samplersIReadOnlyList<CoverageSamplerEntry<TSource>>The datasets to choose from, in the host's order (which breaks ties).
queryCoverageSampleQueryThe point.
timeDateTimeOffset?The requested time, or
nullfor the first step.nearestWhenOutOfRangeboolWhen the time is outside every candidate's range:
falsereturns CoverageSampleOutcome<TSource>.TimeOutOfRange;truereads the nearest step and reports it in the time status.
Returns
- CoverageSampleOutcome<TSource>
Type Parameters
TSourceThe host's handle for a dataset.
SampleWindow<TSource>(IReadOnlyList<CoverageSamplerEntry<TSource>>, CoverageSampleQuery, CoverageTimeWindow)
Samples over a range or series window. Only sites with Steps answer; when none does, the first WindowUnsupportedReason is reported.
public static CoverageSampleOutcome<TSource> SampleWindow<TSource>(IReadOnlyList<CoverageSamplerEntry<TSource>> samplers, CoverageSampleQuery query, CoverageTimeWindow window)
Parameters
samplersIReadOnlyList<CoverageSamplerEntry<TSource>>The datasets to choose from, in the host's order.
queryCoverageSampleQueryThe point.
windowCoverageTimeWindowThe window.
Returns
- CoverageSampleOutcome<TSource>
Type Parameters
TSourceThe host's handle for a dataset.
SelectTimeStep(IReadOnlyList<DateTime>, DateTimeOffset?)
The index of the step closest to requested; 0 when it
is null. Times outside the range clamp to the first or last step
(per S-100 Part 10c ยง10.2.1.1, time-step indices are in
[0, numberOfTimes - 1]); callers decide beforehand whether an
out-of-range request may be sampled at all. Ties go to the earlier index.
public static int SelectTimeStep(IReadOnlyList<DateTime> steps, DateTimeOffset? requested)
Parameters
stepsIReadOnlyList<DateTime>The time steps in storage order (ascending or descending); at least one.
requestedDateTimeOffset?The requested time.