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

Relaxing the accuracy level (both for horizontal accuracy and received interval) for room and house #265

Closed
jeden opened this issue Sep 20, 2019 · 7 comments
Assignees
Labels
Milestone

Comments

@jeden
Copy link

jeden commented Sep 20, 2019

If I call

LocationManager.shared.locateFromGPS(.continous, accuracy: .block, activity: .otherNavigation) { result in
  ...
}

multiple times at different times, and I start location tracking on each handler, only the first receives updates. The 2nd start receiving updates only if the first one is stopped.

For this to happen, I delayed the 2nd call to locateFromGPS by 10 seconds (using DispatchQueue.main.asyncAfter())

If I replace .continous with .oneShot it works fine instead.

Is it supposed to work this way, or is it a bug?

@abakhtin
Copy link
Contributor

Same issue if start continous request and ask for oneShot - OneShot will be waiting for location update based on continous request options

@phucdanghuu
Copy link

@abakhtin did you resolve this issue?

@eminisrafil
Copy link

I'm seeing the same. Any luck?

@adamisrafil
Copy link

Getting the same problem

@eminisrafil
Copy link

Also, LocationManager.shared.locateFromGPS(.continous, accuracy: .house, activity: .fitness, timeout: .absolute(30)) can have a pretty long delay under good wifi/cell conditions if only called once

@malcommac
Copy link
Owner

I tried to reproduce the issue but it seems to works fine:

   r1 = LocationManager.shared.locateFromGPS(.continous, accuracy: .block, activity: .otherNavigation) { result in
            print("#1 -> \(result)")
        }
        
        DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
            self.r2 = LocationManager.shared.locateFromGPS(.continous, accuracy: .city, activity: .otherNavigation) { result in
                print("#2 -> \(result)")
            }
        }
        
        DispatchQueue.main.asyncAfter(deadline: .now() + 60) {
            self.r1?.stop()
            debugPrint("-----------------------------------> STOP FIRST")
        }

I can receive both r1 and r2 requests.
I think the accuracy level house and room are to strict to be satisfied easily from the GPS receiver in normal conditions.

I've relaxed these parameters to the following levels:

for meters

public var value: CLLocationAccuracy {
            switch self {
            case .any:
                return CLLocationAccuracyAccuracyAny
            case .city:
                return 5000
            case .neighborhood:
                return 1000
            case .block:
                return 100
            case .house:
                return 60 // from 15 mt
            case .room:
                return 25 // from 5 mt
            case .custom(let value):
                return value
            }
        }

and interval:

  public var interval: TimeInterval {
            switch self {
            case .city:
                return 600.0
            case .neighborhood:
                return 300.0
            case .block:
                return 60.0
            case .house:
                return 40.0 // from 15secs
            case .room:
                return 20.0 // from 5secs
            default:
                return TimeInterval.greatestFiniteMagnitude
            }
        }

Since the next update.

@malcommac malcommac changed the title First handler only receiving location updates when using locateFromGPS in continous mode Relaxing the accuracy level (both for horizontal accuracy and received interval) for room and house Nov 17, 2019
@malcommac malcommac self-assigned this Nov 17, 2019
@malcommac malcommac added the bug label Nov 17, 2019
@malcommac malcommac added this to the 4.2.0 milestone Nov 17, 2019
@malcommac
Copy link
Owner

Let me know if it works for you

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

6 participants