次のコードを使用して、0.1 秒ごとに位置を更新しています -
- (void)viewDidLoad
{
[super viewDidLoad];
CLController = [[CoreLocationController alloc] init];
CLController.delegate = self;
// set auto update timer
currentTimer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self
selector:@selector(updatestart) userInfo:nil repeats:YES];
}
-(void)updatestart
{
[CLController.locMgr startUpdatingLocation];
}
そして、私は速度を計算しようとしています
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
[locMgr stopUpdatingLocation];
NSLog(@"%f",newLocation.speed);
}
メートル/秒で速度を取得していますが、しばらくするとプロセスが遅くなり、移動を停止しても速度が計算されています。
私が望むのは、正確な速度を取得し、速度が時速 12 km を超えた場合にアラートを表示することです。
同じものを見つけるために使用できる他のアプローチはありますか?
ありがとう..