Class ExtentSelector<T>
java.lang.Object
org.apache.sis.internal.referencing.ExtentSelector<T>
- Type Parameters:
T- the type of object to be selected.
Selects an object in a sequence of objects using their extent as a criterion.
The selection is based on the temporal extent and geographic area using the following rules:
- Object having largest intersection with the time of interest (TOI) is selected.
- If two or more candidates have the same intersection with TOI, then the one with less "overtime" (time outside TOI) is selected.
- If two or more candidates 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 the candidates are a raster of monthly averages and a raster of daily data, we want
the daily data to be selected even if by coincidence the monthly averages is more centered.
If there is no time of interest, or the candidate objects do not declare time range,
or some objects 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 candidates 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 candidates are considered equal after above criteria, the one best centered on the AOI is selected.
- If two or more candidates are considered equal after above criteria, then the first of those candidates is selected.
Change of rule order
The following configuration flags change the order in which above rules are applied.alternateOrdering— whether the time center criterion is tested last.
Usage
Example:- Since:
- 0.4
- Version:
- 1.3
- Author:
- Martin Desruisseaux (Geomatys)
-
Field Summary
FieldsModifier and TypeFieldDescriptionbooleanWhether to use an alternate conditions order where the time center criterion is tested last. -
Constructor Summary
ConstructorsConstructorDescriptionExtentSelector(org.opengis.metadata.extent.Extent domain) Creates a selector for the given area of interest.ExtentSelector(org.opengis.metadata.extent.GeographicBoundingBox aoi, Instant[] toi) Creates a selector for the given area and time of interest. -
Method Summary
Modifier and TypeMethodDescriptionbest()Returns the object associated to the largest area found so far.voidEvaluates the given extent against the criteria represented by thisExtentSelector.voidevaluate(org.opengis.metadata.extent.GeographicBoundingBox bbox, Instant startTime, Instant endTime, T object) Evaluates the given bounding box and time range against the criteria represented by thisExtentSelector.final org.opengis.metadata.extent.GeographicBoundingBoxReturns the area of interest.final Instant[]Returns the time of interest as an array of length 2, ornullif none.final booleansetExtentOfInterest(org.opengis.metadata.extent.Extent domain, org.opengis.metadata.extent.GeographicBoundingBox aoi, Instant[] toi) Sets the area of interest (AOI) and time of interest (TOI) to the intersection of given arguments.final voidsetTimeGranularity(Duration resolution) Sets the temporal granularity of the Time of Interest (TOI).
-
Field Details
-
alternateOrdering
public boolean alternateOrderingWhether to use an alternate conditions order where the time center criterion is tested last. This flag can be set totrueif the Time Of Interest (TOI) is expected to be larger than the temporal extent of candidate objects, in which case many objects may fit in the TOI. Those candidates may be considered practically equally good regarding temporal aspect, in which case the caller may want to give precedence to geographic area.This flag is often used together with
setTimeGranularity(Duration)method for reducing the preponderance of temporal criteria.
-
-
Constructor Details
-
ExtentSelector
Creates a selector for the given area and time of interest.- Parameters:
aoi- the area of interest, ornullif unbounded.toi- the time of interest, ornullor empty if unbounded. The first element is start time and the last element is end time.
-
ExtentSelector
public ExtentSelector(org.opengis.metadata.extent.Extent domain) Creates a selector for the given area of interest.- Parameters:
domain- the area and time of interest, ornullif none.- Throws:
IllegalArgumentException- if AOI or TOI has an invalid range.
-
-
Method Details
-
setExtentOfInterest
public final boolean setExtentOfInterest(org.opengis.metadata.extent.Extent domain, org.opengis.metadata.extent.GeographicBoundingBox aoi, Instant[] toi) Sets the area of interest (AOI) and time of interest (TOI) to the intersection of given arguments. This method should be invoked only ifbest()returnednull. It allows to make new attempts with a different domain of interest when the search using previous AOI/TOI gave no result.Callers should not use this
ExtentSelectorif this method returnsfalse, except for invoking thissetExtentOfInterest(…)method again with different values until this method returnstrue.- Parameters:
domain- the area and time of interest, ornullif none.aoi- second area of interest as a bounding box, ornullif none.toi- second time of interest as a an array of length 2, 1 or 0, ornull. If array length is 2, it contains start time and end time in that order. If array length is 1, start time and end time are assumed the same. If array length is 0 or array reference is null, there is no temporal range to intersect.- Returns:
- whether the intersections of
domainwithaoiandtoihave valid ranges.
-
getAreaOfInterest
public final org.opengis.metadata.extent.GeographicBoundingBox getAreaOfInterest()Returns the area of interest.- Returns:
- area of interest, or
nullif none.
-
getTimeOfInterest
Returns the time of interest as an array of length 2, ornullif none.- Returns:
- the start time and end time of interest, or
nullif none.
-
setTimeGranularity
Sets the temporal granularity of the Time of Interest (TOI). 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 (for example one remote sensing image per day) and we want to ignore slight variations in the temporal extent declared for each image.This method is often used together with
alternateOrderingflag for reducing the preponderance of temporal criteria.- Parameters:
resolution- granularity of the time of interest, ornullif none.- Throws:
IllegalArgumentException- if the given resolution is zero or negative.
-
evaluate
Evaluates the given extent against the criteria represented by thisExtentSelector. See class javadoc for a list of criteria and the order in which they are applied. Implementation delegates toevaluate(GeographicBoundingBox, Instant, Instant, Object).- Parameters:
domain- the extent to evaluate, ornullif none.object- a user object associated to the given extent.
-
evaluate
public void evaluate(org.opengis.metadata.extent.GeographicBoundingBox bbox, Instant startTime, Instant endTime, T object) Evaluates the given bounding box and time range against the criteria represented by thisExtentSelector. See class javadoc for a list of criteria and the order in which they are applied.- Parameters:
bbox- the geographic extent ofobject, ornullif none.startTime- start time ofobject, ornullif none (unbounded).endTime- end time ofobject, ornullif none (unbounded).object- a user object associated to the given extent.
-
best
Returns the object associated to the largest area found so far.- Returns:
- the object associated to the largest area found so far, or
null.
-