dev/cbwu #29

Merged
WuChengbo merged 2 commits from dev/cbwu into master 12 months ago

@ -160,16 +160,17 @@ STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "选择航路特征和航线号"
FONT 12, "微软雅黑", 400, 0, 0x86
BEGIN
DEFPUSHBUTTON "保存",IDOK,77,82,43,12
PUSHBUTTON "取消",IDCANCEL,23,82,43,12
LTEXT "航线编号:",IDC_STATIC,25,43,38,8
COMBOBOX IDC_COMBO_LINEID,76,41,45,63,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
DEFPUSHBUTTON "保存",IDOK,77,87,43,12
PUSHBUTTON "取消",IDCANCEL,23,87,43,12
LTEXT "航线编号:",IDC_STATIC,25,40,38,8
COMBOBOX IDC_COMBO_LINEID,76,38,45,63,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
CONTROL "返回原点",IDC_RADIO_LINE,"Button",BS_AUTORADIOBUTTON | NOT WS_VISIBLE | WS_GROUP,23,4,37,10
CONTROL "闭合航路",IDC_RADIO3,"Button",BS_AUTORADIOBUTTON | NOT WS_VISIBLE | WS_TABSTOP,62,4,37,10
LTEXT "航线高度:",IDC_STATIC,25,21,38,8
EDITTEXT IDC_EDIT_LHGT,76,19,45,12,ES_CENTER | ES_AUTOHSCROLL
LTEXT "航路特征:",IDC_STATIC,25,64,38,8
COMBOBOX IDC_COMBO_LINECE,76,62,45,63,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
LTEXT "航线高度:",IDC_STATIC,25,20,38,8
EDITTEXT IDC_EDIT_LHGT,76,18,45,12,ES_CENTER | ES_AUTOHSCROLL
LTEXT "航路特征:",IDC_STATIC,25,60,38,8
COMBOBOX IDC_COMBO_LINECE,76,58,45,63,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
CONTROL "批量航线",IDC_RADIO_MultiRoute,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,26,73,37,10
END
IDD_DIALOG_LINE_SECT DIALOGEX 0, 0, 106, 71
@ -396,6 +397,39 @@ BEGIN
COMBOBOX IDC_COMBO_DIRECTION,67,49,73,63,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
END
IDD_DLG_DESIGNSURVEYLINE DIALOGEX 0, 0, 195, 106
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "航测航线设计"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
LTEXT "航线高度(m):",IDC_STATIC,16,13,53,10
EDITTEXT IDC_EDIT_HEIGHT,69,11,73,15,ES_AUTOHSCROLL,WS_EX_RIGHT
LTEXT "航线间隔(m):",IDC_STATIC,16,32,57,10
EDITTEXT IDC_EDIT_LINEINTERVAL,69,29,73,15,ES_AUTOHSCROLL,WS_EX_RIGHT
PUSHBUTTON "导入航测区",IDC_BTN_INPUTREGION,10,55,55,18
PUSHBUTTON "绘制航测区",IDC_BTN_DRAWREGION,69,55,55,18
PUSHBUTTON "保存航测区",IDC_BTN_SAVEREGION,128,55,55,18
PUSHBUTTON "装订航线",IDC_BTN_BINDLINE,10,77,55,18
PUSHBUTTON "生成航线",IDC_BTN_CALCULATELINE,69,77,55,18
END
IDD_DLG_SETMULTIROUTE DIALOGEX 0, 0, 210, 159
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "航线批量生成设置"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "确定",IDOK,39,125,61,20
PUSHBUTTON "取消",IDCANCEL,118,125,61,20
LTEXT "航线间隔(m):",IDC_STATIC,25,41,65,14
EDITTEXT IDC_EDIT_LINEINTERVAL,112,37,77,21,ES_CENTER | ES_AUTOHSCROLL
LTEXT "偏移角度(°):",IDC_STATIC,25,14,65,14
EDITTEXT IDC_EDIT_AZIMUTH,112,10,77,21,ES_CENTER | ES_AUTOHSCROLL
LTEXT "高度间隔(m):",IDC_STATIC,25,69,65,14
EDITTEXT IDC_EDIT_HEIGHTINTERVAL,112,65,77,21,ES_CENTER | ES_AUTOHSCROLL
LTEXT "航线数量:",IDC_STATIC,26,96,65,14
EDITTEXT IDC_EDIT_LINENUMBER,112,92,77,21,ES_CENTER | ES_AUTOHSCROLL
END
/////////////////////////////////////////////////////////////////////////////
//
@ -527,6 +561,22 @@ BEGIN
TOPMARGIN, 2
BOTTOMMARGIN, 89
END
IDD_DLG_DESIGNSURVEYLINE, DIALOG
BEGIN
LEFTMARGIN, 3
RIGHTMARGIN, 191
TOPMARGIN, 3
BOTTOMMARGIN, 101
END
IDD_DLG_SETMULTIROUTE, DIALOG
BEGIN
LEFTMARGIN, 3
RIGHTMARGIN, 204
TOPMARGIN, 3
BOTTOMMARGIN, 152
END
END
#endif // APSTUDIO_INVOKED

@ -190,6 +190,7 @@
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ClCompile Include="circleguidence.cpp" />
<ClCompile Include="designsurveylinedlg.cpp" />
<ClCompile Include="DlgDemAlt.cpp" />
<ClCompile Include="DlgLightRegion.cpp" />
<ClCompile Include="DlgMarker.cpp" />
@ -209,6 +210,7 @@
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ClCompile Include="geocompute.cpp" />
<ClCompile Include="geoprojection.cpp">
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -287,6 +289,7 @@
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ClCompile Include="setmultiroutedlg.cpp" />
<ClCompile Include="SetSaveLineID.cpp">
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -378,6 +381,7 @@
<ClInclude Include="charts.h" />
<ClInclude Include="circleguidence.h" />
<ClInclude Include="CUtils.h" />
<ClInclude Include="designsurveylinedlg.h" />
<ClInclude Include="DlgDemAlt.h" />
<ClInclude Include="DlgLightRegion.h" />
<ClInclude Include="DlgMarker.h" />
@ -385,6 +389,7 @@
<ClInclude Include="extents.h" />
<ClInclude Include="field.h" />
<ClInclude Include="FlyLineDesign.h" />
<ClInclude Include="geocompute.h" />
<ClInclude Include="geoprojection.h" />
<ClInclude Include="GISDlg.h" />
<ClInclude Include="GISManager.h" />
@ -410,6 +415,7 @@
<ClInclude Include="SaveLineEditSetting.h" />
<ClInclude Include="SaveZoneDlg.h" />
<ClInclude Include="ScreenCapture.h" />
<ClInclude Include="setmultiroutedlg.h" />
<ClInclude Include="SetSaveLineID.h" />
<ClInclude Include="shape.h" />
<ClInclude Include="shapedrawingoptions.h" />

@ -186,6 +186,15 @@
<ClCompile Include="circleguidence.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="designsurveylinedlg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="geocompute.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="setmultiroutedlg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="GISControlDlg.def">
@ -436,5 +445,14 @@
<ClInclude Include="CUtils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="designsurveylinedlg.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="geocompute.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="setmultiroutedlg.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

