Package org.apache.sis.storage.geotiff
Class CompressedSubset
java.lang.Object
org.apache.sis.coverage.BandedCoverage
org.apache.sis.coverage.grid.GridCoverage
org.apache.sis.internal.storage.TiledGridCoverage
org.apache.sis.storage.geotiff.DataSubset
org.apache.sis.storage.geotiff.CompressedSubset
- All Implemented Interfaces:
Localized
Raster data obtained from a compressed GeoTIFF file in the domain requested by user.
- Since:
- 1.1
- Version:
- 1.1
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.sis.internal.storage.TiledGridCoverage
TiledGridCoverage.AOI, TiledGridCoverage.SnapshotNested classes/interfaces inherited from class org.apache.sis.coverage.grid.GridCoverage
GridCoverage.Evaluator -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final intNumber of sample values to skip for reaching end-of-row after reading the last value of the first pixel in a row.private final intNumber of sample values to skip before to read the first value of the first pixel in a row.private InflaterThe inflater, created when reading the first tile and discarded after reading the last tile.private final intNumber of sample values that compose a chunk (pixel or sample) in the GeoTIFF file.private final longNumber of sample values to skip for moving to the next row of a tile in the GeoTIFF file.private final int[]Number of sample values to skip after a chunk has been read, ornullif none.Fields inherited from class org.apache.sis.storage.geotiff.DataSubset
numBanks, source, sourcePixelStride, targetPixelStrideFields inherited from class org.apache.sis.internal.storage.TiledGridCoverage
BIDIMENSIONAL, colors, fillValue, includedBands, model, X_DIMENSION, Y_DIMENSIONFields inherited from class org.apache.sis.coverage.grid.GridCoverage
gridGeometry -
Constructor Summary
ConstructorsConstructorDescriptionCompressedSubset(DataCube source, TiledGridResource.Subset subset) Creates a new data subset. -
Method Summary
Modifier and TypeMethodDescription(package private) final CloseableReturns the object to close for releasing inflater resources.private static intpixelCount(long[] lower, long[] upper, int[] subsampling, int i) Computes the number of pixels to read in dimension i.(package private) RasterreadSlice(long[] offsets, long[] byteCounts, long[] lower, long[] upper, int[] subsampling, Point location) Reads a two-dimensional slice of the data cube from the given input channel.private voidInvoked after the last tile has been read, or after an exception has been thrown during the reading process.private static booleanstartsWithZeros(int[] skipAfterChunks, int m) Returnstrueif all array elements except the last one are zeros.Methods inherited from class org.apache.sis.storage.geotiff.DataSubset
fillRemainingRows, getBankCapacity, getDataType, getIdentifier, getLocale, input, readTilesMethods inherited from class org.apache.sis.internal.storage.TiledGridCoverage
getPixelsPerElement, getSubsampling, getTileSize, renderMethods inherited from class org.apache.sis.coverage.grid.GridCoverage
createConvertedValues, evaluator, forConvertedValues, getCoordinateReferenceSystem, getEnvelope, getGridGeometry, getSampleDimensions, toString, toTree
-
Field Details
-
scanlineStride
private final long scanlineStrideNumber of sample values to skip for moving to the next row of a tile in the GeoTIFF file. This is not necessarily the same scanline stride than for the tiles created by this class. -
beforeFirstBand
private final int beforeFirstBandNumber of sample values to skip before to read the first value of the first pixel in a row. The first pixel is at column index 0; subsampling offset is not included in this calculation. -
afterLastBand
private final int afterLastBandNumber of sample values to skip for reaching end-of-row after reading the last value of the first pixel in a row. For computing the actual number of sample values to skip, the number of sample values read or skipped before the last pixel must be subtracted. -
skipAfterChunks
private final int[] skipAfterChunksNumber of sample values to skip after a chunk has been read, ornullif none. In this class, a "chunk" is a sample value or a complete pixel, depending onsamplesPerChunk(note that the definition of "chunk" can be expanded to an entire row by theInflaterclass). TheskipAfterChunksarray is used in a cyclic way:- Skip
skipAfterChunks[0]sample values between chunk 0 and chunk 1. - Skip
skipAfterChunks[1]sample values between chunk 1 and chunk 2. - etc. When we reach the array end, continue at
skipAfterChunks[0]. - When we start a new row, unconditionally restart at
skipAfterChunks[0].
skipAfterChunks[x % skipAfterChunks.length]sample values after chunk at the zero-based column index x. - Skip
-
samplesPerChunk
private final int samplesPerChunkNumber of sample values that compose a chunk (pixel or sample) in the GeoTIFF file. The value of this field can be:- 1 if a chunk is a sample value.
DataSubset.sourcePixelStrideif a chunk is a full pixel.- Any intermediate value if some optimizations have been applied,
for example for taking advantage of consecutive indices in
TiledGridCoverage.includedBands.
DataSubset.targetPixelStride. -
inflater
The inflater, created when reading the first tile and discarded after reading the last tile.- See Also:
-
-
Constructor Details
-
CompressedSubset
CompressedSubset(DataCube source, TiledGridResource.Subset subset) throws DataStoreException Creates a new data subset. All parameters should have been validated byImageFileDirectory.validateMandatoryTags()before this call. This constructor should be invoked inside a synchronized block.- Parameters:
source- the resource which contain thisDataSubset.subset- description of theownersubset to cover.rasters- potentially shared cache of rasters read by thisDataSubset.- Throws:
ArithmeticException- if the number of tiles overflows 32 bits integer arithmetic.DataStoreException
-
-
Method Details
-
startsWithZeros
private static boolean startsWithZeros(int[] skipAfterChunks, int m) Returnstrueif all array elements except the last one are zeros. Atruevalue means that all sample values in a pixel are consecutive.- Parameters:
m-skipAfterChunks.length- 1. Shall be greater than zero.
-
pixelCount
private static int pixelCount(long[] lower, long[] upper, int[] subsampling, int i) Computes the number of pixels to read in dimension i. The arguments given to this method are the ones given to thereadSlice(…)method. -
readSlice
Raster readSlice(long[] offsets, long[] byteCounts, long[] lower, long[] upper, int[] subsampling, Point location) throws IOException, DataStoreException Reads a two-dimensional slice of the data cube from the given input channel.- Overrides:
readSlicein classDataSubset- Parameters:
offsets- position in the channel where tile data begins, one value per bank.byteCounts- number of bytes for the compressed tile data, one value per bank.lower- (x, y) coordinates of the first pixel to read relative to the tile.upper- (x, y) coordinates after the last pixel to read relative to the tile.subsampling- (sx, sy) subsampling factors.location- pixel coordinates in the upper-left corner of the tile to return.- Returns:
- a single tile decoded from the GeoTIFF file.
- Throws:
IOException- if an I/O error occurred.DataStoreException- if a logical error occurred.- See Also:
-
createInflater
Returns the object to close for releasing inflater resources. This method is invoked in a synchronized block before the first call toreadSlice(…).- Overrides:
createInflaterin classDataSubset
-
releaseInflater
Invoked after the last tile has been read, or after an exception has been thrown during the reading process. This method releases any resources used by the inflater.- Throws:
IOException
-