public class

ExportTileCacheTask

extends Object
java.lang.Object
   ↳ com.esri.core.tasks.tilecache.ExportTileCacheTask

Class Overview

The class is used to create a local tile cache from a map service supporting the 'exportTiles' operation.

Create an instance of this class by passing in the URL of the map service. If the service requires authentication, also pass in the credentials to use.

To generate the tile cache, use the method generateTileCache(ExportTileCacheParameters, CallbackListener, CallbackListener, String) which will submit the job then download the tile cache to the specified path when complete.

Before generating the tile cache, you have the option of estimating the size of the download for the parameters you have set using estimateTileCacheSize(ExportTileCacheParameters, CallbackListener).

Both methods accept an ExportTileCacheParameters parameter, which can be used to control the extent of the tile cache, the levels included, and the type of cache created (a compact cache or a tile package .tpk file). The fetchMapServiceInfo() method can be used to find out information about the service, for example the full extent.

Summary

Public Constructors
ExportTileCacheTask(String serviceUrl, UserCredentials credentials)
Creates a new tile cache task.
Public Methods
Future<Long> estimateTileCacheSize(ExportTileCacheParameters params, CallbackListener<Long> callback)
This method returns an estimate of the size of the tile cache.
MapServiceInfo fetchMapServiceInfo()
Fetches the MapServiceInfo synchronously from the map service.
Future<MapServiceInfo> fetchMapServiceInfo(CallbackListener<MapServiceInfo> callback)
Fetches the MapServiceInfo asynchronously from the map service.
Future<String> generateTileCache(ExportTileCacheParameters params, CallbackListener<ExportTileCacheStatus> statusCallback, CallbackListener<String> downloadCallback, String tileCachePath)
Submits a tile cache job, polls for status (at a predetermined time) and downloads the completed cache to disk.
void recoverAllJobs(CallbackListener<ExportTileCacheStatus> statusCallback, CallbackListener<String> downloadCallback)
Use this method to recover all incomplete jobs contained in the directory set with setRecoveryDir(String).
void setRecoveryDir(String path)
Sets the location on disk to be used to store recovery information on tasks that have not yet completed.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public ExportTileCacheTask (String serviceUrl, UserCredentials credentials)

Creates a new tile cache task.

Parameters
serviceUrl String: the service url
credentials UserCredentials: the credentials used to access the service, or null if the service does not require authentication

Public Methods

public Future<Long> estimateTileCacheSize (ExportTileCacheParameters params, CallbackListener<Long> callback)

This method returns an estimate of the size of the tile cache. it can take a few minutes to generate, but it has been kept simple (no job ID returned and no check job status) as it is a fairly lightweight method. It returns a long which is the size of the tile cache in bytes.

Parameters
params ExportTileCacheParameters: parameters that will be used to request an offline cache
callback CallbackListener: this will be called with the approximate size of the download in bytes.
Returns
Future<Long> approximate download size in bytes.

public MapServiceInfo fetchMapServiceInfo ()

Fetches the MapServiceInfo synchronously from the map service. Performs a network request on the current thread, so do not call this from the UI thread. The MapServiceInfo provides information on the map service that the tile cache will be requested from. It can be used to determine the desired layers to request.

Returns
MapServiceInfo The MapServiceInfo.
Throws
Exception If unable to complete the request.

public Future<MapServiceInfo> fetchMapServiceInfo (CallbackListener<MapServiceInfo> callback)

Fetches the MapServiceInfo asynchronously from the map service. The MapServiceInfo provides information on the map service that the tile cache will be requested from. It can be used to determine the desired layers to request.

Parameters
callback CallbackListener: The callback that fires when the MapServiceInfo has been fetched or an error occurred.
Returns
Future<MapServiceInfo> A Future that allows cancellation of the async request as well as retrieving the MapServiceInfo result.

public Future<String> generateTileCache (ExportTileCacheParameters params, CallbackListener<ExportTileCacheStatus> statusCallback, CallbackListener<String> downloadCallback, String tileCachePath)

Submits a tile cache job, polls for status (at a predetermined time) and downloads the completed cache to disk. If the thread that calls this terminates, this method can be called again and the job will be resumed from where it left off. Note that for this to work, the params parameter object should be exactly the same as the last time the method was called, with the same area of interest, levels of detail, and createAsTilePackage value.

Parameters
params ExportTileCacheParameters: the parameters defining the tile cache to be generated
statusCallback CallbackListener: a callback called with information about the status of the task
downloadCallback CallbackListener: the callback called when the tile cache is downloaded
tileCachePath String: the path to save the tile cache to
Returns
Future<String> the future provides a means of cancelling the job and also an alternative to the callback for getting the tile cache path

public void recoverAllJobs (CallbackListener<ExportTileCacheStatus> statusCallback, CallbackListener<String> downloadCallback)

Use this method to recover all incomplete jobs contained in the directory set with setRecoveryDir(String). The statusCallbackwill be called at the start of each recovered task and downloadCallbackwill be called at the end of each one. The recovery information will be deleted for each job that completes successfully.

Parameters
statusCallback CallbackListener: called at the start of each recovered job, returns the starting status
downloadCallback CallbackListener: called at the end of each recovered job. Any errors will be reported via this callback.

public void setRecoveryDir (String path)

Sets the location on disk to be used to store recovery information on tasks that have not yet completed.

Parameters
path String: directory to use to save recovery information