Class SparseTIFFImageReader
Extends the default TIFFImageReader to add support for querying empty tiles, so that sampling operations
can avoid initializing and indexing tiles (float[]s) full of zeroes.
Some hazard rasters, particularly water based, will be very fine resolution but very sparse. The raw amount of RAM required to represent these images is huge, but small on disk. Being able to skip generating image tiles for these empty tiles makes a big difference to performance.
Can only be used with a single image from a TIFF, which should be fine as I can't see any code in the
GeoTiffReader that would do anything but decide on a single image from the container to use. See
read(int, ImageReadParam) for information on why it is this way
{@link https://gdal.org/en/stable/drivers/raster/gtiff.html#sparse-files}
-
Nested Class Summary
Nested classes/interfaces inherited from class it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReader
it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReader.PageInfo -
Field Summary
Fields inherited from class it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReader
bitsPerSample, colorMap, compression, currIndex, destinationBands, dstHeight, dstMinX, dstMinY, dstWidth, dstXOffset, dstYOffset, extraSamples, gotTiffHeader, height, imageMetadata, imageReadParam, initialized, noData, numBands, photometricInterpretation, pixelsRead, pixelsToRead, planarConfiguration, sampleFormat, samplesPerPixel, sourceBands, sourceXOffset, sourceYOffset, srcXSubsampling, srcYSubsampling, stream, streamMetadata, theImage, tileOrStripHeight, tileOrStripWidth, tilesAcross, tilesDown, widthFields inherited from class javax.imageio.ImageReader
availableLocales, ignoreMetadata, input, locale, minIndex, originatingProvider, progressListeners, seekForwardOnly, updateListeners, warningListeners, warningLocales -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic SparseTIFFImageReaderinitialize(SparseTiffCoverage coverage) Initialize and return theSparseTIFFImageReaderthat is being used by the given coverage so that it is correctly setup with the right image index from the TIFF.booleanisEmptyTile(int tileX, int tileY) read(int imageIndex, ImageReadParam param) Override's the default method to aid in our kludge for supporting the isEmptyTile tile method without an image index, e.g.Methods inherited from class it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReader
canReadRaster, dispose, getCompression, getDefaultReadParam, getDestination, getHeight, getImageMetadata, getImageTypes, getNumImages, getNumThumbnails, getStreamMetadata, getStreamMetadata, getTileHeight, getTileOrStripByteCount, getTileOrStripOffset, getTileWidth, getWidth, hasThumbnails, isImageTiled, isRandomAccessEasy, prepareRead, readAsRenderedImage, readRaster, readSupportsThumbnails, readTile, reset, resetLocal, setInputMethods inherited from class javax.imageio.ImageReader
abort, abortRequested, addIIOReadProgressListener, addIIOReadUpdateListener, addIIOReadWarningListener, checkReadParamBandSettings, clearAbortRequest, computeRegions, getAspectRatio, getAvailableLocales, getDestination, getFormatName, getImageMetadata, getInput, getLocale, getMinIndex, getOriginatingProvider, getRawImageType, getSourceRegion, getStreamMetadata, getThumbnailHeight, getThumbnailWidth, getTileGridXOffset, getTileGridYOffset, isIgnoringMetadata, isSeekForwardOnly, processImageComplete, processImageProgress, processImageStarted, processImageUpdate, processPassComplete, processPassStarted, processReadAborted, processSequenceComplete, processSequenceStarted, processThumbnailComplete, processThumbnailPassComplete, processThumbnailPassStarted, processThumbnailProgress, processThumbnailStarted, processThumbnailUpdate, processWarningOccurred, processWarningOccurred, read, readAll, readAll, readerSupportsThumbnails, readThumbnail, readTileRaster, removeAllIIOReadProgressListeners, removeAllIIOReadUpdateListeners, removeAllIIOReadWarningListeners, removeIIOReadProgressListener, removeIIOReadUpdateListener, removeIIOReadWarningListener, setInput, setInput, setLocale
-
Constructor Details
-
SparseTIFFImageReader
-
-
Method Details
-
initialize
Initialize and return the
SparseTIFFImageReaderthat is being used by the given coverage so that it is correctly setup with the right image index from the TIFF. -
isEmptyTile
public boolean isEmptyTile(int tileX, int tileY) - Returns:
- true if the given tile is empty. Querying pixels from this tile will always result in no_data being returned
-
hasEmptyTiles
public boolean hasEmptyTiles()- Returns:
- true if this image reader has any knowledge of any empty (no-data) tiles
-
read
Override's the default method to aid in our kludge for supporting the isEmptyTile tile method without an image index, e.g. isEmptyTile(imageIndex, tileX, tileY) vs isEmptyTile(tileX, tileY).
From my reckons, there's no API way to access the index of the image that a coverage is actually sampling. The JAI Image API doesn't surface it, and neither does the GridCoverage2D API. That left me in a bind when implementing this: Do I use reflection to access the index from the JAI Image class, monkey patch the very large GeoTiffReader#read method to store the index that was picked? In the end I decided neither. In practice, it looks like it's always going to be one image in a TIFF that gets used, so this mild kludge seemed the lesser of all the evils.
- Overrides:
readin classit.geosolutions.imageioimpl.plugins.tiff.TIFFImageReader- Throws:
IOException
-