Class SimulatedLocationDataSource
- java.lang.Object
-
- com.esri.arcgisruntime.location.LocationDataSource
-
- com.esri.arcgisruntime.location.SimulatedLocationDataSource
-
public final class SimulatedLocationDataSource extends LocationDataSource
A location data source that provides simulated device locations for testing.Use this data source to simulate location updates for a device. It uses a collection of
LocationDataSource.Location
that are sequentially passed toLocationDataSource.updateLocation(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.- Since:
- 100.8.0 for Android and 100.9.0 for Java SE
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.esri.arcgisruntime.location.LocationDataSource
LocationDataSource.ErrorChangedEvent, LocationDataSource.ErrorChangedListener, LocationDataSource.HeadingChangedEvent, LocationDataSource.HeadingChangedListener, LocationDataSource.Location, LocationDataSource.LocationChangedEvent, LocationDataSource.LocationChangedListener, LocationDataSource.Status, LocationDataSource.StatusChangedEvent, LocationDataSource.StatusChangedListener
-
-
Constructor Summary
Constructors Constructor Description SimulatedLocationDataSource()
Creates a simulated location data source.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getCurrentLocationIndex()
Gets the index of the item in the location list that provides the current location.double
getIterationRate()
Gets the rate over which thegetLocations()
list is iterated, default is 1.0.java.util.List<LocationDataSource.Location>
getLocations()
Gets an unmodifiable list of locations that are used in the data source.protected void
onStart()
Called fromLocationDataSource.startAsync()
.protected void
onStop()
Called from theLocationDataSource.stopAsync()
orLocationDataSource.stop()
method, subclasses should perform any necessary clean-up in this method; for example, stop streaming the location data, release resources, and so on.void
setCurrentLocationIndex(int index)
Sets the index of the item in the location list that provides the current location.void
setIterationRate(double iterationRate)
Sets the rate over which thegetLocations()
list is iterated, default is 1.0.void
setLocations(Polyline polyline)
Creates a list of locations using vertices from an input polyline.void
setLocations(Polyline polyline, SimulationParameters parameters)
Creates a list of locations along an input polyline based on simulation parameters.void
setLocations(java.lang.Iterable<LocationDataSource.Location> locations)
Sets a list of locations that are iterated sequentially.-
Methods inherited from class com.esri.arcgisruntime.location.LocationDataSource
addErrorChangedListener, addHeadingChangedListener, addLocationChangedListener, addStartedListener, addStatusChangedListener, getError, getStatus, isStarted, onStartCompleted, removeErrorChangedListener, removeHeadingChangedListener, removeLocationChangedListener, removeStartedListener, removeStatusChangedListener, setLastKnownLocation, startAsync, stop, stopAsync, updateHeading, updateLocation
-
-
-
-
Method Detail
-
setLocations
public void setLocations(java.lang.Iterable<LocationDataSource.Location> locations)
Sets a list of locations that are iterated sequentially.As the list of locations is iterated, the
LocationDataSource.LocationChangedEvent
is fired for each location. The frequency at which this data source iterates over the provided locations is determined bygetIterationRate()
. Populate the location list by callingsetLocations(Polyline)
or directly assigning a list of locations by this method.Note - the provided locations are copied from the Iterable, thus any subsequent changes to the Iterable won't have any affect on the list of locations returned by
getLocations()
.- Parameters:
locations
- a list of locations- Throws:
java.lang.IllegalArgumentException
- if locations is null or empty- Since:
- 100.8.0 for Android and 100.9.0 for Java SE
-
getLocations
public java.util.List<LocationDataSource.Location> getLocations()
Gets an unmodifiable list of locations that are used in the data source.As the list of locations is iterated, the
LocationDataSource.LocationChangedEvent
is fired for each location. The frequency at which this data source iterates over the provided locations is determined bygetIterationRate()
. Populate the location list by callingsetLocations(Polyline)
or directly assigning a list of locations bysetLocations(Iterable)
.- Returns:
- an unmodifiable list of locations that are iterated sequentially
- Since:
- 100.8.0 for Android and 100.9.0 for Java SE
-
getCurrentLocationIndex
public int getCurrentLocationIndex()
Gets the index of the item in the location list that provides the current location.This represents the index of the location that is currently used by this location data source to represent the current location. This can be used to either find which location in the
getLocations()
list is being used, or it can be used to forward/rewind/loop to a different location in thegetLocations
list usingsetCurrentLocationIndex(int)
.- Returns:
- the index of the current location in the location list
- Since:
- 100.8.0 for Android and 100.9.0 for Java SE
-
setCurrentLocationIndex
public void setCurrentLocationIndex(int index)
Sets the index of the item in the location list that provides the current location.Sets the index of the item in the location list that will be used by this location data source to represent the current location. The index can be used to forward/rewind/loop to a different location in the list returned by
getLocations()
.- Parameters:
index
- the index of the current location in the location list- Throws:
java.lang.IllegalArgumentException
- if index is negative- Since:
- 100.8.0 for Android and 100.9.0 for Java SE
-
getIterationRate
public double getIterationRate()
Gets the rate over which thegetLocations()
list is iterated, default is 1.0.The rate at which the locations are iterated over, controlling the time between location updates. The default value is 1.0, which updates the location once a second. To increase the frequency, set this property to a higher value, e.g. 2.0 = 2x speedup. To decrease frequency, set this property to a lower value, e.g. 0.5 = 2x slowdown. This property does not affect the time property of the items in the
getLocations
(they are always 1 second apart).- Returns:
- the iteration rate over the location list
- Since:
- 100.8.0 for Android and 100.9.0 for Java SE
-
setIterationRate
public void setIterationRate(double iterationRate)
Sets the rate over which thegetLocations()
list is iterated, default is 1.0.The rate at which the locations are iterated over, controlling the time between location updates. The default value is 1.0, which updates the location once a second. To increase the frequency, set this property to a higher value, e.g. 2.0 = 2x speedup. To decrease frequency, set this property to a lower value, e.g. 0.5 = 2x slowdown. This property does not affect the time property of the items in the
getLocations
(they are always 1 second apart).- Parameters:
iterationRate
- the iteration rate over the location list- Throws:
java.lang.IllegalArgumentException
- if iterationRate is zero or negative- Since:
- 100.8.0 for Android and 100.9.0 for Java SE
-
setLocations
public void setLocations(Polyline polyline)
Creates a list of locations using vertices from an input polyline.The generated locations are available from the
getLocations()
method.Based on the inputs, these location properties are set:
- time stamp
- position
- velocity
- horizontal accuracy
- vertical accuracy
- last known
- course
- Parameters:
polyline
- a polyline that defines a simulated route of travel- Throws:
java.lang.IllegalArgumentException
- if polyline is null or empty- Since:
- 100.8.0 for Android and 100.9.0 for Java SE
-
setLocations
public void setLocations(Polyline polyline, SimulationParameters parameters)
Creates a list of locations along an input polyline based on simulation parameters.The generated locations are available from the
getLocations()
method. Distance between each location on the polyline depends on velocity. For example if velocity is 10 meters per second then distance between 2 locations will be 10 meters. TheLocationDataSource.Location.getTimeStamp()
values will always be one second apart.Based on the inputs, these location properties are set:
- time stamp
- position
- velocity
- horizontal accuracy
- vertical accuracy
- last known
- course
- Parameters:
polyline
- a polyline that defines a simulated travel pathparameters
- a SimulationParameters used in creating the locations from the polyline. If it is null, it is equivalent to callsetLocations(Polyline)
- Throws:
java.lang.IllegalArgumentException
- if polyline is null or empty- Since:
- 100.8.0 for Android and 100.9.0 for Java SE
-
onStart
protected void onStart()
Description copied from class:LocationDataSource
Called fromLocationDataSource.startAsync()
. Subclasses should implement this method to prepare for starting the data source. TheLocationDataSource.onStartCompleted(Throwable)
method must be called by the subclass once the location data source has finished its starting process.- Specified by:
onStart
in classLocationDataSource
-
onStop
protected void onStop()
Description copied from class:LocationDataSource
Called from theLocationDataSource.stopAsync()
orLocationDataSource.stop()
method, subclasses should perform any necessary clean-up in this method; for example, stop streaming the location data, release resources, and so on.- Specified by:
onStop
in classLocationDataSource
-
-