// 高斯大地坐标正反算Dlg.cpp : implementation file
//
#include "stdafx.h"
#include "高斯大地坐标正反算.h"
#include "高斯大地坐标正反算Dlg.h"
#define PI 3.141592653589793238
#define ruo ((float)180*3600/PI)
#include
#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()
/////////////////////////////////////////////////////////////////////////////
// CMyDlg dialog
CMyDlg::CMyDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMyDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMyDlg)
m_B1D = 0;
m_B1F = 0;
m_B1M = 0.0;
m_BD = 0;
m_BF = 0;
m_BM = 0.0;
m_DX = 0.0;
m_DY = 0.0;
m_L0D = 0;
m_L0F = 0;
m_L0M = 0.0;
m_L1D = 0;
m_L1F = 0;
m_L1M = 0.0;
m_LD = 0;
m_LF = 0;
m_LM = 0.0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CMyDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMyDlg)
DDX_Control(pDX, IDC_COMBO1, m_JIZHUN);
DDX_Text(pDX, B1D, m_B1D);
DDX_Text(pDX, B1F, m_B1F);
DDX_Text(pDX, B1M, m_B1M);
DDX_Text(pDX, BD, m_BD);
DDX_Text(pDX, BF, m_BF);
DDX_Text(pDX, BM, m_BM);
DDX_Text(pDX, DX, m_DX);
DDX_Text(pDX, DY, m_DY);
DDX_Text(pDX, L0D, m_L0D);
DDX_Text(pDX, L0F, m_L0F);
DDX_Text(pDX, L0M, m_L0M);
DDX_Text(pDX, L1D, m_L1D);
DDX_Text(pDX, L1F, m_L1F);
DDX_Text(pDX, L1M, m_L1M);
DDX_Text(pDX, LD, m_LD);
DDX_Text(pDX, LF, m_LF);
DDX_Text(pDX, LM, m_LM);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
//{{AFX_MSG_MAP(CMyDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_CBN_KILLFOCUS(IDC_COMBO1, OnKillfocusCombo1)
ON_BN_CLICKED(ZS, OnZS)
ON_BN_CLICKED(FS, OnFS)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyDlg message handlers
BOOL CMyDlg::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
m_JIZHUN.SetCurSel(0);
JIZHUN=0;
return TRUE; // return TRUE unless you set the focus to a control
}
void CMyDlg::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 CMyDlg::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 CMyDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CMyDlg::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
void CMyDlg::OnKillfocusCombo1()
{
// TODO: Add your control notification handler code here
UpdateData(true);
double N0[2][5]={{6399698.902,21562.267,108.973,0.612},{6399596.652,21565.045,108.996,0.603}};
double a00[2][5]={{32140.404,135.3302,0.7092,0.0040},{32144.5189,135.3646,0.7034,0.0041}};
double a40[2][5]={{0.25,0.00252,0.04166},{0.25,0.00253,0.04167}};
double a60[2][5]={{0.166,0.084},{0.167,0.083}};
double a30[2][5]={{0.3333333,0.001123,0.1666667},{0.3333333,0.001123,0.1666667}};
double a50[2][5]={{0.0083,0.1667,0.1968,0.0040},{0.00878,0.1702,0.20382}};
// 正算椭球系数
double BF0[2][5]={{50221746,293622,2350,22},{50228976,293697,2383,22}};
double NF0[2][5]={{6399698.902,21562.266,108.973,0.612,0.004},{6399596.652,21565.047,109.003,0.612,0.004}};
double b20[2][5]={{0.5,0.003369},{0.5,0.00336975}};
double b30[2][5]={{0.333333,0.1666667,0.001123},{0.333333,0.1666667,0.001123}};
double b40[2][5]={{0.25,0.16161,0.00562},{0.25,0.161612,0.005617}};
double b50[2][5]={{0.2,0.1667,0.0088},{0.2,0.16667,0.00878}};
//反算椭球系数
JIZHUN=m_JIZHUN.GetCurSel();
int i;
switch(JIZHUN)
{case 0:
X=6367558.4969;
for(i=0;i {N[i]=N0[0][i];
a0[i]=a00[0][i];
a4[i]=a40[0][i];
a6[i]=a60[0][i];
a3[i]=a30[0][i];
a5[i]=a50[0][i];
NF[i]=NF0[0][i];
BFZ[i]=BF0[0][i];
b2[i]=b20[0][i];
b3[i]=b30[0][i];
b4[i]=b40[0][i];
b5[i]=b50[0][i];
}
break;
case 1:
X=6367452.1328;
for(i=0;i {N[i]=N0[1][i];
a0[i]=a00[1][i];
a4[i]=a40[1][i];
a6[i]=a60[1][i];
a3[i]=a30[1][i];
a5[i]=a50[1][i];
NF[i]=NF0[1][i];
BFZ[i]=BF0[1][i];
b2[i]=b20[1][i];
b3[i]=b30[1][i];
b4[i]=b40[1][i];
b5[i]=b50[1][i];
}
break;
}
UpdateData(false);
}
void CMyDlg::OnZS()
{
// TODO: Add your control notification handler code here
UpdateData(true);
double L=m_LD*3600+m_LF*60+m_LM;
double B=m_BD*3600+m_BF*60+m_BM;
double L0=m_L0D*3600+m_L0F*60+m_L0M;
double l=(L-L0)/ruo;
double cp=cos(B/ruo)*cos(B/ruo); //cos的平方
double N1=N[0]-(N[1]-(N[2]-N[3]*cp)*cp)*cp;
double a01=a0[0]-(a0[1]-(a0[2]-a0[3]*cp)*cp)*cp;
double a41=(a4[0]+a4[1]*cp)*cp-a4[2];
double a61=(a6[0]*cp-a6[1])*cp;
double a31=(a3[0]+a3[1]*cp)*cp-a3[2];
double a51;
if(JIZHUN==0)
a51=a5[0]-(a5[1]-(a5[2]+a5[3]*cp)*cp)*cp;
if(JIZHUN==1)
a51=a5[0]-(a5[1]-a5[2]*cp)*cp;
m_DX=X*B/ruo-(a01-(0.5+(a41+a61*l*l)*l*l)*l*l*N1)*sin(B/ruo)*cos(B/ruo);
m_DY=(1+(a31+a51*l*l)*l*l)*l*N1*cos(B/ruo)+500000;
CString dx,dy;
dx.Format("%0.4f",m_DX);
dy.Format("%0.4f",m_DY);
CWnd *pWnd;
pWnd=GetDlgItem(DX);
pWnd->SetWindowText(dx);
pWnd=GetDlgItem(DY);
pWnd->SetWindowText(dy);
/*double x,y;
x=m_DX;
y=m_DY;
dx.Format("%.4f",x);
m_DX=x;
dy.Format("%0.4f",y);
m_DY=y;*/
//UpdateData(false);
}
void CMyDlg::OnFS()
{
// TODO: Add your control notification handler code here
UpdateData(true);
double bd;
if(JIZHUN==0)
{
bd=m_DX*ruo/6367558.496;
}
if(JIZHUN==1)
{
bd=m_DX*ruo/6367452.133;
}
m_DY=m_DY-500000;
double cp=cos(bd/ruo)*cos(bd/ruo);
double BF1=bd+(BFZ[0]+(BFZ[1]+(BFZ[2]+BFZ[3]*cp)*cp)*cp)*(1e-10)*sin(bd/ruo)*cos(bd/ruo)*ruo;
double cp1=cos(BF1/ruo)*cos(BF1/ruo);
double NF1=NF[0]-(NF[1]-(NF[2]-NF[3]*cp1)*cp1)*cp1+NF[4]*cp1*cp1*cp1*cp1;
double Z=m_DY/(NF1*cos(BF1/ruo));
double b21=(b2[0]+b2[1]*cp1)*cos(BF1/ruo)*sin(BF1/ruo);
double b31=b3[0]-(b3[1]-b3[2]*cp1)*cp1;
double b41=b4[0]+(b4[1]+b4[2]*cp1)*cp1;
double b51=b5[0]-(b5[1]-b5[2]*cp1)*cp1;
double ZP=Z*Z;
double B1;
if(JIZHUN==0)
{
B1=BF1-(1-(b41-0.12*ZP)*ZP)*ZP*b21*ruo;
}
if(JIZHUN==1)
{
B1=BF1-(1-(b41-0.147*ZP)*ZP)*ZP*b21*ruo;
}
double L1=m_L0D*3600+m_L0F*60+m_L0M+(1-(b31-b51*ZP)*ZP)*Z*ruo;
m_L1D=(int)(L1/3600.0);
m_L1F=(int)((L1-m_L1D*3600)/60.0);
m_L1M=L1-m_L1D*3600-m_L1F*60;
m_B1D=(int)(B1/3600.0);
m_B1F=(int)((B1-m_B1D*3600)/60.0);
m_B1M=B1-m_B1D*3600-m_B1F*60;
CString dx;
dx.Format("%d",m_L1D);
CWnd *pWnd;
pWnd=GetDlgItem(L1D);
pWnd->SetWindowText(dx);
dx.Format("%d",m_L1F);
pWnd=GetDlgItem(L1F);
pWnd->SetWindowText(dx);
dx.Format("%0.4f",m_L1M);
pWnd=GetDlgItem(L1M);
pWnd->SetWindowText(dx);
dx.Format("%d",m_B1D);
pWnd=GetDlgItem(B1D);
pWnd->SetWindowText(dx);
dx.Format("%d",m_B1F);
pWnd=GetDlgItem(B1F);
pWnd->SetWindowText(dx);
dx.Format("%0.4f",m_B1M);
pWnd=GetDlgItem(B1M);
pWnd->SetWindowText(dx);
}