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;

            }

        }

  • 相关阅读:
    求最长不降子序列

    普通背包问题
    求最大子序列
    最大人品
    C# 显示webBrowser页面加载进度
    Provider 错误 '80004005' 未指定的错误 的最终解决方法
    C# 截取webBrowser网页存为图片
    浅谈Python小数据池
    js文件编译成动态链接库(dll)文件
  • 原文地址:https://www.cnblogs.com/scottgu/p/2220425.html
Copyright © 2011-2022 走看看