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(); +};