RouteTask Class

  • RouteTask
  • class Esri::ArcGISRuntime::RouteTask

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

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

    This class was introduced in Esri::ArcGISRuntime 100.0.

    Public Functions

    RouteTask(Esri::ArcGISRuntime::TransportationNetworkDataset *transportationNetworkDataset, QObject *parent = nullptr)
    RouteTask(const QUrl &url, QObject *parent = nullptr)
    RouteTask(const QUrl &url, Esri::ArcGISRuntime::Credential *credential, QObject *parent = nullptr)
    RouteTask(const QString &pathToDatabase, const QString &networkName, QObject *parent = nullptr)
    virtual ~RouteTask() override
    Esri::ArcGISRuntime::TaskWatcher createDefaultParameters()
    Esri::ArcGISRuntime::TaskWatcher createParameters(const Esri::ArcGISRuntime::FeatureCollection &featureCollection)
    Esri::ArcGISRuntime::TaskWatcher createParametersWithPortalItem(Esri::ArcGISRuntime::PortalItem *portalItem)
    Esri::ArcGISRuntime::RouteTaskInfo routeTaskInfo() const
    Esri::ArcGISRuntime::TaskWatcher solveRoute(const Esri::ArcGISRuntime::RouteParameters &routeParameters)
    Esri::ArcGISRuntime::TransportationNetworkDataset *transportationNetworkDataset() const

    Reimplemented Public Functions

    virtual QString apiKey() const override
    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 setApiKey(const QString &apiKey) override
    virtual void setRequestConfiguration(const Esri::ArcGISRuntime::RequestConfiguration &requestConfiguration) override
    virtual QUrl url() const override

    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

    Esri::ArcGISRuntime::TaskWatcher createRouteResult(Esri::ArcGISRuntime::PortalItem *portalItem)
    Esri::ArcGISRuntime::RouteTask *instance()

    Detailed Description

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

    Constructor that takes a transportationNetworkDataset 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(const QUrl &url, Esri::ArcGISRuntime::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 QString &pathToDatabase, const QString &networkName, QObject *parent = nullptr)

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

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

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

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

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

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

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

    Signal emitted when the load status changes for this object.

    See also Loadable.

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

    [override virtual] RouteTask::~RouteTask()

    Destructor.

    [override virtual] QString RouteTask::apiKey() const

    Reimplements: ApiKeyResource::apiKey() const.

    Returns the API key. See ApiKeyResource.

    This function was introduced in Esri::ArcGISRuntime 100.10.

    See also setApiKey().

    [override virtual] void RouteTask::cancelLoad()

    Reimplements: Loadable::cancelLoad().

    See Loadable.

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

    Esri::ArcGISRuntime::TaskWatcher RouteTask::createParameters(const Esri::ArcGISRuntime::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.

    Esri::ArcGISRuntime::TaskWatcher RouteTask::createParametersWithPortalItem(Esri::ArcGISRuntime::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.

    [static] Esri::ArcGISRuntime::TaskWatcher RouteTask::createRouteResult(Esri::ArcGISRuntime::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.

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

    Reimplements: RemoteResource::credential() const.

    Returns the security credential used to access the routing service.

    Only applicable if using an online service that is secured.

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

    [override virtual] void RouteTask::load()

    Reimplements: Loadable::load().

    See Loadable.

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

    Reimplements: Loadable::loadError() const.

    See Loadable.

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

    Reimplements: Loadable::loadStatus() const.

    See Loadable.

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

    Reimplements: Loadable::retryLoad().

    See Loadable.

    Esri::ArcGISRuntime::RouteTaskInfo RouteTask::routeTaskInfo() const

    Returns the RouteTaskInfo for this RouteTask.

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

    [override virtual] void RouteTask::setApiKey(const QString &apiKey)

    Reimplements: ApiKeyResource::setApiKey(const QString &apiKey).

    Sets the API key to apiKey. See ApiKeyResource.

    This function was introduced in Esri::ArcGISRuntime 100.10.

    See also apiKey().

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

    Solves a route with the given routeParameters.

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

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

    Returns the TransportationNetworkDataset used to construct this RouteTask.

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

    Reimplements: RemoteResource::url() const.

    Returns the URL to the online service.

    Only applicable to online routing.

    Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.