Uses a location to provide status and progress updates as a route is traversed (by a moving vehicle, for example). More...
|RouteTracker(const RouteResult &routeResult, int routeIndex, QObject *parent = nullptr)|
|TaskWatcher||enableRerouting(RouteTask *routeTask, const RouteParameters &routeParameters, ReroutingStrategy strategy, bool visitFirstStopOnStart)|
|VoiceGuidance *||generateVoiceGuidance() const|
|TaskWatcher||trackLocation(const QGeoPositionInfo &gpsLocation)|
|TrackingStatus *||trackingStatus() const|
- 31 public functions inherited from QObject
|void||rerouteCompleted(Esri::ArcGISRuntime::TrackingStatus *trackingStatus, const Esri::ArcGISRuntime::Error &error)|
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
Uses a location to provide status and progress updates as a route is traversed (by a moving vehicle, for example).
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:
- Create a new RouteTracker instance.
- Enable rerouting (if supported by the underlying route service).
- Use RouteTracker::trackLocation(const QGeoPositionInfo&) to track the location of the device.
- Await the RouteTracker::trackingStatusChanged signal to get the TrackingStatus as the location updates.
- Await the RouteTracker::newVoiceGuidance signal to get the VoiceGuidance whenever new instructions are available.
- If there are multiple stops, call RouteTracker::switchToNextDestination() each time DestinationStatus::Reached status is returned. Before switching to the next destination, make sure TrackingStatus::remainingDestinationCount() >
1. A value of
1means the last destination is being approached.
Member Function Documentation
RouteTracker::RouteTracker(const RouteResult &routeResult, int routeIndex, QObject *parent = nullptr)
Constructor that takes a RouteResult and a route index.
- routeResult - A RouteResult object obtained by calling RouteTask::solveRoute(const RouteParameters&).
- routeIndex - The zero-based index of the Route in RouteResult to track. The specified Route must contain Stops and Directions.
- parent - A parent object (optional).
Cancels a running reroute task.
If rerouting is in progress, this method will interrupt the background route task process.
Disables automatic rerouting.
TaskWatcher RouteTracker::enableRerouting(RouteTask *routeTask, const RouteParameters &routeParameters, ReroutingStrategy strategy, bool visitFirstStopOnStart)
Enables rerouting functionality of route tracker.
- routeTask - The RouteTask capable of solving routes on the same network used by the original route. This is usually the same RouteTask that was used to create the route being tracked. It will be used for rerouting in background thread.
- routeParameters - The RouteParameters that define parameters for the rerouting RouteTask.. The RouteParameters will be used for rerouting in background thread. The following properties will be ignored:
- strategy - A ReroutingStrategy that determines how route tracker should deal with remaining stops/waypoints during reroute process (reroute to next waypoint by default).
- visitFirstStopOnStart - A flag that forces route tracker to navigate to first stop of route.
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.
[signal] void RouteTracker::enableReroutingCompleted(QUuid taskId)
Emitted when the enableRerouting asynchronous operation completes.
- taskId - The task ID of the enableRerouting operation.
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.
Returns whether routes are automatically regenerated when tracking status is off-route.
[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.
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().
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).
The switchToNextDestinationCompleted signal will emit once the operation is complete.
[signal] void RouteTracker::switchToNextDestinationCompleted(QUuid taskId)
Emitted when the switchToNextDestination asynchronous operation completes.
- taskId - The task ID of the switchToNextDestination operation.
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.
[signal] void RouteTracker::trackLocationCompleted(QUuid taskId)
Emitted when the trackLocation asynchronous operation completes.
- taskId - The task ID of the trackLocation operation.
TrackingStatus *RouteTracker::trackingStatus() const
Returns tracker status for the current location on the route.
[signal] void RouteTracker::trackingStatusChanged(Esri::ArcGISRuntime::TrackingStatus *trackingStatus)
Emitted when trackingStatus changes.
- trackingStatus - current TrackingStatus.
Returns the unit system that will be used for generating route guidance, expressed as an enumeration.
See also setVoiceGuidanceUnitSystem.