Class CoverageSubset

All Implemented Interfaces:
DataSet, GridCoverageResource, Resource

final class CoverageSubset extends AbstractGridCoverageResource
The result of CoverageQuery.execute(GridCoverageResource). This implementation merges the domain and range specified by the query with arguments of GridCoverageResource.read(GridGeometry, int...) method.
Since:
1.1
Version:
1.3
  • Field Details

    • source

      private final GridCoverageResource source
      The coverage resource instance which provides the data.
    • query

      private final CoverageQuery query
      The domain and range to read from the source coverage.
  • Constructor Details

    • CoverageSubset

      CoverageSubset(GridCoverageResource source, CoverageQuery query)
      Creates a new coverage resource by filtering the given coverage using the given query. This given query is stored as-is (it is not cloned neither optimized).
      Parameters:
      source - the coverage resource instances which provides the data.
      query - the domain and range to read from the source coverage.
  • Method Details

    • createMetadata

      protected org.opengis.metadata.Metadata createMetadata() throws DataStoreException
      Creates metadata about this subset. It includes information about the complete feature set.
      Overrides:
      createMetadata in class AbstractGridCoverageResource
      Returns:
      the newly created metadata, or null if unknown.
      Throws:
      DataStoreException - if an error occurred while reading metadata from this resource.
    • getGridGeometry

      public GridGeometry getGridGeometry() throws DataStoreException
      Returns the valid extent of grid coordinates clipped to the area specified in the query. It should be the geometry of the coverage that we get when invoking read(…) with null arguments, but this is not guaranteed. The returned grid geometry may be approximate.
      Returns:
      extent of grid coordinates clipped to the query.
      Throws:
      DataStoreException - if an error occurred while reading definitions from the underlying data store, or if the grid geometry cannot be clipped to the query area.
      See Also:
    • clip

      private GridGeometry clip(GridGeometry domain, GridRoundingMode rounding, GridClippingMode clipping) throws DataStoreException
      Clips the given domain to the area of interest specified by the query. If any grid geometry is null, the other one is returned. The domain argument should be the domain to read as specified to read(GridGeometry, int...), or the full CoverageSubset domain if no value were given to the read(…) method.
      Parameters:
      domain - the domain requested in a read operation, or null.
      rounding - whether to clip to nearest box or an enclosing box.
      clipping - whether to clip the resulting extent to the specified domain extent.
      Returns:
      intersection of the given grid geometry with the query domain.
      Throws:
      DataStoreException - if the intersection cannot be computed.
    • getSampleDimensions

      public List<SampleDimension> getSampleDimensions() throws DataStoreException
      Returns the ranges of sample values together with the conversion from samples to real values. The returned list should never be empty.
      Returns:
      ranges of sample values together with their mapping to "real values".
      Throws:
      DataStoreException - if an error occurred while reading definitions from the underlying data store.
      See Also:
    • getLoadingStrategy

      public RasterLoadingStrategy getLoadingStrategy() throws DataStoreException
      Returns an indication about when the "physical" loading of raster data will happen. This information is fetched from the wrapped resource doing the actual real operations.
      Returns:
      current raster data loading strategy for this resource.
      Throws:
      DataStoreException - if an error occurred while fetching data store configuration.
    • setLoadingStrategy

      public boolean setLoadingStrategy(RasterLoadingStrategy strategy) throws DataStoreException
      Sets the preferred strategy about when to do the "physical" loading of raster data. This information is forwarded to the wrapped resource doing the actual real operations.
      Parameters:
      strategy - the desired strategy for loading raster data.
      Returns:
      true if the given strategy has been accepted, or false if this implementation replaced the given strategy by an alternative.
      Throws:
      DataStoreException - if an error occurred while setting data store configuration.
    • read

      public GridCoverage read(GridGeometry domain, int... ranges) throws DataStoreException
      Loads a subset of the grid coverage represented by this resource. The domain to be read by the resource is computed as below:
      • If the query specifies a domain, the given domain is intersected with the query domain.
      • If the query specifies a domain expansion, the given domain is expanded by the amount specified in the query.
      Parameters:
      domain - desired grid extent and resolution, or null for reading the whole domain.
      ranges - 0-based indices of sample dimensions to read, or null or an empty sequence for reading them all.
      Returns:
      the grid coverage for the specified domain and ranges.
      Throws:
      DataStoreException - if an error occurred while reading the grid coverage data.
    • invalidRange

      private String invalidRange(int size, int index)
      Creates an exception message for an invalid range index.
      Parameters:
      size - number of sample dimensions in source coverage.
      index - the index which is out of bounds.