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
ca2c3722
Commit
ca2c3722
authored
Jun 10, 2017
by
Beat Küng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AirMap: display polygons from api.airmap.com/status/alpha/point
parent
c92f9ca0
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
202 additions
and
96 deletions
+202
-96
JsonHelper.cc
src/JsonHelper.cc
+4
-3
JsonHelper.h
src/JsonHelper.h
+5
-4
AirMapManager.cc
src/MissionManager/AirMapManager.cc
+148
-56
AirMapManager.h
src/MissionManager/AirMapManager.h
+45
-33
No files found.
src/JsonHelper.cc
View file @
ca2c3722
...
...
@@ -104,9 +104,10 @@ void JsonHelper::_saveGeoCoordinate(const QGeoCoordinate& coordinate,
bool
JsonHelper
::
loadGeoCoordinate
(
const
QJsonValue
&
jsonValue
,
bool
altitudeRequired
,
QGeoCoordinate
&
coordinate
,
QString
&
errorString
)
QString
&
errorString
,
bool
geoJsonFormat
)
{
return
_loadGeoCoordinate
(
jsonValue
,
altitudeRequired
,
coordinate
,
errorString
,
false
/* geoJsonFormat */
);
return
_loadGeoCoordinate
(
jsonValue
,
altitudeRequired
,
coordinate
,
errorString
,
geoJsonFormat
);
}
void
JsonHelper
::
saveGeoCoordinate
(
const
QGeoCoordinate
&
coordinate
,
...
...
@@ -384,7 +385,7 @@ bool JsonHelper::loadPolygon(const QJsonArray& polygonArray, QmlObjectListModel&
const
QJsonValue
&
pointValue
=
polygonArray
[
i
];
QGeoCoordinate
pointCoord
;
if
(
!
JsonHelper
::
loadGeoCoordinate
(
pointValue
,
false
/* altitudeRequired */
,
pointCoord
,
errorString
))
{
if
(
!
JsonHelper
::
loadGeoCoordinate
(
pointValue
,
false
/* altitudeRequired */
,
pointCoord
,
errorString
,
true
))
{
list
.
clearAndDeleteContents
();
return
false
;
}
...
...
src/JsonHelper.h
View file @
ca2c3722
...
...
@@ -66,10 +66,11 @@ public:
/// Loads a QGeoCoordinate
/// Stored as array [ lat, lon, alt ]
/// @return false: validation failed
static
bool
loadGeoCoordinate
(
const
QJsonValue
&
jsonValue
,
///< json value to load from
bool
altitudeRequired
,
///< true: altitude must be specified
QGeoCoordinate
&
coordinate
,
///< returned QGeoCordinate
QString
&
errorString
);
///< returned error string if load failure
static
bool
loadGeoCoordinate
(
const
QJsonValue
&
jsonValue
,
///< json value to load from
bool
altitudeRequired
,
///< true: altitude must be specified
QGeoCoordinate
&
coordinate
,
///< returned QGeoCordinate
QString
&
errorString
,
///< returned error string if load failure
bool
geoJsonFormat
=
false
);
///< if true, use [lon, lat], [lat, lon] otherwise
/// Saves a QGeoCoordinate
/// Stored as array [ lat, lon, alt ]
...
...
src/MissionManager/AirMapManager.cc
View file @
ca2c3722
This diff is collapsed.
Click to expand it.
src/MissionManager/AirMapManager.h
View file @
ca2c3722
...
...
@@ -22,39 +22,6 @@
Q_DECLARE_LOGGING_CATEGORY
(
AirMapManagerLog
)
/// AirMap server communication support.
class
AirMapManager
:
public
QGCTool
{
Q_OBJECT
public:
AirMapManager
(
QGCApplication
*
app
,
QGCToolbox
*
toolbox
);
~
AirMapManager
();
/// Set the ROI for airspace information
/// @param center Center coordinate for ROI
/// @param radiusMeters Radius in meters around center which is of interest
void
setROI
(
QGeoCoordinate
&
center
,
double
radiusMeters
);
QmlObjectListModel
*
polygonRestrictions
(
void
)
{
return
&
_polygonList
;
}
QmlObjectListModel
*
circularRestrictions
(
void
)
{
return
&
_circleList
;
}
private
slots
:
void
_getFinished
(
void
);
void
_getError
(
QNetworkReply
::
NetworkError
code
);
void
_updateToROI
(
void
);
private:
void
_get
(
QUrl
url
);
void
_parseAirspaceJson
(
const
QJsonDocument
&
airspaceDoc
);
QGeoCoordinate
_roiCenter
;
double
_roiRadius
;
QNetworkAccessManager
_networkManager
;
QTimer
_updateTimer
;
QmlObjectListModel
_polygonList
;
QmlObjectListModel
_circleList
;
};
class
AirspaceRestriction
:
public
QObject
{
...
...
@@ -92,4 +59,49 @@ private:
double
_radius
;
};
/// AirMap server communication support.
class
AirMapManager
:
public
QGCTool
{
Q_OBJECT
public:
AirMapManager
(
QGCApplication
*
app
,
QGCToolbox
*
toolbox
);
~
AirMapManager
();
/// Set the ROI for airspace information
/// @param center Center coordinate for ROI
/// @param radiusMeters Radius in meters around center which is of interest
void
setROI
(
QGeoCoordinate
&
center
,
double
radiusMeters
);
QmlObjectListModel
*
polygonRestrictions
(
void
)
{
return
&
_polygonList
;
}
QmlObjectListModel
*
circularRestrictions
(
void
)
{
return
&
_circleList
;
}
private
slots
:
void
_getFinished
(
void
);
void
_getError
(
QNetworkReply
::
NetworkError
code
);
void
_updateToROI
(
void
);
private:
void
_get
(
QUrl
url
);
void
_parseAirspaceJson
(
const
QJsonDocument
&
airspaceDoc
);
enum
class
State
{
Idle
,
RetrieveList
,
RetrieveItems
,
};
State
_state
=
State
::
Idle
;
int
_numAwaitingItems
=
0
;
QGeoCoordinate
_roiCenter
;
double
_roiRadius
;
QNetworkAccessManager
_networkManager
;
QTimer
_updateTimer
;
QmlObjectListModel
_polygonList
;
QmlObjectListModel
_circleList
;
QList
<
PolygonAirspaceRestriction
*>
_nextPolygonList
;
QList
<
CircularAirspaceRestriction
*>
_nextcircleList
;
};
#endif
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