我發現這個問題與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