it.geosolutions.imageio.gdalframework
Class GDALImageReader

Object
  extended by ImageReader
      extended by GDALImageReader

public abstract class GDALImageReader
extends ImageReader

Main abstract class defining the main framework which needs to be used to extend Image I/O architecture using GDAL (Geospatial Data Abstraction Layer) by means of SWIG (Simplified Wrapper and Interface Generator) bindings in order to perform read operations.

Author:
Daniele Romagnoli, GeoSolutions., Simone Giannecchini, GeoSolutions.

Field Summary
 
Fields inherited from class ImageReader
availableLocales, ignoreMetadata, input, locale, minIndex, originatingProvider, progressListeners, seekForwardOnly, updateListeners, warningListeners, warningLocales
 
Constructor Summary
GDALImageReader(GDALImageReaderSpi originatingProvider)
          Constructs a GDALImageReader using a GDALImageReaderSpi.
GDALImageReader(GDALImageReaderSpi originatingProvider, int numSubdatasets)
          Constructs a GDALImageReader using a GDALImageReaderSpi.
 
Method Summary
protected  void checkImageIndex(int imageIndex)
          Checks if the specified ImageIndex is valid.
protected  GDALCommonIIOImageMetadata createDatasetMetadata(Dataset mainDataset, String mainDatasetFileName)
          Build a proper GDALCommonIIOImageMetadata given an input dataset as well as the file name containing such a dataset.
protected  GDALCommonIIOImageMetadata createDatasetMetadata(String datasetName)
          Build a proper GDALCommonIIOImageMetadata given the name of a dataset.
 void dispose()
          Allows resources to be released
 GDALCommonIIOImageMetadata getDatasetMetadata(int imageIndex)
          Retrieves a GDALCommonIIOImageMetadata by index.
protected  File getDatasetSource(Object myInput)
          Tries to retrieve the Dataset Source for the ImageReader's input.
 int getGCPCount(int imageIndex)
          Returns the number of Ground Control Points of the Dataset at index imageIndex.
 String getGCPProjection(int imageIndex)
          Returns the Ground Control Points projection definition string of the Dataset at index imageIndex.
 List<? extends GCP> getGCPs(int imageIndex)
          Returns Ground Control Points of the Dataset at index imageIndex.
 double[] getGeoTransform(int imageIndex)
          Retrieves the GeoTransformation coefficients for the Dataset at index imageIndex.
 int getHeight(int imageIndex)
          Returns the height of the raster of the Dataset at index imageIndex.
 IIOMetadata getImageMetadata(int imageIndex)
          Returns an IIOMetadata object containing metadata associated with the given image, specified by the imageIndex parameter
 Iterator<ImageTypeSpecifier> getImageTypes(int imageIndex)
          Returns an Iterator containing possible image types to which the given image may be decoded, in the form of ImageTypeSpecifierss.
 double getMaximum(int imageIndex, int band)
          Returns the optional Maximum Value of the specified band of the Dataset at index imageIndex.
 double getMinimum(int imageIndex, int band)
          Returns the optional Minimum Value of the specified band of the Dataset at index imageIndex.
 double getNoDataValue(int imageIndex, int band)
          Returns the NoDataValue of the specified Band of the specified image
 int getNumImages(boolean allowSearch)
          Returns the number of images (subdatasets) contained within the data source.
 double getOffset(int imageIndex, int band)
          Returns the optional Offset Value of the specified band of the Dataset at index imageIndex.
 String getProjection(int imageIndex)
          Retrieves the WKT projection String for the Dataset at index imageIndex.
 double getScale(int imageIndex, int band)
          Returns the optional Scale Value of the specified band of the Dataset at index imageIndex.
 IIOMetadata getStreamMetadata()
          Returns an IIOMetadata object representing the metadata associated with the input source as a whole.
 int getTileHeight(int imageIndex)
          Returns the tile height of the raster of the Dataset at index imageIndex.
 int getTileWidth(int imageIndex)
          Returns the tile width of the raster of the Dataset at index imageIndex.
 int getWidth(int imageIndex)
          Returns the width of the raster of the Dataset at index imageIndex.
 BufferedImage read(int imageIndex)
          Performs a full read operation.
 BufferedImage read(int imageIndex, ImageReadParam param)
          Read the raster and returns a BufferedImage
 Raster readRaster(int imageIndex, ImageReadParam param)
          Implements the ImageRead.readRaster method which returns a new Raster object containing the raw pixel data from the image stream, without any color conversion applied.
 void reset()
          Reset main values
 void setInput(Object input, boolean seekForwardOnly)
           
 void setInput(Object input, boolean seekForwardOnly, boolean ignoreMetadata)
          Sets the input for the specialized reader.
 
