0

基本上我的应用程序中的位置控制器工作。但是如果它运行了很长时间,它会在不识别的情况下得到错误的位置。我认为 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;
}

}

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

4

1 回答 1

1

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

// check that the location data isn't older than 60 seconds
if ([newLocation.timestamp timeIntervalSinceReferenceDate] < [NSDate timeIntervalSinceReferenceDate] - 60) {
    return;
}
于 2010-06-25T15:16:00.993 回答