本文主要是介绍GPS经纬度换算成XY坐标,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
/// <summary>/// GPS经纬度换算成x,y坐标
/// </summary>
/// <param name="l"> 精度 </param>
/// <param name="B"> 纬度 </param>
/// <param name="xc"> X坐标 </param>
/// <param name="yc"> Y坐标 </param>
public static void MCT84Bl2xy( double l, double B, out double xc, out double yc)
{
try
{
l = l * Math.PI / 180 ;
B = B * Math.PI / 180 ;
double B0 = 30 * Math.PI / 180 ;
double N = 0 , e = 0 , a = 0 , b = 0 , e2 = 0 , K = 0 ;
a = 6378137 ;
b = 6356752.3142 ;
e = Math.Sqrt( 1 - (b / a) * (b / a));
e2 = Math.Sqrt((a / b) * (a / b) - 1 );
double CosB0 = Math.Cos(B0);
N = (a * a / b) / Math.Sqrt( 1 + e2 * e2 * CosB0 * CosB0);
K = N * CosB0;
double Pi = Math.PI;
double SinB = Math.Sin(B);
double tan = Math.Tan(Pi / 4 + B / 2 );
double E2 = Math.Pow(( 1 - e * SinB) / ( 1 + e * SinB), e / 2 );
double xx = tan * E2;
xc = K * Math.Log(xx);
yc = K * l;
return ;
}
catch (Exception ErrInfo)
{
}
xc = - 1 ;
yc = - 1 ;
}
这篇关于GPS经纬度换算成XY坐标的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!