LocationSimulator (API Reference)
Class LocationSimulator
Use the LocationSimulator to generate locations along a route or a GPX document. It notifies
the registered object about the current location at a fixed interval. In order to customize
the interval, see LocationSimulatorOptions.
The locations are closely matched to the shape and proceeded from the start to the
destination as found in the provided route or the GPX document.
When providing a route, the LocationSimulator uses a base speed taken from each span
found in the provided route object. This base speed can be multiplied upfront
with a custom speedFactor for simulation purposes.
Effectively, this means that traffic-related information is not considered
to adjust the speed of the simulation.
For the GPXTrack, a speed is either based on timestamps in the original file or provided by the user. The following data is read from a GPXTrack and inserted into the provided Location object: latitude, longitude, altitude, time, bearingInDegrees, speedInMetersPerSecond, horizontalAccuracyInMeters, verticalAccuracyInMeters and locationTechnology.
Note that simulation works offline and independent from any map data
- only the information found in the provided route or GPX document is considered.
- When initializing the
LocationSimulatorwith a route, then interpolations take place between the vertices of the route's polyline. The distance between interpolated locations is a function of the current span's speed and the set notification interval. - When initializing the
LocationSimulatorwith a GPX file, theLocationSimulatordoes not apply any interpolation on the provided location data as this would shadow the recorded GPX data.
Notifications will stop after the entire route has been traveled.
Note:
Map-matched locations are only accessible from RouteProgress.
-
Constructor Summary
ConstructorsConstructorDescriptionLocationSimulator(GPXTrack gpxTrack, LocationSimulatorOptions options) Create a location simulatorLocationSimulator(Route route, LocationSimulatorOptions options) Creates a new instance of this class. -
Method Summary
Modifier and TypeMethodDescriptionGets aLocationListenerthat notifies on location updates.voidpause()Pauses sending notifications to the subscribers.voidresume()Resumes sending notifications to the subscribers.voidsetListener(LocationListener value) Sets aLocationListenerthat notifies on location updates.voidstart()Starts the location provider to send notifications to the subscribers.voidstop()Stops the location provider from sending notifications to the subscribers.
-
Constructor Details
-
Method Details
-
start
public void start()Starts the location provider to send notifications to the subscribers. Calling this method will always start the location simulator from the route's first
Waypoint, even if a simulation has already been started or stopped. -
stop
public void stop()Stops the location provider from sending notifications to the subscribers.
-
pause
public void pause()Pauses sending notifications to the subscribers. Calling this function has no effect when location provider is not started.
-
resume
public void resume()Resumes sending notifications to the subscribers. Calling this function has no effect when location provider is not started.
-
getListener
Gets a
LocationListenerthat notifies on location updates.- Returns:
The object that notifies on location updates.
-
setListener
Sets a
LocationListenerthat notifies on location updates.- Parameters:
value-The object that notifies on location updates.
-