@ -187,6 +187,11 @@ CGISDlg::CGISDlg(CWnd* pParent /*=NULL*/)
m_designLinePointNum = 0; //当前航点个数
m_CircleGuideLayer = -1; //盘旋引导图层
/*******************************测绘航线********************************/
surveyRegionLayerID = -1;
tmpSurveyRegionLayerID = -1;
tmpSurveyLineLayerID = -1;
/*******************************新增限制区********************************/
//绘制禁飞区、限飞区
std::fill(noFlyZoneLayersID, noFlyZoneLayersID + 5, -1);//禁飞区
@ -434,6 +439,12 @@ CGISDlg::~CGISDlg()
m_gisManager->DestroyObject();
m_gisManager = NULL;
}
if (designSurveyLineDlg != nullptr)
{
delete designSurveyLineDlg;
designSurveyLineDlg = nullptr;
}
}
@ -611,6 +622,10 @@ BEGIN_MESSAGE_MAP(CGISDlg, CBCGPDialog)
ON_COMMAND(IDM_BIND_ZONE,OnBindZone)
/*****************************测绘航线*******************************/
ON_MESSAGE(WM_SEND_SHOWSURVEYREGION, &CGISDlg::OnShowSurveyRegion) //显示测绘区域
ON_MESSAGE(WM_SEND_SHOWSURVEYLINE, &CGISDlg::OnShowSurveyRegion) //显示测绘航线
ON_MESSAGE(WM_CLEAR_TMPSURVEYFEATURE, &CGISDlg::OnClearTmpSurveyFeature) //显示测绘航线
END_MESSAGE_MAP()
@ -667,6 +682,10 @@ BOOL CGISDlg::OnInitDialog()
m_dlgMarker.Create(IDD_DIALOG_MARKER,this);
m_dlgMarker.MoveToGivenArea(m_gisAreaInScreen);
//创建航线航测对话框
designSurveyLineDlg = new DesignSurveyLineDlg();
designSurveyLineDlg->Create(IDD_DLG_DESIGNSURVEYLINE);
//地图显示区宽度、高度倒数
m_onePerWidth = 1.0/m_rcGISArea.Width();
m_onePerHeight = 1.0/m_rcGISArea.Height();
@ -990,6 +1009,13 @@ void CGISDlg::OnMapFullScreen()
m_bLDSetPoint = FALSE;
m_bSelectFeatureFlag = false;
/*
if (designSurveyLineDlg==nullptr)
{
designSurveyLineDlg = new DesignSurveyLineDlg();
}
designSurveyLineDlg->ShowWindow(true);*/
}
@ -1904,6 +1930,16 @@ void CGISDlg::MouseDownMap1(short Button, short Shift, long x, long y)
//TRACE(g_bSelectMarker);
// return;
}
//绘制航测区域
if (designSurveyLineDlg != nullptr && designSurveyLineDlg->bDrawRegion && (Button == 1))
{
//像素坐标转换地理坐标
m_map.PixelToProj(x,y, &dX, &dY);
surveyRegionLons.push_back(dX);
surveyRegionLats.push_back(dY);
}
if (m_bHaveShowDistanceDlg && (Button == 1))
{
@ -2695,6 +2731,28 @@ void CGISDlg::MouseDblClickMap1()
}
}
//结束绘制航测区
if (designSurveyLineDlg != nullptr && designSurveyLineDlg->bDrawRegion)
{
designSurveyLineDlg->bDrawRegion = false;
if (surveyRegionLons.size()<3) //多边形无效
{
surveyRegionLons.clear();
surveyRegionLats.clear();
return;
}
//添加原点闭合
surveyRegionLons.push_back(surveyRegionLons[0]);
surveyRegionLats.push_back(surveyRegionLats[0]);
//显示测绘区域
ShowSurveyRegion(tmpSurveyRegionLayerID,surveyRegionLons,surveyRegionLats);
m_map.Redraw();
designSurveyLineDlg->SetSurveyRegion(surveyRegionLons,surveyRegionLats);
surveyRegionLons.clear();
surveyRegionLats.clear();
}
}
void CGISDlg::MouseMoveMap1(short Button, short Shift, long x, long y)
@ -2704,6 +2762,49 @@ void CGISDlg::MouseMoveMap1(short Button, short Shift, long x, long y)
return;
}
//绘制航测区域
if (designSurveyLineDlg!= nullptr && designSurveyLineDlg->bDrawRegion)
{
double dX = 0;
double dY = 0;
m_map.PixelToProj(x,y, &dX, &dY);
if ( 1 == surveyRegionLons.size()) //绘制直线
{
if (m_tempLayerID!=-1)
{
m_map.ClearDrawing(m_tempLayerID);
m_tempLayerID = -1;
}
m_tempLayerID = m_map.NewDrawing(1);
m_map.DrawLineEx(m_tempLayerID,surveyRegionLons[0],surveyRegionLats[0],dX,dY,2,RGB(255,0,0));
m_map.Redraw();
}
if (2 <= surveyRegionLons.size()) //绘制多边形
{
/*
if ( 2 == surveyRegionLons.size())
{
//添加实时点绘制多边形
surveyRegionLons.push_back(dX);
surveyRegionLats.push_back(dY);
}*/
if (m_tempLayerID!=-1)
{
m_map.ClearDrawing(m_tempLayerID);
m_tempLayerID = -1;
}
surveyRegionLons.push_back(dX);
surveyRegionLats.push_back(dY);
ShowSurveyRegion(tmpSurveyRegionLayerID,surveyRegionLons,surveyRegionLats);
m_map.Redraw();
surveyRegionLons.pop_back();
surveyRegionLats.pop_back();
}
}
//显示经纬度坐标时(地图定位)
if (m_bHaveShowLonLatDlg && m_pLonLatDlg ->GetAutoEditStatus())
{
@ -3046,10 +3147,11 @@ void CGISDlg::MouseMoveMap1(short Button, short Shift, long x, long y)
void CGISDlg::AddTextToPointShapeLayer(long &drawLayerID, const double lon, const double lat, const CString strPtName, const CString strColor, unsigned long fontColor)
{
//判断点矢量图层是否已经存在,存在则删除
if (drawLayerID > 0)
if (drawLayerID >= 0)
{
//清除标绘的点矢量图层
ClearPointShape(drawLayerID);
drawLayerID = -1;
}
/////////////////////新建点矢量图层标绘点目标///////////////////////////////////
@ -3165,15 +3267,6 @@ void CGISDlg::DrawDistLabelEx(long drawLayerID, const double ptLon1, const doubl
}
CLabels drawLabels = m_map.GetDrawingLabels(drawLayerID);
//drawLabels.SetAvoidCollisions(false);
/*
CLabelCategory labelCategory = drawLabels.AddCategory(_T("dist"));
labelCategory.SetFontName(_T("ºÚÌå"));
labelCategory.SetFontSize(12);
labelCategory.SetOffsetX(8);
labelCategory.SetFrameVisible(true);
labelCategory.SetFrameTransparency(180);
*/
drawLabels.SetFontName(_T("黑体"));
//drawLabels.SetFontName(_T("Arial"));
@ -4975,8 +5068,36 @@ void CGISDlg::OnShowGivenLine(const CString strLineFileName)
BCGPMessageBox("航线号不正确!");
return;
}
int ch = lineDataGroup.linePts[lineDataGroup.pointNum-1].ch1;
/***************************测绘区域处理************************************/
if (ch == 0x03)
{
if (tmpSurveyRegionLayerID!=-1)
{
m_map.RemoveLayer(tmpSurveyRegionLayerID);
tmpSurveyRegionLayerID = -1;
}
vector<double> regionLons;
vector<double> regionLats;
for (int i = 0;i<lineDataGroup.pointNum;++i)
{
regionLons.push_back(lineDataGroup.linePts[i].dX);
regionLats.push_back(lineDataGroup.linePts[i].dY);
}
//添加原点
regionLons.push_back(lineDataGroup.linePts[0].dX);
regionLats.push_back(lineDataGroup.linePts[0].dY);
if (designSurveyLineDlg!=nullptr)
{
designSurveyLineDlg->SetSurveyRegion(regionLons,regionLats);
}
ShowSurveyRegion(surveyRegionLayerID,regionLons,regionLats);
return;
}
/***************************限制区处理************************************/
if (ch==0x0D) //限飞区
{
//ClearZoneLayer(restrictedZoneLayersID[lineDataGroup.lineID-1]);
@ -5463,6 +5584,28 @@ void CGISDlg::OnEnddesign() //
return ;
}
//批量航线设置
double azmuth,heightInterval,lineInterval,numLine;
bool bSaveMultiLine = false;
CString pathName;
if (g_b981AMulti && dlg.m_bCheckMultiLine)
{
SetMultiRouteDlg multiRouteDlg;
if (multiRouteDlg.DoModal() == IDOK )
{
azmuth = multiRouteDlg.azmuth;
heightInterval = multiRouteDlg.heightInterval;
lineInterval = multiRouteDlg.lineInterval;
numLine = multiRouteDlg.numLine;
bSaveMultiLine = true;
}
else
{
bSaveMultiLine = false;
}
}
//保存设置航线
CString strRouteFileDir = GetSoftwareCurrentDirectory() + _T("\\Route");
TCHAR s[10000];
@ -5479,7 +5622,7 @@ void CGISDlg::OnEnddesign() //
if (IDOK == dlgSave.DoModal())
{
strFlyLineName = dlgSave.GetPathName();
pathName = ExtractFileName(strFlyLineName);
////写出航线数据
FILE *fp = fopen(strFlyLineName, "w" );
@ -5493,25 +5636,29 @@ void CGISDlg::OnEnddesign() //
memset(&pt, 0, sizeof(PtStruct));
//原点数据写入
fprintf(fp, "%d, %d, %lf, %lf, %.2lf, %d, %02X, %02X\n", designLineID, 0, g_gcsLon, g_gcsLat, 0.0, 0, 0, 3);
fprintf(fp, "%d, %d, %.7f, %.7f, %.2f, %d, %02X, %02X\n", designLineID, 0, g_gcsLon, g_gcsLat, 0.0, 0, 0, 3);
//遍历航点集合数据
for ( int i = 0; i < m_designLinePointNum; i++ )
{
pt = m_pDesignLineStruct[i];
m_pDesignLineStruct[i].nL = designLineID;
m_pDesignLineStruct[i].nH = lineHeight;
//将除最后一个点的数据写入文件
if ( i < (m_designLinePointNum-1))
{
fprintf(fp, "%d, %d, %lf, %lf, %.2lf, %d, %02X, %02X\n", designLineID, pt.nPt, pt.dX, pt.dY, lineHeight, pt.nV, pt.ch1, 3);
fprintf(fp, "%d, %d, %.7f, %.7f, %.2f, %d, %02X, %02X\n", designLineID, pt.nPt, pt.dX, pt.dY, lineHeight, pt.nV, pt.ch1, 3);
}
else//将最后一个点的航段特征数据写入文件
{
fprintf(fp, "%d, %d, %lf, %lf, %.2lf, %d, %02X, %02X\n", designLineID, pt.nPt, pt.dX, pt.dY, lineHeight, pt.nV, designLineCE/*pt.ch1*/, lineProperty);
fprintf(fp, "%d, %d, %.7f, %.7f, %.2f, %d, %02X, %02X\n", designLineID, pt.nPt, pt.dX, pt.dY, lineHeight, pt.nV, designLineCE/*pt.ch1*/, lineProperty);
m_pDesignLineStruct[i].ch2 = designLineCE;
m_pDesignLineStruct[i].ch1 = lineProperty;
}
}
fclose( fp );
fclose( fp );
//弹出保存成功对话框
BCGPMessageBox(_T("航线文件保存成功!"));
@ -5519,6 +5666,14 @@ void CGISDlg::OnEnddesign() //
}
}
//批量航线保存
if (g_b981AMulti && bSaveMultiLine)
{
vector<vector<PtStruct>> resultLines;
GetMultiRouteLine(azmuth,lineInterval,numLine,m_pDesignLineStruct,m_designLinePointNum,resultLines);
SaveMultiRouteLine(pathName,heightInterval,resultLines);
}
memset(m_pDesignLineStruct, 0, sizeof(PtStruct)*m_lineMaxPointNum); //初始化新建一条航线
m_designLinePointNum = 0;
@ -8105,6 +8260,177 @@ void CGISDlg::OnBindZone()
}
//显示航测区域
void CGISDlg::ShowSurveyRegion(long& layerID,vector<double>& xPoints,vector<double>& yPoints)
{
if (layerID!=-1)
{
m_map.RemoveLayer(layerID);
layerID = -1;
}
mapWindow::IShapePtr shapePtr;
shapePtr.CreateInstance("MapWinGIS.Shape");
//创建面矢量shapfile
shapePtr->Create(mapWindow::SHP_POLYGON);
CreateEmptyShapfile(layerID,2,RGB(255,0,0));
int nPoints = xPoints.size();
for (long i=0; i<nPoints; i++)
{
mapWindow::IPointPtr pintPtr;
pintPtr.CreateInstance("MapWinGIS.Point");
//经度
pintPtr->x = xPoints[i];
//纬度
pintPtr->y = yPoints[i];
shapePtr->InsertPoint(pintPtr, &i);
//插入面矢量
(m_map.GetShapefile(layerID)).EditInsertShape(shapePtr, &i);
}
mapWindow::IShapeDrawingOptionsPtr pShapeDrawingOption;
pShapeDrawingOption.CreateInstance("MapWinGIS.ShapeDrawingOptions");
pShapeDrawingOption->LineColor = RGB(66,102,244);//RGB(212,212,252);
pShapeDrawingOption->FillColor = RGB(117,176,247);//RGB(0,255,255);//RGB(244,206,199);
pShapeDrawingOption->LineWidth = 2;
pShapeDrawingOption->FillTransparency = 40; //透明度
(m_map.GetShapefile(layerID)).SetDefaultDrawingOptions(pShapeDrawingOption);
}
//显示航测航线
void CGISDlg::ShowPolyline(long& layerID,vector<double>& xPoints,vector<double>& yPoints)
{
if (layerID!=-1)
{
m_map.RemoveLayer(layerID);
layerID = -1;
}
mapWindow::IShapePtr shapePtr;
shapePtr.CreateInstance("MapWinGIS.Shape");
//创建面矢量shapfile
shapePtr->Create(mapWindow::SHP_POLYLINE);
CreateEmptyShapfile(layerID,1,RGB(255,0,0));
int nPoints = xPoints.size();
for (long i=0; i<nPoints; i++)
{
mapWindow::IPointPtr pintPtr;
pintPtr.CreateInstance("MapWinGIS.Point");
//经度
pintPtr->x = xPoints[i];
//纬度
pintPtr->y = yPoints[i];
shapePtr->InsertPoint(pintPtr, &i);
//插入面矢量
(m_map.GetShapefile(layerID)).EditInsertShape(shapePtr, &i);
}
mapWindow::IShapeDrawingOptionsPtr pShapeDrawingOption;
pShapeDrawingOption.CreateInstance("MapWinGIS.ShapeDrawingOptions");
pShapeDrawingOption->LineColor = RGB(212,212,252);
pShapeDrawingOption->LineWidth = 2;
(m_map.GetShapefile(layerID)).SetDefaultDrawingOptions(pShapeDrawingOption);
}
//显示测绘区域
afx_msg LRESULT CGISDlg::OnShowSurveyRegion(WPARAM wParam, LPARAM lParam)
{
CString path = (char*)wParam;
OnShowGivenLine(path);
//ShowSurveyRegion(surveyRegionLayerID,designSurveyLineDlg->surveyRegionLons,designSurveyLineDlg->surveyRegionLats);
return 0;
}
//显示测绘区域
afx_msg LRESULT CGISDlg::OnShowSurveyLine(WPARAM wParam, LPARAM lParam)
{
CString path = (char*)wParam;
OnShowGivenLine(path);
//ShowSurveyRegion(surveyRegionLayerID,designSurveyLineDlg->surveyRegionLons,designSurveyLineDlg->surveyRegionLats);
return 0;
}
//显示测绘区域
afx_msg LRESULT CGISDlg::OnClearTmpSurveyFeature(WPARAM wParam, LPARAM lParam)
{
if (tmpSurveyRegionLayerID!=-1)
{
m_map.RemoveLayer(tmpSurveyRegionLayerID);
tmpSurveyRegionLayerID = -1;
}
m_map.Redraw();
return 0;
}
/****************************多机航线一键生成************************************/
void CGISDlg::GetMultiRouteLine(double azimuth,double lineInterval,int lineNumber,PtStruct* lineStruct,int nLinePts,vector<vector<PtStruct>>& resultLines)
{
GeoCompute geoComputer;
double tmpLon,tmpLat;
vector<PtStruct> line;
double dist = 0;
double lineAzimuth = 0;
for (int j=0;j< lineNumber;++j)
{
line.clear();
dist = lineInterval*(j+1);
tmpLon = lineStruct[0].dX;
tmpLat = lineStruct[0].dY;
lineAzimuth = azimuth;
for (int i=0;i< nLinePts;++i)
{
PtStruct line0 = lineStruct[i];
PtStruct line1 = lineStruct[i+1];
geoComputer.computeOffsetGeoPosition(tmpLon,tmpLat,lineAzimuth,dist/1000,tmpLon,tmpLat);
PtStruct pt;
pt.dX = tmpLon;
pt.dY = tmpLat;
pt.nH = lineStruct[i].nH;
pt.nL = lineStruct[i].nL;
pt.nPt = lineStruct[i].nPt;
pt.nV = lineStruct[i].nV;
pt.ch1 = lineStruct[i].ch1;
pt.ch2 = lineStruct[i].ch2;
line.push_back(pt);
//CalculateTwoPtsAzimuth(azimuth,lineStruct[i].dX,lineStruct[i].dY,lineStruct[i+1].dX,lineStruct[i+1].dY,3);
if (i+1<nLinePts)
{
CalculateTwoPtsDistanceAzimuth(dist,lineAzimuth,lineStruct[i].dX,lineStruct[i].dY,lineStruct[i+1].dX,lineStruct[i+1].dY,3);
}
//dist = geoComputer.VincentyDistance(lineStruct[i].dX,lineStruct[i].dY,lineStruct[i+1].dX,lineStruct[i+1].dY);
}
resultLines.push_back(line);
}
}
void CGISDlg::SaveMultiRouteLine(CString pathDirName,double heightInterval,const vector<vector<PtStruct>>& resultLines)
{
CString saveFileName;
for (int i=0;i<resultLines.size();++i)
{
vector<PtStruct> line = resultLines[i];
CString tmp;
tmp.Format("-%d",i+2);
saveFileName = pathDirName + tmp + ".txt";
//保存文件
FILE* fp = fopen(saveFileName,"w");
fprintf(fp,"%d, 0, %.7f, %.7f, %.2f, 0, 00, 03\n", line[0].nL, 0.0, 0.0, 0.0);
int j = 0;
for (j;j<line.size()-1;++j)
{
fprintf(fp,"%d, %d, %.7f, %.7f, %.2f, 0, 00, 03\n", line[j].nL, j+1,line[j].dX, line[j].dY,line[j].nH + heightInterval*(i+1));
}
fprintf(fp,"%d, %d, %.7f, %.7f, %.2f, 0, %02X, 01\n", line[j].nL, j+1,line[j].dX, line[j].dY,line[j].nH + heightInterval*(i+1),line[j].ch2);
fclose(fp);
}
}

