public abstract class

RouteTask

extends Object
java.lang.Object
   ↳ com.esri.core.tasks.na.RouteTask

Class Overview

Class for creating online and offline RouteTasks. A RouteTask can, among other things, perform point to point routing, reordering of stops to optimality, and generate driving directions.

To create a RouteTask using an online service, use createOnlineRouteTask(String, UserCredentials)
To create a RouteTask using local data, use createLocalRouteTask(String, String)

Summary

Public Methods
static RouteTask createLocalRouteTask(String database, String network)
Create an offline RouteTask using local data.
static RouteTask createOnlineRouteTask(String url, UserCredentials cred)
Create an online RouteTask using an ArcGIS service.
void dispose()
Cleanup any resources that the RouteTask might be holding.
abstract NetworkDescription getNetworkDescription()
Get the NetworkDescription.
abstract RouteParameters retrieveDefaultRouteTaskParameters()
Get the default settings from the RouteTask object.
abstract RouteResult solve(RouteParameters parameters)
Solve a route passing in a parameters object.
Future<RouteResult> solve(RouteParameters parameters, CallbackListener<RouteResult> callback)
Solve a route asynchronously passing in a RouteParameters object.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static RouteTask createLocalRouteTask (String database, String network)

Create an offline RouteTask using local data.

Parameters
database String: The path to the runtime geodatabase e.g. "/mnt/sdcard/ArcGIS/database.geodatabase"
network String: The name of the transportation network e.g. "Routing_ND"
Returns
RouteTask A RouteTask that performs solves using local data.
Throws
Exception
Exception

public static RouteTask createOnlineRouteTask (String url, UserCredentials cred)

Create an online RouteTask using an ArcGIS service.

Parameters
url String: The url of the routing service.
cred UserCredentials: Login credentials for the service. Pass null for an unsecured service.
Returns
RouteTask A RouteTask that performs solves through an online service.
Throws
Exception
Exception

public void dispose ()

Cleanup any resources that the RouteTask might be holding.

This is only applicable for offline routing. A RouteTask that has been disposed should not be used to route again unless it is recreated.

public abstract NetworkDescription getNetworkDescription ()

Get the NetworkDescription. This includes network name, cost attributes, restriction attributes, supported directions styles, and supported directions languages. For a RouteTask using an online service, this will involve a network call.

Returns
NetworkDescription
Throws
Exception

public abstract RouteParameters retrieveDefaultRouteTaskParameters ()

Get the default settings from the RouteTask object. This is the only way to create a RouteParameters object.

It's important to note that a RouteParameters object created from on online RouteTask should not be used in an offline RouteTask and vice versa. Meaning, retrieveDefaultRouteTaskParameters should be called each time a RouteTask is created or recreated.

Calling this method for an online service will involve a network call.

Returns
RouteParameters A RouteParameters object with default settings pulled from the RouteTask.
Throws
Exception
Exception

public abstract RouteResult solve (RouteParameters parameters)

Solve a route passing in a parameters object. This method is executed synchronously.

Parameters
parameters RouteParameters: The RouteParameters object containing the settings for the solve and the inputs (stops, barriers, etc.).
Returns
RouteResult A RouteResult object that contains information such as driving directions, travel time, route shape, and various other attributes.
Throws
Exception
Exception

public Future<RouteResult> solve (RouteParameters parameters, CallbackListener<RouteResult> callback)

Solve a route asynchronously passing in a RouteParameters object. To obtain and populate a parameters object, see retrieveDefaultRouteTaskParameters(). If the solve has not already started execution, it can be cancelled using the cancel method on the Future returned.

Parameters
parameters RouteParameters: The RouteParameters object that contains the settings for the solve and the inputs (stops, barriers, etc.).
callback CallbackListener: A callback that will be used when the solve completes. Override onCallback(Object) to handle a successful solve and onError(Throwable) to handle a solve that fails.
Returns
Future<RouteResult> A Future object that can be used to poll for or cancel the solve operation.