Class AggregatedFeatureSet

All Implemented Interfaces:
DataSet, FeatureSet, Resource
Direct Known Subclasses:
ConcatenatedFeatureSet, JoinFeatureSet

abstract class AggregatedFeatureSet extends AbstractFeatureSet
A feature set made from the aggregation of other feature sets. The features may be aggregated in different ways, depending on the subclass. The aggregation may be all features from one set followed by all features from another set, or it may be features of the two sets merged together in a way similar to SQL JOIN statement.

This class provides default implementations of getEnvelope() and AbstractResource.getMetadata(). Subclasses need to implement dependencies().

Since:
1.0
Version:
1.2
  • Field Details

    • envelope

      private ImmutableEnvelope envelope
      The envelope, computed when first needed and cached for reuse.
      See Also:
    • isEnvelopeComputed

      private boolean isEnvelopeComputed
      Whether envelope has been computed. The result may still be null.
  • Constructor Details

    • AggregatedFeatureSet

      protected AggregatedFeatureSet(StoreListeners parent)
      Creates a new aggregated feature set.
      Parameters:
      parent - listeners of the parent resource, or null if none. This is usually the listeners of the DataStore that created this resource.
  • Method Details

    • dependencies

      abstract Collection<FeatureSet> dependencies()
      Returns all feature set used by this aggregation. This method is invoked for implementation of getEnvelope() and
      invalid reference
      #createMetadata(MetadataBuilder)
      .
      Returns:
      all feature sets in this aggregation.
    • getEnvelopes

      private boolean getEnvelopes(List<org.opengis.geometry.Envelope> addTo) throws DataStoreException
      Adds the envelopes of the aggregated feature sets in the given list. If some of the feature sets are themselves aggregated feature sets, then this method traverses them recursively. We compute the union of all envelopes at once after we got all envelopes.

      If any source has an absent value, then this method stops the collect immediately and returns false. The rational is that if at least one source has unknown location, providing a location based on other sources may be misleading since they may be very far from the missing resource location.

      Returns:
      false if the collect has been interrupted because an envelope is absent.
      Throws:
      DataStoreException
    • getEnvelope

      public final Optional<org.opengis.geometry.Envelope> getEnvelope() throws DataStoreException
      Returns the union of the envelopes in all aggregated feature sets. This method tries to find a CRS common to all feature sets. If no common CRS can be found, then the envelope is absent.
      Implementation note: this method is final because overriding it would invalidate the unwrapping of other AggregatedFeatureSet instances. If we wish to allow overrides in a future version, we would need to revisit getEnvelopes(List) first.
      Specified by:
      getEnvelope in interface DataSet
      Overrides:
      getEnvelope in class AbstractResource
      Returns:
      union of envelopes from all dependencies.
      Throws:
      DataStoreException - if an error occurred while computing the envelope.
    • createMetadata

      protected org.opengis.metadata.Metadata createMetadata() throws DataStoreException
      Invoked in a synchronized block the first time that getMetadata() is invoked. The default implementation adds the information documented in the parent class, then adds the dependencies as lineages.
      Overrides:
      createMetadata in class AbstractFeatureSet
      Returns:
      the newly created metadata, or null if unknown.
      Throws:
      DataStoreException - if an error occurred while reading metadata from the data stores.
    • clearCache

      protected void clearCache()
      Clears any cache in this resource, forcing the data to be recomputed when needed again. This method should be invoked if the data in underlying data store changed.
      Overrides:
      clearCache in class AbstractResource