Class TLcdGeoTIFFModelEncoder
- All Implemented Interfaces:
ILcdModelEncoder
,ILcdStatusSource
,Serializable
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 Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
-
Constructor Summary
ConstructorDescriptionCreates a GeoTIFF model encoder.TLcdGeoTIFFModelEncoder
(ALcdImagingEngine aImagingEngine) Creates a GeoTIFF model encoder with the specified imaging engine. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addStatusListener
(ILcdStatusListener aListener) Registers the given listener so it will receive status events from this source.boolean
Returns whether this encoder can export the specified model to the specified destination.boolean
Returns whether this model encoder can save the specified model to the location it originally came from.void
Exports a model to a GeoTIFF file.int
Returns the compression scheme.Returns a short, displayable name for the format thisILcdModelEncoder
encodes to.Returns the additional TIFF fields, if any.Returns the additional TIFF fields, if any.Returns the output stream factory.int
Returns the number of levels.Returns the model reference encoder, if any.float
Returns the JPEG compression quality.double
Returns the scale factor.int
Returns the tile height.int
Returns the tile width.boolean
Determines if this encoder uses the BigTIFF file format or not.boolean
Returns whether large color maps are included when encoding images.boolean
Deprecated.This method has been deprecated.void
removeStatusListener
(ILcdStatusListener aListener) Removes the specified listener so it is no longer notified.void
Saves the model to the location where it originally came from.static void
setClassTraceOn
(boolean aClassTraceOn) Deprecated.This method has been deprecated.void
setCompression
(int aCompression) Sets the compression scheme of the encoded images.void
setEncodeBigTIFF
(boolean aEncodeBigTIFF) Determines if the encoder will encode GeoTIFFs using the BigTIFF file format or not.void
setExtraGeoKeys
(TLcdGeoTIFFField[] aExtraGeoKeys) Sets additional GeoKey fields to be added to encoded GeoTIFFs.void
setExtraTIFFFields
(TLcdGeoTIFFField[] aExtraTIFFFields) Sets additional TIFF fields to be added to encoded GeoTIFFs.void
setImageOutputStreamFactory
(ILcdOutputStreamFactory aImageOutputStreamFactory) Sets the factory that will create the output streams to which images can be encoded.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.void
setModelReferenceEncoder
(ILcdModelReferenceEncoder aModelReferenceEncoder) Sets a custom model reference encoder.void
setQuality
(float aQuality) Sets the quality of images encoded with the JPEG compression scheme.void
setSaveLargeColorMaps
(boolean aSaveLargeColorMaps) Specifies whether large color maps (for 16-bits pixel values) should be included when encoding images.void
setScaleFactor
(double aScaleFactor) Sets the scale factor between subsequent levels.void
setTileHeight
(int aTileHeight) Sets the tile height of the encoded images.void
setTileWidth
(int aTileWidth) Sets the tile width of the encoded images.void
setTraceOn
(boolean aTraceOn) Deprecated.This method has been deprecated.
-
Field Details
-
COMPRESSION_NONE
public static final int COMPRESSION_NONE- See Also:
-
COMPRESSION_PACKBITS
public static final int COMPRESSION_PACKBITS- See Also:
-
COMPRESSION_GROUP3_1D
public static final int COMPRESSION_GROUP3_1D- See Also:
-
COMPRESSION_GROUP3_2D
public static final int COMPRESSION_GROUP3_2D- See Also:
-
COMPRESSION_GROUP4
public static final int COMPRESSION_GROUP4- See Also:
-
COMPRESSION_LZW
public static final int COMPRESSION_LZW- See Also:
-
COMPRESSION_JPEG_TTN2
public static final int COMPRESSION_JPEG_TTN2- See Also:
-
COMPRESSION_DEFLATE
public static final int COMPRESSION_DEFLATE- See Also:
-
-
Constructor Details
-
TLcdGeoTIFFModelEncoder
public TLcdGeoTIFFModelEncoder()Creates a GeoTIFF model encoder. The default imaging engine is used if necessary. -
TLcdGeoTIFFModelEncoder
Creates a GeoTIFF model encoder with the specified imaging engine.- Parameters:
aImagingEngine
- the imaging engine to use to retrieve data forALcdImage
's ornull
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 istrue
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 eithertrue
orfalse
as argument automatically turns off tracing for all other class instances for whichsetTraceOn
has not been called. If the argument isfalse
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.Returnstrue
if tracing is enabled for this class.- Returns:
- true if tracing is enabled for this class, false otherwise.
-
addStatusListener
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 interfaceILcdStatusSource
- Parameters:
aListener
- The listener to be notified when the status has changed.
-
removeStatusListener
Description copied from interface:ILcdStatusSource
Removes the specified listener so it is no longer notified.- Specified by:
removeStatusListener
in interfaceILcdStatusSource
- Parameters:
aListener
- The listener to remove.
-
setImageOutputStreamFactory
Sets the factory that will create the output streams to which images can be encoded. The default isnull
, 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
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 isCOMPRESSION_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 anIndexColorModel
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
, orCOMPRESSION_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
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
Returns the additional TIFF fields, if any.- Returns:
- the additional TIFF fields, or
null
if none have been set.
-
setExtraGeoKeys
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
Returns the additional TIFF fields, if any.- Returns:
- the additional TIFF fields, or
null
if none have been set. - See Also:
-
getModelReferenceEncoder
Returns the model reference encoder, if any.- Returns:
- the model reference encoder.
-
setModelReferenceEncoder
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
Description copied from interface:ILcdModelEncoder
Returns a short, displayable name for the format thisILcdModelEncoder
encodes to.- Specified by:
getDisplayName
in interfaceILcdModelEncoder
- Returns:
- the displayable name of this
ILcdModelEncoder
.
-
canSave
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 interfaceILcdModelEncoder
- 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
Description copied from interface:ILcdModelEncoder
Saves the model to the location where it originally came from.- Specified by:
save
in interfaceILcdModelEncoder
- 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
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 interfaceILcdModelEncoder
- 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
Exports a model to a GeoTIFF file. Only the firstALcdBasicImage
,ALcdMultilevelImage
,ILcdRaster
orILcdMultilevelRaster
element in the model is exported.- Specified by:
export
in interfaceILcdModelEncoder
- 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.
-