Package org.mapsforge.map.layer.cache
Class TileStore
- java.lang.Object
-
- org.mapsforge.map.layer.cache.TileStore
-
- All Implemented Interfaces:
TileCache
,ObservableInterface
public class TileStore extends java.lang.Object implements TileCache
A "tilecache" storing map tiles that is prepopulated and never removes any files. This tile store uses the standard TMS directory layout of zoomlevel/y/x . To support a different directory structure override the findFile method.
-
-
Constructor Summary
Constructors Constructor Description TileStore(java.io.File rootDirectory, java.lang.String suffix, org.mapsforge.core.graphics.GraphicFactory graphicFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addObserver(Observer observer)
boolean
containsKey(Job key)
void
destroy()
Destroys this cache.protected java.io.File
findFile(Job key)
org.mapsforge.core.graphics.TileBitmap
get(Job key)
int
getCapacity()
int
getCapacityFirstLevel()
org.mapsforge.core.graphics.TileBitmap
getImmediately(Job key)
Returns tileBitmap only if available at fastest cache in case of multi-layered cache, null otherwise.void
purge()
Purges this cache.void
put(Job key, org.mapsforge.core.graphics.TileBitmap bitmap)
void
removeObserver(Observer observer)
void
setWorkingSet(java.util.Set<Job> key)
Reserves a working set in this cache, for multi-level caches this means bringing the elements in workingSet into the fastest cache.
-
-
-
Constructor Detail
-
TileStore
public TileStore(java.io.File rootDirectory, java.lang.String suffix, org.mapsforge.core.graphics.GraphicFactory graphicFactory)
- Parameters:
rootDirectory
- the directory where cached tiles will be stored.suffix
- the suffix for stored tiles.graphicFactory
- the mapsforge graphic factory to create tile data instances.- Throws:
java.lang.IllegalArgumentException
- if the root directory cannot be a tile store
-
-
Method Detail
-
containsKey
public boolean containsKey(Job key)
- Specified by:
containsKey
in interfaceTileCache
- Returns:
- true if this cache contains an image for the given key, false otherwise.
- See Also:
Map.containsKey(java.lang.Object)
-
destroy
public void destroy()
Description copied from interface:TileCache
Destroys this cache. Applications are expected to call this method when they no longer require the cache. In versions prior to 0.5.1, it was common practice to call this method but continue using the cache, in order to empty it, forcing all tiles to be re-rendered or re-requested from the source. Beginning with 0.5.1,TileCache.purge()
should be used for this purpose. The earlier practice is now discouraged and may lead to unexpected results when used with features introduced in 0.5.1 or later.
-
get
public org.mapsforge.core.graphics.TileBitmap get(Job key)
-
getCapacity
public int getCapacity()
- Specified by:
getCapacity
in interfaceTileCache
- Returns:
- the capacity of this cache.
-
getCapacityFirstLevel
public int getCapacityFirstLevel()
- Specified by:
getCapacityFirstLevel
in interfaceTileCache
- Returns:
- the capacity of the first level of a multi-level cache.
-
getImmediately
public org.mapsforge.core.graphics.TileBitmap getImmediately(Job key)
Description copied from interface:TileCache
Returns tileBitmap only if available at fastest cache in case of multi-layered cache, null otherwise.- Specified by:
getImmediately
in interfaceTileCache
- Returns:
- tileBitmap if available without getting from lower storage levels
-
purge
public void purge()
Description copied from interface:TileCache
Purges this cache. Calls toTileCache.get(Job)
issued after purging will not return any tiles added before the purge operation. Applications should purge the tile cache when map model parameters change, such as the render style for locally rendered tiles, or the source for downloaded tiles. Applications which frequently alternate between a limited number of map model configurations may want to consider using a different cache for each.
-
put
public void put(Job key, org.mapsforge.core.graphics.TileBitmap bitmap)
-
findFile
protected java.io.File findFile(Job key)
-
setWorkingSet
public void setWorkingSet(java.util.Set<Job> key)
Description copied from interface:TileCache
Reserves a working set in this cache, for multi-level caches this means bringing the elements in workingSet into the fastest cache.- Specified by:
setWorkingSet
in interfaceTileCache
-
addObserver
public void addObserver(Observer observer)
- Specified by:
addObserver
in interfaceObservableInterface
-
removeObserver
public void removeObserver(Observer observer)
- Specified by:
removeObserver
in interfaceObservableInterface
-
-