Package com.luciad.format.raster
Class TLcdTFWRasterModelDecoder
java.lang.Object
com.luciad.format.raster.TLcdTFWRasterModelDecoder
- All Implemented Interfaces:
ILcdInputStreamFactoryCapable
,ILcdModelDecoder
@LcdService(service=ILcdModelDecoder.class,
priority=20000)
public class TLcdTFWRasterModelDecoder
extends Object
implements ILcdModelDecoder, ILcdInputStreamFactoryCapable
This model decoder decodes TIFF World files (
tfw
files), as well as JPEG World files (jgw
files), BMP World
files (bpw
files) and PNG World files (pgw
). A TFW/JGW/BPW/PGW file provides part of the
geo-referencing information for its corresponding TIFF/JPEG/BMP/PNG image file.
Input files
File | Required | Entry point | Description |
---|---|---|---|
*.tfw | x | x | TIFF World files specifying the raster bounds |
*.tif | x | Corresponding TIFF file containing the actual raster data | |
*.jgw | x | x | JPEG World files specifying the raster bounds |
*.jpg | x | Corresponding JPEG file containing the actual raster data | |
*.jpw | x | x | JPEG World files specifying the raster bounds |
*.jpg | x | Corresponding JPEG file containing the actual raster data | |
*.bpw | x | x | BMP World files specifying the raster bounds |
*.bmp | x | Corresponding BMP file containing the actual raster data | |
*.gfw | x | x | GIF World files specifying the raster bounds |
*.gif | x | Corresponding GIF file containing the actual raster data | |
*.pgw | x | x | PNG World files specifying the raster bounds |
*.png | x | Corresponding PNG file containing the actual raster data |
The image file is found by replacing the world extension by its corresponding image extension.
Model reference
The model reference is obtained from anILcdModelReferenceDecoder
. The default reference decoder set on this
model decoder is based on all model reference decoders annotated with the LcdService
annotation, and can handle
- EPSG references (
<filename>.epsg
): seeTLcdEPSGModelReferenceDecoder
for more info. - WKT references (
<filename>.prj
): seeTLcdWKTModelReferenceDecoder
for more info. - Luciad encoded model references (
<filename>.ref
): seeTLcdModelReferenceDecoder
for more info.
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 TFW/JGW/BPW 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 elements
- Each decoded model contains a single element that implements
ALcdImage
(and eitherILcdRaster
orILcdMultilevelRaster)
).
Useful settings
- 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 TLcdTFWRasterModelDecoder(3, 0.25, new TLcdEPSGModelReferenceDecoder(),
new TLcdGeodeticReference(new TLcdGeodeticDatum()),
0);
ILcdModel model = decoder.decode("raster.tif");
Performance tips
- The decoder supports tiled images. Tiled images 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 the 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
- Tagged Image File Format, TIFF, Revision 6.0, Aldus Developers Desk, 3 June 1992
Known limitations
- Sheared transformations 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 TLcdTFWRasterModelDecoder that creates single level raster models by default.TLcdTFWRasterModelDecoder
(int aLevelCount, double aLevelScaleFactor) Creates a new TLcdTABRasterModelDecoder that creates multi-level raster models by default.TLcdTFWRasterModelDecoder
(int aLevelCount, double aLevelScaleFactor, ILcdModelReference aModelReference) Creates a new TLcdTABRasterModelDecoder that creates multi-level raster models by default, with a given fixed model reference.TLcdTFWRasterModelDecoder
(int aLevelCount, double aLevelScaleFactor, ILcdModelReferenceDecoder aModelReferenceDecoder) Creates a new TLcdTABRasterModelDecoder that creates multi-level raster models by default, with model references decoded by the given model reference decoder. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canDecodeSource
(String aSourceName) Checks whetherTLcdTFWRasterModelDecoder
can decode the given data.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.Returns the model reference that is assigned to decoded models.Returns the model reference decoder that is used for creating model references for decoded models.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
setModelReference
(ILcdModelReference aDefaultModelReference) Sets the model reference to be assigned to decoded models.void
setModelReferenceDecoder
(ILcdModelReferenceDecoder aModelReferenceDecoder) Sets the model reference decoder that will be used for creating model references for decoded models.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
-
-
Constructor Details
-
TLcdTFWRasterModelDecoder
public TLcdTFWRasterModelDecoder()Creates a new TLcdTFWRasterModelDecoder that creates single level raster models by default. -
TLcdTFWRasterModelDecoder
public TLcdTFWRasterModelDecoder(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.
-
TLcdTFWRasterModelDecoder
public TLcdTFWRasterModelDecoder(int aLevelCount, double aLevelScaleFactor, ILcdModelReference aModelReference) Creates a new TLcdTABRasterModelDecoder that creates multi-level raster models by default, with a given fixed model reference.- Parameters:
aLevelCount
- the number of rasters levels.aLevelScaleFactor
- the scale factor between subsequent levels, in both raster dimensions.aModelReference
- the model reference that is assigned to all decoded models.
-
TLcdTFWRasterModelDecoder
public TLcdTFWRasterModelDecoder(int aLevelCount, double aLevelScaleFactor, ILcdModelReferenceDecoder aModelReferenceDecoder) Creates a new TLcdTABRasterModelDecoder that creates multi-level raster models by default, with model references decoded by the given model reference decoder.- Parameters:
aLevelCount
- the number of rasters levels.aLevelScaleFactor
- the scale factor between subsequent levels, in both raster dimensions.aModelReferenceDecoder
- the decoder that can create model references for decoded models.
-
-
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. -
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. -
setModelReference
Sets the model reference to be assigned to decoded models. -
getModelReference
Returns the model reference that is assigned to decoded models. -
setModelReferenceDecoder
Sets the model reference decoder that will be used for creating model references for decoded models. -
getModelReferenceDecoder
Returns the model reference decoder that is used for creating model references for decoded models. The default value supports WKT (*.prj), REF (*.ref), and EPSG (*.epsg).- Returns:
- the model reference decoder used by this decoder
- See Also:
-
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
Checks whetherTLcdTFWRasterModelDecoder
can decode the given data. The extension of the file name should be "tfw", "jgw", "bpw", or "gfw".- Specified by:
canDecodeSource
in interfaceILcdModelDecoder
- Parameters:
aSourceName
- the name of the file that is to be decoded.- Returns:
true
ifTLcdTFWRasterModelDecoder
can 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:
-