SimulatedLocationDataSource Class

  • SimulatedLocationDataSource
  • class Esri::ArcGISRuntime::SimulatedLocationDataSource

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

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

    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(const Esri::ArcGISRuntime::Location&). 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

    [explicit] SimulatedLocationDataSource::SimulatedLocationDataSource(QObject *parent)

    Creates a simulated location data source with an optional parent.

    [override virtual] SimulatedLocationDataSource::~SimulatedLocationDataSource()


    int SimulatedLocationDataSource::currentLocationIndex() const

    The index of the item in the location collection that provides the current location

    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(const Esri::ArcGISRuntime::Location&) every 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 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(const Esri::ArcGISRuntime::Location&) is fired for each location. The frequency at which AbstractLocationDataSource::updateLocation(const Esri::ArcGISRuntime::Location&) is called is determined by iterationRate. Populate the collection by calling setLocationsWithPolyline(const Esri::ArcGISRuntime::Polyline&) or by directly assigning a collection of Location to this property.

    See also setLocations().

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

    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 - A polyline that defines a simulated travel path.

    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.

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