using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace MRP
{
public class ClassMct
{
static public int __IterativeTimes = ; //反向转换程序中的迭代次数
static public double __IterativeValue = ; //反向转换程序中的迭代初始值
static public double __A = 6378.137; //椭球体长轴,千米
static public double __B = 6356.752314; //椭球体短轴,千米
static public double __B0 = ; //标准纬度,弧度
static public double __L0 = ; //原点经度,弧度 //角度到弧度的转换
static public double DegreeToRad(double degree)
{
return Math.PI * degree / ;
} //弧度到角度的转换
static public double RadToDegree(double rad)
{
return ( * rad) / Math.PI;
} //设定__A与__B
static public void SetAB(double a, double b)
{
if (a <= || b <= )
{
return;
}
__A = a;
__B = b;
}
//设定__B0
static public void SetLB0(double pmtL0, double pmtB0)
{
double l0 = DegreeToRad(pmtL0);
if (l0 < -Math.PI || l0 > Math.PI)
{
return;
}
__L0 = l0; double b0 = DegreeToRad(pmtB0);
if (b0 < -Math.PI / || b0 > Math.PI / )
{
return;
}
__B0 = b0;
} /*******************************************
经纬度转XY坐标
pmtLB0: 参考点经纬度
pmtLB1: 要转换的经纬度
返回值: 直角坐标,单位:公里
*******************************************/
static public PointXY LBToXY(PointLB pmtLB0, PointLB pmtLB1)
{
SetLB0(pmtLB0.lon, pmtLB0.lat); double B = DegreeToRad(pmtLB1.lat);
double L = DegreeToRad(pmtLB1.lon); PointXY xy = new PointXY();
xy.x = ; xy.y = ; double f/*扁率*/, e/*第一偏心率*/, e_/*第二偏心率*/, NB0/*卯酉圈曲率半径*/, K, dtemp;
double E = Math.Exp();
if (L < -Math.PI || L > Math.PI || B < -Math.PI / || B > Math.PI / )
{
return xy;
}
if (__A <= || __B <= )
{
return xy;
}
f = (__A - __B) / __A;
dtemp = - (__B / __A) * (__B / __A);
if (dtemp < )
{
return xy;
}
e = Math.Sqrt(dtemp);
dtemp = (__A / __B) * (__A / __B) - ;
if (dtemp < )
{
return xy;
}
e_ = Math.Sqrt(dtemp);
NB0 = ((__A * __A) / __B) / Math.Sqrt( + e_ * e_ * Math.Cos(__B0) * Math.Cos(__B0));
K = NB0 * Math.Cos(__B0);
xy.x = K * (L - __L0);
xy.y = K * Math.Log(Math.Tan(Math.PI / + (B) / ) * Math.Pow(( - e * Math.Sin(B)) / ( + e * Math.Sin(B)), e / ));
double y0 = K * Math.Log(Math.Tan(Math.PI / + (__B0) / ) * Math.Pow(( - e * Math.Sin(__B0)) / ( + e * Math.Sin(__B0)), e / ));
xy.y = xy.y - y0; xy.y = -xy.y;//正常的Y坐标系(向上)转程序的Y坐标系(向下) return xy;
} /*******************************************
XY坐标转经纬度
pmtLB0: 参考点经纬度
pmtXY: 要转换的XY坐标,单位:公里
返回值: 经纬度
*******************************************/
static public PointLB XYtoLB(PointLB pmtLB0, PointXY pmtXY)
{
SetLB0(pmtLB0.lon, pmtLB0.lat); double X = pmtXY.x;
double Y = -pmtXY.y;//程序的Y坐标系(向下)转正常的Y坐标系(向上) double B = , L = ; PointLB lb = new PointLB();
lb.lat = ; lb.lon = ; double f/*扁率*/, e/*第一偏心率*/, e_/*第二偏心率*/, NB0/*卯酉圈曲率半径*/, K, dtemp;
double E = Math.Exp(); if (__A <= || __B <= )
{
return lb;
}
f = (__A - __B) / __A;
dtemp = - (__B / __A) * (__B / __A);
if (dtemp < )
{
return lb;
}
e = Math.Sqrt(dtemp);
dtemp = (__A / __B) * (__A / __B) - ;
if (dtemp < )
{
return lb;
}
e_ = Math.Sqrt(dtemp);
NB0 = ((__A * __A) / __B) / Math.Sqrt( + e_ * e_ * Math.Cos(__B0) * Math.Cos(__B0));
K = NB0 * Math.Cos(__B0); double y0 = K * Math.Log(Math.Tan(Math.PI / + (__B0) / ) * Math.Pow(( - e * Math.Sin(__B0)) / ( + e * Math.Sin(__B0)), e / ));
Y = Y + y0; L = X / K + __L0;
B = __IterativeValue; for (int i = ; i < __IterativeTimes; i++)
{
B = Math.PI / - * Math.Atan(Math.Pow(E, (-Y / K)) * Math.Pow(E, (e / ) * Math.Log(( - e * Math.Sin(B)) / ( + e * Math.Sin(B)))));
} lb.lon = RadToDegree(L);
lb.lat = RadToDegree(B); return lb;
}
}
}

最新文章

  1. 关于本月第一天,本月最后一天的SQL代码
  2. Flex数据交互之Remoting
  3. struts拦截器
  4. 同是url参数传进来的值,String类型就用getAttribute获取不到,只能用getParameter获取,而int就两个都可以这是为什么?
  5. Codeforces Round #259 (Div. 2) C - Little Pony and Expected Maximum
  6. DelphiXE8新建AVD
  7. Reverse Words in a String——LeetCode
  8. HDOJ-1009 FatMouse&#39; Trade
  9. Unity3d 要点板书
  10. Windows Phone 8初学者开发—第5部分:布局和事件基础
  11. 55. 略谈Lotus Notes的与众不同及系列文章至此的总结
  12. ubuntu+github配置使用
  13. hadoop-hdfs编程
  14. Springboot 2.0.x 引入链路跟踪Sleuth及Zipkin
  15. web技术栈中不可或缺的Linux技术
  16. Centos7中修改Hostname的方法
  17. 安装SHARP MX-3618NC PCL6打印机驱动程序
  18. IOS企业开发者帐号申请
  19. Mybatis里Mapper映射sql文件里insert的主键返回selectKey使用
  20. 【Oracle 12c】最新CUUG OCP-071考试题库(55题)

热门文章

  1. 拜拜了,浮动布局-基于display:inline-block的列表布局
  2. entity framework自动迁移
  3. inotify +rsync进行实时同步
  4. == 与 equals 的区别
  5. Sublime Text 注册码 License Key
  6. An invalid character [32] was present in the Cookie value
  7. C++工程目录架构
  8. 解决duplicate symbols for architecture x86_64错误
  9. WinForm中使用XML文件存储用户配置及操作本地Config配置文件(zt)
  10. MySQL基础原创笔记