Methods inherited from class ImageReader
abort, abortRequested, addIIOReadProgressListener, addIIOReadUpdateListener, addIIOReadWarningListener, canReadRaster, checkReadParamBandSettings, clearAbortRequest, computeRegions, getAspectRatio, getAvailableLocales, getDefaultReadParam, getDestination, getFormatName, getImageMetadata, getInput, getLocale, getMinIndex, getNumThumbnails, getOriginatingProvider, getRawImageType, getSourceRegion, getStreamMetadata, getThumbnailHeight, getThumbnailWidth, getTileGridXOffset, getTileGridYOffset, hasThumbnails, isIgnoringMetadata, isImageTiled, isRandomAccessEasy, isSeekForwardOnly, processImageComplete, processImageProgress, processImageStarted, processImageUpdate, processPassComplete, processPassStarted, processReadAborted, processSequenceComplete, processSequenceStarted, processThumbnailComplete, processThumbnailPassComplete, processThumbnailPassStarted, processThumbnailProgress, processThumbnailStarted, processThumbnailUpdate, processWarningOccurred, processWarningOccurred, readAll, readAll, readAsRenderedImage, readerSupportsThumbnails, readThumbnail, readTile, readTileRaster, removeAllIIOReadProgressListeners, removeAllIIOReadUpdateListeners, removeAllIIOReadWarningListeners, removeIIOReadProgressListener, removeIIOReadUpdateListener, removeIIOReadWarningListener, setInput, setLocale
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GDALImageReader

public GDALImageReader(GDALImageReaderSpi originatingProvider)
Constructs a GDALImageReader using a GDALImageReaderSpi.

Parameters:
originatingProvider - The GDALImageReaderSpi to use for building this GDALImageReader.

GDALImageReader

public GDALImageReader(GDALImageReaderSpi originatingProvider,
                       int numSubdatasets)
Constructs a GDALImageReader using a GDALImageReaderSpi.

Parameters:
originatingProvider - The GDALImageReaderSpi to use for building this GDALImageReader.
Method Detail

setInput

public void setInput(Object input,
                     boolean seekForwardOnly)
Overrides:
setInput in class ImageReader

getDatasetMetadata

public GDALCommonIIOImageMetadata getDatasetMetadata(int imageIndex)
Retrieves a GDALCommonIIOImageMetadata by index.

Parameters:
imageIndex - is the index of the required GDALCommonIIOImageMetadata.
Returns:
a GDALCommonIIOImageMetadata

checkImageIndex

protected void checkImageIndex(int imageIndex)
Checks if the specified ImageIndex is valid.

Parameters:
imageIndex - the specified imageIndex
Throws:
IndexOutOfBoundsException - if imageIndex is belower than 0 or if is greater than the number of subdatasets contained within the source (when the format supports subdatasets)

createDatasetMetadata

protected GDALCommonIIOImageMetadata createDatasetMetadata(String datasetName)
Build a proper GDALCommonIIOImageMetadata given the name of a dataset. The default implementation return a GDALCommonIIOImageMetadata instance.This method should be overridden by the specialized GDALImageReader in case you need to obtain a specific GDALCommonIIOImageMetadata's subclass

