Class TLcdEarthMemoryCachingTileSet
- All Implemented Interfaces:
ILcdEarthTileSet
,ILcdBounded
,ILcdDisposable
,AutoCloseable
- Since:
- 9.1
-
Constructor Summary
ConstructorDescriptionTLcdEarthMemoryCachingTileSet
(ILcdEarthTileSet aDelegate, int aNumCachedTiles) Creates a new memory caching tileset with the given parameters. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancelTile
(int aLevel, long aTileX, long aTileY, ILcdEarthTileSetCoverage aCoverage, ILcdGeoReference aGeoReference, TLcdEarthTileFormat aFormat, ILcdEarthTileSetCallback aCallback, Object aContext) This method should be overridden if theproduceTile
and/orupdateTile
is overridden and the new implementation calls the implementation of this class using different parameters than passed to it.void
Clears the tile cache.boolean
containsTile
(ILcdEarthTileSetCoverage aCoverage, int aLevel, long aX, long aY, Object aContext) Returns true if the repository contains the specified tile.void
dispose()
This method releases all resources held by the repository, such as file locks, threads or server connections.int
Returns the maximum number of the cached tiles.getTileFromCache
(ILcdEarthTileSetCoverage aCoverage, int aLevel, long aTileX, long aTileY, ILcdGeoReference aGeoReference, TLcdEarthTileFormat aFormat, Object aContext) Retrieves a tile from the cache.protected boolean
isCacheable
(ALcdEarthTile aTile, Object aContext) Returns whether the tile should be cached or not.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
setCacheSize
(int aSize) Sets the maximum number of cached tiles.void
updateTile
(ALcdEarthTile aTile, TLcdEarthTileOperationMode aMode, ILcdEarthTileSetCallback aCallback, Object aContext) Updates the tile and the version cached in memory.updateTile
(ALcdEarthTile aEarthTile, Object aContext) Updates the tile and the version cached in memory.Methods inherited from class com.luciad.earth.tileset.util.ALcdEarthTileSetWrapper
containsTileSetCoverage, getBounds, getDelegateTileSet, getLevelCount, getTileColumnCount, getTileRowCount, getTileSetCoverage, getTileSetCoverage, getTileSetCoverageCount, isFormatSupported, isGeoReferenceSupported
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.util.ILcdDisposable
close
-
Constructor Details
-
TLcdEarthMemoryCachingTileSet
Creates a new memory caching tileset with the given parameters.- Parameters:
aDelegate
- the delegate that produces the tiles.aNumCachedTiles
- the maximum number of cached tiles.
-
-
Method Details
-
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
- Overrides:
produceTile
in classALcdEarthTileSetWrapper
- 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
-
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
- Overrides:
produceTile
in classALcdEarthTileSetWrapper
- 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
-
getTileFromCache
public ALcdEarthTile getTileFromCache(ILcdEarthTileSetCoverage aCoverage, int aLevel, long aTileX, long aTileY, ILcdGeoReference aGeoReference, TLcdEarthTileFormat aFormat, Object aContext) Retrieves a tile from the cache. No attempt will be made to produce the tile if it is not available in the cache.- Parameters:
aCoverage
- the coverageaLevel
- the tile levelaTileX
- the tile x coordinateaTileY
- the tile y coordinateaGeoReference
- the tile referenceaFormat
- the tile formataContext
- the context- Returns:
- the requested tile or null if it is not present in the cache.
-
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
- Overrides:
containsTile
in classALcdEarthTileSetWrapper
- 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
public void updateTile(ALcdEarthTile aTile, TLcdEarthTileOperationMode aMode, ILcdEarthTileSetCallback aCallback, Object aContext) Updates the tile and the version cached in memory.- Specified by:
updateTile
in interfaceILcdEarthTileSet
- Overrides:
updateTile
in classALcdEarthTileSetWrapper
- 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
-
updateTile
Updates the tile and the version cached in memory.- Specified by:
updateTile
in interfaceILcdEarthTileSet
- Overrides:
updateTile
in classALcdEarthTileSetWrapper
- 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
-
isCacheable
Returns whether the tile should be cached or not. The default implementation always returnstrue
.- Parameters:
aTile
- the tileaContext
- the context of the tile production- Returns:
- true if the given tile should be cached, false otherwise
-
cancelTile
public void cancelTile(int aLevel, long aTileX, long aTileY, ILcdEarthTileSetCoverage aCoverage, ILcdGeoReference aGeoReference, TLcdEarthTileFormat aFormat, ILcdEarthTileSetCallback aCallback, Object aContext) Description copied from class:ALcdEarthTileSetWrapper
This method should be overridden if theproduceTile
and/orupdateTile
is overridden and the new implementation calls the implementation of this class using different parameters than passed to it. If the produceTile is overridden assuper.produceTile( myCoverage, aLevel, aTileX, aTileY, aGeoReference, aFormat, aMode, new MyTileSetCallback( aCallback ), aContext );
this method should be overridden assuper.cancelTile( aLevel, aTileX, aTileY, myCoverage, aGeoReference, aFormat, new MyTileSetCallback( aCallback ), aContext );
whereMyTileSetCallback
instances with the same delegate callback are equal.- Specified by:
cancelTile
in interfaceILcdEarthTileSet
- Overrides:
cancelTile
in classALcdEarthTileSetWrapper
- 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
-
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
- Overrides:
dispose
in classALcdEarthTileSetWrapper
-
clearCache
public void clearCache()Clears the tile cache. -
getCacheSize
public int getCacheSize()Returns the maximum number of the cached tiles.- Returns:
- the size of the cache.
-
setCacheSize
public void setCacheSize(int aSize) Sets the maximum number of cached tiles. If the cache size is decreased some tiles will no longer be cached, otherwise all previously cached tiles will still be cached.- Parameters:
aSize
- the new cache size.
-