Skip To Content ArcGIS for Developers Sign In Dashboard

ClosestFacilityTask Class


A task to find a least-cost route between facilities and incidents. More...

Header: #include <ClosestFacilityTask>
Since: Esri::ArcGISRuntime 100.1
Inherits: Object, Loadable, and RemoteResource

Public Functions

ClosestFacilityTask(const QString &databasePath, const QString &networkName, QObject *parent = nullptr)
ClosestFacilityTask(const QUrl &url, Credential *credential, QObject *parent = nullptr)
ClosestFacilityTask(const QUrl &url, QObject *parent = nullptr)
ClosestFacilityTask(TransportationNetworkDataset *transportationNetworkDataset, QObject *parent = nullptr)
ClosestFacilityTaskInfo closestFacilityTaskInfo() const
TaskWatcher createDefaultParameters()
TaskWatcher solveClosestFacility(const ClosestFacilityParameters &closestFacilityParameters)
TransportationNetworkDataset *transportationNetworkDataset() const

Reimplemented Public Functions

virtual void cancelLoad()
virtual Credential *credential() const
virtual void load()
virtual Error loadError() const
virtual LoadStatus loadStatus() const
virtual RequestConfiguration requestConfiguration() const
virtual void retryLoad()
virtual void setRequestConfiguration(const RequestConfiguration &requestConfiguration)
virtual QUrl url() const


void createDefaultParametersCompleted(QUuid taskId, Esri::ArcGISRuntime::ClosestFacilityParameters defaultParameters)
void doneLoading(Esri::ArcGISRuntime::Error loadError)
void loadStatusChanged(Esri::ArcGISRuntime::LoadStatus loadStatus)
void solveClosestFacilityCompleted(QUuid taskId, Esri::ArcGISRuntime::ClosestFacilityResult closestFacilityResult)

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 1 public variable inherited from QObject
  • 10 static public members inherited from QObject
  • 9 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

A task to find a least-cost route between facilities and incidents.

The closest facility task class uses a transportation network to measure the cost of traveling between incidents and facilities and determines which are nearest to one other in terms of cost. When finding closest facilities, you can specify how many to find and whether the direction of travel is toward or away from them. You can also provide impedance attributes to be considered when calculating route cost. ClosestFacilityTask is executed asynchronously. A successful execution returns a ClosestFacilityResult instance with details about the closest facility route.

The closest facility task works in an online connected scenario by using a transportation network that is published to ArcGIS Server as an online Network Analyst closest facility service. Esri also provides ready-to-use services, such as the Directions and Routing Services, which requires authentication with an ArcGIS organizational account. In connected scenarios, provide a URL to the REST endpoint of the service, along with any necessary credentials.

See also Loadable and Closest Facility REST API documentation.

Member Function Documentation

ClosestFacilityTask::ClosestFacilityTask(const QString &databasePath, const QString &networkName, QObject *parent = nullptr)

Constructor that takes a databasePath and networkName, with an optional parent.

This function was introduced in Esri::ArcGISRuntime 100.2.

ClosestFacilityTask::ClosestFacilityTask(const QUrl &url, Credential *credential, QObject *parent = nullptr)

Constructor that takes a url to a secured Network Analysis service endpoint and a credential, with an optional parent.

ClosestFacilityTask::ClosestFacilityTask(const QUrl &url, QObject *parent = nullptr)

Constructor that takes a url to a Network Analysis service endpoint with an optional parent.

ClosestFacilityTask::ClosestFacilityTask(TransportationNetworkDataset *transportationNetworkDataset, QObject *parent = nullptr)

Constructor that takes a transportationNetworkDataset with an optional parent.

This function was introduced in Esri::ArcGISRuntime 100.2.



[virtual] void ClosestFacilityTask::cancelLoad()

Reimplemented from Loadable::cancelLoad().

See Loadable.

ClosestFacilityTaskInfo ClosestFacilityTask::closestFacilityTaskInfo() const

Returns ClosestFacilityTaskInfo about the ClosestFacilityTask.

Wait until the ClosestFacilityTask is doneLoading before attempting to obtain the ClosestFacilityTaskInfo.

TaskWatcher ClosestFacilityTask::createDefaultParameters()

Creates default closest facility parameters from the service.

The createDefaultParametersCompleted signal will emit once the operation is complete, giving access to the resulting ClosestFacilityParameters.

[signal] void ClosestFacilityTask::createDefaultParametersCompleted(QUuid taskId, Esri::ArcGISRuntime::ClosestFacilityParameters defaultParameters)

Signal emitted after the createDefaultParameters asynchronous method completes.

[virtual] Credential *ClosestFacilityTask::credential() const

Reimplemented from RemoteResource::credential().

Returns the security credential used to access the closest facility service.

Only applicable if using an online service that is secured.

[signal] void ClosestFacilityTask::doneLoading(Esri::ArcGISRuntime::Error loadError)

Signal emitted when this object is done loading.

  • loadError - Details about any error that may have occurred.

Note: If there is a load error it will also be emitted on the errorOccurred signal.

See also Loadable and Object.

[virtual] void ClosestFacilityTask::load()

Reimplemented from Loadable::load().

See Loadable.

[virtual] Error ClosestFacilityTask::loadError() const

Reimplemented from Loadable::loadError().

See Loadable.

[virtual] LoadStatus ClosestFacilityTask::loadStatus() const

Reimplemented from Loadable::loadStatus().

See Loadable.

[signal] void ClosestFacilityTask::loadStatusChanged(Esri::ArcGISRuntime::LoadStatus loadStatus)

Signal emitted when the load status changes for this object.

See also Loadable.

[virtual] RequestConfiguration ClosestFacilityTask::requestConfiguration() const

Reimplemented from RemoteResource::requestConfiguration().

Returns the RequestConfiguration in use by this task.

This function was introduced in Esri::ArcGISRuntime 100.1.

See also setRequestConfiguration().

[virtual] void ClosestFacilityTask::retryLoad()

Reimplemented from Loadable::retryLoad().

See Loadable.

[virtual] void ClosestFacilityTask::setRequestConfiguration(const RequestConfiguration &requestConfiguration)

Reimplemented from RemoteResource::setRequestConfiguration().

Sets configuration parameters used for network requests sent by this task to requestConfiguration.

This function was introduced in Esri::ArcGISRuntime 100.1.

See also requestConfiguration().

TaskWatcher ClosestFacilityTask::solveClosestFacility(const ClosestFacilityParameters &closestFacilityParameters)

Solves a closest facility with the given closestFacilityParameters.

The solveClosestFacilityCompleted signal will emit once the operation is complete, giving access to the ClosestFacilityResult.

[signal] void ClosestFacilityTask::solveClosestFacilityCompleted(QUuid taskId, Esri::ArcGISRuntime::ClosestFacilityResult closestFacilityResult)

Signal emitted after the solveClosestFacility asynchronous method completes.

  • taskId - The task ID of the asynchronous task.
  • closestFacilityResult - The generated ClosestFacilityResult.

TransportationNetworkDataset *ClosestFacilityTask::transportationNetworkDataset() const

Returns the TransportationNetworkDataset used to construct this ClosestFacilityTask.

This function was introduced in Esri::ArcGISRuntime 100.2.

[virtual] QUrl ClosestFacilityTask::url() const

Reimplemented from RemoteResource::url().

Returns the URL to the online service.

Only applicable to online closest facility.

Feedback on this topic?