Class TLcdS57CatalogueModelDecoder

java.lang.Object
com.luciad.format.s57.TLcdS57CatalogueModelDecoder
All Implemented Interfaces:
ILcdMetadataDecoder, ILcdInputStreamFactoryCapable, ILcdDataSourceModelDecoder, ILcdModelDecoder
Direct Known Subclasses:
TLcdS63CatalogueModelDecoder

public class TLcdS57CatalogueModelDecoder extends Object implements ILcdModelDecoder, ILcdDataSourceModelDecoder, ILcdInputStreamFactoryCapable, ILcdMetadataDecoder
Model decoder that can decode ECDIS S-57 catalogues into ILcdModel objects.

Model information

Model organization

  • This model decoder creates a model list per ENC catalogue (.031 file) that is decoded. Each catalogue model list on itself contains another list of model lists, one per level (=navigation purpose). Each of these level model lists contains a model per ENC cell in that level.
    
     TLcdModelList (catalogue) --> TLcdS57CatalogueModelDescriptor
       |
       +-- TLcdModelList (one for each level) --> TLcdS57LevelModelDescriptor
             |
             +-- ILcdModel (one for each ENC cell) --> TLcdS57ModelDescriptor
     
  • The individual ENC cells are decoded using the TLcdS57ModelDecoder. See the documentation of the TLcdS57ModelDecoder for more information on the structure of the individual cell models.

Model descriptor

  • All models returned by this model decoder have a TLcdS57CatalogueModelDescriptor.

Model types

  • All models returned by this model decoder implement ILcd2DBoundsIndexedModel, the catalogue and level model lists as well as the individual cell models.

Domain object types

  • See the documentation of TLcdS57ModelDecoder for more information on domain objects.

Data information

Entry point

  • The catalogue (CATALOG.031 file) is used as the entry point for an individual catalogue.
  • The decoder also supports the simultaneous decoding of multiple catalogues as a single, virtual catalogue. To decode multiple catalogues simultaneously, put the catalogue directories in a common parent directory, and place an empty file, called MULTICATALOG.031, in this parent directory. When decoding this file, the decoder will automatically scan for catalogues in the subdirectories and decode them as one catalogue.

Required files

  • In addition to the cell files, used by the TLcdS57ModelDecoder for decoding of the individual ENC cells, this decoder requires a CATALOG.031 file to be present. The individual ENC cell files should be located relatively to the catalogue file, as specified in the FILE subfield of the CATD fields of the catalogue.
  • To decode multiple catalogues as one virtual catalogue, there should also be a MULTICATALOG.031 file present in the common parent directory of all catalogues

Supported file transfer protocols

  • This model decoder supports any transfer protocol, supported by the ILcdInputStreamFactory that is set on this decoder.

Performance tips

  • When a catalogue is used, the presence of the M_COVR class can have a small impact on the rendering performance. See the performance tips of the TLcdS57ModelDecoder for more information on this topic.
  • The policy to be used to load individual ENC cells can be controlled via the setLoadingPolicy method: it allows to use lazy loading with weak or soft references, necessary when dealing with large catalogues that are too large to load fully into memory. If the decoded models are processed by the TLcdS52ModelListBuilder and all consecutive operations are performed on the S-52 ordered model list (not on the original model list), it is advised to use the LoadingPolicy.WEAK_REFERENCED policy for optimal performance and memory usage.

SENC cache

SENC (System ENC) is a LuciadLightspeed-specific format for representing S-57 data. While S-57 is optimized for exchange purposes, SENC is opimized for optimal performance (decoding and visualization). When a catalogue is decoded for the first time, the decoder will convert the S-57 catalogue into SENC on-the-fly and store the SENC in a local cache folder. The next time the catalogue is decoded, it will be decoded from the SENC cache, rather than the original S-57 source. SENC is typically much faster to load than S-57; the effect of enabling SENC cache will be that the first decoding of an S-57 catalogue will be slightly slower (due to the conversion to SENC), but all subsequent decodings will be significantly faster.

