iPhone CLLocationManager每0.5秒更新一次

| 对于需要根据GPS进行大量计算的应用,我需要每0.5秒获取一次纬度/经度和速度,这样才能非常准确并避免延迟。 我在用:
[locationManager setDesiredAccuracy:kCLLocationAccuracyBestForNavigation];
- locationManager:didUpdateToLocation:fromLocation:
函数将值存储在3个变量中:
newLatitude
newLongitude
newSpeed
0.55ѭ对象,每0.5秒调用一次函数。 参见下面的图表,该图表由Excel生成,代表18秒内的纬度值: 我们可以清楚地看到我们每秒都有一次位置更新,而不是期望的每0.5秒更新一次。我在办公室周围进行样品采样,因此速度在0到65 MPH之间变化。因此,当我以50MPH的速度行驶时,应该每0.5s从iPhone获得不同的纬度/经度/速度值,对吗? 如果您对
CLLocationManager
物体的精度有所了解,请告诉我如何每0.5秒获取一次位置更新。 谢谢!     
已邀请:
您无法告诉位置管理器您希望多久更新一次,而只能在它选择给您更新时作出响应。无法确定获取更新的时间,这取决于查找WiFi信号和GPS信号的难易程度。     
[self.locationManager startUpdatingLocation];
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self     selector:@selector(myTimerFunc) userInfo:nil repeats:YES];

- (void)myTimerFunc
{
    CLLocation location = self.locationManager.location;
    // do work here //
}

 - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
    // do nothing here //
}
    

要回复问题请先登录注册