Iphone 距离产生极大(不正确)距离的位置

Iphone 距离产生极大(不正确)距离的位置,iphone,cocoa-touch,location,distance,Iphone,Cocoa Touch,Location,Distance,我一直在努力找出为什么distanceFromLocation不能计算两个位置的正确距离。计算结果远大于实际距离,但这两个位置似乎是有效位置 首先,这里有两个位置: 位置1:+/-0.00m(速度-1.00mps/航向-1.00)@2010-12-13 21:12:03-0500 地点2: +/-0.00米 (速度-1.00 mps/航程-1.00)@ 2010-12-13 21:12:03-0500 下面是声明位置1和位置2的代码。我已经验证了这些是正确的值,但我仍然无法弄清楚这一点 CLLo

我一直在努力找出为什么distanceFromLocation不能计算两个位置的正确距离。计算结果远大于实际距离,但这两个位置似乎是有效位置

首先,这里有两个位置:

位置1:+/-0.00m(速度-1.00mps/航向-1.00)@2010-12-13 21:12:03-0500
地点2: +/-0.00米 (速度-1.00 mps/航程-1.00)@ 2010-12-13 21:12:03-0500

下面是声明位置1和位置2的代码。我已经验证了这些是正确的值,但我仍然无法弄清楚这一点

CLLocation *newLocation = [[CLLocation alloc] 
    initWithLatitude:[latitude doubleValue] 
    longitude:[longitude doubleValue]];
    // CURRENT LOCATION (OR SEARCHED LOCATION)

double dLat = 0;
int tmpDistance = 0;
id returnId = nil;

id tmp = [featuredResults objectAtIndex:i];
CLLocation *newLocation2 = [[CLLocation alloc] 
    initWithLatitude:[[tmp valueForKey:@"lat"] doubleValue]  
    longitude:[[tmp valueForKey:@"lng"] doubleValue]];

dLat = [newLocation distanceFromLocation:newLocation2];

我得到的dLat值是330707027,这是非常错误的。有人知道我哪里会出错吗?谢谢

该测试代码基于问题中的代码给出了大约33669米:

CLLocation *newLocation = [[CLLocation alloc] 
    initWithLatitude:44.56697840 longitude:-69.55759810];

CLLocation *newLocation2 = [[CLLocation alloc] 
    initWithLatitude:44.31400400 longitude:-69.79157000];

double dLat = [newLocation distanceFromLocation:newLocation2];

NSLog(@"distance = %f meters", dLat);

[newLocation release];
[newLocation2 release];
输出:

距离=33669.002406米


可能您正在使用除
%f
之外的其他内容记录dLat?

是否要计算与新位置2的距离?