public class TLcdS57CatalogueModelDecoder extends Object implements ILcdModelDecoder,ILcdDataSourceModelDecoder, ILcdInputStreamFactoryCapable, ILcdMetadataDecoder
ILcdModel
objects.
TLcdModelList (catalogue) --> TLcdS57CatalogueModelDescriptor | +-- TLcdModelList (one for each level) --> TLcdS57LevelModelDescriptor | +-- ILcdModel (one for each ENC cell) --> TLcdS57ModelDescriptor
TLcdS57ModelDecoder
. See the
documentation of the
TLcdS57ModelDecoder
for more information on the structure of the individual cell
models.
TLcdS57CatalogueModelDescriptor
.ILcd2DBoundsIndexedModel
,
the catalogue
and level model lists as well as the individual cell models.TLcdS57ModelDecoder
for more information on domain
objects.
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.
ILcdInputStreamFactory
that
is set on this decoder.TLcdS57ModelDecoder
for more information on this
topic.
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.
setUseSENCCache(boolean)
.
Limitations of SENC:
TLcdS57CatalogueModelDecoder
instance should have its own SENC cache dir.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.TLcdS63ModelDecoder
instance should be provided to the
constructor of this model
decoder.TLcdS57ModelDecoder
apply to the
TLcdCatalogueModelDecoder
as well.TLcdS57UnifiedModelDecoder
class javadoc for detail.
Modifier and Type | Class and Description |
---|---|
static class |
TLcdS57CatalogueModelDecoder.LoadingPolicy
This class is a typesafe enumeration, representing all possible loading
policies that can be used when decoding models with this decoder.
|
ILcdMetadataDecoder.MetadataWithSource
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_DISPLAY_NAME |
static String |
DEFAULT_EXTENSION |
Constructor and Description |
---|
TLcdS57CatalogueModelDecoder()
Creates a new TLcdS57CatalogueModelDecoder that will delegate the decoding
of S-57 cells to the
TLcdS57ModelDecoder . |
TLcdS57CatalogueModelDecoder(TLcdS57ModelDecoder aS57ModelDecoder)
Creates a new TLcdS57CatalogueModelDecoder that will delegate the
decoding of S-57 cells to the given
TLcdS57ModelDecoder . |
Modifier and Type | Method and Description |
---|---|
boolean |
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.
|
ILcdModel |
decode(String aSourceName)
Creates a new model from the given data source.
|
TLcdISO19115Metadata |
decodeMetadata(String aSourceName)
Decodes the metadata from a given source name as an ISO-19115 metadata object.
|
TLcdModelMetadata |
decodeModelMetadata(String aSourceName)
Decodes metadata for the specified data source.
|
ILcdModel |
decodeSource(ILcdDataSource aDataSource)
Creates a new model from the given data source.
|
TLcdS57AttributeClassMap |
getAttributeClassMap()
Returns the attribute class map that is used by this model decoder.
|
String |
getDisplayName()
Returns a short, displayable name for the format that is decoded by this
ILcdModelDecoder . |
ILcdInputStreamFactory |
getInputStreamFactory()
Returns the factory that will create input streams from which models can be
decoded.
|
ILcdS57InvalidCellExceptionHandler |
getInvalidCellExceptionHandler()
Return the cell exception handler to be used when decoding individual cells.
|
TLcdS57CatalogueModelDecoder.LoadingPolicy |
getLoadingPolicy()
Returns the loading policy to be used by this model decoder.
|
TLcdS57ObjectClassMap |
getObjectClassMap()
Returns the object class map that is used by this model decoder.
|
TLcdS57ModelDecoder |
getS57ModelDecoder()
Returns the S-57 cell model decoder to which this catalogue model decoder delegates.
|
File |
getSENCCacheDir()
Returns the SENC cache dir where the converted SENC copies of S-57 cells should be stored.
|
boolean |
isIgnoreInvalidCells()
Returns whether to ignore invalid cells or not.
|
boolean |
isUseSENCCache()
Returns
true if the SENC cache is being used, false otherwise. |
boolean |
isVerifyChecksum()
Returns whether to compute the checksum of the ENC cells and verify it with the corresponding
checksum in the catalogue.
|
void |
resetExcludedObjectClasses()
Resets the list of object classes that is excluded from decoded models.
|
void |
resetObjectClassSelection()
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 |
setInvalidCellExceptionHandler(ILcdS57InvalidCellExceptionHandler aHandler)
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
decodeModelMetadata, discoverDataSources
findAndDecodeMetadata
public static final String DEFAULT_DISPLAY_NAME
public static final String DEFAULT_EXTENSION
public TLcdS57CatalogueModelDecoder()
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()
public TLcdS57CatalogueModelDecoder(TLcdS57ModelDecoder aS57ModelDecoder)
TLcdS57ModelDecoder
.public TLcdS57ModelDecoder getS57ModelDecoder()
public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
setInputStreamFactory
in interface ILcdInputStreamFactoryCapable
aInputStreamFactory
- the factory that creates an input stream
based on a source name.getInputStreamFactory()
public ILcdInputStreamFactory getInputStreamFactory()
getInputStreamFactory
in interface ILcdInputStreamFactoryCapable
setInputStreamFactory(com.luciad.io.ILcdInputStreamFactory)
public void setIgnoreInvalidCells(boolean aIgnoreInvalidCells)
class javadoc
section "Error handling" for details.aIgnoreInvalidCells
- whether to ignore invalid cells or notisIgnoreInvalidCells()
,
setInvalidCellExceptionHandler(com.luciad.format.s57.ILcdS57InvalidCellExceptionHandler)
public boolean isIgnoreInvalidCells()
true
if invalid cells have to be ignored, false
otherwise.setIgnoreInvalidCells(boolean)
public void setInvalidCellExceptionHandler(ILcdS57InvalidCellExceptionHandler aHandler)
class javadoc
section "Error handling" for details.aHandler
- the exception handler to be used when decoding individual cells.getInvalidCellExceptionHandler()
,
ILcdS57InvalidCellExceptionHandler
,
setIgnoreInvalidCells(boolean)
public ILcdS57InvalidCellExceptionHandler getInvalidCellExceptionHandler()
public void setLoadingPolicy(TLcdS57CatalogueModelDecoder.LoadingPolicy aLoadingPolicy)
aLoadingPolicy
- the loading policy to useNullPointerException
- if the given loading policy is null
.TLcdS57CatalogueModelDecoder.LoadingPolicy
,
getLoadingPolicy()
public TLcdS57CatalogueModelDecoder.LoadingPolicy getLoadingPolicy()
setLoadingPolicy(TLcdS57CatalogueModelDecoder.LoadingPolicy)
public boolean isVerifyChecksum()
public void setVerifyChecksum(boolean aVerifyChecksum)
aVerifyChecksum
- boolean indicating whether to verify the ENC cell checksums.public void setSENCCacheDir(File aSENCCacheDir)
.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.
aSENCCacheDir
- the SENC cache dir where the converted SENC copies of S-57 cells should
be
stored.getSENCCacheDir()
,
setUseSENCCache(boolean)
public File getSENCCacheDir()
setSENCCacheDir(File)
,
setUseSENCCache(boolean)
public void setUseSENCCache(boolean aUseSENCCache)
setSENCCacheDir(java.io.File)
.aUseSENCCache
- flag indicating whether to use the SENC cache or not.isUseSENCCache()
,
setSENCCacheDir(File)
public boolean isUseSENCCache()
true
if the SENC cache is being used, false
otherwise.true
if the SENC cache is being used, false
otherwise.setUseSENCCache(boolean)
public void resetObjectClassSelection()
setObjectClassSelection(int[])
public void setObjectClassSelection(int[] aObjectClasses)
aObjectClasses
- the object classes to be included in the decoded
models. They can be listed in any order, and duplicate
entries are allowed.resetObjectClassSelection()
,
setExcludedObjectClasses(int[])
public void resetExcludedObjectClasses()
setExcludedObjectClasses(int[])
public void setExcludedObjectClasses(int[] aExcludedObjectClasses)
aExcludedObjectClasses
- the object classes to be excluded from the
decoded models. They can be listed in any
order, and duplicate entries are allowed.resetExcludedObjectClasses()
,
setObjectClassSelection(int[])
public void setObjectClassMap(TLcdS57ObjectClassMap aObjectClassMap)
aObjectClassMap
- the object class map to be used by this model decoder.public TLcdS57ObjectClassMap getObjectClassMap()
public void setAttributeClassMap(TLcdS57AttributeClassMap aAttributeClassMap)
aAttributeClassMap
- the attribute class map to be used by this model decoder.public TLcdS57AttributeClassMap getAttributeClassMap()
public boolean canDecodeMetadata(String aSourceName)
ILcdMetadataDecoder
true
, it is likely that ILcdMetadataDecoder.decodeMetadata(String)
will return a non-null TLcdISO19115Metadata
object,
but it is not a guarantee. The result is optimistic.
false
, it is guaranteed that ILcdMetadataDecoder.decodeMetadata(String)
will throw an exception or return null
.
canDecodeMetadata
in interface ILcdMetadataDecoder
aSourceName
- the source name to decode metadata fortrue
if this metadata decoder can decode metadata for the given source name, false
otherwisepublic TLcdISO19115Metadata decodeMetadata(String aSourceName) throws IOException
ILcdMetadataDecoder
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.
decodeMetadata
in interface ILcdMetadataDecoder
aSourceName
- the source name to decode metadata fromIOException
- if the metadata cannot be decoded for some reasonpublic TLcdModelMetadata decodeModelMetadata(String aSourceName) throws IOException
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.decodeModelMetadata
in interface ILcdModelDecoder
aSourceName
- the data source for which the model metadata will be decoded.IOException
- if the metadata cannot be decoded for some reason.ILcdModelDecoder.canDecodeSource(String)
public boolean canDecodeSource(ILcdDataSource aDataSource)
Return true
if:
TLcdS57CatalogueDataSource
.ENC
or AML
cell.canDecodeSource
in interface ILcdModelDecoder
aDataSource
- the data sourcetrue
if the data source can be decoded, false
otherwiseILcdModelDecoder.decodeSource(ILcdDataSource)
,
ILcdModelDecoder.decodeModelMetadata(ILcdDataSource)
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 boolean canDecodeSource(String aSourceName)
ILcdModelDecoder
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.
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 String getDisplayName()
ILcdModelDecoder
ILcdModelDecoder
.getDisplayName
in interface ILcdModelDecoder
ILcdModelDecoder
.public ILcdModel decode(String aSourceName) throws IOException
ILcdModelDecoder
decode
in interface ILcdModelDecoder
aSourceName
- 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)