@ -38,6 +38,8 @@
#include "../Include/8BMapDLL_type.h"
#include "SaveZoneDlg.h"
#include "circleguidence.h"
#include "designsurveylinedlg.h"
#include "setmultiroutedlg.h"
using namespace B8MapDLL;
#define MESSAGE_B8MAP WM_USER+750
@ -958,6 +960,26 @@ public:
//显示盘旋引导装订对话框
void OnShowCircleGuidenceDlg();
/******************************航测航线*******************************/
DesignSurveyLineDlg* designSurveyLineDlg;
//航测区域图层
long surveyRegionLayerID;
long tmpSurveyRegionLayerID;
long tmpSurveyLineLayerID;
//航测点
vector<double> surveyRegionLons;
vector<double> surveyRegionLats;
//显示航测区域
afx_msg LRESULT OnShowSurveyRegion(WPARAM wParam,LPARAM lParam);
afx_msg LRESULT OnShowSurveyLine(WPARAM wParam,LPARAM lParam);
afx_msg LRESULT OnClearTmpSurveyFeature(WPARAM wParam,LPARAM lParam);
void ShowSurveyRegion(long& layerID,vector<double>& xPoints,vector<double>& yPoints);
//显示航测航线
void ShowPolyline(long& layerID,vector<double>& xPoints,vector<double>& yPoints);
/****************************多机航线一键生成************************************/
void GetMultiRouteLine(double azimuth,double lineInterval,int lineNumber,PtStruct* lineStruct,int nLinePts,vector<vector<PtStruct>>& resultLines);
void SaveMultiRouteLine(CString pathDirName,double heightInterval,const vector<vector<PtStruct>>& resultLines);
};
//{{AFX_INSERT_LOCATION}}

