国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

[C#]地球坐標系 (WGS-84) 到火星坐標系 (GCJ-02) 的轉換 幫助類

2019-11-17 02:42:56
字體:
來源:轉載
供稿:網友

[C#]地球坐標系 (WGS-84) 到火星坐標系 (GCJ-02) 的轉換 幫助類

關鍵代碼:

using System;using YanZhiwei.DotNet2.Utilities.Models;namespace YanZhiwei.DotNet2.Utilities.Common{    /// <summary>    /// 地球坐標系 (WGS-84) 到火星坐標系 (GCJ-02) 的轉換 幫助類     /// </summary>    public class WGSGCJLatLonHelper    {        /*         *參考:         *1.http://blog.csdn.net/yorling/article/details/9175913         *2.http://kongxz.com/2013/10/wgs-cgj/         *3.https://on4wp7.codeplex.com/SourceControl/changeset/view/21483#EvilTransform.cs         *4.https://github.com/googollee/eviltransform         *5.https://github.com/shenqiliang/WGS2Mars         *         *WGS84:World Geodetic System 1984,是為GPS全球定位系統使用而建立的坐標系統。通過遍布世界的衛星觀測站觀測到         *的坐標建立,其初次WGS84的精度為1-2m,在1994年1月2號,通過10個觀測站在GPS測量方法上改正,得到了WGS84         *(G730),G表示由GPS測量得到,730表示為GPS時間第730個周。1996年,National Imagery and Mapping Agency (NIMA)          *為美國國防部 (U.S.Departemt of Defense, DoD)做了一個新的坐標系統。這樣實現了新的WGS版本:WGS(G873)。其因為         *加入了USNO站和北京站的改正,其東部方向加入了31-39cm 的改正。所有的其他坐標都有在1分米之內的修正。         *         *GCJ-02:國家保密插件,也叫做加密插件或者加偏或者SM模組,其實就是對真實坐標系統進行人為的加偏處理,按照幾行代碼的算         *法,將真實的坐標加密成虛假的坐標,而這個加偏并不是線性的加偏,所以各地的偏移情況都會有所不同。而加密后的坐標也常         *被人稱為火星坐標系統。GCJ-02 意味“國測局-2002”,也就是說,這是國家測繪局于2002年弄出的標準。         */        #region 常量以及私有方法        const double pi = 3.14159265358979324;//Math.PI;//;        const double a = 6378245.0;        const double ee = 0.00669342162296594323;        PRivate static double TransformLat(double lonX, double latY)        {            double _ret = -100.0 + 2.0 * lonX + 3.0 * latY + 0.2 * latY * latY + 0.1 * lonX * latY + 0.2 * Math.Sqrt(Math.Abs(lonX));            _ret += (20.0 * Math.Sin(6.0 * lonX * pi) + 20.0 * Math.Sin(2.0 * lonX * pi)) * 2.0 / 3.0;            _ret += (20.0 * Math.Sin(latY * pi) + 40.0 * Math.Sin(latY / 3.0 * pi)) * 2.0 / 3.0;            _ret += (160.0 * Math.Sin(latY / 12.0 * pi) + 320 * Math.Sin(latY * pi / 30.0)) * 2.0 / 3.0;            return _ret;        }        private static double TransformLon(double lonX, double latY)        {            double _ret = 300.0 + lonX + 2.0 * latY + 0.1 * lonX * lonX + 0.1 * lonX * latY + 0.1 * Math.Sqrt(Math.Abs(lonX));            _ret += (20.0 * Math.Sin(6.0 * lonX * pi) + 20.0 * Math.Sin(2.0 * lonX * pi)) * 2.0 / 3.0;            _ret += (20.0 * Math.Sin(lonX * pi) + 40.0 * Math.Sin(lonX / 3.0 * pi)) * 2.0 / 3.0;            _ret += (150.0 * Math.Sin(lonX / 12.0 * pi) + 300.0 * Math.Sin(lonX / 30.0 * pi)) * 2.0 / 3.0;            return _ret;        }        private static LatLngPoint Transform(LatLngPoint point)        {            LatLngPoint _transPoint = new LatLngPoint();            double _lat = TransformLat(point.LonX - 105.0, point.LatY - 35.0);            double _lon = TransformLon(point.LonX - 105.0, point.LatY - 35.0);            double _radLat = point.LatY / 180.0 * pi;            double _magic = Math.Sin(_radLat);            _magic = 1 - ee * _magic * _magic;            double _sqrtMagic = Math.Sqrt(_magic);            _lat = (_lat * 180.0) / ((a * (1 - ee)) / (_magic * _sqrtMagic) * pi);            _lon = (_lon * 180.0) / (a / _sqrtMagic * Math.Cos(_radLat) * pi);            _transPoint.LatY = _lat;            _transPoint.LonX = _lon;            return _transPoint;        }        #endregion        #region 火星坐標轉 (GCJ-02)地球坐標(WGS-84)        /// <summary>        /// 火星坐標轉 (GCJ-02)地球坐標(WGS-84)        /// </summary>        /// <param name="gcjPoint">火星坐標轉 (GCJ-02)</param>        /// <returns>地球坐標(WGS-84)</returns>        public static LatLngPoint GCJ02ToWGS84(LatLngPoint gcjPoint)        {            if (MapHelper.OutOfChina(gcjPoint))            {                return gcjPoint;            }            LatLngPoint _transPoint = Transform(gcjPoint);            return new LatLngPoint(gcjPoint.LatY - _transPoint.LatY, gcjPoint.LonX - _transPoint.LonX);        }        #endregion        #region 地球坐標(WGS-84)轉火星坐標 (GCJ-02)        /// <summary>        /// 地球坐標(WGS-84)轉火星坐標 (GCJ-02)        /// </summary>        /// <param name="wgsPoint">地球坐標(WGS-84)</param>        /// <returns>火星坐標 (GCJ-02)</returns>        public static LatLngPoint WGS84ToGCJ02(LatLngPoint wgsPoint)        {            if (MapHelper.OutOfChina(wgsPoint))            {                return wgsPoint;            }            LatLngPoint _transPoint = Transform(wgsPoint);            return new LatLngPoint(wgsPoint.LatY + _transPoint.LatY, wgsPoint.LonX + _transPoint.LonX);        }        #endregion    }}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 墨竹工卡县| 株洲市| 扎兰屯市| 西宁市| 南宁市| 漯河市| 布拖县| 普格县| 利川市| 石城县| 汨罗市| 神木县| 松潘县| 南皮县| 连平县| 武胜县| 从化市| 营口市| 大邑县| 凤山县| 松桃| 南昌县| 象州县| 东安县| 德兴市| 达日县| 横山县| 岳阳市| 盘锦市| 从江县| 治多县| 桂平市| 富阳市| 肃南| 绥宁县| 会东县| 连平县| 织金县| 崇信县| 马公市| 织金县|