小编b.d*_*dot的帖子

Geo Spacial Bounding Box矩形计算错误:纬度不正确

任何触发或GPS专家都可以帮助我吗?我正在尝试创建一个地理空间边界框(矩形)计算,使用我检索到的以下方法返回最大纬度和经度.我为每个轴承调用一次方法:北,南,东和西.有了这四个值,我打算在我的Core Data存储库中查询框中的所有对象.

  -(CLLocation*) offsetLocation:(CLLocation*)startLocation:(double)offsetMeters:(double)bearing {


    double EARTH_MEAN_RADIUS_METERS = 6372796.99;
    double newLatitude = asin( sin(startLocation.coordinate.latitude) * cos(offsetMeters/EARTH_MEAN_RADIUS_METERS) + cos(startLocation.coordinate.latitude) * sin(offsetMeters/EARTH_MEAN_RADIUS_METERS) * cos(bearing) );
    double newLongitude = startLocation.coordinate.longitude + atan2( sin(bearing) * sin(offsetMeters/EARTH_MEAN_RADIUS_METERS) * cos(startLocation.coordinate.latitude), cos(offsetMeters/EARTH_MEAN_RADIUS_METERS) - sin(startLocation.coordinate.latitude) * sin(newLatitude));


    CLLocation *tempLocation = [[CLLocation alloc] initWithLatitude:newLatitude longitude:newLongitude];
    [tempLocation autorelease];
    return tempLocation;
}
Run Code Online (Sandbox Code Playgroud)

问题是newLatitude偏移的计算肯定是不正确的.鉴于以下内容:

startLocation:北纬37.331688999999997,经度-122.030731 offsetMeters:1000轴承:0(北)

newLatitude返回-0.36726592610659514(不正确).

有什么建议?到目前为止,我已经围绕这个特殊的公式进行了编码,这个让我难过.我也试过从PHP翻译不同的公式无济于事.我认为如果它可以调整,上面正是我需要的.

谢谢,b.dot

iphone gps core-data objective-c geolocation

6
推荐指数
1
解决办法
3634
查看次数

标签 统计

core-data ×1

geolocation ×1

gps ×1

iphone ×1

objective-c ×1