@ -96,6 +96,26 @@ extern bool CreateDirectory(const CString &strDir)
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
@ -249,4 +269,5 @@ bool g_bMarkerPlot[g_iMarkerPtNum] = {false};
-------------------------------------------------------------------------------------------------------------*/
bool g_b981ADesktop = true;
bool g_b981APad = false;
bool g_b981CDesktop = false;
bool g_b981CDesktop = false;
bool g_b981AMulti = true;

@ -57,6 +57,14 @@ const UINT WM_SEND_MAPLOCATION = WM_USER+1088; //
const UINT WM_SEND_MAPCURSORMODE = WM_USER+1089; //设置Map CursorMode
const UINT WM_SEND_SHOWSURVEYLINE = WM_USER+1090; //显示测绘航线
const UINT WM_SEND_SHOWSURVEYREGION = WM_USER+1091; //显示测绘区域
const UINT WM_BIND_SURVEYLINE = WM_USER+1092; //装订测绘航线
const UINT WM_CLEAR_TMPSURVEYFEATURE = WM_USER+1093; //清除临时测绘要素
/////////////////////////////////////////////////////////消息定义////////////////////////////////////////////////////////////
@ -164,6 +172,9 @@ extern bool SearchDirectory(const CString &strDir);
// false——创建失败
extern bool CreateDirectory(const CString &strDir);
//提取没有后缀名的文件名
extern CString ExtractFileName(CString fileName);
//功能一个字节分成8位分别存储到数组中
//输入字节oneByte
//输出8位的位集合bitArray
@ -279,5 +290,6 @@ extern bool g_bMarkerPlot[g_iMarkerPtNum];
extern bool g_b981ADesktop; // 981A电脑端
extern bool g_b981APad; // 981A平板端
extern bool g_b981CDesktop; // 981C电脑端
extern bool g_b981AMulti; // 981A多机
#endif

@ -34,6 +34,8 @@ CSetSaveLineID::CSetSaveLineID(CWnd* pParent /*=NULL*/)
m_bCheck = false;
m_bClosedLine = 1;
m_bCheckMultiLine = false;
}
@ -58,6 +60,7 @@ BEGIN_MESSAGE_MAP(CSetSaveLineID, CBCGPDialog)
ON_BN_CLICKED(IDOK, CSetSaveLineID::OnBnClickedOk)
//ON_BN_CLICKED(IDC_RADIO3, &CSetSaveLineID::OnBnClickedRadio3)
// ON_EN_CHANGE(IDC_EDIT_LHGT, &CSetSaveLineID::OnEnChangeEditLhgt)
ON_BN_CLICKED(IDC_RADIO_MultiRoute, &CSetSaveLineID::OnBnClickedRadioMultiroute)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
@ -215,4 +218,20 @@ int CSetSaveLineID::GetLineID()
return _ttoi(str);
}
}
}
}
//Ñ¡ÔñÅúÁ¿º½Ïß
void CSetSaveLineID::OnBnClickedRadioMultiroute()
{
if (!m_bCheckMultiLine)
{
((CButton *)GetDlgItem(IDC_RADIO_MultiRoute))->SetCheck(true);
m_bCheckMultiLine = true;
}
else
{
((CButton *)GetDlgItem(IDC_RADIO_MultiRoute))->SetCheck(false);
m_bCheckMultiLine = false;
}
}

@ -68,6 +68,9 @@ public:
// afx_msg void OnEnChangeEditLhgt();
// 航线高度文本框
CEdit heightEdit;
afx_msg void OnBnClickedRadioMultiroute();
bool m_bCheckMultiLine;
};
//{{AFX_INSERT_LOCATION}}

