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
f3253d42
Commit
f3253d42
authored
Jan 24, 2018
by
Gus Grubba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Figuring out rulesets
parent
be0901cc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
138 additions
and
7 deletions
+138
-7
AirMapManager.cc
src/Airmap/AirMapManager.cc
+72
-0
AirMapManager.h
src/Airmap/AirMapManager.h
+24
-3
AirspaceManagement.cc
src/Airmap/AirspaceManagement.cc
+15
-0
AirspaceManagement.h
src/Airmap/AirspaceManagement.h
+27
-4
No files found.
src/Airmap/AirMapManager.cc
View file @
f3253d42
...
...
@@ -24,6 +24,7 @@
#include <airmap/flights.h>
#include <airmap/pilots.h>
#include <airmap/telemetry.h>
#include <airmap/rulesets.h>
using
namespace
airmap
;
...
...
@@ -979,3 +980,74 @@ AirspaceRestrictionProvider* AirMapManager::instantiateRestrictionProvider()
return
restrictionManager
;
}
AirspaceRulesetsProvider
*
AirMapManager
::
instantiateRulesetsProvider
()
{
AirMapRulesetsManager
*
rulesetsManager
=
new
AirMapRulesetsManager
(
_shared
);
connect
(
rulesetsManager
,
&
AirMapRulesetsManager
::
error
,
this
,
&
AirMapManager
::
_error
);
return
rulesetsManager
;
}
//-----------------------------------------------------------------------------
AirMapRulesetsManager
::
AirMapRulesetsManager
(
AirMapSharedState
&
shared
)
:
_shared
(
shared
)
{
}
//-----------------------------------------------------------------------------
void
AirMapRulesetsManager
::
setROI
(
const
QGeoCoordinate
&
center
)
{
if
(
!
_shared
.
client
())
{
qCDebug
(
AirMapManagerLog
)
<<
"No AirMap client instance. Not updating Airspace"
;
return
;
}
if
(
_state
!=
State
::
Idle
)
{
qCWarning
(
AirMapManagerLog
)
<<
"AirMapRestrictionManager::updateROI: state not idle"
;
return
;
}
qCDebug
(
AirMapManagerLog
)
<<
"Setting ROI for Rulesets"
;
_state
=
State
::
RetrieveItems
;
RuleSets
::
Search
::
Parameters
params
;
params
.
geometry
=
Geometry
::
point
(
center
.
latitude
(),
center
.
longitude
());
std
::
weak_ptr
<
LifetimeChecker
>
isAlive
(
_instance
);
_shared
.
client
()
->
rulesets
().
search
(
params
,
[
this
,
isAlive
](
const
RuleSets
::
Search
::
Result
&
result
)
{
if
(
!
isAlive
.
lock
())
return
;
if
(
_state
!=
State
::
RetrieveItems
)
return
;
if
(
result
)
{
const
std
::
vector
<
RuleSet
>&
rulesets
=
result
.
value
();
qCDebug
(
AirMapManagerLog
)
<<
"Successful rulesets search. Items:"
<<
rulesets
.
size
();
for
(
const
auto
&
ruleset
:
rulesets
)
{
qDebug
()
<<
"------------------------------------------"
;
qDebug
()
<<
"Jurisdiction:"
<<
ruleset
.
jurisdiction
.
name
.
data
()
<<
(
int
)
ruleset
.
jurisdiction
.
region
;
qDebug
()
<<
"Name: "
<<
ruleset
.
name
.
data
();
qDebug
()
<<
"Short Name: "
<<
ruleset
.
short_name
.
data
();
qDebug
()
<<
"Description: "
<<
ruleset
.
description
.
data
();
qDebug
()
<<
"Is default: "
<<
ruleset
.
is_default
;
qDebug
()
<<
"Applicable to these airspace types:"
;
for
(
const
auto
&
airspaceType
:
ruleset
.
airspace_types
)
{
qDebug
()
<<
airspaceType
.
data
();
}
qDebug
()
<<
"Rules:"
;
for
(
const
auto
&
rule
:
ruleset
.
rules
)
{
qDebug
()
<<
" --------------------------------------"
;
qDebug
()
<<
" "
<<
rule
.
short_text
.
data
();
qDebug
()
<<
" "
<<
rule
.
description
.
data
();
qDebug
()
<<
" "
<<
rule
.
display_order
;
qDebug
()
<<
" "
<<
(
int
)
rule
.
status
;
qDebug
()
<<
" Features:"
;
for
(
const
auto
&
feature
:
rule
.
features
)
{
qDebug
()
<<
" "
<<
feature
.
name
.
data
();
qDebug
()
<<
" "
<<
feature
.
description
.
data
();
qDebug
()
<<
" "
<<
(
int
)
feature
.
status
;
}
}
}
}
else
{
QString
description
=
QString
::
fromStdString
(
result
.
error
().
description
()
?
result
.
error
().
description
().
get
()
:
""
);
emit
error
(
"Failed to retrieve RuleSets"
,
QString
::
fromStdString
(
result
.
error
().
message
()),
description
);
}
emit
requestDone
(
true
);
_state
=
State
::
Idle
;
});
}
src/Airmap/AirMapManager.h
View file @
f3253d42
...
...
@@ -136,6 +136,27 @@ private:
AirMapSharedState
&
_shared
;
};
/// class to download rulesets from AirMap
class
AirMapRulesetsManager
:
public
AirspaceRulesetsProvider
,
public
LifetimeChecker
{
Q_OBJECT
public:
AirMapRulesetsManager
(
AirMapSharedState
&
shared
);
void
setROI
(
const
QGeoCoordinate
&
center
)
override
;
signals:
void
error
(
const
QString
&
what
,
const
QString
&
airmapdMessage
,
const
QString
&
airmapdDetails
);
private:
enum
class
State
{
Idle
,
RetrieveItems
,
};
State
_state
=
State
::
Idle
;
AirMapSharedState
&
_shared
;
};
/// class to upload a flight
class
AirMapFlightManager
:
public
QObject
,
public
LifetimeChecker
...
...
@@ -343,9 +364,9 @@ public:
void
setToolbox
(
QGCToolbox
*
toolbox
)
override
;
AirspaceManagerPerVehicle
*
instantiateVehicle
(
const
Vehicle
&
vehicle
)
override
;
AirspaceR
estrictionProvider
*
instantiateRestrictionProvider
()
override
;
AirspaceManagerPerVehicle
*
instantiateVehicle
(
const
Vehicle
&
vehicle
)
override
;
AirspaceRestrictionProvider
*
instantiateRestrictionProvider
()
override
;
AirspaceR
ulesetsProvider
*
instantiateRulesetsProvider
()
override
;
QString
name
()
const
override
{
return
"AirMap"
;
}
...
...
src/Airmap/AirspaceManagement.cc
View file @
f3253d42
...
...
@@ -50,6 +50,9 @@ AirspaceManager::~AirspaceManager()
if
(
_restrictionsProvider
)
{
delete
_restrictionsProvider
;
}
if
(
_rulesetsProvider
)
{
delete
_rulesetsProvider
;
}
_polygonRestrictions
.
clearAndDeleteContents
();
_circleRestrictions
.
clearAndDeleteContents
();
}
...
...
@@ -64,6 +67,13 @@ void AirspaceManager::setToolbox(QGCToolbox* toolbox)
connect
(
_restrictionsProvider
,
&
AirspaceRestrictionProvider
::
requestDone
,
this
,
&
AirspaceManager
::
_restrictionsUpdated
);
}
_rulesetsProvider
=
instantiateRulesetsProvider
();
/*
if (_rulesetsProvider) {
connect(_rulesetsProvider, &AirspaceRulesetsProvider::requestDone, this,
&AirspaceManager::_rulesetsUpdated);
}
*/
}
void
AirspaceManager
::
setROI
(
const
QGeoCoordinate
&
center
,
double
radiusMeters
)
...
...
@@ -78,6 +88,11 @@ void AirspaceManager::_updateToROI()
if
(
_restrictionsProvider
)
{
_restrictionsProvider
->
setROI
(
_roiCenter
,
_roiRadius
);
}
//-- TODO: We may want to check the distance between this ROI and the last
// to see if we really need to update it.
if
(
_rulesetsProvider
)
{
_rulesetsProvider
->
setROI
(
_roiCenter
);
}
}
void
AirspaceManager
::
_restrictionsUpdated
(
bool
success
)
...
...
src/Airmap/AirspaceManagement.h
View file @
f3253d42
...
...
@@ -120,6 +120,24 @@ protected:
QList
<
CircularAirspaceRestriction
*>
_circleList
;
};
/**
* @class AirspaceRulesetsProvider
* Base class that queries for airspace rulesets
*/
class
AirspaceRulesetsProvider
:
public
QObject
{
Q_OBJECT
public:
AirspaceRulesetsProvider
()
=
default
;
~
AirspaceRulesetsProvider
()
=
default
;
/**
* Set region of interest that should be queried. When finished, the requestDone() signal will be emmited.
* @param center Center coordinate for ROI
*/
virtual
void
setROI
(
const
QGeoCoordinate
&
center
)
=
0
;
signals:
void
requestDone
(
bool
success
);
};
class
AirspaceManagerPerVehicle
;
class
Vehicle
;
...
...
@@ -153,11 +171,15 @@ public:
virtual
AirspaceManagerPerVehicle
*
instantiateVehicle
(
const
Vehicle
&
vehicle
)
=
0
;
/**
*
* Factory method to create an AirspaceRestrictionProvider object
*/
virtual
AirspaceRestrictionProvider
*
instantiateRestrictionProvider
()
=
0
;
/**
* Factory method to create an AirspaceRulesetsProvider object
*/
virtual
AirspaceRulesetsProvider
*
instantiateRulesetsProvider
()
=
0
;
/**
* Set the ROI for airspace information (restrictions shown in UI)
* @param center Center coordinate for ROI
...
...
@@ -190,10 +212,11 @@ private slots:
private:
void
_updateToROI
();
AirspaceRestrictionProvider
*
_restrictionsProvider
=
nullptr
;
///< restrictions that are shown in the UI
AirspaceRestrictionProvider
*
_restrictionsProvider
=
nullptr
;
///< restrictions that are shown in the UI
AirspaceRulesetsProvider
*
_rulesetsProvider
=
nullptr
;
///< restrictions that are shown in the UI
QmlObjectListModel
_polygonRestrictions
;
///< current polygon restrictions
QmlObjectListModel
_circleRestrictions
;
///< current circle restrictions
QmlObjectListModel
_polygonRestrictions
;
///< current polygon restrictions
QmlObjectListModel
_circleRestrictions
;
///< current circle restrictions
QTimer
_roiUpdateTimer
;
QGeoCoordinate
_roiCenter
;
...
...
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