Class MultiResolutionImage

java.lang.Object
org.apache.sis.internal.storage.GridResourceWrapper
org.apache.sis.storage.geotiff.MultiResolutionImage
All Implemented Interfaces:
ResourceOnFileSystem, StoreResource, DataSet, GridCoverageResource, Resource

final class MultiResolutionImage extends GridResourceWrapper implements ResourceOnFileSystem, StoreResource
A list of Image File Directory (FID) where the first entry is the image at finest resolution and following entries are images at finer resolutions.
Since:
1.2
Version:
1.3
  • Field Details

    • namespace

      private org.opengis.util.NameSpace namespace
      Name of the image at finest resolution. This is used as the namespace for overviews.
    • levels

      private final ImageFileDirectory[] levels
      Descriptions of each Image File Directory (IFD) in the GeoTIFF file. Should have at least 2 elements. The full-resolution image shall be at index 0.
    • resolutions

      private final double[][] resolutions
      Resolutions (in units of CRS axes) of each level from finest to coarsest resolution. Array elements may be null if not yet computed.
      See Also:
    • lastOperation

      private volatile org.opengis.referencing.operation.CoordinateOperation lastOperation
      The last coordinate operation returned by
      invalid reference
      #getTransformFrom(CoordinateReferenceSystem)
      . Used as an optimization in the common case where the same CRS is used for many requests.
  • Constructor Details

    • MultiResolutionImage

      MultiResolutionImage(List<ImageFileDirectory> overviews)
      Creates a multi-resolution images with all the given reduced-resolution (overview) images, from finest resolution to coarsest resolution. The full-resolution image shall be at index 0.
  • Method Details

    • getOriginator

      public final DataStore getOriginator()
      Returns the data store that produced this resource.
      Specified by:
      getOriginator in interface StoreResource
      Returns:
      the data store that created this resource.
    • getComponentFiles

      public Path[] getComponentFiles()
      Gets the paths to files used by this resource, or an empty array if unknown.
      Specified by:
      getComponentFiles in interface ResourceOnFileSystem
      Returns:
      files used by this resource. Should never be null.
    • getSynchronizationLock

      protected final Object getSynchronizationLock()
      Returns the object on which to perform all synchronizations for thread-safety.
      Specified by:
      getSynchronizationLock in class GridResourceWrapper
      Returns:
      the object on which to perform synchronizations.
    • createSource

      protected GridCoverageResource createSource() throws DataStoreException
      Creates the resource on which to delegate operations. The source is the first image, the one having finest resolution. By Cloud Optimized GeoTIFF (COG) convention, this is the image containing metadata (CRS). This method is invoked in a synchronized block when first needed and the result is cached.
      Specified by:
      createSource in class GridResourceWrapper
      Returns:
      the resource on which to delegate operations.
      Throws:
      DataStoreException - if the resource cannot be created.
    • getImageFileDirectory

      private ImageFileDirectory getImageFileDirectory(int index) throws IOException, DataStoreException
      Completes and returns the image at the given pyramid level. Indices are in the same order as the images appear in the TIFF file, with 0 for the full resolution image.
      Parameters:
      index - image index (level) in the pyramid, with 0 for finest resolution.
      Returns:
      image at the given pyramid level.
      Throws:
      IOException
      DataStoreException
    • resolution

      private double[] resolution(int level) throws DataStoreException
      Returns the resolution (in units of CRS axes) for the given level.
      Parameters:
      level - the desired resolution level, numbered from finest to coarsest resolution.
      Returns:
      resolution at the specified level, not cloned (caller shall not modify).
      Throws:
      DataStoreException
    • getResolutions

      public List<double[]> getResolutions() throws DataStoreException
      Returns the preferred resolutions (in units of CRS axes) for read operations in this data store. Elements are ordered from finest (smallest numbers) to coarsest (largest numbers) resolution.
      Specified by:
      getResolutions in interface GridCoverageResource
      Overrides:
      getResolutions in class GridResourceWrapper
      Returns:
      preferred resolutions for read operations in this data store, or an empty array if none.
      Throws:
      DataStoreException - if an error occurred while reading definitions from the underlying data store.
      See Also:
    • getResolution

      private double[] getResolution(GridGeometry domain) throws DataStoreException
      Converts a resolution from units in the given CRS to units of this coverage CRS.
      Parameters:
      domain - the geometry from which to get the resolution.
      Returns:
      resolution from the given grid geometry in units of this coverage CRS, or null.
      Throws:
      DataStoreException
    • read

      public GridCoverage read(GridGeometry domain, int... ranges) throws DataStoreException
      Loads a subset of the grid coverage represented by this resource.
      Specified by:
      read in interface GridCoverageResource
      Overrides:
      read in class GridResourceWrapper
      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.