GPS计算两点之间的距离
public double Distance(double Longitude1, double latitude1, double Longitude2, double latitude2)
        {
            try
            {
                double R;
                double dx, dy, dew;
                R = 6378137; //地球半径
                Longitude1 *= Math.PI / 180.0;
                latitude1 *=  Math.PI / 180.0;
                Longitude2 *= Math.PI / 180.0;
                latitude2 *= Math.PI / 180.0;
                //经度差
                dew = Longitude1 - Longitude2;
                //若跨东经西经180度,进行调整
                if (dew > Math.PI)
                    dew = 2 * Math.PI - dew;
                else if(dew < -Math.PI)
                    dew = 2 * Math.PI + dew;
                dx = R * Math.Cos(latitude1) * dew;
                dy = R * (latitude1 - latitude2);
                return Math.Abs(Math.Sqrt(dx * dx + dy * dy)); 
            }
            catch
            {
                return 0;
            }
        }
 
                    
                 
                
            
         
 浙公网安备 33010602011771号
浙公网安备 33010602011771号