SENC caching is disabled by default and can be enabled via setUseSENCCache(boolean).

Limitations of SENC:

  • When SENC caching is enabled, the object class selection and excluded object class selection are ignored.
  • SENC caching is currently only supported for the out-of-the-box supported product types (ENC and AML).
  • SENC caches are not meant to be shared among decoder instances; each TLcdS57CatalogueModelDecoder instance should have its own SENC cache dir.

SENC cache entries are identified by their source name provided to the decoder; moving a catalogue will result in a cache miss, even if the catalogue has already been opened before on another place.

Supported versions and flavors

  • This model decoder supports all ECDIS catalogues, encoded according to the IHO (International Hydrographic Organization) publication S-57 standard ("IHO Transfer Standard for Digital Hydrographic Data, Special Publication No. 57"). This includes S-63, Inland ECDIS (2.0 to 2.4) and AML data.
  • In case of S-63, a TLcdS63ModelDecoder instance should be provided to the constructor of this model decoder.

Known limitiations and issues

  • All limitations for the TLcdS57ModelDecoder apply to the TLcdCatalogueModelDecoder as well.

Error handling

See TLcdS57UnifiedModelDecoder class javadoc for detail.

Notes on thread safety

  • This model decoder can be used in a multi-threaded environment.
  • Read access to decoded models is thread-safe.

