ArcGIS Runtime SDK for iOS: AGSRouteTask Class Reference
ArcGIS Runtime SDK for iOS  100.5
AGSRouteTask Class Reference

Description

Instances of this class represent a task used to compute routes and turn-by-turn directions. It allows you to find a variety of routes between any given locations - the quickest, shortest, most scenic, and so on. The route returned depends on the impedance chosen by you. For example, if the impedance is time, then the best route is the quickest route. Hence, the best route can be defined as the route that has the lowest impedance.

The task can be created for an ArcGIS Network Analyst service hosted in the cloud on ArcGIS Online or on-premises with ArcGIS Server. The task can also be created for a transportation network dataset stored locally on the device in which case it can used even when the device has no network connectivity.

Since
100
Inheritance diagram for AGSRouteTask:
AGSLoadableRemoteResourceBase AGSLoadableBase <AGSRemoteResource> AGSObject <AGSLoadable>

Instance Methods

(void) - cancelLoad
 
(id< AGSCancelable >) - defaultRouteParametersWithCompletion:
 
(instancetype) - initWithDatabaseName:networkName:
 
(instancetype) - initWithDataset:
 
(instancetype) - initWithFileURLToDatabase:networkName:
 
(instancetype) - initWithURL:
 
(void) - loadWithCompletion:
 
(void) - retryLoadWithCompletion:
 
(id< AGSCancelable >) - routeParametersWithFeatureCollection:completion:
 
(id< AGSCancelable >) - routeParametersWithPortalItem:completion:
 
(AGSRouteTaskInfo *) - routeTaskInfo
 
(id< AGSCancelable >) - solveRouteWithParameters:completion:
 

Class Methods

(id< AGSCancelable >) + routeResultWithFeatureCollection:completion:
 
(id< AGSCancelable >) + routeResultWithPortalItem:completion:
 
(instancetype) + routeTaskWithDatabaseName:networkName:
 
(instancetype) + routeTaskWithDataset:
 
(instancetype) + routeTaskWithFileURLToDatabase:networkName:
 
(instancetype) + routeTaskWithURL:
 

Properties

AGSCredentialcredential
 
NSError * loadError
 
AGSLoadStatus loadStatus
 
AGSRequestConfigurationrequestConfiguration
 
AGSTransportationNetworkDatasettransportationNetworkDataset
 
NSURL * URL
 

Method Documentation

§ cancelLoad()

- (void) cancelLoad
requiredinherited

Cancels loading if it is in progress, otherwise it does nothing. This should be called carefully because other objects could be waiting for loadWithCompletion: or retryLoadWithCompletion: to complete and this will call them all back with the error of NSUserCancelledError

Since
100

§ defaultRouteParametersWithCompletion:()

- (id<AGSCancelable>) defaultRouteParametersWithCompletion: (void(^)(AGSRouteParameters *__nullable routeParams, NSError *__nullable error))  completion

A convenience method to get properly initialized parameters for computing a route. The parameters are initialized with default values based on the routeTaskInfo

Parameters
completionblock that is invoked when the operation completes. The route parameters are populated if the operation succeeds, else the error is populated if the operation fails.
Since
100

§ initWithDatabaseName:networkName:()

- (instancetype) initWithDatabaseName: (NSString *)  databaseName
networkName: (NSString *)  networkName 

Initialize the task with the name of a geodatabase containing a transportation network dataset, and the name of the dataset.

Parameters
databaseNamename of the geodatabase file (within the application bundle or shared documents directory) without the .geodatabase file extension
networkNamename of the transportation network dataset within the geodatabase
Returns
a new route task
Since
100

§ initWithDataset:()

- (instancetype) initWithDataset: (AGSTransportationNetworkDataset *)  dataset

Initialize the task with a reference to the transportation network dataset available for a map.

Parameters
datasettransportation network dataset to use
Returns
a new route task
Since
100
See also
AGSMap::transportationNetworks to get a reference to the transportation network datasets available for a map.

§ initWithFileURLToDatabase:networkName:()

- (instancetype) initWithFileURLToDatabase: (NSURL *)  fileURLToDatabase
networkName: (NSString *)  networkName 

Initialize the task with a path to the geodatabase containing a transportation network dataset, and the name of the transportation network dataset.

Parameters
fileURLToDatabaseURL to the .geodatabase file on disk
networkNamename of the transportation network dataset within the geodatabase
Returns
a new route task
Since
100

§ initWithURL:()

- (instancetype) initWithURL: (NSURL *)  URL

Initialize the task with a URL to a route layer in an ArcGIS Network Analyst service. The service may be hosted in the cloud on ArcGIS Online or on-premises with ArcGIS Server.

Parameters
URLto a route layer in an ArcGIS Network Analyst service. For example, http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/NAServer/Route
Returns
a new route task
Since
100

§ loadWithCompletion:()

- (void) loadWithCompletion: (nullable void(^)(NSError *__nullable error))  completion
requiredinherited

Loads data for the object asynchronously. The completion block is invoked upon completion.

You can call this method any number of times, however only one attempt is made to load the data. If it is already loading, it will just continue to load (i.e. not force a reload). If it has already loaded successfully, the completion block will be invoked right away. If it has already failed to load, the completion block will be invoked right away with error previously encountered. This method supports multiple callers and will call them all back on completion. However, each caller's completion block will be invoked once and only once.

Parameters
completionblock that is invoked when object loads successfully or fails to load. An error is passed to the block if the object fails to load.
Note
The completion block is always invoked on the main thread.
Since
100
See also
- cancelLoad to cancel loading
- retryLoadWithCompletion: to force reload

§ retryLoadWithCompletion:()

- (void) retryLoadWithCompletion: (nullable void(^)(NSError *__nullable error))  completion
requiredinherited

Tries to reload when an object has failed to load. This method should be called judiciously. It should be called when:

  1. you didn't have network connectivity earlier when it failed and you want to retry now that you have connectivity
  2. the server was down earlier when it failed and you want to retry
  3. the request is taking too long and you want to cancel it and retry, in which case you will first call cancelLoad and then this method

If the data hasn't started loading, it will start loading. If it is already loading, it will just continue to load. If it has already loaded successfully, calls back right away. If it has already failed to load, tries again. This method supports multiple callers and will call them all back on completion. However, each caller's completion block will be invoked once and only once.

Parameters
completionblock that is invoked when object loads successfully or fails to load. An error is passed to the block if the object fails to load.
Note
The completion block is always invoked on the main thread.
Since
100

§ routeParametersWithFeatureCollection:completion:()

- (id<AGSCancelable>) routeParametersWithFeatureCollection: (AGSFeatureCollection *)  featureCollection
completion: (void(^)(AGSRouteParameters *__nullable routeParams, NSError *__nullable error))  completion 

A convenience method to get properly initialized parameters for computing a route. The parameters are initialized with default values based on the routeTaskInfo, and every feature in the provided feature collection is added as a stop along the desired route.

Parameters
featureCollectioncontaining the stops
completionblock that is invoked when the operation completes. The route parameters are populated if the operation succeeds, else the error is populated if the operation fails.
Since
100

§ routeParametersWithPortalItem:completion:()

- (id<AGSCancelable>) routeParametersWithPortalItem: (AGSPortalItem *)  portalItem
completion: (void(^)(AGSRouteParameters *__nullable routeParams, NSError *__nullable error))  completion 

A convenience method to get properly initialized parameters for computing a route similar to the one in the portal item. The item's type must be AGSPortalItemTypeFeatureCollection and the item must represent a route layer (i.e the item's typeKeywords must contain "Route Layer"). The parameters are initialized with default values based on the routeTaskInfo, and every feature in the provided feature collection is added as a stop along the desired route.

Parameters
portalItemrepresenting a feature collection that contains stops, route info, and barriers tables. Stops table is required.
completionblock that is invoked when the operation completes. The route parameters are populated if the operation succeeds, else the error is populated if the operation fails.
Since
100.3

§ routeResultWithFeatureCollection:completion:()

+ (id<AGSCancelable>) routeResultWithFeatureCollection: (AGSFeatureCollection *)  featureCollection
completion: (void(^)(AGSRouteResult *__nullable routeResult, NSError *__nullable error))  completion 

Imports a pre-planned route result from a feature collection.

Parameters
featureCollectioncontaining a route result.
completionblock that is invoked when the operation completes. The route result is populated if the operation succeeds, else the error is populated if the operation fails.
Since
100.4

