Package com.luciad.earth.model
Class TLcdEarthRepositoryModelDecoder
java.lang.Object
com.luciad.earth.model.TLcdEarthRepositoryModelDecoder
- All Implemented Interfaces:
ILcdModelDecoder
@LcdService(service=ILcdModelDecoder.class,
priority=20000)
public class TLcdEarthRepositoryModelDecoder
extends Object
implements ILcdModelDecoder
This model decoder decodes tile repositories.
Input files
File | Required | Entry point | Description |
---|---|---|---|
tilerepository.cfg | x |
x | The root file of an Earth tile repository. |
tilerepository.ref | x |
The model reference of an Earth tile repository. | |
tilerepository_metadata.xml | The asset model of an Earth tile repository that describes its contents. |
Supported file transfer protocols
As random access to the data is required, this decoder only reads from files. So it can for example not read from anInputStream
, from a http connection or from a file inside a
jar file.
Model structure
- All models returned by this model decoder implement
ILcd2DBoundsIndexedModel
.
Model descriptor
- All models returned by this model decoder have an
ILcdEarthAssetBasedModelDescriptor
. - If the repository is opened in
read-write
mode and itsasset model
is changed it can be saved by using the asset model's model encoder (e.g.ILcdModel.getModelEncoder()
).
Model reference
- All models returned by this model decoder have an
ILcdGridReference
or anILcdGeodeticReference
. - This model decoder retrieves its model references using the model reference decoder that is
currently set (a
TLcdModelReferenceDecoder
by default).
Model elements
- Each decoded model contains a
TLcdEarthTileRepository
element.
Sample code
ILcdModelDecoder decoder = new TLcdEarthRepositoryModelDecoder();
ILcdModel model = decoder.decode("mydirectory/tilerepository.cfg");
Thread safety
- The decoded models are thread-safe for read access.
- Since:
- 9.1
- See Also:
-
Constructor Summary
ConstructorDescriptionConstructs a newTLcdEarthTileRepositoryModelDecoder
with the default asset and tile data codecs. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAssetCodec
(ILcdEarthAssetCodec aCodec) Adds the specified asset codec.void
Adds the specified tile data codec for its encoded format.boolean
canDecodeSource
(String aSourceName) Checks whether this model decoder can decode the specified data source.protected TLcdEarthTileRepository
createRepository
(String aRepositoryName, boolean aReadOnly) Creates a repository instance by opening the tile repository with the given name.Creates a new model from the given data source.Returns the current collection of asset codecs.Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder
.Returns the current collection of tile data codecs.boolean
Returns whether the repositories will be opened in read-only mode.boolean
removeAssetCodec
(ILcdEarthAssetCodec aCodec) Removes the specified asset codec.boolean
Removes the specified tile data codec for its encoded format.void
setOpenRepositoriesReadOnly
(boolean aOpenRepositoriesReadOnly) Sets whether the repositories will be opened in read-only mode.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.model.ILcdModelDecoder
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
-
Constructor Details
-
TLcdEarthRepositoryModelDecoder
public TLcdEarthRepositoryModelDecoder()Constructs a newTLcdEarthTileRepositoryModelDecoder
with the default asset and tile data codecs. The repositories will be opened inread-only
mode.
-
-
Method Details
-
isOpenRepositoriesReadOnly
public boolean isOpenRepositoriesReadOnly()Returns whether the repositories will be opened in read-only mode. If this istrue
it will not be possible to edit the decoded repositories (e.g. the methods in theILcdEarthEditableTileSet
interface will not be usable). The default value istrue
.- Returns:
- true if the repositories will be opened in read-only mode, false if they will be opened in read-write mode.
-
setOpenRepositoriesReadOnly
public void setOpenRepositoriesReadOnly(boolean aOpenRepositoriesReadOnly) Sets whether the repositories will be opened in read-only mode.- Parameters:
aOpenRepositoriesReadOnly
-true
if the repositories should be opened in read-only mode,false
if they should be opened in read-write mode.- See Also:
-
addTileDataCodec
Adds the specified tile data codec for its encoded format.- Parameters:
aCodec
- the tile data codec that should be added
-
removeTileDataCodec
Removes the specified tile data codec for its encoded format.- Parameters:
aCodec
- the tile data codec that should be removed- Returns:
- true if a codec was remove; false otherwise
-
getTileDataCodecs
Returns the current collection of tile data codecs.- Returns:
- the current collection of tile data codecs
-
addAssetCodec
Adds the specified asset codec.- Parameters:
aCodec
- the asset codec that should be added
-
removeAssetCodec
Removes the specified asset codec.- Parameters:
aCodec
- the asset codec that should be removed- Returns:
- true if a codec was remove; false otherwise
-
getAssetCodecs
Returns the current collection of asset codecs.- Returns:
- the current collection of asset codecs
-
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
.
-
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:
-
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:
-
createRepository
protected TLcdEarthTileRepository createRepository(String aRepositoryName, boolean aReadOnly) throws IOException Creates a repository instance by opening the tile repository with the given name. The default implementation creates aTLcdEarthTileRepository
instance.- Parameters:
aRepositoryName
- the name of the repository to openaReadOnly
-true
if the repository should be opened in read-only mode,false
if it should be opened in read-write mode- Returns:
- a repository
- Throws:
IOException
- if the repository could not be opened- See Also:
-