我正在玩iPhone SDK,我想在我的应用程序中显示当前的速度。有这么多的应用程序可以做到非常精确,特别是对于跑步或骑自行车等低速运动。我见过的最好的是RunKeeper。为什么我的CLLocation速度不准确?
但是,在我的应用程序中,速度是绝对不准确的。在低速时它总是无效的,只有在更高的速度下它才会显示一些数值,但它们很少被更新并且不是很有用。
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation {
if (newLocation.timestamp > oldLocation.timestamp &&
newLocation.verticalAccuracy > 0.0f && // GPS is active
newLocation.horizontalAccuracy < 500.0f && // GPS is active
//newLocation.horizontalAccuracy < kCLLocationAccuracyHundredMeters && // good quality GPS signal
//newLocation.speed > 1.0f && // enough movment for accurate speed and course measurement
oldLocation != nil) // oldLocation is nil on the first reading
{
double speed = (newLocation.speed * 3.6);
[self updateDisplayWithSpeed:speed];
//double direction = newLocation.course;
}
}
有没有人有工作代码?或者你能告诉我我的问题吗?
你有一个代码示例来处理第一个问题?或者,这只是检查与前一个位置的时间戳? – 2014-03-20 08:40:25