public final class MergeStrategy extends Object
Algorithm to apply when more than one grid coverage can be found at the same grid index. A merge may happen if an aggregated coverage is created with
CoverageAggregator, and the extent of some source coverages are overlapping in the dimension to aggregate.
Example: a collection ofIf no merge strategy is specified, then the default behavior is to throw
GridCoverageinstances may represent the same phenomenon (for example Sea Surface Temperature) over the same geographic area but at different dates and times.
CoverageAggregatorcan be used for building a single data cube with a time axis. But if two coverages have overlapping time ranges, and if a user request data in the overlapping region, then the aggregated coverages have more than one source coverages capable to provide the requested data. This enumeration specify how to handle this multiplicity.
GridCoverage.render(GridExtent)method is invoked and more than one source coverage (slice) is found for a specified grid index.
Defined in the
Method SummaryModifier and TypeMethodDescriptionReturns a resource with same data than specified resource but using this merge strategy.
(Duration timeGranularity)Selects a single slice using criteria based first on temporal extent, then on geographic area.Returns a string representation of this strategy for debugging purposes.
selectByTimeThenAreapublic static MergeStrategy selectByTimeThenArea
(Duration timeGranularity)Selects a single slice using criteria based first on temporal extent, then on geographic area. This strategy applies the following rules, in order:
Rational: the "smallest time outside" criterion (rule 2) is before "best centered" criterion (rule 3) because of the following scenario: if a user specifies a "time of interest" (TOI) of 1 day and if there is two slices intersecting the TOI, with one slice being a raster of monthly averages the other slice being a raster of daily data, we want the daily data to be selected even if by coincidence the monthly averages is better centered.If the
- Slice having largest intersection with the time of interest (TOI) is selected.
- If two or more slices have the same intersection with TOI, then the one with less "overtime" (time outside TOI) is selected.
- If two or more slices are considered equal after above criteria, then the one best centered on the TOI is selected.
timeGranularityargument is non-null, then intersections with TOI will be rounded to an integer amount of the specified granularity and the last criterion in above list is relaxed. This is useful when data are expected at an approximately regular time interval (for example one remote sensing image per day) and we want to ignore slight variations in the temporal extent declared for each image.
If there is no time of interest, or the slices do not declare time range, or some slices are still at equality after application of above criteria, then the selection continues on the basis of geographic criteria:
- Largest intersection with the area of interest (AOI) is selected.
- If two or more slices have the same intersection area with AOI, then the one with the less "irrelevant" material is selected. "Irrelevant" material are area outside the AOI.
- If two or more slices are considered equal after above criteria, the one best centered on the AOI is selected.
- If two or more slices are considered equal after above criteria, then the first of those candidates is selected.
LimitationsCurrent implementation does not check the vertical dimension. This check may be added in a future version.
timeGranularity- the temporal granularity of the Time of Interest (TOI), or
- a merge strategy for selecting a slice based on temporal criteria first.
applyReturns a resource with same data than specified resource but using this merge strategy. If the given resource is an instance created by
CoverageAggregatorand uses a different strategy, then a new resource using this merge strategy is returned. Otherwise the given resource is returned as-is. The returned resource will share the same resources and caches than the given resource.
resource- the resource for which to update the merge strategy, or
- resource with updated merge strategy, or
nullif the given resource was null.
toStringpublic String toString()Returns a string representation of this strategy for debugging purposes.