# 根据地球上任意两点的经纬度计算两点间的距离

C = sin(MLatA)*sin(MLatB)*cos(MLonA-MLonB) + cos(MLatA)*cos(MLatB)

Distance = R*Arccos(C)*Pi/180

C = sin(LatA)*sin(LatB) + cos(LatA)*cos(LatB)*cos(MLonA-MLonB)

Distance = R*Arccos(C)*Pi/180

C = sin(LatA*Pi/180)*sin(LatB*Pi/180) + cos(LatA*Pi/180)*cos(LatB*Pi/180)*cos((MLonA-MLonB)*Pi/180)

Distance = R*Arccos(C)*Pi/180

C = sin(LatA/57.2958)*sin(LatB/57.2958) + cos(LatA/57.2958)*cos(LatB/57.2958)*cos((MLonA-MLonB)/57.2958)

Distance = R*Arccos(C) = 6371.004*Arccos(C) kilometer = 0.621371192*6371.004*Arccos(C) mile = 3958.758349716768*Arccos(C) mile

private const double EARTH_RADIUS = 6378.137;//地球半径
private static double rad(double d)
{
return d * Math.PI / 180.0;
}

public static double GetDistance(double lat1, double lng1, double lat2, double lng2)
{

double s = 2 * Math.Asin(Math.Sqrt(Math.Pow(Math.Sin(a/2),2) +
s = s * EARTH_RADIUS;
s = Math.Round(s * 10000) / 10000;
return s;
}

#### 通过两点经纬度，计算他们之间的距离 - JAVA

2012年11月28日 186KB 下载

12-19 1355

03-05 2224

07-16 851

02-23 623

09-21 4407

01-09 2634

04-11 2045

10-29 4794

09-15 5705