⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dialog1.cpp

📁 用visual c++实现地理信息系统中常用的投影
💻 CPP
字号:
// DIALOG1.cpp : implementation file
//

#include "stdafx.h"
#include "Projection.h"
#include "DIALOG1.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#include <math.h>


/////////////////////////////////////////////////////////////////////////////
// CDIALOG1 dialog


CDIALOG1::CDIALOG1(CWnd* pParent /*=NULL*/)
	: CDialog(CDIALOG1::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDIALOG1)
	m_EW0 = _T("E");
	m_EW1 = _T("E");
	m_EW2 = _T("E");
	m_NS0 = _T("N");
	m_NS1 = _T("N");
	m_NS2 = _T("N");
	m_B0 = 30;
	m_B1 = 5;
	m_B2 = 55;
	m_DB = 5;
	m_DL = 5;
	m_L0 = 105;
	m_L1 = 70;
	m_L2 = 140;
	m_M = 10000000;
	m_R = 6371116;
	//}}AFX_DATA_INIT
}


void CDIALOG1::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDIALOG1)
	DDX_Control(pDX, IDC_LIST1, m_List);
	DDX_CBString(pDX, IDC_COMBO_EW0, m_EW0);
	DDX_CBString(pDX, IDC_COMBO_EW1, m_EW1);
	DDX_CBString(pDX, IDC_COMBO_EW2, m_EW2);
	DDX_CBString(pDX, IDC_COMBO_NS0, m_NS0);
	DDX_CBString(pDX, IDC_COMBO_NS1, m_NS1);
	DDX_CBString(pDX, IDC_COMBO_NS2, m_NS2);
	DDX_Text(pDX, IDC_EDIT_B0, m_B0);
	DDX_Text(pDX, IDC_EDIT_B1, m_B1);
	DDX_Text(pDX, IDC_EDIT_B2, m_B2);
	DDX_Text(pDX, IDC_EDIT_DB1, m_DB);
	DDX_Text(pDX, IDC_EDIT_DL1, m_DL);
	DDX_Text(pDX, IDC_EDIT_L0, m_L0);
	DDX_Text(pDX, IDC_EDIT_L1, m_L1);
	DDX_Text(pDX, IDC_EDIT_L2, m_L2);
	DDX_Text(pDX, IDC_EDIT_M, m_M);
	DDX_Text(pDX, IDC_EDIT_R, m_R);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDIALOG1, CDialog)
	//{{AFX_MSG_MAP(CDIALOG1)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDIALOG1 message handlers
BOOL CDIALOG1::OnInitDialog()
{
	CDialog::OnInitDialog();

	this->m_List.InsertColumn (0,"No",LVCFMT_CENTER,24);
	this->m_List.InsertColumn (1,"B",LVCFMT_CENTER,30);
	this->m_List.InsertColumn (2,"L",LVCFMT_CENTER,30);
	this->m_List.InsertColumn (3,"X",LVCFMT_CENTER,70);
	this->m_List.InsertColumn (4,"Y",LVCFMT_CENTER,70);
	this->m_List.InsertColumn (5,"u1",LVCFMT_CENTER,60);
	this->m_List.InsertColumn (6,"u2",LVCFMT_CENTER,60);
	this->m_List.InsertColumn (7,"w/2",LVCFMT_CENTER,60);

	LONG lStyle = m_List.SendMessage(LVM_GETEXTENDEDLISTVIEWSTYLE);       //画表格边框
	lStyle |= LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_HEADERDRAGDROP;
	m_List.SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, 0,	(LPARAM)lStyle);

	return TRUE;  // return TRUE  unless you set the focus to a control
}


void CDIALOG1::OnButton1() 
{
	// TODO: Add your control notification handler code here
	double	u1 = 0.0 ,u2 = 0.0 ,     //初始化垂直圈,等高圈长度比
			x = 0.0 ,y = 0.0 ,       //平面直角坐标
			w2 = 0.0 ;               //最大角度变形
   double   z,a,p;                   //天顶距、方位角、动径
   double   b,l,b0,l0;                //中间变量(角度->弧度)
   int      B,L;                     //纬度、经度
   int      k = 0;                   //NO.
   CString str[8];
 
   UpdateData();
   m_List.DeleteAllItems();
	  				
	  for(B=m_B1;B<=m_B2;B+=m_DB)          //纬度方向
		{
			for(L=m_L1;L<=m_L2;L+=m_DL)    //经度方向
			{	
   			   b=B*3.1415926/180;       //角度->为弧度
			   l=L*3.1415926/180;
			   b0=(m_B0)*3.1415926/180;
			   l0=(m_L0)*3.1415926/180;					
					
			   ///////////////////计算天顶距Z
			   z=acos(sin(b)*sin(b0)+cos(b)*cos(b0)*cos(l-l0)); 
			 
			   ///////////////////计算方位角a			
		       if(l==l0)
				{
					a=0;							
				}
				else
					a=atan(1/(tan(b)*cos(b0)*(1/sin(l-l0))-sin(b0)*(1/tan(l-l0))));
					if((b-b0)!=0)
					{   
					   if((b-b0)>0)								
					   {       
						 if((l-l0)>0)        
							a=a;  
						  else        
							a=a+2*3.1415926;   
					   }
					   else    
						    a=3.1415926+a;
					}
																													
				p = 200.0 * m_R * sin(z/2.0)/m_M;      //计算动径
			    u1 = cos(z/2.0);      //垂直圈长度比
				u2 = 1/cos(z/2.0);    //等高圈长度比
			    x = p * cos(a);       //坐标X
				y = p * sin(a);       //坐标Y
				w2 = 180.0/3.1415926*asin((u2 - u1)/(u2 + u1)); //最大角度变形
						
				this->m_List .InsertItem (k,"");                //插入列表项
				str[0].Format("%d",k+1);    m_List.SetItemText (k,0,str[0]);
				str[1].Format("%d",B);      m_List.SetItemText (k,1,str[1]);
				str[2].Format("%d",L);      m_List.SetItemText (k,2,str[2]);
				str[6].Format("%0.4f",u2);  m_List.SetItemText (k,6,str[6]);
				str[3].Format("%0.4f",x);   m_List.SetItemText (k,3,str[3]);
				str[4].Format("%0.4f",y);   m_List.SetItemText (k,4,str[4]);
				str[5].Format("%0.4f",u1);  m_List.SetItemText (k,5,str[5]);
				str[7].Format("%0.4f",w2);  m_List.SetItemText (k,7,str[7]);

				k++;

			}
		}
           
		UpdateData(false);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -