gpt4 book ai didi

objective-c - 如何从模拟器的核心位置获得所需的精度?

转载 作者:行者123 更新时间:2023-12-04 07:00:06 25 4
gpt4 key购买 nike

我想在模拟器中检查所需的精度,但我从来没有在 didupdatetolocation 方法中得到它。我知道在模拟器中委托(delegate)方法只调用一次。有人知道如何在模拟器中获得所需的精度。这是我获得所需精度的代码。

// Delegate method from the CLLocationManagerDelegate protocol.
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
NSTimeInterval locationAge = -[newLocation.timestamp timeIntervalSinceNow];
if (locationAge > 5.0)
{
self.DeviceOldLocation=newLocation;
return;
}
LatitudeData = [[[[NSString alloc] initWithFormat:@"%f",newLocation.coordinate.latitude] retain]autorelease];
LongitudeData =[[[[NSString alloc] initWithFormat:@"%f",newLocation.coordinate.longitude] retain]autorelease];

if (newLocation.horizontalAccuracy < 0)
return;

if (bestEffortAtLocation == nil || bestEffortAtLocation.horizontalAccuracy < newLocation.horizontalAccuracy)
{
// store the location as the "best effort"
self.bestEffortAtLocation = newLocation;
[self insertNewLocationInDataBase];
if (newLocation.horizontalAccuracy <= Accuracy)
{
self.VeryAccuratelocation=newLocation;
BestLocationAcquired=YES;
[self insertNewLocationInDataBase];
[self stopUpdatingLocation];
UIAlertView *BestLocation=[[UIAlertView alloc] initWithTitle:@"Best Location" message:@"best location found" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil];
[BestLocation show];
[BestLocation release];
}
}
}

最佳答案

在模拟器上,位置管理器始终以相同的精度返回相同的位置。因此,您应该在定位模拟器时调整准确度阈值,或者只在真实设备上测试定位服务。

#if TARGET_IPHONE_SIMULATOR
double Accuracy = 100;
#else
double Accuracy = 5;
#endif

关于objective-c - 如何从模拟器的核心位置获得所需的精度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2005698/

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