@LcdService(service=ILcdModelDecoder.class, priority=20000) public final class TLcdCoverageModelDecoder extends Object implements ILcdModelDecoder, ILcdInputStreamFactoryCapable
File | Required | Entry point | Description |
---|---|---|---|
${name}.xml | X | X | The Fusion Coverage description (metadata) |
${name}/*.ctr | X | The Fusion Coverage tile data |
input stream factory
of this decoder.
The decoding is based on the coverage xml description file.TLcdCoverageDataSource
. ILcdModel
.
TLcdCoverageModelDescriptor
.
The model descriptor indicates it is suitable for use with the imaging API (ILcdImageModelDescriptor
).
ALcdImage.fromDomainObject(Object)
if you need access to it.
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).
TLcdCoverageModelDecoder modelDecoder = new TLcdCoverageModelDecoder();
ILcdModel model = modelDecoder.decode("Data/LuciadFusion/Coverages/earth__image.xml");
TLcdCoverageDataSource coverageDataSource = new TLcdCoverageDataSource("http://sampleservices.luciad.com/lts", "92c09725-a9c5-46fb-bffd-d9e23b4abbf2");
TLcdCoverageModelDecoder modelDecoder = new TLcdCoverageModelDecoder();
ILcdModel model = modelDecoder.decodeSource(coverageDataSource);
Constructor and Description |
---|
TLcdCoverageModelDecoder()
Constructs 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.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canDecodeSource(ILcdDataSource aDataSource)
Checks whether this model decoder can decode the data source(s), identified by the passed
ILcdDataSource . |
boolean |
canDecodeSource(String aSourceName)
Checks whether this model decoder can decode the specified data source.
|
ILcdModel |
decode(String aSource)
Creates a new model from the given data source.
|
ILcdModel |
decodeSource(ILcdDataSource aDataSource)
Creates a new model from the given data source.
|
List<ILcdDataSource> |
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.
|
String |
getDisplayName()
Returns a short, displayable name for the format that is decoded by this
ILcdModelDecoder . |
ILcdInputStreamFactory |
getInputStreamFactory()
Returns the input stream factory that is used.
|
ILcdTransportFactory |
getTransportFactory()
Returns the transport factory that will construct the
ILcdTransport 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 the
ILcdTransport used for
communicating with Luciad tile server. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
decodeModelMetadata, decodeModelMetadata
public TLcdCoverageModelDecoder()
public TLcdCoverageModelDecoder(ALfnEnvironment aEnvironment, ALfnTileStoreProvider aTileStoreProvider, TLfnClientFactory aClientFactory)
aEnvironment
- The fusion environmentaTileStoreProvider
- The tile store provideraClientFactory
- The client factorypublic String getDisplayName()
ILcdModelDecoder
ILcdModelDecoder
.getDisplayName
in interface ILcdModelDecoder
ILcdModelDecoder
.public ILcdTransportFactory getTransportFactory()
ILcdTransport
used for
communicating with Luciad tile server.setTransportFactory(com.luciad.io.transport.ILcdTransportFactory)
public void setTransportFactory(ILcdTransportFactory aTransportFactory)
ILcdTransport
used for
communicating with Luciad tile server.
The default transport factory creates ILcdTransport
s based on the Apache HttpClient
library. This factory uses the proxy configuration from
the system-wide proxy selector
The transports created by the factory should implement ILcdDisposable
if they hold any
resources (ex. network connections).
This setter does not affect already decoded models.aTransportFactory
- the transport factory, must not be null
public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
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 an TLcdFailureCachingInputStreamFactory
to this method.
setInputStreamFactory
in interface ILcdInputStreamFactoryCapable
aInputStreamFactory
- the input stream factory to be used.public ILcdInputStreamFactory getInputStreamFactory()
ILcdInputStreamFactoryCapable
getInputStreamFactory
in interface ILcdInputStreamFactoryCapable
public boolean canDecodeSource(String aSourceName)
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.
For example:Data/LuciadFusion/Coverages/earth__image.xml
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 boolean canDecodeSource(ILcdDataSource aDataSource)
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 a TLcdDataSource
.
The default implementation of this method will check if the given ILcdDataSource
is a
TLcdDataSource
. If not, this method returns false. Otherwise, it delegates
the source to the ILcdModelDecoder.canDecodeSource(String)
method.
canDecodeSource
in interface ILcdModelDecoder
aDataSource
- the ILcdModelSource
to be verified.true
if this decoder can likely decode the data specified by aDataSource
, false
otherwise.ILcdModelDecoder.decodeSource(ILcdDataSource)
,
ILcdModelDecoder.decodeModelMetadata(ILcdDataSource)
public ILcdModel decode(String aSource) throws IOException
ILcdModelDecoder
decode
in interface ILcdModelDecoder
aSource
- 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)
public ILcdModel decodeSource(ILcdDataSource aDataSource) throws IOException
ILcdModelDecoder
Creates a new model from the given data source.
By default, this method:
NullPointerException
when a null
data source is passed.ILcdModelDecoder.decode(String)
method when a TLcdDataSource
is passed.decodeSource
in interface ILcdModelDecoder
aDataSource
- the ILcdDataSource
to be decoded.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 decodeSource(ILcdDataSource aDataSource) throws IOException {
try {
// Perform decoding ...
} catch (RuntimeException e) {
throw new IOException(e);
}
}
ILcdModelDecoder.canDecodeSource(ILcdDataSource)
public List<ILcdDataSource> discoverDataSources(String aSource) throws IOException
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)
.
discoverDataSources
in interface ILcdModelDecoder
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.null
IOException
- if the given source is not a valid LuciadFusion LTS URI, or if something goes wrong connecting to the URI