Class TLcdCoverageModelDecoder
- All Implemented Interfaces:
ILcdInputStreamFactoryCapable
,ILcdModelDecoder
Input files
File | Required | Entry point | Description |
---|---|---|---|
${name}.xml | X | X | The Fusion Coverage description (metadata) |
${name}/*.ctr | X | The Fusion Coverage tile data |
Supported file transfer protocols
- The decoder supports decoding the coverages directly when located on the local file system. The decoding is based on the coverage xml description file.
- The decoder also supports all transfer protocols that are supported by
the
input stream factory
of this decoder. The decoding is based on the coverage xml description file. - The decoder also supports decoding coverages from a remote location when denoted with a
TLcdCoverageDataSource
.
Model structure
This model decoder returns a singleILcdModel
.
Model descriptor
All models returned by this model decoder have aTLcdCoverageModelDescriptor
.
The model descriptor indicates it is suitable for use with the imaging API (ILcdImageModelDescriptor
).
Model reference
This model decoder retrieves the model reference from the Fusion Coverage description (metadata) file.Model elements
A decoded model contains a single element that can be used with the imaging API. Extract the image usingALcdImage.fromDomainObject(Object)
if you need access to it.
Performance tips
When connecting to a local tile-store on disk this model decoder needs file system access for performance reasons.When connecting to a tile-store via the input stream factory
, performance is likely to be reduced.
The model decoder only attempts this when the tile-store cannot be accessed directly on the file system (e.g. for reading from a jar).
Known limitations
- This model decoder does not support fusion coverages for which a custom tile format has been used.
Thread safety
- The decoding of models is thread-safe.
- The decoded models are thread-safe for read access.
Sample code
Decode a local coverage
TLcdCoverageModelDecoder modelDecoder = new TLcdCoverageModelDecoder();
ILcdModel model = modelDecoder.decode("Data/LuciadFusion/Coverages/earth__image.xml");
Decode a remote coverage
TLcdCoverageDataSource coverageDataSource = new TLcdCoverageDataSource("http://sampleservices.luciad.com/lts", "92c09725-a9c5-46fb-bffd-d9e23b4abbf2");
TLcdCoverageModelDecoder modelDecoder = new TLcdCoverageModelDecoder();
ILcdModel model = modelDecoder.decodeSource(coverageDataSource);
- Since:
- 2017.0
-
Constructor Summary
ConstructorDescriptionConstructs the coverage model decoder.TLcdCoverageModelDecoder
(ALfnEnvironment aEnvironment, ALfnTileStoreProvider aTileStoreProvider, TLfnClientFactory aClientFactory) Constructs a new coverage model decoder instance which uses the specified Fusion environment, client factory and tile store provider. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canDecodeSource
(ILcdDataSource aDataSource) Checks whether this model decoder can decode the data source(s), identified by the passedILcdDataSource
.boolean
canDecodeSource
(String aSourceName) Checks whether this model decoder can decode the specified data source.Creates a new model from the given data source.decodeSource
(ILcdDataSource aDataSource) Creates a new model from the given data source.discoverDataSources
(String aSource) Discovers all the coverages of a given Luciad Tile Store source has to offer and returns them as a list of data sources.Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder
.Returns the input stream factory that is used.Returns the transport factory that will construct theILcdTransport
used for communicating with Luciad tile server.void
setInputStreamFactory
(ILcdInputStreamFactory aInputStreamFactory) Sets the input stream factory to be used.void
setTransportFactory
(ILcdTransportFactory aTransportFactory) Sets the transport factory that will construct theILcdTransport
used for communicating with Luciad tile server.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
decodeModelMetadata, decodeModelMetadata
-
Constructor Details
-
TLcdCoverageModelDecoder
public TLcdCoverageModelDecoder()Constructs the coverage model decoder. -
TLcdCoverageModelDecoder
public TLcdCoverageModelDecoder(ALfnEnvironment aEnvironment, ALfnTileStoreProvider aTileStoreProvider, TLfnClientFactory aClientFactory) Constructs a new coverage model decoder instance which uses the specified Fusion environment, client factory and tile store provider.- Parameters:
aEnvironment
- The fusion environmentaTileStoreProvider
- The tile store provideraClientFactory
- The client factory- Since:
- 2018.1
-
-
Method Details
-
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
.
-
getTransportFactory
Returns the transport factory that will construct theILcdTransport
used for communicating with Luciad tile server.- Returns:
- the transport.
- See Also:
-
setTransportFactory
Sets the transport factory that will construct theILcdTransport
used for communicating with Luciad tile server. The default transport factory createsILcdTransport
s based on the Apache HttpClient library. This factory uses the proxy configuration fromthe system-wide proxy selector
The transports created by the factory should implementILcdDisposable
if they hold any resources (ex. network connections). This setter does not affect already decoded models.- Parameters:
aTransportFactory
- the transport factory, must not benull
-
setInputStreamFactory
Sets the input stream factory to be used.When the decoder uses the input stream factory, it is decorated by a
TLcdFailureCachingInputStreamFactory
, with a retry period of 30 minutes. To change the retry period, supply anTLcdFailureCachingInputStreamFactory
to this method.- 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.
-
canDecodeSource
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.
For example:Data/LuciadFusion/Coverages/earth__image.xml
- 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:
-
canDecodeSource
Description copied from interface:ILcdModelDecoder
Checks whether this model decoder can decode the data source(s), identified by the passed
ILcdDataSource
.For performance reasons, we strongly recommend that this will only be a simple test. For example: check the instance class of
aDataSource
, or check the file extension if it is aTLcdDataSource
.The default implementation of this method will check if the given
ILcdDataSource
is aTLcdDataSource
. If not, this method returns false. Otherwise, it delegates the source to theILcdModelDecoder.canDecodeSource(String)
method.- Specified by:
canDecodeSource
in interfaceILcdModelDecoder
- Parameters:
aDataSource
- theILcdModelSource
to be verified.- Returns:
true
if this decoder can likely decode the data specified byaDataSource
,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:
aSource
- 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:
-
decodeSource
Description copied from interface:ILcdModelDecoder
Creates a new model from the given data source.
By default, this method:
- Throws a
NullPointerException
when anull
data source is passed. - Delegates to the
ILcdModelDecoder.decode(String)
method when aTLcdDataSource
is passed. - Throws an IOException in other case.
- Specified by:
decodeSource
in interfaceILcdModelDecoder
- Parameters:
aDataSource
- theILcdDataSource
to be decoded.- 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 decodeSource(ILcdDataSource aDataSource) throws IOException { try { // Perform decoding ... } catch (RuntimeException e) { throw new IOException(e); } }
- See Also:
- Throws a
-
discoverDataSources
Discovers all the coverages of a given Luciad Tile Store source has to offer and returns them as a list of data sources. If the given source is not a valid LuciadFusion LTS URI, this method will throw an IO exception.When the provided source location is a coverage XML file this method returns a list with a single data source.
Once you have the list of data sources, you can select and decode them using
decodeSource(com.luciad.model.ILcdDataSource)
.- Specified by:
discoverDataSources
in interfaceILcdModelDecoder
- Parameters:
aSource
- the source, which must be a valid LuciadFusion LTS URI, e.g.,http://terrain:8080/LuciadFusionV2016/lts
, or a path to a local coverage XML file.- Returns:
- a list of all the coverages as data sources, possibly empty but never
null
- Throws:
IOException
- if the given source is not a valid LuciadFusion LTS URI, or if something goes wrong connecting to the URI
-