Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
5b96a14f
Commit
5b96a14f
authored
Jun 16, 2017
by
Don Gagne
Committed by
GitHub
Jun 16, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5301 from DonLakeFlyer/SingleTransect
Survey: Handle case of transects < 2
parents
42c7c4e4
9d925db1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
9 deletions
+25
-9
SurveyMissionItem.cc
src/MissionManager/SurveyMissionItem.cc
+25
-9
No files found.
src/MissionManager/SurveyMissionItem.cc
View file @
5b96a14f
...
...
@@ -847,6 +847,7 @@ void SurveyMissionItem::_intersectLinesWithRect(const QList<QLineF>& lineList, c
void
SurveyMissionItem
::
_intersectLinesWithPolygon
(
const
QList
<
QLineF
>&
lineList
,
const
QPolygonF
&
polygon
,
QList
<
QLineF
>&
resultLines
)
{
resultLines
.
clear
();
for
(
int
i
=
0
;
i
<
lineList
.
count
();
i
++
)
{
int
foundCount
=
0
;
QLineF
intersectLine
;
...
...
@@ -932,15 +933,15 @@ int SurveyMissionItem::_gridGenerator(const QList<QPointF>& polygonPoints, QLis
}
polygon
<<
polygonPoints
[
0
];
QRectF
smallBoundRect
=
polygon
.
boundingRect
();
QPointF
c
enter
=
smallBoundRect
.
center
();
QPointF
boundingC
enter
=
smallBoundRect
.
center
();
qCDebug
(
SurveyMissionItemLog
)
<<
"Bounding rect"
<<
smallBoundRect
.
topLeft
().
x
()
<<
smallBoundRect
.
topLeft
().
y
()
<<
smallBoundRect
.
bottomRight
().
x
()
<<
smallBoundRect
.
bottomRight
().
y
();
// Rotate the bounding rect around it's center to generate the larger bounding rect
QPolygonF
boundPolygon
;
boundPolygon
<<
_rotatePoint
(
smallBoundRect
.
topLeft
(),
c
enter
,
gridAngle
);
boundPolygon
<<
_rotatePoint
(
smallBoundRect
.
topRight
(),
c
enter
,
gridAngle
);
boundPolygon
<<
_rotatePoint
(
smallBoundRect
.
bottomRight
(),
c
enter
,
gridAngle
);
boundPolygon
<<
_rotatePoint
(
smallBoundRect
.
bottomLeft
(),
c
enter
,
gridAngle
);
boundPolygon
<<
_rotatePoint
(
smallBoundRect
.
topLeft
(),
boundingC
enter
,
gridAngle
);
boundPolygon
<<
_rotatePoint
(
smallBoundRect
.
topRight
(),
boundingC
enter
,
gridAngle
);
boundPolygon
<<
_rotatePoint
(
smallBoundRect
.
bottomRight
(),
boundingC
enter
,
gridAngle
);
boundPolygon
<<
_rotatePoint
(
smallBoundRect
.
bottomLeft
(),
boundingC
enter
,
gridAngle
);
boundPolygon
<<
boundPolygon
[
0
];
QRectF
largeBoundRect
=
boundPolygon
.
boundingRect
();
qCDebug
(
SurveyMissionItemLog
)
<<
"Rotated bounding rect"
<<
largeBoundRect
.
topLeft
().
x
()
<<
largeBoundRect
.
topLeft
().
y
()
<<
largeBoundRect
.
bottomRight
().
x
()
<<
largeBoundRect
.
bottomRight
().
y
();
...
...
@@ -962,7 +963,7 @@ int SurveyMissionItem::_gridGenerator(const QList<QPointF>& polygonPoints, QLis
float
yTop
=
largeBoundRect
.
topLeft
().
y
()
-
100.0
;
float
yBottom
=
largeBoundRect
.
bottomRight
().
y
()
+
100.0
;
lineList
+=
QLineF
(
_rotatePoint
(
QPointF
(
x
,
yTop
),
center
,
gridAngle
),
_rotatePoint
(
QPointF
(
x
,
yBottom
),
c
enter
,
gridAngle
));
lineList
+=
QLineF
(
_rotatePoint
(
QPointF
(
x
,
yTop
),
boundingCenter
,
gridAngle
),
_rotatePoint
(
QPointF
(
x
,
yBottom
),
boundingC
enter
,
gridAngle
));
qCDebug
(
SurveyMissionItemLog
)
<<
"line("
<<
lineList
.
last
().
x1
()
<<
", "
<<
lineList
.
last
().
y1
()
<<
")-("
<<
lineList
.
last
().
x2
()
<<
", "
<<
lineList
.
last
().
y2
()
<<
")"
;
x
+=
gridSpacing
;
...
...
@@ -975,7 +976,7 @@ int SurveyMissionItem::_gridGenerator(const QList<QPointF>& polygonPoints, QLis
float
yTop
=
largeBoundRect
.
topRight
().
y
()
-
100.0
;
float
yBottom
=
largeBoundRect
.
bottomLeft
().
y
()
+
100.0
;
lineList
+=
QLineF
(
_rotatePoint
(
QPointF
(
x
,
yTop
),
center
,
gridAngle
),
_rotatePoint
(
QPointF
(
x
,
yBottom
),
c
enter
,
gridAngle
));
lineList
+=
QLineF
(
_rotatePoint
(
QPointF
(
x
,
yTop
),
boundingCenter
,
gridAngle
),
_rotatePoint
(
QPointF
(
x
,
yBottom
),
boundingC
enter
,
gridAngle
));
qCDebug
(
SurveyMissionItemLog
)
<<
"line("
<<
lineList
.
last
().
x1
()
<<
", "
<<
lineList
.
last
().
y1
()
<<
")-("
<<
lineList
.
last
().
x2
()
<<
", "
<<
lineList
.
last
().
y2
()
<<
")"
;
x
-=
gridSpacing
;
...
...
@@ -992,7 +993,7 @@ int SurveyMissionItem::_gridGenerator(const QList<QPointF>& polygonPoints, QLis
float
xLeft
=
largeBoundRect
.
bottomLeft
().
x
()
-
100.0
;
float
xRight
=
largeBoundRect
.
topRight
().
x
()
+
100.0
;
lineList
+=
QLineF
(
_rotatePoint
(
QPointF
(
xLeft
,
y
),
center
,
gridAngle
),
_rotatePoint
(
QPointF
(
xRight
,
y
),
c
enter
,
gridAngle
));
lineList
+=
QLineF
(
_rotatePoint
(
QPointF
(
xLeft
,
y
),
boundingCenter
,
gridAngle
),
_rotatePoint
(
QPointF
(
xRight
,
y
),
boundingC
enter
,
gridAngle
));
qCDebug
(
SurveyMissionItemLog
)
<<
"y:xLeft:xRight"
<<
y
<<
xLeft
<<
xRight
<<
"line("
<<
lineList
.
last
().
x1
()
<<
", "
<<
lineList
.
last
().
y1
()
<<
")-("
<<
lineList
.
last
().
x2
()
<<
", "
<<
lineList
.
last
().
y2
()
<<
")"
;
y
-=
gridSpacing
;
...
...
@@ -1005,7 +1006,7 @@ int SurveyMissionItem::_gridGenerator(const QList<QPointF>& polygonPoints, QLis
float
xLeft
=
largeBoundRect
.
topLeft
().
x
()
-
100.0
;
float
xRight
=
largeBoundRect
.
bottomRight
().
x
()
+
100.0
;
lineList
+=
QLineF
(
_rotatePoint
(
QPointF
(
xLeft
,
y
),
center
,
gridAngle
),
_rotatePoint
(
QPointF
(
xRight
,
y
),
c
enter
,
gridAngle
));
lineList
+=
QLineF
(
_rotatePoint
(
QPointF
(
xLeft
,
y
),
boundingCenter
,
gridAngle
),
_rotatePoint
(
QPointF
(
xRight
,
y
),
boundingC
enter
,
gridAngle
));
qCDebug
(
SurveyMissionItemLog
)
<<
"y:xLeft:xRight"
<<
y
<<
xLeft
<<
xRight
<<
"line("
<<
lineList
.
last
().
x1
()
<<
", "
<<
lineList
.
last
().
y1
()
<<
")-("
<<
lineList
.
last
().
x2
()
<<
", "
<<
lineList
.
last
().
y2
()
<<
")"
;
y
+=
gridSpacing
;
...
...
@@ -1022,6 +1023,21 @@ int SurveyMissionItem::_gridGenerator(const QList<QPointF>& polygonPoints, QLis
intersectLines
=
lineList
;
#endif
// Less than two transects intersected with the polygon:
// Create a single transect which goes through the center of the polygon
// Intersect it with the polygon
if
(
intersectLines
.
count
()
<
2
)
{
_mapPolygon
.
center
();
QLineF
firstLine
=
lineList
.
first
();
QPointF
lineCenter
=
firstLine
.
pointAt
(
0.5
);
QPointF
centerOffset
=
boundingCenter
-
lineCenter
;
firstLine
.
translate
(
centerOffset
);
lineList
.
clear
();
lineList
.
append
(
firstLine
);
intersectLines
=
lineList
;
_intersectLinesWithPolygon
(
lineList
,
polygon
,
intersectLines
);
}
// Make sure all lines are going to same direction. Polygon intersection leads to line which
// can be in varied directions depending on the order of the intesecting sides.
QList
<
QLineF
>
resultLines
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment