@LcdService(service=ILcdModelDecoder.class, priority=20000) public class TLcdTABRasterModelDecoder extends Object implements ILcdModelDecoder, ILcdInputStreamFactoryCapable
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. |
inputStreamFactory
of this decoder. The input stream factory must produce a SeekableStream
for the
image file.ILcd2DBoundsIndexedModel
.TLcdRasterModelDescriptor
or a
TLcdMultilevelRasterModelDescriptor
.tab
file.
ALcdImage
(and either ILcdRaster
or ILcdMultilevelRaster)
) and ALcdImage
.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
, 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 TLcdTABModelDecoder();
ILcdModel model = decoder.decode("raster.tif");
levelCount
,
levelScaleFactor
, and levelInterpolation
.
Although there is an obvious overhead compared to 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 |
static double |
EPSILON |
Constructor and Description |
---|
TLcdTABRasterModelDecoder()
Creates 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.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canDecodeSource(String aSourceName)
Checks whether this model decoder can decode the specified data source.
|
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.
|
double |
getMaximumResidualTiePointError()
Returns the maximum acceptable average residual error for tie points.
|
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
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.
|
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 static final double EPSILON
public TLcdTABRasterModelDecoder()
public TLcdTABRasterModelDecoder(int aLevelCount, double aLevelScaleFactor)
aLevelCount
- the number of rasters levels.aLevelScaleFactor
- the scale factor between subsequent levels,
in both raster dimensions.public void setJAIOperator(String aJAIOperator)
public String getJAIOperator()
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.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)
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 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)