@ -196,6 +196,7 @@ double mult(CPoint1 a, CPoint1 b, CPoint1 c)
return (a.GetX()-c.GetX())*(b.GetY()-c.GetY())-(b.GetX()-c.GetX())*(a.GetY()-c.GetY());
}
//判断两条直线段是否相交
bool TopologicalAnalysis::isLineIntersect(CPoint1 line1Start, CPoint1 line1End, CPoint1 line2Start, CPoint1 line2End){
double l1sx = line1Start.GetX();
double l1sy = line1Start.GetY();
@ -231,3 +232,108 @@ bool TopologicalAnalysis::isLineIntersect(CPoint1 line1Start, CPoint1 line1End,
}
return true;
}
bool TopologicalAnalysis::GetBoundingBoxVertices(const vector<double>& polygonX,const vector<double>& polygonY,vector<double>& rectangleX,vector<double>& rectangleY)
{
if (polygonX.size()<3 || polygonY.size()<3) return false;
//计算最大最小x和y
double minX = polygonX[0];
double minY = polygonY[0];
double maxX = polygonX[0];
double maxY = polygonY[0];
for (int i=0;i<polygonY.size();++i) {
if (polygonX[i] < minX) minX = polygonX[i];
if (polygonY[i] < minY) minY = polygonY[i];
if (polygonX[i] > maxX) maxX = polygonX[i];
if (polygonY[i] > maxY) maxY = polygonY[i];
}
rectangleX.push_back(minX);
rectangleX.push_back(maxX);
rectangleX.push_back(maxX);
rectangleX.push_back(minX);
rectangleY.push_back(maxY);
rectangleY.push_back(maxY);
rectangleY.push_back(minY);
rectangleY.push_back(minY);
}
//计算直线与多边形的交点
void TopologicalAnalysis::linePolygonIntersections(const Point2D& linePt1,const Point2D& linePt2,const vector<double>& polygonX,const vector<double>& polygonY, vector<Point2D>& result)
{
Line2D line1;
line1.p1 = linePt1;
line1.p2 = linePt2;
Point2D intersectionPt;
vector<Point2D> resPoints;
for (int i=0;i<polygonX.size()-1;++i)
{
Point2D pt1,pt2;
pt1.x = polygonX[i];
pt1.y = polygonY[i];
pt2.x = polygonX[i+1];
pt2.y = polygonY[i+1];
Line2D line2;
line2.p1 = pt1;
line2.p2 = pt2;
int type = isLineIntersecting(line1,line2,intersectionPt);
if (type == 1 || type == 2) //相交或重合
{
resPoints.push_back(intersectionPt);
}
}
if (resPoints.size()>0)
{
//获取最左或者最右的两个点,忽略凹多边形中间交点
double minX = resPoints[0].x;
double maxX = resPoints[0].x;
int minIndex = 0;
int maxIndex = 0;
for (int i=0;i<resPoints.size();++i) {
if (resPoints[i].x < minX) minIndex = i;
if (resPoints[i].x > maxX) maxIndex = i;
}
result.push_back(resPoints[minIndex]);
result.push_back(resPoints[maxIndex]);
}
}
// 判断两条线段是否相交
int TopologicalAnalysis::isLineIntersecting(const Line2D& l1, const Line2D& l2, Point2D& intersection) {
float numera = (l2.p2.x-l2.p1.x) * (l1.p1.y-l2.p1.y) - (l2.p2.y-l2.p1.y) * (l1.p1.x-l2.p1.x);
float numerb = (l1.p2.x-l1.p1.x) * (l1.p1.y-l2.p1.y) - (l1.p2.y-l1.p1.y) * (l1.p1.x-l2.p1.x);
float denom = (l2.p2.y-l2.p1.y) * (l1.p2.x-l1.p1.x) - (l2.p2.x-l2.p1.x) * (l1.p2.y-l1.p1.y);
if(denom == 0.0f)
{
if(numera == 0.0f && numerb == 0.0f)
{
intersection.x = l2.p2.x;
intersection.y = l2.p2.y;
return 2; //重合
}
return 3; //平行
}
float ua = numera / denom;
float ub = numerb / denom;
if(ua >= 0.0f && ua <= 1.0f && ub >= 0.0f && ub <= 1.0f)
{
intersection.x = l1.p1.x + ua*(l1.p2.x - l1.p1.x);
intersection.y = l1.p1.y + ua*(l1.p2.y - l1.p1.y);
return 1; //相交
}
return 0; //不相交
}

@ -1,8 +1,29 @@
#pragma once
#include <vector>
#include "point.h"
#include <cmath>
#include <algorithm>
#include <limits>
#include "geocompute.h"
using namespace std;
struct Point2D {
double x, y;
};
struct Line2D {
Point2D p1, p2;
};
struct Rectangle2D {
Point2D vertices[4];
double area() const {
double width = std::sqrt(std::pow(vertices[1].x - vertices[0].x, 2) + std::pow(vertices[1].y - vertices[0].y, 2));
double height = std::sqrt(std::pow(vertices[2].x - vertices[1].x, 2) + std::pow(vertices[2].y - vertices[1].y, 2));
return width * height;
}
};
class TopologicalAnalysis
{
public:
@ -29,4 +50,17 @@ public:
//计算一组CPoint1的最大X
double getMaxX(vector<CPoint1> points);
//获取多边形外包矩形
bool GetBoundingBoxVertices(const vector<double>& polygonX,const vector<double>& polygonY,vector<double>& rectangleX,vector<double>& rectangleY);
//计算直线与多边形的交点
void linePolygonIntersections(const Point2D& linePt1,const Point2D& linePt2,const vector<double>& polygonX,const std::vector<double>& polygonY,std::vector<Point2D>& result);
private:
// 判断两条线段是否相交
int isLineIntersecting(const Line2D& l1, const Line2D& l2, Point2D& intersection);
};

