GPS坐标换算
——>30
0.8872*60 = 53.232 ——>53
0.232*60 = 13.92
30: 53' 13.92"
30: 53' 13.92"=======》
30+53/60+13.92/3600=30.887199
同经度两点之间距离
dla=30.887m * [差值/(1/3600)] = 30.887m * 差值 *3600 = 111193.2m * 差值
同纬度两点之间距离
dlo=30.887m * [差值/(1/3600)] * cos纬度 = 30.887m * 差值 *3600 *cos纬度 = 111193.2m * 差值 *cos纬度
#define M_PI 3.14159265358979323846264338327950288
-(double) deg2rad:(double) degree
{
return degree / 180 * M_PI;
}
- (IBAction)Get:(id)sender {
double r = 6378137;
double lat2=34.7457;
double lat1=34.7418;
double lng2=113.6247;
double lng1=113.6328;
lat1 = [self deg2rad:lat1];
lat2 = [self deg2rad:lat2];
lng1 = [self deg2rad:lng1];
lng2 = [self deg2rad:lng2];
double d1 = ABS(lat1 - lat2);
double d2 = ABS(lng1 - lng2);
double p = pow(sin(d1 / 2), 2) + cos(lat1)* cos(lat2) * pow(sin(d2 / 2), 2);
double dis = r * 2 * asin(sqrt(p));
Distance.text = [[NSString alloc]initWithFormat:@"%lf",dis];
}
文章来源: zzzili.blog.csdn.net,作者:清雨小竹,版权归原作者所有,如需转载,请联系作者。
原文链接:zzzili.blog.csdn.net/article/details/8265483
- 点赞
- 收藏
- 关注作者
评论(0)