使用手机信号塔进行位置跟踪,降低噪音

时间:2017-03-03 12:16:12

标签: ios swift algorithm location

我正在跟踪用户的位置以获得旅行日志。为此我使用细胞塔三角测量。我的应用程序会收到有关主要位置更改的通知,并将位置保存到数据库。后来我尝试减少录制的噪音。

一切都运行正常,除了我有时在单元格塔之间记录虚拟跳跃,如下所示:

zoomed out zoomed in

在录制过程中,用户没有旅行。

我尝试使用此算法降低噪音,但它无法正常工作。 您有其他想法如何删除它吗?

var invalidLocationIDs = [String]()

        for index in 0...points.count-3 {

            let point0 = points[index+0]
            let point1 = points[index+1]
            let point2 = points[index+2]

            let location0 = CLLocation(latitude: point0.latitude, longitude: point0.longitude)
            let location1 = CLLocation(latitude: point1.latitude, longitude: point1.longitude)
            let location2 = CLLocation(latitude: point2.latitude, longitude: point2.longitude)

            let distanceA = location0.distance(from: location1)
            let distanceB = location0.distance(from: location2)

            if distanceB < distanceA {
                invalidLocationIDs.append(point2.locationID)
            }
        }
        deleteLocationsWithIDs(locationIDs: invalidLocationIDs)

这是跟踪位置的算法:

self.locationManager.requestAlwaysAuthorization()
                    self.locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters
                    self.locationManager.distanceFilter = 200
                    self.locationManager.pausesLocationUpdatesAutomatically = false
                    self.locationManager.allowsBackgroundLocationUpdates = true
                    self.locationManager.activityType = .other

0 个答案:

没有答案