LocationSimulator
public class LocationSimulator
extension LocationSimulator: NativeBase
extension LocationSimulator: Hashable
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.
-
Creates a new instance of this class.
Throws
InstantiationErrorIndicates what went wrong when the instantiation was attempted.Declaration
Swift
public init(route: Route, options: LocationSimulatorOptions) throwsParameters
routeThe route to travel.
optionsThe options to specify how the location simulator will behave.
-
Create a location simulator
Throws
InstantiationErrorIndicates what went wrong when the instantiation was attempted.Declaration
Swift
public init(gpxTrack: GPXTrack, options: LocationSimulatorOptions) throwsParameters
gpxTrackThe GPX track to travel.
optionsThe options to specify how the location simulator will behave.
-
The object that notifies on location updates.
Declaration
Swift
public weak var delegate: LocationDelegate? { get set } -
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.Declaration
Swift
public func start() -
Stops the location provider from sending notifications to the subscribers.
Declaration
Swift
public func stop() -
Pauses sending notifications to the subscribers. Calling this function has no effect when location provider is not started.
Declaration
Swift
public func pause() -
Resumes sending notifications to the subscribers. Calling this function has no effect when location provider is not started.
Declaration
Swift
public func resume()