我正在进行一些实验,尝试通过对随时间收集的数据执行加权平均来增加iPhone上的GPS精度。我注意到控制台,iPhone模拟器和iPhone本身的坐标显示有所不同。为什么CLLocation坐标在显示时会失去精度?
我正在运行基本的CoreLocation代码来设置我的位置管理器。
self.locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[locationManager startUpdatingLocation];
在我的LocationManager:didUpdateToLocation:fromLocation:方法我写的坐标控制台在我IBOutlets显示它们之前,使用NSLog的几种格式。
NSLog(@"%@", newLocation);
NSLog(@"%f", newLocation.coordinate.latitude);
NSLog(@"%e", newLocation.coordinate.latitude);
NSLog(@"%E", newLocation.coordinate.latitude);
self.latitude.text = [NSString stringWithFormat:@"%f", newLocation.coordinate.latitude];
self.longitude.text = [NSString stringWithFormat:@"%f", newLocation.coordinate.longitude];
self.altitude.text = [NSString stringWithFormat:@"%f", newLocation.altitude];
self.horizontalAccuracy.text = [NSString stringWithFormat:@"%f", newLocation.horizontalAccuracy];
self.verticalAccuracy.text = [NSString stringWithFormat:@"%f", newLocation.verticalAccuracy];
写入控制台的值如下所示。
NSLog(@"%@", ...); | <+42.40334972, -71.27483790> +/- 240.00m (speed -1.00 mps/course -1.00) @ 2010-10-19 12:15:00 GMT
NSLog(@"%f", ...); | 42.403350
NSLog(@"%e", ...); | 4.240335e+01
NSLog(@"%E", ...); | 4.240335E+01
屏幕上显示的纬度和经度如下。
Latitude | 42.403350
Longitude | -7.274838
由于纬度和经度CLLocationDegrees,即增加一倍,而我使用%F写坐标到控制台,并在屏幕上显示出来,我不认为“原始”坐标是从小数点后8位保留到小数点后6位。 (我也不知道iPhone上的GPS接收器是否以与MacBook Pro相同的精度收集坐标。)
显然,我可以将CLLocation对象存储在数组中,并使用我的更精确的坐标加权平均计算,但我也想在屏幕上显示增加的精度。任何解决方法或想法?
在此先感谢。
只是想指出,6位小数给你一个10厘米的决议。 GPS接收器的分辨率最好只有几米。 – geon 2010-11-09 13:50:42