public static double Fun_Rad(double d)
{
return d * Math.PI / 180.0;
}
public static double Fun_GetDistance(double lat1, double lng1, double lat2, double lng2)
{
double d_EarthRadius = 6378.137;
double radLat1 = Fun_Rad(lat1);
double radLat2 = Fun_Rad(lat2);
double radLat = Fun_Rad(lat1) - Fun_Rad(lat2);
double radLng = Fun_Rad(lng1) - Fun_Rad(lng2);
double s = 2 * Math.Asin(Math.Sqrt(Math.Pow(Math.Sin(radLat / 2), 2) +
Math.Cos(radLat1) * Math.Cos(radLat2) * Math.Pow(Math.Sin(radLng / 2), 2)));
s = s * d_EarthRadius;
s = Math.Round(s * 10000) / 10000;
return s;