码迷,mamicode.com
首页 > 其他好文 > 详细

【转】根据高德地图得出的坐标算出两点之间的距离

时间:2017-03-31 16:53:12      阅读:1516      评论:0      收藏:0      [点我收藏+]

标签:http   stat   ati   etl   via   net   art   坐标   bsp   

 

摘自 http://blog.csdn.net/u012251421/article/details/41242891

public static string GetDistance(double n1, double e1, double n2, double e2)
{
double lon1 = (Math.PI / 180) * n1;
double lon2 = (Math.PI / 180) * n2;
double lat1 = (Math.PI / 180) * e1;
double lat2 = (Math.PI / 180) * e2;

// double Lat1r = (Math.PI/180)*(gp1.getLatitudeE6()/1E6);
// double Lat2r = (Math.PI/180)*(gp2.getLatitudeE6()/1E6);
// double Lon1r = (Math.PI/180)*(gp1.getLongitudeE6()/1E6);
// double Lon2r = (Math.PI/180)*(gp2.getLongitudeE6()/1E6);

// 地球半径
double R = 6378;

// 两点间距离 km,如果想要米的话,结果*1000就可以了
double d = Math.Acos(Math.Sin(lat1) * Math.Sin(lat2) + Math.Cos(lat1) * Math.Cos(lat2) * Math.Cos(lon2 - lon1)) * R;
if ((d * 1000) > deviation)

return (d * 1000).ToString();
}

【转】根据高德地图得出的坐标算出两点之间的距离

标签:http   stat   ati   etl   via   net   art   坐标   bsp   

原文地址:http://www.cnblogs.com/sxlbk/p/6651890.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!