@ -0,0 +1,354 @@
// designsurveylinedlg.cpp : 实现文件
//
#include "stdafx.h"
#include "designsurveylinedlg.h"
#include "afxdialogex.h"
// DesignSurveyLineDlg 对话框
IMPLEMENT_DYNAMIC(DesignSurveyLineDlg, CBCGPDialog)
DesignSurveyLineDlg::DesignSurveyLineDlg(CWnd* pParent /*=NULL*/)
: CBCGPDialog(DesignSurveyLineDlg::IDD, pParent)
{
EnableVisualManagerStyle(TRUE, TRUE);
bDrawRegion = false;
}
DesignSurveyLineDlg::~DesignSurveyLineDlg()
{
}
void DesignSurveyLineDlg::DoDataExchange(CDataExchange* pDX)
{
CBCGPDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_BTN_SAVEREGION, m_btnSaveRegion);
}
BEGIN_MESSAGE_MAP(DesignSurveyLineDlg, CBCGPDialog)
ON_BN_CLICKED(IDC_BTN_INPUTREGION, &DesignSurveyLineDlg::OnBnClickedBtnInputregion)
ON_BN_CLICKED(IDC_BTN_DRAWREGION, &DesignSurveyLineDlg::OnBnClickedBtnDrawregion)
ON_BN_CLICKED(IDC_BTN_SAVEREGION, &DesignSurveyLineDlg::OnBnClickedBtnSaveregion)
ON_BN_CLICKED(IDC_BTN_BINDLINE, &DesignSurveyLineDlg::OnBnClickedBtnBindline)
ON_BN_CLICKED(IDC_BTN_CALCULATELINE, &DesignSurveyLineDlg::OnBnClickedBtnCalculateline)
ON_WM_CLOSE()
END_MESSAGE_MAP()
BOOL DesignSurveyLineDlg::OnInitDialog()
{
CBCGPDialog::OnInitDialog();
CenterWindow();
GetDlgItem( IDC_BTN_CALCULATELINE )->EnableWindow( false );
return TRUE;
}
//提取没有后缀名的文件名
CString DesignSurveyLineDlg::extractFileName(CString fileName)
{
// 查找最后一个点的位置
int dotIndex = fileName.ReverseFind(_T('.'));
// 如果找到了点,并且点不是第一个字符
if (dotIndex != -1)
{
// 提取文件名,不包括后缀
CString fileNameWithoutExtension = fileName.Left(dotIndex);
return fileNameWithoutExtension;
}
else
{
// 如果没有找到点,说明没有后缀,直接显示文件名
return fileName;
}
}
//设置航测区域
void DesignSurveyLineDlg::SetSurveyRegion(const vector<double>& lons,const vector<double>& lats)
{
for (int i=0;i<lons.size();++i)
{
surveyRegionLons.push_back(lons[i]);
surveyRegionLats.push_back(lats[i]);
}
GetDlgItem( IDC_BTN_CALCULATELINE )->EnableWindow( true );
}
//计算测绘航线
void DesignSurveyLineDlg::calculateSurveyLine(double lineInterval,vector<double>&surveyLineLons,vector<double>& surveyLineLats)
{
vector<double> recLons;
vector<double> recLats;
TopologicalAnalysis analysis;
GeoCompute geocompute;
analysis.GetBoundingBoxVertices(surveyRegionLons,surveyRegionLats,recLons,recLats);
double lon1,lat1,lon2,lat2;
//第一条切割线为航线间隔一半
geocompute.computeOffsetGeoPosition(recLons[0],recLats[0],180,lineInterval/2000,lon1,lat1);
geocompute.computeOffsetGeoPosition(recLons[1],recLats[1],180,lineInterval/2000,lon2,lat2);
Point2D pt1,pt2;
pt1.x = lon1;
pt1.y = lat1;
pt2.x = lon2;
pt2.y = lat2;
vector<Point2D> result;
analysis.linePolygonIntersections(pt1,pt2,surveyRegionLons,surveyRegionLats,result);
while(lat1>recLats[2]){
//平移切割线
geocompute.computeOffsetGeoPosition(lon1,lat1,180,lineInterval/1000,lon1,lat1);
geocompute.computeOffsetGeoPosition(lon2,lat2,180,lineInterval/1000,lon2,lat2);
pt1.x = lon1;
pt1.y = lat1;
pt2.x = lon2;
pt2.y = lat2;
//计算交点
analysis.linePolygonIntersections(pt1,pt2,surveyRegionLons,surveyRegionLats,result);
}
//串联交点
int j = 1;
for (int i=0;i<result.size();i+=2)
{
if (j == 1)
{
surveyLineLons.push_back(result[i+1].x);
surveyLineLons.push_back(result[i].x);
surveyLineLats.push_back(result[i+1].y);
surveyLineLats.push_back(result[i].y);
j = 0;
continue;
}
else if (j==0)
{
surveyLineLons.push_back(result[i].x);
surveyLineLons.push_back(result[i+1].x);
surveyLineLats.push_back(result[i].y);
surveyLineLats.push_back(result[i+1].y);
j=1;
continue;
}
}
}
//保存测绘航线
void DesignSurveyLineDlg::saveSurveyLine(const vector<double>&surveyLineLons,const vector<double>& surveyLineLats,double height)
{
//写航线
CString filename;
CString strRouteFileDir = GetSoftwareCurrentDirectory() + _T("\\Route\\") + _T("测绘航线\\");
//测绘航线文件夹不存在则创建
if (!SearchDirectory(strRouteFileDir))
{
CreateDirectory(strRouteFileDir);
}
TCHAR s[10000];
s[0]=0;
CString defaultName = g_regionFileName + "-测绘航线.route";
CFileDialog dlg(FALSE, _T(".route"), defaultName);
dlg.m_ofn.lpstrTitle=_T("保存测绘航线文件");
/*
dlg.m_ofn.lpstrFile=s;
dlg.m_ofn.nMaxFile=sizeof(s)/sizeof(TCHAR);*/
TCHAR filter[500]=_T("测绘航线文件(*.route)\0*.route\0");
dlg.m_ofn.lpstrFilter=filter;
dlg.m_ofn.Flags|=OFN_OVERWRITEPROMPT|OFN_HIDEREADONLY|OFN_CREATEPROMPT;
dlg.m_ofn.lpstrInitialDir = strRouteFileDir;
if (IDOK == dlg.DoModal())
{
filename = dlg.GetPathName();
g_linePathName = filename;
g_lineFileName = extractFileName(dlg.GetFileName());
FILE* fp = fopen(filename,"w");
int iLineNum = 5;
fprintf(fp,"%d, 0, %.7f, %.7f, %.2f, 0, 00, 03\n", iLineNum, 0.0, 0.0, 0.0);
int i = 0;
for (i;i<surveyLineLons.size()-1;++i)
{
fprintf(fp,"%d, %d, %.7f, %.7f, %.2f, 0, 00, 03\n", iLineNum,i+1, surveyLineLons[i], surveyLineLats[i], height);
}
fprintf(fp,"%d, %d, %.7f, %.7f, %.2f, 0, 02, 01\n", iLineNum,i+1, surveyLineLons[i], surveyLineLats[i], height);
fclose(fp);
}else
{
return;
}
}
//保存航测区域
bool DesignSurveyLineDlg::saveSurveyRegion(const vector<double>&surveyRegionLons,const vector<double>& surveyRegionLats)
{
//写航线
CString filename;
CString strRouteFileDir = GetSoftwareCurrentDirectory() + _T("\\Route\\") + _T("测绘航线\\");
//测绘航线文件夹不存在则创建
if (!SearchDirectory(strRouteFileDir))
{
CreateDirectory(strRouteFileDir);
}
TCHAR s[10000];
s[0]=0;
CFileDialog dlg(FALSE, _T(".txt"), _T("测绘区域1.txt"));
dlg.m_ofn.lpstrTitle=_T("保存测绘区域文件");
/*
dlg.m_ofn.lpstrFile=s;
dlg.m_ofn.nMaxFile=sizeof(s)/sizeof(TCHAR);*/
TCHAR filter[500]=_T("测绘区域文件(*.txt)\0*.txt\0");
dlg.m_ofn.lpstrFilter=filter;
dlg.m_ofn.Flags|=OFN_OVERWRITEPROMPT|OFN_HIDEREADONLY|OFN_CREATEPROMPT;
dlg.m_ofn.lpstrInitialDir = strRouteFileDir;
if (IDOK == dlg.DoModal())
{
filename = dlg.GetPathName();
g_regionPathName = filename;
g_regionFileName = extractFileName(dlg.GetFileName());
FILE* fp = fopen(filename,"w");
int iLineNum = 5;
fprintf(fp,"%d, 0, %.7f, %.7f, %.2f, 0, 00, 03\n", iLineNum, 0.0, 0.0, 0.0);
int i = 0;
for (i;i<surveyRegionLons.size()-2;++i)
{
fprintf(fp,"%d, %d, %.7f, %.7f, %.2f, 0, 00, 03\n", iLineNum,i+1, surveyRegionLons[i], surveyRegionLats[i], 0);
}
fprintf(fp,"%d, %d, %.7f, %.7f, %.2f, 0, 03, 01\n", iLineNum,i+1, surveyRegionLons[i], surveyRegionLats[i], 0);
fclose(fp);
return true;
}else
{
return false;
}
}
// DesignSurveyLineDlg 消息处理程序
//导入航测区
void DesignSurveyLineDlg::OnBnClickedBtnInputregion()
{
//写航线
CString filename;
CString strRouteFileDir = GetSoftwareCurrentDirectory() + _T("\\Route\\") + _T("测绘航线\\");
TCHAR s[10000];
s[0]=0;
CFileDialog dlg(TRUE);
dlg.m_ofn.lpstrTitle=_T("打开航测区域文件");
dlg.m_ofn.lpstrFile=s;
dlg.m_ofn.nMaxFile=sizeof(s)/sizeof(TCHAR);
TCHAR filter[500]=_T("航测区域文件(*.txt)\0*.txt\0所有文件(*.*)\0*.*\0");
dlg.m_ofn.lpstrFilter=filter;
dlg.m_ofn.Flags|=OFN_HIDEREADONLY;
dlg.m_ofn.lpstrInitialDir = strRouteFileDir;
// 显示对话框并获取用户的选择
if (dlg.DoModal() == IDOK)
{
// 获取选择的文件路径
CString filePath = dlg.GetPathName();
g_regionPathName = filePath;
g_regionFileName = extractFileName(dlg.GetFileName());
char* path = filePath.GetBuffer();
//发送消息到主程序,进行显示
if (g_mapHwnd != NULL)
{
::SendMessage(g_mapHwnd, WM_SEND_SHOWSURVEYREGION, (WPARAM)path, 0);
}
GetDlgItem( IDC_BTN_CALCULATELINE )->EnableWindow( true );
}
else
{
return;
}
}
//绘制航测区
void DesignSurveyLineDlg::OnBnClickedBtnDrawregion()
{
bDrawRegion = true;
}
//保存航测区
void DesignSurveyLineDlg::OnBnClickedBtnSaveregion()
{
m_btnSaveRegion.EnableWindow(false);
if (saveSurveyRegion(surveyRegionLons,surveyRegionLats))
{
char* path = g_regionPathName.GetBuffer();
//发送消息到主程序,进行标绘
if (g_mapHwnd != NULL)
{
::SendMessage(g_mapHwnd, WM_SEND_SHOWSURVEYREGION, (WPARAM)path, 0);
}
}
m_btnSaveRegion.EnableWindow(true);
}
//装订测绘航线
void DesignSurveyLineDlg::OnBnClickedBtnBindline()
{
// TODO: 在此添加控件通知处理程序代码
}
//生成航测航线
void DesignSurveyLineDlg::OnBnClickedBtnCalculateline()
{
if (surveyRegionLats.size()<3)
{
BCGPMessageBox("航测区域无效或缺少航测区域!");
return;
}
CString cstr;
GetDlgItemText(IDC_EDIT_HEIGHT,cstr);
double height = _ttof(cstr);
if (height<=0||height>500)
{
BCGPMessageBox("航高范围为(0,500]m!");
return;
}
GetDlgItemText(IDC_EDIT_LINEINTERVAL,cstr);
double lineInterval = _ttof(cstr);
if (lineInterval < 1 )
{
BCGPMessageBox("航线间隔必须大于1m");
return;
}
g_Height = height;
//测绘航线坐标
vector<double> surveyLineLons;
vector<double> surveyLineLats;
//计算航测航线
calculateSurveyLine(lineInterval,surveyLineLons,surveyLineLats);
//保存航测航线
saveSurveyLine(surveyLineLons,surveyLineLats,height);
//发送消息到主程序,进行标绘
if (g_mapHwnd != NULL)
{
char* path = g_linePathName.GetBuffer();
::SendMessage(g_mapHwnd, WM_SEND_SHOWSURVEYLINE, (WPARAM)path, 0);
}
}
void DesignSurveyLineDlg::OnClose()
{
CBCGPDialog::OnClose();
//发送消息到主程序,进行显示
if (g_mapHwnd != NULL)
{
::SendMessage(g_mapHwnd, WM_CLEAR_TMPSURVEYFEATURE, 0, 0);
}
}

