Class TLcdGeoTIFFModelEncoder

java.lang.Object
com.luciad.format.raster.TLcdGeoTIFFModelEncoder
All Implemented Interfaces:
ILcdModelEncoder, ILcdStatusSource, Serializable

@LcdService(service=ILcdModelEncoder.class, priority=20000) public class TLcdGeoTIFFModelEncoder extends Object implements ILcdModelEncoder, ILcdStatusSource
This ILcdModelEncoder encodes image or raster models into GeoTIFF files. The encoder will encode the first ALcdBasicImage, ALcdMultilevelImage, ILcdRaster or ILcdMultilevelRaster element in the model. Any other elements are ignored.

The property imageOutputStreamFactory provides some control over the destination of the encoded images. By default, they are written to files.

The encoder supports all baseline TIFF compression schemes. Compressed images are typically an order of magnitude smaller than uncompressed images. The default compression scheme is deflate (ZIP) compression. ZIP compression is lossless. It is well suited for vector images, typically with a limited number of colors defined in a color map. The most common alternative, JPEG compression, is lossy. It is better suited for pictures, like satellite imagery, typically with a large number of colors. JPEG compression does not support transparency though. The current implementation ignores any alpha channel when using JPEG compression.

The encoder can write out TIFF files containing multiple versions of the raster data at decreasing resolutions, as specified by the properties levelCount and levelScaleFactor. These precomputed levels of detail can greatly improve response times and quality of the image rendering when zoomed out. By default, the encoder writes out a single image for an ALcdBasicImage or ILcdRaster instance, and all levels for an ALcdMultilevelImage or ILcdMultilevelRaster instance. Alternatively, the number of levels can be specified explicitly. They are then computed on the fly, based on the most detailed data.

The encoder can write out tiled images, as specified by the properties tileWidth and tileHeight. Tiled images can greatly improve access times when they are used, since only the required parts of the images need be decoded and cached. The default tile size is 256 by 256 pixels.

The encoder provides the option saveLargeColorMaps to specify whether 16-bits color maps should be saved along with the image or not. By default, such large color models are not saved.

The encoder can optionally add additional TIFF fields to the encoded GeoTIFF files.

The encoder can produce files in the BigTIFF format, which is an extension of the TIFF format that supports files larger than 4Gb. See the BigTIFF File Format Proposal for details. BigTIFF output is enabled using setEncodeBigTIFF(boolean).

