Package com.luciad.format.s57
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 theTLcdS57ModelDecoder
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 theTLcdS52ModelListBuilder
and all consecutive operations are performed on the S-52 ordered model list (not on the original model list), it is advised to use theLoadingPolicy.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 viasetUseSENCCache(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.
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 theTLcdCatalogueModelDecoder
as well.
Error handling
SeeTLcdS57UnifiedModelDecoder
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:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
This class is a typesafe enumeration, representing all possible loading policies that can be used when decoding models with this decoder.Nested classes/interfaces inherited from interface com.luciad.format.metadata.model.ILcdMetadataDecoder
ILcdMetadataDecoder.MetadataWithSource
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreates a new TLcdS57CatalogueModelDecoder that will delegate the decoding of S-57 cells to theTLcdS57ModelDecoder
.TLcdS57CatalogueModelDecoder
(TLcdS57ModelDecoder aS57ModelDecoder) Creates a new TLcdS57CatalogueModelDecoder that will delegate the decoding of S-57 cells to the givenTLcdS57ModelDecoder
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canDecodeMetadata
(String aSourceName) Tells whether this metadata decoder can likely decode metadata for a given source name.boolean
canDecodeSource
(ILcdDataSource aDataSource) Checks whether this model decoder can decode the data source.boolean
canDecodeSource
(String aSourceName) Checks whether this model decoder can decode the specified data source.Creates a new model from the given data source.decodeMetadata
(String aSourceName) Decodes the metadata from a given source name as an ISO-19115 metadata object.decodeModelMetadata
(String aSourceName) Decodes metadata for the specified data source.decodeSource
(ILcdDataSource aDataSource) Creates a new model from the given data source.Returns the attribute class map that is used by this model decoder.Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder
.Returns the factory that will create input streams from which models can be decoded.Return the cell exception handler to be used when decoding individual cells.Returns the loading policy to be used by this model decoder.Returns the object class map that is used by this model decoder.Returns the S-57 cell model decoder to which this catalogue model decoder delegates.Returns the SENC cache dir where the converted SENC copies of S-57 cells should be stored.boolean
Returns whether to ignore invalid cells or not.boolean
Returnstrue
if the SENC cache is being used,false
otherwise.boolean
Returns whether to compute the checksum of the ENC cells and verify it with the corresponding checksum in the catalogue.void
Resets the list of object classes that is excluded from decoded models.void
Resets the list of object classes that is included into decoded models.void
setAttributeClassMap
(TLcdS57AttributeClassMap aAttributeClassMap) Sets the attribute class map to be used by this model decoder.void
setExcludedObjectClasses
(int[] aExcludedObjectClasses) Sets the list of object classes that is excluded from decoded models.void
setIgnoreInvalidCells
(boolean aIgnoreInvalidCells) Specifies whether to ignore invalid cells or not.void
setInputStreamFactory
(ILcdInputStreamFactory aInputStreamFactory) Sets the factory that will create input streams from which models can be decoded.void
Sets the cell exception handler to be used when decoding individual cells.void
setLoadingPolicy
(TLcdS57CatalogueModelDecoder.LoadingPolicy aLoadingPolicy) Sets the loading policy to be used by this model decoder.void
setObjectClassMap
(TLcdS57ObjectClassMap aObjectClassMap) Sets the object class map to be used by this model decoder.void
setObjectClassSelection
(int[] aObjectClasses) Sets the list of object classes that is included into decoded models.void
setSENCCacheDir
(File aSENCCacheDir) Sets the SENC cache dir where the converted SENC copies of S-57 cells should be stored.void
setUseSENCCache
(boolean aUseSENCCache) Enables or disables the use of SENC (System ENC) caches.void
setVerifyChecksum
(boolean aVerifyChecksum) Sets whether to compute the checksum of the ENC cells and verify it with the corresponding checksum in the catalogue.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
decodeModelMetadata, discoverDataSources
-
Field Details
-
DEFAULT_DISPLAY_NAME
- See Also:
-
DEFAULT_EXTENSION
- See Also:
-
-
Constructor Details
-
TLcdS57CatalogueModelDecoder
public TLcdS57CatalogueModelDecoder()Creates a new TLcdS57CatalogueModelDecoder that will delegate the decoding of S-57 cells to theTLcdS57ModelDecoder
. 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 viaTLcdS57ProductConfiguration.createCatalogueModelDecoder()
-
TLcdS57CatalogueModelDecoder
Creates a new TLcdS57CatalogueModelDecoder that will delegate the decoding of S-57 cells to the givenTLcdS57ModelDecoder
.
-
-
Method Details
-
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
Sets the factory that will create input streams from which models can be decoded.- Specified by:
setInputStreamFactory
in interfaceILcdInputStreamFactoryCapable
- Parameters:
aInputStreamFactory
- the factory that creates an input stream based on a source name.- See Also:
-
getInputStreamFactory
Returns the factory that will create input streams from which models can be decoded.- Specified by:
getInputStreamFactory
in interfaceILcdInputStreamFactoryCapable
- 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. Seeclass 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
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. Seeclass javadoc
section "Error handling" for details.- Parameters:
aHandler
- the exception handler to be used when decoding individual cells.- See Also:
-
getInvalidCellExceptionHandler
Return the cell exception handler to be used when decoding individual cells.- See Also:
-
setLoadingPolicy
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 isnull
.- See Also:
-
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
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
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, seesetSENCCacheDir(java.io.File)
.- Parameters:
aUseSENCCache
- flag indicating whether to use the SENC cache or not.- See Also:
-
isUseSENCCache
public boolean isUseSENCCache()Returnstrue
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
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
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
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
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
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
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)
returnstrue
, this method may yet not be able to decode the given source name. While returningnull
is allowed when this decoder couldn't decode the given source name, implementors are advised to throw an error instead.- Specified by:
decodeMetadata
in interfaceILcdMetadataDecoder
- 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
Decodes metadata for the specified data source. The resultingTLcdModelMetadata
also includes a metadata instance for every individual cell referenced by the catalogue. These metadata instances can be retrieved withTLcdModelMetadata.discoverDataSeries()
, without triggering any additional I/O.- Specified by:
decodeModelMetadata
in interfaceILcdModelDecoder
- 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
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
orAML
cell.
- Specified by:
canDecodeSource
in interfaceILcdModelDecoder
- Parameters:
aDataSource
- the data source- Returns:
true
if the data source can be decoded,false
otherwise- See Also:
- The source is a
-
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
-
canDecodeSource
Description copied from interface:ILcdModelDecoder
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.
- 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:
-
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
.
-
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:
-