?? gaosidlg.cpp
字號:
// gaosiDlg.cpp : implementation file
//
#include "stdafx.h"
#include "gaosi.h"
#include "gaosiDlg.h"
#include "newpara.h"
#include "math.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
int i,k,dmslat1,dmslat2,dmslon1,dmslon2;
double a,Alfa;
double dmslat,dmslon,dmslat3,dmslon3,dmsl0;
double a0 ,a2 ,a4, a6, a8;
double radlat,radlon,radl0,l;
double b,t,sb,cb,ita,e1,e;
double m0 ,m2 ,m4, m6, m8;
double X,l0;
double N,c,v;
double coor_x,coor_y;
double Bf[1000],dB[1000],FBf[1000],bf;
double itaf, tf;
double Nf,Mf;
double B,L,dietaB,dietal;
int B1,B2,L1,L2;
double B3,L3;
/////////////////////////////////////////////////////////////////////////////
// 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()
/////////////////////////////////////////////////////////////////////////////
// CGaosiDlg dialog
CGaosiDlg::CGaosiDlg(CWnd* pParent /*=NULL*/)
: CDialog(CGaosiDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CGaosiDlg)
m_nzuobiao = -1;
m_L0 = 126.0;
m_L = 0.0;
m_B = 0.0;
m_X = 4602268.4765;
m_Y = 404279.7367-500000;
m_h1 = 200.0;
m_B1 = 41.40;
m_h2 = 230.0;
m_e2 = 50.0;
m_y1 = 393289.1530-500000.0;
m_B2 = 41.4016;
m_y2 = 393630.4878-500000.0;
m_result = 0.0;
m_d = 579.5888;
m_e1 = 50.0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CGaosiDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CGaosiDlg)
DDX_Radio(pDX, IDC_WGS84, m_nzuobiao);
DDX_Text(pDX, IDC_EDIT1, m_L0);
DDX_Text(pDX, IDC_EDIT2, m_L);
DDX_Text(pDX, IDC_EDIT3, m_B);
DDX_Text(pDX, IDC_EDIT7, m_X);
DDX_Text(pDX, IDC_EDIT8, m_Y);
DDX_Text(pDX, IDC_EDIT5, m_h1);
DDX_Text(pDX, IDC_EDIT12, m_B1);
DDX_Text(pDX, IDC_EDIT10, m_h2);
DDX_Text(pDX, IDC_EDIT11, m_e2);
DDX_Text(pDX, IDC_EDIT13, m_y1);
DDX_Text(pDX, IDC_EDIT14, m_B2);
DDX_Text(pDX, IDC_EDIT15, m_y2);
DDX_Text(pDX, IDC_EDIT16, m_result);
DDX_Text(pDX, IDC_EDIT18, m_d);
DDX_Text(pDX, IDC_EDIT9, m_e1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CGaosiDlg, CDialog)
//{{AFX_MSG_MAP(CGaosiDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_WGS84, OnWgs84)
ON_EN_CHANGE(IDC_EDIT7, OnChangeEdit7)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BJ54, OnBj54)
ON_BN_CLICKED(IDC_GDZ80, OnGdz80)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGaosiDlg message handlers
BOOL CGaosiDlg::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
//GetDlgItem(IDC_EDIT1)->SetWindowText("");
// GetDlgItem(IDC_EDIT2)->SetWindowText("");
//CButton* pwnd;
//pwnd = (CButton*)GetDlgItem(IDC_WGS84);
// pwnd->SetCheck(1);
return TRUE; // return TRUE unless you set the focus to a control
}
void CGaosiDlg::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 CGaosiDlg::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 CGaosiDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CGaosiDlg::OnWgs84()
{
// TODO: Add your control notification handler code here
a=6378137;Alfa=1.0/298.257223563;
}
void CGaosiDlg::OnBj54()
{
// TODO: Add your control notification handler code here
a=6378245;Alfa=1.0/298.3;
//a=6378356.80231876;Alfa=1.0/298.3;
}
void CGaosiDlg::OnGdz80()
{
// TODO: Add your control notification handler code here
a=6378140;Alfa=1.0/298.257;
}
void CGaosiDlg::OnOK()
{
// TODO: Add extra validation here
CString strzb,WGS84,BJ54,GDZ80;
UpdateData();
//GetDlgItem(IDC_WGS84+m_nzuobiao)->GetWindowText(strzb);
dmslat=m_B;
dmslat1=(int)(dmslat+0.00001);
dmslat2=(int)((dmslat-dmslat1)*100);
dmslat3=(dmslat-dmslat1-dmslat2/100.0)*10000;
dmslon=m_L;
dmslon1=(int)(dmslon+0.00001);
dmslon2=(int)((dmslon-dmslon1)*100);
dmslon3=(dmslon-dmslon1-dmslon2/100.0)*10000;
dmsl0=m_L0;
/*將角度轉化為弧度*/
radlat=(dmslat1+dmslat2/60.0+dmslat3/3600.0)*3.1415926535897932384626433832795/180.0;
radlon=(dmslon1+dmslon2/60.0+dmslon3/3600.0)*3.1415926535897932384626433832795/180.0;
radl0=dmsl0*3.1415926535897932384626433832795/180.0;
l=radlon-radl0;
/*計算橢球的基本參數和中間變量*/
b=a*(1-Alfa);
sb=sin(radlat);
cb=cos(radlat);
t=sb/cb;
e1=sqrt((a/b)*(a/b)-1);
e=sqrt(1-(b/a)*(b/a));
ita=e1*cb;
/*計算m0 m2 m4 m6 m8*/
m0=a*(1-e*e);
m2=3*e*e*m0/2;
m4=5*e*e*m2/4;
m6=7*e*e*m4/6;
m8=9*e*e*m6/8;
/*計算a0 a2 a4 a6 a8*/
a0=m0+m2/2+3*m4/8+5*m6/16+35*m8/128;
a2=m2/2+m4/2+15*m6/32+7*m8/16;
a4=m4/8+3*m6/16+7*m8/32;
a6=m6/32+m8/16;
a8=m8/128;
/*計算X*/
X=a0*radlat-sb*cb*((a2-a4+a6)+(2*a4-16*a6/3)*sb*sb+16*a6*sb*sb*sb*sb/3.0);
/*計算卯酉圈半徑N*/
c=a*a/b;
v=sqrt(1+e1*e1*cb*cb);
N=c/v;
/*計算未知點的坐標*/
coor_x=X+N*sb*cb*l*l/2+N*sb*cb*cb*cb*(5-t*t+9*ita*ita+4*ita*ita*ita*ita)*l*l*l*l/24+N*sb*cb*cb*cb*cb*cb*(61-58*t*t+t*t*t*t)*l*l*l*l*l*l/720;
coor_y=N*cb*l+N*cb*cb*cb*(1-t*t+ita*ita)*l*l*l/6+N*cb*cb*cb*cb*cb*(5-18*t*t+t*t*t*t+14*ita*ita-58*ita*ita*t*t)*l*l*l*l*l/120;
m_X=coor_x;
m_Y=coor_y+500000.0;
UpdateData(FALSE);
//CDialog::OnOK();
}
void CGaosiDlg::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
}
void CGaosiDlg::OnButton1()
{
// TODO: Add your control notification handler code here
CString strzb,WGS84,BJ54,GDZ80;
UpdateData();
GetDlgItem(IDC_WGS84+m_nzuobiao)->GetWindowText(strzb);
dmsl0=m_L0;
radl0=dmsl0*3.1415926535897932384626433832795/180.0;
coor_x=m_X ;
coor_y=m_Y;
/*計算b,e1,e*/
b=a*(1-Alfa);
e1=sqrt((a/b)*(a/b)-1);
e=sqrt(1-(b/a)*(b/a));
/*計算m0 m2 m4 m6 m8*/
m0=a*(1-e*e);
m2=3*e*e*m0/2;
m4=5*e*e*m2/4;
m6=7*e*e*m4/6;
m8=9*e*e*m6/8;
/*計算a0 a2 a4 a6 a8*/
a0=m0+m2/2+3*m4/8+5*m6/16+35*m8/128;
a2=m2/2+m4/2+15*m6/32+7*m8/16;
a4=m4/8+3*m6/16+7*m8/32;
a6=m6/32+m8/16;
a8=m8/128;
X=coor_x;
Bf[0]=X/a0;
i=0;
do
{ FBf[i]=-sin(Bf[i])*cos(Bf[i])*((a2-a4+a6)+(2*a4-16*a6/3)*sin(Bf[i])*sin(Bf[i])+(16/3)*a6*sin(Bf[i])*sin(Bf[i])*sin(Bf[i])*sin(Bf[i]));
Bf[i+1]=(X-FBf[i])/a0;
dB[i]=(Bf[i+1]-Bf[i]);
i++;
} while(fabs(dB[i-1]*180*3600/3.1415926535897932384626433832795)>0.00001);
bf=Bf[i];
/*計算c,v,N,M*/
c=a*a/b;
v=sqrt(1+e1*e1*cos(bf)*cos(bf));
Nf=c/v;
Mf=c/(v*v*v);
tf=sin(bf)/cos(bf);
itaf=e1*cos(bf);
/*計算dietaB,dietal*/
dietaB=tf*coor_y*coor_y/(2*Mf*Nf)-tf*(5+3*tf*tf+itaf*itaf-9*tf*tf*itaf*itaf)*coor_y*coor_y*coor_y*coor_y/(24*Mf*Nf*Nf*Nf)+(61+90*tf*tf+45*tf*tf*tf*tf)*coor_y*coor_y*coor_y*coor_y*coor_y*coor_y/(720*Mf*Nf*Nf*Nf*Nf*Nf);
dietal=coor_y/(Nf*cos(bf)+(1+2*tf*tf+itaf*itaf)*cos(bf)*coor_y*coor_y/(6*Nf))+(5+44*tf*tf+32*tf*tf*tf*tf-2*itaf*itaf-16*itaf*itaf*tf*tf)/(360*Nf*Nf*Nf*Mf*Mf*cos(bf));
B=(bf-dietaB)*180*3600/3.1415926535897932384626433832795;
L=(radl0+dietal)*180*3600/3.1415926535897932384626433832795;
B1=(int)(B/3600);
B2=(int)((B-B1*3600)/60);
B3=(B-B1*3600-B2*60);
L1=(int)(L/3600);
L2=(int)((L-L1*3600)/60);
L3=(L-L1*3600-L2*60);
B=B1+B2/100.0+B3/10000.0;
L=L1+L2/100.0+L3/10000.0;
m_B=B;
m_L=L;
UpdateData(FALSE);
}
void CGaosiDlg::OnButton2()
{
// TODO: Add your control notification handler code here
newpara s;
s.DoModal();
a=s.m_a,Alfa=1/s.m_b;
//CDialog::OnButton2();
}
double DMS2RAD(double x)
{
int a,b;
double y,c;
a=int(x+0.000001);
b=int(100*(x-a));
c=100.0*(100.0*(x-a)-b);
y=(a+b/60.0+c/3600.0)*3.1415926535897932384626433832795/180.0;
return y;
}
void CGaosiDlg::OnButton3()
{
// TODO: Add your control notification handler code here
UpdateData();
double h1,h2,E1,E2,H1,H2,b3,b1,b2,y1,y2,R,d,s,D,ym,e,sinB,Hm,M,N;
e=sqrt(2*Alfa-Alfa*Alfa);
h1=m_h1;h2=m_h2;
E1=m_e1;E2=m_e2;
H1=h1+E1;H2=h2+E2;Hm=(H1+H2)/2.0;
b1=m_B1;b2=m_B2;
y1=m_y1;y2=m_y2;
ym=(y1+y2)/2;
D=m_d;
b1=DMS2RAD(b1);
b2=DMS2RAD(b2);
b3=(b1+b2)/2.0;
sinB=sin(b3);
M=a*(1-e*e)/sqrt(pow((1-e*e*sinB*sinB),3));
N=a/sqrt(1-e*e*sinB*sinB);
R=sqrt(M*N);
s=D*sqrt((1-(H2-H1)*(H2-H1)/(D*D))/((1+H1/R)*(1+H2/R)))+D*D*D/(24.0*R*R);
d=s*(1+ym*ym/(2*R*R));
m_result=d;
UpdateData(FALSE);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -