org.geotoolkit.image.io.plugin
Class WorldFileImageReader

Object
  extended by ImageReader
      extended by SpatialImageReader
          extended by ImageReaderAdapter
              extended by WorldFileImageReader
All Implemented Interfaces:
Disposable, Localized, WarningProducer

public class WorldFileImageReader
extends ImageReaderAdapter

Reader for the World File format. This reader wraps an other image reader for an "ordinary" image format, like TIFF, PNG or JPEG. This WorldFileImageReader delegates the reading of pixel values to the wrapped reader, and additionally looks for two small text files in the same directory than the image file, with the same filename but a different extension:

Every text file are expected to be encoded in ISO-8859-1 (a.k.a. ISO-LATIN-1) and every numbers are expected to be formatted in US locale.

Since:
3.08 (derived from 3.07)
Version:
3.08
Author:
Martin Desruisseaux (Geomatys)
See Also:
World File Format Description, WorldFileImageWriter
Module:
coverage/geotk-coverageio (download)    View source code for this class

Nested Class Summary
static class WorldFileImageReader.Spi
          Service provider interface (SPI) for WorldFileImageReaders.
 
Field Summary
 
Fields inherited from class ImageReaderAdapter
main
 
Fields inherited from class ImageReader
availableLocales, ignoreMetadata, input, locale, minIndex, originatingProvider, progressListeners, seekForwardOnly, updateListeners, warningListeners, warningLocales
 
Fields inherited from interface WarningProducer
LOGGER
 
Constructor Summary
WorldFileImageReader(WorldFileImageReader.Spi provider)
          Constructs a new image reader.
WorldFileImageReader(WorldFileImageReader.Spi provider, ImageReader main)
          Constructs a new image reader wrapping the given reader.
 
Method Summary
protected  void close()
          Closes the input streams created by this reader.
protected  Object createInput(String readerID)
          Creates the input to be given to the reader identified by the given argument.
protected  SpatialMetadata createMetadata(int imageIndex)
          Creates a new stream or image metadata.
 
Methods inherited from class ImageReaderAdapter
abort, addIIOReadProgressListener, addIIOReadUpdateListener, addIIOReadWarningListener, canReadRaster, dispose, finalize, getAspectRatio, getAvailableLocales, getDefaultReadParam, getDimension, getGridEnvelope, getHeight, getImageMetadata, getImageTypes, getLocale, getNumBands, getNumImages, getNumThumbnails, getRawImageType, getStreamMetadata, getThumbnailHeight, getThumbnailWidth, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, getWidth, hasColors, hasThumbnails, initialize, isImageTiled, isRandomAccessEasy, read, read, readAsRenderedImage, readerSupportsThumbnails, readRaster, readThumbnail, readTile, readTileRaster, removeAllIIOReadProgressListeners, removeAllIIOReadUpdateListeners, removeAllIIOReadWarningListeners, removeIIOReadProgressListener, removeIIOReadUpdateListener, removeIIOReadWarningListener, reset, setLocale
 
Methods inherited from class SpatialImageReader
checkBandIndex, checkImageIndex, collapseNoDataValues, getDestination, getImageType, getRawDataType, setInput, warningOccurred
 
Methods inherited from class ImageReader
abortRequested, checkReadParamBandSettings, clearAbortRequest, computeRegions, getDestination, getFormatName, getImageMetadata, getInput, getMinIndex, getOriginatingProvider, getSourceRegion, getStreamMetadata, isIgnoringMetadata, isSeekForwardOnly, processImageComplete, processImageProgress, processImageStarted, processImageUpdate, processPassComplete, processPassStarted, processReadAborted, processSequenceComplete, processSequenceStarted, processThumbnailComplete, processThumbnailPassComplete, processThumbnailPassStarted, processThumbnailProgress, processThumbnailStarted, processThumbnailUpdate, processWarningOccurred, processWarningOccurred, readAll, readAll, setInput, setInput
 
Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorldFileImageReader

public WorldFileImageReader(WorldFileImageReader.Spi provider)
                     throws IOException
Constructs a new image reader. The provider argument is mandatory for this constructor. If the provider is unknown, use the next constructor below instead.

Parameters:
provider - The ImageReaderSpi that is constructing this object.
Throws:
IOException - If an error occurred while creating the main reader.

WorldFileImageReader

public WorldFileImageReader(WorldFileImageReader.Spi provider,
                            ImageReader main)
Constructs a new image reader wrapping the given reader.

Parameters:
provider - The ImageReaderSpi that is constructing this object, or null.
main - The reader to use for reading the pixel values.
Method Detail

createInput

protected Object createInput(String readerID)
                      throws IOException
Creates the input to be given to the reader identified by the given argument. If the readerID argument is "main" (ignoring case), then this method delegates to the super-class method. Otherwise this method returns an input which is typically a File or URL having the same name than the input of this reader, but a different extension. The new extension is determined from the readerID argument, which can be: Subclasses can override this method for specifying a different main ("main"), World File ("tfw") or Map Projection ("prj") input. They can also invoke this method with other identifiers than the three above-cited ones, in which case this method uses the given identifier as the extension of the returned input. However the default WorldFileImageReader implementation uses only "main", "tfw" and "prj".

Overrides:
createInput in class ImageReaderAdapter
Parameters:
readerID - "main" for the main input, "tfw" for the World File input, or "prj" for the Map Projection input. Other identifiers are allowed but subclass-specific.
Returns:
The given kind of input typically as a File or URL object, or null if there is no input for the given identifier.
Throws:
IOException - If an error occurred while creating the input.
See Also:
WorldFileImageWriter.createOutput(String)

createMetadata

protected SpatialMetadata createMetadata(int imageIndex)
                                  throws IOException
Creates a new stream or image metadata. This method first delegates to the main reader as documented in the super-class method, then completes the metadata with information read from the World File and Map Projection files.

The World File and Map Projection files are determined by calls to the createInput(String) method with "tfw" and "prj" argument values. Subclasses can override the later method if they want to specify different files to be read.

Overrides:
createMetadata in class ImageReaderAdapter
Parameters:
imageIndex - -1 for stream metadata, or the image index for image metadata.
Returns:
The requested metadata, or null if none.
Throws:
IOException - If an error occurred while reading metadata.

close

protected void close()
              throws IOException
Closes the input streams created by this reader. This method is automatically invoked when a new input is set, or when the reader is reset or disposed.

Overrides:
close in class ImageReaderAdapter
Throws:
IOException - if an error occurred while closing the stream.


Copyright © 2009-2013 Geotoolkit.org. All Rights Reserved.