@LcdService(service=ILcdModelEncoder.class, priority=20000) public class TLcdGeoTIFFModelEncoder extends Object implements ILcdModelEncoder, ILcdStatusSource
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).
TLcdGeoTIFFModelDecoder
,
Serialized FormModifier and Type | Field and Description |
---|---|
static int |
COMPRESSION_DEFLATE |
static int |
COMPRESSION_GROUP3_1D |
static int |
COMPRESSION_GROUP3_2D |
static int |
COMPRESSION_GROUP4 |
static int |
COMPRESSION_JPEG_TTN2 |
static int |
COMPRESSION_LZW |
static int |
COMPRESSION_NONE |
static int |
COMPRESSION_PACKBITS |
Constructor and Description |
---|
TLcdGeoTIFFModelEncoder()
Creates a GeoTIFF model encoder.
|
TLcdGeoTIFFModelEncoder(ALcdImagingEngine aImagingEngine)
Creates a GeoTIFF model encoder with the specified imaging engine.
|
Modifier and Type | Method and Description |
---|---|
void |
addStatusListener(ILcdStatusListener aListener)
Registers the given listener so it will receive status events from this source.
|
boolean |
canExport(ILcdModel aModel,
String aFilename)
Returns whether this encoder can export the specified model to the specified destination.
|
boolean |
canSave(ILcdModel aModel)
Returns whether this model encoder can save the specified model to the location it originally came from.
|
void |
export(ILcdModel aModel,
String aFilename)
Exports a model to a GeoTIFF file.
|
int |
getCompression()
Returns the compression scheme.
|
String |
getDisplayName()
Returns a short, displayable name for the format this
ILcdModelEncoder encodes to. |
TLcdGeoTIFFField[] |
getExtraGeoKeys()
Returns the additional TIFF fields, if any.
|
TLcdGeoTIFFField[] |
getExtraTIFFFields()
Returns the additional TIFF fields, if any.
|
ILcdOutputStreamFactory |
getImageOutputStreamFactory()
Returns the output stream factory.
|
int |
getLevelCount()
Returns the number of levels.
|
ILcdModelReferenceEncoder |
getModelReferenceEncoder()
Returns the model reference encoder, if any.
|
float |
getQuality()
Returns the JPEG compression quality.
|
double |
getScaleFactor()
Returns the scale factor.
|
int |
getTileHeight()
Returns the tile height.
|
int |
getTileWidth()
Returns the tile width.
|
boolean |
isEncodeBigTIFF()
Determines if this encoder uses the BigTIFF file format or not.
|
boolean |
isSaveLargeColorMaps()
Returns whether large color maps are included when encoding images.
|
boolean |
isTraceOn()
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
void |
removeStatusListener(ILcdStatusListener aListener)
Removes the specified listener so it is no longer notified.
|
void |
save(ILcdModel aModel)
Saves the model to the location where it originally came from.
|
static void |
setClassTraceOn(boolean aClassTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
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. It is recommended to use the
standard Java logging framework directly.
|
public static final int COMPRESSION_NONE
public static final int COMPRESSION_PACKBITS
public static final int COMPRESSION_GROUP3_1D
public static final int COMPRESSION_GROUP3_2D
public static final int COMPRESSION_GROUP4
public static final int COMPRESSION_LZW
public static final int COMPRESSION_JPEG_TTN2
public static final int COMPRESSION_DEFLATE
public TLcdGeoTIFFModelEncoder()
public TLcdGeoTIFFModelEncoder(ALcdImagingEngine aImagingEngine)
aImagingEngine
- the imaging engine to use to retrieve data for ALcdImage
's or null
to use the defaultpublic static void setClassTraceOn(boolean aClassTraceOn)
true
then all log messages are recorded, otherwise only
the informative, warning and error messages are recorded.aClassTraceOn
- if true then all log messages are recorded,
otherwise only the informative, warning and error messages are recorded.public void setTraceOn(boolean aTraceOn)
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.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.public boolean isTraceOn()
true
if tracing is enabled for this class.public void addStatusListener(ILcdStatusListener aListener)
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.
addStatusListener
in interface ILcdStatusSource
aListener
- The listener to be notified when the status has changed.public void removeStatusListener(ILcdStatusListener aListener)
ILcdStatusSource
removeStatusListener
in interface ILcdStatusSource
aListener
- The listener to remove.public void setImageOutputStreamFactory(ILcdOutputStreamFactory aImageOutputStreamFactory)
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.public ILcdOutputStreamFactory getImageOutputStreamFactory()
public void setLevelCount(int aLevelCount)
public int getLevelCount()
setLevelCount(int)
public void setScaleFactor(double aScaleFactor)
setLevelCount(int)
public double getScaleFactor()
setScaleFactor(double)
public void setTileWidth(int aTileWidth)
setTileHeight(int)
public int getTileWidth()
setTileWidth(int)
public void setTileHeight(int aTileHeight)
setTileWidth(int)
public int getTileHeight()
setTileHeight(int)
public boolean isEncodeBigTIFF()
setEncodeBigTIFF(boolean)
public void setEncodeBigTIFF(boolean aEncodeBigTIFF)
aEncodeBigTIFF
- true to enable BigTIFF encoding; false to disable it.isEncodeBigTIFF()
public void setCompression(int aCompression)
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.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
.public int getCompression()
setCompression(int)
public void setQuality(float aQuality)
aQuality
- a value between 0 and 1.setCompression(int)
public float getQuality()
setCompression(int)
public void setSaveLargeColorMaps(boolean aSaveLargeColorMaps)
aSaveLargeColorMaps
- a flag that specifies whether large color maps
should be included.public boolean isSaveLargeColorMaps()
public void setExtraTIFFFields(TLcdGeoTIFFField[] aExtraTIFFFields)
aExtraTIFFFields
- additional TIFF fields, identified by their tags.public TLcdGeoTIFFField[] getExtraTIFFFields()
null
if none have
been set.public void setExtraGeoKeys(TLcdGeoTIFFField[] aExtraGeoKeys)
aExtraGeoKeys
- additional TIFF fields, identified by their tags.public TLcdGeoTIFFField[] getExtraGeoKeys()
null
if none have been set.setExtraGeoKeys(TLcdGeoTIFFField[])
public ILcdModelReferenceEncoder getModelReferenceEncoder()
public void setModelReferenceEncoder(ILcdModelReferenceEncoder aModelReferenceEncoder)
aModelReferenceEncoder
- the model reference encoder.public String getDisplayName()
ILcdModelEncoder
ILcdModelEncoder
encodes to.getDisplayName
in interface ILcdModelEncoder
ILcdModelEncoder
.public boolean canSave(ILcdModel aModel)
ILcdModelEncoder
canSave
in interface ILcdModelEncoder
aModel
- the model to be verified.true
if this encoder can save the model in the location where it originally came from,
false
otherwise.ILcdModelEncoder.save(com.luciad.model.ILcdModel)
public void save(ILcdModel aModel) throws IllegalArgumentException, IOException
ILcdModelEncoder
save
in interface ILcdModelEncoder
aModel
- the model to be saved.IllegalArgumentException
- if the model cannot be saved by this encoder (!canSave(aModel)
).IOException
- if an I/O error occurs during encoding.public boolean canExport(ILcdModel aModel, String aFilename)
ILcdModelEncoder
canExport
in interface ILcdModelEncoder
aModel
- the model to be verified.aFilename
- the location where the model should be exported to.true
if this encoder can export the specified model to the
specified location, false
otherwise.ILcdModelEncoder.export(com.luciad.model.ILcdModel, java.lang.String)
public void export(ILcdModel aModel, String aFilename) throws IllegalArgumentException, IOException
ALcdBasicImage
, ALcdMultilevelImage
, ILcdRaster
or ILcdMultilevelRaster
element in the model is exported.export
in interface ILcdModelEncoder
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.IllegalArgumentException
- if the model cannot be saved by this encoder (!canExport(aModel, aDestinationName)
).IOException
- if an I/O error occurs during encoding.