RouteTracker Class

  • RouteTracker
  • class Esri::ArcGISRuntime::RouteTracker

    Uses a location to provide status and progress updates as a route is traversed (by a moving vehicle, for example). More...

    Header: #include <RouteTracker.h>
    Since: Esri::ArcGISRuntime 100.6
    Inherits: Esri::ArcGISRuntime::Object

    This class was introduced in Esri::ArcGISRuntime 100.6.

    Public Functions

    RouteTracker(const Esri::ArcGISRuntime::RouteResult &routeResult, int routeIndex, bool skipCoincidentStops, QObject *parent = nullptr)
    RouteTracker(const Esri::ArcGISRuntime::RouteResult &routeResult, int routeIndex, QObject *parent = nullptr)
    virtual ~RouteTracker() override
    void cancelRerouting()
    void disableRerouting() const
    Esri::ArcGISRuntime::TaskWatcher enableRerouting(Esri::ArcGISRuntime::ReroutingParameters *parameters)
    Esri::ArcGISRuntime::VoiceGuidance *generateVoiceGuidance() const
    bool isReroutingEnabled() const
    bool isSkipCoincidentStops() const
    void setSpeechEngineReadyFunction(std::function<bool ()> func)
    void setVoiceGuidanceUnitSystem(Esri::ArcGISRuntime::UnitSystem distanceUnit)
    std::function<bool ()> speechEngineReadyFunction() const
    Esri::ArcGISRuntime::TaskWatcher switchToNextDestination()
    Esri::ArcGISRuntime::TaskWatcher trackLocation(const Esri::ArcGISRuntime::Location &location)
    Esri::ArcGISRuntime::TaskWatcher trackLocation(const QGeoPositionInfo &gpsLocation)
    Esri::ArcGISRuntime::TrackingStatus *trackingStatus() const
    Esri::ArcGISRuntime::UnitSystem voiceGuidanceUnitSystem()

    Signals

    void enableReroutingCompleted(QUuid taskId)
    void newVoiceGuidance(Esri::ArcGISRuntime::VoiceGuidance *voiceGuidance)
    void rerouteCompleted(Esri::ArcGISRuntime::TrackingStatus *trackingStatus, const Esri::ArcGISRuntime::Error &error)
    void rerouteStarted()
    void switchToNextDestinationCompleted(QUuid taskId)
    void trackLocationCompleted(QUuid taskId)
    void trackingStatusChanged(Esri::ArcGISRuntime::TrackingStatus *trackingStatus)

    Detailed Description

    RouteTracker can give the time or distance to the next maneuver, notify if the location is off-route, and regenerate a new route if necessary. Basic workflow:

    See also RouteResult.

    Member Function Documentation

    RouteTracker::RouteTracker(const Esri::ArcGISRuntime::RouteResult &routeResult, int routeIndex, bool skipCoincidentStops, QObject *parent = nullptr)

    Creates a Route Tracker using a specific route from a route result, with an option to treat coincident stops as a single destination.

    • routeResult - A Esri::ArcGISRuntime::RouteResult generated from route task solve.
    • routeIndex - The zero-based index of the Route in RouteResult
    • skipCoincidentStops - Determines if coincident stops (multiple stops in a row at the same location) should be treated as a single destination.
    • parent - The optional parent QObject.

    This function was introduced in Esri::ArcGISRuntime 100.9.

    RouteTracker::RouteTracker(const Esri::ArcGISRuntime::RouteResult &routeResult, int routeIndex, QObject *parent = nullptr)

    Constructor that takes a RouteResult and a route index.

    The RouteResult must contain at least one Route.

    [signal] void RouteTracker::enableReroutingCompleted(QUuid taskId)

    Emitted when the enableRerouting asynchronous operation completes.

    [signal] void RouteTracker::newVoiceGuidance(Esri::ArcGISRuntime::VoiceGuidance *voiceGuidance)

    Emitted when there is new voice guidance.

    • voiceGuidance - new voice guidance.

    The returned VoiceGuidance object has the RouteTracker as its parent.

    See also Returned QObjects Parenting.

    [signal] void RouteTracker::rerouteCompleted(Esri::ArcGISRuntime::TrackingStatus *trackingStatus, const Esri::ArcGISRuntime::Error &error)

    Emitted when background rerouting is finished.

    • trackingStatus - current TrackingStatus with recalculated RouteResult.
    • error - populated if error occurs during rerouting, otherwise NULL.

    The returned TrackingStatus object has the RouteTracker as its parent.

    See also Returned QObjects Parenting.

    [signal] void RouteTracker::rerouteStarted()

    Emitted when background rerouting starts.

    [signal] void RouteTracker::switchToNextDestinationCompleted(QUuid taskId)

    Emitted when the switchToNextDestination asynchronous operation completes.

    [signal] void RouteTracker::trackLocationCompleted(QUuid taskId)

    Emitted when the trackLocation asynchronous operation completes.

    [signal] void RouteTracker::trackingStatusChanged(Esri::ArcGISRuntime::TrackingStatus *trackingStatus)

    Emitted when trackingStatus changes.

    The returned TrackingStatus object has the RouteTracker as its parent.

    See also Returned QObjects Parenting.

    [override virtual] RouteTracker::~RouteTracker()

    Destructor.

    void RouteTracker::cancelRerouting()

    Cancels a running reroute task.

    If rerouting is in progress, this method will interrupt the background route task process.

    void RouteTracker::disableRerouting() const

    Disables automatic rerouting.

    When disabled, the RouteTracker will not automatically recalculate a route when TrackingStatus::isOnRoute is false.

    Esri::ArcGISRuntime::TaskWatcher RouteTracker::enableRerouting(Esri::ArcGISRuntime::ReroutingParameters *parameters)

    Returns enables automatic rerouting when the tracker detects an off-route status.

    Rerouting only occurs when the current location is off-route, but on or near the transportation network edges. For example if an off-route state is detected, but the tracked location is in a parking lot, away from any transportation network edges, rerouting will not occur, and will occur only when a subsequent tracked location is on or near the transportation network edges.

    Returns a TaskWatcher for the asynchronous operation.

    This function was introduced in Esri::ArcGISRuntime 100.11.

    Esri::ArcGISRuntime::VoiceGuidance *RouteTracker::generateVoiceGuidance() const

    Returns voice guidance.

    The most recent voice guidance based on the last trackLocation. It can be used to repeat last/latest voice guidance.

    bool RouteTracker::isReroutingEnabled() const

    Returns whether routes are automatically regenerated when tracking status is off-route.

    bool RouteTracker::isSkipCoincidentStops() const

    Returns whether multiple stops in a row at the same location should be treated as one stop. When true, if there are multiple stops in a row, at the same network location, the new voice guidance event will fire a single time. Calling Esri::ArcGISRuntime::RouteTracker::switchToNextDestination will skip over the other coincident stops, setting the state to the next relevant direction maneuver. If the value is false, each stop will be treated as a unique destination. The default value for this property is true. If your route does not have coincident stops, the value of this property will have no effect.

    This function was introduced in Esri::ArcGISRuntime 100.9.

    void RouteTracker::setSpeechEngineReadyFunction(std::function<bool ()> func)

    Sets a function to be called to determine if the text-to-speech engine is ready to func.

    The function is called by RouteTracker internally before newVoiceGuidance emits to check if the text-to-speech engine is busy. If it is busy it will postpone raising the voice guidance event until next time trackLocation is called.

    This will be called internally by RouteTracker on a background thread.

    Setting this is optional, and if this is not set RouteTracker assumes the speech engine is always ready so that no voice guidance messages are skipped.

    The function provided must return true if the engine is ready, false otherwise.

    This can be set or unset at any time.

    Here is an example of usage with a lambda.

    // QTextToSpeech* m_speaker;
    m_routeTracker->setSpeechEngineReadyFunction([speaker = m_speaker]() -> bool
    {
      return speaker->state() == QTextToSpeech::State::Ready;
    });

    Here is an example of unsetting this if you no longer want it to be used.

    m_routeTracker->setSpeechEngineReadyFunction({});

    By default no function is set.

    This function was introduced in Esri::ArcGISRuntime 100.12.

    See also speechEngineReadyFunction().

    void RouteTracker::setVoiceGuidanceUnitSystem(Esri::ArcGISRuntime::UnitSystem distanceUnit)

    Sets the unit system used for generating route guidance to distanceUnit.

    Default value is UnitSystem::Metric.

    See also voiceGuidanceUnitSystem().

    std::function<bool ()> RouteTracker::speechEngineReadyFunction() const

    Gets the function to be called to determine if the text-to-speech engine is ready, if any was set.

    This function was introduced in Esri::ArcGISRuntime 100.12.

    See also setSpeechEngineReadyFunction.

    Esri::ArcGISRuntime::TaskWatcher RouteTracker::switchToNextDestination()

    Starts tracking progress to the next destination in the Route.

    Use switchToNextDestination when the tracker reports a DestinationStatus::Reached status. Before calling switchToNextDestination make sure that TrackingStatus::remainingDestinationCount > 1. A value of 1 means navigation is proceeding to last destination. This method can also be called after DestinationStatus::Approaching in cases where the location cannot get near enough to the destination point for DestinationStatus::Reached (such as the center of a park or shopping center, for example).

    RouteTracker::trackLocation needs to be called at least once before calling this method; otherwise an error will be thrown. RouteTracker::trackLocation is needed for getting TrackingStatus and for handling visitFirstStopOnStart.

    The switchToNextDestinationCompleted signal will emit once the operation is complete.

    Esri::ArcGISRuntime::TaskWatcher RouteTracker::trackLocation(const Esri::ArcGISRuntime::Location &location)

    Provides route tracking status relative to the provided location.

    The location generally comes from a GPS but may also be a simulated or a manually entered Location. It must have valid values for X and Y coordinates, velocity (in meters per second), heading (in degrees), and a timestamp. When a new location is tracked the trackingStatusChanged signal will be emmited.

    This method should be called each time a new position is received from the location source (usually once per second).

    The trackLocationCompleted signal emits when the operation completes.

    This function was introduced in Esri::ArcGISRuntime 100.8.

    Esri::ArcGISRuntime::TaskWatcher RouteTracker::trackLocation(const QGeoPositionInfo &gpsLocation)

    Provides route tracking status relative to the provided gpsLocation.

    The location generally comes from a GPS but may also be a simulated or manually entered location. It must have valid values for X and Y coordinates, speed (in meters per second), course (in degrees), and a timestamp. Events fired for RouteTracker and TrackingStatus returned when completed.

    Method should be called each time a new position is received from the location source (usually once per second).

    The trackLocationCompleted signal emits when the operation completes.

    Esri::ArcGISRuntime::TrackingStatus *RouteTracker::trackingStatus() const

    Returns tracker status for the current location on the route.

    Esri::ArcGISRuntime::UnitSystem RouteTracker::voiceGuidanceUnitSystem()

    Returns the unit system that will be used for generating route guidance, expressed as an enumeration.

    See also setVoiceGuidanceUnitSystem.

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