@ -0,0 +1,58 @@
#pragma once
#include "Resource.h"
#include <vector>
#include "topologicalanalysis.h"
#include "geocompute.h"
#include "Globe.h"
#include "afxwin.h"
// DesignSurveyLineDlg 对话框
// DesignSurveyLineDlg 对话框
class DesignSurveyLineDlg : public CBCGPDialog
{
DECLARE_DYNAMIC(DesignSurveyLineDlg)
public:
DesignSurveyLineDlg(CWnd* pParent = NULL); // 标准构造函数
virtual ~DesignSurveyLineDlg();
bool bDrawRegion;
void SetSurveyRegion(const vector<double>& lons,const vector<double>& lats);
//测绘区域坐标
vector<double> surveyRegionLons;
vector<double> surveyRegionLats;
// 对话框数据
enum { IDD = IDD_DLG_DESIGNSURVEYLINE };
private:
void calculateSurveyLine(double lineInterval,vector<double>&surveyLineLons,vector<double>& surveyLineLats);//计算测绘航线
void saveSurveyLine(const vector<double>&surveyLineLons,const vector<double>& surveyLineLats,double height); //保存测绘航线
bool saveSurveyRegion(const vector<double>&surveyRegionLons,const vector<double>& surveyRegionLats); //保存航测区域
//测绘航线坐标
vector<double> surveyLineLons;
vector<double> surveyLineLats;
double g_Height;
// 测绘区域文件路径
CString g_regionPathName;
CString g_regionFileName;
CString g_linePathName;
CString g_lineFileName;
CString extractFileName(CString fileName); //提取没有后缀名的文件名
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP()
public:
virtual BOOL OnInitDialog();
afx_msg void OnBnClickedBtnInputregion();
afx_msg void OnBnClickedBtnDrawregion();
afx_msg void OnBnClickedBtnSaveregion();
afx_msg void OnBnClickedBtnBindline();
afx_msg void OnBnClickedBtnCalculateline();
afx_msg void OnClose();
CBCGPButton m_btnSaveRegion;
};

@ -0,0 +1,132 @@
#include "stdafx.h"
#include "geocompute.h"
GeoCompute::GeoCompute(void)
{
}
GeoCompute::~GeoCompute(void)
{
}
/*@brief 根据起点坐标、方位角、距离,计算另一点坐标。
* 使Vincenty's,使WGS-84
* startPoint:lat(-9090)lon(-180,180)
* bearing:
* dist:(km)
*/
void GeoCompute::computeOffsetGeoPosition(double lon1, double lat1, double bearing, double dist,double& targetLon,double& targetLat)
{
//角度转化为弧度
// qreal lon1 = (fmod(startPoint.x()+540,360)-180.0)*PI/180;
lon1 = lon1*PI/180.0;
lat1 = lat1*PI/180.0;
bearing = bearing*PI/180.0;
dist = dist*1000;
//WGS-84椭球参数
double flat = 298.257223563;
double a = 6378137.0;
double b = 6356752.314245;
//开始求解坐标
double f = 1/flat;
double sb = sin(bearing);
double cb = cos(bearing);
double tu1 = (1-f)*tan(lat1);
double cu1 = 1/sqrt((1+tu1*tu1));
double su1 = tu1*cu1;
double s2 = atan2(tu1, cb);
double sa = cu1*sb;
double csa = 1-sa*sa;
double us = csa*(a*a - b*b)/(b*b);
double A = 1+us/16384*(4096+us*(-768+us*(320-175*us)));
double B = us/1024*(256+us*(-128+us*(74-47*us)));
double s1 = dist/(b*A);
double s1p = 2*PI;
double cs1m = 0.0;
double ss1 = 0.0;
double cs1 = 0.0;
double ds1 = 0.0;
while (abs(s1-s1p) > 1e-12)
{
cs1m = cos(2*s2+s1);
ss1 = sin(s1);
cs1 = cos(s1);
ds1 = B*ss1*(cs1m+B/4*(cs1*(-1+2*cs1m*cs1m)- B/6*cs1m*(-3+4*ss1*ss1)*(-3+4*cs1m*cs1m)));
s1p = s1;
s1 = dist/(b*A)+ds1;
}
double t = su1*ss1-cu1*cs1*cb;
double lat2 = atan2(su1*cs1+cu1*ss1*cb, (1-f)*sqrt(sa*sa + t*t));
double l2 = atan2(ss1*sb, cu1*cs1-su1*ss1*cb);
double c = f/16*csa*(4+f*(4-3*csa));
double l = l2-(1-c)*f*sa* (s1+c*ss1*(cs1m+c*cs1*(-1+2*cs1m*cs1m)));
double lon2 = lon1+l;
targetLon = lon2*180/PI;
targetLat = lat2*180/PI;
}
// 使用Vincenty's公式计算地理距离
double GeoCompute::VincentyDistance(double lon1, double lat1, double lon2, double lat2) {
// 常量定义
const double a = 6378137.0; // 地球长半轴 (米)
const double f = 1 / 298.257223563; // 地球扁率
const double b = a * (1 - f); // 地球短半轴 (米)
lat1 = lat1* M_PI / 180.0;
lon1 = lon1* M_PI / 180.0;
lat2 = lat2* M_PI / 180.0;
lon2 = lon2* M_PI / 180.0;
double L = lon2 - lon1;
double U1 = atan((1 - f) * tan(lat1));
double U2 = atan((1 - f) * tan(lat2));
double sinU1 = sin(U1), cosU1 = cos(U1);
double sinU2 = sin(U2), cosU2 = cos(U2);
double lambda = L, lambdaP;
int iterLimit = 100;
double sinLambda, cosLambda;
double sinSigma, cosSigma, sigma;
double sinAlpha, cos2Alpha, cos2SigmaM;
double C;
do {
sinLambda = sin(lambda);
cosLambda = cos(lambda);
sinSigma = sqrt((cosU2 * sinLambda) * (cosU2 * sinLambda) +
(cosU1 * sinU2 - sinU1 * cosU2 * cosLambda) * (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda));
if (sinSigma == 0) return 0; // co-incident points
cosSigma = sinU1 * sinU2 + cosU1 * cosU2 * cosLambda;
sigma = atan2(sinSigma, cosSigma);
sinAlpha = cosU1 * cosU2 * sinLambda / sinSigma;
cos2Alpha = 1 - sinAlpha * sinAlpha;
cos2SigmaM = cosSigma - 2 * sinU1 * sinU2 / cos2Alpha;
if (cos2Alpha == 0) cos2SigmaM = 0; // equatorial line: cos2Alpha=0
C = f / 16 * cos2Alpha * (4 + f * (4 - 3 * cos2Alpha));
lambdaP = lambda;
lambda = L + (1 - C) * f * sinAlpha *
(sigma + C * sinSigma * (cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM)));
} while (fabs(lambda - lambdaP) > 1e-12 && --iterLimit > 0);
if (iterLimit == 0) return -1; // formula failed to converge, return -1 or an appropriate error code
double uSquared = cos2Alpha * (a * a - b * b) / (b * b);
double A = 1 + uSquared / 16384 * (4096 + uSquared * (-768 + uSquared * (320 - 175 * uSquared)));
double B = uSquared / 1024 * (256 + uSquared * (-128 + uSquared * (74 - 47 * uSquared)));
double deltaSigma = B * sinSigma *
(cos2SigmaM + B / 4 * (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM) -
B / 6 * cos2SigmaM * (-3 + 4 * sinSigma * sinSigma) * (-3 + 4 * cos2SigmaM * cos2SigmaM)));
double s = b * A * (sigma - deltaSigma);
return s;
}