§ routeResultWithPortalItem:completion:()

+ (id<AGSCancelable>) routeResultWithPortalItem: (AGSPortalItem *)  portalItem
completion: (void(^)(AGSRouteResult *__nullable routeResult, NSError *__nullable error))  completion 

Imports a pre-planned route result from a portal item. The item's type must be AGSPortalItemTypeFeatureCollection and the item must represent a route layer (i.e the item's typeKeywords must contain "Route Layer")

Parameters
portalItemrepresenting a feature collection containing a route result.
completionblock that is invoked when the operation completes. The route result is populated if the operation succeeds, else the error is populated if the operation fails.
Since
100.3

§ routeTaskInfo()

- (AGSRouteTaskInfo*) routeTaskInfo

Metadata about the ArcGIS Network Analyst service or transportation network dataset being used by the task

Since
100

§ routeTaskWithDatabaseName:networkName:()

+ (instancetype) routeTaskWithDatabaseName: (NSString *)  databaseName
networkName: (NSString *)  networkName 

Initialize the task with the name of a geodatabase containing a transportation network dataset, and the name of the dataset.

Parameters
databaseNamename of the geodatabase file (within the application bundle or shared documents directory) without the .geodatabase file extension
networkNamename of the transportation network dataset within the geodatabase
Returns
a new route task
Since
100

§ routeTaskWithDataset:()

+ (instancetype) routeTaskWithDataset: (AGSTransportationNetworkDataset *)  dataset

Initialize the task with a reference to the transportation network dataset available for a map.

Parameters
datasettransportation network dataset to use
Returns
a new route task
Since
100
See also
AGSMap::transportationNetworks to get a reference to the transportation network datasets available for a map.

§ routeTaskWithFileURLToDatabase:networkName:()

+ (instancetype) routeTaskWithFileURLToDatabase: (NSURL *)  fileURLToDatabase
networkName: (NSString *)  networkName 

Initialize the task with a path to the geodatabase containing a transportation network dataset, and the name of the transportation network dataset.

Parameters
fileURLToDatabaseURL to the .geodatabase file on disk
networkNamename of the transportation network dataset within the geodatabase
Returns
a new route task
Since
100

§ routeTaskWithURL:()

+ (instancetype) routeTaskWithURL: (NSURL *)  URL

Initialize the task with a URL to a route layer in an ArcGIS Network Analyst service. The service may be hosted in the cloud on ArcGIS Online or on-premises with ArcGIS Server.

Parameters
URLto a route layer in an ArcGIS Network Analyst service. For example, http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/NAServer/Route
Returns
a new route task
Since
100

§ solveRouteWithParameters:completion:()

- (id<AGSCancelable>) solveRouteWithParameters: (AGSRouteParameters *)  routeParameters
completion: (void(^)(AGSRouteResult *__nullable routeResult, NSError *__nullable error))  completion 

Computes routes based on the provided route parameters

Parameters
routeParametersbased on which routes should be computed
completionblock that is invoked when the operation completes. The result is populated if the operation succeeds, else the error is populated if the operation fails.
Since
100

Property Documentation

§ credential

- (AGSCredential*) credential
readwritenonatomicstronginherited

Security credentials to access the remote resource. Only applicable if the resource is secured.

Since
100

§ loadError

- (NSError*) loadError
readnonatomicstronginherited

The error that was encountered during the most recent load operation. Will be nil if the operation succeeded.

Since
100

§ loadStatus

- (AGSLoadStatus) loadStatus
readrequirednonatomicassigninherited

Status of the load operation.

Since
100

§ requestConfiguration

- (AGSRequestConfiguration*) requestConfiguration
readwritenonatomicstronginherited

The AGSRequestConfiguration object which defines the behavior and policies to use when accessing the remote resource. The default will be nil. If it is nil the [AGSRequestConfiguration globalConfiguration] will be used.

Since
100

§ transportationNetworkDataset

- (AGSTransportationNetworkDataset*) transportationNetworkDataset
readnonatomicstrong

The transportation network dataset being used by this task Will be nil if the task is using a service instead of a local geodatabase.

Since
100

§ URL

- (NSURL*) URL
readrequirednonatomicstronginherited

The URL of the remote resource.

Since
100