Skip to content

Commit

Permalink
fix #318: store lastLocation value and fix minTimeInterval and minDis…
Browse files Browse the repository at this point in the history
…tance filtering
  • Loading branch information
malcommac committed Dec 24, 2020
1 parent b0b120f commit 19de19e
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ public class GPSLocationRequest: RequestProtocol, Codable {
}

if let previousLocation = lastLocation {
// We have already received a previous valid location so we'll
// also check for distance and interval if required and eventually dispatch value.
if options.minDistance > kCLDistanceFilterNone,
previousLocation.distance(from: data) > options.minDistance {
return .notMinDistance // minimum distance since last location is not respected.
Expand All @@ -152,6 +154,9 @@ public class GPSLocationRequest: RequestProtocol, Codable {
}
}

// Store previous value because it was validated.
lastLocation = data

return nil
}

Expand Down

0 comments on commit 19de19e

Please sign in to comment.