gpt4 book ai didi

ios - 核心位置检测到的最低速度

转载 作者:行者123 更新时间:2023-12-01 17:59:40 28 4
gpt4 key购买 nike

我正在尝试开发一个显示用户速度和其他数据的应用程序。

我想知道“核心位置”可以检测到的最低速度是多少。当我在街上移动时,读数为0.00。

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation 
{
//i display some other data here
speedLbl.text =[NSString stringWithFormat:@"Speed: %f km/hr",([lastLocation speed]*3.6)];
}

最佳答案

您应该设置distanceFilterdesiredAccuracy属性。

这是Jano的代码

self.locationManager = [[[CLLocationManager alloc] init] autorelease];
self.locationManager.delegate = self;

/* Pinpoint our location with the following accuracy:
*
* kCLLocationAccuracyBestForNavigation highest + sensor data
* kCLLocationAccuracyBest highest
* kCLLocationAccuracyNearestTenMeters 10 meters
* kCLLocationAccuracyHundredMeters 100 meters
* kCLLocationAccuracyKilometer 1000 meters
* kCLLocationAccuracyThreeKilometers 3000 meters
*/
self.locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;

/* Notify changes when device has moved x meters.
* Default value is kCLDistanceFilterNone: all movements are reported.
*/
self.locationManager.distanceFilter = 10.0f;

/* Notify heading changes when heading is > 5.
* Default value is kCLHeadingFilterNone: all movements are reported.
*/
self.locationManager.headingFilter = 5;

// update location
if ([CLLocationManager locationServicesEnabled]){
[self.locationManager startUpdatingLocation];
}

速度计算:
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
double speed = newLocation.speed;

//another way
if(oldLocation != nil)
{
CLLocationDistance distanceChange = [newLocation getDistanceFrom:oldLocation];
NSTimeInterval sinceLastUpdate = [newLocation.timestamp timeIntervalSinceDate:oldLocation.timestamp];
speed = distanceChange/sinceLastUpdate;

}
}

关于ios - 核心位置检测到的最低速度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12198245/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com