Update some intervals, throw out the last postion log if the latest one is < 10 meters away.

This commit is contained in:
Garth Vander Houwen 2023-11-26 17:50:10 -08:00
parent f12eed755d
commit 906d22c350
3 changed files with 5 additions and 5 deletions

View file

@ -85,7 +85,6 @@ enum UserTrackingModes: Int, CaseIterable, Identifiable {
}
enum LocationUpdateInterval: Int, CaseIterable, Identifiable {
case fiveSeconds = 5
case tenSeconds = 10
case fifteenSeconds = 15
case thirtySeconds = 30
@ -97,8 +96,6 @@ enum LocationUpdateInterval: Int, CaseIterable, Identifiable {
var id: Int { self.rawValue }
var description: String {
switch self {
case .fiveSeconds:
return "interval.five.seconds".localized
case .tenSeconds:
return "interval.ten.seconds".localized
case .fifteenSeconds:

View file

@ -73,6 +73,7 @@ enum ScreenOnIntervals: Int, CaseIterable, Identifiable {
enum ScreenCarouselIntervals: Int, CaseIterable, Identifiable {
case off = 0
case fifteenSeconds = 15
case thirtySeconds = 30
case oneMinute = 60
case fiveMinutes = 300
@ -84,6 +85,8 @@ enum ScreenCarouselIntervals: Int, CaseIterable, Identifiable {
switch self {
case .off:
return "off".localized
case .fifteenSeconds:
return "interval.fifteen.seconds".localized
case .thirtySeconds:
return "interval.thirty.seconds".localized
case .oneMinute:

View file

@ -256,10 +256,10 @@ func upsertPositionPacket (packet: MeshPacket, context: NSManagedObjectContext)
guard let mutablePositions = fetchedNode[0].positions!.mutableCopy() as? NSMutableOrderedSet else {
return
}
/// Don't save the same position over and over.
/// Don't save nearly the same position over and over. If the next position is less than 10 meters from the new position, delete the previous position and save the new one.
if mutablePositions.count > 0 {
let mostRecent = mutablePositions.lastObject as! PositionEntity
if mostRecent.latitudeI == position.latitudeI && mostRecent.longitudeI == position.longitudeI {
if mostRecent.coordinate.distance(from: position.coordinate) < 10 {
mutablePositions.remove(mostRecent)
}
}