Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
b98f08d7
Commit
b98f08d7
authored
Nov 10, 2017
by
Beat Küng
Browse files
AirMapManager: handle multi_polygon
parent
44a05ab6
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/MissionManager/AirMapManager.cc
View file @
b98f08d7
...
@@ -162,36 +162,21 @@ void AirMapRestrictionManager::setROI(const QGeoCoordinate& center, double radiu
...
@@ -162,36 +162,21 @@ void AirMapRestrictionManager::setROI(const QGeoCoordinate& center, double radiu
if
(
result
)
{
if
(
result
)
{
const
std
::
vector
<
Airspace
>&
airspaces
=
result
.
value
();
const
std
::
vector
<
Airspace
>&
airspaces
=
result
.
value
();
qCDebug
(
AirMapManagerLog
)
<<
"Successful search:
"
<<
airspaces
.
size
();
qCDebug
(
AirMapManagerLog
)
<<
"Successful search
. Items
:"
<<
airspaces
.
size
();
for
(
const
auto
&
airspace
:
airspaces
)
{
for
(
const
auto
&
airspace
:
airspaces
)
{
const
Geometry
&
geometry
=
airspace
.
geometry
();
const
Geometry
&
geometry
=
airspace
.
geometry
();
switch
(
geometry
.
type
())
{
switch
(
geometry
.
type
())
{
case
Geometry
::
Type
::
polygon
:
{
case
Geometry
::
Type
::
polygon
:
{
const
Geometry
::
Polygon
&
polygon
=
geometry
.
details_for_polygon
();
const
Geometry
::
Polygon
&
polygon
=
geometry
.
details_for_polygon
();
QVariantList
polygonArray
;
_addPolygonToList
(
polygon
,
_polygonList
);
if
(
polygon
.
size
()
==
1
)
{
for
(
const
auto
&
vertex
:
polygon
[
0
].
coordinates
)
{
QGeoCoordinate
coord
;
if
(
vertex
.
altitude
)
{
coord
=
QGeoCoordinate
(
vertex
.
latitude
,
vertex
.
longitude
,
vertex
.
altitude
.
get
());
}
else
{
coord
=
QGeoCoordinate
(
vertex
.
latitude
,
vertex
.
longitude
);
}
polygonArray
.
append
(
QVariant
::
fromValue
(
coord
));
}
_polygonList
.
append
(
new
PolygonAirspaceRestriction
(
polygonArray
));
}
else
{
// TODO: support that?
qWarning
()
<<
"Empty polygon, or Polygon with holes. Size: "
<<
polygon
.
size
();
}
}
}
break
;
break
;
case
Geometry
::
Type
::
multi_polygon
:
{
case
Geometry
::
Type
::
multi_polygon
:
{
const
Geometry
::
MultiPolygon
&
multiPolygon
=
geometry
.
details_for_multi_polygon
();
const
Geometry
::
MultiPolygon
&
multiPolygon
=
geometry
.
details_for_multi_polygon
();
qWarning
()
<<
"multi polygon "
<<
multiPolygon
.
size
();
for
(
const
auto
&
polygon
:
multiPolygon
)
{
// TODO
_addPolygonToList
(
polygon
,
_polygonList
);
}
}
}
break
;
break
;
case
Geometry
::
Type
::
point
:
{
case
Geometry
::
Type
::
point
:
{
...
@@ -220,6 +205,27 @@ void AirMapRestrictionManager::setROI(const QGeoCoordinate& center, double radiu
...
@@ -220,6 +205,27 @@ void AirMapRestrictionManager::setROI(const QGeoCoordinate& center, double radiu
});
});
}
}
void
AirMapRestrictionManager
::
_addPolygonToList
(
const
airmap
::
Geometry
::
Polygon
&
polygon
,
QList
<
PolygonAirspaceRestriction
*>&
list
)
{
QVariantList
polygonArray
;
if
(
polygon
.
size
()
==
1
)
{
for
(
const
auto
&
vertex
:
polygon
[
0
].
coordinates
)
{
QGeoCoordinate
coord
;
if
(
vertex
.
altitude
)
{
coord
=
QGeoCoordinate
(
vertex
.
latitude
,
vertex
.
longitude
,
vertex
.
altitude
.
get
());
}
else
{
coord
=
QGeoCoordinate
(
vertex
.
latitude
,
vertex
.
longitude
);
}
polygonArray
.
append
(
QVariant
::
fromValue
(
coord
));
}
list
.
append
(
new
PolygonAirspaceRestriction
(
polygonArray
));
}
else
{
// TODO: support that?
qWarning
()
<<
"Empty polygon, or Polygon with holes. Size: "
<<
polygon
.
size
();
}
}
AirMapFlightManager
::
AirMapFlightManager
(
AirMapSharedState
&
shared
)
AirMapFlightManager
::
AirMapFlightManager
(
AirMapSharedState
&
shared
)
:
_shared
(
shared
)
:
_shared
(
shared
)
{
{
...
...
src/MissionManager/AirMapManager.h
View file @
b98f08d7
...
@@ -109,6 +109,8 @@ signals:
...
@@ -109,6 +109,8 @@ signals:
private:
private:
static
void
_addPolygonToList
(
const
airmap
::
Geometry
::
Polygon
&
polygon
,
QList
<
PolygonAirspaceRestriction
*>&
list
);
enum
class
State
{
enum
class
State
{
Idle
,
Idle
,
RetrieveItems
,
RetrieveItems
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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