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
299a27e3
Commit
299a27e3
authored
Jun 05, 2017
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unit tests for survey grid angle and entry location
parent
62bbd9c8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
0 deletions
+75
-0
SurveyMissionItemTest.cc
src/MissionManager/SurveyMissionItemTest.cc
+71
-0
SurveyMissionItemTest.h
src/MissionManager/SurveyMissionItemTest.h
+4
-0
No files found.
src/MissionManager/SurveyMissionItemTest.cc
View file @
299a27e3
...
...
@@ -178,3 +178,74 @@ void SurveyMissionItemTest::_testCameraTrigger(void)
QCOMPARE(_multiSpy->pullIntFromSignalIndex(lastSequenceNumberChangedIndex), lastSeq);
#endif
}
// Clamp expected grid angle from 0<->180. We don't care about opposite angles like 90/270
double
SurveyMissionItemTest
::
_clampGridAngle180
(
double
gridAngle
)
{
if
(
gridAngle
>=
0.0
)
{
if
(
gridAngle
==
360.0
)
{
gridAngle
=
0.0
;
}
else
if
(
gridAngle
>=
180.0
)
{
gridAngle
-=
180.0
;
}
}
else
{
if
(
gridAngle
<
-
180.0
)
{
gridAngle
+=
360.0
;
}
else
{
gridAngle
+=
180.0
;
}
}
return
gridAngle
;
}
void
SurveyMissionItemTest
::
_testGridAngle
(
void
)
{
QGCMapPolygon
*
mapPolygon
=
_surveyItem
->
mapPolygon
();
for
(
int
i
=
0
;
i
<
_polyPoints
.
count
();
i
++
)
{
QGeoCoordinate
&
vertex
=
_polyPoints
[
i
];
mapPolygon
->
appendVertex
(
vertex
);
}
for
(
double
gridAngle
=-
360.0
;
gridAngle
<=
360.0
;
gridAngle
++
)
{
_surveyItem
->
gridAngle
()
->
setRawValue
(
gridAngle
);
QVariantList
gridPoints
=
_surveyItem
->
gridPoints
();
QGeoCoordinate
firstTransectEntry
=
gridPoints
[
0
].
value
<
QGeoCoordinate
>
();
QGeoCoordinate
firstTransectExit
=
gridPoints
[
1
].
value
<
QGeoCoordinate
>
();
double
azimuth
=
firstTransectEntry
.
azimuthTo
(
firstTransectExit
);
//qDebug() << gridAngle << azimuth << _clampGridAngle180(gridAngle) << _clampGridAngle180(azimuth);
QCOMPARE
((
int
)
_clampGridAngle180
(
gridAngle
),
(
int
)
_clampGridAngle180
(
azimuth
));
}
}
void
SurveyMissionItemTest
::
_testEntryLocation
(
void
)
{
QGCMapPolygon
*
mapPolygon
=
_surveyItem
->
mapPolygon
();
for
(
int
i
=
0
;
i
<
_polyPoints
.
count
();
i
++
)
{
QGeoCoordinate
&
vertex
=
_polyPoints
[
i
];
mapPolygon
->
appendVertex
(
vertex
);
}
for
(
double
gridAngle
=-
360.0
;
gridAngle
<=
360.0
;
gridAngle
++
)
{
_surveyItem
->
gridAngle
()
->
setRawValue
(
gridAngle
);
QList
<
QGeoCoordinate
>
rgSeenEntryCoords
;
QList
<
int
>
rgEntryLocation
;
rgEntryLocation
<<
SurveyMissionItem
::
EntryLocationTopLeft
<<
SurveyMissionItem
::
EntryLocationTopRight
<<
SurveyMissionItem
::
EntryLocationBottomLeft
<<
SurveyMissionItem
::
EntryLocationBottomRight
;
// Validate that each entry location is unique
for
(
int
i
=
0
;
i
<
rgEntryLocation
.
count
();
i
++
)
{
int
entryLocation
=
rgEntryLocation
[
i
];
_surveyItem
->
gridEntryLocation
()
->
setRawValue
(
entryLocation
);
QVERIFY
(
!
rgSeenEntryCoords
.
contains
(
_surveyItem
->
coordinate
()));
rgSeenEntryCoords
<<
_surveyItem
->
coordinate
();
}
rgSeenEntryCoords
.
clear
();
}
}
src/MissionManager/SurveyMissionItemTest.h
View file @
299a27e3
...
...
@@ -34,8 +34,12 @@ private slots:
void
_testDirty
(
void
);
void
_testCameraValueChanged
(
void
);
void
_testCameraTrigger
(
void
);
void
_testGridAngle
(
void
);
void
_testEntryLocation
(
void
);
private:
double
_clampGridAngle180
(
double
gridAngle
);
enum
{
gridPointsChangedIndex
=
0
,
cameraShotsChangedIndex
,
...
...
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