ArcGIS Runtime SDK for iOS: AGSClosestFacilityTask Class Reference
ArcGIS Runtime SDK for iOS  100.12
AGSClosestFacilityTask Class Reference

Description

A task to find facilities closest to an incident.

Instances of this class represent tasks that can find the closest facilities around any location (incidents) on a network. Finding the closest hospital to an accident, the closest police cars to a crime scene, and the closest store to a customer's address are all examples of closest facility problems. When finding closest facilities, you can specify how many to find and whether the direction of travel is toward or away from them. Once you've found the closest facilities, you can display the best route to or from them, return the travel cost for each route, and display directions to each facility. Additionally, you can specify an impedance cutoff beyond which the task should not search for a facility. For instance, you can set up a closest facility problem to search for hospitals within 15 minutes drive time of the site of an accident. Any hospitals that take longer than 15 minutes to reach will not be included in the results.

The task can be created for an ArcGIS Network Analyst service hosted in the cloud on ArcGIS Online or on-premises with ArcGIS Server.

Since
100.1
License Restrictions:
This feature requires a Analysis extension for production deployment when using a network dataset in a local mobile geodatabase . No license required in Developer mode for testing.
Inheritance diagram for AGSClosestFacilityTask:
AGSLoadableRemoteResourceBase <AGSAPIKeyResource> AGSLoadableBase <AGSRemoteResource> AGSObject <AGSLoadable>

Instance Methods

(void) - cancelLoad
 
(id< AGSCancelable >) - defaultClosestFacilityParametersWithCompletion:
 
(void) - doCancelLoading
 
(void) - doStartLoading:
 
(instancetype) - initWithDatabaseName:networkName:
 
(instancetype) - initWithDataset:
 
(instancetype) - initWithFileURLToDatabase:networkName:
 
(instancetype) - initWithURL:
 
(void) - loadDidFinishWithError:
 
(void) - loadWithCompletion:
 
(void) - onLoadStatusChanged
 
(void) - retryLoadWithCompletion:
 
(id< AGSCancelable >) - solveClosestFacilityWithParameters:completion:
 

Class Methods

(instancetype) + closestFacilityTaskWithDatabaseName:networkName:
 
(instancetype) + closestFacilityTaskWithDataset:
 
(instancetype) + closestFacilityTaskWithFileURLToDatabase:networkName:
 
(instancetype) + closestFacilityTaskWithURL:
 

Properties

NSString * APIKey
 
AGSClosestFacilityTaskInfoclosestFacilityTaskInfo
 
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

◆ closestFacilityTaskWithURL:

+ (instancetype) closestFacilityTaskWithURL: (NSURL *)  URL

Initialize the task with a URL to a closest facility 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 closest facility layer in an ArcGIS Network Analyst service. For example, http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/NAServer//Closest%20Facility
Returns
a new closest facility task
Since
100.1

◆ defaultClosestFacilityParametersWithCompletion:

- (id<AGSCancelable>) defaultClosestFacilityParametersWithCompletion: (void(^)(AGSClosestFacilityParameters *__nullable closestFacilityParameters, NSError *__nullable error))  completion

A convenience method to get properly initialized parameters for finding closest facilities. The parameters are initialized with default values based on the closestFacilityTaskInfo

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

◆ doCancelLoading

- (void) doCancelLoading

Never call this method directly. The framework calls this method on a background thread when cancelLoad (AGSLoadable-p) is called. It is meant to be overriden by subclasses. Subclasses should override this method to cancel loading their data and call loadDidFinishWithError: (AGSLoadableBase(ForSubclassEyesOnly)) at the end passing in an error representing NSUserCancelledError.

Since
100

Provided by category AGSLoadableBase(ForSubclassEyesOnly).

◆ doStartLoading:

- (void) doStartLoading: (BOOL)  retrying

Never call this method directly. The framework calls this method on a background thread when loadWithCompletion: (AGSLoadable-p) or retryLoadWithCompletion: (AGSLoadable-p) is called. It is meant to be overriden by subclasses. Subclasses should override this method to load their data and call loadDidFinishWithError: (AGSLoadableBase(ForSubclassEyesOnly)) upon completion, passing in the error if any.

Parameters
retryingflag that is true if this method was called from retryLoadWithCompletion: (AGSLoadable-p).
Since
100

Provided by category AGSLoadableBase(ForSubclassEyesOnly).

◆ initWithURL:

- (instancetype) initWithURL: (NSURL *)  URL

Initialize the task with a URL to a closest facility 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 closest facility layer in an ArcGIS Network Analyst service. For example, http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/NAServer/Closest%20Facility
Returns
a new closest facility task
Since
100.1

◆ loadDidFinishWithError:

- (void) loadDidFinishWithError: (nullable NSError *)  error

Only subclasses should call this method in doStartLoading: (AGSLoadableBase(ForSubclassEyesOnly)) and doCancelLoading (AGSLoadableBase(ForSubclassEyesOnly)) when done loading or failed to load.

Since
100

Provided by category AGSLoadableBase(ForSubclassEyesOnly).

◆ 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

◆ onLoadStatusChanged

- (void) onLoadStatusChanged

Never call this method directly. The framework calls this method on a background thread when AGSLoadable::loadStatus changes is called. Subclasses can optionally implement this to know when their loading status has changed.

Since
100

Provided by category AGSLoadableBase(ForSubclassEyesOnly).

◆ 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

◆ solveClosestFacilityWithParameters:completion:

- (id<AGSCancelable>) solveClosestFacilityWithParameters: (AGSClosestFacilityParameters *)  closestFacilityParameters
completion: (void(^)(AGSClosestFacilityResult *__nullable closestFacilityResult, NSError *__nullable error))  completion 

Finds closest facilities based on the provided parameters

Parameters
closestFacilityParametersbased on which closest facilities should be found
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.1

Property Documentation

◆ APIKey

- (NSString*) APIKey
readwriterequirednonatomiccopyinherited

The API key to access API key enabled services and resources in ArcGIS Online.

An API key is a unique key used to authorize access to specific services and resources in ArcGIS Online. It is also used to monitor access to those services. An API key is created and managed in the ArcGIS developer dashboard and is tied to a specific ArcGIS account.

In addition to setting an API key at a global level for your application using the AGSArcGISRuntimeEnvironment::APIKey property, you can set an AGSAPIKeyResource::APIKey property on any ArcGIS Runtime class that implements AGSAPIKeyResource. When you set an individual AGSAPIKeyResource::APIKey property on an AGSAPIKeyResource it will override the default key at the global level (on the AGSArcGISRuntimeEnvironment::APIKey property, in other words), enabling more granular usage telemetry and management for ArcGIS Online resources used by your app. Classes that expose an API key property by implementing AGSAPIKeyResource include:

◆ closestFacilityTaskInfo

- (AGSClosestFacilityTaskInfo*) closestFacilityTaskInfo
readnonatomicstrong

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

Since
100.1

◆ 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.2

◆ URL

- (NSURL*) URL
readrequirednonatomicstronginherited

The URL of the remote resource.

Since
100