You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
GCS-GISControlDlg-for-981A-.../ShowHZDistanceDlg.cpp

150 lines
2.8 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// ShowHZDistanceDlg.cpp : 实现文件
//
#include "stdafx.h"
#include "ShowHZDistanceDlg.h"
//#include "afxdialogex.h"
#include "Globe.h"
#include <math.h>
// CShowHZDistanceDlg 对话框
//
IMPLEMENT_DYNAMIC(CShowHZDistanceDlg, CDialog)
CShowHZDistanceDlg::CShowHZDistanceDlg(CWnd* pParent /*=NULL*/)
: CDialog(CShowHZDistanceDlg::IDD, pParent)
{
ResetCoordinateData();
}
CShowHZDistanceDlg::~CShowHZDistanceDlg()
{
}
void CShowHZDistanceDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_PT1_LAT, m_pt1Lat);
DDX_Text(pDX, IDC_PT2_LAT, m_pt2Lat);
DDX_Text(pDX, IDC_PT1_LON, m_pt1Lon);
DDX_Text(pDX, IDC_PT2_LON, m_pt2Lon);
DDX_Text(pDX, IDC_HZ_DISTANCE, m_strHZDistance);
DDX_Text(pDX, IDC_AZ_ANGLE, m_strAZAngle);
}
BEGIN_MESSAGE_MAP(CShowHZDistanceDlg, CDialog)
END_MESSAGE_MAP()
// CShowHZDistanceDlg 消息处理程序
void CShowHZDistanceDlg::OnCancel()
{
ResetCoordinateData();
// TODO: 在此添加专用代码和/或调用基类
//发送主程序,标识已经关闭
if (g_mapHwnd != NULL)
{
::PostMessage(g_mapHwnd, WM_CLOSE_DISTANCE_DIALOG, 0, 0);
}
CDialog::OnCancel();
}
//输入点的坐标
//输入经度lon(以度为单位)纬度lat(以度为单位)
void CShowHZDistanceDlg::SetPtCoordinate(const double lon, const double lat)
{
if (!m_bHaveOnePoint)
{
m_bHaveOnePoint = true;
m_pt1Lon = lon;
m_pt1Lat = lat;
m_pt2Lon = 0.0;
m_pt2Lat = 0.0;
m_strHZDistance = _T("");
m_strAZAngle = _T("");
}
else
{
m_bHaveOnePoint = false;
m_pt2Lon = lon;
m_pt2Lat = lat;
//计算两点之间的水平距离
Cal2PtsDisAZ();
}
UpdateData(FALSE);
}
//功能:计算两点之间的水平距离
void CShowHZDistanceDlg::Cal2PtsDisAZ()
{
double distance = 0;
double azValue = 0;
//计算两点之间的距离和方位角
CalculateTwoPtsDistanceAzimuth(distance, azValue, m_pt1Lon, m_pt1Lat, m_pt2Lon, m_pt2Lat, 3);
m_strHZDistance.Format("%.4fkm", distance*0.001);
m_strAZAngle.Format("%.1f", azValue);
}
//功能:初始化所有数据
void CShowHZDistanceDlg::ResetCoordinateData()
{
m_hzDistance = 0.0;
m_pt1Lat = 0.0;
m_pt2Lat = 0.0;
m_pt1Lon = 0.0;
m_pt2Lon = 0.0;
m_bHaveOnePoint = false;
m_strHZDistance = _T("");
//方位角
m_strAZAngle = _T("");
}
//功能:移动对话框到给定的显示区域
//输入显示区域rcArea
void CShowHZDistanceDlg::MoveToGivenArea(const CRect rcArea)
{
m_rcHZDistanceDlg = rcArea;
m_rcHZDistanceDlg.top += 20;
}
BOOL CShowHZDistanceDlg::OnInitDialog()
{
CDialog::OnInitDialog();
//移动到固定的显示区域
SetWindowPos( &CWnd::wndTop, m_rcHZDistanceDlg.left, m_rcHZDistanceDlg.top, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_HIDEWINDOW );
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}