📄 gszsdlg.cpp
字号:
// gszsDlg.cpp : implementation file
//
#include "stdafx.h"
#include "gszs.h"
#include "gszsDlg.h"
#include "math.h"
#define Pi 3.1415926
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
virtual void OnOK();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGszsDlg dialog
CGszsDlg::CGszsDlg(CWnd* pParent /*=NULL*/)
: CDialog(CGszsDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CGszsDlg)
m_b1 = 0;
m_b2 = 0;
m_b3 = 0.0;
m_L1 = 0;
m_L2 = 0;
m_L3 = 0.0;
m_x = 0.0;
m_y = 0.0;
m_H = 0.0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CGszsDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CGszsDlg)
DDX_Text(pDX, IDC_EDIT1, m_b1);
DDV_MinMaxInt(pDX, m_b1, 0, 180);
DDX_Text(pDX, IDC_EDIT2, m_b2);
DDV_MinMaxInt(pDX, m_b2, 0, 60);
DDX_Text(pDX, IDC_EDIT3, m_b3);
DDV_MinMaxDouble(pDX, m_b3, 0., 60.);
DDX_Text(pDX, IDC_EDIT4, m_L1);
DDV_MinMaxInt(pDX, m_L1, 0, 180);
DDX_Text(pDX, IDC_EDIT5, m_L2);
DDV_MinMaxInt(pDX, m_L2, 0, 60);
DDX_Text(pDX, IDC_EDIT6, m_L3);
DDV_MinMaxDouble(pDX, m_L3, 0., 60.);
DDX_Text(pDX, IDC_EDIT8, m_x);
DDX_Text(pDX, IDC_EDIT9, m_y);
DDX_Text(pDX, IDC_EDIT7, m_H);
DDV_MinMaxDouble(pDX, m_H, -1000., 9000.);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CGszsDlg, CDialog)
//{{AFX_MSG_MAP(CGszsDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_EN_CHANGE(IDC_EDIT2, OnChangeEdit2)
ON_EN_CHANGE(IDC_EDIT7, OnChangeEdit7)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGszsDlg message handlers
BOOL CGszsDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CGszsDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CGszsDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CGszsDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void BLH_xyz(double B,double l,double H,double a,double e2,double xyz[])
{
double N;
N=a/sqrt(1-e2*pow(sin(B),2));
xyz[0]=(N+H)*cos(B)*cos(l);
xyz[1]=(N+H)*cos(B)*sin(l);
xyz[2]=(N*(1-e2)+H)*sin(B);
}
void xyz84_54(double bj_xyz[],double wgs_xyz[])
{
double R[3][3]={1,0,0,0,1,0,0,0,1},d_xyz[3]={0}; //旋转矩阵R和平移参数dx,dy,dz
int i,j;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
bj_xyz[i]+=wgs_xyz[j]*R[i][j];
}
}
void xyz_BLH(double BLH[],double a,double e2,double xyz[])
{
int i;
double N=a,m,n;
n=pow(xyz[0],2)+pow(xyz[1],2);
m=xyz[2]/sqrt(n);
BLH[1]=atan(xyz[1]/xyz[0]);
BLH[2]=sqrt(2*n)-N;
for(i=0;i<4;i++)
{
BLH[0]=atan(m)/(1-e2*N/(N+BLH[2]));
BLH[2]=sqrt(n)/cos(BLH[0])-N;
N=a/sqrt(1-e2*pow(sin(BLH[0]),2));
}
}
double N(double x)
{
double n;
n=6399698.902-(21562.276-(108.973-0.612*x)*x)*x;
return (n);
}
double A0(double x)
{
double a;
a=32140.404-(135.3302-(0.7092-0.004*x)*x)*x;
return (a);
}
double A4(double x)
{
double a;
a=(0.25+0.00252*x)*x-0.04166;
return (a);
}
double A6(double x)
{
double a;
a=(0.166*x-0.084)*x;
return (a);
}
double A3(double x)
{
double a;
a=(0.3333333+0.001123*x)*x-0.1666667;
return (a);
}
double A5(double x)
{
double a;
a=0.0083-(0.1667-(0.1968+0.004*x)*x)*x;
return (a);
}
void CGszsDlg::OnButton1()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
double B;
double p,l,l2;
double s,s2,c,c2;
double a0,a4,a6,a3,a5,n;
double wgs_a=6378137,wgs_e2=0.006694379901,bj_a=6378245,bj_e2=0.0066933421623;
double wgs_xyz[3],bj_xyz[3]={0},bj_BLH[3];
p=180*3600/Pi;
B=(m_b1*3600+m_b2*60+m_b3)/p;
l=(m_L1*3600+m_L2*60+m_L3)/p;
BLH_xyz(B,l,m_H,wgs_a,wgs_e2,wgs_xyz); // WGS-84坐标系下大地坐标系到空间直角坐标系
xyz84_54(bj_xyz,wgs_xyz); //WGS-84空间直角坐标系到北京54空间直角坐标系
xyz_BLH(bj_BLH,bj_a,bj_e2,bj_xyz); // 北京54坐标系下空间直角坐标系到大地坐标系
bj_BLH[1]=bj_BLH[1]*180/Pi; //北京54坐标系下大地坐标系到高斯坐标系
bj_BLH[1]=(bj_BLH[1]-(int(bj_BLH[1])/3)*3)*Pi/180;
l2=pow(bj_BLH[1],2);
s=sin(bj_BLH[0]);
s2=pow(s,2);
c=cos(bj_BLH[0]);
c2=pow(c,2);
n=N(c2);
a0=A0(c2);
a4=A4(c2);
a6=A6(c2);
a3=A3(c2);
a5=A5(c2);
m_x=6367558.4969*B-(a0-(0.5+(a4+a6*l2)*l2)*l2*n)*s*c;
m_y=(1+(a3+a5*l2)*l2)*l*n*c;
UpdateData(FALSE);
}
void CAboutDlg::OnOK()
{
// TODO: Add extra validation here
CDialog::OnOK();
}
void CGszsDlg::OnChangeEdit2()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
void CGszsDlg::OnChangeEdit7()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -