Package org.apache.sis.storage.aggregate
Class MergeStrategy
java.lang.Object
org.apache.sis.storage.aggregate.MergeStrategy
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 of
If no merge strategy is specified, then the default behavior is to throw
GridCoverage
instances may represent the same phenomenon
(for example Sea Surface Temperature) over the same geographic area but at different dates and times.
CoverageAggregator
can 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.SubspaceNotSpecifiedException
when the GridCoverage.render(GridExtent)
method
is invoked and more than one source coverage (slice) is found for a specified grid index.- Since:
- 1.3
- Version:
- 1.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final MergeStrategy
Selects a single slice using criteria based first on temporal extent, then on geographic area.private final Duration
Temporal granularity of the time of interest, ornull
if none. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
MergeStrategy
(Duration timeGranularity) Creates a new merge strategy. -
Method Summary
Modifier and TypeMethodDescription(package private) final Integer
apply
(GridGeometry request, GridGeometry[] candidates) Applies the merge using the strategy represented by this instance.Returns a resource with same data than specified resource but using this merge strategy.static MergeStrategy
selectByTimeThenArea
(Duration timeGranularity) Selects a single slice using criteria based first on temporal extent, then on geographic area.toString()
Returns a string representation of this strategy for debugging purposes.
-
Field Details
-
SELECT_BY_TIME
Selects a single slice using criteria based first on temporal extent, then on geographic area. This default instance do not use any duration.- See Also:
-
timeGranularity
Temporal granularity of the time of interest, ornull
if none. If non-null, intersections with TOI will be rounded to an integer amount of this granularity. This is useful if data are expected at an approximately regular interval and we want to ignore slight variations in the temporal extent declared for each image.
-
-
Constructor Details
-
MergeStrategy
Creates a new merge strategy. This constructor is private for now because we have not yet decided a callback API for custom merges.
-
-
Method Details
-
selectByTimeThenArea
Selects a single slice using criteria based first on temporal extent, then on geographic area. This strategy applies the following rules, in order:- 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.
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 thetimeGranularity
argument 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.
Limitations
Current implementation does not check the vertical dimension. This check may be added in a future version.- Parameters:
timeGranularity
- the temporal granularity of the Time of Interest (TOI), ornull
if none.- Returns:
- a merge strategy for selecting a slice based on temporal criteria first.
-
apply
Applies the merge using the strategy represented by this instance. Current implementation does only a slice selection. A future version may allow real merge operations.- Parameters:
request
- the geographic area and temporal extent requested by user.candidates
- grid geometry of all slices that intersect the request. Null elements are ignored.- Returns:
- index of best slice according the heuristic rules of this
MergeStrategy
.
-
apply
Returns a resource with same data than specified resource but using this merge strategy. If the given resource is an instance created byCoverageAggregator
and 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.- Parameters:
resource
- the resource for which to update the merge strategy, ornull
.- Returns:
- resource with updated merge strategy, or
null
if the given resource was null.
-
toString
Returns a string representation of this strategy for debugging purposes.
-