Skip To Content ArcGIS for Developers Sign In Dashboard

ClosestFacilityTask Class

class Esri::ArcGISRuntime::ClosestFacilityTask

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

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

This class was introduced in Esri::ArcGISRuntime 100.1.

Public Functions

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

Reimplemented Public Functions

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


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)

Detailed Description

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(Esri::ArcGISRuntime::TransportationNetworkDataset *transportationNetworkDataset, QObject *parent = nullptr)

Constructor that takes a transportationNetworkDataset with an optional parent.

This function was introduced in Esri::ArcGISRuntime 100.2.

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(const QUrl &url, Esri::ArcGISRuntime::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 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.

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

Signal emitted after the createDefaultParameters asynchronous method completes.

[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.

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

Signal emitted when the load status changes for this object.

See also Loadable.

[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.

[override virtual] ClosestFacilityTask::~ClosestFacilityTask()


[override virtual] void ClosestFacilityTask::cancelLoad()

Reimplements: Loadable::cancelLoad().

See Loadable.

Esri::ArcGISRuntime::ClosestFacilityTaskInfo ClosestFacilityTask::closestFacilityTaskInfo() const

Returns ClosestFacilityTaskInfo about the ClosestFacilityTask.

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

Esri::ArcGISRuntime::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.

[override virtual] Esri::ArcGISRuntime::Credential *ClosestFacilityTask::credential() const

Reimplements: RemoteResource::credential() const.

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

Only applicable if using an online service that is secured.

[override virtual] void ClosestFacilityTask::load()

Reimplements: Loadable::load().

See Loadable.

[override virtual] Esri::ArcGISRuntime::Error ClosestFacilityTask::loadError() const

Reimplements: Loadable::loadError() const.

See Loadable.

[override virtual] Esri::ArcGISRuntime::LoadStatus ClosestFacilityTask::loadStatus() const

Reimplements: Loadable::loadStatus() const.

See Loadable.

[override virtual] Esri::ArcGISRuntime::RequestConfiguration ClosestFacilityTask::requestConfiguration() const

Reimplements: RemoteResource::requestConfiguration() const.

Returns the RequestConfiguration in use by this task.

This function was introduced in Esri::ArcGISRuntime 100.1.

See also setRequestConfiguration().

[override virtual] void ClosestFacilityTask::retryLoad()

Reimplements: Loadable::retryLoad().

See Loadable.

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

Reimplements: RemoteResource::setRequestConfiguration(const Esri::ArcGISRuntime::RequestConfiguration &requestConfiguration).

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().

Esri::ArcGISRuntime::TaskWatcher ClosestFacilityTask::solveClosestFacility(const Esri::ArcGISRuntime::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.

Esri::ArcGISRuntime::TransportationNetworkDataset *ClosestFacilityTask::transportationNetworkDataset() const

Returns the TransportationNetworkDataset used to construct this ClosestFacilityTask.

This function was introduced in Esri::ArcGISRuntime 100.2.

[override virtual] QUrl ClosestFacilityTask::url() const

Reimplements: RemoteResource::url() const.

Returns the URL to the online service.

Only applicable to online closest facility.

Feedback on this topic?