Skip To Content ArcGIS for Developers Sign In Dashboard

SimulatedLocationDataSource Class

class Esri::ArcGISRuntime::SimulatedLocationDataSource

A location data source that provides simulated device locations for testing. More...

Header: #include <SimulatedLocationDataSource>
Since: Esri::ArcGISRuntime 100.8
Inherits: Esri::ArcGISRuntime::AbstractLocationDataSource

This class was introduced in Esri::ArcGISRuntime 100.8.

Public Functions

SimulatedLocationDataSource(QObject *parent)
virtual ~SimulatedLocationDataSource() override
int currentLocationIndex() const
double iterationRate() const
QList<Esri::ArcGISRuntime::Location> locations() const
void setCurrentLocationIndex(int currentLocationIndex)
void setIterationRate(double iterationRate)
void setLocations(const QList<Esri::ArcGISRuntime::Location> &locations)
void setLocationsWithPolyline(const Esri::ArcGISRuntime::Polyline &polyline)
void setLocationsWithPolyline(const Esri::ArcGISRuntime::Polyline &polyline, Esri::ArcGISRuntime::SimulationParameters *simulationParameters)

Protected Slots

virtual void onStart() override
virtual void onStop() override

Detailed Description

Use this data source to simulate location updates for a device. It uses a collection of Location that are sequentially passed to AbstractLocationDataSource::updateLocation. The location collection can be derived from vertices in a provided polyline, generated evenly along a polyline based on a travel velocity, or assigned to the collection directly.

Member Function Documentation

SimulatedLocationDataSource::SimulatedLocationDataSource(QObject *parent)

Creates the new instance of the data source with an optional parent.

[override virtual protected slot] void SimulatedLocationDataSource::onStart()

Reimplements: AbstractLocationDataSource::onStart().

Reacts to start requests by starting the simulation.

Note: You should not call this method directly - use start instead.

[override virtual protected slot] void SimulatedLocationDataSource::onStop()

Reimplements: AbstractLocationDataSource::onStop().

Reacts to stop requests by stopping the simulation.

Note: You should not call this method directly - use stop instead.

[override virtual] SimulatedLocationDataSource::~SimulatedLocationDataSource()


int SimulatedLocationDataSource::currentLocationIndex() const

Returns the index of the item in the locations list that is currently being used.

You can get this value to find which item in the SimulatedLocationDataSource::locations collection represents the current location. You can also provide a new index to skip to a different location in the collection.

See also setCurrentLocationIndex().

double SimulatedLocationDataSource::iterationRate() const

Returns the rate over which the SimulatedLocationDataSource::locations collection is iterated.

This controls the frequency of location updates for the simulated location data source. The default value is 1.0, resulting in calls to AbstractLocationDataSource::updateLocation once per second. To increase the frequency, provide a higher value. A value of 2.0, for example, doubles the frequency of location updates. To slow down updates, provide a lower value. A value of 0.5, for example, decreases location updates by a factor of two. The iteration rate does not affect the Location::timestamp property of the items in the SimulatedLocationDataSource::locations (they are always 1 second apart).

See also setIterationRate().

QList<Esri::ArcGISRuntime::Location> SimulatedLocationDataSource::locations() const

Returns a list of location objects.

As the collection is iterated, the AbstractLocationDataSource::updateLocation is called for each location. The frequency at which AbstractLocationDataSource::updateLocation is called is determined by SimulatedLocationDataSource::iterationRate. Populate the collection by calling SimulatedLocationDataSource::setLocationsWithPolyline or by directly assigning a collection of Location objects in a list.

See also setLocations().

void SimulatedLocationDataSource::setCurrentLocationIndex(int currentLocationIndex)

Sets the currentLocationIndex to currentLocationIndex.

See also currentLocationIndex.

void SimulatedLocationDataSource::setIterationRate(double iterationRate)

Sets the iterationRate to iterationRate.

See also iterationRate.

void SimulatedLocationDataSource::setLocations(const QList<Esri::ArcGISRuntime::Location> &locations)

Sets the locations to locations.

See also locations.

void SimulatedLocationDataSource::setLocationsWithPolyline(const Esri::ArcGISRuntime::Polyline &polyline)

Creates a collection of locations using vertices from the input polyline.

The result locations can be obtained from SimulatedLocationDataSource::locations. These properties are populated based on the inputs: Location::timestamp, Location::position, Location::velocity,

These properties is calculated based on the inputs: Location::course

These properties are not set: Location::horizontalAccuracy, Location::verticalAccuracy, Location::isLastKnown.

  • polyline - The polyline

void SimulatedLocationDataSource::setLocationsWithPolyline(const Esri::ArcGISRuntime::Polyline &polyline, Esri::ArcGISRuntime::SimulationParameters *simulationParameters)

Creates a collection of locations along an input polyline based on simulation parameters.

The generated locations are available from the SimulatedLocationDataSource::locations property. Distance between each location on the polyline is determined by the value of SimulationParameters::velocity. If velocity is 10 meters per second, for example, the distance between locations will be 10 meters. The Location::timestamp values will always be 1 second apart. These location properties will be set based on the following inputs:

The Location::course property will be calculated based on the inputs. The Location::isLastKnown property will not be set.

Feedback on this topic?