|
|
|
@ -48,8 +48,8 @@ BOOL DesignSurveyLineDlg::OnInitDialog()
|
|
|
|
|
GetDlgItem( IDC_BTN_CALCULATELINE )->EnableWindow( false );
|
|
|
|
|
GetDlgItem( IDC_BTN_CALCULATETIME )->EnableWindow( false );
|
|
|
|
|
SetDlgItemText(IDC_EDIT_FLYSPEED,"10");
|
|
|
|
|
SetDlgItemText(IDC_EDIT_EXTERNALLENGTH,"0");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -76,6 +76,8 @@ CString DesignSurveyLineDlg::extractFileName(CString fileName)
|
|
|
|
|
//设置航测区域
|
|
|
|
|
void DesignSurveyLineDlg::SetSurveyRegion(const vector<double>& lons,const vector<double>& lats)
|
|
|
|
|
{
|
|
|
|
|
surveyRegionLons.clear();
|
|
|
|
|
surveyRegionLats.clear();
|
|
|
|
|
for (int i=0;i<lons.size();++i)
|
|
|
|
|
{
|
|
|
|
|
surveyRegionLons.push_back(lons[i]);
|
|
|
|
@ -85,39 +87,108 @@ void DesignSurveyLineDlg::SetSurveyRegion(const vector<double>& lons,const vecto
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//计算测绘航线
|
|
|
|
|
void DesignSurveyLineDlg::calculateSurveyLine(double lineInterval,vector<double>&surveyLineLons,vector<double>& surveyLineLats)
|
|
|
|
|
void DesignSurveyLineDlg::calculateSurveyLine(double lineInterval,vector<double>&surveyLineLons,vector<double>& surveyLineLats,double outLength)
|
|
|
|
|
{
|
|
|
|
|
vector<double> recLons;
|
|
|
|
|
vector<double> recLats;
|
|
|
|
|
TopologicalAnalysis analysis;
|
|
|
|
|
GeoCompute geocompute;
|
|
|
|
|
analysis.GetBoundingBoxVertices(surveyRegionLons,surveyRegionLats,recLons,recLats);
|
|
|
|
|
//计算外包矩形
|
|
|
|
|
//analysis.GetBoundingBoxVertices(surveyRegionLons,surveyRegionLats,recLons,recLats);
|
|
|
|
|
|
|
|
|
|
int startPt1 = analysis.getLineWithPolygonMinWidth(surveyRegionLons,surveyRegionLats);
|
|
|
|
|
recLons.push_back(surveyRegionLons[startPt1]);
|
|
|
|
|
recLons.push_back(surveyRegionLons[startPt1+1]);
|
|
|
|
|
recLats.push_back(surveyRegionLats[startPt1]);
|
|
|
|
|
recLats.push_back(surveyRegionLats[startPt1+1]);
|
|
|
|
|
double flyAngle;//飞行航向
|
|
|
|
|
CalculateTwoPtsAzimuth(flyAngle,surveyRegionLons[startPt1],surveyRegionLats[startPt1],surveyRegionLons[startPt1+1],surveyRegionLats[startPt1+1],3);
|
|
|
|
|
//计算偏移航向
|
|
|
|
|
Line2D line;
|
|
|
|
|
line.p1.x = surveyRegionLons[startPt1];
|
|
|
|
|
line.p1.y = surveyRegionLats[startPt1];
|
|
|
|
|
line.p2.x = surveyRegionLons[startPt1 + 1];
|
|
|
|
|
line.p2.y = surveyRegionLats[startPt1 + 1];
|
|
|
|
|
Point2D p; //直线的下一个顶点
|
|
|
|
|
if (startPt1+1 == (surveyRegionLons.size()-1)) //直线为多边形最后一条边
|
|
|
|
|
{
|
|
|
|
|
p.x = surveyRegionLons[1];
|
|
|
|
|
p.y = surveyRegionLats[1];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
p.x = surveyRegionLons[startPt1 + 2];
|
|
|
|
|
p.y = surveyRegionLats[startPt1 + 2];
|
|
|
|
|
}
|
|
|
|
|
int ptPos = analysis.pointPosition(p,line);
|
|
|
|
|
if (ptPos == 1) //左侧
|
|
|
|
|
{
|
|
|
|
|
int i = (flyAngle + 270)/360;
|
|
|
|
|
flyAngle = (flyAngle + 270) - 360*i;
|
|
|
|
|
}
|
|
|
|
|
else if(ptPos == -1) //右侧
|
|
|
|
|
{
|
|
|
|
|
int i = (flyAngle + 90)/360;
|
|
|
|
|
flyAngle = (flyAngle + 90) - 360*i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
geocompute.computeOffsetGeoPosition(recLons[0],recLats[0],flyAngle,lineInterval/2000,lon1,lat1);
|
|
|
|
|
geocompute.computeOffsetGeoPosition(recLons[1],recLats[1],flyAngle,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);
|
|
|
|
|
//交点个数
|
|
|
|
|
int nCrossPt = analysis.linePolygonIntersections(pt1,pt2,surveyRegionLons,surveyRegionLats,result);
|
|
|
|
|
|
|
|
|
|
while(lat1>recLats[2]){
|
|
|
|
|
while(nCrossPt>1){
|
|
|
|
|
//平移切割线
|
|
|
|
|
geocompute.computeOffsetGeoPosition(lon1,lat1,180,lineInterval/1000,lon1,lat1);
|
|
|
|
|
geocompute.computeOffsetGeoPosition(lon2,lat2,180,lineInterval/1000,lon2,lat2);
|
|
|
|
|
geocompute.computeOffsetGeoPosition(lon1,lat1,flyAngle,lineInterval/1000,lon1,lat1);
|
|
|
|
|
geocompute.computeOffsetGeoPosition(lon2,lat2,flyAngle,lineInterval/1000,lon2,lat2);
|
|
|
|
|
pt1.x = lon1;
|
|
|
|
|
pt1.y = lat1;
|
|
|
|
|
pt2.x = lon2;
|
|
|
|
|
pt2.y = lat2;
|
|
|
|
|
//计算交点
|
|
|
|
|
analysis.linePolygonIntersections(pt1,pt2,surveyRegionLons,surveyRegionLats,result);
|
|
|
|
|
nCrossPt = analysis.linePolygonIntersections(pt1,pt2,surveyRegionLons,surveyRegionLats,result);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int nlinePts = result.size();
|
|
|
|
|
if (nlinePts%2!=0)
|
|
|
|
|
{
|
|
|
|
|
nlinePts--;
|
|
|
|
|
}
|
|
|
|
|
//计算外扩航点
|
|
|
|
|
if (nlinePts>1 && outLength>0)
|
|
|
|
|
{
|
|
|
|
|
double angle;
|
|
|
|
|
CalculateTwoPtsAzimuth(angle,result[0].x,result[0].y,result[1].x,result[1].y,3);
|
|
|
|
|
//计算外扩航向
|
|
|
|
|
double outAngle1,outAngle2;
|
|
|
|
|
outAngle2 = angle;
|
|
|
|
|
int n = (angle + 180)/360;
|
|
|
|
|
outAngle1 = (angle + 180) - 360*n;
|
|
|
|
|
geocompute.computeOffsetGeoPosition(result[1].x,result[1].y,outAngle2,outLength/1000,lon2,lat2);
|
|
|
|
|
result[1].x = lon2;
|
|
|
|
|
result[1].y = lat2;
|
|
|
|
|
for (int i=2;i<nlinePts;i+=2)
|
|
|
|
|
{
|
|
|
|
|
geocompute.computeOffsetGeoPosition(result[i].x,result[i].y,outAngle1,outLength/1000,lon1,lat1);
|
|
|
|
|
geocompute.computeOffsetGeoPosition(result[i+1].x,result[i+1].y,outAngle2,outLength/1000,lon2,lat2);
|
|
|
|
|
result[i].x = lon1;
|
|
|
|
|
result[i].y = lat1;
|
|
|
|
|
result[i+1].x = lon2;
|
|
|
|
|
result[i+1].y = lat2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//串联交点
|
|
|
|
|
int j = 1;
|
|
|
|
|
for (int i=0;i<result.size();i+=2)
|
|
|
|
|
int j = 0;
|
|
|
|
|
for (int i=0;i<nlinePts;i+=2)
|
|
|
|
|
{
|
|
|
|
|
if (j == 1)
|
|
|
|
|
{
|
|
|
|
@ -336,12 +407,20 @@ void DesignSurveyLineDlg::OnBnClickedBtnCalculateline()
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GetDlgItemText(IDC_EDIT_EXTERNALLENGTH,cstr);
|
|
|
|
|
double outLength = _ttof(cstr);
|
|
|
|
|
if (outLength < 0 )
|
|
|
|
|
{
|
|
|
|
|
BCGPMessageBox("外扩长度必须大于0m");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_Height = height;
|
|
|
|
|
//测绘航线坐标
|
|
|
|
|
vector<double> surveyLineLons;
|
|
|
|
|
vector<double> surveyLineLats;
|
|
|
|
|
//计算航测航线
|
|
|
|
|
calculateSurveyLine(lineInterval,surveyLineLons,surveyLineLats);
|
|
|
|
|
calculateSurveyLine(lineInterval,surveyLineLons,surveyLineLats,outLength);
|
|
|
|
|
//保存航测航线
|
|
|
|
|
saveSurveyLine(surveyLineLons,surveyLineLats,height);
|
|
|
|
|
//发送消息到主程序,进行标绘
|
|
|
|
|