Class TiledGridCoverage


public abstract class TiledGridCoverage extends GridCoverage
Base class of grid coverage read from a resource where data are stored in tiles. This grid coverage may represent only a subset of the coverage resource. Tiles are read from the storage only when first needed.

Cell Coordinates

When there is no subsampling, this coverage uses the same cell coordinates than the originating resource. When there is a subsampling, cell coordinates in this coverage are divided by the subsampling factors. Conversions are done by toFullResolution(long, int).

Tile coordinate matrix

In each TiledGridCoverage, indices of tiles starts at (0, 0, …). This class does not use the same tile indices than the coverage resource in order to avoid integer overflow.
Since:
1.1
Version:
1.2
Author:
Martin Desruisseaux (Geomatys)
  • Field Details

    • BIDIMENSIONAL

      protected static final int BIDIMENSIONAL
      Number of dimensions in a rendered image. Used for identifying codes where a two-dimensional slice is assumed.
      See Also:
    • X_DIMENSION

      protected static final int X_DIMENSION
      The dimensions of x and y axes. Static constants for now, may become configurable fields in the future.
      See Also:
    • Y_DIMENSION

      protected static final int Y_DIMENSION
      The dimensions of x and y axes. Static constants for now, may become configurable fields in the future.
      See Also:
    • includedBands

      protected final int[] includedBands
      Indices of TiledGridResource bands which have been retained for inclusion in this TiledGridCoverage, in strictly increasing order. An "included" band is stored in memory but not necessarily visible to the user, because the SampleModel can be configured for ignoring some bands. This array is null if all bands shall be included.

      If the user specified bands out of order, the change of band order is taken in account by the sample model. This includedBands array does not apply any change of order for making sequential readings easier.

    • model

      protected final SampleModel model
      The sample model for all rasters. The width and height of this sample model are the two first elements of tileSize divided by subsampling and clipped to the domain. If user requested to read only a subset of the bands, then this sample model is already the subset.
    • colors

      protected final ColorModel colors
      The Java2D color model for images rendered from this coverage.
    • fillValue

      protected final Number fillValue
      The value to use for filling empty spaces in rasters, or null if zero.
  • Constructor Details

    • TiledGridCoverage

      protected TiledGridCoverage(TiledGridResource.Subset subset)
      Creates a new tiled grid coverage. All parameters should have been validated before this call.
      Parameters:
      subset - description of the TiledGridResource subset to cover.
      Throws:
      ArithmeticException - if the number of tiles overflows 32 bits integer arithmetic.
  • Method Details

    • getIdentifier

      protected abstract org.opengis.util.GenericName getIdentifier()
      Returns a unique name that identifies this coverage. The name shall be unique in the TileMatrixSet.
      Returns:
      an human-readable identification of this coverage.
    • getLocale

      protected Locale getLocale()
      Returns the locale for error messages, or null for the default.
      Returns:
      the locale for warning or error messages, or null if unspecified.
    • getTileSize

      protected final int getTileSize(int dimension)
      Returns the size of all tiles in the domain of this TiledGridCoverage, without clipping and subsampling.
      Parameters:
      dimension - dimension for which to get tile size.
      Returns:
      tile size in the given dimension, without clipping and subsampling.
    • getSubsampling

      protected final int getSubsampling(int dimension)
      Returns the subsampling in the given dimension.
      Parameters:
      dimension - dimension for which to get subsampling.
      Returns:
      subsampling as a value ≥ 1.
    • getPixelsPerElement

      protected final int getPixelsPerElement()
      Returns the number of pixels in a single bank element. This is usually 1, except for MultiPixelPackedSampleModel which packs many pixels in a single bank element. This value is a power of 2 according MultiPixelPackedSampleModel specification.
      Note: this is "pixels per element", not "samples per element". It makes a difference in the SinglePixelPackedSampleModel case, for which this method returns 1 (by contrast a "samples per element" would give a value greater than 1). But this value can nevertheless be understood as a "samples per element" value where only one band is considered at a time.
      Returns:
      number of pixels in a single bank element. Usually 1.
      See Also:
    • render

      public RenderedImage render(GridExtent sliceExtent)
      Returns a two-dimensional slice of grid data as a rendered image.
      Specified by:
      render in class GridCoverage
      Parameters:
      sliceExtent - a subspace of this grid coverage extent, or null for the whole image.
      Returns:
      the grid slice as a rendered image. Image location is relative to sliceExtent.
    • readTiles

      protected abstract Raster[] readTiles(TiledGridCoverage.AOI iterator) throws IOException, DataStoreException
      Returns all tiles in the given area of interest. Tile indices are relative to this TiledGridCoverage: (0,0) is the tile in the upper-left corner of this TiledGridCoverage (not necessarily the upper-left corner of the image in the TiledGridResource). The Raster.getMinX() and getMinY() coordinates of returned rasters shall start at the given iterator.offsetAOI values.

      This method must be thread-safe. It is implementer responsibility to ensure synchronization, for example using AbstractResource.getSynchronizationLock().

      Parameters:
      iterator - an iterator over the tiles that intersect the Area Of Interest specified by user.
      Returns:
      tiles decoded from the TiledGridResource.
      Throws:
      IOException - if an I/O error occurred.
      DataStoreException - if a logical error occurred.
      RuntimeException - if the Java2D image cannot be created for another reason (too many exception types to list them all).