Class TLfnTileStoreModelDecoder
java.lang.Object
com.luciad.fusion.tilestore.model.TLfnTileStoreModelDecoder
- All Implemented Interfaces:
ILcdDataSourceModelDecoder
,ILcdModelDecoder
public class TLfnTileStoreModelDecoder
extends Object
implements ILcdModelDecoder, ILcdDataSourceModelDecoder
Decodes a Tile Store from a URI or directly from an
ALfnTileStore
into a tile set.
A tile set defines a logical group of coverages, identified by their coverage IDs. The Tile Store
model returned by this decoder is initially empty, a selection of coverages needs to be made by
calling ALfnTileStoreModel.setCoverageId(String)
on the Tile Store model. All coverages in the tile set must have equals bounds, structure and
geographic reference.
Input files
The model decoder can recognize different sources:- a
ALfnTileStore
object: a Tile Store model is decoded directly from a Tile Store - a file system path: a Tile Store model is decoded using a file system path as Tile Store home directory.
Note that the file
"tile-store.xml"
is checked for existence. This model decoder never automatically creates an empty Tile Store - a URI: a Tile Store model is decoded using a URI. In case of a URI with scheme
"file"
, the URI is interpreted as Tile Store home. Other URI schemes are interpreted as service URIs and are passed to the client factory for interpretation. The client factory is optional and needs to be specified in the constructor. Typical URI schemes are"http"
and"https"
. When no client factory is specified in the constructor, the only URIs that can be decoded are"file"
URIs, which is often sufficient. - a
TLfnTileStoreDataSource
object: a Tile Store model is decoded directly from a Tile Store, with the specified coverages
Supported file transfer protocols
- This model decoder supports all transfer protocols that are supported by
File
.
Model structure
All models returned by this model decoder extendALfnTileStoreModel
.
-
When decoded with a single coverage ID, the model contains:
- a single element that implements
ILcdEarthTileSet
for raster coverages. - a set of
ILcdShape
elements for vector coverages.
- a single element that implements
-
When decoded without specifying a coverage ID, the model is initially empty, and must be populated by calling
ALfnTileStoreModel#setCoverageIds(String...)
before it can be used. -
It is possible to decode a single model containing multiple coverage IDs, to support the legacy 3D use case where
an image and elevation coverage are modeled as two
ILcdEarthTileSetCoverage
s of a singleILcdEarthTileSet
. In LuciadLightspeed applications, imagery and elevation should always be modeled as two separate models, and you should never decode multiple coverages into a single model.
Model descriptor
- All models returned by this model decoder have either:
TLfnRasterTileStoreModelDescriptor
: for raster coverages.TLfnVectorTileStoreModelDescriptor
: for vector coverages.
Model reference
- All models returned by this model decoder have a
ILcdGridReference
orILcdGeodeticReference
.
Model elements
- A decoded model contains:
-
A single element that implements
ILcdEarthTileSet
for raster coverages. When some conditions are met, the element also extendsALcdImageMosaic
so it can integrate with the imaging API. These conditions are:- A single coverage per model. This condition is virtually always fulfilled. The only exception is the legacy 3D use case of multiple coverages per model.
-
An
ILcdEarthTileDataCodec
exist that has a decodedTLcdEarthTileFormat
withRenderedImage
(or a subclass thereof) as its format class. This condition is fulfilled for all built-in raster tile formats. If you have added any custom tile formats, you're responsible for adding the necessary codecs.
ALcdImageMosaic
and the decoded model does not integrate with the imaging API. - A set of
ILcdShape
elements for vector coverages.
-
A single element that implements
Useful settings
- Tile data codecs: the codecs that are used to decode the tile data from the tile set can be changed.
Additionally the tile sets created for raster coverages also support retrieving the raw tile data by
using a format with
byte[]
as its class and the name of the coverage native format.
Sample code
ILcdModelDecoder decoder = new TLfnTileStoreModelDecoder();
ILcdModel model = decoder.decode("http://sampleservices.luciad.com/lts");
Thread safety
- The decoding of models is thread-safe.
- The decoded models are thread-safe for read access.
Example
Decode a specific coverage from a tile store and visualize it in a Lightspeed layer: //First create the model
//Start by creating a TLcdCoverageDataSource for the coverage
String tileStoreURL = "http://sampleservices.luciad.com/lts";
String coverageID = "92c09725-a9c5-46fb-bffd-d9e23b4abbf2";
TLcdCoverageDataSource dataSource = new TLcdCoverageDataSource(tileStoreURL, coverageID);
//Decode the model by passing the datasource to the model decoder
ILcdModelDecoder decoder =
new TLcdCompositeModelDecoder(TLcdServiceLoader.getInstance(ILcdModelDecoder.class));
ILcdModel model = decoder.decodeSource(dataSource);
//Create a layer for the model with default styling
ILspLayer layer = TLspRasterLayerBuilder.newBuilder()
.model(model)
.build();
//Add the layer to the Lightspeed view (an ILspView)
view.addLayer(layer);
- Since:
- 10.0
- See Also:
-
Constructor Summary
ConstructorDescriptionConstructs a new Tile Store model decoder with a default environment and client factory.TLfnTileStoreModelDecoder
(ALfnEnvironment aEnvironment) Constructs a new Tile Store model decoder without a client factory, which can be used to decodefile
URIs.TLfnTileStoreModelDecoder
(ALfnEnvironment aEnvironment, TLfnClientFactory aClientFactory) Constructs a new Tile Store model decoder.TLfnTileStoreModelDecoder
(ALfnEnvironment aEnvironment, ALfnTileStoreProvider aTileStoreProvider) Constructs a new Tile Store model decoder using a given Tile Store provider for decoding URIs. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addTileDataCodec
(ILcdEarthTileDataCodec aCodec, ELfnDataType aDataType) Adds (registers) a codec.boolean
canDecodeSource
(ILcdDataSource aDataSource) Indicates whether a given source can be decoded as a Tile Store model.boolean
canDecodeSource
(String aSourceName) Indicates whether or not a given source name can be decoded as a Tile Store.boolean
canDecodeTileStore
(String aSourceName) Indicates whether or not a given source name can be decoded as a Tile Store.decode
(ALfnTileStore aTileStore, String aCoverageId) Decodes a model of given a Tile Store and sets the coverage ID on it.Decodes a Tile Store model given a source URI or file path.decodeSource
(ILcdDataSource aDataSource) Decodes a model for a given Tile Store data source.decodeTileStore
(String aSourceName) Decodes a Tile Store from a given source name, throwing an exception in case of failure.discoverDataSources
(String aSource) Discovers all the coverages a given source has to offer and returns them as a list of data sources.Returns"LuciadFusion Tile Store"
as display name.getTileDataCodecs
(ELfnDataType aDataType) Gets the registered tile data codecs.boolean
removeTileDataCodec
(ILcdEarthTileDataCodec aCodec, ELfnDataType aDataType) Removes a tile data codec.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
decodeModelMetadata, decodeModelMetadata
-
Constructor Details
-
TLfnTileStoreModelDecoder
public TLfnTileStoreModelDecoder(ALfnEnvironment aEnvironment, ALfnTileStoreProvider aTileStoreProvider) Constructs a new Tile Store model decoder using a given Tile Store provider for decoding URIs.- Parameters:
aEnvironment
- an environment, must not benull
aTileStoreProvider
- a Tile Store provider, must not benull
-
TLfnTileStoreModelDecoder
Constructs a new Tile Store model decoder. The client factory is needed to decode source names which denote URIs other than files. All URI schemes other thanfile
will be passed to the client factory. The client factory may benull
, but then the use of this model decoder can only be used to:- decode models from source names which denote a file, for example
/mnt/TileStore/tile-store.xml
orfile:///mnt/TileStore/tile-store.xml
. - decode models using
decode(ALfnTileStore, String)
and passing a Tile Store instance directly. Note that there is no 'canDecode' equivalent.
- Parameters:
aEnvironment
- an environment, must not benull
aClientFactory
- a client factory, may benull
- decode models from source names which denote a file, for example
-
TLfnTileStoreModelDecoder
Constructs a new Tile Store model decoder without a client factory, which can be used to decodefile
URIs. This constructor is equivalent toTLfnTileStoreModelDecoder(aEnvironment, null)
. You will not be able to use it to decodehttp
. If you want to decode any- Parameters:
aEnvironment
- an environment, must not benull
- See Also:
-
TLfnTileStoreModelDecoder
public TLfnTileStoreModelDecoder()Constructs a new Tile Store model decoder with a default environment and client factory. Such a model decoder is capable of decodingfile
andhttp
URIs.- Since:
- 2013.1
-
-
Method Details
-
addTileDataCodec
Adds (registers) a codec. The tile data codec will be used when decoding supported tile data of the specified type. The data type should benull
if it is not relevant.- Parameters:
aCodec
- the codec to be addedaDataType
- the data type
-
removeTileDataCodec
Removes a tile data codec.- Parameters:
aCodec
- the codec to be removedaDataType
- the data type ornull
if it is not relevant- Returns:
true
if the codec was removed successfully,false
otherwise
-
getTileDataCodecs
Gets the registered tile data codecs.- Parameters:
aDataType
- the data type ornull
if it is not relevant- Returns:
- an unmodifiable collection of codecs.
-
getDisplayName
Returns"LuciadFusion Tile Store"
as display name.- Specified by:
getDisplayName
in interfaceILcdModelDecoder
- Returns:
"LuciadFusion Tile Store"
as display name
-
canDecodeSource
Indicates whether or not a given source name can be decoded as a Tile Store. This method will returntrue
in any of the following cases:- The source name is a path to a directory where a
tile-store.xml
file exists. - The source name is a path to an existing
tile-store.xml
file. - The source name is a URI with "file" scheme, with a path to either a directory or a
tile-store.xml
file. - The source name is a URI to which the client factory (if any) gives a valid response.
path/to/tile-store.xml
/path/to/tile-store-directory
file:/path/to/tile-store-directory
http://server:8080/LuciadFusion/lts
false
.- Specified by:
canDecodeSource
in interfaceILcdModelDecoder
- Parameters:
aSourceName
- the source name to decode as Tile Store- Returns:
true
if the given source name can be decoded as a Tile Store,false
otherwise- See Also:
- The source name is a path to a directory where a
-
decode
Decodes a Tile Store model given a source URI or file path. The source URI must have scheme"file"
or another scheme that is supported by the client factory. The returned model will have anTLfnTileStoreModelDescriptor
or a subclass thereof. SeeTLfnRasterTileStoreModelDescriptor
andTLfnVectorTileStoreModelDescriptor
for an explanation of the model's structure.- Specified by:
decode
in interfaceILcdModelDecoder
- Parameters:
aSourceName
- the source to decode as Tile Store- Returns:
- a Tile Store model
- Throws:
IOException
- when a Tile Store cannot be decoded from the given source- See Also:
-
decode
Decodes a model of given a Tile Store and sets the coverage ID on it. The returned model will have anTLfnTileStoreModelDescriptor
or a subclass thereof. SeeTLfnRasterTileStoreModelDescriptor
andTLfnVectorTileStoreModelDescriptor
for an explanation of the model's structure.- Parameters:
aTileStore
- the Tile Store to create a model ofaCoverageId
- the coverage ID to set on the model before returning it- Returns:
- a model of the Tile Store
- Throws:
IOException
- when a Tile Store with given coverages cannot be decodedIllegalArgumentException
- if the coverages are not compatibleNullPointerException
- if the given tile store is null- See Also:
-
discoverDataSources
Discovers all the coverages a given source has to offer and returns them as a list of data sources. If the given source is not a valid LuciadFusion LTS URI, this method will throw. You can check beforehand if a source is a valid LTS URI usingcanDecodeSource(String)
.Once you have the list of data sources, you can select and decode them using
decodeSource(com.luciad.model.ILcdDataSource)
.If an
ALfnTileStoreProvider
was set on this decoder, theALfnTileStore
on the returnedTLfnTileStoreDataSource
does not need to be closed. Instead theALfnTileStoreProvider
is responsible for the disposal of the tile store.- Specified by:
discoverDataSources
in interfaceILcdModelDecoder
- Parameters:
aSource
- the source, which must be a valid LuciadFusion LTS URI- Returns:
- a list of all the coverages as data sources, possibly empty but never
null
- Throws:
IOException
- if the given source is not a valid LuciadFusion LTS URI, or if something goes wrong connecting to the URI- Since:
- 2014.0
-
canDecodeSource
Indicates whether a given source can be decoded as a Tile Store model. This method will returntrue
if the data source is aTLfnTileStoreDataSource
.- Specified by:
canDecodeSource
in interfaceILcdModelDecoder
- Parameters:
aDataSource
- the data source to decode- Returns:
true
when the given data source source is Tile Store data source,false
otherwise- Since:
- 11.0
- See Also:
-
decodeSource
Decodes a model for a given Tile Store data source. The returned model will have anTLfnTileStoreModelDescriptor
or a subclass thereof. SeeTLfnRasterTileStoreModelDescriptor
andTLfnVectorTileStoreModelDescriptor
for an explanation of the model's structure.- Specified by:
decodeSource
in interfaceILcdModelDecoder
- Parameters:
aDataSource
- a Tile Store data source- Returns:
- a model containing the coverages specified in the data source
- Throws:
IOException
- if a Tile Store with given coverages cannot be decodedIllegalArgumentException
- if the data source cannot be handled or the coverages are not compatible- Since:
- 11.0
- See Also:
-
canDecodeTileStore
Indicates whether or not a given source name can be decoded as a Tile Store. This method will returntrue
in any of the following cases:- The source name is a path to a directory where a
tile-store.xml
file exists. - The source name is a path to an existing
tile-store.xml
file. - The source name is a URI with "file" scheme, with a path to either a directory or a
tile-store.xml
file. - The source name is a URI to which the client factory (if any) gives a valid response.
path/to/tile-store.xml
/path/to/tile-store-directory
file:/path/to/tile-store-directory
http://server:8080/LuciadFusion/lts
false
.- Parameters:
aSourceName
- the source name to decode as Tile Store- Returns:
true
if the given source name can be decoded as a Tile Store,false
otherwise- Since:
- 2013.1
- The source name is a path to a directory where a
-
decodeTileStore
Decodes a Tile Store from a given source name, throwing an exception in case of failure.
If an
ALfnTileStoreProvider
was set on this decoder, the returnedALfnTileStore
does not need to be closed. Instead theALfnTileStoreProvider
is responsible for closing the tile store.- Parameters:
aSourceName
- the source name to decode as Tile Store- Returns:
- the Tile Store which was decoded from the given source name
- Throws:
IOException
- if no Tile Store could be decoded from the given source name- See Also:
-