Skip To Content ArcGIS for Developers Sign In Dashboard

RouteTracker Class

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>
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()
void cancelRerouting()
void disableRerouting() const
Esri::ArcGISRuntime::TaskWatcher enableRerouting(Esri::ArcGISRuntime::RouteTask *routeTask, const Esri::ArcGISRuntime::RouteParameters &routeParameters, Esri::ArcGISRuntime::ReroutingStrategy strategy, bool visitFirstStopOnStart)
Esri::ArcGISRuntime::VoiceGuidance *generateVoiceGuidance() const
bool isReroutingEnabled() const
bool isSkipCoincidentStops() const
void setVoiceGuidanceUnitSystem(Esri::ArcGISRuntime::UnitSystem distanceUnit)
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.

[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::RouteTask *routeTask, const Esri::ArcGISRuntime::RouteParameters &routeParameters, Esri::ArcGISRuntime::ReroutingStrategy strategy, bool visitFirstStopOnStart)

Enables rerouting functionality of route tracker.

Rerouting is initiated automatically when the tracking status is off-route. In order to be considered off-route, the location must be on the transportation network as well as off the current route. If a tracked location is in a parking lot, for example, it is not considered off-route and rerouting will not occur. If the next location is on the network but not on the route, automatic rerouting will begin.

The enableReroutingCompleted signal will emit once the operation is complete.

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::setVoiceGuidanceUnitSystem(Esri::ArcGISRuntime::UnitSystem distanceUnit)

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

Default value is UnitSystem::Metric.

See also voiceGuidanceUnitSystem().

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.


Feedback on this topic?