首页 > 其他 > 详细

根据经纬度算距离

时间:2014-09-12 14:52:53      阅读:225      评论:0      收藏:0      [点我收藏+]
public double getDistance(double startLat,double startLong,double endLat,double endLong){
//startLong 起始坐标点经度
   //startLat 起始坐标点维度
   //endLong 目标坐标点经度
   //endLat 目标坐标点维度
double lat1 = (Math.PI/180)*startLat; double lat2 = (Math.PI/180)*endLat; double lon1 = (Math.PI/180)*startLong; double lon2 = (Math.PI/180)*endLong; //地球半径 double R = 6371; //两点间距离 km,如果想要米的话,结果*1000就可以了 double d = Math.acos(Math.sin(lat1)*Math.sin(lat2)+Math.cos(lat1)*Math.cos(lat2)*Math.cos(lon2-lon1))*R; //double s=R*Math.acos(Math.cos(lat1*Math.PI/180 ) * Math.cos(lat2*Math.PI/180) * Math.cos(lng1*Math.PI/180 -lng2*Math.PI/180) + Math.sin(lat1*Math.PI/180 ) * Math.sin(lat2*Math.PI/180)); return d*1000;
}

 

根据经纬度算距离

原文:http://www.cnblogs.com/konghou/p/3968222.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!