Calculates the GPS two point distances

public double GetDistance(double Lat1, double Long1, double Lat2, double Long2)
{
double Lat1r = ConvertDegreeToRadians(Lat1);
double Lat2r = ConvertDegreeToRadians(Lat2);
double Long1r = ConvertDegreeToRadians(Long1);
double Long2r = ConvertDegreeToRadians(Long2);
double R = 6371; // Earth's radius (km)
double d = Math.Acos(Math.Sin(Lat1r) * Math.Sin(Lat2r) + Math.Cos(Lat1r) *
Math.Cos(Lat2r) * Math.Cos(Long2r-Long1r)) * R;
return d;
}
private double ConvertDegreeToRadians(double degrees)
{ return (Math.PI/180)*degrees;}

留言

這個網誌中的熱門文章

使用VB讀取健保卡基本資料

使用VB讀取自然人評証卡號