Package com.luciad.format.raster
Class TLcdTABRasterModelDecoder
java.lang.Object
com.luciad.format.raster.TLcdTABRasterModelDecoder
- All Implemented Interfaces:
ILcdInputStreamFactoryCapable
,ILcdModelDecoder
@LcdService(service=ILcdModelDecoder.class,
priority=20000)
public class TLcdTABRasterModelDecoder
extends Object
implements ILcdModelDecoder, ILcdInputStreamFactoryCapable
This model decoder decodes MapInfo TAB Raster files. A TAB Raster file
provides the file name and the geo-referencing information of its
corresponding image file.
Input files
File | Required | Entry point | Description |
---|---|---|---|
*.tab | x | x | TAB file specifying a model reference, raster tie points, and the actual raster image file |
*.tif ... |
x | image file containing the raster data. Note that the case of the image file name may matter, depending on your file system. |
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 aSeekableStream
for the image file.
Model structure
- This model decoder creates a model per TAB file.
- All models returned by this model decoder implement
ILcd2DBoundsIndexedModel
.
Model descriptor
- All models returned by this model decoder have a
TLcdRasterModelDescriptor
or aTLcdMultilevelRasterModelDescriptor
. - The type name of the model descriptor is the display name of this decoder.
Model reference
The model reference is decoded from thetab
file.
Model elements
- Each decoded model contains a single element that implements
ALcdImage
(and eitherILcdRaster
orILcdMultilevelRaster)
) andALcdImage
.
Useful settings
- Since the raster location is specified by means of tie points, the
properties
minimumTiePointCount
,allowOrthographicReferencing
, andmaximumResidualTiePointError
provide some control over the model reference system that is created and the minimal accuracy that is required. Alternatively, the propertyrasterReferencer
provides a means to completely control the way in which the raster model reference and bounds are created. - The properties
colorModel
,defaultValue
, andforcedTransparentColorIndex
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 suitableIndexColorModel
if the raster is to be painted.
Sample code
ILcdModelDecoder decoder = new TLcdTABRasterModelDecoder();
ILcdModel model = decoder.decode("raster.tif");
Performance tips
- The decoder supports tiled images. Tiling 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
, andlevelInterpolation
. Although there is an obvious overhead compared to 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
- TAB Format Specification, Revision 1.0, Specification Version 1.8.2
- Tagged Image File Format, TIFF, Revision 6.0, Aldus Developers Desk, 3 June 1992
Known limitations
- Some rare model references 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 Summary
-
Constructor Summary
ConstructorDescriptionCreates a new TLcdTABRasterModelDecoder that creates single level raster models by default.TLcdTABRasterModelDecoder
(int aLevelCount, double aLevelScaleFactor) Creates a new TLcdTABRasterModelDecoder that creates multi-level raster models by default. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canDecodeSource
(String aSourceName) Checks whether this model decoder can decode the specified data source.Creates a new model from the given data source.Returns the color model that is assigned to decoded rasters.int
Returns the default color or color index that is assigned to decoded rasters.Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder
.int
Returns the index of the color that is made transparent.Returns the input stream factory that is used.Returns the JAI operator that is used to load raster images.int
Returns the number of raster levels that is constructed on the fly.javax.media.jai.Interpolation
Returns the Interpolation that is applied between subsequent levels.double
Returns the scale factor between subsequent levels.double
Returns the maximum acceptable average residual error for tie points.Returns the raster referencer that is used when positioning image files based on tie points.boolean
Returns whether images that are positioned in geodetic references may be put in approximating orthographic grid references that are centered around the images.void
setAllowOrthographicReferencing
(boolean aAllowOrthographicReferencing) Specifies whether images that are positioned in geodetic references may be put in approximating orthographic grid references that are centered around the images.void
setColorModel
(ColorModel aColorModel) Sets the color model to be assigned to decoded rasters.void
setDefaultValue
(int aDefaultValue) Sets the default color or color index to be assigned to decoded rasters.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) Sets the JAI operator to be used to load raster images.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.void
setLevelInterpolation
(javax.media.jai.Interpolation aLevelInterpolation) Sets the Interpolation to be applied between subsequent levels.void
setLevelScaleFactor
(double aLevelScaleFactor) Sets the scale factor between subsequent levels.void
setMaximumResidualTiePointError
(double aMaximumResidualTiePointError) Sets the maximum acceptable average residual error for the tie points.void
setRasterReferencer
(ILcdRasterReferencer aRasterReferencer) Sets the raster referencer that will be used when positioning image files based on tie points.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.model.ILcdModelDecoder
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
-
Field Details
-
DEFAULT_DISPLAY_NAME
- See Also:
-
DEFAULT_EXTENSION
- See Also:
-
EPSILON
public static final double EPSILON- See Also:
-
-
Constructor Details
-
TLcdTABRasterModelDecoder
public TLcdTABRasterModelDecoder()Creates a new TLcdTABRasterModelDecoder that creates single level raster models by default. -
TLcdTABRasterModelDecoder
public TLcdTABRasterModelDecoder(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.
-
-
Method Details
-
setJAIOperator
Sets the JAI operator to be used to load raster images. -
getJAIOperator
Returns the JAI operator that is used to load raster images. -
setAllowOrthographicReferencing
public void setAllowOrthographicReferencing(boolean aAllowOrthographicReferencing) Specifies whether images that are positioned in geodetic references may be put in approximating orthographic grid references that are centered around the images. The default istrue
. -
isAllowOrthographicReferencing
public boolean isAllowOrthographicReferencing()Returns whether images that are positioned in geodetic references may be put in approximating orthographic grid references that are centered around the images. -
setMaximumResidualTiePointError
public void setMaximumResidualTiePointError(double aMaximumResidualTiePointError) Sets the maximum acceptable average residual error for the tie points.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
.- Parameters:
aMaximumResidualTiePointError
- the maximum residual error, expressed in pixels.
-
getMaximumResidualTiePointError
public double getMaximumResidualTiePointError()Returns the maximum acceptable average residual error for tie points. -
setRasterReferencer
Sets the raster referencer that will be used when positioning image files based on tie points. If it is set, it replaces the more basic settingsminimumTiePointCount
,allowOrthographicReferencing
, andmaximumResidualTiePointError
, which are used by default.- Parameters:
aRasterReferencer
- the raster referencer, which will create model references and raster bounds based on tie points.
-
getRasterReferencer
Returns the raster referencer that is used when positioning image files based on tie points. -
setInputStreamFactory
Sets the input stream factory that will be used for creating input streams. It must createSeekableStream
instances for the image file in order for JAI to be able to use them.- Specified by:
setInputStreamFactory
in interfaceILcdInputStreamFactoryCapable
- Parameters:
aInputStreamFactory
- the input stream factory to be used.
-
getInputStreamFactory
Description copied from interface:ILcdInputStreamFactoryCapable
Returns the input stream factory that is used.- Specified by:
getInputStreamFactory
in interfaceILcdInputStreamFactoryCapable
- 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
Sets the color model to be assigned to decoded rasters. -
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. -
getDisplayName
Description copied from interface:ILcdModelDecoder
Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder
.- Specified by:
getDisplayName
in interfaceILcdModelDecoder
- Returns:
- the displayable name of this
ILcdModelDecoder
.
-
canDecodeSource
Description copied from interface:ILcdModelDecoder
Checks whether this model decoder can decode the specified data source. It is acceptable for this method to returntrue
for a source name whiledecode
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.
- Specified by:
canDecodeSource
in interfaceILcdModelDecoder
- Parameters:
aSourceName
- the data source to be verified; typically a file name or a URL.- Returns:
true
if this decoder can likely decode the data specified by the source name,false
otherwise.- See Also:
-
decode
Description copied from interface:ILcdModelDecoder
Creates a new model from the given data source.- Specified by:
decode
in interfaceILcdModelDecoder
- 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:
-