Class TiledGridCoverage
readTiles(TileIterator) method,
which must be defined by subclasses.
Cell coordinates
When there is no subsampling, this coverage uses the same cell coordinates as the originating resource. When there is a subsampling, cell coordinates in this coverage are divided by the subsampling factors. Conversions can be done bycoverageToResourceCoordinate(long, int).
Design note: TiledGridCoverage uses the same cell coordinates as the originating
TiledGridCoverageResource (when no subsampling) because those two classes use long integers.
There is no integer overflow to avoid, contrary to tile matrix indices described below.
Tile matrix coordinate (TMC)
In eachTiledGridCoverage, indices of tiles starts at (0, 0, …).
This class does not use the same tile indices as the coverage resource in order to avoid integer overflow.
Each TiledGridCoverage instance uses its own, independent, Tile Matrix Coordinates (TMC).- Since:
- 1.7
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classAn Area Of Interest (AOI) describing a tile area or sub-area to read in response to a user's request.protected static classSnapshot of aTiledGridCoverage.TileIteratorposition.protected final classAn iterator over the tiles to read.Nested classes/interfaces inherited from class GridCoverage
GridCoverage.EvaluatorModifier and TypeClassDescriptionstatic interfaceInterpolates values of sample dimensions at given positions. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ColorModelThe Java2D color model for images rendered from this coverage.protected final Number[]The values to use for filling empty spaces in rasters, ornullif zero in all bands.protected final int[]Indices ofTiledGridCoverageResourcebands which have been retained for inclusion in thisTiledGridCoverage, in strictly increasing order.protected final SampleModelThe sample model for all rasters.protected final intThe dimension of the grid which is mapped to the x axis (column indexes) in rendered images.protected final intThe dimension of the grid which is mapped to the y axis (row indexes) in rendered images.Fields inherited from class GridCoverage
BIDIMENSIONAL, gridGeometryModifier and TypeFieldDescriptionprotected static final intNumber of dimensions in a two-dimensional slice of data represented as a rendered image.protected final GridGeometryThe grid extent, coordinate reference system (CRS) and conversion from cell indices to CRS. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a new tiled grid coverage. -
Method Summary
Modifier and TypeMethodDescriptionprotected final Rectanglebidimensional(GridExtent extent) Returns the two-dimensional slice of the given grid extent, converted to 32-bits integers.protected final longcoverageToResourceCoordinate(long coordinate, int dimension) Converts a cell coordinate of this coverage to theTiledGridCoverageResourcecoordinate space.protected PathgetContentPath(long... tileIndices) Returns the path to the content of the specified data, ornullif none or unknown.protected abstract GenericNameReturns a unique name that identifies this coverage.protected final intReturns the number of pixels in a single bank element.protected final longgetSubsampling(int dimension) Returns the subsampling in the given dimension.protected final longgetTileSize(int dimension) Returns the size of all tiles in the domain of thisTiledGridCoverage, without sub-sampling.protected abstract Raster[]readTiles(TiledGridCoverage.TileIterator iterator) Returns all tiles in the given area of interest.render(GridExtent sliceExtent) Returns a two-dimensional slice of grid data as a rendered image.protected final longresourceToCoverageCoordinate(long coordinate, int dimension) Converts a cell coordinate from theTiledGridCoverageResourceto this coverage coordinate space.Methods inherited from class GridCoverage
createConvertedValues, createCoordinateFormat, evaluator, forConvertedValues, getCoordinateReferenceSystem, getEnvelope, getGridGeometry, getSampleDimensions, toString, toTreeModifier and TypeMethodDescriptionprotected GridCoveragecreateConvertedValues(boolean converted) Creates the grid coverage instance for the converted or packed values.Creates a new object for formatting spatial-temporal coordinates in the domain of this grid coverage.Creates a new function for computing or interpolating sample values at given locations.forConvertedValues(boolean converted) Returns a grid coverage that contains real values or sample values, depending ifconvertedistrueorfalserespectively.Returns the coordinate reference system to which the values in grid domain are referenced.Returns the bounding box for the coverage domain in CRS coordinates.Returns information about the domain of this grid coverage.Returns information about the range of this grid coverage.Returns a string representation of this grid coverage for debugging purpose.Returns a tree representation of some elements of this grid coverage.
-
Field Details
-
includedBands
protected final int[] includedBandsIndices ofTiledGridCoverageResourcebands which have been retained for inclusion in thisTiledGridCoverage, in strictly increasing order. An included band is stored in memory but not necessarily visible to users, depending on how theSampleModeluses each band. This array isnullif all bands shall be included.If the user specified bands out of order, the band reordering is applied by the sample
model. Changes of band order are not encoded in thisincludedBandsarray (i.e., values are always in strictly increasing order) for making sequential reads easier. -
xDimension
protected final int xDimensionThe dimension of the grid which is mapped to the x axis (column indexes) in rendered images. This is the value of thexDimensionargument in the last call to theTiledGridCoverageResource.setRasterSubspaceDimensions(int, int)method before this coverage has been constructed. This value is usually 0.- See Also:
-
yDimension
protected final int yDimensionThe dimension of the grid which is mapped to the y axis (row indexes) in rendered images. This is the value of theyDimensionargument in the last call to theTiledGridCoverageResource.setRasterSubspaceDimensions(int, int)method before this coverage has been constructed. This value is usually 1.- See Also:
-
model
The sample model for all rasters. The width and height of this sample model are computed from the size of tiles in the resource divided by subsampling and clipped to the domain. The components may be a subset of the bands in the resource if the user requested to read only a subset of those bands.- See Also:
-
colors
The Java2D color model for images rendered from this coverage.- See Also:
-
fillValues
The values to use for filling empty spaces in rasters, ornullif zero in all bands. If non-null, the array length is equal to the number of bands.- See Also:
-
-
Constructor Details
-
TiledGridCoverage
Creates a new tiled grid coverage. This constructor does not load any tile.- Parameters:
subset- description of theTiledGridCoverageResourcesubset to cover.- Throws:
ArithmeticException- if the number of tiles overflows 32 bits integer arithmetic.- See Also:
-
-
Method Details
-
getIdentifier
Returns a unique name that identifies this coverage. The name shall be unique in theTileMatrixSet.- Returns:
- an human-readable identification of this coverage.
-
getContentPath
Returns the path to the content of the specified data, ornullif none or unknown. IftileIndicesisnull, then this method returns a path to the content of the whole coverage (if known). Otherwise, this method returns a path to the content of the tile at the specified indices.The default implementation returns
null.- Parameters:
tileIndices- indices of the tile, ornullfor the whole coverage.- Returns:
- path to the content of the coverage (if
tileIndiceswas null) or to the specified tile, ornullif none or unknown. - See Also:
-
getTileSize
protected final long getTileSize(int dimension) Returns the size of all tiles in the domain of thisTiledGridCoverage, without sub-sampling. This is usually the same size as the tiles in the storage which is read byTiledGridCoverageResource, but not necessarily. It may be larger if theTiledGridCoverageResourcesubclass decided to coalesce many real tiles into larger virtual tiles, or it may be smaller when reading a sub-region of an effectively untiled coverage.- Parameters:
dimension- dimension for which to get tile size.- Returns:
- tile size in the given dimension, without clipping and subsampling.
-
getSubsampling
protected final long getSubsampling(int dimension) Returns the subsampling in the given dimension.- Parameters:
dimension- dimension for which to get subsampling.- Returns:
- subsampling as a value ≥ 1.
-
coverageToResourceCoordinate
protected final long coverageToResourceCoordinate(long coordinate, int dimension) Converts a cell coordinate of this coverage to theTiledGridCoverageResourcecoordinate space. This method removes the subsampling effect, i.e. returns the coordinate that we would have if this coverage was at full resolution. The result is the givencoordinatevalue unchanged when there is no subsampling.- Parameters:
coordinate- coordinate in thisTiledGridCoveragedomain.dimension- the dimension of the coordinate to convert.- Returns:
- coordinate in the
TiledGridCoverageResourcedomain with no subsampling applied. - Throws:
ArithmeticException- if the coordinate cannot be represented as a 64 bits integer.
-
resourceToCoverageCoordinate
protected final long resourceToCoverageCoordinate(long coordinate, int dimension) Converts a cell coordinate from theTiledGridCoverageResourceto this coverage coordinate space. This method is the converse ofcoverageToResourceCoordinate(long, int). The result is the givencoordinatevalue unchanged when there is no subsampling. If there is a subsampling, the returned value is rounded toward negative infinity.- Parameters:
coordinate- coordinate in theTiledGridCoverageResourcedomain.dimension- the dimension of the coordinate to convert.- Returns:
- coordinates in this subsampled
TiledGridCoveragedomain. - Throws:
ArithmeticException- if the coordinate cannot be represented as a 64 bits integer.
-
getPixelsPerElement
protected final int getPixelsPerElement()Returns the number of pixels in a single bank element. This is usually 1, except forMultiPixelPackedSampleModelwhich packs many pixels in a single bank element. This value is a power of 2 accordingMultiPixelPackedSampleModelspecification.Design note
This is value is the number of pixels per element, not samples per element. This distinction is important in the case ofSinglePixelPackedSampleModel, for which this method returns 1 (contrary to the number of samples per element which would be greater than 1).- Returns:
- number of pixels in a single bank element. This is often 1.
- See Also:
-
bidimensional
Returns the two-dimensional slice of the given grid extent, converted to 32-bits integers. By default, the x axis is the grid dimension at index 0 and the y axis is the grid dimension at index 1. Other dimensions are ignored.- Parameters:
extent- the grid extent to slice, ornull.- Returns:
- two-dimensional slice of the given extent, or
nullif the given extent was null. - Throws:
ArithmeticException- if the extent exceeds the capacity of 32-bits integers.
-
render
Returns a two-dimensional slice of grid data as a rendered image. The default implementation creates aTiledGridCoverage.TileIteratorover the region specified in argument, then reads the tiles and stores the result in a rendered image.- Specified by:
renderin classGridCoverage- Parameters:
sliceExtent- a subspace of this grid coverage, ornullfor the whole image.- Returns:
- the grid slice as a rendered image. Image location is relative to
sliceExtent. - Throws:
MismatchedDimensionException- if the given extent does not have the same number of dimensions as this coverage.SubspaceNotSpecifiedException- if the given argument is not sufficient for reducing the grid to a two-dimensional slice.DisjointExtentException- if the given extent does not intersect this grid coverage.CannotEvaluateException- if this method cannot produce the rendered image for another reason.
-
readTiles
Returns all tiles in the given area of interest. Tile indices are relative to thisTiledGridCoverage: (0,0) is the tile in the upper-left corner of thisTiledGridCoverage(not necessarily the upper-left corner of the image in theTiledGridCoverageResource).The
Raster.getMinX()andgetMinY()coordinates of returned rasters shall start at the values given byTiledGridCoverage.TileIterator.getTileOrigin(int). Each tile in the returned array shall be stored at the index given byTiledGridCoverage.AOI.getTileIndexInResultArray().The x axis of the raster shall be the grid dimension specified by
xDimension. Likewise, the y axis shall be the dimension specified byyDimension. These dimensions are usually 0 and 1 respectively.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
TiledGridCoverageResource. - Throws:
Exception- if the tile cannot be created. There is too many possible exceptions for listing all types, but the main ones areIOExceptionfor I/O errors and variousRuntimeExceptionsubtypes for Java2D errors.- See Also:
-