Class MemoryGridCoverageResource

All Implemented Interfaces:
Data­Set, Grid­Coverage­Resource, Resource

public class MemoryGridCoverageResource extends AbstractGridCoverageResource
A Grid Coverage Resource stored in memory. This resource wraps an arbitrary Grid­Coverage specified at construction time. Metadata can be specified by overriding the Abstract­Grid­Coverage­Resource​.create­Metadata() method.

When to use

This class is useful for small grid coverages, or for testing purposes, or when the coverage is in memory anyway (for example, a computation result). It should generally not be used for large coverages read from files or databases.
Since:
1.6
  • Field Details

    • coverage

      protected final GridCoverage coverage
      The grid coverage specified at construction time.
      See Also:
    • processor

      protected final GridCoverageProcessor processor
      The grid coverage processor to use for selecting bands. It may be configured with a colorizer for determining the color models.
  • Constructor Details

    • MemoryGridCoverageResource

      public MemoryGridCoverageResource(Resource parent, GenericName identifier, GridCoverage coverage, GridCoverageProcessor processor)
      Creates a new coverage stored in memory.
      Parameters:
      parent - the parent resource, or null if none.
      identifier - resource identifier, or null if none.
      coverage - stored coverage retained as-is (not copied). Cannot be null.
      processor - the grid coverage processor for selecting bands, or null for default.
  • Method Details

    • getIdentifier

      public Optional<GenericName> getIdentifier()
      Returns the resource identifier specified at construction time, if any.
      Returns:
      a persistent identifier unique within the data store, or absent if this resource has no such identifier.
      See Also:
    • getGridCoverage

      public GridCoverage getGridCoverage()
      Returns the grid coverage wrapped by this resource. The grid coverage returned by this method shall be the same or equivalent to the coverage that would be returned by a call to read(null), and should not be expansive to get.
      Returns:
      the grid coverage wrapped by this resource.
      See Also:
    • getGridGeometry

      public GridGeometry getGridGeometry()
      Returns information about the domain of wrapped grid coverage.
      Returns:
      extent of grid coordinates together with their mapping to "real world" coordinates.
      See Also:
    • getSampleDimensions

      public List<SampleDimension> getSampleDimensions()
      Returns information about the ranges of wrapped grid coverage.
      Returns:
      ranges of sample values together with their mapping to "real values".
      See Also:
    • getLoadingStrategy

      public RasterLoadingStrategy getLoadingStrategy()
      Returns an indication about whether read(…) tries to force the loading of data.
      Returns:
      current raster data loading strategy for this resource.
    • setLoadingStrategy

      public boolean setLoadingStrategy(RasterLoadingStrategy strategy)
      Sets the preference about whether read(…) should try to force the loading of data.
      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.
    • read

      public GridCoverage read(GridGeometry domain, int... ranges)
      Returns a subset of the wrapped grid coverage. If a null grid geometry and a null or empty range is specified, then this method shall return the same grid coverage as get­Grid­Coverage() or an equivalent coverage. If a non-null grid geometry is specified, then this method tries to return a grid coverage matching the given grid geometry on a best-effort basis. It may be the whole coverage.
      Parameters:
      domain - desired grid extent and resolution, or null for 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.
    • equals

      public boolean equals(Object obj)
      Tests whether this memory grid coverage resource is wrapping the same coverage as the given object. This method checks also that the listeners and the grid coverage processor are equal.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to compare.
      Returns:
      whether the two objects are memory resources wrapping the same coverage.
    • hashCode

      public int hashCode()
      Returns a hash code value for consistency with equals(Object).
      Overrides:
      hash­Code in class Object
      Returns:
      a hash code value.
    • toString

      public String toString()
      Returns a string representation of this resource. The default implementation returns the string representation of the wrapped coverage.
      Overrides:
      to­String in class Object
      Returns:
      the string representation of this resource.