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

📄 casmcoordtransdlg.cpp

📁 坐标转换程序
💻 CPP
字号:
// CASMCoordTransDlg.cpp : implementation file
//

#include "stdafx.h"
#include "CASMCoordTrans.h"
#include "CASMCoordTransDlg.h"
#include "CoordTrans.h"
#include <iomanip.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()

/////////////////////////////////////////////////////////////////////////////
// CCASMCoordTransDlg dialog

CCASMCoordTransDlg::CCASMCoordTransDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CCASMCoordTransDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CCASMCoordTransDlg)
	m_inputfile = _T("");
	m_outputfile = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CCASMCoordTransDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CCASMCoordTransDlg)
	DDX_Text(pDX, IDC_EDIT1, m_inputfile);
	DDX_Text(pDX, IDC_EDIT2, m_outputfile);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CCASMCoordTransDlg, CDialog)
	//{{AFX_MSG_MAP(CCASMCoordTransDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_inputbrowse, Oninputbrowse)
	ON_BN_CLICKED(IDC_coverse, Oncoverse)
	ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
	ON_BN_CLICKED(IDC_BUTTON2, OnOutputPath)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCASMCoordTransDlg message handlers

BOOL CCASMCoordTransDlg::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 CCASMCoordTransDlg::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 CCASMCoordTransDlg::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 CCASMCoordTransDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}


void CCASMCoordTransDlg::Oninputbrowse() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	CFileDialog filedlg(TRUE);
	filedlg.m_ofn.lpstrTitle="Pleas choose the WGS84 Data";
	filedlg.m_ofn.lpstrFilter="Data File(*.dat)";
	CString fn,pn,ft,fp;
	if (IDOK==filedlg.DoModal())
	{
		pn=filedlg.GetPathName();
		fn=filedlg.GetFileName();
		ft=filedlg.GetFileTitle();
     }
	CStdioFile file(pn,CFile::modeRead);
	m_inputfile=pn;
	CString ca,cb;
	ca=pn.Left(pn.Find("."));
	m_outputfile=ca+"_out";
	UpdateData(FALSE);
}

void CCASMCoordTransDlg::Oncoverse() 
{
	// TODO: Add your control notification handler code here
	double b84,l84,h84;
	CString str;
	CString straim;
	CStdioFile file(m_inputfile,CFile::modeRead);
	CStdioFile aimfile(m_outputfile,CFile::modeCreate|CFile::modeReadWrite);
	
	while (file.ReadString(str)) 
	{
		int a;
		a=str.GetLength();
		if (a>5)
		{
			
 			b84 = atof(str.Left(str.Find(",")));
 			l84 = atof(str.Mid(str.Find(",")+1,str.Find(",",str.Find(","))));
 			h84 = atof(str.Right(9));
// 			CString cat;
// 			cat=str.FindOneOf(" ,	");
// 			b84 = atof(str.Left(str.Find(cat)));
// 			l84 = atof(str.Mid(str.Find(cat)+1,str.Find(cat,str.Find(cat))));
//             h84 = atof(str.Right(9));
			CCoordTrans MM(b84,l84,h84);
			b84=MM.jdhhd(b84);
			l84=MM.jdhhd(l84);
			MM.blhxyz(b84,l84,h84);
			MM.trans(MM.x84,MM.y84,MM.z84);
			MM.xyzblh(MM.x80,MM.y80,MM.z80);
			MM.b80=MM.hdhjd(MM.b80);
			MM.l80=MM.hdhjd(MM.l80);
			straim.Format("%0.8f,%0.8f,%0.2f",MM.b80,MM.l80,MM.h80);
			aimfile.WriteString(straim);
			aimfile.WriteString("\n");
		}
	}
	file.Close();
	aimfile.Close();
	MessageBox(" 计算结束!");

}

void CCASMCoordTransDlg::OnChangeEdit1() 
{
	// 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 CCASMCoordTransDlg::OnOutputPath() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	CFileDialog filedlg(FALSE);
	filedlg.m_ofn.lpstrTitle="Please choose result path";
	filedlg.m_ofn.lpstrFilter="Data File(*.dat)\0*.dat\0All Files(*.*)\0*.*\0\0";
	//filedlg.m_ofn.lpstrDefExt="dat";
	if (IDOK==filedlg.DoModal())
	{
		m_outputfile=filedlg.GetPathName();
	}
	UpdateData(FALSE);
}

⌨️ 快捷键说明

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