Class MultiResolutionCoverageLoader

java.lang.Object
org.apache.sis.internal.map.coverage.MultiResolutionCoverageLoader

public class MultiResolutionCoverageLoader extends Object
A helper class for reading GridCoverage instances at various resolutions. The resolutions are inferred from GridCoverageResource.getResolutions(), using default values if necessary. The objective CRS does not need to be the same than the coverage CRS, in which case transformations are applied at the point in the center of the display bounds.

Multi-threading

Instances of this class are immutable (except for the cache) and safe for use by multiple threads. However, it assumes that the GridCoverageResource given to the constructor is also thread-safe; this class does not synchronize accesses to the resource (because it may be used outside this class anyway).
Since:
1.2
Version:
1.2
Author:
Martin Desruisseaux (Geomatys)
  • Field Details

    • resource

      public final GridCoverageResource resource
      The resource from which to read grid coverages.
  • Constructor Details

    • MultiResolutionCoverageLoader

      public MultiResolutionCoverageLoader(GridCoverageResource resource, org.opengis.geometry.Envelope domain, int[] range) throws DataStoreException
      Creates a new loader of grid coverages from the given resource. The loader assumes a pyramid with resolutions declared by the given resource if present, or computes default resolutions otherwise.
      Parameters:
      resource - the resource from which to read grid coverages. Should be thread-safe.
      domain - desired spatiotemporal region in any CRS, or null for no sub-area.
      range - 0-based indices of sample dimensions to read, or null for all.
      Throws:
      DataStoreException - if an error occurred while querying the resource for resolutions.
  • Method Details

    • getOrLoad

      public final GridCoverage getOrLoad(int level) throws DataStoreException
      Returns the coverage at the given level if it is present in the cache, or loads and caches it otherwise.
      Parameters:
      level - pyramid level of the desired coverage.
      Returns:
      the coverage at the specified level (never null).
      Throws:
      DataStoreException - if an error occurred while loading the coverage.
    • getOrLoad

      public final GridCoverage getOrLoad(GridGeometry domain, int[] range) throws DataStoreException
      If the a grid coverage for the given domain and range is in the cache, returns that coverage. Otherwise loads the coverage and eventually caches it. The caching happens only if the given domain and range are managed by this loader.
      Parameters:
      domain - desired grid extent and resolution, or null for reading the whole domain.
      range - 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 range.
      Throws:
      DataStoreException - if an error occurred while reading the grid coverage data.
    • toString

      public String toString()
      Returns a string representation of this loader for debugging purpose. Default implementation formats the resolution thresholds in a table with "cached" word after the level having a cached coverage.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this loader.