TripSegmentator
final class TripSegmentator : NSObject, ObservableObject, CLLocationManagerDelegate
Used for recording location data. Uses CoreMotion to classify the activity and only store trip information when travling on a automotive vheicle.
-
mapView to update with new location and classification data.
Declaration
Swift
weak var mapView: MKMapView?
-
Only used for debugging and showing information on the debug map
Declaration
Swift
var segments: [LocationsSegment]
-
The identified motion activity
Declaration
Swift
@Published var activity: CMMotionActivity.Classification { get set }
-
Stores trips durring the tracking session
Declaration
Swift
var trips: [Trip]
-
Initializer, setup the delegate and the locationmanager.
Declaration
Swift
override init()
-
Delegate method called when new location data is available.
Declaration
Swift
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
-
Required function. If something fails we just print it.
Declaration
Swift
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error)
-
Will classify the users activity and store trip data untill
stopMinitoring()
is called.Declaration
Swift
func startMonitoring()
-
Stops monitoring and empties logged trips and segments.
Declaration
Swift
func stopMonitoring() -> [Trip]