Class TLcdEarthTileRepository
- All Implemented Interfaces:
ILcdEarthEditableTileSet
,ILcdEarthIterableTileSet
,ILcdEarthTileSet
,ILcdBounded
,ILcdDisposable
,AutoCloseable
ILcdEarthEditableTileSet
which stores tiles in a database on
disk.
A repository consists of:
- A database with
ROOT_FILENAME
as its main entry point. - A model reference, as encoded by
TLcdModelReferenceEncoder
. The main entry point of the database is used as the destination file for which the reference is stored. - An optional asset model, stored in
METADATA_FILENAME
, that describes the contents of the database. It can be encoded and decoded usingTLcdEarthAssetModelCodec
.
TLcdEarthRepositoryModelDecoder
and TLcdEarthRepositoryModelFactory
classes are generally preferred over
the constructors of this class for respectively opening and creating a repository. These classes
will also decode or encode the model reference and asset model while the constructors of this
class only open or create the database.
The TLcdEarthTileRepositoryPreprocessor
can be
used to add data to a repository.
Tiles can be produced in any format for which a tile data codec has been registered
(see addTileDataCodec(com.luciad.earth.repository.codec.ILcdEarthTileDataCodec)
). Additionally a format with byte[]
as its class and the
name of the coverage native format is supported.
This class is thread-safe (assuming the added tiledata codecs are thread-safe), except for the
following methods: - Since:
- 8.2
-
Field Summary
-
Constructor Summary
ConstructorDescriptionTLcdEarthTileRepository
(String aRepositoryName, boolean aReadOnly) Opens an existing tile repository with the given name.TLcdEarthTileRepository
(String aRepositoryName, ILcdEarthTileSetCoverageCodec aCoverageCodec, boolean aReadOnly) Opens an existing tile repository with the given name.TLcdEarthTileRepository
(String aRepositoryName, ILcdEarthTileSet aTileSet) Creates a new tile repository with the given name.TLcdEarthTileRepository
(String aRepositoryName, ILcdEarthTileSet aTileSet, ILcdEarthTileSetCoverageCodec aCoverageCodec) Creates a new tile repository with the given name. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addTile
(ALcdEarthTile aEarthTile, Object aContext) Adds a tile to the tileset.void
addTileDataCodec
(ILcdEarthTileDataCodec aTileDataCodec) Adds a tile data codec for all coverages that are supported by the codec.void
addTileDataCodec
(String aCoverageName, ILcdEarthTileDataCodec aTileDataCodec) Adds a data codec to be used for encoding and decoding tiles of the given coverage.void
addTileSetCoverage
(ILcdEarthTileSetCoverage aCoverage) Adds a coverage to the tileset.void
addTileSetCoverage
(ILcdEarthTileSetCoverage aCoverage, String aTargetName, ILcdGeoReference aTargetReference) Adds a coverage to the tileset, overriding the coverage's native georeference and name.void
cancelTile
(int aLevel, long aTileX, long aTileY, ILcdEarthTileSetCoverage aCoverage, ILcdGeoReference aGeoReference, TLcdEarthTileFormat aFormat, ILcdEarthTileSetCallback aCallback, Object aContext) Cancels any pending tile requests for the given parameters.void
commit()
Flushes any pending changes to the tileset.boolean
containsTile
(ILcdEarthTileSetCoverage aCoverage, int aLevel, long aX, long aY, Object aContext) Returns true if the repository contains the specified tile.boolean
containsTileSetCoverage
(String aCoverageName) Returns true if the repository contains a coverage with the specified name.void
dispose()
This method releases all resources held by the repository, such as file locks, threads or server connections.protected void
finalize()
Returns the bounds of this tile set, expressed in the model reference of the model that contains this tile set.int
Returns the number of available detail levels.Returns the model reference of the repository ornull
if it is unknown.long
getTileColumnCount
(int aLevel) Returns the number of columns in the tile grid at the given level.getTileDataCodecs
(String aCoverageName) Returns the tile data codecs for the coverage with the given name.long
getTileRowCount
(int aLevel) Returns the number of rows in the tile grid at the given level.getTileSetCoverage
(int aIndex) Returns the coverage at the specified index.getTileSetCoverage
(String aCoverageName) Returns the tileset coverage with the specified name.int
Returns the number of coverages this tileset contains.boolean
isFormatSupported
(ILcdEarthTileSetCoverage aCoverage, TLcdEarthTileFormat aFormat) The native format of a coverage is generally not supported as this is an encoded format.boolean
isGeoReferenceSupported
(ILcdEarthTileSetCoverage aCoverage, ILcdGeoReference aGeoReference) Returns true if the tileset can produce tiles for the given coverage in the given reference system.boolean
iterator
(ILcdEarthTileSetCoverage aCoverage, ILcdGeoReference aGeoReference, TLcdEarthTileFormat aFormat) If aTLcdEarthTileSetIterationException
is thrown during the iteration and itstile
is notnull
it is guaranteed that it contains enough attributes such that theremoveTile(com.luciad.earth.tileset.ALcdEarthTile, java.lang.Object)
can still work.void
produceTile
(ILcdEarthTileSetCoverage aCoverage, int aLevel, long aTileX, long aTileY, ILcdGeoReference aGeoReference, TLcdEarthTileFormat aFormat, TLcdEarthTileOperationMode aMode, ILcdEarthTileSetCallback aCallback, Object aContext) Produces the requested tile, and invoke the supplied callback when done.produceTile
(ILcdEarthTileSetCoverage aCoverage, int aLevel, long aX, long aY, ILcdGeoReference aGeoReference, TLcdEarthTileFormat aFormat, Object aContext) Gets a tile from the repository.void
removeTile
(ALcdEarthTile aTile, Object aContext) Removes the specified tile from the tileset.boolean
removeTileDataCodec
(ILcdEarthTileDataCodec aTileDataCodec) Removes a tile data codec for all coverages if it is present.boolean
removeTileDataCodec
(String aCoverageName, ILcdEarthTileDataCodec aTileDataCodec) Removes a tile data codec for a single coverage if it is present.void
removeTileSetCoverage
(ILcdEarthTileSetCoverage aCoverage) Removes the specified coverage from the tileset.void
setModelReference
(ILcdModelReference aModelReference) Sets the model reference of the repository.void
updateTile
(ALcdEarthTile aTile, TLcdEarthTileOperationMode aMode, ILcdEarthTileSetCallback aCallback, Object aContext) Produces an updated version of the given tile, if necessary.updateTile
(ALcdEarthTile aEarthTile, Object aContext) Returns an updated version of the specified tile.Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.util.ILcdDisposable
close
-
Field Details
-
ROOT_FILENAME
Defines the name of the file which is the main entry point into a tile repository. This file ("tilerepository.cfg") can be used with model decoders, filename filters, etc.- See Also:
-
METADATA_FILENAME
Defines the name of the (optional) file which contains the asset metadata of a tile repository. These assets describe the contents of the tile repository.- See Also:
-
-
Constructor Details
-
TLcdEarthTileRepository
public TLcdEarthTileRepository(String aRepositoryName, ILcdEarthTileSet aTileSet) throws IOException Creates a new tile repository with the given name. When this method is used, the repository is always opened in read/write mode. This method fails if the repository already exists. The default coverage codec is used.- Parameters:
aRepositoryName
- the name of the repository to openaTileSet
- the tileset that will provide tiles to this repository- Throws:
IOException
- if the repository already exists or cannot be created for some other reason- See Also:
-
TLcdEarthTileRepository
Opens an existing tile repository with the given name. Users can choose whether the repository should be opened in read/write mode or read-only mode. In read-only mode,addTileSetCoverage()
andaddTile()
will throw an exception. The default coverage codec is used.- Parameters:
aRepositoryName
- the name of the repository to openaReadOnly
- true if the repository will not be written to- Throws:
IOException
- if the repository cannot be opened- See Also:
-
TLcdEarthTileRepository
public TLcdEarthTileRepository(String aRepositoryName, ILcdEarthTileSet aTileSet, ILcdEarthTileSetCoverageCodec aCoverageCodec) throws IOException Creates a new tile repository with the given name. When this method is used, the repository is always opened in read/write mode. This method fails if the repository already exists.- Parameters:
aRepositoryName
- the name of the repository to openaTileSet
- the tileset that will provide tiles to this repositoryaCoverageCodec
- the codec to use for the tileset coverages- Throws:
IOException
- if the repository already exists or cannot be created for some other reason- See Also:
-
TLcdEarthTileRepository
public TLcdEarthTileRepository(String aRepositoryName, ILcdEarthTileSetCoverageCodec aCoverageCodec, boolean aReadOnly) throws IOException Opens an existing tile repository with the given name. Users can choose whether the repository should be opened in read/write mode or read-only mode. In read-only mode,addTileSetCoverage()
andaddTile()
will throw an exception.- Parameters:
aRepositoryName
- the name of the repository to openaCoverageCodec
- the codec to use for the tileset coveragesaReadOnly
- true if the repository will not be written to- Throws:
IOException
- if the repository cannot be opened- See Also:
-
-
Method Details
-
addTileDataCodec
Adds a tile data codec for all coverages that are supported by the codec.- Parameters:
aTileDataCodec
- the codec to add- See Also:
-
addTileDataCodec
Adds a data codec to be used for encoding and decoding tiles of the given coverage. Note that the encoding format must be the same for all codecs of a coverage.- Parameters:
aCoverageName
- the name of the coverage to add the codec foraTileDataCodec
- the codec to add- Throws:
IllegalArgumentException
- if the specified codec is not compatible with the coverage or previously added codecs for the coverage
-
removeTileDataCodec
Removes a tile data codec for all coverages if it is present.- Parameters:
aTileDataCodec
- the codec to be removed- Returns:
- true if a codec was removed, false otherwise
-
removeTileDataCodec
Removes a tile data codec for a single coverage if it is present.- Parameters:
aCoverageName
- the name of the coverageaTileDataCodec
- the codec to be removed- Returns:
- true if a codec was removed, false otherwise
-
getTileDataCodecs
Returns the tile data codecs for the coverage with the given name.- Parameters:
aCoverageName
- A coverage name. Must not benull
.- Returns:
- A collection of
ILcdEarthTileDataCodec
-
commit
Description copied from interface:ILcdEarthEditableTileSet
Flushes any pending changes to the tileset.- Specified by:
commit
in interfaceILcdEarthEditableTileSet
- Throws:
IOException
- if the commit fails
-
dispose
public void dispose()Description copied from interface:ILcdEarthTileSet
This method releases all resources held by the repository, such as file locks, threads or server connections.- Specified by:
dispose
in interfaceILcdDisposable
- Specified by:
dispose
in interfaceILcdEarthTileSet
-
finalize
-
getTileSetCoverageCount
public int getTileSetCoverageCount()Description copied from interface:ILcdEarthTileSet
Returns the number of coverages this tileset contains.- Specified by:
getTileSetCoverageCount
in interfaceILcdEarthTileSet
- Returns:
- the number of coverages this tileset contains
-
getLevelCount
public int getLevelCount()Description copied from interface:ILcdEarthTileSet
Returns the number of available detail levels. Level 0 is the coarsest level.- Specified by:
getLevelCount
in interfaceILcdEarthTileSet
- Returns:
- the number of available detail levels
-
getTileRowCount
public long getTileRowCount(int aLevel) Description copied from interface:ILcdEarthTileSet
Returns the number of rows in the tile grid at the given level. Each level should have twice the number of rows of the previous one.- Specified by:
getTileRowCount
in interfaceILcdEarthTileSet
- Parameters:
aLevel
- the level to be queried- Returns:
- the number of tile rows on the specified level
-
getTileColumnCount
public long getTileColumnCount(int aLevel) Description copied from interface:ILcdEarthTileSet
Returns the number of columns in the tile grid at the given level. Each level should have twice the number of columns of the previous one.- Specified by:
getTileColumnCount
in interfaceILcdEarthTileSet
- Parameters:
aLevel
- the level to be queried- Returns:
- the number of tile columns on the specified level
-
produceTile
public void produceTile(ILcdEarthTileSetCoverage aCoverage, int aLevel, long aTileX, long aTileY, ILcdGeoReference aGeoReference, TLcdEarthTileFormat aFormat, TLcdEarthTileOperationMode aMode, ILcdEarthTileSetCallback aCallback, Object aContext) Description copied from interface:ILcdEarthTileSet
Produces the requested tile, and invoke the supplied callback when done. The resulting tile is passed to the call back'stileAvailable()
method. If the tile cannot be produced for some reason, the methodtileNotAvailable()
should be called instead.If the tileset supports it and
aMode
isTLcdEarthTileOperationMode.PREFER_ASYNCHRONOUS
, the tile request may be executed asynchronously. However, the callback must be invoked at some point in time, unless thecancelTile()
method is used to cancel the tile request before it is executed. IfaMode
isTLcdEarthTileOperationMode.FORCE_SYNCHRONOUS
, the request must be executed synchronously and the callback must be invoked beforeproduceTile()
returns.Tiles may be requested in reference systems other than the native geo reference of the underlying data, provided that the
isGeoReferenceSupported()
method returns true for the requested reference. If this is not the case, the tileset should calltileNotAvailable()
. If the tileset callstileAvailable()
, the geo reference of the resulting tile must be equal toaGeoReference
, and the tile's bounds must likewise be expressed in this reference.Similarly, tiles may be requested in different data formats, as described by
TLcdEarthTileFormat
. The format determines the type of the data object that will be contained in the requested tile. To check if a format is supported, useisFormatSupported()
. If the specified format is not supported, the tileset should calltileNotAvailable()
.The context parameter may be used to pass application-specific data into the tileset. If it is not needed, its value may be
null
.- Specified by:
produceTile
in interfaceILcdEarthTileSet
- Parameters:
aCoverage
- the coverage from which the tile is requestedaLevel
- the level from which the tile is requestedaTileX
- the column index of the requested tileaTileY
- the row index of the requested tileaGeoReference
- the reference system in which the tile should be returnedaFormat
- the desired format of the tile's dataaMode
- controls the synchronous or asynchronous behaviour of the tilesetaCallback
- will be invoked when the tile is available to be usedaContext
- application-specific data to be used by the tileset, if any
-
getBounds
Description copied from interface:ILcdEarthTileSet
Returns the bounds of this tile set, expressed in the model reference of the model that contains this tile set.- Specified by:
getBounds
in interfaceILcdBounded
- Specified by:
getBounds
in interfaceILcdEarthTileSet
- Returns:
- the bounds of this tile set
- See Also:
-
getRepositoryName
-
isReadOnly
public boolean isReadOnly() -
containsTileSetCoverage
Description copied from interface:ILcdEarthTileSet
Returns true if the repository contains a coverage with the specified name.- Specified by:
containsTileSetCoverage
in interfaceILcdEarthTileSet
- Parameters:
aCoverageName
- the name of the coverage to look for- Returns:
- true if the repository contains a coverage with the specified name, false otherwise
-
getTileSetCoverage
Description copied from interface:ILcdEarthTileSet
Returns the tileset coverage with the specified name.- Specified by:
getTileSetCoverage
in interfaceILcdEarthTileSet
- Parameters:
aCoverageName
- the name of the coverage to look for- Returns:
- the tileset coverage with the specified name
-
addTileSetCoverage
Description copied from interface:ILcdEarthEditableTileSet
Adds a coverage to the tileset.- Specified by:
addTileSetCoverage
in interfaceILcdEarthEditableTileSet
- Parameters:
aCoverage
- the coverage to be added to the tileset- Throws:
IOException
- if the coverage cannot be added
-
addTileSetCoverage
public void addTileSetCoverage(ILcdEarthTileSetCoverage aCoverage, String aTargetName, ILcdGeoReference aTargetReference) throws IOException Description copied from interface:ILcdEarthEditableTileSet
Adds a coverage to the tileset, overriding the coverage's native georeference and name.- Specified by:
addTileSetCoverage
in interfaceILcdEarthEditableTileSet
- Parameters:
aCoverage
- the coverage to be added to the tilesetaTargetName
- the name of the new coverageaTargetReference
- the georeference into which the coverage should be encoded- Throws:
IOException
- if the coverage cannot be added
-
getTileSetCoverage
Description copied from interface:ILcdEarthTileSet
Returns the coverage at the specified index.- Specified by:
getTileSetCoverage
in interfaceILcdEarthTileSet
- Parameters:
aIndex
- the index of the coverage to return- Returns:
- the requested
ILcdEarthTileSetCoverage
-
updateTile
public void updateTile(ALcdEarthTile aTile, TLcdEarthTileOperationMode aMode, ILcdEarthTileSetCallback aCallback, Object aContext) Description copied from interface:ILcdEarthTileSet
Produces an updated version of the given tile, if necessary. Produces the same tile if the given tile is up to date.- Specified by:
updateTile
in interfaceILcdEarthTileSet
- Parameters:
aTile
- tile to checkaMode
- controls the synchronous or asynchronous behaviour of the tilesetaCallback
- will be invoked when the tile is available to be usedaContext
- application-specific data to be used by the tileset, if any
-
cancelTile
public void cancelTile(int aLevel, long aTileX, long aTileY, ILcdEarthTileSetCoverage aCoverage, ILcdGeoReference aGeoReference, TLcdEarthTileFormat aFormat, ILcdEarthTileSetCallback aCallback, Object aContext) Description copied from interface:ILcdEarthTileSet
Cancels any pending tile requests for the given parameters. This method is only meaningful in tilesets that support the asynchronous operation mode. IfcancelTile()
is called, the tileset is no longer required to invoke theILcdEarthTileSetCallback
for the tile in question. The tileset is not obligated to honor thecancelTile()
request, but ifcancelTile()
is not called, then it is required to invoke theILcdEarthTileSetCallback
at some point.- Specified by:
cancelTile
in interfaceILcdEarthTileSet
- Parameters:
aLevel
- the level from which the tile is requestedaTileX
- the column index of the requested tileaTileY
- the row index of the requested tileaCoverage
- the coverage from which the tile is requestedaGeoReference
- the reference system in which the tile is requestedaFormat
- the format in which the tile is requestedaCallback
- would be invoked when the tile would have been available to be usedaContext
- application-specific data to be used by the tileset, if any
-
containsTile
public boolean containsTile(ILcdEarthTileSetCoverage aCoverage, int aLevel, long aX, long aY, Object aContext) Description copied from interface:ILcdEarthTileSet
Returns true if the repository contains the specified tile.- Specified by:
containsTile
in interfaceILcdEarthTileSet
- Parameters:
aCoverage
- the coverage from which to query a tileaLevel
- the detail level for which to query a tileaX
- the column index at which to query a tileaY
- the row index at which to query a tileaContext
- application-specific data to be used by the tileset, if any- Returns:
- true if the repository contains the requested tile
-
updateTile
Description copied from interface:ILcdEarthTileSet
Returns an updated version of the specified tile.- Specified by:
updateTile
in interfaceILcdEarthTileSet
- Parameters:
aEarthTile
- the tile to checkaContext
- application-specific data to be used by the tileset, if any- Returns:
- the tile itself or a new, updated version
- Throws:
IOException
- if the tile cannot be updated
-
addTile
Description copied from interface:ILcdEarthEditableTileSet
Adds a tile to the tileset.- Specified by:
addTile
in interfaceILcdEarthEditableTileSet
- Parameters:
aEarthTile
- the tile to be added to the tilesetaContext
- application-specific data to be used by the tileset, if any- Throws:
IOException
- if the tile cannot be added to the tileset
-
produceTile
public ALcdEarthTile produceTile(ILcdEarthTileSetCoverage aCoverage, int aLevel, long aX, long aY, ILcdGeoReference aGeoReference, TLcdEarthTileFormat aFormat, Object aContext) throws IOException Description copied from interface:ILcdEarthTileSet
Gets a tile from the repository.- Specified by:
produceTile
in interfaceILcdEarthTileSet
- Parameters:
aCoverage
- the coverage from which to query a tileaLevel
- the detail level for which to query a tileaX
- the column index at which to query a tileaY
- the row index at which to query a tileaGeoReference
- the georeference of the requested tileaFormat
- the format of the requested tileaContext
- application-specific data to be used by the tileset, if any- Returns:
- the requested tile, or null if the repository does not contain this tile
- Throws:
IOException
- if the tile cannot be produced
-
isGeoReferenceSupported
public boolean isGeoReferenceSupported(ILcdEarthTileSetCoverage aCoverage, ILcdGeoReference aGeoReference) Description copied from interface:ILcdEarthTileSet
Returns true if the tileset can produce tiles for the given coverage in the given reference system. Note that any reference other than the native reference may result in reduced performance.This method must always return true for the native reference of the coverage. If it returns true for any other georeference, then the tileset must be able to handle the georeference in question in its
produceTile()
method.- Specified by:
isGeoReferenceSupported
in interfaceILcdEarthTileSet
- Parameters:
aCoverage
- the coverage to check foraGeoReference
- the reference to check for- Returns:
- true if the given coverage can be queried with the given reference
-
isFormatSupported
The native format of a coverage is generally not supported as this is an encoded format.- Specified by:
isFormatSupported
in interfaceILcdEarthTileSet
- Parameters:
aCoverage
- the coverage to check foraFormat
- the format to check for- Returns:
- true if the given coverage can be queried with the given format
-
removeTileSetCoverage
Description copied from interface:ILcdEarthEditableTileSet
Removes the specified coverage from the tileset. If the specified coverage does not exist in this tileset, this method does nothing. If it exists but cannot be removed for some reason, an IOException is thrown.- Specified by:
removeTileSetCoverage
in interfaceILcdEarthEditableTileSet
- Parameters:
aCoverage
- the coverage to be removed- Throws:
IOException
- if the coverage cannot be removed
-
removeTile
Description copied from interface:ILcdEarthEditableTileSet
Removes the specified tile from the tileset. If the specified tile does not exist in this tileset, this method does nothing. If it exists but cannot be removed for some reason, an IOException is thrown.- Specified by:
removeTile
in interfaceILcdEarthEditableTileSet
- Parameters:
aTile
- the tile to be removedaContext
- application-specific data to be used by the tileset, if any- Throws:
IOException
- if the tile cannot be removed
-
iterator
public Iterator<ALcdEarthTile> iterator(ILcdEarthTileSetCoverage aCoverage, ILcdGeoReference aGeoReference, TLcdEarthTileFormat aFormat) If aTLcdEarthTileSetIterationException
is thrown during the iteration and itstile
is notnull
it is guaranteed that it contains enough attributes such that theremoveTile(com.luciad.earth.tileset.ALcdEarthTile, java.lang.Object)
can still work.- Specified by:
iterator
in interfaceILcdEarthIterableTileSet
- Parameters:
aCoverage
- the coverage whose tiles will be iterated overaGeoReference
- the georeference in which the tiles should be returnedaFormat
- the format in which the tiles should be returned- Returns:
- an iterator for the selected coverage.
-
setModelReference
Sets the model reference of the repository. Thebounds
will be initialized to the correct type based on the model reference (for exampleTLcdXYBounds
orTLcdLonLatBounds
).- Parameters:
aModelReference
- the model reference
-
getModelReference
Returns the model reference of the repository ornull
if it is unknown.- Returns:
- the model reference of the repository
-