/// <summary>
        /// 经纬度之间的距离
        /// </summary>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <returns></returns>
        public static double CalcDistance(System.Windows.Point from, System.Windows.Point to)
        {
            double rad = 6371; //Earth radius in Km
            double p1X = from.X / 180 * Math.PI;
            double p1Y = from.Y / 180 * Math.PI;
            double p2X = to.X / 180 * Math.PI;
            double p2Y = to.Y / 180 * Math.PI;
            return Math.Acos(Math.Sin(p1Y) * Math.Sin(p2Y) +
                Math.Cos(p1Y) * Math.Cos(p2Y) * Math.Cos(p2X - p1X)) * rad;
        }

 

posted on 2012-07-06 16:41  ﹎蓝言觅ぷ雨  阅读(2664)  评论(0编辑  收藏  举报