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 String |
cacheDirBase |
static long |
FILE_AGE_ONE_DAY |
static long |
FILE_AGE_ONE_WEEK |
private static Logger |
log |
protected long |
maxCacheFileAge |
protected long |
recheckAfter |
protected Map<TileSource,File> |
sourceCacheDirMap |
private static Charset |
TAGS_CHARSET |
protected static String |
TAGS_FILE_EXT |
headers, listener, timeoutConnect, timeoutRead
Constructor and Description |
---|
OsmFileCacheTileLoader(TileLoaderListener map)
Create a OSMFileCacheTileLoader with system property temp dir.
|
OsmFileCacheTileLoader(TileLoaderListener map,
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. |
String |
getCacheDirBase() |
static File |
getDefaultCacheDir() |
long |
getMaxFileAge() |
protected File |
getSourceCacheDir(TileSource source) |
void |
setCacheMaxFileAge(long maxFileAge)
Sets the maximum age of the local cached tile in the file system.
|
void |
setTileCacheDir(String tileCacheDir) |
loadTileFromOsm, loadTileMetadata, prepareHttpUrlConnection, toString
protected static final String TAGS_FILE_EXT
private static final Charset TAGS_CHARSET
public static final long FILE_AGE_ONE_DAY
public static final long FILE_AGE_ONE_WEEK
protected String cacheDirBase
protected final Map<TileSource,File> sourceCacheDirMap
protected long maxCacheFileAge
protected long recheckAfter
public OsmFileCacheTileLoader(TileLoaderListener map, File cacheDir) throws IOException
map
- the listener checking for tile load events (usually the map for display)cacheDir
- directory to store cached tilesIOException
public OsmFileCacheTileLoader(TileLoaderListener map) throws SecurityException, IOException
map
- the listener checking for tile load events (usually the map for display)SecurityException
IOException
public static File getDefaultCacheDir() throws SecurityException
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 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 String getCacheDirBase()
public void setTileCacheDir(String tileCacheDir)
public void clearCache(TileSource source)
clearCache
in interface CachedTileLoader
public void clearCache(TileSource source, TileClearController controller)
clearCache
in interface CachedTileLoader