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-writemode and itsasset modelis 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
ILcdGridReferenceor anILcdGeodeticReference. - This model decoder retrieves its model references using the model reference decoder that is
currently set (a
TLcdModelReferenceDecoderby default).
Model elements
- Each decoded model contains a
TLcdEarthTileRepositoryelement.
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
ConstructorsConstructorDescriptionConstructs a newTLcdEarthTileRepositoryModelDecoderwith the default asset and tile data codecs. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAssetCodec(ILcdEarthAssetCodec aCodec) Adds the specified asset codec.voidAdds the specified tile data codec for its encoded format.booleancanDecodeSource(String aSourceName) Checks whether this model decoder can decode the specified data source.protected TLcdEarthTileRepositorycreateRepository(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.booleanReturns whether the repositories will be opened in read-only mode.booleanremoveAssetCodec(ILcdEarthAssetCodec aCodec) Removes the specified asset codec.booleanRemoves the specified tile data codec for its encoded format.voidsetOpenRepositoriesReadOnly(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, waitMethods inherited from interface com.luciad.model.ILcdModelDecoder
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
-
Constructor Details
-
TLcdEarthRepositoryModelDecoder
public TLcdEarthRepositoryModelDecoder()Constructs a newTLcdEarthTileRepositoryModelDecoderwith the default asset and tile data codecs. The repositories will be opened inread-onlymode.
-
-
Method Details
-
isOpenRepositoriesReadOnly
public boolean isOpenRepositoriesReadOnly()Returns whether the repositories will be opened in read-only mode. If this istrueit will not be possible to edit the decoded repositories (e.g. the methods in theILcdEarthEditableTileSetinterface 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-trueif the repositories should be opened in read-only mode,falseif 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:ILcdModelDecoderReturns a short, displayable name for the format that is decoded by thisILcdModelDecoder.- Specified by:
getDisplayNamein interfaceILcdModelDecoder- Returns:
- the displayable name of this
ILcdModelDecoder.
-
canDecodeSource
Description copied from interface:ILcdModelDecoderChecks whether this model decoder can decode the specified data source. It is acceptable for this method to returntruefor a source name whiledecodethrows 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:
canDecodeSourcein interfaceILcdModelDecoder- Parameters:
aSourceName- the data source to be verified; typically a file name or a URL.- Returns:
trueif this decoder can likely decode the data specified by the source name,falseotherwise.- See Also:
-
decode
Description copied from interface:ILcdModelDecoderCreates a new model from the given data source.- Specified by:
decodein interfaceILcdModelDecoder- Parameters:
aSourceName- the data source to be decoded; typically a file name or a URL.- Returns:
- A model containing the decoded data. While
nullis 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 aTLcdEarthTileRepositoryinstance.- Parameters:
aRepositoryName- the name of the repository to openaReadOnly-trueif the repository should be opened in read-only mode,falseif it should be opened in read-write mode- Returns:
- a repository
- Throws:
IOException- if the repository could not be opened- See Also:
-