Parameters:
datasetName - the name of the dataset

createDatasetMetadata

protected GDALCommonIIOImageMetadata createDatasetMetadata(Dataset mainDataset,
                                                           String mainDatasetFileName)
Build a proper GDALCommonIIOImageMetadata given an input dataset as well as the file name containing such a dataset.


getDatasetSource

protected File getDatasetSource(Object myInput)
Tries to retrieve the Dataset Source for the ImageReader's input.


setInput

public void setInput(Object input,
                     boolean seekForwardOnly,
                     boolean ignoreMetadata)
Sets the input for the specialized reader.

Overrides:
setInput in class ImageReader
Throws:
IllegalArgumentException - if the provided input is null

dispose

public void dispose()
Allows resources to be released

Overrides:
dispose in class ImageReader

reset

public void reset()
Reset main values

Overrides:
reset in class ImageReader

getImageTypes

public Iterator<ImageTypeSpecifier> getImageTypes(int imageIndex)
                                           throws IOException
Returns an Iterator containing possible image types to which the given image may be decoded, in the form of ImageTypeSpecifierss. At least one legal image type will be returned. This implementation simply returns an ImageTypeSpecifier set in compliance with the property of the dataset contained within the underlying data source.

Specified by:
getImageTypes in class ImageReader
Parameters:
imageIndex - the index of the image to be retrieved.
Returns:
an Iterator containing possible image types to which the given image may be decoded, in the form of ImageTypeSpecifierss
Throws:
IOException

read

public BufferedImage read(int imageIndex,
                          ImageReadParam param)
                   throws IOException
Read the raster and returns a BufferedImage

Specified by:
read in class ImageReader
Parameters:
imageIndex - the index of the image to be retrieved.
param - an ImageReadParam used to control the reading process, or null. Actually, setting a destinationType allows to specify the number of bands in the destination image.
Returns:
the desired portion of the image as a BufferedImage
Throws:
IllegalArgumentException - if param contains an invalid specification of a source and/or destination band subset or of a destination image.
IOException - if an error occurs when acquiring access to the underlying datasource

readRaster

public Raster readRaster(int imageIndex,
                         ImageReadParam param)
                  throws IOException
Implements the ImageRead.readRaster method which returns a new Raster object containing the raw pixel data from the image stream, without any color conversion applied.

Overrides:
readRaster in class ImageReader
Parameters:
imageIndex - the index of the image to be retrieved.
param - an ImageReadParam used to control the reading process, or null.
Returns:
the desired portion of the image as a Raster.
Throws:
IOException

read

public BufferedImage read(int imageIndex)
                   throws IOException
Performs a full read operation.

Overrides:
read in class ImageReader
Parameters:
imageIndex - the index of the image to be retrieved.
Throws:
IOException

getNumImages

public int getNumImages(boolean allowSearch)
                 throws IOException
Returns the number of images (subdatasets) contained within the data source. If there are no subdatasets, it returns 1.

Specified by:
getNumImages in class ImageReader
Throws:
IOException

getWidth

public int getWidth(int imageIndex)
             throws IOException
Returns the width of the raster of the Dataset at index imageIndex.

Specified by:
getWidth in class ImageReader
Parameters:
imageIndex - the index of the specified raster
Returns:
raster width
Throws:
IOException

getHeight

public int getHeight(int imageIndex)
              throws IOException
Returns the height of the raster of the Dataset at index imageIndex.

Specified by:
getHeight in class ImageReader
Parameters:
imageIndex - the index of the specified raster
Returns:
raster height
Throws:
IOException

getTileHeight

public int getTileHeight(int imageIndex)
                  throws IOException
Returns the tile height of the raster of the Dataset at index imageIndex.

Overrides:
getTileHeight in class ImageReader
Parameters:
imageIndex - the index of the specified raster
Returns:
raster tile height
Throws:
IOException

getTileWidth

public int getTileWidth(int imageIndex)
                 throws IOException
