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
60bc4330
Commit
60bc4330
authored
Feb 17, 2018
by
Gus Grubba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Process features
parent
2842dd68
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
120 additions
and
44 deletions
+120
-44
AirMapFlightManager.cc
src/Airmap/AirMapFlightManager.cc
+6
-4
AirMapFlightPlanManager.cc
src/Airmap/AirMapFlightPlanManager.cc
+30
-2
AirMapRulesetsManager.cc
src/Airmap/AirMapRulesetsManager.cc
+81
-28
AirMapRulesetsManager.h
src/Airmap/AirMapRulesetsManager.h
+3
-8
AirspaceRulesetsProvider.h
src/AirspaceManagement/AirspaceRulesetsProvider.h
+0
-2
No files found.
src/Airmap/AirMapFlightManager.cc
View file @
60bc4330
...
...
@@ -186,15 +186,17 @@ void AirMapFlightManager::_uploadFlight()
params
.
pilot
.
id
=
_pilotID
.
toStdString
();
params
.
start_time
=
Clock
::
universal_time
()
+
Minutes
{
5
};
params
.
end_time
=
Clock
::
universal_time
()
+
Hours
{
2
};
// TODO: user-configurable?
//-- Rules
AirMapRulesetsManager
*
pRulesMgr
=
dynamic_cast
<
AirMapRulesetsManager
*>
(
qgcApp
()
->
toolbox
()
->
airspaceManager
()
->
ruleSets
());
if
(
pRulesMgr
)
{
foreach
(
QString
ruleset
,
pRulesMgr
->
rulesetsIDs
())
{
params
.
rulesets
.
push_back
(
ruleset
.
toStdString
());
for
(
int
rs
=
0
;
rs
<
pRulesMgr
->
ruleSets
()
->
count
();
rs
++
)
{
AirMapRuleSet
*
ruleSet
=
qobject_cast
<
AirMapRuleSet
*>
(
pRulesMgr
->
ruleSets
()
->
get
(
rs
));
//-- If this ruleset is selected
if
(
ruleSet
&&
ruleSet
->
selected
())
{
params
.
rulesets
.
push_back
(
ruleSet
->
id
().
toStdString
());
}
}
}
// geometry: LineString
Geometry
::
LineString
lineString
;
for
(
const
auto
&
qcoord
:
_flight
.
coords
)
{
...
...
src/Airmap/AirMapFlightPlanManager.cc
View file @
60bc4330
...
...
@@ -194,8 +194,36 @@ AirMapFlightPlanManager::_uploadFlightPlan()
//-- Rules
AirMapRulesetsManager
*
pRulesMgr
=
dynamic_cast
<
AirMapRulesetsManager
*>
(
qgcApp
()
->
toolbox
()
->
airspaceManager
()
->
ruleSets
());
if
(
pRulesMgr
)
{
foreach
(
QString
ruleset
,
pRulesMgr
->
rulesetsIDs
())
{
params
.
rulesets
.
push_back
(
ruleset
.
toStdString
());
for
(
int
rs
=
0
;
rs
<
pRulesMgr
->
ruleSets
()
->
count
();
rs
++
)
{
AirMapRuleSet
*
ruleSet
=
qobject_cast
<
AirMapRuleSet
*>
(
pRulesMgr
->
ruleSets
()
->
get
(
rs
));
//-- If this ruleset is selected
if
(
ruleSet
&&
ruleSet
->
selected
())
{
params
.
rulesets
.
push_back
(
ruleSet
->
id
().
toStdString
());
//-- Features within each rule
for
(
int
r
=
0
;
r
<
ruleSet
->
rules
()
->
count
();
r
++
)
{
AirMapRule
*
rule
=
qobject_cast
<
AirMapRule
*>
(
ruleSet
->
rules
()
->
get
(
r
));
if
(
rule
)
{
for
(
int
f
=
0
;
f
<
rule
->
features
()
->
count
();
f
++
)
{
AirMapRuleFeature
*
feature
=
qobject_cast
<
AirMapRuleFeature
*>
(
rule
->
features
()
->
get
(
f
));
if
(
feature
&&
feature
->
value
().
isValid
())
{
switch
(
feature
->
type
())
{
case
AirspaceRuleFeature
:
:
Boolean
:
params
.
features
[
feature
->
name
().
toStdString
()]
=
RuleSet
::
Feature
::
Value
(
feature
->
value
().
toBool
());
break
;
case
AirspaceRuleFeature
:
:
Float
:
params
.
features
[
feature
->
name
().
toStdString
()]
=
RuleSet
::
Feature
::
Value
(
feature
->
value
().
toFloat
());
break
;
case
AirspaceRuleFeature
:
:
String
:
params
.
features
[
feature
->
name
().
toStdString
()]
=
RuleSet
::
Feature
::
Value
(
feature
->
value
().
toString
().
toStdString
());
break
;
default:
qCWarning
(
AirMapManagerLog
)
<<
"Unknown type for feature"
<<
feature
->
name
();
}
}
}
}
}
}
}
}
//-- Geometry: LineString
...
...
src/Airmap/AirMapRulesetsManager.cc
View file @
60bc4330
...
...
@@ -9,9 +9,12 @@
#include "AirMapRulesetsManager.h"
#include "AirMapManager.h"
#include <QSettings>
using
namespace
airmap
;
static
const
char
*
kAirMapFeatureGroup
=
"AirMapFeatureGroup"
;
//-----------------------------------------------------------------------------
AirMapRuleFeature
::
AirMapRuleFeature
(
QObject
*
parent
)
:
AirspaceRuleFeature
(
parent
)
...
...
@@ -23,13 +26,27 @@ AirMapRuleFeature::AirMapRuleFeature(airmap::RuleSet::Feature feature, QObject*
:
AirspaceRuleFeature
(
parent
)
,
_feature
(
feature
)
{
//-- TODO: Read possible saved value from previous runs
//-- Restore persisted value (if it exists)
QSettings
settings
;
settings
.
beginGroup
(
kAirMapFeatureGroup
);
_value
=
settings
.
value
(
name
());
settings
.
endGroup
();
}
//-----------------------------------------------------------------------------
AirspaceRuleFeature
::
Type
AirMapRuleFeature
::
type
()
{
switch
(
_feature
.
type
)
{
case
RuleSet
:
:
Feature
::
Type
::
boolean
:
return
AirspaceRuleFeature
::
Boolean
;
case
RuleSet
:
:
Feature
::
Type
::
floating_point
:
return
AirspaceRuleFeature
::
Float
;
case
RuleSet
:
:
Feature
::
Type
::
string
:
return
AirspaceRuleFeature
::
String
;
default:
break
;
}
return
AirspaceRuleFeature
::
Unknown
;
}
...
...
@@ -37,6 +54,16 @@ AirMapRuleFeature::type()
AirspaceRuleFeature
::
Unit
AirMapRuleFeature
::
unit
()
{
switch
(
_feature
.
unit
)
{
case
RuleSet
:
:
Feature
::
Unit
::
kilograms
:
return
AirspaceRuleFeature
::
Kilogram
;
case
RuleSet
:
:
Feature
::
Unit
::
meters
:
return
AirspaceRuleFeature
::
Meters
;
case
RuleSet
:
:
Feature
::
Unit
::
meters_per_sec
:
return
AirspaceRuleFeature
::
MetersPerSecond
;
default:
break
;
}
return
AirspaceRuleFeature
::
UnknownUnit
;
}
...
...
@@ -44,9 +71,32 @@ AirMapRuleFeature::unit()
AirspaceRuleFeature
::
Measurement
AirMapRuleFeature
::
measurement
()
{
switch
(
_feature
.
measurement
)
{
case
RuleSet
:
:
Feature
::
Measurement
::
speed
:
return
AirspaceRuleFeature
::
Speed
;
case
RuleSet
:
:
Feature
::
Measurement
::
weight
:
return
AirspaceRuleFeature
::
Weight
;
case
RuleSet
:
:
Feature
::
Measurement
::
distance
:
return
AirspaceRuleFeature
::
Distance
;
default:
break
;
}
return
AirspaceRuleFeature
::
UnknownMeasurement
;
}
//-----------------------------------------------------------------------------
void
AirMapRuleFeature
::
setValue
(
const
QVariant
val
)
{
_value
=
val
;
//-- Make value persistent
QSettings
settings
;
settings
.
beginGroup
(
kAirMapFeatureGroup
);
settings
.
setValue
(
name
(),
_value
);
settings
.
endGroup
();
emit
valueChanged
();
}
//-----------------------------------------------------------------------------
AirMapRule
::
AirMapRule
(
QObject
*
parent
)
:
AirspaceRule
(
parent
)
...
...
@@ -98,6 +148,18 @@ AirMapRuleSet::~AirMapRuleSet()
_rules
.
deleteListAndContents
();
}
//-----------------------------------------------------------------------------
void
AirMapRuleSet
::
setSelected
(
bool
sel
)
{
if
(
_selectionType
!=
AirspaceRuleSet
::
Required
)
{
_selected
=
sel
;
}
else
{
_selected
=
true
;
}
emit
selectedChanged
();
}
//-----------------------------------------------------------------------------
AirMapRulesetsManager
::
AirMapRulesetsManager
(
AirMapSharedState
&
shared
)
:
_shared
(
shared
)
...
...
@@ -169,16 +231,17 @@ void AirMapRulesetsManager::setROI(const QGeoCoordinate& center)
for
(
const
auto
&
rule
:
ruleset
.
rules
)
{
AirMapRule
*
pRule
=
new
AirMapRule
(
rule
,
this
);
//-- Iterate Rule Features
//-- TODO: Rule features don't make sense as they are
for
(
const
auto
&
feature
:
rule
.
features
)
{
AirMapRuleFeature
*
pFeature
=
new
AirMapRuleFeature
(
feature
,
this
);
pRule
->
_features
.
append
(
pFeature
);
}
pRuleSet
->
_rules
.
append
(
pRule
);
}
//-- Sort rules by display order
std
::
sort
(
pRuleSet
->
_rules
.
objectList
()
->
begin
(),
pRuleSet
->
_rules
.
objectList
()
->
end
(),
rules_sort
);
_ruleSets
.
append
(
pRuleSet
);
qCDebug
(
AirMapManagerLog
)
<<
"Adding ruleset"
<<
pRuleSet
->
name
();
/*
qCDebug(AirMapManagerLog) << "Adding ruleset" << pRuleSet->name();
qDebug() << "------------------------------------------";
qDebug() << "Jurisdiction:" << ruleset.jurisdiction.name.data() << (int)ruleset.jurisdiction.region;
qDebug() << "Name: " << ruleset.name.data();
...
...
@@ -187,20 +250,24 @@ void AirMapRulesetsManager::setROI(const QGeoCoordinate& center)
qDebug() << "Is default: " << ruleset.is_default;
qDebug() << "Applicable to these airspace types:";
for (const auto& airspaceType : ruleset.airspace_types) {
qDebug() << airspaceType.data();
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:";
qDebug() << " short_text: " << rule.short_text.data();
qDebug() << " description: " << rule.description.data();
qDebug() << " display_order:" << rule.display_order;
qDebug() << " status: " << (int)rule.status;
qDebug() << " ------------------------------";
qDebug() << " Features:";
for (const auto& feature : rule.features) {
qDebug() << " " << feature.name.data();
qDebug() << " " << feature.description.data();
qDebug() << " " << (int)feature.status;
qDebug() << " name: " << feature.name.data();
qDebug() << " description:" << feature.description.data();
qDebug() << " status: " << (int)feature.status;
qDebug() << " type: " << (int)feature.type;
qDebug() << " measurement:" << (int)feature.measurement;
qDebug() << " unit: " << (int)feature.unit;
}
}
*/
...
...
@@ -241,17 +308,3 @@ AirMapRulesetsManager::_selectedChanged()
emit
selectedRuleSetsChanged
();
//-- TODO: Do whatever it is you do to select a rule
}
//-----------------------------------------------------------------------------
QStringList
AirMapRulesetsManager
::
rulesetsIDs
()
{
QStringList
list
;
for
(
int
i
=
0
;
i
<
_ruleSets
.
count
();
i
++
)
{
AirMapRuleSet
*
rule
=
qobject_cast
<
AirMapRuleSet
*>
(
_ruleSets
.
get
(
i
));
if
(
rule
&&
rule
->
selected
())
{
list
<<
rule
->
id
();
}
}
return
list
;
}
src/Airmap/AirMapRulesetsManager.h
View file @
60bc4330
...
...
@@ -39,7 +39,7 @@ public:
QString
name
()
override
{
return
QString
::
fromStdString
(
_feature
.
name
);
}
QString
description
()
override
{
return
QString
::
fromStdString
(
_feature
.
description
);
}
QVariant
value
()
override
{
return
_value
;
}
void
setValue
(
const
QVariant
val
)
override
{
_value
=
val
;
emit
valueChanged
();
}
void
setValue
(
const
QVariant
val
)
override
;
private:
airmap
::
RuleSet
::
Feature
_feature
;
QVariant
_value
;
...
...
@@ -49,6 +49,7 @@ private:
class
AirMapRule
:
public
AirspaceRule
{
Q_OBJECT
friend
class
AirMapRulesetsManager
;
public:
AirMapRule
(
QObject
*
parent
=
NULL
);
...
...
@@ -82,7 +83,7 @@ public:
QString
shortName
()
override
{
return
_shortName
;
}
SelectionType
selectionType
()
override
{
return
_selectionType
;
}
bool
selected
()
override
{
return
_selected
;
}
void
setSelected
(
bool
sel
)
override
{
_selected
=
sel
;
emit
selectedChanged
();
}
void
setSelected
(
bool
sel
)
override
;
QmlObjectListModel
*
rules
()
override
{
return
&
_rules
;
}
private:
QString
_id
;
...
...
@@ -104,14 +105,10 @@ public:
bool
valid
()
override
{
return
_valid
;
}
QmlObjectListModel
*
ruleSets
()
override
{
return
&
_ruleSets
;
}
QmlObjectListModel
*
features
()
override
{
return
&
_features
;
}
QString
selectedRuleSets
()
override
;
void
setROI
(
const
QGeoCoordinate
&
center
)
override
;
//-- Selected rules
QStringList
rulesetsIDs
();
signals:
void
error
(
const
QString
&
what
,
const
QString
&
airmapdMessage
,
const
QString
&
airmapdDetails
);
...
...
@@ -127,8 +124,6 @@ private:
State
_state
=
State
::
Idle
;
AirMapSharedState
&
_shared
;
QmlObjectListModel
_ruleSets
;
//-- TODO: Connect to AirMapRuleSet::selectedChanged and rebuild features based on it.
QmlObjectListModel
_features
;
};
src/AirspaceManagement/AirspaceRulesetsProvider.h
View file @
60bc4330
...
...
@@ -153,11 +153,9 @@ public:
Q_PROPERTY
(
bool
valid
READ
valid
NOTIFY
ruleSetsChanged
)
Q_PROPERTY
(
QString
selectedRuleSets
READ
selectedRuleSets
NOTIFY
selectedRuleSetsChanged
)
Q_PROPERTY
(
QmlObjectListModel
*
ruleSets
READ
ruleSets
NOTIFY
ruleSetsChanged
)
Q_PROPERTY
(
QmlObjectListModel
*
features
READ
features
NOTIFY
ruleSetsChanged
)
virtual
bool
valid
()
=
0
;
///< Current ruleset is valid
virtual
QmlObjectListModel
*
ruleSets
()
=
0
;
///< List of AirspaceRuleSet
virtual
QmlObjectListModel
*
features
()
=
0
;
///< List of AirspaceRuleFeature (Aggregate of all features of selected rulesets)
virtual
QString
selectedRuleSets
()
=
0
;
///< All selected rules concatenated into a string
/**
* Set region of interest that should be queried. When finished, the rulesChanged() signal will be emmited.
...
...
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