【问题标题】:GPS gets wrong PositionGPS 定位错误
【发布时间】:2010-06-25 12:27:23
【问题描述】:

基本上我的应用程序中的位置控制器工作。但是如果它运行了很长时间,它会在不识别的情况下得到错误的位置。我认为 gps 缓冲区溢出或类似的。

这是我的 didUpdate-Event 代码

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {

//nonvalid
if (signbit(newLocation.horizontalAccuracy))
    return;

//0.0 is no valid location here
if ((abs(newLocation.coordinate.latitude) < 1.0e-05) || (abs(newLocation.coordinate.longitude) < 1.0e-05))
    return;

if (newLocation.horizontalAccuracy > DBL_MAX)
    return;


@synchronized(self)
{
    currentCoordinate.latitude = newLocation.coordinate.latitude;
    currentCoordinate.longitude = newLocation.coordinate.longitude;
}

}

是否可以刷新位置缓冲区? 还是用三角测量的值来控制位置?

【问题讨论】:

  • 您不必在标题中包含“iPhone”,只要添加标签“iphone”即可。 :)
  • 你说的时间是多久?苹果似乎不太可能对此进行彻底测试;)

标签: iphone objective-c localization gps cllocationmanager


【解决方案1】:

您还应该测试位置数据的年龄。这是最接近刷新缓存的方法(这是不可能的)。检查timestamp 属性,如果太旧则拒绝更新。

// check that the location data isn't older than 60 seconds
if ([newLocation.timestamp timeIntervalSinceReferenceDate] < [NSDate timeIntervalSinceReferenceDate] - 60) {
    return;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-13
    • 2016-07-01
    • 1970-01-01
    • 2017-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多