@ -0,0 +1,24 @@
#pragma once
#include <vector>
#include <cmath>
using namespace std;
#define PI 3.14159265358979323846
class GeoCompute
{
public:
GeoCompute(void);
~GeoCompute(void);
/*@brief 根据起点坐标、方位角、距离,计算另一点坐标。
* 使Vincenty's,使WGS-84
* startPoint:lat(-9090)lon(-180,180)
* bearing:
* dist:(km)
*/
void computeOffsetGeoPosition(double lon1, double lat1, double bearing, double dist,double& targetLon,double& targetLat);
// 使用Vincenty's公式计算地理距离(m)
double VincentyDistance(double lon1, double lat1, double lon2, double lat2);
};

@ -42,14 +42,18 @@
#define IDC_BUTTON_ADD_TARGET2 1002
#define IDC_BUTTON_SELECT_TARGET 1002
#define IDC_BUTTON_ADDMARKER 1002
#define IDC_BTN_DRAWREGION 1002
#define IDC_ADD_FLYLINE 1003
#define IDB_BITMAP_ZOOMIN 1003
#define IDC_BTN_DELETE_POINT 1003
#define IDC_BTN_SAVEREGION 1003
#define IDC_LAYER_MANAGE 1004
#define IDB_BITMAP_ADD_FLYLINE 1004
#define IDC_BUTTON_DELETEMARKER 1004
#define IDC_BTN_BINDLINE 1004
#define IDC_REMOVE_LAYERS 1005
#define IDB_BITMAP_ADD_SHPFILE 1005
#define IDC_BTN_CALCULATELINE 1005
#define IDC_SELECT_ITEM 1006
#define IDB_BITMAP_ADD_IMGFILE 1006
#define IDC_ZOOM_IN 1007
@ -107,6 +111,8 @@
#define IDC_EDIT_GROUND_LON 1035
#define IDC_EDIT_ORG_DISTANCE 1036
#define IDC_EDIT_GROUND_LAT 1036
#define IDC_RADIO5 1036
#define IDC_RADIO_MultiRoute 1036
#define IDC_EDIT_SECT_AZ_ANGLE2 1037
#define IDC_EDIT_ORG_AZ_ANGLE 1037
#define IDC_TREE1 1037
@ -119,10 +125,13 @@
#define IDC_EDIT_POINT_ALT 1039
#define IDR_TOOLBAR1 1040
#define IDC_EDIT_POINT_LOS 1040
#define IDC_EDIT_AZIMUTH 1040
#define IDC_EDIT_BASEALT 1041
#define IDC_EDIT_HEIGHTINTERVAL 1041
#define IDR_MENU1 1042
#define IDC_EDIT_TARGET_LON 1042
#define IDC_EDIT_REGIONRADIUS 1042
#define IDC_EDIT_LINENUMBER 1042
#define IDR_MENU2 1043
#define IDC_SEL_UAV 1043
#define IDC_EDIT_TARGET_LAT 1043
@ -150,6 +159,7 @@
#define IDC_COMBO_ZONETYPE 1051
#define IDC_EDIT_RADIUS 1052
#define IDC_COMBO_DIRECTION 1053
#define IDC_EDIT_LINEINTERVAL 1054
#define IDC_EDIT_MARKER_LON 1055
#define IDR_TOOLBAR3 1056
#define IDC_EDIT_MARKER_LAT 1056
@ -230,6 +240,9 @@
#define IDB_BITMAP41 1154
#define IDD_DIALOG_ZONESETTING 1169
#define IDD_DLG_CIRCLEGUIDENCE 1170
#define IDC_BTN_INPUTREGION 1172
#define IDD_DLG_DESIGNSURVEYLINE 1172
#define IDD_DLG_SETMULTIROUTE 1173
#define IDT_GIS_CTRL_BUTTON1 1231
#define IDT_GIS_CTRL_BUTTON2 1232
#define IDT_GIS_CTRL_BUTTON3 1233
@ -410,9 +423,9 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 1172
#define _APS_NEXT_RESOURCE_VALUE 1174
#define _APS_NEXT_COMMAND_VALUE 32940
#define _APS_NEXT_CONTROL_VALUE 1054
#define _APS_NEXT_CONTROL_VALUE 1055
#define _APS_NEXT_SYMED_VALUE 1000
#endif
#endif

@ -0,0 +1,77 @@
// setmultiroutedlg.cpp : 实现文件
//
#include "stdafx.h"
#include "setmultiroutedlg.h"
#include "afxdialogex.h"
// SetMultiRouteDlg 对话框
IMPLEMENT_DYNAMIC(SetMultiRouteDlg, CBCGPDialog)
SetMultiRouteDlg::SetMultiRouteDlg(CWnd* pParent /*=NULL*/)
: CBCGPDialog(SetMultiRouteDlg::IDD, pParent)
{
EnableVisualManagerStyle(TRUE, TRUE);
}
SetMultiRouteDlg::~SetMultiRouteDlg()
{
}
void SetMultiRouteDlg::DoDataExchange(CDataExchange* pDX)
{
CBCGPDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(SetMultiRouteDlg, CBCGPDialog)
ON_BN_CLICKED(IDOK, &SetMultiRouteDlg::OnBnClickedOk)
END_MESSAGE_MAP()
BOOL SetMultiRouteDlg::OnInitDialog()
{
CBCGPDialog::OnInitDialog();
CenterWindow();
GetDlgItem( IDC_EDIT_AZIMUTH )->SetWindowTextA("0");
GetDlgItem( IDC_EDIT_LINEINTERVAL )->SetWindowTextA("30");
GetDlgItem( IDC_EDIT_HEIGHTINTERVAL )->SetWindowTextA("10");
GetDlgItem( IDC_EDIT_LINENUMBER )->SetWindowTextA("3");
return TRUE;
}
// SetMultiRouteDlg 消息处理程序
void SetMultiRouteDlg::OnBnClickedOk()
{
CString cstr;
((CEdit*)GetDlgItem(IDC_EDIT_AZIMUTH))->GetWindowTextA(cstr);
azmuth = _ttof(cstr);
if (azmuth<0 || azmuth>360)
{
BCGPMessageBox("方位角范围为[0,360]!");
}
((CEdit*)GetDlgItem(IDC_EDIT_LINEINTERVAL))->GetWindowTextA(cstr);
lineInterval = _ttof(cstr);
if (lineInterval<0 )
{
BCGPMessageBox("航线间隔必须大于0!");
}
((CEdit*)GetDlgItem(IDC_EDIT_HEIGHTINTERVAL))->GetWindowTextA(cstr);
heightInterval = _ttof(cstr);
if (heightInterval<0 || heightInterval > 100)
{
BCGPMessageBox("高度间隔为[0,100]!");
}
((CEdit*)GetDlgItem(IDC_EDIT_LINENUMBER))->GetWindowTextA(cstr);
numLine = _ttof(cstr);
if (numLine<1 || numLine > 10)
{
BCGPMessageBox("航线数为[1,10]!");
}
this->OnOK();
}

@ -0,0 +1,27 @@
#pragma once
#include "Resource.h"
// SetMultiRouteDlg 对话框
class SetMultiRouteDlg : public CBCGPDialog
{
DECLARE_DYNAMIC(SetMultiRouteDlg)
public:
SetMultiRouteDlg(CWnd* pParent = NULL); // 标准构造函数
virtual ~SetMultiRouteDlg();
// 对话框数据
enum { IDD = IDD_DLG_SETMULTIROUTE };
double azmuth;
double heightInterval;
double lineInterval;
double numLine;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
virtual BOOL OnInitDialog();
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedOk();
};
Loading…
Cancel
Save