@LcdService(service=ILcdModelDecoder.class, priority=20000) public class TLcdGeoTIFFModelDecoder extends Object implements ILcdModelDecoder, ILcdInputStreamFactoryCapable
File | Required | Entry point | Description |
---|---|---|---|
*.tif *.tiff |
x | x | GeoTIFF/TIFF file containing the raster data and possibly specifying a model reference and raster bounds |
*.tab | TAB file specifying a model reference and raster bounds | ||
*.tfw | TIFF World file specifying raster bounds |
If none of the files specify a 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
<filename>.epsg
): see TLcdEPSGModelReferenceDecoder
for more info.<filename>.prj
): see TLcdWKTModelReferenceDecoder
for more info.<filename>.ref
): see TLcdModelReferenceDecoder
for more info.
If none of the files specify raster bounds, it is retrieved from the
bounds
property of this decoder.
You can find all details about reference decoding in the model reference section below.
inputStreamFactory
of this decoder. The input stream factory must produce a SeekableStream
or
ImageInputStream
for the image file.ILcd2DBoundsIndexedModel
.TLcdGeoTIFFModelDescriptor
or a
TLcdMultilevelGeoTIFFModelDescriptor
.ILcdGeodeticReference
or ILcdGridReference
as model
references.
ModelReferenceDecoder
(the default supports WKT (*.prj), REF (*.ref), and EPSG (*.epsg));
note that this only specifies the coordinate reference so you need another source for the bounds (ex. TFW file)default ModelReference
default Bounds
;
note that if this is used then the default ModelReference is also used (if set)supportGeoidDatums
is set to
true
and if the GeoTIFF tags specify a supported vertical
coordinate system, a more accurate geoid datum like EGM84, EGM96,
NGVD27, or NAVD88 is created. This is mostly relevant for GeoTIFF files
containing elevation data.
ALcdImage
(and either ILcdRaster
or ILcdMultilevelRaster)
).ILcdDisposable
. Disposing an element will release
all associated resources (ex. open files) immediately, afterwards it must not be used anymore. Elements that are not
disposed explicitly rely on the garbage collector to handle this.GTRasterTypeGeoKey
(1025). The sampling nature of the data is only exposed through
the image API
. The legacy
ILcdRaster
API assumes area-sampled.minimumTiePointCount
,
allowOrthographicReferencing
, and
maximumResidualTiePointError
provide some control over the
model reference system that is created and the minimal accuracy that is
required. Alternatively, the property rasterReferencer
provides a means to completely control the way in which the raster
model reference and bounds are created.colorModel
, defaultValue
,
forcedTransparentColorIndex
, and expandColorMap
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 don't have a
color map, so you should provide a suitable
IndexColorModel
if the raster is to be painted.
ILcdModelDecoder decoder =
new TLcdGeoTIFFModelDecoder();
ILcdModel model = decoder.decode("raster.tif");
levelCount
and levelScaleFactor
.
Although there is an obvious overhead compared to the precomputed levels
of detail, this technique still provides better raster painting
performance when zoomed out.TLcdGeoTIFFModelEncoder
can create compressed and tiled
multilevel GeoTIFF files that can replace the original GeoTIFF
files.optimize.jai.tile.cache
to
false
when starting up the Java Virtual Machine. The command
line then typically looks as follows:
java -Doptimize.jai.tile.cache=false ....
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_DISPLAY_NAME |
static String |
DEFAULT_JAI_OPERATOR |
static double |
EPSILON |
static String[] |
TIFF_EXTENSIONS |
Constructor and Description |
---|
TLcdGeoTIFFModelDecoder()
Creates a new TLcdGeoTIFFModelDecoder.
|
TLcdGeoTIFFModelDecoder(ILcdModelReference aDefaultModelReference)
Creates a new TLcdGeoTIFFModelDecoder with a default model reference.
|
TLcdGeoTIFFModelDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
Creates a new TLcdGeoTIFFModelDecoder with a model reference decoder.
|
TLcdGeoTIFFModelDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder,
ILcdModelReference aDefaultModelReference,
int aDefaultValue)
Creates a new TLcdGeoTIFFModelDecoder with a model reference decoder,
a default model reference, and a default value.
|
TLcdGeoTIFFModelDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder,
int aDefaultValue)
Creates a new TLcdGeoTIFFModelDecoder with a model reference decoder
and a default value.
|
TLcdGeoTIFFModelDecoder(ILcdModelReference aDefaultModelReference,
int aDefaultValue)
Creates a new TLcdGeoTIFFModelDecoder with a default model reference
and a default value.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canDecodeSource(String aSourceName)
Checks whether this model decoder can decode the specified data source.
|
static RenderedImage |
combine(RenderedImage aRGBImage,
RenderedImage aAlphaImage)
Combines an RGB image and a transparency bitmask image into a single
RGBA image.
|
ILcdModel |
decode(String aSourceName)
Creates a new model from the given data source.
|
ILcdBounds |
getBounds()
Sets the default model bounds that are assigned to decoded models of which the
image files don't specify bounds.
|
ColorModel |
getColorModel()
Returns the default color model that is assigned to decoded rasters.
|
ILcdModelReference |
getDefaultModelReference()
Returns the default model reference that is assigned to decoded models
whose image files don't specify model references.
|
int |
getDefaultValue()
Returns the default color or color index that is assigned to decoded rasters.
|
String |
getDisplayName()
Returns a short, displayable name for the format that is decoded by this
ILcdModelDecoder . |
int |
getForcedTransparentColorIndex()
Returns the index of the color that is made transparent.
|
ILcdInputStreamFactory |
getInputStreamFactory()
Returns the input stream factory that is used.
|
String |
getJAIOperator()
Deprecated.
This field no longer has any effect
|
int |
getLevelCount()
Returns the number of raster levels that is constructed on the fly.
|
double |
getLevelScaleFactor()
Returns the scale factor between subsequent levels.
|
double |
getMaximumResidualTiePointError()
Returns the maximum acceptable average residual error for tie points.
|
int |
getMinimumTiePointCount()
Returns the minimum number of tie points required for positioning image
files that provide tie points.
|
ILcdModelReferenceDecoder |
getModelReferenceDecoder()
Returns the model reference decoder that is used for image files that
don't specify model references.
|
ILcdRasterReferencer |
getRasterReferencer()
Returns the raster referencer that is used when positioning image files
based on tie points.
|
boolean |
isAllowOrthographicReferencing()
Returns whether images that are positioned in geodetic references
using tie points may be put in approximating orthographic grid
references that are centered around the images.
|
boolean |
isExpandColorMap()
Returns whether the color maps of decoded images are expanded.
|
boolean |
isStrictMode()
Determines if strict mode is enabled or not.
|
boolean |
isSupportGeoidDatums()
Returns whether the geodetic datums of the decoded GeoTIFF model references may be geoid datums.
|
boolean |
isTraceOn()
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
void |
setAllowOrthographicReferencing(boolean aAllowOrthographicReferencing)
Specifies whether images that are positioned in geodetic references
using tie points may be put in approximating orthographic grid
references that are centered around the images.
|
void |
setBounds(ILcdBounds aBounds)
Sets the default model bounds to be assigned to decoded models of which the
image files don't specify bounds.
|
static void |
setClassTraceOn(boolean aClassTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
void |
setColorModel(ColorModel aColorModel)
Sets the default color model to be assigned to decoded rasters.
|
void |
setDefaultModelReference(ILcdModelReference aDefaultModelReference)
Sets the default model reference to be assigned to decoded models of which the
image files don't specify model references.
|
void |
setDefaultValue(int aDefaultValue)
Sets the default color or color index to be assigned to decoded rasters.
|
void |
setExpandColorMap(boolean aExpandColorMap)
Sets whether the color maps of decoded images should be expanded.
|
void |
setForcedTransparentColorIndex(int aForcedTransparentColorIndex)
Sets the index of the color that should be made transparent in the rasters
that will be decoded next.
|
void |
setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
Sets the input stream factory that will be used for creating input streams.
|
void |
setJAIOperator(String aJAIOperator)
Deprecated.
This field no longer has any effect
|
void |
setLevelCount(int aLevelCount)
Sets the number of raster levels with varying levels of detail that should
be computed on the fly, and cached, for more efficient access by the
application.
|
void |
setLevelScaleFactor(double aLevelScaleFactor)
Sets the scale factor between subsequent levels.
|
void |
setMaximumResidualTiePointError(double aMaximumResidualTiePointError)
Sets the maximum acceptable average residual error for tie points, when
positioning image files that provide tie points instead of scaling
information or transformation matrices.
|
void |
setMinimumTiePointCount(int aMinimumTiePointCount)
Sets the minimum number of tie points required for positioning image
files that provide tie points instead of scaling information or
transformation matrices.
|
void |
setModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
Sets the model reference decoder that will be used for image files that
don't specify model references.
|
void |
setRasterReferencer(ILcdRasterReferencer aRasterReferencer)
Sets the raster referencer that will be used when positioning image files
based on tie points.
|
void |
setStrictMode(boolean aStrictMode)
Enables or disables strict decoding mode.
|
void |
setSupportGeoidDatums(boolean aSupportGeoidDatums)
Specifies whether the geodetic datums of the decoded GeoTIFF model
references may be geoid datums (like EGM96), instead of the default
ellipsoid datums (like WGS84).
|
void |
setTraceOn(boolean aTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
public static final String DEFAULT_DISPLAY_NAME
public static final String[] TIFF_EXTENSIONS
public static final String DEFAULT_JAI_OPERATOR
public static final double EPSILON
public TLcdGeoTIFFModelDecoder()
public TLcdGeoTIFFModelDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
public TLcdGeoTIFFModelDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder, int aDefaultValue)
public TLcdGeoTIFFModelDecoder(ILcdModelReference aDefaultModelReference)
public TLcdGeoTIFFModelDecoder(ILcdModelReference aDefaultModelReference, int aDefaultValue)
public TLcdGeoTIFFModelDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder, ILcdModelReference aDefaultModelReference, int aDefaultValue)
public 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 setModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
aModelReferenceDecoder
- the model reference decoder.public ILcdModelReferenceDecoder getModelReferenceDecoder()
setModelReferenceDecoder(com.luciad.model.ILcdModelReferenceDecoder)
public void setDefaultModelReference(ILcdModelReference aDefaultModelReference)
aDefaultModelReference
- the default model reference.public ILcdModelReference getDefaultModelReference()
public boolean isStrictMode()
setStrictMode(boolean)
public void setStrictMode(boolean aStrictMode)
aStrictMode
- true to enable strict mode; false to disable itpublic void setBounds(ILcdBounds aBounds)
aBounds
- the default model bounds.public ILcdBounds getBounds()
public void setSupportGeoidDatums(boolean aSupportGeoidDatums)
public boolean isSupportGeoidDatums()
false
, ignoring the vertical datum information.public void setMinimumTiePointCount(int aMinimumTiePointCount)
A value of 3 can be used, if the assumption is made that 3 tie points always define an affine transformation (which is not strictly guaranteed by the GeoTIFF specifications).
A value of 2 can be used, if the assumption is made that 2 tie points always define an affine transformation without rotation.
aMinimumTiePointCount
- the minimum number of tie points.setAllowOrthographicReferencing(boolean)
,
setMaximumResidualTiePointError(double)
public int getMinimumTiePointCount()
public void setAllowOrthographicReferencing(boolean aAllowOrthographicReferencing)
true
.public boolean isAllowOrthographicReferencing()
public void setMaximumResidualTiePointError(double aMaximumResidualTiePointError)
A raster is always positioned by means of an affine transformation in its coordinate system. For tie points that define an affine transformation, the residual error should therefore be 0. For tie points that define more complex, non-linear warping of the image, it will be larger than 0.
The residual error is computed in image coordinates and expressed in
pixels. The default is EPSILON
.
aMaximumResidualTiePointError
- the maximum residual error, expressed
in pixels.setMinimumTiePointCount(int)
public double getMaximumResidualTiePointError()
public void setRasterReferencer(ILcdRasterReferencer aRasterReferencer)
minimumTiePointCount
, allowOrthographicReferencing
,
and maximumResidualTiePointError
, which are used by default.aRasterReferencer
- the raster referencer, which will create model
references and raster bounds based on tie points.public ILcdRasterReferencer getRasterReferencer()
public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
ImageInputStream
SeekableStream
setInputStreamFactory
in interface ILcdInputStreamFactoryCapable
aInputStreamFactory
- the input stream factory to be used.public ILcdInputStreamFactory getInputStreamFactory()
ILcdInputStreamFactoryCapable
getInputStreamFactory
in interface ILcdInputStreamFactoryCapable
public void setJAIOperator(String aJAIOperator)
public String getJAIOperator()
public void setLevelCount(int aLevelCount)
public int getLevelCount()
public void setLevelScaleFactor(double aLevelScaleFactor)
setLevelCount(int)
public double getLevelScaleFactor()
public void setColorModel(ColorModel aColorModel)
public ColorModel getColorModel()
public void setDefaultValue(int aDefaultValue)
public int getDefaultValue()
public void setForcedTransparentColorIndex(int aForcedTransparentColorIndex)
42113
(GDAL_NODATA
) to indicate the no data value.public int getForcedTransparentColorIndex()
public void setExpandColorMap(boolean aExpandColorMap)
public boolean isExpandColorMap()
public String getDisplayName()
ILcdModelDecoder
ILcdModelDecoder
.getDisplayName
in interface ILcdModelDecoder
ILcdModelDecoder
.public boolean canDecodeSource(String aSourceName)
ILcdModelDecoder
true
for a source name while decode
throws an exception for that same source name.
For performance reasons, we strongly recommend that this will only be a simple test. For example: check the file extension of a file, but not that the file exists or contains expected content.
canDecodeSource
in interface ILcdModelDecoder
aSourceName
- the data source to be verified; typically a file name or a URL.true
if this decoder can likely decode the data specified by the source name, false
otherwise.ILcdModelDecoder.decode(String)
,
ILcdModelDecoder.decodeModelMetadata(String)
public ILcdModel decode(String aSourceName) throws IOException
ILcdModelDecoder
decode
in interface ILcdModelDecoder
aSourceName
- the data source to be decoded; typically a file name or a URL.null
is allowed, implementors are advised to throw an error instead.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);
}
}
InterruptedIOException
- When the thread on which this method is called is interrupted: it is recommended to stop the decoding
and throw an InterruptedIOException
.
This same exception can also be used if the decoder shows UI to the user, and the user cancels the decoding
through the UI.ILcdModelDecoder.canDecodeSource(String)
public static RenderedImage combine(RenderedImage aRGBImage, RenderedImage aAlphaImage)