标签:art sqrt 经纬 double asi mat radius ng2 ble
/**
* 计算两个经纬度之间的距离 (lon1,lat1),(lon2,lat2)
* @param lan1
* @param lat1
* @param lan2
* @param lat2
* @return
*/
public static double GetDistance(double lng1, double lat1, double lng2, double lat2)
{
double EARTH_RADIUS = 6371.393;
double radLat1 = (lat1*Math.PI / 180.0);
double radLat2 = (lat2*Math.PI / 180.0);
double a = radLat1 - radLat2;
double b = (lng1*Math.PI / 180.0) - (lng2*Math.PI / 180.0);
double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a/2),2) +
Math.cos(radLat1)*Math.cos(radLat2)*Math.pow(Math.sin(b/2),2)));
s = s * EARTH_RADIUS;
s = Math.round(s * 1000);
return s;
}
标签:art sqrt 经纬 double asi mat radius ng2 ble
原文地址:https://www.cnblogs.com/seeYagain/p/9889941.html