Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minDistance/minInterval filtering does not work (lastLocation property has never been set on first pass inside GPSRequest) #318

Closed
hamzaozturk opened this issue Dec 23, 2020 · 1 comment
Assignees
Labels
Milestone

Comments

@hamzaozturk
Copy link
Contributor

hamzaozturk commented Dec 23, 2020

public private(set) var lastLocation: CLLocation?

property has never been set, so minDistance and minTimeInterval checks do not work.

if let previousLocation = lastLocation {
    if options.minDistance > kCLDistanceFilterNone,
       previousLocation.distance(from: data) > options.minDistance {
        return .notMinDistance // minimum distance since last location is not respected.
    }
    
    if let minInterval = options.minTimeInterval,
       previousLocation.timestamp.timeIntervalSince(Date()) >= minInterval {
        return .notMinInterval // minimum time interval since last location is not respected.
    }
}
@malcommac malcommac changed the title lastLocation property has never been set lastLocation property has never been set on first pass inside GPSRequest (minDistance/minInterval filtering does not work) Dec 24, 2020
@malcommac malcommac changed the title lastLocation property has never been set on first pass inside GPSRequest (minDistance/minInterval filtering does not work) minDistance/minInterval filtering does not work (lastLocation property has never been set on first pass inside GPSRequest) Dec 24, 2020
@malcommac malcommac added this to the 5.0.3 milestone Dec 24, 2020
@malcommac malcommac added the bug label Dec 24, 2020
@malcommac malcommac self-assigned this Dec 24, 2020
@malcommac
Copy link
Owner

Thank you for your analysis. Yes in fact lastLocation has never been set on first valid location therefore filtering never worked. I fixed it for 5.0.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants