-
public class CacheManagerProvides various methods for managing the local filesystem cache of osmdroid tiles: - Dowloading of tiles inside a specified area, - Cleaning of tiles inside a specified area,- Information about cache capacity and current cache usage.
Important note 1: These methods only make sense for a MapView using an OnlineTileSourceBase: bitmap tiles downloaded from urls. Important note 2 - about Bulk Downloading:When using OSM Mapnik tile server as the tile source, take care about OSM Tile usage policy (http://wiki.openstreetmap.org/wiki/Tile_usage_policy). Do not let to end-users the ability to download significant areas of tiles.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceCacheManager.CacheManagerCallbackpublic abstract classCacheManager.CacheManagerDialogpublic classCacheManager.CacheManagerTaskgeneric class for common code related to AsyncTask management- performing an action- within a manager- on a list of tiles (potentially sorted by ascending zoom level)- and with callbacks for task progression
public interfaceCacheManager.CacheManagerActionAction to perform on a tile within a CacheManagerTask
-
Field Summary
Fields Modifier and Type Field Description protected booleanverifyCancel
-
Constructor Summary
Constructors Constructor Description CacheManager(MapView mapView)CacheManager(MapView mapView, IFilesystemCache writer)CacheManager(MapTileProviderBase pTileProvider, IFilesystemCache pWriter, int pMinZoomLevel, int pMaxZoomLevel)See https://github. CacheManager(ITileSource pTileSource, IFilesystemCache pWriter, int pMinZoomLevel, int pMaxZoomLevel)
-
Method Summary
Modifier and Type Method Description booleangetVerifyCancel()voidsetVerifyCancel(boolean state)intgetPendingJobs()static PointgetMapTileFromCoordinates(double aLat, double aLon, int zoom)static GeoPointgetCoordinatesFromMapTile(int x, int y, int zoom)static FilegetFileName(ITileSource tileSource, long pMapTileIndex)booleanloadTile(OnlineTileSourceBase tileSource, long pMapTileIndex)booleanforceLoadTile(OnlineTileSourceBase tileSource, long pMapTileIndex)Actual tile download, regardless of the tile being already present in the cache booleandeleteTile(long pMapTileIndex)booleancheckTile(long pMapTileIndex)booleanisTileToBeDownloaded(ITileSource pTileSource, long pMapTileIndex)"Should we download this tile? static List<Long>getTilesCoverage(BoundingBox pBB, int pZoomMin, int pZoomMax)Computes the theoretical tiles covered by the bounding box static Collection<Long>getTilesCoverage(BoundingBox pBB, int pZoomLevel)Computes the theoretical tiles covered by the bounding box static RectgetTilesRect(BoundingBox pBB, int pZoomLevel)Retrieve upper left and lower right points(exclusive) corresponding to the tiles coverage forthe selected zoom level. static List<Long>getTilesCoverage(ArrayList<GeoPoint> pGeoPoints, int pZoomMin, int pZoomMax)Computes the theoretical tiles covered by the list of points static Collection<Long>getTilesCoverage(ArrayList<GeoPoint> pGeoPoints, int pZoomLevel)Computes the theoretical tiles covered by the list of pointsCalculation done based on http://www.movable-type.co.uk/scripts/latlong. intpossibleTilesInArea(BoundingBox pBB, int pZoomMin, int pZoomMax)intpossibleTilesCovered(ArrayList<GeoPoint> pGeoPoints, int pZoomMin, int pZoomMax)CacheManager.CacheManagerTaskexecute(CacheManager.CacheManagerTask pTask)CacheManager.CacheManagerTaskdownloadAreaAsync(Context ctx, BoundingBox bb, int zoomMin, int zoomMax)Download in background all tiles of the specified area in osmdroid cache. CacheManager.CacheManagerTaskdownloadAreaAsync(Context ctx, ArrayList<GeoPoint> geoPoints, int zoomMin, int zoomMax)Download in background all tiles of the specified area in osmdroid cache. CacheManager.CacheManagerTaskdownloadAreaAsync(Context ctx, BoundingBox bb, int zoomMin, int zoomMax, CacheManager.CacheManagerCallback callback)Download in background all tiles of the specified area in osmdroid cache. CacheManager.CacheManagerTaskdownloadAreaAsync(Context ctx, ArrayList<GeoPoint> geoPoints, int zoomMin, int zoomMax, CacheManager.CacheManagerCallback callback)Download in background all tiles covered by the GePoints list in osmdroid cache. CacheManager.CacheManagerTaskdownloadAreaAsyncNoUI(Context ctx, ArrayList<GeoPoint> geoPoints, int zoomMin, int zoomMax, CacheManager.CacheManagerCallback callback)Download in background all tiles covered by the GeoPoints list in osmdroid cache without a user interface. CacheManager.CacheManagerTaskdownloadAreaAsyncNoUI(Context ctx, BoundingBox bb, int zoomMin, int zoomMax, CacheManager.CacheManagerCallback callback)Download in background all tiles of the specified area in osmdroid cache without a user interface. voidcancelAllJobs()cancels all tasks CacheManager.CacheManagerTaskdownloadAreaAsync(Context ctx, List<Long> pTiles, int zoomMin, int zoomMax)Download in background all tiles of the specified area in osmdroid cache. CacheManager.CacheManagerDialoggetDownloadingDialog(Context pCtx, CacheManager.CacheManagerTask pTask)CacheManager.CacheManagerDialoggetCleaningDialog(Context pCtx, CacheManager.CacheManagerTask pTask)CacheManager.CacheManagerActiongetDownloadingAction(Context pCtx)CacheManager.CacheManagerActiongetCleaningAction()CacheManager.CacheManagerTaskcleanAreaAsync(Context ctx, BoundingBox bb, int zoomMin, int zoomMax)Remove all cached tiles in the specified area. CacheManager.CacheManagerTaskcleanAreaAsync(Context ctx, ArrayList<GeoPoint> geoPoints, int zoomMin, int zoomMax)Remove all cached tiles covered by the GeoPoints list. CacheManager.CacheManagerTaskcleanAreaAsync(Context ctx, List<Long> tiles, int zoomMin, int zoomMax)Remove all cached tiles in the specified area. BoundingBoxextendedBoundsFromGeoPoints(ArrayList<GeoPoint> geoPoints, int minZoomLevel)longcurrentCacheUsage()longcacheCapacity()longdirectorySize(File pDirectory)voidsetTileDownloader(TileDownloader pTileDownloader)-
-
Constructor Detail
-
CacheManager
CacheManager(MapView mapView)
-
CacheManager
CacheManager(MapView mapView, IFilesystemCache writer)
-
CacheManager
CacheManager(MapTileProviderBase pTileProvider, IFilesystemCache pWriter, int pMinZoomLevel, int pMaxZoomLevel)
See https://github.
-
CacheManager
CacheManager(ITileSource pTileSource, IFilesystemCache pWriter, int pMinZoomLevel, int pMaxZoomLevel)
-
-
Method Detail
-
getVerifyCancel
boolean getVerifyCancel()
-
setVerifyCancel
void setVerifyCancel(boolean state)
-
getPendingJobs
int getPendingJobs()
-
getMapTileFromCoordinates
@Deprecated() static Point getMapTileFromCoordinates(double aLat, double aLon, int zoom)
-
getCoordinatesFromMapTile
@Deprecated() static GeoPoint getCoordinatesFromMapTile(int x, int y, int zoom)
-
getFileName
static File getFileName(ITileSource tileSource, long pMapTileIndex)
-
loadTile
boolean loadTile(OnlineTileSourceBase tileSource, long pMapTileIndex)
-
forceLoadTile
boolean forceLoadTile(OnlineTileSourceBase tileSource, long pMapTileIndex)
Actual tile download, regardless of the tile being already present in the cache
-
deleteTile
boolean deleteTile(long pMapTileIndex)
-
checkTile
boolean checkTile(long pMapTileIndex)
-
isTileToBeDownloaded
boolean isTileToBeDownloaded(ITileSource pTileSource, long pMapTileIndex)
"Should we download this tile?", either because it's not cached yet or because it's expired
-
getTilesCoverage
static List<Long> getTilesCoverage(BoundingBox pBB, int pZoomMin, int pZoomMax)
Computes the theoretical tiles covered by the bounding box
-
getTilesCoverage
static Collection<Long> getTilesCoverage(BoundingBox pBB, int pZoomLevel)
Computes the theoretical tiles covered by the bounding box
-
getTilesRect
static Rect getTilesRect(BoundingBox pBB, int pZoomLevel)
Retrieve upper left and lower right points(exclusive) corresponding to the tiles coverage forthe selected zoom level.
- Parameters:
pBB- the given bounding boxpZoomLevel- the given zoom level
-
getTilesCoverage
static List<Long> getTilesCoverage(ArrayList<GeoPoint> pGeoPoints, int pZoomMin, int pZoomMax)
Computes the theoretical tiles covered by the list of points
-
getTilesCoverage
static Collection<Long> getTilesCoverage(ArrayList<GeoPoint> pGeoPoints, int pZoomLevel)
Computes the theoretical tiles covered by the list of pointsCalculation done based on http://www.movable-type.co.uk/scripts/latlong.html
-
possibleTilesInArea
int possibleTilesInArea(BoundingBox pBB, int pZoomMin, int pZoomMax)
-
possibleTilesCovered
int possibleTilesCovered(ArrayList<GeoPoint> pGeoPoints, int pZoomMin, int pZoomMax)
-
execute
CacheManager.CacheManagerTask execute(CacheManager.CacheManagerTask pTask)
-
downloadAreaAsync
CacheManager.CacheManagerTask downloadAreaAsync(Context ctx, BoundingBox bb, int zoomMin, int zoomMax)
Download in background all tiles of the specified area in osmdroid cache.
-
downloadAreaAsync
CacheManager.CacheManagerTask downloadAreaAsync(Context ctx, ArrayList<GeoPoint> geoPoints, int zoomMin, int zoomMax)
Download in background all tiles of the specified area in osmdroid cache.
-
downloadAreaAsync
CacheManager.CacheManagerTask downloadAreaAsync(Context ctx, BoundingBox bb, int zoomMin, int zoomMax, CacheManager.CacheManagerCallback callback)
Download in background all tiles of the specified area in osmdroid cache.
-
downloadAreaAsync
CacheManager.CacheManagerTask downloadAreaAsync(Context ctx, ArrayList<GeoPoint> geoPoints, int zoomMin, int zoomMax, CacheManager.CacheManagerCallback callback)
Download in background all tiles covered by the GePoints list in osmdroid cache.
-
downloadAreaAsyncNoUI
CacheManager.CacheManagerTask downloadAreaAsyncNoUI(Context ctx, ArrayList<GeoPoint> geoPoints, int zoomMin, int zoomMax, CacheManager.CacheManagerCallback callback)
Download in background all tiles covered by the GeoPoints list in osmdroid cache without a user interface.
-
downloadAreaAsyncNoUI
CacheManager.CacheManagerTask downloadAreaAsyncNoUI(Context ctx, BoundingBox bb, int zoomMin, int zoomMax, CacheManager.CacheManagerCallback callback)
Download in background all tiles of the specified area in osmdroid cache without a user interface.
-
cancelAllJobs
void cancelAllJobs()
cancels all tasks
-
downloadAreaAsync
CacheManager.CacheManagerTask downloadAreaAsync(Context ctx, List<Long> pTiles, int zoomMin, int zoomMax)
Download in background all tiles of the specified area in osmdroid cache.
-
getDownloadingDialog
CacheManager.CacheManagerDialog getDownloadingDialog(Context pCtx, CacheManager.CacheManagerTask pTask)
-
getCleaningDialog
CacheManager.CacheManagerDialog getCleaningDialog(Context pCtx, CacheManager.CacheManagerTask pTask)
-
getDownloadingAction
CacheManager.CacheManagerAction getDownloadingAction(Context pCtx)
-
getCleaningAction
CacheManager.CacheManagerAction getCleaningAction()
-
cleanAreaAsync
CacheManager.CacheManagerTask cleanAreaAsync(Context ctx, BoundingBox bb, int zoomMin, int zoomMax)
Remove all cached tiles in the specified area.
-
cleanAreaAsync
CacheManager.CacheManagerTask cleanAreaAsync(Context ctx, ArrayList<GeoPoint> geoPoints, int zoomMin, int zoomMax)
Remove all cached tiles covered by the GeoPoints list.
-
cleanAreaAsync
CacheManager.CacheManagerTask cleanAreaAsync(Context ctx, List<Long> tiles, int zoomMin, int zoomMax)
Remove all cached tiles in the specified area.
-
extendedBoundsFromGeoPoints
BoundingBox extendedBoundsFromGeoPoints(ArrayList<GeoPoint> geoPoints, int minZoomLevel)
-
currentCacheUsage
long currentCacheUsage()
-
cacheCapacity
long cacheCapacity()
-
directorySize
long directorySize(File pDirectory)
-
setTileDownloader
void setTileDownloader(TileDownloader pTileDownloader)
-
-
-
-