我发现这个问题与distanceFromLocation函数返回值不准确。请确认我是否做错了或功能有问题。iphone - distanceFromLocation准确性
CLLocation *locA = [[CLLocation alloc] initWithLatitude:5.321008 longitude:100.290131];
CLLocation *locB = [[CLLocation alloc] initWithLatitude:5.321008 longitude:100.290138];
CLLocationDistance distance = [locA distanceFromLocation:locB];
NSLog(@"distance: %f, locA: %f,%f, locB: %f,%f",distance,locA.coordinate.latitude,locA.coordinate.longitude,locB.coordinate.latitude,locB.coordinate.longitude);
输出是:
distance: 0.775644, locA: 5.321008,100.290131, locB: 5.321008,100.290138
两个位置都近,应小于10米。但是,该功能返回更大的距离。经过与网站如http://jan.ucc.nau.edu/~cvm/latlongdist.html的距离应该是:
Distance between 5.321008N 100.290131E and 5.321008N 100.290138E is 0.0008 km
只是注意到这一点,谢谢指出 – mnazwan 2012-01-27 03:38:42