iOS 定位准确度

iOS Location Accuracy

您好,我在 iOS 应用程序中使用位置,我设置的准确度如下:

 locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters

我正在使用这个函数来检查准确性

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           
    }
}

问题是准确度叠加到 1414 而永远不会达到 100。有什么办法可以解决这个问题吗?

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

这是硬件的限制,可能与您的特定位置相结合。如果你在室内编写代码,那么 GPS 将无法工作(尝试走到 window),所以你依赖 WiFi,它可能只是在你所在的地方或在手机信号塔上的准确性非常差'在任何地方都非常准确。

iOS 使用多种硬件选项来确定位置:基站、wifi 接入点、gps。这些选项以精度和功耗递增的顺序列出。

iOS 使用 desiredAccuracy 作为它应该使用哪个硬件来满足您的请求的提示,并且 OS 将尽量避免激活它认为不必要的硬件以实现所需的准确性。

我相信 Apple 没有提供任何关于阈值的细节。

您的情况 iOS 似乎没有使用 WiFi AP 硬件(或者可能无法连接到服务器以访问 AP 数据库,或者没有足够的 known 你周围的接入点),因此你得到的所有位置读数都来自蜂窝塔三角测量。

您可能想要

  • 请求比您需要的更高的准确度,但一旦达到所需的准确度就停止更新,或者
  • (假设 iOS9)使用新的 requestLocation() 方法,它至少对电池更友好,最多可以尝试对激活哪些硬件做出更智能的决定 - 注意我没有测试"at most"假设,如果它是正确的,有兴趣了解。

此外,这不是书上的,但您可以通过查看速度值来判断位置读数是否来自 GPS,如果无效(小于零),则不是 GPS 位置。

希望这对您有所帮助, -- 亚历克斯