Class TLcdECWModelDecoder
- All Implemented Interfaces:
ILcdMetadataDecoder
,ILcdModelDecoder
Input files
File | Required | Entry point | Description |
---|---|---|---|
*.ecw | x | x | ECW file containing the raster data and possibly specifying a model reference and raster bounds using embedded GeoTIFF tags |
*.ers | ERS file specifying a model reference and raster bounds | ||
*.tab | TAB file specifying a model reference and 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
- 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.
If none of the files specify raster bounds, it is retrieved from the
bounds
property of this decoder.
Supported file transfer protocols
As random access to the data is required, this decoder only reads from files. So it can for example not read from anInputStream
, from a http connection or from an image file inside
a jar file.
Model structure
- This model decoder creates a model per ECW file.
- All models returned by this model decoder implement
ILcd2DBoundsIndexedModel
.
Model descriptor
- All models returned by this model decoder have a
TLcdECWModelDescriptor
. - The type name of the model descriptor is the display name of this decoder.
Model reference
- This decoder retrieves the model references embedded in the ECW file.
- It is possible to specify a
default reference
for files from which the reference information is mssing. - A
custom reference decoder
can also be installed.
Model elements
- Each decoded model contains one object: an
ALcdImage
(andILcdMultilevelRaster
) instance.
Useful settings
- The property
defaultValue
allows the specify the default value that is assigned to decoded rasters.
Sample code
ILcdModelDecoder decoder =
new TLcdECWModelDecoder();
ILcdModel model = decoder.decode("raster.ecw");
Performance tips
- The decoded rasters load their data lazily. The encoding parameters of the ECW file may affect the run-time performance.
Thread safety
- The decoding of models is thread-safe, as long as no properties are changed during the decoding.
- The decoded models are thread-safe for read access.
Supported versions and specifications
- ECW SDK, Release 6.1.0
Known limitations
- Some rare EPSG model references are not supported.
Requirements
- This decoder is part of the Advanced Raster Connectors component.
- The native ECW library has to be available in order to be able to use this decoder. Note that on Windows systems, this library requires an up-to-date version of the Microsoft Visual C++ 2017 redistributable.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.luciad.format.metadata.model.ILcdMetadataDecoder
ILcdMetadataDecoder.MetadataWithSource
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreates a new TLcdECWModelDecoder, with a globally shared buffer for caching tiles.TLcdECWModelDecoder
(ILcdBuffer aBuffer) Creates a new TLcdECWModelDecoder with the given buffer.TLcdECWModelDecoder
(ILcdBuffer aBuffer, ILcdModelReference aDefaultModelReference) Creates a new TLcdECWModelDecoder with the given buffer and default model reference.TLcdECWModelDecoder
(ILcdBuffer aBuffer, ILcdModelReferenceDecoder aModelReferenceDecoder) Creates a new TLcdECWModelDecoder with the given buffer and model reference decoder.TLcdECWModelDecoder
(ILcdBuffer aBuffer, ILcdModelReferenceDecoder aModelReferenceDecoder, int aDefaultValue) Creates a new TLcdECWModelDecoder with the given buffer, model reference decoder, and default value.TLcdECWModelDecoder
(ILcdBuffer aBuffer, ILcdModelReferenceDecoder aModelReferenceDecoder, ILcdModelReference aDefaultModelReference, int aDefaultValue) Creates a new TLcdECWModelDecoder with the given properties.TLcdECWModelDecoder
(ILcdBuffer aBuffer, ILcdModelReference aDefaultModelReference, int aDefaultValue) Creates a new TLcdECWModelDecoder with the given buffer, default model reference, and default value. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canDecodeMetadata
(String aSourceName) Tells whether this metadata decoder can likely decode metadata for a given source name.boolean
canDecodeSource
(String aSourceName) Checks whetherTLcdECWModelDecoder
can decode the given data.Creates a new model from the given data source.decodeMetadata
(String aSourceName) The ECW metadata has the following structure:Sets the default model bounds that is assigned to rasters of the decoded models whose image files don't specify bounds.Returns the default model reference that is assigned to decoded models whose image files don't specify model references.int
Returns the default pixel value that is assigned to the rasters of the decoded models.Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder
.long
Returns the maximum size of the ECW image cache.double
Returns the maximum acceptable average residual error for tie points.Deprecated.Returns the model reference decoder that is used for decoded models whose image files don't specify model references.void
setBounds
(ILcdBounds aBounds) Sets the default model bounds that will be assigned to rasters of the decoded models whose image files don't specify bounds.void
setDefaultModelReference
(ILcdModelReference aDefaultModelReference) Sets the default model reference that will be assigned to decoded models whose image files don't specify model references.void
setDefaultValue
(int aDefaultValue) Sets the default pixel value that will be assigned to the rasters of the decoded models.void
setMaxCacheSize
(long aMaxCacheSize) Sets the maximum size of the ECW image cache.void
setMaximumResidualTiePointError
(double aMaximumResidualTiePointError) Sets the maximum acceptable average residual error for tie points, when positioning rasters based TAB files instead of on scaling information.void
setModelReference
(ILcdModelReference aDefaultModelReference) Deprecated.void
setModelReferenceDecoder
(ILcdModelReferenceDecoder aModelReferenceDecoder) Sets the model reference decoder that will be used for decoded models whose image files don't specify model references.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.format.metadata.model.ILcdMetadataDecoder
findAndDecodeMetadata
Methods inherited from interface com.luciad.model.ILcdModelDecoder
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
-
Field Details
-
DEFAULT_DISPLAY_NAME
- See Also:
-
EPSILON
public static final double EPSILON- See Also:
-
-
Constructor Details
-
TLcdECWModelDecoder
public TLcdECWModelDecoder()Creates a new TLcdECWModelDecoder, with a globally shared buffer for caching tiles.- See Also:
-
TLcdECWModelDecoder
Creates a new TLcdECWModelDecoder with the given buffer.- Parameters:
aBuffer
- the buffer in which pixel data can be decoded and cached.
-
TLcdECWModelDecoder
Creates a new TLcdECWModelDecoder with the given buffer and model reference decoder.
Important: The parameter
aBuffer
is no longer used and has no effect on the functionality of this decoder.- Parameters:
aBuffer
- the buffer in which pixel data can be decoded and cached.aModelReferenceDecoder
- the model reference decoder.
-
TLcdECWModelDecoder
public TLcdECWModelDecoder(ILcdBuffer aBuffer, ILcdModelReferenceDecoder aModelReferenceDecoder, int aDefaultValue) Creates a new TLcdECWModelDecoder with the given buffer, model reference decoder, and default value.
Important: The parameter
aBuffer
is no longer used and has no effect on the functionality of this decoder.- Parameters:
aBuffer
- the buffer in which pixel data can be decoded and cached.aModelReferenceDecoder
- the model reference decoder.aDefaultValue
- the default pixel value.
-
TLcdECWModelDecoder
Creates a new TLcdECWModelDecoder with the given buffer and default model reference.
Important: The parameter
aBuffer
is no longer used and has no effect on the functionality of this decoder.- Parameters:
aBuffer
- the buffer in which pixel data can be decoded and cached.aDefaultModelReference
- the default model reference.
-
TLcdECWModelDecoder
public TLcdECWModelDecoder(ILcdBuffer aBuffer, ILcdModelReference aDefaultModelReference, int aDefaultValue) Creates a new TLcdECWModelDecoder with the given buffer, default model reference, and default value.
Important: The parameter
aBuffer
is no longer used and has no effect on the functionality of this decoder.- Parameters:
aBuffer
- the buffer in which pixel data can be decoded and cached.aDefaultModelReference
- the default model reference.aDefaultValue
- the default pixel value.
-
TLcdECWModelDecoder
public TLcdECWModelDecoder(ILcdBuffer aBuffer, ILcdModelReferenceDecoder aModelReferenceDecoder, ILcdModelReference aDefaultModelReference, int aDefaultValue) Creates a new TLcdECWModelDecoder with the given properties.
Important: The parameter
aBuffer
is no longer used and has no effect on the functionality of this decoder.- Parameters:
aBuffer
- the buffer in which pixel data can be decoded and cached.aModelReferenceDecoder
- the model reference decoder.aDefaultModelReference
- the default model reference.aDefaultValue
- the default pixel value.
-
-
Method Details
-
setModelReferenceDecoder
Sets the model reference decoder that will be used for decoded models whose image files don't specify model references.- Parameters:
aModelReferenceDecoder
- the model reference decoder.
-
getModelReferenceDecoder
Returns the model reference decoder that is used for decoded models whose image files don't specify model references. The default value supports WKT (*.prj), REF (*.ref), and EPSG (*.epsg).- Returns:
- the model reference decoder used by this decoder
- See Also:
-
setDefaultModelReference
Sets the default model reference that will be assigned to decoded models whose image files don't specify model references.- Parameters:
aDefaultModelReference
- the default model reference.
-
getDefaultModelReference
Returns the default model reference that is assigned to decoded models whose image files don't specify model references. -
setModelReference
Deprecated. -
getModelReference
Deprecated. -
setBounds
Sets the default model bounds that will be assigned to rasters of the decoded models whose image files don't specify bounds.- Parameters:
aBounds
- the default model bounds.
-
getBounds
Sets the default model bounds that is assigned to rasters of the decoded models whose image files don't specify bounds. -
setMaximumResidualTiePointError
public void setMaximumResidualTiePointError(double aMaximumResidualTiePointError) Sets the maximum acceptable average residual error for tie points, when positioning rasters based TAB files instead of on scaling information.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. -
setDefaultValue
public void setDefaultValue(int aDefaultValue) Sets the default pixel value that will be assigned to the rasters of the decoded models.- Parameters:
aDefaultValue
- the default pixel value.- See Also:
-
getDefaultValue
public int getDefaultValue()Returns the default pixel value that is assigned to the rasters of the decoded models. -
getMaxCacheSize
public long getMaxCacheSize()Returns the maximum size of the ECW image cache. Note that the ECW image cache is currently shared between all ECW images. The default value is64MB
which should give good performance and reasonable memory usage in almost all cases.- Returns:
- the maximum size in bytes
-
setMaxCacheSize
public void setMaxCacheSize(long aMaxCacheSize) Sets the maximum size of the ECW image cache.- Parameters:
aMaxCacheSize
- the maximum size in bytes- 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 whetherTLcdECWModelDecoder
can decode the given data. The extension of the file name should be "ecw" or "ers".- Specified by:
canDecodeSource
in interfaceILcdModelDecoder
- Parameters:
aSourceName
- the name of the file that is to be decoded.- Returns:
true
ifTLcdECWModelDecoder
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:
-
canDecodeMetadata
Description copied from interface:ILcdMetadataDecoder
Tells whether this metadata decoder can likely decode metadata for a given source name.-
If
true
, it is likely thatILcdMetadataDecoder.decodeMetadata(String)
will return a non-nullTLcdISO19115Metadata
object, but it is not a guarantee. The result is optimistic. -
If
false
, it is guaranteed thatILcdMetadataDecoder.decodeMetadata(String)
will throw an exception or returnnull
.
- Specified by:
canDecodeMetadata
in interfaceILcdMetadataDecoder
- Parameters:
aSourceName
- the source name to decode metadata for- Returns:
true
if this metadata decoder can decode metadata for the given source name,false
otherwise
-
If
-
decodeMetadata
The ECW metadata has the following structure:Metadata DataIdentification Citation Title=[ECW data file name, same as identifier code] Identifier Code=[ECW data file name] Describes MX_DataSet DataFile FileName=[ECW data file name] SupportFiles FileName Src=[TAB support file name]* Src=[ERS support file name]* Src=[REF support file name]* Src=[PRJ support file name]*
Elements with a '*' are optional. All file names are without parent path, which is needed for portability.
Both the identifier and title contain the data file name. The identifier is authoritative, the title is for display purposes.
- Specified by:
decodeMetadata
in interfaceILcdMetadataDecoder
- Parameters:
aSourceName
- the source name to decode metadata from- Returns:
- the ECW metadata, possibly
null
- Throws:
IOException
- if the metadata cannot be decoded for some reason
-
.getDefaultModelReference()