public class TLcdEarthTileRepository extends Object implements ILcdEarthEditableTileSet, ILcdEarthIterableTileSet
ILcdEarthEditableTileSet
which stores tiles in a database on
disk.
A repository consists of:
ROOT_FILENAME
as its main entry point.TLcdModelReferenceEncoder
.
The main entry point of the database is used as the destination file for which the reference is
stored.METADATA_FILENAME
, that describes the contents
of the database. It can be encoded and decoded using TLcdEarthAssetModelCodec
.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: Modifier and Type | Field and Description |
---|---|
static String |
METADATA_FILENAME
Defines the name of the (optional) file which contains the asset metadata of a tile repository.
|
static String |
ROOT_FILENAME
Defines the name of the file which is the main entry point into a tile repository.
|
Constructor and Description |
---|
TLcdEarthTileRepository(String aRepositoryName,
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,
ILcdEarthTileSetCoverageCodec aCoverageCodec,
boolean aReadOnly)
Opens an existing tile repository with the given name.
|
TLcdEarthTileRepository(String aRepositoryName,
ILcdEarthTileSet aTileSet,
ILcdEarthTileSetCoverageCodec aCoverageCodec)
Creates a new tile repository with the given name.
|
Modifier and Type | Method and Description |
---|---|
void |
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() |
ILcdBounds |
getBounds()
Returns the bounds of this tile set, expressed in the model reference of the model that
contains this tile set.
|
int |
getLevelCount()
Returns the number of available detail levels.
|
ILcdModelReference |
getModelReference()
Returns the model reference of the repository or
null if it is unknown. |
String |
getRepositoryName() |
long |
getTileColumnCount(int aLevel)
Returns the number of columns in the tile grid at the given level.
|
Collection<ILcdEarthTileDataCodec> |
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.
|
ILcdEarthTileSetCoverage |
getTileSetCoverage(int aIndex)
Returns the coverage at the specified index.
|
ILcdEarthTileSetCoverage |
getTileSetCoverage(String aCoverageName)
Returns the tileset coverage with the specified name.
|
int |
getTileSetCoverageCount()
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 |
isReadOnly() |
Iterator<ALcdEarthTile> |
iterator(ILcdEarthTileSetCoverage aCoverage,
ILcdGeoReference aGeoReference,
TLcdEarthTileFormat aFormat)
If a
TLcdEarthTileSetIterationException is thrown during the
iteration and its tile is not null it is guaranteed that it contains enough attributes such that
the removeTile(com.luciad.earth.tileset.ALcdEarthTile, java.lang.Object) can still work. |
ALcdEarthTile |
produceTile(ILcdEarthTileSetCoverage aCoverage,
int aLevel,
long aX,
long aY,
ILcdGeoReference aGeoReference,
TLcdEarthTileFormat aFormat,
Object aContext)
Gets a tile from the repository.
|
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.
|
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.
|
ALcdEarthTile |
updateTile(ALcdEarthTile aEarthTile,
Object aContext)
Returns an updated version of the specified tile.
|
void |
updateTile(ALcdEarthTile aTile,
TLcdEarthTileOperationMode aMode,
ILcdEarthTileSetCallback aCallback,
Object aContext)
Produces an updated version of the given tile, if necessary.
|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close
public static final String ROOT_FILENAME
public static final String METADATA_FILENAME
public TLcdEarthTileRepository(String aRepositoryName, ILcdEarthTileSet aTileSet) throws IOException
aRepositoryName
- the name of the repository to openaTileSet
- the tileset that will provide tiles to this repositoryIOException
- if the repository already exists or cannot be created for some other
reasonTLcdEarthRepositoryModelFactory
public TLcdEarthTileRepository(String aRepositoryName, boolean aReadOnly) throws IOException
addTileSetCoverage()
and addTile()
will throw an
exception. The default coverage codec is used.aRepositoryName
- the name of the repository to openaReadOnly
- true if the repository will not be written toIOException
- if the repository cannot be openedTLcdEarthRepositoryModelDecoder
public TLcdEarthTileRepository(String aRepositoryName, ILcdEarthTileSet aTileSet, ILcdEarthTileSetCoverageCodec aCoverageCodec) throws IOException
aRepositoryName
- the name of the repository to openaTileSet
- the tileset that will provide tiles to this repositoryaCoverageCodec
- the codec to use for the tileset coveragesIOException
- if the repository already exists or cannot be created for some other
reasonTLcdEarthRepositoryModelFactory
public TLcdEarthTileRepository(String aRepositoryName, ILcdEarthTileSetCoverageCodec aCoverageCodec, boolean aReadOnly) throws IOException
addTileSetCoverage()
and addTile()
will throw an
exception.aRepositoryName
- the name of the repository to openaCoverageCodec
- the codec to use for the tileset coveragesaReadOnly
- true if the repository will not be written toIOException
- if the repository cannot be openedTLcdEarthRepositoryModelDecoder
public void addTileDataCodec(ILcdEarthTileDataCodec aTileDataCodec)
aTileDataCodec
- the codec to addaddTileDataCodec(String, com.luciad.earth.repository.codec.ILcdEarthTileDataCodec)
public void addTileDataCodec(String aCoverageName, ILcdEarthTileDataCodec aTileDataCodec)
aCoverageName
- the name of the coverage to add the codec foraTileDataCodec
- the codec to addIllegalArgumentException
- if the specified codec is not compatible with the coverage or
previously added codecs for the coveragepublic boolean removeTileDataCodec(ILcdEarthTileDataCodec aTileDataCodec)
aTileDataCodec
- the codec to be removedpublic boolean removeTileDataCodec(String aCoverageName, ILcdEarthTileDataCodec aTileDataCodec)
aCoverageName
- the name of the coverageaTileDataCodec
- the codec to be removedpublic Collection<ILcdEarthTileDataCodec> getTileDataCodecs(String aCoverageName)
aCoverageName
- A coverage name. Must not be null
.ILcdEarthTileDataCodec
public void commit() throws IOException
ILcdEarthEditableTileSet
commit
in interface ILcdEarthEditableTileSet
IOException
- if the commit failspublic void dispose()
ILcdEarthTileSet
dispose
in interface ILcdEarthTileSet
dispose
in interface ILcdDisposable
protected void finalize() throws Throwable
public int getTileSetCoverageCount()
ILcdEarthTileSet
getTileSetCoverageCount
in interface ILcdEarthTileSet
public int getLevelCount()
ILcdEarthTileSet
getLevelCount
in interface ILcdEarthTileSet
public long getTileRowCount(int aLevel)
ILcdEarthTileSet
getTileRowCount
in interface ILcdEarthTileSet
aLevel
- the level to be queriedpublic long getTileColumnCount(int aLevel)
ILcdEarthTileSet
getTileColumnCount
in interface ILcdEarthTileSet
aLevel
- the level to be queriedpublic void produceTile(ILcdEarthTileSetCoverage aCoverage, int aLevel, long aTileX, long aTileY, ILcdGeoReference aGeoReference, TLcdEarthTileFormat aFormat, TLcdEarthTileOperationMode aMode, ILcdEarthTileSetCallback aCallback, Object aContext)
ILcdEarthTileSet
tileAvailable()
method. If the tile cannot be produced for some reason, the method tileNotAvailable()
should be called instead.
If the tileset supports it and aMode
is TLcdEarthTileOperationMode.PREFER_ASYNCHRONOUS
,
the tile request may be executed asynchronously. However, the callback
must be invoked at some point in time, unless the
cancelTile()
method is used to cancel the tile request before it is executed. If
aMode
is TLcdEarthTileOperationMode.FORCE_SYNCHRONOUS
,
the request must be executed synchronously and the callback must be
invoked before produceTile()
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 call tileNotAvailable()
. If the tileset
calls tileAvailable()
, the geo reference of the resulting tile
must be equal to aGeoReference
, 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, use isFormatSupported()
.
If the specified format is not supported, the tileset should call
tileNotAvailable()
.
The context parameter may be used to pass application-specific data into
the tileset. If it is not needed, its value may be null
.
produceTile
in interface ILcdEarthTileSet
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 anypublic ILcdBounds getBounds()
ILcdEarthTileSet
getBounds
in interface ILcdEarthTileSet
getBounds
in interface ILcdBounded
ILcdBounded.getBounds()
public String getRepositoryName()
public boolean isReadOnly()
public boolean containsTileSetCoverage(String aCoverageName)
ILcdEarthTileSet
containsTileSetCoverage
in interface ILcdEarthTileSet
aCoverageName
- the name of the coverage to look forpublic ILcdEarthTileSetCoverage getTileSetCoverage(String aCoverageName)
ILcdEarthTileSet
getTileSetCoverage
in interface ILcdEarthTileSet
aCoverageName
- the name of the coverage to look forpublic void addTileSetCoverage(ILcdEarthTileSetCoverage aCoverage) throws IOException
ILcdEarthEditableTileSet
addTileSetCoverage
in interface ILcdEarthEditableTileSet
aCoverage
- the coverage to be added to the tilesetIOException
- if the coverage cannot be addedpublic void addTileSetCoverage(ILcdEarthTileSetCoverage aCoverage, String aTargetName, ILcdGeoReference aTargetReference) throws IOException
ILcdEarthEditableTileSet
addTileSetCoverage
in interface ILcdEarthEditableTileSet
aCoverage
- the coverage to be added to the tilesetaTargetName
- the name of the new coverageaTargetReference
- the georeference into which the coverage should be encodedIOException
- if the coverage cannot be addedpublic ILcdEarthTileSetCoverage getTileSetCoverage(int aIndex)
ILcdEarthTileSet
getTileSetCoverage
in interface ILcdEarthTileSet
aIndex
- the index of the coverage to returnILcdEarthTileSetCoverage
public void updateTile(ALcdEarthTile aTile, TLcdEarthTileOperationMode aMode, ILcdEarthTileSetCallback aCallback, Object aContext)
ILcdEarthTileSet
updateTile
in interface ILcdEarthTileSet
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 anypublic void cancelTile(int aLevel, long aTileX, long aTileY, ILcdEarthTileSetCoverage aCoverage, ILcdGeoReference aGeoReference, TLcdEarthTileFormat aFormat, ILcdEarthTileSetCallback aCallback, Object aContext)
ILcdEarthTileSet
cancelTile()
is called, the tileset is no longer required
to invoke the ILcdEarthTileSetCallback
for the tile in question.
The tileset is not obligated to honor the cancelTile()
request, but if cancelTile()
is not called, then it
is required to invoke the ILcdEarthTileSetCallback
at some
point.cancelTile
in interface ILcdEarthTileSet
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 anypublic boolean containsTile(ILcdEarthTileSetCoverage aCoverage, int aLevel, long aX, long aY, Object aContext)
ILcdEarthTileSet
containsTile
in interface ILcdEarthTileSet
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 anypublic ALcdEarthTile updateTile(ALcdEarthTile aEarthTile, Object aContext) throws IOException
ILcdEarthTileSet
updateTile
in interface ILcdEarthTileSet
aEarthTile
- the tile to checkaContext
- application-specific data to be used by the tileset, if anyIOException
- if the tile cannot be updatedpublic void addTile(ALcdEarthTile aEarthTile, Object aContext) throws IOException
ILcdEarthEditableTileSet
addTile
in interface ILcdEarthEditableTileSet
aEarthTile
- the tile to be added to the tilesetaContext
- application-specific data to be used by the tileset, if anyIOException
- if the tile cannot be added to the tilesetpublic ALcdEarthTile produceTile(ILcdEarthTileSetCoverage aCoverage, int aLevel, long aX, long aY, ILcdGeoReference aGeoReference, TLcdEarthTileFormat aFormat, Object aContext) throws IOException
ILcdEarthTileSet
produceTile
in interface ILcdEarthTileSet
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 anyIOException
- if the tile cannot be producedpublic boolean isGeoReferenceSupported(ILcdEarthTileSetCoverage aCoverage, ILcdGeoReference aGeoReference)
ILcdEarthTileSet
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.
isGeoReferenceSupported
in interface ILcdEarthTileSet
aCoverage
- the coverage to check foraGeoReference
- the reference to check forpublic boolean isFormatSupported(ILcdEarthTileSetCoverage aCoverage, TLcdEarthTileFormat aFormat)
isFormatSupported
in interface ILcdEarthTileSet
aCoverage
- the coverage to check foraFormat
- the format to check forpublic void removeTileSetCoverage(ILcdEarthTileSetCoverage aCoverage) throws IOException
ILcdEarthEditableTileSet
removeTileSetCoverage
in interface ILcdEarthEditableTileSet
aCoverage
- the coverage to be removedIOException
- if the coverage cannot be removedpublic void removeTile(ALcdEarthTile aTile, Object aContext) throws IOException
ILcdEarthEditableTileSet
removeTile
in interface ILcdEarthEditableTileSet
aTile
- the tile to be removedaContext
- application-specific data to be used by the tileset, if anyIOException
- if the tile cannot be removedpublic Iterator<ALcdEarthTile> iterator(ILcdEarthTileSetCoverage aCoverage, ILcdGeoReference aGeoReference, TLcdEarthTileFormat aFormat)
TLcdEarthTileSetIterationException
is thrown during the
iteration and its tile
is not null
it is guaranteed that it contains enough attributes such that
the removeTile(com.luciad.earth.tileset.ALcdEarthTile, java.lang.Object)
can still work.iterator
in interface ILcdEarthIterableTileSet
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 returnedpublic void setModelReference(ILcdModelReference aModelReference)
bounds
will be initialized to the correct type based on the model
reference (for example TLcdXYBounds
or TLcdLonLatBounds
).aModelReference
- the model referencepublic ILcdModelReference getModelReference()
null
if it is unknown.