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

    Public Functions

    RouteTask(const QString &pathToDatabase, const QString &networkName, QObject *parent = nullptr)
    RouteTask(const QUrl &url, Esri::ArcGISRuntime::Credential *credential, QObject *parent = nullptr)
    RouteTask(const QUrl &url, QObject *parent = nullptr)
    RouteTask(Esri::ArcGISRuntime::TransportationNetworkDataset *transportationNetworkDataset, QObject *parent = nullptr)
    virtual ~RouteTask() override
    QFuture<Esri::ArcGISRuntime::RouteParameters> createDefaultParametersAsync()
    QFuture<Esri::ArcGISRuntime::RouteParameters> createParametersAsync(Esri::ArcGISRuntime::FeatureCollection *collection)
    QFuture<Esri::ArcGISRuntime::RouteParameters> createParametersAsync(Esri::ArcGISRuntime::PortalItem *portalItem)
    Esri::ArcGISRuntime::RouteTaskInfo routeTaskInfo() const
    QFuture<Esri::ArcGISRuntime::RouteResult> solveRouteAsync(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 doneLoading(const Esri::ArcGISRuntime::Error &loadError)
    void loadStatusChanged(Esri::ArcGISRuntime::LoadStatus loadStatus)

    Static Public Members

    QFuture<Esri::ArcGISRuntime::RouteResult> createRouteResultAsync(Esri::ArcGISRuntime::FeatureCollection *collection)
    QFuture<Esri::ArcGISRuntime::RouteResult> createRouteResultAsync(Esri::ArcGISRuntime::PortalItem *portalItem)

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

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

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

    [explicit] RouteTask::RouteTask(Esri::ArcGISRuntime::TransportationNetworkDataset *transportationNetworkDataset, QObject *parent = nullptr)

    Constructor that takes a transportationNetworkDataset with an optional parent.

    [override virtual] RouteTask::~RouteTask()

    Destructor.

    [override virtual, since Esri::ArcGISRuntime 100.10] QString RouteTask::apiKey() const

    Reimplements: ApiKeyResource::apiKey() const.

    Returns the API key allows your app to access ArcGIS location services and private portal items.

    An API key is a unique long-lived access token that is used to authenticate and monitor requests to ArcGIS location services and private portal items. You can create and manage an API key using your portal when you sign in with an ArcGIS Location Platform account or an ArcGIS Online account with administrator access or a custom role that has the `Generate API keys` privilege. To learn how to create and manage API keys, go to the Create an API Key tutorial. You must ensure that your API key has the correct privileges to access secure resources.

    Note: An API key created with a referrer is not supported. If you need service requests to include the referrer, use the SDK's functionality to intercept the request and add an HTTP referer header.

    In addition to setting an ArcGISRuntimeEnvironment::apiKey at a global level for your application, you can set it on any class that implements ApiKeyResource. This overrides the ArcGISRuntimeEnvironment::apiKey and enables more granular usage telemetry and management of ArcGIS location resources used by your app.

    Classes that expose an API key property by implementing ApiKeyResource include:

    For more information, see API key authentication and Types of authentication.

    This function was introduced in Esri::ArcGISRuntime 100.10.

    See also setApiKey().

    [override virtual] void RouteTask::cancelLoad()

    Reimplements: Loadable::cancelLoad().

    See Loadable.

    [since Esri::ArcGISRuntime 200.2] QFuture<Esri::ArcGISRuntime::RouteParameters> RouteTask::createDefaultParametersAsync()

    Creates default route parameters from the service or database.

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 200.2.

    [since Esri::ArcGISRuntime 200.2] QFuture<Esri::ArcGISRuntime::RouteParameters> RouteTask::createParametersAsync(Esri::ArcGISRuntime::FeatureCollection *collection)

    Imports route parameters from feature collection and then adjusts imported parameters to current Route task.

    • collection - The feature collection object that contains stops, route info, and barriers tables. Stops table is required.

    Travel mode would be empty if it could not be created from the route layer settings for the route task's network. In case if travel mode is empty then client can override it by another travel mode (for example obtained from RouteTaskInfo). Accumulate attributes from Route Info table going to be applied only if they exist in transportation network restriction and cost attributes. This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 200.2.

    [since Esri::ArcGISRuntime 200.2] QFuture<Esri::ArcGISRuntime::RouteParameters> RouteTask::createParametersAsync(Esri::ArcGISRuntime::PortalItem *portalItem)

    Creates the route parameters from portal item and then adjusts imported parameters to current Route task.

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

    Travel mode would be empty if it could not be created from the route layer settings for the route task's network. In case if travel mode is empty then client can override it by another travel mode (for example obtained from RouteTaskInfo). Accumulate attributes from Route Info table going to be applied only if they exist in transportation network restriction and cost attributes. This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 200.2.

    [static, since Esri::ArcGISRuntime 200.2] QFuture<Esri::ArcGISRuntime::RouteResult> RouteTask::createRouteResultAsync(Esri::ArcGISRuntime::FeatureCollection *collection)

    Imports the route result from feature collection.

    • collection - The feature collection that contains directions, stops, route info, and barriers tables.

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 200.2.

    [static, since Esri::ArcGISRuntime 200.2] QFuture<Esri::ArcGISRuntime::RouteResult> RouteTask::createRouteResultAsync(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 QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 200.2.

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

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

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

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

    Signal emitted when the load status changes for this object.

    See also Loadable.

    [override virtual, since Esri::ArcGISRuntime 100.1] 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, since Esri::ArcGISRuntime 100.10] void RouteTask::setApiKey(const QString &apiKey)

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

    Sets the API key to apiKey.

    This function was introduced in Esri::ArcGISRuntime 100.10.

    See also apiKey().

    [override virtual, since Esri::ArcGISRuntime 100.1] 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().

    [since Esri::ArcGISRuntime 200.2] QFuture<Esri::ArcGISRuntime::RouteResult> RouteTask::solveRouteAsync(const Esri::ArcGISRuntime::RouteParameters &routeParameters)

    Solves a route with the given routeParameters.

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 200.2.

    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.