See Also:
  • Field Details

  • Constructor Details

    • TLcdGeoTIFFModelEncoder

      public TLcdGeoTIFFModelEncoder()
      Creates a GeoTIFF model encoder.

      The default imaging engine is used if necessary.

    • TLcdGeoTIFFModelEncoder

      public TLcdGeoTIFFModelEncoder(ALcdImagingEngine aImagingEngine)
      Creates a GeoTIFF model encoder with the specified imaging engine.
      Parameters:
      aImagingEngine - the imaging engine to use to retrieve data for ALcdImage's or null to use the default
  • Method Details

    • setClassTraceOn

      public static void setClassTraceOn(boolean aClassTraceOn)
      Deprecated.
      This method has been deprecated. It is recommended to use the standard Java logging framework directly.
      Enables tracing for all instances of this class. If the argument is true then all log messages are recorded, otherwise only the informative, warning and error messages are recorded.
      Parameters:
      aClassTraceOn - if true then all log messages are recorded, otherwise only the informative, warning and error messages are recorded.
    • setTraceOn

      public void setTraceOn(boolean aTraceOn)
      Deprecated.
      This method has been deprecated. It is recommended to use the standard Java logging framework directly.
      Enables tracing for this class instance. Calling this method with either true or false as argument automatically turns off tracing for all other class instances for which setTraceOn has not been called. If the argument is false then only the informative, warning and error log messages are recorded.
      Parameters:
      aTraceOn - if true then all log messages are recorded for this instance. If false, then only the informative, warning and error log messages are recorded.
    • isTraceOn

      public boolean isTraceOn()
      Deprecated.
      This method has been deprecated. It is recommended to use the standard Java logging framework directly.
      Returns true if tracing is enabled for this class.
      Returns:
      true if tracing is enabled for this class, false otherwise.
    • addStatusListener

      public void addStatusListener(ILcdStatusListener aListener)
      Description copied from interface: ILcdStatusSource

      Registers the given listener so it will receive status events from this source.

      In case you need to register a listener which keeps a reference to an object with a shorter life-time than this status source, you can use a ALcdWeakStatusListener instance as status listener.

      Specified by:
      addStatusListener in interface ILcdStatusSource
      Parameters:
      aListener - The listener to be notified when the status has changed.
    • removeStatusListener

      public void removeStatusListener(ILcdStatusListener aListener)
      Description copied from interface: ILcdStatusSource
      Removes the specified listener so it is no longer notified.
      Specified by:
      removeStatusListener in interface ILcdStatusSource
      Parameters:
      aListener - The listener to remove.
    • setImageOutputStreamFactory

      public void setImageOutputStreamFactory(ILcdOutputStreamFactory aImageOutputStreamFactory)
      Sets the factory that will create the output streams to which images can be encoded. The default is null, meaning that images are encoded in files.

      To ensure good performance this factory should create streams that implement one of the following interfaces:

      Otherwise a a temporary file may be created.
    • getImageOutputStreamFactory

      public ILcdOutputStreamFactory getImageOutputStreamFactory()
      Returns the output stream factory.
      See Also:
    • setLevelCount

      public void setLevelCount(int aLevelCount)
      Sets the number of raster levels with varying levels of detail that should be computed on the fly and written into the GeoTIFF file. The default is 0, meaning that only the original levels of the input rasters are encoded. If set to a value larger than 1, the additional levels of detail are computed and encoded.
    • getLevelCount

      public int getLevelCount()
      Returns the number of levels.
      See Also:
    • setScaleFactor

      public void setScaleFactor(double aScaleFactor)
      Sets the scale factor between subsequent levels. The default is 0.25.
      See Also:
    • getScaleFactor

      public double getScaleFactor()
      Returns the scale factor.
      See Also:
    • setTileWidth

      public void setTileWidth(int aTileWidth)
      Sets the tile width of the encoded images. The default is 256 pixels. Setting the tile width or tile height to a negative value or zero will cause the encoder to produce a stripped TIFF file rather than a tiled one.
      See Also:
    • getTileWidth

      public int getTileWidth()
      Returns the tile width.
      See Also:
    • setTileHeight

      public void setTileHeight(int aTileHeight)
      Sets the tile height of the encoded images. The default is 256 pixels. Setting the tile width or tile height to a negative value or zero will cause the encoder to produce a stripped TIFF file rather than a tiled one.
      See Also:
    • getTileHeight

      public int getTileHeight()
      Returns the tile height.
      See Also:
    • isEncodeBigTIFF

      public boolean isEncodeBigTIFF()
      Determines if this encoder uses the BigTIFF file format or not.
      Returns:
      true if BigTIFF encoding is enabled; false otherwise
      See Also:
    • setEncodeBigTIFF

      public void setEncodeBigTIFF(boolean aEncodeBigTIFF)
      Determines if the encoder will encode GeoTIFFs using the BigTIFF file format or not. By default BigTIFF encoding is disabled.
      Parameters:
      aEncodeBigTIFF - true to enable BigTIFF encoding; false to disable it.
      See Also:
    • setCompression

      public void setCompression(int aCompression)
      Sets the compression scheme of the encoded images. The default is COMPRESSION_DEFLATE (ZIP compression). The compression scheme must be compatible with the rasters to be encoded. For instance, it is not possible to encode rasters that have an IndexColorModel using JPEG compression.
      Parameters:
      aCompression - one of the supported TIFF compression schemes: COMPRESSION_NONE, COMPRESSION_PACKBITS, COMPRESSION_GROUP3_1D, COMPRESSION_GROUP3_2D, COMPRESSION_GROUP4, COMPRESSION_LZW, COMPRESSION_JPEG_TTN2, or COMPRESSION_DEFLATE.
    • getCompression

      public int getCompression()
      Returns the compression scheme.
      See Also:
    • setQuality

      public void setQuality(float aQuality)
      Sets the quality of images encoded with the JPEG compression scheme. The default is 0.8.
      Parameters:
      aQuality - a value between 0 and 1.
      See Also:
    • getQuality

      public float getQuality()
      Returns the JPEG compression quality.
      See Also:
    • setSaveLargeColorMaps

      public void setSaveLargeColorMaps(boolean aSaveLargeColorMaps)
      Specifies whether large color maps (for 16-bits pixel values) should be included when encoding images. Large color maps may for instance be attached to elevation rasters, and are often not strictly part of the data. The default is false.
      Parameters:
      aSaveLargeColorMaps - a flag that specifies whether large color maps should be included.
    • isSaveLargeColorMaps

      public boolean isSaveLargeColorMaps()
      Returns whether large color maps are included when encoding images.
    • setExtraTIFFFields

      public void setExtraTIFFFields(TLcdGeoTIFFField[] aExtraTIFFFields)
      Sets additional TIFF fields to be added to encoded GeoTIFFs. By default, only the GeoTIFF tag/field pairs are added.
      Parameters:
      aExtraTIFFFields - additional TIFF fields, identified by their tags.
    • getExtraTIFFFields

      public TLcdGeoTIFFField[] getExtraTIFFFields()
      Returns the additional TIFF fields, if any.
      Returns:
      the additional TIFF fields, or null if none have been set.
    • setExtraGeoKeys

      public void setExtraGeoKeys(TLcdGeoTIFFField[] aExtraGeoKeys)
      Sets additional GeoKey fields to be added to encoded GeoTIFFs. These fields are encoded not encoded as regular TIFF tags. They are encoded as part of the GeoKeyDirectoryTag, GeoDoubleParamsTag and GeoDoubleParamsTag GeoTIFF tags. Note the encoder already produces most of the required GeoKey values. Any values specified in the given array that are also generated by the encoder itself will be ignored.
      Parameters:
      aExtraGeoKeys - additional TIFF fields, identified by their tags.
    • getExtraGeoKeys

      public TLcdGeoTIFFField[] getExtraGeoKeys()
      Returns the additional TIFF fields, if any.
      Returns:
      the additional TIFF fields, or null if none have been set.
      See Also:
    • getModelReferenceEncoder

      public ILcdModelReferenceEncoder getModelReferenceEncoder()
      Returns the model reference encoder, if any.
      Returns:
      the model reference encoder.
    • setModelReferenceEncoder

      public void setModelReferenceEncoder(ILcdModelReferenceEncoder aModelReferenceEncoder)
      Sets a custom model reference encoder. By default the model reference parameters are encoded in the GeoTIFF file itself. If a reference encoder is set, only the bounds of the raster are encoded in the GeoTIFF file.
      Parameters:
      aModelReferenceEncoder - the model reference encoder.
    • getDisplayName

      public String getDisplayName()
      Description copied from interface: ILcdModelEncoder
      Returns a short, displayable name for the format this ILcdModelEncoder encodes to.
      Specified by:
      getDisplayName in interface ILcdModelEncoder
      Returns:
      the displayable name of this ILcdModelEncoder.
    • canSave

      public boolean canSave(ILcdModel aModel)
      Description copied from interface: ILcdModelEncoder
      Returns whether this model encoder can save the specified model to the location it originally came from. Often this will only be a simple test, for example checking the type of the model's model descriptor.
      Specified by:
      canSave in interface ILcdModelEncoder
      Parameters:
      aModel - the model to be verified.
      Returns:
      true if this encoder can save the model in the location where it originally came from, false otherwise.
      See Also:
    • save

      public void save(ILcdModel aModel) throws IllegalArgumentException, IOException
      Description copied from interface: ILcdModelEncoder
      Saves the model to the location where it originally came from.
      Specified by:
      save in interface ILcdModelEncoder
      Parameters:
      aModel - the model to be saved.
      Throws:
      IllegalArgumentException - if the model cannot be saved by this encoder (!canSave(aModel)).
      IOException - if an I/O error occurs during encoding.
    • canExport

      public boolean canExport(ILcdModel aModel, String aFilename)
      Description copied from interface: ILcdModelEncoder
      Returns whether this encoder can export the specified model to the specified destination. This method will typically check whether the contents of the specified model are compatible with the format this encoder is written for.
      Specified by:
      canExport in interface ILcdModelEncoder
      Parameters:
      aModel - the model to be verified.
      aFilename - the location where the model should be exported to.
      Returns:
      true if this encoder can export the specified model to the specified location, false otherwise.
      See Also:
    • export

      public void export(ILcdModel aModel, String aFilename) throws IllegalArgumentException, IOException
      Exports a model to a GeoTIFF file. Only the first ALcdBasicImage, ALcdMultilevelImage, ILcdRaster or ILcdMultilevelRaster element in the model is exported.
      Specified by:
      export in interface ILcdModelEncoder
      Parameters:
      aModel - the model to be exported.
      aFilename - the location where the model should be saved. Typically, this is a name for the output file, but it can also point to a file containing the required properties to create a set of data files.
      Throws:
      IllegalArgumentException - if the model cannot be saved by this encoder (!canExport(aModel, aDestinationName)).
      IOException - if an I/O error occurs during encoding.