|
|
#include "StdAfx.h"
|
|
|
#include "Globe.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//视图类句柄
|
|
|
HWND g_viewHwnd;
|
|
|
|
|
|
|
|
|
//红灯
|
|
|
CBitmap g_bmpRed;
|
|
|
|
|
|
//绿灯
|
|
|
CBitmap g_bmpGreen;
|
|
|
|
|
|
//黄灯
|
|
|
CBitmap g_bmpYellow;
|
|
|
|
|
|
//灰灯
|
|
|
CBitmap g_bmpGray;
|
|
|
|
|
|
//数据刷新显示的间隔
|
|
|
int g_refreshTimes;
|
|
|
|
|
|
|
|
|
//遥测数据帧主帧计数换算的时间
|
|
|
double g_mainFrameCountTime;
|
|
|
|
|
|
|
|
|
//地图显示区软件界面句柄
|
|
|
HWND g_mapHwnd;
|
|
|
|
|
|
|
|
|
//地面站位置
|
|
|
double g_gcsLon; //经度
|
|
|
double g_gcsLat; //纬度
|
|
|
double g_gcsAlt; //高度
|
|
|
|
|
|
|
|
|
//航线设计时航点模式:0为置点;1为航点编辑和删除模式
|
|
|
int g_ptModeInLineDesign;
|
|
|
|
|
|
|
|
|
//功能:获得软件的运行目录
|
|
|
CString GetSoftwareCurrentDirectory()
|
|
|
{
|
|
|
TCHAR exeFullPath[MAX_PATH];
|
|
|
GetModuleFileName(NULL, exeFullPath, MAX_PATH);
|
|
|
|
|
|
CString str;
|
|
|
str.Format(_T("%s"), exeFullPath);
|
|
|
|
|
|
int index = str.ReverseFind('\\');
|
|
|
|
|
|
str.Delete(index, str.GetLength()-index);
|
|
|
|
|
|
return str;
|
|
|
}
|
|
|
|
|
|
//功能:在文件夹中查找文件,看其是否存在
|
|
|
//输入:文件或文件夹名称strDir
|
|
|
//返回值:true——存在该文件或文件夹
|
|
|
// false——不存在该文件或文件夹
|
|
|
bool SearchDirectory(const CString &strDir)
|
|
|
{
|
|
|
CFileFind fileFind;
|
|
|
|
|
|
if (fileFind.FindFile(strDir))
|
|
|
{
|
|
|
fileFind.Close();
|
|
|
return true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
fileFind.Close();
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//功能:新建文件夹
|
|
|
//输入:文件夹名称strDir
|
|
|
//返回值:true——创建成功
|
|
|
// false——创建失败
|
|
|
extern bool CreateDirectory(const CString &strDir)
|
|
|
{
|
|
|
CString File_directory(strDir);
|
|
|
|
|
|
if (!PathIsDirectory(File_directory))//创建文件夹
|
|
|
{
|
|
|
CreateDirectory(File_directory, NULL);
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
//提取没有后缀名的文件名
|
|
|
/*
|
|
|
extern CString ExtractFileName(CString fileName)
|
|
|
{
|
|
|
// 查找最后一个点的位置
|
|
|
int dotIndex = fileName.ReverseFind(_T('.'));
|
|
|
|
|
|
// 如果找到了点,并且点不是第一个字符
|
|
|
if (dotIndex != -1)
|
|
|
{
|
|
|
// 提取文件名,不包括后缀
|
|
|
CString fileNameWithoutExtension = fileName.Left(dotIndex);
|
|
|
return fileNameWithoutExtension;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
// 如果没有找到点,说明没有后缀,直接显示文件名
|
|
|
return fileName;
|
|
|
}
|
|
|
}*/
|
|
|
|
|
|
|
|
|
//功能:一个字节分成8位,分别存储到数组中
|
|
|
//输入:字节oneByte
|
|
|
//输出:8位的位集合bitArray
|
|
|
void BYTE2BitArray(int *bitArray, const BYTE oneByte)
|
|
|
{
|
|
|
memset(bitArray,0,8);
|
|
|
|
|
|
bitArray[0] = oneByte&0X01;
|
|
|
bitArray[1] = (oneByte&0X02)>>1;
|
|
|
bitArray[2] = (oneByte&0X04)>>2;
|
|
|
bitArray[3] = (oneByte&0X08)>>3;
|
|
|
bitArray[4] = (oneByte&0X10)>>4;
|
|
|
bitArray[5] = (oneByte&0X20)>>5;
|
|
|
bitArray[6] = (oneByte&0X40)>>6;
|
|
|
bitArray[7] = (oneByte&0X80)>>7;
|
|
|
}
|
|
|
|
|
|
|
|
|
//功能:无符号2个字节的整数转换成位数组(16个数据)
|
|
|
//输入:无符号的整数usValue
|
|
|
//返回值:含16个数据的一维数组
|
|
|
void UnsignedShort2BitArray(int *pBitArray, const unsigned short usValue)
|
|
|
{
|
|
|
memset(pBitArray,0,16);
|
|
|
|
|
|
pBitArray[0] = usValue&0X01;
|
|
|
pBitArray[1] = (usValue&0X02)>>1;
|
|
|
pBitArray[2] = (usValue&0X04)>>2;
|
|
|
pBitArray[3] = (usValue&0X08)>>3;
|
|
|
pBitArray[4] = (usValue&0X10)>>4;
|
|
|
pBitArray[5] = (usValue&0X20)>>5;
|
|
|
pBitArray[6] = (usValue&0X40)>>6;
|
|
|
pBitArray[7] = (usValue&0X80)>>7;
|
|
|
|
|
|
pBitArray[8] = (usValue&0X100)>>8;
|
|
|
pBitArray[9] = (usValue&0X200)>>9;
|
|
|
pBitArray[10] = (usValue&0X400)>>10;
|
|
|
pBitArray[11] = (usValue&0X800)>>11;
|
|
|
pBitArray[12] = (usValue&0X1000)>>12;
|
|
|
pBitArray[13] = (usValue&0X2000)>>13;
|
|
|
pBitArray[14] = (usValue&0X4000)>>14;
|
|
|
pBitArray[15] = (usValue&0X8000)>>15;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//功能:GPS UTC时间转换成北京时间
|
|
|
//输入:GPS UTC时间utcTime
|
|
|
//返回值:北京时间
|
|
|
CString GPSUTCTime2BeijingTime(const double utcTime)
|
|
|
{
|
|
|
long nTimeGps = static_cast<long>(utcTime);
|
|
|
|
|
|
CString strBeijingTime = _T("");
|
|
|
strBeijingTime.Format(_T("%02d:%02d:%02d"), (nTimeGps/3600+8>=24?nTimeGps/3600+8-24:nTimeGps/3600+8), nTimeGps%3600/60, nTimeGps%3600%60);
|
|
|
|
|
|
return strBeijingTime;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获得航线文件名,输入航线号(1、2、3、4、5)
|
|
|
CString GetFlyLineName( const int lineID )
|
|
|
{
|
|
|
CString str;
|
|
|
str.Format( "%d", lineID );
|
|
|
return (GetSoftwareCurrentDirectory() + _T( "\\route" ) + str + _T( ".txt" ));
|
|
|
}
|
|
|
|
|
|
CString GetFlyLineDirName( const int lineID )
|
|
|
{
|
|
|
CString str;
|
|
|
if (lineID<=5)
|
|
|
{
|
|
|
str.Format( "航线%d", lineID );
|
|
|
}
|
|
|
else if (lineID == 11)
|
|
|
{
|
|
|
str = "应急航线";
|
|
|
}
|
|
|
else if( lineID == 12 )
|
|
|
{
|
|
|
str = "电子围栏";
|
|
|
}
|
|
|
else if (lineID == 14)
|
|
|
{
|
|
|
str = "回收航线";
|
|
|
}
|
|
|
|
|
|
return (GetSoftwareCurrentDirectory() + _T( "\\Route\\" ) + str );
|
|
|
}
|
|
|
|
|
|
//获取文件路径字符串
|
|
|
CString ExtractDirPath(CString strFullPath)
|
|
|
{
|
|
|
int n=strFullPath.ReverseFind('\\')+1;
|
|
|
return strFullPath.Left(n);
|
|
|
}
|
|
|
//获取文件名字字符串
|
|
|
CString ExtractFileName(CString strFullPath,bool bIncludeType)
|
|
|
{
|
|
|
CString strFile;
|
|
|
int n=strFullPath.GetLength()-strFullPath.ReverseFind('\\')-1;
|
|
|
strFile=strFullPath.Right(n);
|
|
|
if (bIncludeType==false) //去除文件名后缀
|
|
|
{
|
|
|
n = strFile.ReverseFind('.');
|
|
|
return strFile.Left(n);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return strFile;
|
|
|
}
|
|
|
}
|
|
|
//获取文件类型
|
|
|
CString ExtractFileType(CString strFullPath)
|
|
|
{
|
|
|
int n=strFullPath.GetLength()-strFullPath.ReverseFind('.')-1;
|
|
|
return strFullPath.Right(n);
|
|
|
}
|
|
|
|
|
|
//可视域分析相关变量
|
|
|
/************************************************************************/
|
|
|
|
|
|
structPoint g_structPointVisible[360];
|
|
|
structPoint g_structPointNotVisible[722];
|
|
|
|
|
|
structPoint g_structPointVisiReal[180];
|
|
|
structPoint g_structPointNotVisiReal[180];
|
|
|
|
|
|
structPoint g_structPointCrashReal[360];
|
|
|
|
|
|
long m_longGroundID = 0; //地面站标绘图层
|
|
|
|
|
|
long m_visbleCircleLayerID = -1; //可视区域图层
|
|
|
long m_notVisibleCircleLayerID = -1; //不可视区域图层
|
|
|
|
|
|
long m_visiRealCircleLayerID = -1; //实时可视区域图层
|
|
|
long m_notVisiRealCircleLayerID = -1; //实时不可视区域图层
|
|
|
long m_RealCircleLayerID = -1; //实时圆图层
|
|
|
|
|
|
long m_longContourLineID[20] = {-1}; //通视等高线图层 每500米一条 500 1000 1500 2000 2500 .... 10000
|
|
|
long m_longContourTextID[20] = {0}; //通视等高线标签图层
|
|
|
|
|
|
bool g_bSelectDropPoint = false; //可视域分析对话框是否在选点
|
|
|
long m_longSelectLineID = -1; //地面站与目标点连线图层
|
|
|
long m_longLabelPlotID = 0; //地面站与目标点连线标注图层
|
|
|
|
|
|
long m_longLinePointID = 0; //航线上的点标绘图层
|
|
|
|
|
|
long m_crashAreaLayerID = -1; //实时碰撞检测区域图层
|
|
|
|
|
|
long m_fightRegionLayerID = -1; //作用范围图层
|
|
|
|
|
|
long m_DemRegionLayerID[500] = {-1}; //高程数据图层
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
|
|
//多点高程分析相关变量
|
|
|
/************************************************************************/
|
|
|
bool g_bDemAnalysising = false; //是否在高程分析中
|
|
|
|
|
|
int g_iDemPointNum = 0; //参与高程分析的点数
|
|
|
|
|
|
//限制参与高程分析的点数
|
|
|
double g_dDemPtLon[g_iDemAltPtNum];
|
|
|
double g_dDemPtLat[g_iDemAltPtNum];
|
|
|
|
|
|
//两点所连线段图层
|
|
|
long g_lDemAltLayerID[g_iDemAltPtNum];
|
|
|
|
|
|
//两点所连线段标注距离方位图层
|
|
|
long g_lDemAltDisLayerID[g_iDemAltPtNum];
|
|
|
|
|
|
//点序号的标注图层
|
|
|
long g_lDemPtNumLayerID[g_iDemAltPtNum];
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
|
|
/*-------------------------------------------------------------------------------------------------------------
|
|
|
说明:标记点相关变量
|
|
|
-------------------------------------------------------------------------------------------------------------*/
|
|
|
//是否在移动鼠标选择标记点
|
|
|
bool g_bSelectMarker = false;
|
|
|
|
|
|
//标记点图层
|
|
|
long g_lMarkerLayerID[g_iMarkerPtNum];
|
|
|
|
|
|
//已经标记的点数
|
|
|
int g_iHaveMarkedPts = 0;
|
|
|
|
|
|
CString g_iMarkerName[g_iMarkerPtNum];
|
|
|
double g_iMarkerLon[g_iMarkerPtNum];
|
|
|
double g_iMarkerLat[g_iMarkerPtNum];
|
|
|
bool g_bMarkerPlot[g_iMarkerPtNum] = {false};
|
|
|
|
|
|
/*-------------------------------------------------------------------------------------------------------------
|
|
|
说明:不同飞机型号变量,用于控制是否启用个性功能
|
|
|
-------------------------------------------------------------------------------------------------------------*/
|
|
|
bool g_b981ADesktop = true;
|
|
|
bool g_b981APad = false;
|
|
|
bool g_b981CDesktop = false;
|
|
|
bool g_b981AMulti = false;
|
|
|
|
|
|
//地图模块版本号 [主版本.次版本.修订版本,日期,特性]
|
|
|
CString mapVersion[3] = { "1.0.0","20240920", "单机版在线地图"}; |