From 33052d8140f1c89c64e4a8f83aac7c7a0e0ab5cc Mon Sep 17 00:00:00 2001 From: cbwu <504-wuchengbo@htsdfp.com> Date: Sat, 15 Jun 2024 09:19:58 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E8=88=AA?= =?UTF-8?q?=E6=B5=8B=E8=88=AA=E7=BA=BF=EF=BC=8C=E5=BE=85=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GISControlDlg.rc | 24 +++ GISControlDlg.vcxproj | 4 + GISControlDlg.vcxproj.filters | 12 ++ GISDlg.cpp | 241 ++++++++++++++++++++++- GISDlg.h | 18 ++ Globe.h | 8 + TopologicalAnalysis.cpp | 105 ++++++++++ TopologicalAnalysis.h | 33 ++++ designsurveylinedlg.cpp | 354 ++++++++++++++++++++++++++++++++++ designsurveylinedlg.h | 58 ++++++ geocompute.cpp | 12 ++ geocompute.h | 74 +++++++ resource.h | 12 +- 13 files changed, 951 insertions(+), 4 deletions(-) create mode 100644 designsurveylinedlg.cpp create mode 100644 designsurveylinedlg.h create mode 100644 geocompute.cpp create mode 100644 geocompute.h diff --git a/GISControlDlg.rc b/GISControlDlg.rc index b7dd7e1..ff9385f 100644 --- a/GISControlDlg.rc +++ b/GISControlDlg.rc @@ -396,6 +396,22 @@ 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 + ///////////////////////////////////////////////////////////////////////////// // @@ -527,6 +543,14 @@ BEGIN TOPMARGIN, 2 BOTTOMMARGIN, 89 END + + IDD_DLG_DESIGNSURVEYLINE, DIALOG + BEGIN + LEFTMARGIN, 3 + RIGHTMARGIN, 191 + TOPMARGIN, 3 + BOTTOMMARGIN, 101 + END END #endif // APSTUDIO_INVOKED diff --git a/GISControlDlg.vcxproj b/GISControlDlg.vcxproj index ea0b5c2..4274d80 100644 --- a/GISControlDlg.vcxproj +++ b/GISControlDlg.vcxproj @@ -190,6 +190,7 @@ %(PreprocessorDefinitions) + @@ -209,6 +210,7 @@ %(PreprocessorDefinitions) %(PreprocessorDefinitions) + %(PreprocessorDefinitions) %(PreprocessorDefinitions) @@ -378,6 +380,7 @@ + @@ -385,6 +388,7 @@ + diff --git a/GISControlDlg.vcxproj.filters b/GISControlDlg.vcxproj.filters index 2149382..2e5444f 100644 --- a/GISControlDlg.vcxproj.filters +++ b/GISControlDlg.vcxproj.filters @@ -186,6 +186,12 @@ Source Files + + Source Files + + + Source Files + @@ -436,5 +442,11 @@ Header Files + + Header Files + + + Header Files + \ No newline at end of file diff --git a/GISDlg.cpp b/GISDlg.cpp index 1af8e90..80b836c 100644 --- a/GISDlg.cpp +++ b/GISDlg.cpp @@ -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; } /////////////////////新建点矢量图层标绘点目标/////////////////////////////////// @@ -4975,8 +5077,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 regionLons; + vector regionLats; + for (int i = 0;iSetSurveyRegion(regionLons,regionLats); + } + ShowSurveyRegion(surveyRegionLayerID,regionLons,regionLats); + return; + } + + /***************************限制区处理************************************/ if (ch==0x0D) //限飞区 { //ClearZoneLayer(restrictedZoneLayersID[lineDataGroup.lineID-1]); @@ -8105,6 +8235,113 @@ void CGISDlg::OnBindZone() } +//显示航测区域 +void CGISDlg::ShowSurveyRegion(long& layerID,vector& xPoints,vector& 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; ix = 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& xPoints,vector& 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; ix = 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; +} + + diff --git a/GISDlg.h b/GISDlg.h index 6287eae..77b4a51 100644 --- a/GISDlg.h +++ b/GISDlg.h @@ -38,6 +38,7 @@ #include "../Include/8BMapDLL_type.h" #include "SaveZoneDlg.h" #include "circleguidence.h" +#include "designsurveylinedlg.h" using namespace B8MapDLL; #define MESSAGE_B8MAP WM_USER+750 @@ -958,6 +959,23 @@ public: //显示盘旋引导装订对话框 void OnShowCircleGuidenceDlg(); + /******************************航测航线*******************************/ + DesignSurveyLineDlg* designSurveyLineDlg; + //航测区域图层 + long surveyRegionLayerID; + long tmpSurveyRegionLayerID; + long tmpSurveyLineLayerID; + //航测点 + vector surveyRegionLons; + vector 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& xPoints,vector& yPoints); + //显示航测航线 + void ShowPolyline(long& layerID,vector& xPoints,vector& yPoints); + }; //{{AFX_INSERT_LOCATION}} diff --git a/Globe.h b/Globe.h index cc2e9de..e4fbdc7 100644 --- a/Globe.h +++ b/Globe.h @@ -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; //清除临时测绘要素 + /////////////////////////////////////////////////////////消息定义//////////////////////////////////////////////////////////// diff --git a/TopologicalAnalysis.cpp b/TopologicalAnalysis.cpp index d42d155..59da569 100644 --- a/TopologicalAnalysis.cpp +++ b/TopologicalAnalysis.cpp @@ -231,3 +231,108 @@ bool TopologicalAnalysis::isLineIntersect(CPoint1 line1Start, CPoint1 line1End, } return true; } + + +bool TopologicalAnalysis::GetBoundingBoxVertices(const vector& polygonX,const vector& polygonY,vector& rectangleX,vector& 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 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& polygonX,const vector& polygonY, vector& result) +{ + Line2D line1; + line1.p1 = linePt1; + line1.p2 = linePt2; + Point2D intersectionPt; + vector resPoints; + for (int i=0;i0) + { + //获取最左或者最右的两个点,忽略凹多边形中间交点 + double minX = resPoints[0].x; + double maxX = resPoints[0].x; + int minIndex = 0; + int maxIndex = 0; + + for (int i=0;i 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; //不相交 +} diff --git a/TopologicalAnalysis.h b/TopologicalAnalysis.h index 79acd10..1f06709 100644 --- a/TopologicalAnalysis.h +++ b/TopologicalAnalysis.h @@ -1,8 +1,29 @@ #pragma once #include #include "point.h" +#include +#include +#include +#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,16 @@ public: //计算一组CPoint1的最大X double getMaxX(vector points); + + //获取多边形外包矩形 + bool GetBoundingBoxVertices(const vector& polygonX,const vector& polygonY,vector& rectangleX,vector& rectangleY); + + //计算直线与多边形的交点 + void linePolygonIntersections(const Point2D& linePt1,const Point2D& linePt2,const vector& polygonX,const std::vector& polygonY,std::vector& result); + +private: + // 判断两条线段是否相交 + int isLineIntersecting(const Line2D& l1, const Line2D& l2, Point2D& intersection); }; + + diff --git a/designsurveylinedlg.cpp b/designsurveylinedlg.cpp new file mode 100644 index 0000000..ca1df9f --- /dev/null +++ b/designsurveylinedlg.cpp @@ -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& lons,const vector& lats) +{ + for (int i=0;iEnableWindow( true ); +} + +//计算测绘航线 +void DesignSurveyLineDlg::calculateSurveyLine(double lineInterval,vector&surveyLineLons,vector& surveyLineLats) +{ + vector recLons; + vector 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 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&surveyLineLons,const vector& 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&surveyRegionLons,const vector& 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;iEnableWindow( 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 surveyLineLons; + vector 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); + } +} diff --git a/designsurveylinedlg.h b/designsurveylinedlg.h new file mode 100644 index 0000000..d3828b3 --- /dev/null +++ b/designsurveylinedlg.h @@ -0,0 +1,58 @@ +#pragma once +#include "Resource.h" +#include +#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& lons,const vector& lats); + //测绘区域坐标 + vector surveyRegionLons; + vector surveyRegionLats; + + // 对话框数据 + enum { IDD = IDD_DLG_DESIGNSURVEYLINE }; + +private: + void calculateSurveyLine(double lineInterval,vector&surveyLineLons,vector& surveyLineLats);//计算测绘航线 + void saveSurveyLine(const vector&surveyLineLons,const vector& surveyLineLats,double height); //保存测绘航线 + bool saveSurveyRegion(const vector&surveyRegionLons,const vector& surveyRegionLats); //保存航测区域 + //测绘航线坐标 + vector surveyLineLons; + vector 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; +}; diff --git a/geocompute.cpp b/geocompute.cpp new file mode 100644 index 0000000..ee54370 --- /dev/null +++ b/geocompute.cpp @@ -0,0 +1,12 @@ +#include "stdafx.h" +#include "geocompute.h" + + +GeoCompute::GeoCompute(void) +{ +} + + +GeoCompute::~GeoCompute(void) +{ +} diff --git a/geocompute.h b/geocompute.h new file mode 100644 index 0000000..758f9f0 --- /dev/null +++ b/geocompute.h @@ -0,0 +1,74 @@ +#pragma once +#include +#include +using namespace std; +#define PI 3.14159265358979323846 +class GeoCompute +{ +public: + GeoCompute(void); + ~GeoCompute(void); + + /*@brief 根据起点坐标、方位角、距离,计算另一点坐标。 + * 使用Vincenty's公式求解,使用WGS-84椭球 + * startPoint:起始点地理坐标点(lat(-90到90),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; + } +}; + diff --git a/resource.h b/resource.h index deee5a5..aa693df 100644 --- a/resource.h +++ b/resource.h @@ -42,16 +42,21 @@ #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_BTN_SAVELINE2 1006 #define IDC_ZOOM_IN 1007 #define IDB_BITMAP_RULER 1007 #define IDC_EDIT_LAT 1007 @@ -150,6 +155,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 +236,8 @@ #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 IDT_GIS_CTRL_BUTTON1 1231 #define IDT_GIS_CTRL_BUTTON2 1232 #define IDT_GIS_CTRL_BUTTON3 1233 @@ -410,9 +418,9 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 1172 +#define _APS_NEXT_RESOURCE_VALUE 1173 #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 From 3756297e0bbf00624f8719905f626306a599c3bf Mon Sep 17 00:00:00 2001 From: cbwu <504-wuchengbo@htsdfp.com> Date: Mon, 17 Jun 2024 16:17:21 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=A4=9A?= =?UTF-8?q?=E6=9C=BA=E8=88=AA=E7=BA=BF=E4=B8=80=E9=94=AE=E7=94=9F=E6=88=90?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GISControlDlg.rc | 42 +++++++++--- GISControlDlg.vcxproj | 2 + GISControlDlg.vcxproj.filters | 6 ++ GISDlg.cpp | 117 +++++++++++++++++++++++++++++---- GISDlg.h | 4 ++ Globe.cpp | 23 ++++++- Globe.h | 4 ++ SetSaveLineID.cpp | 21 +++++- SetSaveLineID.h | 3 + TopologicalAnalysis.cpp | 1 + TopologicalAnalysis.h | 3 +- geocompute.cpp | 120 ++++++++++++++++++++++++++++++++++ geocompute.h | 60 ++--------------- resource.h | 9 ++- setmultiroutedlg.cpp | 77 ++++++++++++++++++++++ setmultiroutedlg.h | 27 ++++++++ 16 files changed, 437 insertions(+), 82 deletions(-) create mode 100644 setmultiroutedlg.cpp create mode 100644 setmultiroutedlg.h diff --git a/GISControlDlg.rc b/GISControlDlg.rc index ff9385f..08e4c55 100644 --- a/GISControlDlg.rc +++ b/GISControlDlg.rc @@ -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 @@ -412,6 +413,23 @@ BEGIN 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 + ///////////////////////////////////////////////////////////////////////////// // @@ -551,6 +569,14 @@ BEGIN TOPMARGIN, 3 BOTTOMMARGIN, 101 END + + IDD_DLG_SETMULTIROUTE, DIALOG + BEGIN + LEFTMARGIN, 3 + RIGHTMARGIN, 204 + TOPMARGIN, 3 + BOTTOMMARGIN, 152 + END END #endif // APSTUDIO_INVOKED diff --git a/GISControlDlg.vcxproj b/GISControlDlg.vcxproj index 4274d80..1c2f784 100644 --- a/GISControlDlg.vcxproj +++ b/GISControlDlg.vcxproj @@ -289,6 +289,7 @@ %(PreprocessorDefinitions) %(PreprocessorDefinitions) + %(PreprocessorDefinitions) %(PreprocessorDefinitions) @@ -414,6 +415,7 @@ + diff --git a/GISControlDlg.vcxproj.filters b/GISControlDlg.vcxproj.filters index 2e5444f..c5b6806 100644 --- a/GISControlDlg.vcxproj.filters +++ b/GISControlDlg.vcxproj.filters @@ -192,6 +192,9 @@ Source Files + + Source Files + @@ -448,5 +451,8 @@ Header Files + + Header Files + \ No newline at end of file diff --git a/GISDlg.cpp b/GISDlg.cpp index 80b836c..9deb4e9 100644 --- a/GISDlg.cpp +++ b/GISDlg.cpp @@ -3267,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")); @@ -5593,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]; @@ -5609,7 +5622,7 @@ void CGISDlg::OnEnddesign() // if (IDOK == dlgSave.DoModal()) { strFlyLineName = dlgSave.GetPathName(); - + pathName = ExtractFileName(strFlyLineName); ////写出航线数据 FILE *fp = fopen(strFlyLineName, "w" ); @@ -5623,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("航线文件保存成功!")); @@ -5649,6 +5666,14 @@ void CGISDlg::OnEnddesign() // } } + //批量航线保存 + if (g_b981AMulti && bSaveMultiLine) + { + vector> 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; @@ -8341,6 +8366,70 @@ afx_msg LRESULT CGISDlg::OnClearTmpSurveyFeature(WPARAM wParam, LPARAM lParam) return 0; } +/****************************多机航线一键生成************************************/ +void CGISDlg::GetMultiRouteLine(double azimuth,double lineInterval,int lineNumber,PtStruct* lineStruct,int nLinePts,vector>& resultLines) +{ + GeoCompute geoComputer; + double tmpLon,tmpLat; + vector 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>& resultLines) +{ + CString saveFileName; + for (int i=0;i 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& xPoints,vector& yPoints); + /****************************多机航线一键生成************************************/ + void GetMultiRouteLine(double azimuth,double lineInterval,int lineNumber,PtStruct* lineStruct,int nLinePts,vector>& resultLines); + void SaveMultiRouteLine(CString pathDirName,double heightInterval,const vector>& resultLines); }; //{{AFX_INSERT_LOCATION}} diff --git a/Globe.cpp b/Globe.cpp index d8e28f1..ced09da 100644 --- a/Globe.cpp +++ b/Globe.cpp @@ -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; \ No newline at end of file +bool g_b981CDesktop = false; +bool g_b981AMulti = true; \ No newline at end of file diff --git a/Globe.h b/Globe.h index e4fbdc7..1e91c1e 100644 --- a/Globe.h +++ b/Globe.h @@ -172,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 @@ -287,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 \ No newline at end of file diff --git a/SetSaveLineID.cpp b/SetSaveLineID.cpp index cf9c5b6..d7d30b2 100644 --- a/SetSaveLineID.cpp +++ b/SetSaveLineID.cpp @@ -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); } } -} \ No newline at end of file +} + + +//选择批量航线 +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; + } +} diff --git a/SetSaveLineID.h b/SetSaveLineID.h index b57e949..1b4f428 100644 --- a/SetSaveLineID.h +++ b/SetSaveLineID.h @@ -68,6 +68,9 @@ public: // afx_msg void OnEnChangeEditLhgt(); // 航线高度文本框 CEdit heightEdit; + afx_msg void OnBnClickedRadioMultiroute(); + + bool m_bCheckMultiLine; }; //{{AFX_INSERT_LOCATION}} diff --git a/TopologicalAnalysis.cpp b/TopologicalAnalysis.cpp index 59da569..12d3c35 100644 --- a/TopologicalAnalysis.cpp +++ b/TopologicalAnalysis.cpp @@ -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(); diff --git a/TopologicalAnalysis.h b/TopologicalAnalysis.h index 1f06709..235b06d 100644 --- a/TopologicalAnalysis.h +++ b/TopologicalAnalysis.h @@ -57,8 +57,9 @@ public: //计算直线与多边形的交点 void linePolygonIntersections(const Point2D& linePt1,const Point2D& linePt2,const vector& polygonX,const std::vector& polygonY,std::vector& result); + private: - // 判断两条线段是否相交 + // 判断两条线段是否相交 int isLineIntersecting(const Line2D& l1, const Line2D& l2, Point2D& intersection); }; diff --git a/geocompute.cpp b/geocompute.cpp index ee54370..9a6e83b 100644 --- a/geocompute.cpp +++ b/geocompute.cpp @@ -10,3 +10,123 @@ GeoCompute::GeoCompute(void) GeoCompute::~GeoCompute(void) { } + +/*@brief 根据起点坐标、方位角、距离,计算另一点坐标。 +* 使用Vincenty's公式求解,使用WGS-84椭球 +* startPoint:起始点地理坐标点(lat(-90到90),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; +} diff --git a/geocompute.h b/geocompute.h index 758f9f0..768cecb 100644 --- a/geocompute.h +++ b/geocompute.h @@ -15,60 +15,10 @@ public: * 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; - } + 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); }; diff --git a/resource.h b/resource.h index aa693df..1be4695 100644 --- a/resource.h +++ b/resource.h @@ -56,7 +56,6 @@ #define IDC_BTN_CALCULATELINE 1005 #define IDC_SELECT_ITEM 1006 #define IDB_BITMAP_ADD_IMGFILE 1006 -#define IDC_BTN_SAVELINE2 1006 #define IDC_ZOOM_IN 1007 #define IDB_BITMAP_RULER 1007 #define IDC_EDIT_LAT 1007 @@ -112,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 @@ -124,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 @@ -238,6 +242,7 @@ #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 @@ -418,7 +423,7 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 1173 +#define _APS_NEXT_RESOURCE_VALUE 1174 #define _APS_NEXT_COMMAND_VALUE 32940 #define _APS_NEXT_CONTROL_VALUE 1055 #define _APS_NEXT_SYMED_VALUE 1000 diff --git a/setmultiroutedlg.cpp b/setmultiroutedlg.cpp new file mode 100644 index 0000000..7400f58 --- /dev/null +++ b/setmultiroutedlg.cpp @@ -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(); +} diff --git a/setmultiroutedlg.h b/setmultiroutedlg.h new file mode 100644 index 0000000..eef9e4b --- /dev/null +++ b/setmultiroutedlg.h @@ -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(); +};