@LcdService(service=ILcdModelDecoder.class, priority=20000) public class TLcdTFWRasterModelDecoder extends Object implements ILcdModelDecoder, ILcdInputStreamFactoryCapable
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.
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.
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.inputStreamFactory
of this decoder. The input stream factory must produce a SeekableStream
for the
image file.ILcd2DBoundsIndexedModel
.TLcdRasterModelDescriptor
or a
TLcdMultilevelRasterModelDescriptor
.ALcdImage
(and either ILcdRaster
or ILcdMultilevelRaster)
).colorModel
, defaultValue
, and
forcedTransparentColorIndex
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 suitable
IndexColorModel
if the raster is to be painted.
ILcdModelDecoder decoder =
new TLcdTFWRasterModelDecoder(3, 0.25, new TLcdEPSGModelReferenceDecoder(),
new TLcdGeodeticReference(new TLcdGeodeticDatum()),
0);
ILcdModel model = decoder.decode("raster.tif");
levelCount
,
levelScaleFactor
, and levelInterpolation
.
Although there is an obvious overhead compared to the precomputed levels
of detail, this technique still provides better raster painting
performance when zoomed out.Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_DISPLAY_NAME |
static String |
DEFAULT_EXTENSION |
Constructor and Description |
---|
TLcdTFWRasterModelDecoder()
Creates 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.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canDecodeSource(String aSourceName)
Checks whether
TLcdTFWRasterModelDecoder can decode the given data. |
ILcdModel |
decode(String aSourceName)
Creates a new model from the given data source.
|
ColorModel |
getColorModel()
Returns the color model that is assigned to decoded rasters.
|
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()
Returns the JAI operator that is used to load raster images.
|
int |
getLevelCount()
Returns the number of raster levels that is constructed on the fly.
|
javax.media.jai.Interpolation |
getLevelInterpolation()
Returns the Interpolation that is applied between subsequent levels.
|
double |
getLevelScaleFactor()
Returns the scale factor between subsequent levels.
|
ILcdModelReference |
getModelReference()
Returns the model reference that is assigned to decoded models.
|
ILcdModelReferenceDecoder |
getModelReferenceDecoder()
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.
|
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 DEFAULT_EXTENSION
public TLcdTFWRasterModelDecoder()
public TLcdTFWRasterModelDecoder(int aLevelCount, double aLevelScaleFactor)
aLevelCount
- the number of rasters levels.aLevelScaleFactor
- the scale factor between subsequent levels,
in both raster dimensions.public TLcdTFWRasterModelDecoder(int aLevelCount, double aLevelScaleFactor, ILcdModelReference aModelReference)
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.public TLcdTFWRasterModelDecoder(int aLevelCount, double aLevelScaleFactor, ILcdModelReferenceDecoder aModelReferenceDecoder)
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.public void setJAIOperator(String aJAIOperator)
public String getJAIOperator()
public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
SeekableStream
instances for the image file in order for JAI to be able to use them.setInputStreamFactory
in interface ILcdInputStreamFactoryCapable
aInputStreamFactory
- the input stream factory to be used.public ILcdInputStreamFactory getInputStreamFactory()
ILcdInputStreamFactoryCapable
getInputStreamFactory
in interface ILcdInputStreamFactoryCapable
public void setLevelCount(int aLevelCount)
public int getLevelCount()
public void setLevelScaleFactor(double aLevelScaleFactor)
setLevelCount(int)
public double getLevelScaleFactor()
public void setLevelInterpolation(javax.media.jai.Interpolation aLevelInterpolation)
setLevelCount(int)
public javax.media.jai.Interpolation getLevelInterpolation()
public void setColorModel(ColorModel aColorModel)
public ColorModel getColorModel()
public void setDefaultValue(int aDefaultValue)
public int getDefaultValue()
public void setForcedTransparentColorIndex(int aForcedTransparentColorIndex)
public int getForcedTransparentColorIndex()
public void setModelReference(ILcdModelReference aDefaultModelReference)
public ILcdModelReference getModelReference()
public void setModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
public ILcdModelReferenceDecoder getModelReferenceDecoder()
setModelReferenceDecoder(com.luciad.model.ILcdModelReferenceDecoder)
public String getDisplayName()
ILcdModelDecoder
ILcdModelDecoder
.getDisplayName
in interface ILcdModelDecoder
ILcdModelDecoder
.public boolean canDecodeSource(String aSourceName)
TLcdTFWRasterModelDecoder
can decode the given data.
The extension of the file name should be "tfw", "jgw", "bpw", or "gfw".canDecodeSource
in interface ILcdModelDecoder
aSourceName
- the name of the file that is to be decoded.true
if TLcdTFWRasterModelDecoder
can
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)