-
大小: 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文件
评论
共有 条评论