计算经纬度距离

public static double GetCoorDistance(double x1, double y1, double x2, double y2)
{
    double num = 111120.0;
    double num2 = num * Math.Cos((y1 + y2) * 0.00872664625);
    double num3 = (x1 - x2) * num2;
    double num4 = (y1 - y2) * num;
    return Math.Sqrt((num3 * num3) + (num4 * num4));
}
public static double GetCoorDistance2(double x1, double y1, double x2, double y2)
{
    double num2 = 1.852;
    double num3 = 0.017453292519943295 * x1;
    double num4 = 0.017453292519943295 * x2;
    double a = 0.017453292519943295 * y1;
    double num6 = 0.017453292519943295 * y2;
    double d = (Math.Sin(a) * Math.Sin(num6)) + ((Math.Cos(a) * Math.Cos(num6)) * Math.Cos(num3 - num4));
    return ((((Math.Acos(d) * 57.295779513082323) * 60.0) * num2) * 1000.0);
}





posted @ 2008-10-15 15:32  半克拉鹅卵石  阅读(342)  评论(0编辑  收藏  举报