0

使用 CLLocationManager 时,我得到了奇怪的读数。报告的纬度/经度是正确的,但行驶的距离很远。我已经实现了以下委托方法:

.h:
    CLLocationManager *mLocationManager;
    CLLocation *mStartDistance;

.m:
    - (void) locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation
    fromLocation:(CLLocation *)oldLocation
    {
        NSLog(@"%g", newLocation.coordinate.latitude);
        NSLog(@"%g", newLocation.coordinate.longitude);
        NSLog(@"%g", newLocation.altitude);
        NSLog(@"%g", newLocation.verticalAccuracy);

    if (mStartDistance == nil)
    { mStartDistance = newLocation; }

    CLLocationDistance dist = [newLocation getDistanceFrom:mStartDistance];
    NSLog(@"%gm", dist);
}

当我在我的设备上运行它时,我得到以下信息(经纬度被掩盖以保护有罪的嘿):

] xx.xxxx
] -yy.yyyy
] 0
] -1
] 0m

] xx.xxxx
] -yy.yyyy
] 0
] -1
] 0m

] xx.xxxx
] -yy.yyyy
] 0
] -1
] 376.133m <-- wat?

我不明白为什么它说我已经移动了+376m ..这就像+1200ft!

4

1 回答 1

2

如果您还记录您的newLocation.horizontalAccuracy.,您可能会看到前两次更新超过 400m。它没有使用 GPS(你在里面,它给你的高度垂直精度为 -1),而且手机三角测量最初可能非常糟糕。有时我的初始位置只能精确到 10 英里,但它仍然给出了最好的猜测。一旦获得更好的锁定,该点可以移动得相当快。

使用 CoreLocation 的部分技巧在于确定您自己的启发式方法来接受或拒绝更新。需要考虑的一些事情是水平精度、更新所花费的时间以及您收到的先前更新的数量。我已经看到之前在这个网站上讨论过很多方案。

于 2010-02-03T03:43:33.617 回答