?? projection_gaussdlg.cpp
字號:
// Projection_GaussDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Projection_Gauss.h"
#include "Projection_GaussDlg.h"
#include <math.h>
#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)
//}}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)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CProjection_GaussDlg dialog
CProjection_GaussDlg::CProjection_GaussDlg(CWnd* pParent /*=NULL*/)
: CDialog(CProjection_GaussDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CProjection_GaussDlg)
m_Coordinate = -1;
m_projType = -1;
m_L1_degree = 0.0;
m_L1_minute = 0.0;
m_L1_second = 0.0;
m_L2_degree = 0.0;
m_L2_minute = 0.0;
m_L2_second = 0.0;
m_X1 = 0.0;
m_X2 = 0.0;
m_Y1 = 0.0;
m_Y2 = 0.0;
m_L0_second = 0.0;
m_L0_minute = 0.0;
m_L0_degree = 0.0;
m_B1_degree = 0.0;
m_B1_minute = 0.0;
m_B1_second = 0.0;
m_B2_degree = 0.0;
m_B2_minute = 0.0;
m_B2_second = 0.0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CProjection_GaussDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CProjection_GaussDlg)
DDX_Control(pDX, IDC_BUTTON1, m_btn);
DDX_Control(pDX, IDC_EDIT_Y2, m_Y2Ctrl);
DDX_Control(pDX, IDC_EDIT_X2, m_X2Ctrl);
DDX_Control(pDX, IDC_EDIT_Y1, m_Y1Ctrl);
DDX_Control(pDX, IDC_EDIT_X1, m_X1Ctrl);
DDX_Control(pDX, IDC_EDIT_L2_second, m_L2_secondCtrl);
DDX_Control(pDX, IDC_EDIT_L2_minute, m_L2_minuteCtrl);
DDX_Control(pDX, IDC_EDIT_L1_second, m_L1_secondCtrl);
DDX_Control(pDX, IDC_EDIT_L1_minute, m_L1_minuteCtrl);
DDX_Control(pDX, IDC_EDIT_L1_degree, m_L1_degreeCtrl);
DDX_Control(pDX, IDC_EDIT_B2_second, m_B2_secondCtrl);
DDX_Control(pDX, IDC_EDIT_B2_degree, m_B2_degreeCtrl);
DDX_Control(pDX, IDC_EDIT_B2_minute, m_B2_minuteCtrl);
DDX_Control(pDX, IDC_EDIT_B1_second, m_B1_secondCtrl);
DDX_Control(pDX, IDC_EDIT_B1_minute, m_B1_minuteCtrl);
DDX_Control(pDX, IDC_EDIT_B1_degree, m_B1_degreeCtrl);
DDX_Control(pDX, IDC_EDIT_L2_degree, m_L2_degreeCtrl);
DDX_Radio(pDX, IDC_RADIO_54, m_Coordinate);
DDX_Radio(pDX, IDC_RADIO_zhengsuan, m_projType);
DDX_Text(pDX, IDC_EDIT_L1_degree, m_L1_degree);
DDX_Text(pDX, IDC_EDIT_L1_minute, m_L1_minute);
DDX_Text(pDX, IDC_EDIT_L1_second, m_L1_second);
DDX_Text(pDX, IDC_EDIT_L2_degree, m_L2_degree);
DDX_Text(pDX, IDC_EDIT_L2_minute, m_L2_minute);
DDX_Text(pDX, IDC_EDIT_L2_second, m_L2_second);
DDX_Text(pDX, IDC_EDIT_X1, m_X1);
DDX_Text(pDX, IDC_EDIT_X2, m_X2);
DDX_Text(pDX, IDC_EDIT_Y1, m_Y1);
DDX_Text(pDX, IDC_EDIT_Y2, m_Y2);
DDX_Text(pDX, IDC_EDIT_L0_miao, m_L0_second);
DDX_Text(pDX, IDC_EDIT_L0_fen, m_L0_minute);
DDX_Text(pDX, IDC_EDIT_L0_du, m_L0_degree);
DDX_Text(pDX, IDC_EDIT_B1_degree, m_B1_degree);
DDX_Text(pDX, IDC_EDIT_B1_minute, m_B1_minute);
DDX_Text(pDX, IDC_EDIT_B1_second, m_B1_second);
DDX_Text(pDX, IDC_EDIT_B2_degree, m_B2_degree);
DDX_Text(pDX, IDC_EDIT_B2_minute, m_B2_minute);
DDX_Text(pDX, IDC_EDIT_B2_second, m_B2_second);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CProjection_GaussDlg, CDialog)
//{{AFX_MSG_MAP(CProjection_GaussDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON_HELP, OnButtonHelp)
ON_BN_CLICKED(IDC_BUTTON_Transfer, OnBUTTONTransfer)
ON_BN_CLICKED(IDC_RADIO_zhengsuan, OnRADIOzhengsuan)
ON_BN_CLICKED(IDC_BUTTON_Transfer2, OnBUTTONTransfer2)
ON_BN_CLICKED(IDC_RADIO_fansuan, OnRADIOfansuan)
ON_BN_CLICKED(IDC_RADIO_54, OnRadio54)
ON_BN_CLICKED(IDC_RADIO_80, OnRadio80)
ON_BN_CLICKED(IDC_RADIO_WGS84, OnRadioWgs84)
ON_BN_CLICKED(IDC_BUTTON1, OnBUTTONTransfer)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CProjection_GaussDlg message handlers
BOOL CProjection_GaussDlg::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 CProjection_GaussDlg::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 CProjection_GaussDlg::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 CProjection_GaussDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CProjection_GaussDlg::OnButtonHelp()
{
// TODO: Add your control notification handler code here
MessageBox("Y坐標不加帶號和加常數");
}
void CProjection_GaussDlg::OnBUTTONTransfer() //正算
{
// TODO: Add your control notification handler code here
UpdateData();
//高斯正算公式
double e=3.1415926/180;
double t,N,v,l0,k,B1,L1,L0,X;
B1=m_B1_degree+m_B1_minute/60+m_B1_second/3600;
L1=m_L1_degree+m_L1_minute/60+m_L1_second/3600;
L0=m_L0_degree+m_L0_minute/60+m_L0_second/3600;
t=tan( B1*e);
k=E1*cos( B1*e)*cos( B1*e);
v=1+k;
N=c/sqrt(v);
l0=L1-L0;
p=cos( B1*e)*l0/p0;
X=a0*B1+a2*sin(2* B1*e)+a4*sin(4*B1*e)+a6*sin(6*B1*e)+a8*sin(8*B1*e);
m_X1=X+N*t*(1+((5-t*t+(9+4*k)*k)+((61+(t*t-58)*t*t+(9-11*t*t)*30*k)+(1385+(-3111+(543-t*t)*t*t)*t*t)*p*p/56)*p*p/30)*p*p/12)*p*p/2;
m_Y1=500000+N*(1+((1-t*t+k)+((5+t*t*(t*t-18-58*k)+14*k)+(61+(-479+(179-t*t)*t*t)*t*t)*p*p/42)*p*p/20)*p*p/6)*p;
UpdateData(false);
}
void CProjection_GaussDlg::OnRADIOzhengsuan() //
{
// TODO: Add your control notification handler code here
// m_projType=1;
m_B1_degree=m_B1_minute=m_B1_second=0;
m_L1_degree=m_L1_minute=m_L1_second=0;
m_B2_degree=m_B2_minute=m_B2_second=0;
m_L2_degree=m_L2_minute=m_L2_second=0;
m_L1_degreeCtrl.EnableWindow(true);
m_L1_minuteCtrl.EnableWindow(true);
m_L1_secondCtrl.EnableWindow(true);
m_B1_degreeCtrl.EnableWindow(true);
m_B1_minuteCtrl.EnableWindow(true);
m_B1_secondCtrl.EnableWindow(true);
m_X1Ctrl.EnableWindow(true);
m_Y1Ctrl.EnableWindow(true);
m_L2_degreeCtrl.EnableWindow(false);
m_L2_minuteCtrl.EnableWindow(false);
m_L2_secondCtrl.EnableWindow(false);
m_B2_degreeCtrl.EnableWindow(false);
m_B2_minuteCtrl.EnableWindow(false);
m_B2_secondCtrl.EnableWindow(false);
m_X2Ctrl.EnableWindow(false);
m_Y2Ctrl.EnableWindow(false);
}
void CProjection_GaussDlg::OnBUTTONTransfer2() // 反算
{
// TODO: Add your control notification handler code here
double tf,Nf,vf,Y,q,Bf,k,B0,l0,B,L,L0;
double e=3.1415926/180;
UpdateData();
L0=m_L0_degree+m_L0_minute/60+m_L0_second/3600;
B0=m_X2*q0;
Bf=B0+sin(2*B0)*(q2+sin(B0)*sin(B0)*(q4+sin(B0)*sin(B0)*(q6+q8*sin(B0)*sin(B0))));
Y=m_Y2-500000;
tf=tan(Bf);
k=E1*cos(Bf)*cos(Bf);
vf=1+k;
Nf=c/sqrt(vf);
q=Y/Nf;
B=Bf/e+p0*tf*(-vf+((5+3*tf*tf*(1+(-2-3*k)*k)+3*k*(2-k))+(-(61+45*tf*tf*(2+tf*tf)+(107+(-162-45*tf*tf)*tf*tf)*k)+(1385+(3633+(4095+1575*tf*tf)*tf*tf)*tf*tf)*q*q/56)*q*q/30)*q*q/12)*q*q/2;
m_B2_degree=int (B);
m_B2_minute=int( (B-int(B))*60);
m_B2_second=int (((B-int(B))*60-m_B2_minute)*60);
l0=p0*q/cos(Bf)*(1+(-(1+2*tf*tf+k)+((5+4*tf*tf*(7+6*tf*tf)+2*k*(3+4*tf*tf))-(61+(662+(1320+720*tf*tf)*tf*tf)*tf*tf)*q*q/42)*q*q/20)*q*q/6);
L=L0+l0;
m_L2_degree=int(L);
m_L2_minute=int( (L-int(L))*60);
m_L2_second=int (((L-int(L))*60-m_L2_minute)*60);
UpdateData(false);
}
void CProjection_GaussDlg::OnRADIOfansuan()
{
// TODO: Add your control notification handler code here
// m_projType=2;
m_B1_degree=m_B1_minute=m_B1_second=0;
m_L1_degree=m_L1_minute=m_L1_second=0;
m_B2_degree=m_B2_minute=m_B2_second=0;
m_L2_degree=m_L2_minute=m_L2_second=0;
m_L2_degreeCtrl.EnableWindow(true);
m_L2_minuteCtrl.EnableWindow(true);
m_L2_secondCtrl.EnableWindow(true);
m_B2_degreeCtrl.EnableWindow(true);
m_B2_minuteCtrl.EnableWindow(true);
m_B2_secondCtrl.EnableWindow(true);
m_X2Ctrl.EnableWindow(true);
m_Y2Ctrl.EnableWindow(true);
m_L1_degreeCtrl.EnableWindow(false);
m_L1_minuteCtrl.EnableWindow(false);
m_L1_secondCtrl.EnableWindow(false);
m_B1_degreeCtrl.EnableWindow(false);
m_B1_minuteCtrl.EnableWindow(false);
m_B1_secondCtrl.EnableWindow(false);
m_X1Ctrl.EnableWindow(false);
m_Y1Ctrl.EnableWindow(false);
}
void CProjection_GaussDlg::OnRadio54() //北京54坐標系
{
// TODO: Add your control notification handler code here
m_Coordinate=1;
a=6378245;
E1=6.738525414683E-03;
E=6.693421622966E-03;
c=6399698.901782711;
a0=111134.8610828;
a2=-16036.48022;
a4=16.82805;
a6=-2.197E-02;
a8=3E-05;
q0=157046064.12328E-15;
q2=2525886946.8158E-12;
q4=-14919317.6572E-12;
q6=120717.4265E-12;
q8=-1075.1509E-12;
}
void CProjection_GaussDlg::OnRadio80() //西安80坐標系
{
// TODO: Add your control notification handler code here
m_Coordinate=2;
a=6378140;
c=6399596.6519880105;
E1=6.739501819473E-03;
E=6.694384999588E-03;
a0=111133.0046793;
a2=-16038.52818;
a4=16.83263;
a6=-2.198E-02;
a8=3E-05;
q0=157048687.47416E-15;
q2=2526252791.9786E-12;
q4=-14923644.4356E-12;
q6=120769.9608E-12;
q8=-1075.7700E-12;
}
void CProjection_GaussDlg::OnRadioWgs84() //WGS84坐標系
{
// TODO: Add your control notification handler code here
m_Coordinate=3;
c=6399593.6258;
E1=6.73949674227E-03;
E=6.6943799013E-03;
a=6378137;
a0=111132.9525494;
a2=-16038.50840;
a4=16.83260;
a6=-2.198E-02;
a8=3E-05;
q0=157048761.142065E-15;
q2=2526250855.8867E-12;
q4=-14923621.5362E-12;
q6=120769.6828E-12;
q8=-1075.7667E-12;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -