⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 coordtran.cpp

📁 坐标转换工具 WGS84坐标转换为地方坐标系的程序 以及各种三维坐标系之间的转换
💻 CPP
字号:
// CoordTran.cpp: implementation of the CCoordTran class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "CoordTran.h"
#include <math.h>

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CCoordTran::CCoordTran()
{
	m_ntype=CCOOD_TRAN;

}

CCoordTran::~CCoordTran()
{

}


void CCoordTran::blhTOxyz()
{
	double N,E;
	double sqa,sqb;
	double temp;
	double B,L,H;

	xyz m_t;

	sax=lax-af*lax;

	sqa=lax*lax; sqb=sax*sax;

	m_xyz.RemoveAll();
	
	for(int i=0;i<m_blh.GetSize();i++)
	{

		B=m_blh.GetAt(i).getb();
		L=m_blh.GetAt(i).getl();
		H=m_blh.GetAt(i).geth();
		
		temp=sqrt(sqa*cos(B)*cos(B)+sqb*sin(B)*sin(B));
		N=sqa/temp;
		E=sqrt((sqa-sqb)/sqa);
		
		m_t.setx((N+H)*cos(B)*cos(L));
		m_t.sety((N+H)*cos(B)*sin(L));
		m_t.setz((N*(1-E*E)+H)*sin(B));
	
		m_xyz.Add(m_t);
	}



}

void CCoordTran::xyzToblh()
{
	blh m_t;
	double X,Y,Z;
	double N;
	double R,P,sinw2,sin2w2,w,q;
	

	sax=lax-af*lax;

	double e=sqrt((lax*lax-sax*sax)/(lax*lax));
	double ep=sqrt((lax*lax-sax*sax)/(sax*sax));


	m_blh.RemoveAll();

	for(int i=0;i<m_xyz.GetSize();i++)
	{
		X=m_xyz.GetAt(i).getx();
		Y=m_xyz.GetAt(i).gety();
		Z=m_xyz.GetAt(i).getz();

		R=sqrt(X*X+Y*Y+Z*Z);
		sinw2=(Z*Z)/(R*R);
		w=acos((1-2*sinw2))/2;
		sin2w2=(1-cos(4*w))/2;
		q=e*e/(2-e*e);

	
		P=lax/sqrt((1+ep*ep*sinw2));
		m_t.h=(R-P)*(1-q*q*sin2w2/2);

		N=lax/sqrt((1-e*e*(sinw2+q*sin2w2)));
		m_t.b=atan(Z*(1+e*e/(1-e*e+m_t.h/N))/sqrt(X*X+Y*Y));
		m_t.l=atan(Y/X);
		N=lax*lax/sqrt(lax*lax*(1+cos(2*m_t.b))/2+sax*sax*(1-cos(2*m_t.b))/2);
	
		m_t.h=(sqrt(X*X+Y*Y)/cos(m_t.b))-N;
	

		m_blh.Add(m_t);

	}



}

void CCoordTran::SetAf(double m_af)
{
	af=m_af;

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -