Package org.apache.sis.storage.aggregate
Class GroupAggregate
java.lang.Object
org.apache.sis.storage.AbstractResource
org.apache.sis.storage.aggregate.GroupAggregate
- All Implemented Interfaces:
Aggregate
,AggregatedResource
,Resource
An aggregate created when, after grouping resources by CRS and other attributes,
more than one group still exist. Those groups become components of an aggregate.
This is used as temporary object during analysis, then kept alive in last resort
when we cannot build a single time series from a sequence of coverages at different times.
This class intentionally does not override AbstractResource.getIdentifier()
because
it would not be a persistent identifier.
- Since:
- 1.3
- Version:
- 1.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Resource[]
The components of this aggregate.private boolean
Whether allcomponents
areGridCoverageResource
elements.private ImmutableEnvelope
The envelope of this aggregate, ornull
if not yet computed.private boolean
Whetherenvelope
has been initialized.private static final int
Minimum number of components for keeping this aggregate after analysis.private String
Name of this aggregate, ornull
if none.(package private) List<SampleDimension>
The sample dimensions of all children in this group, or an empty collection if they are not the same.Fields inherited from class org.apache.sis.storage.AbstractResource
listeners
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
GroupAggregate
(GroupAggregate source, Resource[] components) Creates a new resource with the same data than given resource but a different merge strategy.(package private)
GroupAggregate
(StoreListeners listeners, String name, int count) Creates a new aggregate with the specified number of components.(package private)
GroupAggregate
(StoreListeners listeners, String name, GridCoverageResource[] components, List<SampleDimension> sampleDimensions) Creates a new aggregate with the specified components, which will receive no further processing. -
Method Summary
Modifier and TypeMethodDescriptionfinal Resource
apply
(MergeStrategy strategy) Returns an aggregate with the same data than this aggregate but a different merge strategy.Returns the components of this aggregate.protected org.opengis.metadata.Metadata
Creates when first requested the metadata about this aggregate.(package private) final <E extends Group<?>>
voidfillWithChildAggregates
(Group<E> children, BiConsumer<E, GroupAggregate> childFiller) Sets all components of this aggregate to sub-aggregates, which are themselves initialized with the given filler.(package private) final void
fillWithCoverageComponents
(List<GroupByTransform> children, List<SampleDimension> ranges) Sets all components of this aggregate to grid coverage resources.Optional<org.opengis.geometry.Envelope>
Returns the spatiotemporal envelope of this resource.void
Modifies the name of the resource.(package private) final Resource
simplify
(CoverageAggregator aggregator) Simplifies the resource tree by removing all aggregates of 1 component.toString()
Returns a string representation of this aggregate for debugging purposes.(package private) static ImmutableEnvelope
unionOfComponents
(Resource[] components) Computes the union of envelopes provided by all the given resources.Methods inherited from class org.apache.sis.storage.AbstractResource
addListener, clearCache, getIdentifier, getMetadata, getSynchronizationLock, removeListener
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.sis.storage.Resource
addListener, getIdentifier, getMetadata, removeListener
-
Field Details
-
KEEP_ALIVE
private static final int KEEP_ALIVEMinimum number of components for keeping this aggregate after analysis.- See Also:
-
name
Name of this aggregate, ornull
if none. This is not a persistent identifier. -
components
The components of this aggregate. Array elements are initially null, but should all become non-null after afill(…)
method has been invoked. If the length is smaller than 2, then this aggregate is only a temporary object. -
componentsAreLeaves
private boolean componentsAreLeavesWhether allcomponents
areGridCoverageResource
elements. This is used for skipping calls to#simplify()
when it is known that no component can be simplified. -
envelope
The envelope of this aggregate, ornull
if not yet computed. May also benull
if no component declare an envelope, or if the union cannot be computed.- See Also:
-
envelopeIsEvaluated
private boolean envelopeIsEvaluatedWhetherenvelope
has been initialized. The envelope may still be null if the initialization failed. -
sampleDimensions
List<SampleDimension> sampleDimensionsThe sample dimensions of all children in this group, or an empty collection if they are not the same. This field is initially null, but should become non-null after afill(…)
method has been invoked. This is used for metadata only.
-
-
Constructor Details
-
GroupAggregate
GroupAggregate(StoreListeners listeners, String name, int count) Creates a new aggregate with the specified number of components. One of thefill(…)
methods must be invoked after this constructor.- Parameters:
listeners
- listeners of the parent resource, ornull
if none.name
- name of this aggregate, ornull
if none.count
- expected number of components.- See Also:
-
GroupAggregate
GroupAggregate(StoreListeners listeners, String name, GridCoverageResource[] components, List<SampleDimension> sampleDimensions) Creates a new aggregate with the specified components, which will receive no further processing. This is invoked when the caller has not been able to group the slices in a multi-dimensional cube. The result stay an aggregate of heterogynous resources.- Parameters:
listeners
- listeners of the parent resource, ornull
if none.name
- name of this aggregate, ornull
if none.components
- the resources to uses as components of this aggregate.sampleDimensions
- sample dimensions common to all grid coverage resources.
-
GroupAggregate
Creates a new resource with the same data than given resource but a different merge strategy.- Parameters:
source
- the resource to copy.components
- components with the new merge strategy.
-
-
Method Details
-
apply
Returns an aggregate with the same data than this aggregate but a different merge strategy.- Specified by:
apply
in interfaceAggregatedResource
- Parameters:
strategy
- the new merge strategy to apply.- Returns:
- resource using the specified strategy (may be
this
).
-
fillWithChildAggregates
final <E extends Group<?>> void fillWithChildAggregates(Group<E> children, BiConsumer<E, GroupAggregate> childFiller) Sets all components of this aggregate to sub-aggregates, which are themselves initialized with the given filler. This method may be invoked recursively if the sub-aggregates themselves have sub-sub-aggregates.- Type Parameters:
E
- type of object in the group.- Parameters:
children
- data for creating children, as one sub-aggregate per member of thechildren
group.childFiller
- the action to execute for initializing each sub-aggregate. The firstBiConsumer
argument is achildren
member (the source) and the second argument is the sub-aggregate to initialize (the target).
-
fillWithCoverageComponents
final void fillWithCoverageComponents(List<GroupByTransform> children, List<SampleDimension> ranges) Sets all components of this aggregate to grid coverage resources. Children created by this method are leaf nodes.- Parameters:
children
- date for creating children, as one coverage per member of thechildren
group.ranges
- sample dimensions of the coverage to create. Stored as-is (not copied).
-
simplify
Simplifies the resource tree by removing all aggregates of 1 component.- Parameters:
aggregator
- the aggregation builder which is invoking this method.- Returns:
- the resource to use after simplification.
-
components
Returns the components of this aggregate.- Specified by:
components
in interfaceAggregate
- Returns:
- all children resources that are components of this aggregate. Never
null
.
-
getEnvelope
Returns the spatiotemporal envelope of this resource.- Overrides:
getEnvelope
in classAbstractResource
- Returns:
- the spatiotemporal resource extent.
- Throws:
DataStoreException
- if an error occurred while reading or computing the envelope.
-
unionOfComponents
static ImmutableEnvelope unionOfComponents(Resource[] components) throws DataStoreException, org.opengis.referencing.operation.TransformException Computes the union of envelopes provided by all the given resources.- Parameters:
components
- the components for which to extract the envelope.- Returns:
- union of envelope of all components, or
null
if none. - Throws:
DataStoreException
org.opengis.referencing.operation.TransformException
-
setName
Modifies the name of the resource. This information is used for metadata.- Specified by:
setName
in interfaceAggregatedResource
- Parameters:
name
- new name of the resource.
-
createMetadata
Creates when first requested the metadata about this aggregate. The metadata contains the title for this aggregation, the sample dimensions (if they are the same for all children) and the geographic bounding box.- Overrides:
createMetadata
in classAbstractResource
- Returns:
- the newly created metadata, or
null
if unknown. - Throws:
DataStoreException
- if an error occurred while reading metadata from this resource.
-
toString
Returns a string representation of this aggregate for debugging purposes.
-