Class CompressedSubset

All Implemented Interfaces:
Localized

final class CompressedSubset extends DataSubset
Raster data obtained from a compressed GeoTIFF file in the domain requested by user.
Since:
1.1
Version:
1.1
  • Field Details

    • scanlineStride

      private final long scanlineStride
      Number 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 beforeFirstBand
      Number 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 afterLastBand
      Number 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[] skipAfterChunks
      Number of sample values to skip after a chunk has been read, or null if none. In this class, a "chunk" is a sample value or a complete pixel, depending on samplesPerChunk (note that the definition of "chunk" can be expanded to an entire row by the Inflater class). The skipAfterChunks array 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].
      More generally, skip skipAfterChunks[x % skipAfterChunks.length] sample values after chunk at the zero-based column index x.
    • samplesPerChunk

      private final int samplesPerChunk
      Number of sample values that compose a chunk (pixel or sample) in the GeoTIFF file. The value of this field can be: This value shall always be a divisor of DataSubset.targetPixelStride.
    • inflater

      private transient Inflater inflater
      The inflater, created when reading the first tile and discarded after reading the last tile.
      See Also:
  • Constructor Details

  • Method Details

    • startsWithZeros

      private static boolean startsWithZeros(int[] skipAfterChunks, int m)
      Returns true if all array elements except the last one are zeros. A true value 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 the readSlice(…) 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:
      readSlice in class DataSubset
      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

      final Closeable createInflater()
      Returns the object to close for releasing inflater resources. This method is invoked in a synchronized block before the first call to readSlice(…).
      Overrides:
      createInflater in class DataSubset
    • releaseInflater

      private void releaseInflater() throws IOException
      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