【问题标题】:iOS CLLocationManager: Removing spikesiOS CLLocationManager:去除尖峰
【发布时间】:2016-02-25 10:55:14
【问题描述】:

在 Swift 或 Objective-C 中,我们可以轻松地创建一个 CLLocationmanager 并开始跟踪我们的位置。我们还可以设置一个 distanceFilter,它定义了设备在生成更新事件之前必须水平移动的最小距离(以米为单位)。我的 Swift 代码:

override func viewDidLoad() {
    super.viewDidLoad()

    manager = CLLocationManager()
    manager.delegate = self
    manager.distanceFilter = 10
    manager.desiredAccuracy = kCLLocationAccuracyBest
    manager.startUpdatingLocation()
}

但在某些情况下,如果 gps 精度较低(即在树林、隧道、高层建筑之间...),则会生成不正确的尖峰。 CLLocationManager 缺少一个属性或方法来定义更新的最大距离以清除这种尖峰。

现在,我自己处理最大距离,将可用位置存储到单独的数组中:

var myLocations: [CLLocation] = []

func calculateDistanceBetweenTwoLocations(start:CLLocation,destination:CLLocation) {
    var distanceInMeters = start.distanceFromLocation(destination)      
    if distanceInMeters < 20 {
        myLocations.append(destination)
    }
} 

有没有更准确的方法?

【问题讨论】:

    标签: ios objective-c xcode swift cllocationmanager


    【解决方案1】:

    您正在寻找的是应用于 GPS 数据的 Data cleansing 方法。

    如果你有时间,可以阅读this PDF about it

    解释的一些方法是获取 5 个并发点并确保它是具有特定精度参数的集群的一部分。如果不是,请删除已出的点。

    【讨论】:

      猜你喜欢
      • 2017-08-14
      • 1970-01-01
      • 2014-05-29
      • 1970-01-01
      • 2012-12-28
      • 1970-01-01
      • 2010-09-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多