Returns the tile width of the raster of the Dataset at index imageIndex.

Overrides:
getTileWidth in class ImageReader
Parameters:
imageIndex - the index of the specified raster
Returns:
raster tile width
Throws:
IOException

getProjection

public String getProjection(int imageIndex)
Retrieves the WKT projection String for the Dataset at index imageIndex.

Parameters:
imageIndex - the index of the dataset we want to get the projections for.
Returns:
the WKT projection String for the Dataset at index imageIndex.

getGeoTransform

public double[] getGeoTransform(int imageIndex)
Retrieves the GeoTransformation coefficients for the Dataset at index imageIndex.

Parameters:
imageIndex - the index of the dataset we want to get the coefficients for.
Returns:
the array containing the GeoTransformation coefficients.

getGCPs

public List<? extends GCP> getGCPs(int imageIndex)
Returns Ground Control Points of the Dataset at index imageIndex.

Parameters:
imageIndex - the index of the specified Dataset
Returns:
a List containing the Ground Control Points.

getGCPProjection

public String getGCPProjection(int imageIndex)
Returns the Ground Control Points projection definition string of the Dataset at index imageIndex.

Parameters:
imageIndex - the index of the specified Dataset
Returns:
the Ground Control Points projection definition string.

getGCPCount

public int getGCPCount(int imageIndex)
Returns the number of Ground Control Points of the Dataset at index imageIndex.

Parameters:
imageIndex - the index of the specified Dataset
Returns:
the number of GroundControlPoints of the Dataset.

getNoDataValue

public double getNoDataValue(int imageIndex,
                             int band)
Returns the NoDataValue of the specified Band of the specified image

Parameters:
imageIndex - the specified image
band - the specified band
Returns:
the Band NoDataValue if available
Throws:
IllegalArgumentException - in case the specified band number is out of range or noData value has not been found

getOffset

public double getOffset(int imageIndex,
                        int band)
Returns the optional Offset Value of the specified band of the Dataset at index imageIndex.

Parameters:
imageIndex - the index of the specified Dataset
band - the specified band
Returns:
the Band Offset Value if available
Throws:
IllegalArgumentException - in case the specified band number is out of range or Offset value has not been found

getScale

public double getScale(int imageIndex,
                       int band)
Returns the optional Scale Value of the specified band of the Dataset at index imageIndex.

Parameters:
imageIndex - the index of the specified Dataset
band - the specified band
Returns:
the Band Scale Value if available
Throws:
IllegalArgumentException - in case the specified band number is out of range or scale value has not been found

getMinimum

public double getMinimum(int imageIndex,
                         int band)
Returns the optional Minimum Value of the specified band of the Dataset at index imageIndex.

Parameters:
imageIndex - the index of the specified Dataset
band - the specified band
Returns:
the Band Minimum Value if available
Throws:
IllegalArgumentException - in case the specified band number is out of range or minimum value has not been found

getMaximum

public double getMaximum(int imageIndex,
                         int band)
Returns the optional Maximum Value of the specified band of the Dataset at index imageIndex.

Parameters:
imageIndex - the index of the specified Dataset
band - the specified band
Returns:
the Band Maximum Value if available
Throws:
IllegalArgumentException - in case the specified band number is out of range or maximum value has not been found

getStreamMetadata

public IIOMetadata getStreamMetadata()
                              throws IOException
Returns an IIOMetadata object representing the metadata associated with the input source as a whole.

Specified by:
getStreamMetadata in class ImageReader
Returns:
an IIOMetadata object.
Throws:
IOException

getImageMetadata

public IIOMetadata getImageMetadata(int imageIndex)
                             throws IOException
Returns an IIOMetadata object containing metadata associated with the given image, specified by the imageIndex parameter

Specified by:
getImageMetadata in class ImageReader
Parameters:
imageIndex - the index of the required image
Returns:
an IIOMetadata object
Throws:
IOException


Copyright © 2006-2010 GeoSolutions. All Rights Reserved.