|
@@ -10,10 +10,10 @@ class LocationManager: NSObject, CLLocationManagerDelegate {
|
|
init(context: DcContext) {
|
|
init(context: DcContext) {
|
|
dcContext = context
|
|
dcContext = context
|
|
locationManager = CLLocationManager()
|
|
locationManager = CLLocationManager()
|
|
- locationManager.distanceFilter = 50
|
|
|
|
|
|
+ locationManager.distanceFilter = 25
|
|
locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters
|
|
locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters
|
|
locationManager.allowsBackgroundLocationUpdates = true
|
|
locationManager.allowsBackgroundLocationUpdates = true
|
|
- //locationManager.pausesLocationUpdatesAutomatically = true
|
|
|
|
|
|
+ locationManager.pausesLocationUpdatesAutomatically = false
|
|
locationManager.activityType = CLActivityType.fitness
|
|
locationManager.activityType = CLActivityType.fitness
|
|
super.init()
|
|
super.init()
|
|
locationManager.delegate = self
|
|
locationManager.delegate = self
|
|
@@ -106,8 +106,7 @@ class LocationManager: NSObject, CLLocationManagerDelegate {
|
|
|
|
|
|
return !isNewLocationOutdated(newLocation: newLocation) &&
|
|
return !isNewLocationOutdated(newLocation: newLocation) &&
|
|
hasValidAccuracy(newLocation: newLocation) &&
|
|
hasValidAccuracy(newLocation: newLocation) &&
|
|
- (isSignificantlyMoreAccurate(newLocation: newLocation, lastLocation: lastLocation) ||
|
|
|
|
- isMoreAccurate(newLocation: newLocation, lastLocation: lastLocation) && hasLocationChanged(newLocation: newLocation, lastLocation: lastLocation) ||
|
|
|
|
|
|
+ (isMoreAccurate(newLocation: newLocation, lastLocation: lastLocation) && hasLocationChanged(newLocation: newLocation, lastLocation: lastLocation) ||
|
|
hasLocationSignificantlyChanged(newLocation: newLocation, lastLocation: lastLocation))
|
|
hasLocationSignificantlyChanged(newLocation: newLocation, lastLocation: lastLocation))
|
|
}
|
|
}
|
|
|
|
|
|
@@ -115,11 +114,6 @@ class LocationManager: NSObject, CLLocationManagerDelegate {
|
|
return newLocation.horizontalAccuracy >= 0
|
|
return newLocation.horizontalAccuracy >= 0
|
|
}
|
|
}
|
|
|
|
|
|
- func isSignificantlyMoreAccurate(newLocation: CLLocation, lastLocation: CLLocation) -> Bool {
|
|
|
|
-// logger.debug("LOCATION isSignificantlyMoreAccurate: \(lastLocation.horizontalAccuracy - newLocation.horizontalAccuracy > 25)")
|
|
|
|
- return lastLocation.horizontalAccuracy - newLocation.horizontalAccuracy > 25
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
func isMoreAccurate(newLocation: CLLocation, lastLocation: CLLocation) -> Bool {
|
|
func isMoreAccurate(newLocation: CLLocation, lastLocation: CLLocation) -> Bool {
|
|
// logger.debug("LOCATION: isMoreAccurate \(lastLocation.horizontalAccuracy - newLocation.horizontalAccuracy > 0)")
|
|
// logger.debug("LOCATION: isMoreAccurate \(lastLocation.horizontalAccuracy - newLocation.horizontalAccuracy > 0)")
|
|
return lastLocation.horizontalAccuracy - newLocation.horizontalAccuracy > 0
|
|
return lastLocation.horizontalAccuracy - newLocation.horizontalAccuracy > 0
|