public class TLcdS57ModelDecoder extends Object implements ILcdModelDecoder, ILcdMetadataDecoder, ILcdInputStreamFactoryCapable, ILcdCloneable
ILcdModel
objects.
File | Required | Entry point | Description |
---|---|---|---|
*.000 | x | x | The .000 file is the base file for an ENC cell, and should always be present. |
*.001, *.002, ... | Additional .001, .002, ... update files can be provided, but are not mandatory. The model decoder will start with decoding the .000 base file and continue reading the update files in sequential order, until the update chain is broken (for example, a .002 file will only be read if the preceding .000 and .001 files are present). Update files should be present in the same directory as the base file. |
inputStreamFactory
of this decoder.ILcd2DBoundsIndexedModel
.TLcdS57ModelDescriptor
.ILcdS57Object
, which is an extension of the
ILcdShape
interface.ILcdDataObject
. As each S-57
object class is mapped onto one datatype, a single model may contain data objects with different
data types.
Objects with the same object class will have the same datatype and thus properties.ILcdFeatured
. Note that ILcdDataObject
is the preferred way of accessing the contents of an object.
ECDIS geometric primitive | LuciadLightspeed class | LuciadLightspeed geometric primitive interface |
---|---|---|
Point | TLcdS57Point |
ILcdPoint |
Line | TLcdS57Line |
ILcdPolyline |
Area | TLcdS57Area |
ILcdComplexPolygon |
ILcdModelDecoder decoder = new TLcdS57ModelDecoder();
ILcdModel model = decoder.decode("US5WA51M.000");
S-57
standard ("IHO Transfer Standard for Digital
Hydrographic Data, Special Publication
No. 57"). This includes InlandECDIS (2.0 to 2.4) and AML data.TLcdS57CatalogueModelDecoder
.
TLcdS63ModelDecoder
that
is provided in the S-63 component.ILcdMetadataDecoder.MetadataWithSource
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_DISPLAY_NAME |
static String |
DEFAULT_EXTENSION |
Constructor and Description |
---|
TLcdS57ModelDecoder()
Creates a new 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(String aSourceName)
Checks whether this model decoder can decode the specified data source.
|
TLcdS57ModelDecoder |
clone()
Makes
Object.clone() public. |
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.
|
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 input stream factory that is used.
|
TLcdS57ObjectClassMap |
getObjectClassMap()
Returns the object class map that is used by this model decoder.
|
boolean |
isPreprocess()
Returns whether decoded models are preprocessed by the decoder.
|
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 |
setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
Sets the factory that will create input streams from which models can be
decoded.
|
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 |
setPreprocess(boolean aPreprocess)
Sets whether to preprocess the decoded model using the
TLcdS57Preprocessor at the end
of the decoding process. |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
findAndDecodeMetadata
public static final String DEFAULT_DISPLAY_NAME
public static final String DEFAULT_EXTENSION
public TLcdS57ModelDecoder()
public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
setInputStreamFactory
in interface ILcdInputStreamFactoryCapable
aInputStreamFactory
- the factory that creates an input stream
based on a source name.public ILcdInputStreamFactory getInputStreamFactory()
ILcdInputStreamFactoryCapable
getInputStreamFactory
in interface ILcdInputStreamFactoryCapable
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 isPreprocess()
setPreprocess(boolean)
public void setPreprocess(boolean aPreprocess)
TLcdS57Preprocessor
at the end
of the decoding process.
Preprocessing may be costly, but is required for correct, S-52 compliant visualization.
The default value is true
.aPreprocess
- boolean indicating whether to preprocess the decoded model using the
TLcdS57Preprocessor
.isPreprocess()
,
TLcdS57Preprocessor
public String getDisplayName()
ILcdModelDecoder
ILcdModelDecoder
.getDisplayName
in interface ILcdModelDecoder
ILcdModelDecoder
.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 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)
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 reasonTLcdS57UnifiedModelDecoder.decodeMetadata(String)
public TLcdS57ModelDecoder clone()
ILcdCloneable
Makes Object.clone()
public.
java.lang.Object
, it can be implemented like this:
public Object clone() {
try {
return super.clone();
} catch ( CloneNotSupportedException e ) {
// Cannot happen: extends from Object and implements Cloneable (see also Object.clone)
throw new RuntimeException( e );
}
}
clone
in interface ILcdCloneable
clone
in class Object
Object.clone()