zoukankan      html  css  js  c++  java
  • calculate the distance of 2 [geographic coordinates]

        class PublicFun

        {

        }

        /// <summary>

        /// calculate the distance

        /// </summary>

        public struct EarthPoint

        {

            //equatorial radius:  WGS84 standard major semi-axis of the earth(unit:m)  

            public const double Ea = 6378137; 

            public const double Eb = 6356725; // 极半径   

            public readonly double Longitude, Latidute;

            public readonly double Jd;

            public readonly double Wd;

            public readonly double Ec;

            public readonly double Ed;

            public EarthPoint(double _Longitude, double _Latidute)

            {

                Longitude = _Longitude;

                Latidute = _Latidute;

                Jd = Longitude * Math.PI / 180; //convert to angle

                Wd = Latidute * Math.PI / 180; //convert to angle

                Ec = Eb + (Ea - Eb) * (90 - Latidute) / 90;

                Ed = Ec * Math.Cos(Wd);

            }

            /// <summary>

            ///  return distance of two point(unit:km)

            /// </summary>

            /// <param name="_Point"></param>

            /// <returns></returns>

            public double Distance(EarthPoint _Point)

            {

                double dx = (_Point.Jd - Jd) * Ed;

                double dy = (_Point.Wd - Wd) * Ec;

                return Math.Sqrt(dx * dx + dy * dy)/1000;

            }

        }

  • 相关阅读:
    CSS—BFC学习
    JS函数声明及函数表达式相关
    你想要的正则表达式笔记
    WordPress搭建自己的网站
    声纹识别
    WordPress搭建自己的网站
    L--jsp和servlet
    L--网页跳转
    L1--指针
    L--Java关键字final、static
  • 原文地址:https://www.cnblogs.com/scottgu/p/2220425.html
Copyright © 2011-2022 走看看