Code
Public Static DoubleDistanceoftwopoints (DoubleLng1,DoubleLAT1,DoubleLng2,Double LAT2, gausssphere GS)
{
DoubleRadlat1= Rad (LAT1 );
DoubleRadlat2= Rad (LAT2 );
DoubleA=Radlat1- radlat2;
double B = rad (lng1) - rad (lng2 );
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 * (GS = gausssphere. WGS84 ? 6378137.0 :( GS = gausssphere. xian80 ? 6378140.0 : 6378245.0 ));
S=Math. Round (S* 10000)/ 10000 ;
Return S;
}
Private Static DoubleRad (Double D)
{
ReturnD*Math. Pi/ 180.0;
}
Gausssphere is a custom Enumeration type
/**/ /// <Summary>
///References used in Gaussian projection
/// </Summary>
Public Enum Gausssphere
{
Beijing54,
Xian80,
WGS84,
}
the implementation of distance between two points on the earth's surface based on the latitude and longitude obtained from Google map is slightly adapted. This implementation is sufficient for space distance calculation in China, in meters .. Net2.0, C # implementation.