See Also:
  • Field Details

  • Constructor Details

    • TLcdS57CatalogueModelDecoder

      public TLcdS57CatalogueModelDecoder()
      Creates a new TLcdS57CatalogueModelDecoder that will delegate the decoding of S-57 cells to the TLcdS57ModelDecoder.

      The created decoder is not ready to be used: it still needs to be initialized with object and attribute class maps. Alternatively, you can create a ready-to-use decoder via TLcdS57ProductConfiguration.createCatalogueModelDecoder()

    • TLcdS57CatalogueModelDecoder

      public TLcdS57CatalogueModelDecoder(TLcdS57ModelDecoder aS57ModelDecoder)
      Creates a new TLcdS57CatalogueModelDecoder that will delegate the decoding of S-57 cells to the given TLcdS57ModelDecoder.
  • Method Details

    • getS57ModelDecoder

      public TLcdS57ModelDecoder getS57ModelDecoder()
      Returns the S-57 cell model decoder to which this catalogue model decoder delegates.
      Returns:
      the S-57 cell model decoder to which this catalogue model decoder delegates.
    • setInputStreamFactory

      public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
      Sets the factory that will create input streams from which models can be decoded.
      Specified by:
      setInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Parameters:
      aInputStreamFactory - the factory that creates an input stream based on a source name.
      See Also:
    • getInputStreamFactory

      public ILcdInputStreamFactory getInputStreamFactory()
      Returns the factory that will create input streams from which models can be decoded.
      Specified by:
      getInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Returns:
      the factory that creates an input stream based on a source name.
      See Also:
    • setIgnoreInvalidCells

      public void setIgnoreInvalidCells(boolean aIgnoreInvalidCells)
      Specifies whether to ignore invalid cells or not.

      See class javadoc section "Error handling" for details.

      Parameters:
      aIgnoreInvalidCells - whether to ignore invalid cells or not
      See Also:
    • isIgnoreInvalidCells

      public boolean isIgnoreInvalidCells()
      Returns whether to ignore invalid cells or not.
      Returns:
      true if invalid cells have to be ignored, false otherwise.
      See Also:
    • setInvalidCellExceptionHandler

      public void setInvalidCellExceptionHandler(ILcdS57InvalidCellExceptionHandler aHandler)
      Sets the cell exception handler to be used when decoding individual cells. This exception handler will be called whenever a cell could not be decoded correctly.

      See class javadoc section "Error handling" for details.

      Parameters:
      aHandler - the exception handler to be used when decoding individual cells.
      See Also:
    • getInvalidCellExceptionHandler

      public ILcdS57InvalidCellExceptionHandler getInvalidCellExceptionHandler()
      Return the cell exception handler to be used when decoding individual cells.
      See Also:
    • setLoadingPolicy

      public void setLoadingPolicy(TLcdS57CatalogueModelDecoder.LoadingPolicy aLoadingPolicy)
      Sets the loading policy to be used by this model decoder. The default one is LoadingPolicy.STRONG_REFERENCED.
      Parameters:
      aLoadingPolicy - the loading policy to use
      Throws:
      NullPointerException - if the given loading policy is null.
      See Also:
    • getLoadingPolicy

      public TLcdS57CatalogueModelDecoder.LoadingPolicy getLoadingPolicy()
      Returns the loading policy to be used by this model decoder.
      Returns:
      the loading policy to be used by this model decoder.
      See Also:
    • isVerifyChecksum

      public boolean isVerifyChecksum()
      Returns whether to compute the checksum of the ENC cells and verify it with the corresponding checksum in the catalogue.
      Returns:
      whether to verify the ENC cell checksums.
    • setVerifyChecksum

      public void setVerifyChecksum(boolean aVerifyChecksum)
      Sets whether to compute the checksum of the ENC cells and verify it with the corresponding checksum in the catalogue. This feature is disabled by default, and is not supported for S-63 encrypted files.
      Parameters:
      aVerifyChecksum - boolean indicating whether to verify the ENC cell checksums.
    • setSENCCacheDir

      public void setSENCCacheDir(File aSENCCacheDir)
      Sets the SENC cache dir where the converted SENC copies of S-57 cells should be stored. The default location is the .senccache directory in the user's home folder. If the specified directory does not exist yet, it will be automatically created by the decoder.

      ; if multiple decoder instances run simultaneously they should all have their own SENC cache dir.

      Parameters:
      aSENCCacheDir - the SENC cache dir where the converted SENC copies of S-57 cells should be stored.
      See Also:
    • getSENCCacheDir

      public File getSENCCacheDir()
      Returns the SENC cache dir where the converted SENC copies of S-57 cells should be stored.
      Returns:
      the SENC cache dir where the converted SENC copies of S-57 cells should be stored.
      See Also:
    • setUseSENCCache

      public void setUseSENCCache(boolean aUseSENCCache)
      Enables or disables the use of SENC (System ENC) caches. If enabled, each S-57 cell will be converted into SENC format and cached in the SENC cache dir when it is decoded. The next time the S-57 cell is read, the cached SENC copy will be used instead.

      See the class javadoc for more information on SENC and its limitations.

      If SENC caching is enabled, a suitable caching dir should be set as well, see setSENCCacheDir(java.io.File).

      Parameters:
      aUseSENCCache - flag indicating whether to use the SENC cache or not.
      See Also:
    • isUseSENCCache

      public boolean isUseSENCCache()
      Returns true if the SENC cache is being used, false otherwise.
      Returns:
      true if the SENC cache is being used, false otherwise.
      See Also:
    • resetObjectClassSelection

      public void resetObjectClassSelection()
      Resets the list of object classes that is included into decoded models. All object classes will now be included in the models when decoding S-57 files.
      See Also:
    • setObjectClassSelection

      public void setObjectClassSelection(int[] aObjectClasses)
      Sets the list of object classes that is included into decoded models. By default, all object classes are decoded.
      Parameters:
      aObjectClasses - the object classes to be included in the decoded models. They can be listed in any order, and duplicate entries are allowed.
      See Also:
    • resetExcludedObjectClasses

      public void resetExcludedObjectClasses()
      Resets the list of object classes that is excluded from decoded models. No object classes will now be excluded from the models when decoding S-57 files.
      See Also:
    • setExcludedObjectClasses

      public void setExcludedObjectClasses(int[] aExcludedObjectClasses)
      Sets the list of object classes that is excluded from decoded models. By default, no object classes are excluded. This list has precedence over the list of classes that is included, if specified.
      Parameters:
      aExcludedObjectClasses - the object classes to be excluded from the decoded models. They can be listed in any order, and duplicate entries are allowed.
      See Also:
    • setObjectClassMap

      public void setObjectClassMap(TLcdS57ObjectClassMap aObjectClassMap)
      Sets the object class map to be used by this model decoder. The object class map is used for retrieving the definitions of object classes and initializing the decoded S-57 objects with their correct datatype.
      Parameters:
      aObjectClassMap - the object class map to be used by this model decoder.
    • getObjectClassMap

      public TLcdS57ObjectClassMap getObjectClassMap()
      Returns the object class map that is used by this model decoder.
      Returns:
      the object class map that is used by this model decoder.
    • setAttributeClassMap

      public void setAttributeClassMap(TLcdS57AttributeClassMap aAttributeClassMap)
      Sets the attribute class map to be used by this model decoder. The attribute class map is used for retrieving the definitions of attributes and initializing the decoded S-57 objects with their correct datatype.
      Parameters:
      aAttributeClassMap - the attribute class map to be used by this model decoder.
    • getAttributeClassMap

      public TLcdS57AttributeClassMap getAttributeClassMap()
      Returns the attribute class map that is used by this model decoder.
      Returns:
      the attribute class map that is used by this model decoder.
    • canDecodeMetadata

      public boolean canDecodeMetadata(String aSourceName)
      Description copied from interface: ILcdMetadataDecoder
      Tells whether this metadata decoder can likely decode metadata for a given source name.
      Specified by:
      canDecodeMetadata in interface ILcdMetadataDecoder
      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
    • decodeMetadata

      public TLcdISO19115Metadata decodeMetadata(String aSourceName) throws IOException
      Description copied from interface: ILcdMetadataDecoder
      Decodes the metadata from a given source name as an ISO-19115 metadata object.

      Note that even if ILcdMetadataDecoder.canDecodeMetadata(String) returns true, this method may yet not be able to decode the given source name. While returning null is allowed when this decoder couldn't decode the given source name, implementors are advised to throw an error instead.

      Specified by:
      decodeMetadata in interface ILcdMetadataDecoder
      Parameters:
      aSourceName - the source name to decode metadata from
      Returns:
      a metadata object
      Throws:
      IOException - if the metadata cannot be decoded for some reason
    • decodeModelMetadata

      public TLcdModelMetadata decodeModelMetadata(String aSourceName) throws IOException
      Decodes metadata for the specified data source. The resulting TLcdModelMetadata also includes a metadata instance for every individual cell referenced by the catalogue. These metadata instances can be retrieved with TLcdModelMetadata.discoverDataSeries(), without triggering any additional I/O.
      Specified by:
      decodeModelMetadata in interface ILcdModelDecoder
      Parameters:
      aSourceName - the data source for which the model metadata will be decoded.
      Returns:
      the model metadata for the data source, never null.
      Throws:
      IOException - if the metadata cannot be decoded for some reason.
      See Also:
    • canDecodeSource

      public boolean canDecodeSource(ILcdDataSource aDataSource)
      Checks whether this model decoder can decode the data source.

      Return true if:

      • The source is a TLcdS57CatalogueDataSource.
      • It contains at least one base (non-update) cell, either directly or in a catalogue.
      • The cell can be decoded and is an ENC or AML cell.
      Specified by:
      canDecodeSource in interface ILcdModelDecoder
      Parameters:
      aDataSource - the data source
      Returns:
      true if the data source can be decoded, false otherwise
      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:
    • canDecodeSource

      public boolean canDecodeSource(String aSourceName)
      Description copied from interface: ILcdModelDecoder
      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.

      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:
    • 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.
    • decode

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