📄 tradialog.cpp
字号:
// TraDialog.cpp : 实现文件
//
#include "stdafx.h"
#include "CoorTrans.h"
#include "TraDialog.h"
#include <math.h>
double TT=acos(-1.0);
// CTraDialog 对话框
IMPLEMENT_DYNAMIC(CTraDialog, CDialog)
CTraDialog::CTraDialog(CWnd* pParent /*=NULL*/)
: CDialog(CTraDialog::IDD, pParent)
, B1(0)
, B2(0)
, B3(0)
, L1(0)
, L3(0)
, L2(0)
, H(0)
, x(0)
, y(0)
, z(0)
{
f=1/298.223563;
a=6378137;
b=a-a*f;
e=sqrt((a*a-b*b)/(a*a));
}
CTraDialog::~CTraDialog()
{
}
void CTraDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT4, B1);
DDX_Text(pDX, IDC_EDIT10, B2);
DDX_Text(pDX, IDC_EDIT8, B3);
DDX_Text(pDX, IDC_EDIT11, L1);
DDX_Text(pDX, IDC_EDIT12, L3);
DDX_Text(pDX, IDC_EDIT12, L2);
DDX_Text(pDX, IDC_EDIT13, L3);
DDX_Text(pDX, IDC_EDIT16, H);
DDX_Text(pDX, IDC_EDIT1, x);
DDX_Text(pDX, IDC_EDIT5, y);
DDX_Text(pDX, IDC_EDIT6, z);
DDX_Control(pDX, IDC_COMBO2, Comb);
}
// CTraDialog 消息处理程序
void CTraDialog::setblh()
{
if((B1==90||B1==-90)&&(B2!=0||B3!=0))
MessageBox("数据错误!");
if(B1<-90||B1>90||B2<0||B2>=60||B3<0||B3>=60)
MessageBox("数据错误!");
if((L1==180||L1==-180)&&(L2!=0||L3!=0))
MessageBox("数据错误!");
if(L1<-180||L1>180||L2<0||L2>=60||L3<0||L3>=60)
MessageBox("数据错误!");
double k=B2/60;
B=(TT/180)*(B1+B2/60+B3/3600); // !!!!没考虑B1为负,还有B2不能为int (待修改!)
L=(TT/180)*(L1+L2/60+L3/3600);
}
void CTraDialog::computer2()
{ N=a/(sqrt(1-e*e*sin(B)*sin(B)));
x=(N+H)*cos(B)*cos(L);
y=(N+H)*cos(B)*sin(L);
z=(N*(1-e*e)+H)*sin(B);
}
BEGIN_MESSAGE_MAP(CTraDialog, CDialog)
ON_BN_CLICKED(IDC_BUTTON1, &CTraDialog::OnBnClickedButton1)
ON_CBN_SELCHANGE(IDC_COMBO2, &CTraDialog::OnCbnSelchangeCombo2)
END_MESSAGE_MAP()
void CTraDialog::OnBnClickedButton1()
{
UpdateData();
setblh(); //判断输入数据是否有误
computer2();
UpdateData(FALSE);
//SetDlgItemInt(IDC_EDIT1,x);
//Invalidate();
// TODO: 在此添加控件通知处理程序代码
}
void CTraDialog::OnCbnSelchangeCombo2()
{
UpdateData();
setblh();
int ind=Comb.GetCurSel();
switch(ind)
{
case 0:
f=1/298.257;
a=6378140;
break;
case 1:
f=1/298.223563;
a=6378137;
break;
case 2:
f=1/298.3;
a=6378245;
break;
default:
break;
}
b=a-a*f;
e=sqrt((a*a-b*b)/(a*a));
computer2();
UpdateData(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -