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 booleanWhether allcomponentsareGridCoverageResourceelements.private ImmutableEnvelopeThe envelope of this aggregate, ornullif not yet computed.private booleanWhetherenvelopehas been initialized.private static final intMinimum number of components for keeping this aggregate after analysis.private StringName of this aggregate, ornullif 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
ConstructorsModifierConstructorDescriptionprivateGroupAggregate(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 Resourceapply(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.MetadataCreates 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 voidfillWithCoverageComponents(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.voidModifies the name of the resource.(package private) final Resourcesimplify(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 ImmutableEnvelopeunionOfComponents(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, removeListenerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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, ornullif 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 allcomponentsareGridCoverageResourceelements. This is used for skipping calls to#simplify()when it is known that no component can be simplified. -
envelope
The envelope of this aggregate, ornullif not yet computed. May also benullif no component declare an envelope, or if the union cannot be computed.- See Also:
-
envelopeIsEvaluated
private boolean envelopeIsEvaluatedWhetherenvelopehas 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, ornullif none.name- name of this aggregate, ornullif 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, ornullif none.name- name of this aggregate, ornullif 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:
applyin 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 thechildrengroup.childFiller- the action to execute for initializing each sub-aggregate. The firstBiConsumerargument is achildrenmember (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 thechildrengroup.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:
componentsin interfaceAggregate- Returns:
- all children resources that are components of this aggregate. Never
null.
-
getEnvelope
Returns the spatiotemporal envelope of this resource.- Overrides:
getEnvelopein 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
nullif none. - Throws:
DataStoreExceptionorg.opengis.referencing.operation.TransformException
-
setName
Modifies the name of the resource. This information is used for metadata.- Specified by:
setNamein 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:
createMetadatain classAbstractResource- Returns:
- the newly created metadata, or
nullif unknown. - Throws:
DataStoreException- if an error occurred while reading metadata from this resource.
-
toString
Returns a string representation of this aggregate for debugging purposes.
-