iOS Location Accuracy
Asked Answered
C

3

5

Hello i am using location in iOS app i set the accuracy like this:

 locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters

and i am using this function to check the accuracy

func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
    print(manager.location!.horizontalAccuracy)

    if locations.last!.horizontalAccuracy <= manager.desiredAccuracy{
        print(manager.location)
        location = locations.last!
        locationManager.stopUpdatingLocation()
        locationManager = nil           
    }
}

The problem is that the accuracy stack to 1414 and never goes to 100. Is there any way to fix that problem?

Chilopod answered 22/12, 2015 at 17:40 Comment(1)
Try testing outdoors, with WiFi enabled the triangulation should give you and average of 65m.Scandalmonger
S
4

It's a limitation of the hardware, possible combined with your particular location. If you are indoors writing your code then GPS isn't going to work (try walking to a window), so you rely on WiFi which might just have very bad accuracy where you are, or on cell towers which isn't very accurate anywhere.

Sinusoid answered 22/12, 2015 at 17:59 Comment(0)
W
4

iOS uses multiple hardware options to determine location: cell tower, wifi access points, gps. The options are listed in increasing accuracy AND power consumption order.

iOS uses desiredAccuracy as a hint of which hardware it should engage to serve your request, and the OS will try to avoid activating the hardware it believes is unnecessary in order to achieve the desired accuracy.

I believe Apple does not offer any specifics as to what the threshold values are.

It looks like in your case iOS does not engage WiFi AP hardware (or might be unable to connect to a server to access the AP database, or there is not enough known APs around you), thus all location readings you get are from cell tower triangulation.

You may want to either

  • request higher accuracy than you need, but stop updates as soon as you get required accuracy, or
  • (assuming iOS9) use the new requestLocation() method, which is at least more battery-friendly, and at most might try to make more intelligent decisions on what hardware to activate - note I did not test the "at most" assumption, would be interested to learn if it is correct.

Also, this is not in the books, but you can tell if location reading is from GPS by looking at speed value, if it is invalid (less than zero), it is NOT GPS location.

Hope this helps, -- Alex

Wester answered 22/12, 2015 at 18:55 Comment(0)
F
1

What do horizontalAccuracy and verticalAccuracy of a CLLocation refer to?

The 1414 for horizontalAccuracy indicates that the horizontal (lat/lon) position could be up to 1414m off (this is just an estimated error). This is probably a location determined by cell tower triangulation or WiFi location data. GPS locations usually report 100m or better.

To build, it seems that 1414 is the constant the CLLocationManager gives if it has determined your location based on cell tower triangulation. In my testing, if it has determined your location based on wifi it gives a horizontal accuracy of 65m

Falla answered 22/12, 2015 at 17:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.