Class TLcdCoverageModelDecoder

java.lang.Object
com.luciad.format.coverage.TLcdCoverageModelDecoder
All Implemented Interfaces:
ILcdInputStreamFactoryCapable, ILcdModelDecoder

@LcdService(service=ILcdModelDecoder.class, priority=20000) public final class TLcdCoverageModelDecoder extends Object implements ILcdModelDecoder, ILcdInputStreamFactoryCapable
Model decoder that can decode LuciadFusion coverages of type IMAGE, ELEVATION, and RASTER.

Input files

FileRequiredEntry pointDescription
${name}.xmlXXThe Fusion Coverage description (metadata)
${name}/*.ctrXThe 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 single ILcdModel.

Model descriptor

All models returned by this model decoder have a TLcdCoverageModelDescriptor. 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 using ALcdImage.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 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 environment
      aTileStoreProvider - The tile store provider
      aClientFactory - The client factory
      Since:
      2018.1
  • Method Details

    • getDisplayName

      public String getDisplayName()
      Description copied from interface: ILcdModelDecoder
      Returns a short, displayable name for the format that is decoded by this ILcdModelDecoder.
      Specified by:
      getDisplayName in interface ILcdModelDecoder
      Returns:
      the displayable name of this ILcdModelDecoder.
    • getTransportFactory

      public ILcdTransportFactory getTransportFactory()
      Returns the transport factory that will construct the ILcdTransport used for communicating with Luciad tile server.
      Returns:
      the transport.
      See Also:
    • setTransportFactory

      public void setTransportFactory(ILcdTransportFactory aTransportFactory)
      Sets the transport factory that will construct the ILcdTransport used for communicating with Luciad tile server.

      The default transport factory creates ILcdTransports 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.

      Parameters:
      aTransportFactory - the transport factory, must not be null
    • setInputStreamFactory

      public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
      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 an TLcdFailureCachingInputStreamFactory to this method.

      Specified by:
      setInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Parameters:
      aInputStreamFactory - the input stream factory to be used.
    • getInputStreamFactory

      public ILcdInputStreamFactory getInputStreamFactory()
      Description copied from interface: ILcdInputStreamFactoryCapable
      Returns the input stream factory that is used.
      Specified by:
      getInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Returns:
      the input stream factory that is used.
    • canDecodeSource

      public boolean canDecodeSource(String aSourceName)
      Checks whether this model decoder can decode the specified data source. It is acceptable for this method to return 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
      Specified by:
      canDecodeSource in interface ILcdModelDecoder
      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

      public boolean canDecodeSource(ILcdDataSource aDataSource)
      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 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.

      Specified by:
      canDecodeSource in interface ILcdModelDecoder
      Parameters:
      aDataSource - the ILcdModelSource to be verified.
      Returns:
      true if this decoder can likely decode the data specified by aDataSource, false otherwise.
      See Also:
    • decode

      public ILcdModel decode(String aSource) throws IOException
      Description copied from interface: ILcdModelDecoder
      Creates a new model from the given data source.
      Specified by:
      decode in interface ILcdModelDecoder
      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

      public ILcdModel decodeSource(ILcdDataSource aDataSource) throws IOException
      Description copied from interface: ILcdModelDecoder

      Creates a new model from the given data source.

      By default, this method:

      Specified by:
      decodeSource in interface ILcdModelDecoder
      Parameters:
      aDataSource - the ILcdDataSource 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:
    • discoverDataSources

      public List<ILcdDataSource> discoverDataSources(String aSource) throws IOException
      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 interface ILcdModelDecoder
      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