-
大小: 2.56KB文件類型: .rar金幣: 1下載: 0 次發布日期: 2024-04-23
- 語言: C#
- 標簽: 坐標轉換??WGS84????GCJ02??Webmercator??
資源簡介
坐標轉換 WGS84, GCJ02, Webmercator 坐標相互轉換
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Linq;
namespace?JZ_ShpToFile
{
????public?class?Transform
????{
????????public?static?double?PI?=?3.14159265358979324;
????????public?static?double?x_pi?=?3.14159265358979324?*?3000.0?/?180.0;
????????///?
????????///?經緯度加密轉換
????????///?
????????///?經度
????????///?緯度
????????///?轉換方式
????????///?轉換后的坐標[經度,緯度]
????????public?static?double[]?TranformCoordinate(double?xLon?double?yLat?String?Standard)
????????{
????????????double[]?result?=?new?double[]?{?yLat?xLon?};//最后會轉變成經度?緯度的順序
????????????switch?(Standard)
????????????{
????????????????case?“WGS84-GCJ02“:
????????????????????result?=?gcj_encrypt(yLat?xLon);
????????????????????break;
????????????????case?“GCJ02-WGS84“:
????????????????????result?=?gcj_decrypt(yLat?xLon);
????????????????????break;
????????????????case?“BD09-GCJ02“:
????????????????????result?=?bd_decrypt(yLat?xLon);
????????????????????break;
????????????????case?“GCJ02-BD09“:
????????????????????result?=?bd_encrypt(yLat?xLon);
????????????????????break;
????????????????case?“WGS84-BD09“:
????????????????????result?=?gcj_encrypt(yLat?xLon);
????????????????????result?=?bd_encrypt(result[0]?result[1]);
????????????????????break;
????????????????case?“BD09-WGS84“:
????????????????????result?=?bd_decrypt(yLat?xLon);
????????????????????result?=?gcj_decrypt(result[0]?result[1]);
????????????????????break;
????????????????case?“WGS84-Webmercator“:
????????????????????result?=?mercator_encrypt(yLat?xLon);
????????????????????break;
????????????????case?“Webmercator-WGS84“:
????????????????????result?=?mercator_decrypt(yLat?xLon);
????????????????????break;
????????????????default:
????????????????????break;
????????????}
????????????return?new?double[]?{?result[1]?result[0]?};
????????}
????????public?static?double[]?delta(double?lat?double?lon)
????????{
????????????//?Krasovsky?1940
????????????//
????????????//?a?=?6378245.0?1/f?=?298.3
????????????//?b?=?a?*?(1?-?f)
????????????//?ee?=?(a^2?-?b^2)?/?a^2;
????????????double?a?=?6378245.0;?//??a:?衛星橢球坐標投影到平面地圖坐標系的投影因子。
????????????double?ee?=?0.00669342162296594323;?//??ee:?橢球的偏心率。
????????????double?dLat?=?transformLat(lon?-?105.0?lat?-?35.0);
????????????double?dLon?=?transformLon(lon?-?105.0?lat?-?35.0);
????????????double?radLat?=?lat?/?180.0?*?PI;
????????????double?magic?=?Math.Sin(radLat);
????????????magic?=?1?-?ee?*?magic?*?magic;
????????????double?sqrtMagic?=?Math.Sqrt(magic);
????????????dLat?=?(dLat?*?180.0)?/?((a?*?(1?-?ee))?/?(magic?*?sqrtMagic)?*?PI);
????????????dLon?=?(dLon?*?180.0)?/?(a?/?sqrtMagic?*?Math.Cos(radLat)?*?PI);
????????????return?new?double[]?{?dLat?dLon?};
????????}
????????///?
????????///?WGS-84?to?GCJ-02
????????///?
????????///?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????11722??2021-01-12?14:50??Transform.cs
-----------?---------??----------?-----??----
????????????????11722????????????????????1
- 上一篇:C#串口dll及
- 下一篇:C# 解析dxf文件
評論
共有 條評論