高斯投影坐标正反算

源代码在线查看: 高斯投影坐标正反算dlg.cpp

软件大小: 32 K
上传用户: newyearday
关键词: 高斯 投影
下载地址: 免注册下载 普通下载 VIP

相关代码

				// 高斯投影坐标正反算Dlg.cpp : implementation file
				//
				
				#include "stdafx.h"
				#include "高斯投影坐标正反算.h"
				#include "高斯投影坐标正反算Dlg.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()
				
				/////////////////////////////////////////////////////////////////////////////
				// CMyDlg dialog
				
				CMyDlg::CMyDlg(CWnd* pParent /*=NULL*/)
					: CDialog(CMyDlg::IDD, pParent)
				{
					//{{AFX_DATA_INIT(CMyDlg)
					m_nBd = 0;
					m_nBf = 0;
					m_nBm = 0;
					m_nLd = 0;
					m_nLf = 0;
					m_nLm = 0;
					m_nx = 0.0;
					m_ny = 0.0;
					m_ni = 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_Text(pDX, IDC_EDIT1, m_nBd);
					DDX_Text(pDX, IDC_EDIT2, m_nBf);
					DDX_Text(pDX, IDC_EDIT3, m_nBm);
					DDX_Text(pDX, IDC_EDIT4, m_nLd);
					DDX_Text(pDX, IDC_EDIT5, m_nLf);
					DDX_Text(pDX, IDC_EDIT6, m_nLm);
					DDX_Text(pDX, IDC_EDIT7, m_nx);
					DDX_Text(pDX, IDC_EDIT8, m_ny);
					DDX_Text(pDX, IDC_EDIT9, m_ni);
					//}}AFX_DATA_MAP
				}
				
				BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
					//{{AFX_MSG_MAP(CMyDlg)
					ON_WM_SYSCOMMAND()
					ON_WM_PAINT()
					ON_WM_QUERYDRAGICON()
					ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
					ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
					//}}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
					
					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::OnRadio1() 
				{
					// TODO: Add your control notification handler code here
					CWnd *pWndButn;
					pWndButn=GetDlgItem(IDC_EDIT1);
					pWndButn->EnableWindow(TRUE);
					pWndButn=GetDlgItem(IDC_EDIT2);
					pWndButn->EnableWindow(TRUE);
					pWndButn=GetDlgItem(IDC_EDIT3);
					pWndButn->EnableWindow(TRUE);
					pWndButn=GetDlgItem(IDC_EDIT4);
					pWndButn->EnableWindow(TRUE);
					pWndButn=GetDlgItem(IDC_EDIT5);
					pWndButn->EnableWindow(TRUE);
					pWndButn=GetDlgItem(IDC_EDIT6);
					pWndButn->EnableWindow(TRUE);
					pWndButn=GetDlgItem(IDC_EDIT7);
					pWndButn->EnableWindow(FALSE);
					pWndButn=GetDlgItem(IDC_EDIT8);
					pWndButn->EnableWindow(FALSE);
					pWndButn=GetDlgItem(IDC_EDIT9);
					pWndButn->EnableWindow(FALSE);
					j=1;
				}
				
				void CMyDlg::OnRadio2() 
				{
					// TODO: Add your control notification handler code here
					CWnd *pWndButn;
					pWndButn=GetDlgItem(IDC_EDIT1);
					pWndButn->EnableWindow(FALSE);
					pWndButn=GetDlgItem(IDC_EDIT2);
					pWndButn->EnableWindow(FALSE);
					pWndButn=GetDlgItem(IDC_EDIT3);
					pWndButn->EnableWindow(FALSE);
					pWndButn=GetDlgItem(IDC_EDIT4);
					pWndButn->EnableWindow(FALSE);
					pWndButn=GetDlgItem(IDC_EDIT5);
					pWndButn->EnableWindow(FALSE);
					pWndButn=GetDlgItem(IDC_EDIT6);
					pWndButn->EnableWindow(FALSE);
					pWndButn=GetDlgItem(IDC_EDIT7);
					pWndButn->EnableWindow(TRUE);
					pWndButn=GetDlgItem(IDC_EDIT8);
					pWndButn->EnableWindow(TRUE);
					pWndButn=GetDlgItem(IDC_EDIT9);
					pWndButn->EnableWindow(TRUE);
					j=2;
				}
				
				void CMyDlg::OnOK() 
				{
					// TODO: Add extra validation here
					if(j==1)
					{
					UpdateData(TRUE);
					Bd=GetDlgItemInt(IDC_EDIT1);
					Bf=GetDlgItemInt(IDC_EDIT2);
					Bm=GetDlgItemInt(IDC_EDIT3);
					Ld=GetDlgItemInt(IDC_EDIT4);
					Lf=GetDlgItemInt(IDC_EDIT5);
					Lm=GetDlgItemInt(IDC_EDIT6);
					p=(180*3600)/Pi;		
					B=(Bd+Bf/60+Bm/3600)*Pi/180.0;
				    L=(Ld+Lf/60+Lm/3600)*Pi/180.0;
					BH=int(Bd*3600+Bf*60+Bm);
					LH=int(Ld*3600+Lf*60+Lm);
					l0=((LH+10800)%21600)/p;
					i=int((LH+10800)/21600)*6-3;
					N=6399698.902-(21562.267-(108.973-0.612*cos(B)*cos(B))*cos(B)*cos(B))*cos(B)*cos(B);
					a0=32140.404-(135.3302-(0.7092-0.0040*cos(B)*cos(B))*cos(B)*cos(B))*cos(B)*cos(B);
					a4=(0.25+0.00252*cos(B)*cos(B))*cos(B)*cos(B)-0.04166;
					a6=(0.166*cos(B)*cos(B)-0.084)*cos(B)*cos(B);
					a3=(0.3333333+0.001123*cos(B)*cos(B))*cos(B)*cos(B)-0.1666667;
					a5=0.0083-(0.1667-(0.1968+0.0040*cos(B)*cos(B))*cos(B)*cos(B))*cos(B)*cos(B);		
					x=6367558.4969*BH/p-(a0-(0.5+(a4+a6*l0*l0)*l0*l0)*l0*l0*N)*sin(B)*cos(B);
					y=(1+(a3+a5*l0*l0)*l0*l0)*l0*N*cos(B);
					m_nx=x;
					m_ny=y;
					m_ni=i;
					UpdateData(FALSE);
					CWnd *pWndButn;
					pWndButn=GetDlgItem(IDC_EDIT1);
					pWndButn->EnableWindow(TRUE);
					pWndButn=GetDlgItem(IDC_EDIT2);
					pWndButn->EnableWindow(TRUE);
					pWndButn=GetDlgItem(IDC_EDIT3);
					pWndButn->EnableWindow(TRUE);
					pWndButn=GetDlgItem(IDC_EDIT4);
					pWndButn->EnableWindow(TRUE);
					pWndButn=GetDlgItem(IDC_EDIT5);
					pWndButn->EnableWindow(TRUE);
					pWndButn=GetDlgItem(IDC_EDIT6);
					pWndButn->EnableWindow(TRUE);
					pWndButn=GetDlgItem(IDC_EDIT7);
					pWndButn->EnableWindow(TRUE);
					pWndButn=GetDlgItem(IDC_EDIT8);
					pWndButn->EnableWindow(TRUE);
					pWndButn=GetDlgItem(IDC_EDIT9);
					pWndButn->EnableWindow(TRUE);
					}
					else if(j==2)
					{
						UpdateData(TRUE);
						x=m_nx;
						y=m_ny;
					//x=GetDlgItemInt(IDC_EDIT7);
					//y=GetDlgItemInt(IDC_EDIT8);
					i=GetDlgItemInt(IDC_EDIT9);
					p=180*3600/Pi;
					q=x*p/6367558.4969;
					Q=(q/3600)*Pi/180;
					BF1=q+(50221746+(293622+(2350+22*cos(Q)*cos(Q))*cos(Q)*cos(Q))*cos(Q)*cos(Q))*0.0000000001*sin(Q)*cos(Q)*p;
					BF=(BF1/3600)*Pi/180;
					Nf=6399698.902-(21562.267-(108.973-0.612*cos(BF)*cos(BF))*cos(BF)*cos(BF))*cos(BF)*cos(BF);
					Z=y/(Nf*cos(BF));
					b2=(0.5+0.003369*cos(BF)*cos(BF))*sin(BF)*cos(BF);
					b3=0.333333-(0.166667-0.001123*cos(BF)*cos(BF))*cos(BF)*cos(BF);
					b4=0.25+(0.16161+0.00562*cos(BF)*cos(BF))*cos(BF)*cos(BF);
					b5=0.2-(0.1667-0.0088*cos(BF)*cos(BF))*cos(BF)*cos(BF);
					B=BF1-(1-(b4-0.147*Z*Z)*Z*Z)*Z*Z*b2*p;
					l=(1-(b3-b5*Z*Z)*Z*Z)*Z*p;
					L=l;
					Bd=int(B/3600);
					Bf=int((B-Bd*3600)/60);
					Bm=int(B-Bd*3600-Bf*60);
					Ld=int(L/3600);
					Lf=int((L-Ld*3600)/60);
					Lm=int(L-Ld*3600-Lf*60);
					m_nBd=int(Bd);
					m_nBf=int(Bf);
					m_nBm=int(Bm);
					m_nLd=int(Ld)+i;
					m_nLf=int(Lf);
					m_nLm=int(Lm);
					UpdateData(FALSE);
					CWnd *pWndButn;
					pWndButn=GetDlgItem(IDC_EDIT1);
					pWndButn->EnableWindow(TRUE);
					pWndButn=GetDlgItem(IDC_EDIT2);
					pWndButn->EnableWindow(TRUE);
					pWndButn=GetDlgItem(IDC_EDIT3);
					pWndButn->EnableWindow(TRUE);
					pWndButn=GetDlgItem(IDC_EDIT4);
					pWndButn->EnableWindow(TRUE);
					pWndButn=GetDlgItem(IDC_EDIT5);
					pWndButn->EnableWindow(TRUE);
					pWndButn=GetDlgItem(IDC_EDIT6);
					pWndButn->EnableWindow(TRUE);
					pWndButn=GetDlgItem(IDC_EDIT7);
					pWndButn->EnableWindow(TRUE);
					pWndButn=GetDlgItem(IDC_EDIT8);
					pWndButn->EnableWindow(TRUE);
					pWndButn=GetDlgItem(IDC_EDIT9);
					pWndButn->EnableWindow(TRUE);
					}
					else
					{
						MessageBox("请先选择计算类型!","提示",NULL);
					}
				
				}
				
				void CMyDlg::OnCancel() 
				{
					// TODO: Add extra cleanup here
					CDialog::OnCancel();
				}
							

相关资源