Class TLcdTFWRasterModelDecoder

java.lang.Object
com.luciad.format.raster.TLcdTFWRasterModelDecoder
All Implemented Interfaces:
ILcdInputStreamFactoryCapable, ILcdModelDecoder

@LcdService(service=ILcdModelDecoder.class, priority=20000) public class TLcdTFWRasterModelDecoder extends Object implements ILcdModelDecoder, ILcdInputStreamFactoryCapable
This model decoder decodes TIFF World files (tfw files), as well as JPEG World files (jgw files), BMP World files (bpw files) and PNG World files (pgw). A TFW/JGW/BPW/PGW file provides part of the geo-referencing information for its corresponding TIFF/JPEG/BMP/PNG image file.

Input files

File Required Entry point Description
*.tfw x x TIFF World files specifying the raster bounds
*.tif x
Corresponding TIFF file containing the actual raster data
*.jgw x x JPEG World files specifying the raster bounds
*.jpg x
Corresponding JPEG file containing the actual raster data
*.jpw x x JPEG World files specifying the raster bounds
*.jpg x
Corresponding JPEG file containing the actual raster data
*.bpw x x BMP World files specifying the raster bounds
*.bmp x
Corresponding BMP file containing the actual raster data
*.gfw x x GIF World files specifying the raster bounds
*.gif x
Corresponding GIF file containing the actual raster data
*.pgw x x PNG World files specifying the raster bounds
*.png x
Corresponding PNG file containing the actual raster data

The image file is found by replacing the world extension by its corresponding image extension.

Model reference

The model reference is obtained from an ILcdModelReferenceDecoder. The default reference decoder set on this model decoder is based on all model reference decoders annotated with the LcdService annotation, and can handle If this fails, the decoder's default model reference is returned. Unless set by the user, the default model reference is null.

Supported file transfer protocols

  • This model decoder supports all transfer protocols that are supported by the inputStreamFactory of this decoder. The input stream factory must produce a SeekableStream for the image file.

Model structure

  • This model decoder creates a model per TFW/JGW/BPW file.
  • All models returned by this model decoder implement ILcd2DBoundsIndexedModel.

Model descriptor

Model elements

  • Each decoded model contains a single element that implements ALcdImage (and either ILcdRaster or ILcdMultilevelRaster)).

Useful settings

  • The properties colorModel, defaultValue, and forcedTransparentColorIndex provide some control over the color models that are attached to the decoded rasters, if the color models of the images aren't quite suitable. Notably, 16-bits gray-scale images or elevation rasters often don't have a color map, so you should provide a suitable IndexColorModel if the raster is to be painted.

Sample code


 ILcdModelDecoder decoder =
   new TLcdTFWRasterModelDecoder(3, 0.25, new TLcdEPSGModelReferenceDecoder(),
                                 new TLcdGeodeticReference(new TLcdGeodeticDatum()),
                                 0);

 ILcdModel model = decoder.decode("raster.tif");
 

Performance tips

  • The decoder supports tiled images. Tiled images can greatly improve access times and reduce memory usage, since only the required parts of the images are decoded and cached.
  • It is possible to compute and cache lower resolution images on the fly, by means of the properties levelCount, levelScaleFactor, and levelInterpolation. Although there is an obvious overhead compared to the precomputed levels of detail, this technique still provides better raster painting performance when zoomed out.

Thread safety

  • The decoding of models is not thread-safe.
  • The decoded models are thread-safe for read access.

Supported versions and specifications

  • Tagged Image File Format, TIFF, Revision 6.0, Aldus Developers Desk, 3 June 1992

Known limitations

  • Sheared transformations are not supported.
  • The current implementation does not support TIFF RGB rasters with a planar configuration.

