public class OsmFileCacheTileLoader extends OsmTileLoader implements CachedTileLoader
TileLoader
implementation that loads tiles from OSM via HTTP and
saves all loaded files in a directory located in the temporary directory.
If a tile is present in this file cache it will not be loaded from OSM again.Modifier and Type | Class and Description |
---|---|
protected class |
OsmFileCacheTileLoader.FileLoadJob |
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
cacheDirBase |
static long |
FILE_AGE_ONE_DAY |
static long |
FILE_AGE_ONE_WEEK |
protected long |
maxCacheFileAge |
protected long |
recheckAfter |
protected java.util.Map<TileSource,java.io.File> |
sourceCacheDirMap |
headers, listener, timeoutConnect, timeoutRead
Constructor and Description |
---|
OsmFileCacheTileLoader(TileLoaderListener map)
Create a OSMFileCacheTileLoader with system property temp dir.
|
OsmFileCacheTileLoader(TileLoaderListener map,
java.io.File cacheDir)
Create a OSMFileCacheTileLoader with given cache directory.
|
Modifier and Type | Method and Description |
---|---|
void |
clearCache(TileSource source) |
void |
clearCache(TileSource source,
TileClearController controller) |
TileJob |
createTileLoaderJob(Tile tile)
A typical implementation of this function should create and return a
new
TileJob instance that performs the load action. |
java.lang.String |
getCacheDirBase() |
static java.io.File |
getDefaultCacheDir() |
long |
getMaxFileAge() |
protected java.io.File |
getSourceCacheDir(TileSource source) |
void |
setCacheMaxFileAge(long maxFileAge)
Sets the maximum age of the local cached tile in the file system.
|
void |
setTileCacheDir(java.lang.String tileCacheDir) |
loadTileFromOsm, loadTileMetadata, prepareHttpUrlConnection, toString
public static final long FILE_AGE_ONE_DAY
public static final long FILE_AGE_ONE_WEEK
protected java.lang.String cacheDirBase
protected final java.util.Map<TileSource,java.io.File> sourceCacheDirMap
protected long maxCacheFileAge
protected long recheckAfter
public OsmFileCacheTileLoader(TileLoaderListener map, java.io.File cacheDir) throws java.io.IOException
map
- the listener checking for tile load events (usually the map for display)cacheDir
- directory to store cached tilesjava.io.IOException
public OsmFileCacheTileLoader(TileLoaderListener map) throws java.lang.SecurityException, java.io.IOException
map
- the listener checking for tile load events (usually the map for display)java.lang.SecurityException
java.io.IOException
public static java.io.File getDefaultCacheDir() throws java.lang.SecurityException
java.lang.SecurityException
public TileJob createTileLoaderJob(Tile tile)
TileLoader
TileJob
instance that performs the load action.createTileLoaderJob
in interface TileLoader
createTileLoaderJob
in class OsmTileLoader
tile
- the tile to be loadedTileJob
implementation that performs the desired load
action.protected java.io.File getSourceCacheDir(TileSource source)
public long getMaxFileAge()
public void setCacheMaxFileAge(long maxFileAge)
OsmFileCacheTileLoader
will connect to the tile server and check
if a newer tile is available using the mechanism specified for the
selected tile source/server.maxFileAge
- maximum age in millisecondsFILE_AGE_ONE_DAY
,
FILE_AGE_ONE_WEEK
,
TileSource.getTileUpdate()
public java.lang.String getCacheDirBase()
public void setTileCacheDir(java.lang.String tileCacheDir)
public void clearCache(TileSource source)
clearCache
in interface CachedTileLoader
public void clearCache(TileSource source, TileClearController controller)
clearCache
in interface CachedTileLoader