
public class SqlTileWriter extends Object implements IFilesystemCache
IFilesystemCache based on the original TileWriter. It writes tiles to a sqlite database cache.
It supports expiration timestamps if provided by the server from which the tile was downloaded. Trimming
of expired
If the database exceeds Configuration#getInstance()#getTileFileSystemCacheTrimBytes()
cache exceeds 600 Mb then it will be trimmed to 500 Mb by deleting files that expire first.
DatabaseFileArchive,
SqliteArchiveTileWriter| Modifier and Type | Field and Description |
|---|---|
static boolean |
CLEANUP_ON_START
disables cache purge of expired tiled on start up
if this is set to false, the database will only purge tiles if manually called or if
the storage device runs out of space.
|
static String |
COLUMN_EXPIRES |
static String |
DATABASE_FILENAME |
protected SQLiteDatabase |
db |
protected File |
db_file |
(package private) static boolean |
hasInited |
protected long |
lastSizeCheck |
(package private) int |
questimate
a questimated size (average-ish) size of a tile
|
| Constructor and Description |
|---|
SqlTileWriter() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
exists(ITileSource pTileSource,
MapTile pTile)
Returns true if the given tile source and tile coordinates exist in the cache
|
boolean |
exists(String pTileSource,
MapTile pTile)
Returns true if the given tile source and tile coordinates exist in the cache
|
long |
getRowCount(String tileSourceName)
Returns the number of tiles in the cache for the specified tile source name
|
int[] |
importFromFileCache(boolean removeFromFileSystem)
a helper method to import file system stored map tiles into the sql tile cache
on successful import, the tiles are removed from the file system.
|
void |
onDetach()
Used when the map engine is shutdown, use it to perform any clean up activities and to terminate
any background threads
|
boolean |
purgeCache()
purges and deletes everything from the cache database
|
boolean |
purgeCache(String mTileSourceName)
purges and deletes all tiles from the given tile source name from the cache database
|
boolean |
remove(ITileSource pTileSourceInfo,
MapTile pTile)
Removes a specific tile from the cache
|
void |
runCleanupOperation()
this could be a long running operation, don't run on the UI thread unless necessary.
|
boolean |
saveFile(ITileSource pTileSourceInfo,
MapTile pTile,
InputStream pStream)
Save an InputStream as the specified tile in the file system cache for the specified tile
source.
|
public static final String DATABASE_FILENAME
public static final String COLUMN_EXPIRES
public static boolean CLEANUP_ON_START
protected File db_file
protected SQLiteDatabase db
protected long lastSizeCheck
final int questimate
static boolean hasInited
public void runCleanupOperation()
public boolean saveFile(ITileSource pTileSourceInfo, MapTile pTile, InputStream pStream)
IFilesystemCachesaveFile in interface IFilesystemCachepTileSourceInfo - a tile sourcepTile - a tilepStream - an InputStreampublic boolean exists(String pTileSource, MapTile pTile)
pTileSource - pTile - public boolean exists(ITileSource pTileSource, MapTile pTile)
exists in interface IFilesystemCachepTileSource - pTile - public void onDetach()
IFilesystemCacheonDetach in interface IFilesystemCachepublic boolean purgeCache()
public boolean purgeCache(String mTileSourceName)
public int[] importFromFileCache(boolean removeFromFileSystem)
This can take a long time, so consider running this off of the main thread.
public boolean remove(ITileSource pTileSourceInfo, MapTile pTile)
remove in interface IFilesystemCachepTileSourceInfo - pTile - public long getRowCount(String tileSourceName)
tileSourceName -