Requirements

  • The current implementation delegates image decoding to the Java Advanced Imaging library.
  • Field Details

    • DEFAULT_DISPLAY_NAME

      public static final String DEFAULT_DISPLAY_NAME
      See Also:
    • DEFAULT_EXTENSION

      public static final String DEFAULT_EXTENSION
  • Constructor Details

    • TLcdTFWRasterModelDecoder

      public TLcdTFWRasterModelDecoder()
      Creates a new TLcdTFWRasterModelDecoder that creates single level raster models by default.
    • TLcdTFWRasterModelDecoder

      public TLcdTFWRasterModelDecoder(int aLevelCount, double aLevelScaleFactor)
      Creates a new TLcdTABRasterModelDecoder that creates multi-level raster models by default.
      Parameters:
      aLevelCount - the number of rasters levels.
      aLevelScaleFactor - the scale factor between subsequent levels, in both raster dimensions.
    • TLcdTFWRasterModelDecoder

      public TLcdTFWRasterModelDecoder(int aLevelCount, double aLevelScaleFactor, ILcdModelReference aModelReference)
      Creates a new TLcdTABRasterModelDecoder that creates multi-level raster models by default, with a given fixed model reference.
      Parameters:
      aLevelCount - the number of rasters levels.
      aLevelScaleFactor - the scale factor between subsequent levels, in both raster dimensions.
      aModelReference - the model reference that is assigned to all decoded models.
    • TLcdTFWRasterModelDecoder

      public TLcdTFWRasterModelDecoder(int aLevelCount, double aLevelScaleFactor, ILcdModelReferenceDecoder aModelReferenceDecoder)
      Creates a new TLcdTABRasterModelDecoder that creates multi-level raster models by default, with model references decoded by the given model reference decoder.
      Parameters:
      aLevelCount - the number of rasters levels.
      aLevelScaleFactor - the scale factor between subsequent levels, in both raster dimensions.
      aModelReferenceDecoder - the decoder that can create model references for decoded models.
  • Method Details

    • setJAIOperator

      public void setJAIOperator(String aJAIOperator)
      Sets the JAI operator to be used to load raster images.
    • getJAIOperator

      public String getJAIOperator()
      Returns the JAI operator that is used to load raster images.
    • setInputStreamFactory

      public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
      Sets the input stream factory that will be used for creating input streams. It must create SeekableStream instances for the image file in order for JAI to be able to use them.
      Specified by:
      setInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Parameters:
      aInputStreamFactory - the input stream factory to be used.
    • getInputStreamFactory

      public ILcdInputStreamFactory getInputStreamFactory()
      Description copied from interface: ILcdInputStreamFactoryCapable
      Returns the input stream factory that is used.
      Specified by:
      getInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Returns:
      the input stream factory that is used.
    • setLevelCount

      public void setLevelCount(int aLevelCount)
      Sets the number of raster levels with varying levels of detail that should be constructed on the fly, and cached, for more efficient access by the application. If 1, a single level raster is constructed. If larger than 1, a multi-level raster is constructed.
    • getLevelCount

      public int getLevelCount()
      Returns the number of raster levels that is constructed on the fly.
    • setLevelScaleFactor

      public void setLevelScaleFactor(double aLevelScaleFactor)
      Sets the scale factor between subsequent levels.
      See Also:
    • getLevelScaleFactor

      public double getLevelScaleFactor()
      Returns the scale factor between subsequent levels.
    • setLevelInterpolation

      public void setLevelInterpolation(javax.media.jai.Interpolation aLevelInterpolation)
      Sets the Interpolation to be applied between subsequent levels.
      See Also:
    • getLevelInterpolation

      public javax.media.jai.Interpolation getLevelInterpolation()
      Returns the Interpolation that is applied between subsequent levels.
    • setColorModel

      public void setColorModel(ColorModel aColorModel)
      Sets the color model to be assigned to decoded rasters.
    • getColorModel

      public ColorModel getColorModel()
      Returns the color model that is assigned to decoded rasters.
    • setDefaultValue

      public void setDefaultValue(int aDefaultValue)
      Sets the default color or color index to be assigned to decoded rasters.
    • getDefaultValue

      public int getDefaultValue()
      Returns the default color or color index that is assigned to decoded rasters.
    • setForcedTransparentColorIndex

      public void setForcedTransparentColorIndex(int aForcedTransparentColorIndex)
      Sets the index of the color that should be made transparent in the rasters that will be decoded next. This can be useful if the image has an IndexColorModel that doesn't contain a transparent color of its own.
    • getForcedTransparentColorIndex

      public int getForcedTransparentColorIndex()
      Returns the index of the color that is made transparent.
    • setModelReference

      public void setModelReference(ILcdModelReference aDefaultModelReference)
      Sets the model reference to be assigned to decoded models.
    • getModelReference

      public ILcdModelReference getModelReference()
      Returns the model reference that is assigned to decoded models.
    • setModelReferenceDecoder

      public void setModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
      Sets the model reference decoder that will be used for creating model references for decoded models.
    • getModelReferenceDecoder

      public ILcdModelReferenceDecoder getModelReferenceDecoder()
      Returns the model reference decoder that is used for creating model references for decoded models. The default value supports WKT (*.prj), REF (*.ref), and EPSG (*.epsg).
      Returns:
      the model reference decoder used by this decoder
      See Also:
    • getDisplayName

      public String getDisplayName()
      Description copied from interface: ILcdModelDecoder
      Returns a short, displayable name for the format that is decoded by this ILcdModelDecoder.
      Specified by:
      getDisplayName in interface ILcdModelDecoder
      Returns:
      the displayable name of this ILcdModelDecoder.
    • canDecodeSource

      public boolean canDecodeSource(String aSourceName)
      Checks whether TLcdTFWRasterModelDecoder can decode the given data. The extension of the file name should be "tfw", "jgw", "bpw", or "gfw".
      Specified by:
      canDecodeSource in interface ILcdModelDecoder
      Parameters:
      aSourceName - the name of the file that is to be decoded.
      Returns:
      true if TLcdTFWRasterModelDecoder can decode the data specified by the source name, false otherwise.
      See Also:
    • decode

      public ILcdModel decode(String aSourceName) throws IOException
      Description copied from interface: ILcdModelDecoder
      Creates a new model from the given data source.
      Specified by:
      decode in interface ILcdModelDecoder
      Parameters:
      aSourceName - the data source to be decoded; typically a file name or a URL.
      Returns:
      A model containing the decoded data. While null is allowed, implementors are advised to throw an error instead.
      Throws:
      IOException - for any exceptions caused by IO problems or invalid data. Since decoding invalid data almost always results in RunTimeExceptions (NullPointerException, IndexOutOfBoundsException, IllegalArgumentException, ...) on unexpected places, implementations are advised to catch RuntimeExceptions in their decode() method, and wrap them into an IOException, as illustrated in the code snippet below.
      
         public ILcdModel decode( String aSourceName ) throws IOException {
            try (InputStream input = fInputStreamFactory.createInputStream(aSourceName)) {
               // Perform decoding ...
            } catch (RuntimeException e) {
               throw new IOException(e);
            }
         }
       
      See Also: