Skip To Content ArcGIS for Developers Sign In Dashboard

RouteTracker Class

(Esri::ArcGISRuntime::RouteTracker)

Tracks the vehicle location along the route, checking status and reporting progress. More...

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

Public Functions

RouteTracker(const RouteResult &routeResult, int routeIndex, QObject *parent = nullptr)
~RouteTracker()
void cancelRerouting()
void disableRerouting() const
TaskWatcher enableRerouting(RouteTask *routeTask, const RouteParameters &routeParameters, ReroutingStrategy strategy, bool visitFirstStopOnStart)
VoiceGuidance *generateVoiceGuidance() const
bool isReroutingEnabled() const
void setVoiceGuidanceUnitSystem(UnitSystem distanceUnit)
TaskWatcher switchToNextDestination()
TaskWatcher trackLocation(const QGeoPositionInfo &gpsLocation)
TrackingStatus *trackingStatus() const
UnitSystem voiceGuidanceUnitSystem()
  • 31 public functions inherited from QObject

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)

Additional Inherited Members

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

Detailed Description

Tracks the vehicle location along the route, checking status and reporting progress.

Instances of this class represent methods for processing navigation. The usual (generic) workflow can look like this:

  1. Create Route Tracker.
  2. Enable rerouting enableRerouting.
  3. Subscribe trackLocation to Location Provider (GPS, simulation, etc. Usual tracking happens each 1 second).
  4. Subscribe Map to updating location after trackLocation (Use display location).
  5. Call switchToNextDestination after obtaining DestinationStatus::reached status. Before calling switchToNextDestination, make sure that TrackingStatus::remainingDestinationCount > 1. A value of 1 means we are proceeding to last destination and there are no other destinations to switch to.

Member Function Documentation

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

Constructor that takes a RouteResult and a route index.

  • routeResult - The RouteResult object that must contain Route.
  • routeIndex - The zero-based index of the Route in RouteResult to use for tracking.
  • parent - A parent object (optional).

RouteTracker::~RouteTracker()

Destructor.

void RouteTracker::cancelRerouting()

Cancels rerouting task of route tracker.

If rerouting is started this method will interrupt rerouting background process.

void RouteTracker::disableRerouting() const

Disables rerouting functionality of route tracker.

After disabling rerouting, the RouteTracker cannot recalculate a route when TrackingStatus::isOnRoute is false.

TaskWatcher RouteTracker::enableRerouting(RouteTask *routeTask, const RouteParameters &routeParameters, ReroutingStrategy strategy, bool visitFirstStopOnStart)

Enables rerouting functionality of route tracker.

  • routeTask - The RouteTask that will be used for rerouting in background thread.
  • routeParameters - The The RouteParameters that will be used for rerouting in background thread.
  • strategy - A ReroutingStrategy that determines how route tracker should behave during reroute process (to next waypoint by default).
  • visitFirstStopOnStart - A flag that forces route tracker to navigate to first stop of route.

Tracker will start a re-routing calculation automatically as necessary (in general when vehicle if off route). Note, tracker validates that the passed in GPS location is "on" the transportation network, if it is not (e.g. in a parking lot) re-routing will not occur. Re-routing will occur once the passed in GPS location is "on" the transportation network.

The enableReroutingCompleted signal will emit once the operation is complete.

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

Emitted when the enableRerouting asynchronous operation completes.

VoiceGuidance *RouteTracker::generateVoiceGuidance() const

Returns voice guidance.

The latest voice guidance is based on last location that was passed to trackLocation. Can be used to repeat latest voice guidance, where distances will be based on current location.

bool RouteTracker::isReroutingEnabled() const

Returns whether rerouting is enabled.

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

Emitted when there is new voice guidance.

  • voiceGuidance - new voice guidance.

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

[signal] void RouteTracker::rerouteStarted()

Emitted when background rerouting starts.

void RouteTracker::setVoiceGuidanceUnitSystem(UnitSystem distanceUnit)

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

Default value is UnitSystem::Metric.

See also voiceGuidanceUnitSystem().

TaskWatcher RouteTracker::switchToNextDestination()

Switches route tracker to the next destination.

Call switchToNextDestination after obtaining DestinationStatus::Reached status. Before calling switchToNextDestination, make sure that TrackingStatus::remainingDestinationCount > 1. A value of 1 means that the RouteTracker is already proceeding to the final destination and there are no other destinations to switch to. This method also can be useful after DestinationStatus::Approaching when the vehicle cannot get DestinationStatus::Reached such as when near some private place.

The switchToNextDestinationCompleted signal will emit once the operation is complete.

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

Emitted when the switchToNextDestination asynchronous operation completes.

TaskWatcher RouteTracker::trackLocation(const QGeoPositionInfo &gpsLocation)

Tracks gpsLocation and updates route tracking result.

Location must have valid x,y values, speed (in meters per second), course (in degrees) and 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.

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

Emitted when the trackLocation asynchronous operation completes.

TrackingStatus *RouteTracker::trackingStatus() const

Returns tracker status for current location.

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

Emitted when trackingStatus changes.

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?