Skip To Content ArcGIS for Developers Sign In Dashboard

RouteTask Class

(Esri::ArcGISRuntime::RouteTask)

A task to find a route between two or more locations. More...

Header: #include <RouteTask>
Since: Esri::ArcGISRuntime 100.0
Inherits: Object, Loadable, and RemoteResource

Public Functions

RouteTask(const QString &pathToDatabase, const QString &networkName, QObject *parent = nullptr)
RouteTask(const QUrl &url, Credential *credential, QObject *parent = nullptr)
RouteTask(const QUrl &url, QObject *parent = nullptr)
RouteTask(TransportationNetworkDataset *transportationNetworkDataset, QObject *parent = nullptr)
~RouteTask()
TaskWatcher createDefaultParameters()
TaskWatcher createParameters(const FeatureCollection &featureCollection)
TaskWatcher createParametersWithPortalItem(PortalItem *portalItem)
RouteTaskInfo routeTaskInfo() const
TaskWatcher solveRoute(const RouteParameters &routeParameters)
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

Signals

void createDefaultParametersCompleted(QUuid taskId, Esri::ArcGISRuntime::RouteParameters defaultParameters)
void createParametersCompleted(QUuid taskId, Esri::ArcGISRuntime::RouteParameters parameters)
void createParametersWithPortalItemCompleted(QUuid taskId, Esri::ArcGISRuntime::RouteParameters parameters)
void createRouteResultCompleted(QUuid taskId, Esri::ArcGISRuntime::RouteResult routeResult)
void doneLoading(Esri::ArcGISRuntime::Error loadError)
void loadStatusChanged(Esri::ArcGISRuntime::LoadStatus loadStatus)
void solveRouteCompleted(QUuid taskId, Esri::ArcGISRuntime::RouteResult routeResult)

Static Public Members

TaskWatcher createRouteResult(PortalItem *portalItem)
RouteTask *instance()
  • 10 static public members inherited from QObject

Additional Inherited Members

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

Detailed Description

A task to find a route between two or more locations.

Use a RouteTask to find the best way to get from one location to another or to visit several locations. RouteTask is a network analysis task that solves a routing problem defined in a RouteParameters instance, using data in a transportation network dataset. The task calculates the route between a series of locations, known as stops. RouteTask is executed asynchronously. A successful execution returns a RouteResult instance with details about the route.

When working in an online connected scenario, the transportation network can be published to ArcGIS Server as an online Network Analyst routing 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.

When working offline in a disconnected scenario, the transportation network can be exported as a Runtime-enabled network from either ArcMap or ArcGIS Pro. If you are using ArcMap, run the Create Runtime Content geoprocessing tool, and reference a map document that contains the network dataset you want to export. This will output a mobile geodatabase (*.geodatabase), and a transportation network folder (*.tn). Create RouteTask by loading the mobile geodatabase and transportation network folder onto the device, setting the URL property to a local path to the mobile geodatabase that contains the network, and setting the networkName property to the name of the network dataset. If you are using ArcGIS Pro, run the Create Mobile Map Package geoprocessing tool, and select the map and network dataset that you want to export. The output is a mobile map package (*.mmpk) which is a compressed file containing everything needed to use RouteTask offline. To solve network analyst routes, load a mobile map package onto your device, extract the map from the package, and access the transportation network from each map. Each transportation networks contain the geodatabase and the network name needed to execute RouteTask.

See also Loadable, MobileMapPackage, and Route REST API documentation.

Member Function Documentation

RouteTask::RouteTask(const QString &pathToDatabase, const QString &networkName, QObject *parent = nullptr)

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

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

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

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

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

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

Constructor that takes a transportationNetworkDataset with an optional parent.

RouteTask::~RouteTask()

Destructor.

[virtual] void RouteTask::cancelLoad()

Reimplemented from Loadable::cancelLoad().

See Loadable.

TaskWatcher RouteTask::createDefaultParameters()

Creates default route parameters from the service or database.

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

[signal] void RouteTask::createDefaultParametersCompleted(QUuid taskId, Esri::ArcGISRuntime::RouteParameters defaultParameters)

Signal emitted after the createDefaultParameters asynchronous method completes.

  • taskId - The task ID of the asynchronous task.
  • defaultParameters - The generated default RouteParameters.

TaskWatcher RouteTask::createParameters(const FeatureCollection &featureCollection)

Creates the route parameters from a feature collection for this route task.

Imported route parameters from a feature collection will be adjusted to the current RouteTask.

Please note:

featureCollection must contain at least a Stops table.

The createParametersCompleted signal emits when the operation is complete, giving access to the resulting RouteParameters.

This function was introduced in Esri::ArcGISRuntime 100.1.

[signal] void RouteTask::createParametersCompleted(QUuid taskId, Esri::ArcGISRuntime::RouteParameters parameters)

Signal emitted after the createParameters asynchronous method completes.

  • taskId - The task ID of the asynchronous task.
  • parameters - The generated RouteParameters.

TaskWatcher RouteTask::createParametersWithPortalItem(PortalItem *portalItem)

Creates the route parameters from a portal item for this route task.

This operation allows the user to download a set of route parameters stored in the portal and use them to solve routing problems locally on the device. Imported route parameters from the portal item will be adjusted to the current RouteTask.

  • portalItem - The portal item object with a feature collection that contains stops, route info, and barriers tables. A stops table is required.

Please note:

This function was introduced in Esri::ArcGISRuntime 100.3.

[signal] void RouteTask::createParametersWithPortalItemCompleted(QUuid taskId, Esri::ArcGISRuntime::RouteParameters parameters)

Signal emitted after the createParametersWithPortalItem asynchronous method completes.

  • taskId - The task ID of the asynchronous task.
  • parameters - The generated RouteParameters.

This function was introduced in Esri::ArcGISRuntime 100.3.

[static] TaskWatcher RouteTask::createRouteResult(PortalItem *portalItem)

Imports a pre-generated route result from the supplied portal item.

This operation allows the user to download an existing route result from a portal and use it for routing purposes on the local device.

  • portalItem - The portal item with a feature collection that contains directions, stops, route info, and barriers tables.

This method returns a TaskWatcher for the asynchronous operation. Connect to the RouteTask singleton provided by the instance() method to determine when the operation is completed.

This function was introduced in Esri::ArcGISRuntime 100.3.

[signal] void RouteTask::createRouteResultCompleted(QUuid taskId, Esri::ArcGISRuntime::RouteResult routeResult)

Signal emitted after the createRouteResult asynchronous method completes.

  • taskId - The task ID of the asynchronous task.
  • routeResult - The generated RouteResult.

This function was introduced in Esri::ArcGISRuntime 100.3.

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

Reimplemented from RemoteResource::credential().

Returns the security credential used to access the routing service.

Only applicable if using an online service that is secured.

[signal] void RouteTask::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.

[static] RouteTask *RouteTask::instance()

Returns an instance of the RouteTask singleton.

The instance is used to connect to the Object::errorOccurred and createRouteResultCompleted signals. You do not need to obtain the instance to call the static methods on the RouteTask.

This function was introduced in Esri::ArcGISRuntime 100.3.

[virtual] void RouteTask::load()

Reimplemented from Loadable::load().

See Loadable.

[virtual] Error RouteTask::loadError() const

Reimplemented from Loadable::loadError().

See Loadable.

[virtual] LoadStatus RouteTask::loadStatus() const

Reimplemented from Loadable::loadStatus().

See Loadable.

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

Signal emitted when the load status changes for this object.

See also Loadable.

[virtual] RequestConfiguration RouteTask::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 RouteTask::retryLoad()

Reimplemented from Loadable::retryLoad().

See Loadable.

RouteTaskInfo RouteTask::routeTaskInfo() const

Returns the RouteTaskInfo for this RouteTask.

Wait until this RouteTask is finished loading before attempting to obtain the RouteTaskInfo.

[virtual] void RouteTask::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 RouteTask::solveRoute(const RouteParameters &routeParameters)

Solves a route with the given routeParameters.

The solveRouteCompleted signal will emit once the operation is complete, giving access to the RouteResult.

[signal] void RouteTask::solveRouteCompleted(QUuid taskId, Esri::ArcGISRuntime::RouteResult routeResult)

Signal emitted after the solveRoute asynchronous method completes.

  • taskId - The task ID of the asynchronous task.
  • routeResult - The generated RouteResult.

TransportationNetworkDataset *RouteTask::transportationNetworkDataset() const

Returns the TransportationNetworkDataset used to construct this RouteTask.

[virtual] QUrl RouteTask::url() const

Reimplemented from RemoteResource::url().

Returns the URL to the online service.

Only applicable to online routing.


Feedback on this topic?