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
24f8cd47
Commit
24f8cd47
authored
Mar 17, 2018
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restructure for TerrainQueryInterface base class
parent
bf202aac
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
231 additions
and
151 deletions
+231
-151
TransectStyleComplexItem.cc
src/MissionManager/TransectStyleComplexItem.cc
+2
-2
VisualMissionItem.cc
src/MissionManager/VisualMissionItem.cc
+2
-2
VisualMissionItem.h
src/MissionManager/VisualMissionItem.h
+1
-1
TerrainQuery.cc
src/Terrain/TerrainQuery.cc
+161
-116
TerrainQuery.h
src/Terrain/TerrainQuery.h
+65
-30
No files found.
src/MissionManager/TransectStyleComplexItem.cc
View file @
24f8cd47
...
...
@@ -374,7 +374,7 @@ void TransectStyleComplexItem::_adjustTransectPointsForTerrain(void)
bool
surveyEdgeIndicator
=
transectPoint
.
altitude
()
==
_surveyEdgeIndicator
;
if
(
_followTerrain
)
{
transectPoint
.
setAltitude
(
_transectsPathHeightInfo
[
i
].
rgHeight
[
0
]
+
altitude
);
transectPoint
.
setAltitude
(
_transectsPathHeightInfo
[
i
].
heights
[
0
]
+
altitude
);
}
else
{
transectPoint
.
setAltitude
(
altitude
);
}
...
...
@@ -390,7 +390,7 @@ void TransectStyleComplexItem::_adjustTransectPointsForTerrain(void)
QGeoCoordinate
transectPoint
=
_transectPoints
.
last
().
value
<
QGeoCoordinate
>
();
bool
surveyEdgeIndicator
=
transectPoint
.
altitude
()
==
_surveyEdgeIndicator
;
if
(
_followTerrain
){
transectPoint
.
setAltitude
(
_transectsPathHeightInfo
.
last
().
rgHeight
.
last
()
+
altitude
);
transectPoint
.
setAltitude
(
_transectsPathHeightInfo
.
last
().
heights
.
last
()
+
altitude
);
}
else
{
transectPoint
.
setAltitude
(
altitude
);
}
...
...
src/MissionManager/VisualMissionItem.cc
View file @
24f8cd47
...
...
@@ -180,10 +180,10 @@ void VisualMissionItem::_reallyUpdateTerrainAltitude(void)
}
}
void
VisualMissionItem
::
_terrainDataReceived
(
bool
success
,
QList
<
float
>
altitude
s
)
void
VisualMissionItem
::
_terrainDataReceived
(
bool
success
,
QList
<
double
>
height
s
)
{
if
(
success
)
{
_terrainAltitude
=
altitude
s
[
0
];
_terrainAltitude
=
height
s
[
0
];
emit
terrainAltitudeChanged
(
_terrainAltitude
);
sender
()
->
deleteLater
();
}
...
...
src/MissionManager/VisualMissionItem.h
View file @
24f8cd47
...
...
@@ -211,7 +211,7 @@ protected:
private
slots
:
void
_updateTerrainAltitude
(
void
);
void
_reallyUpdateTerrainAltitude
(
void
);
void
_terrainDataReceived
(
bool
success
,
QList
<
float
>
altitude
s
);
void
_terrainDataReceived
(
bool
success
,
QList
<
double
>
height
s
);
private:
QTimer
_updateTerrainTimer
;
...
...
src/Terrain/TerrainQuery.cc
View file @
24f8cd47
This diff is collapsed.
Click to expand it.
src/Terrain/TerrainQuery.h
View file @
24f8cd47
...
...
@@ -21,31 +21,71 @@ Q_DECLARE_LOGGING_CATEGORY(TerrainQueryLog)
class
TerrainAtCoordinateQuery
;
// Base class for all terrain query objects
class
TerrainQuery
:
public
QObject
{
/// Base class for offline/online terrain queries
class
TerrainQueryInterface
:
public
QObject
{
Q_OBJECT
public:
TerrainQuery
(
QObject
*
parent
=
NULL
);
TerrainQueryInterface
(
QObject
*
parent
)
:
QObject
(
parent
)
{
}
/// Request terrain heights for specified coodinates.
/// Signals: coordinateHeights when data is available
virtual
void
requestCoordinateHeights
(
const
QList
<
QGeoCoordinate
>&
coordinates
)
=
0
;
/// Requests terrain heights along the path specified by the two coordinates.
/// Signals: pathHeights
/// @param coordinates to query
virtual
void
requestPathHeights
(
const
QGeoCoordinate
&
fromCoord
,
const
QGeoCoordinate
&
toCoord
)
=
0
;
/// Request terrain heights for the rectangular area specified.
/// Signals: carpetHeights when data is available
/// @param swCoord South-West bound of rectangular area to query
/// @param neCoord North-East bound of rectangular area to query
/// @param statsOnly true: Return only stats, no carpet data
virtual
void
requestCarpetHeights
(
const
QGeoCoordinate
&
swCoord
,
const
QGeoCoordinate
&
neCoord
,
bool
statsOnly
)
=
0
;
signals:
void
coordinateHeights
(
bool
success
,
QList
<
double
>
heights
);
void
pathHeights
(
bool
success
,
double
latStep
,
double
lonStep
,
const
QList
<
double
>&
heights
);
void
carpetHeights
(
bool
success
,
double
minHeight
,
double
maxHeight
,
const
QList
<
QList
<
double
>>&
carpet
);
};
protected:
// Send a query to AirMap terrain servers. Data and errors are returned back from super class virtual implementations.
// @param path Additional path to add to url
// @param urlQuery Query to send
void
_sendQuery
(
const
QString
&
path
,
const
QUrlQuery
&
urlQuery
);
/// AirMap online implementation of terrain queries
class
TerrainAirMapQuery
:
public
TerrainQueryInterface
{
Q_OBJECT
public:
TerrainAirMapQuery
(
QObject
*
parent
=
NULL
);
// Called when the request to the server fails or succeeds
virtual
void
_terrainData
(
bool
success
,
const
QJsonValue
&
dataJsonValue
)
=
0
;
// Overrides from TerrainQueryInterface
void
requestCoordinateHeights
(
const
QList
<
QGeoCoordinate
>&
coordinates
)
final
;
void
requestPathHeights
(
const
QGeoCoordinate
&
fromCoord
,
const
QGeoCoordinate
&
toCoord
)
final
;
void
requestCarpetHeights
(
const
QGeoCoordinate
&
swCoord
,
const
QGeoCoordinate
&
neCoord
,
bool
statsOnly
)
final
;
private
slots
:
void
_requestFinished
(
void
);
private:
QNetworkAccessManager
_networkManager
;
void
_sendQuery
(
const
QString
&
path
,
const
QUrlQuery
&
urlQuery
);
void
_requestFailed
(
void
);
void
_parseCoordinateData
(
const
QJsonValue
&
coordinateJson
);
void
_parsePathData
(
const
QJsonValue
&
pathJson
);
void
_parseCarpetData
(
const
QJsonValue
&
carpetJson
);
enum
QueryMode
{
QueryModeCoordinates
,
QueryModePath
,
QueryModeCarpet
};
QNetworkAccessManager
_networkManager
;
QueryMode
_queryMode
;
bool
_carpetStatsOnly
;
};
/// Used internally by TerrainAtCoordinateQuery to batch coordinate requests together
class
TerrainAtCoordinateBatchManager
:
public
TerrainQuery
{
class
TerrainAtCoordinateBatchManager
:
public
QObject
{
Q_OBJECT
public:
...
...
@@ -53,13 +93,10 @@ public:
void
addQuery
(
TerrainAtCoordinateQuery
*
terrainAtCoordinateQuery
,
const
QList
<
QGeoCoordinate
>&
coordinates
);
protected:
// Overrides from TerrainQuery
void
_terrainData
(
bool
success
,
const
QJsonValue
&
dataJsonValue
)
final
;
private
slots
:
void
_sendNextBatch
(
void
);
void
_queryObjectDestroyed
(
QObject
*
elevationProvider
);
void
_coordinateHeights
(
bool
success
,
QList
<
double
>
heights
);
private:
typedef
struct
{
...
...
@@ -87,6 +124,7 @@ private:
State
_state
=
State
::
Idle
;
const
int
_batchTimeout
=
500
;
QTimer
_batchTimer
;
TerrainAirMapQuery
_terrainQuery
;
};
/// NOTE: TerrainAtCoordinateQuery is not thread safe. All instances/calls to ElevationProvider must be on main thread.
...
...
@@ -102,13 +140,13 @@ public:
void
requestData
(
const
QList
<
QGeoCoordinate
>&
coordinates
);
// Internal method
void
_signalTerrainData
(
bool
success
,
QList
<
float
>&
altitude
s
);
void
_signalTerrainData
(
bool
success
,
QList
<
double
>&
height
s
);
signals:
void
terrainData
(
bool
success
,
QList
<
float
>
altitude
s
);
void
terrainData
(
bool
success
,
QList
<
double
>
height
s
);
};
class
TerrainPathQuery
:
public
TerrainQuery
class
TerrainPathQuery
:
public
QObject
{
Q_OBJECT
...
...
@@ -123,16 +161,18 @@ public:
typedef
struct
{
double
latStep
;
///< Amount of latitudinal distance between each returned height
double
lonStep
;
///< Amount of longitudinal distance between each returned height
QList
<
double
>
rgHeight
;
///< Terrain heights along path
QList
<
double
>
heights
;
///< Terrain heights along path
}
PathHeightInfo_t
;
signals:
/// Signalled when terrain data comes back from server
void
terrainData
(
bool
success
,
const
PathHeightInfo_t
&
pathHeightInfo
);
protected:
// Overrides from TerrainQuery
void
_terrainData
(
bool
success
,
const
QJsonValue
&
dataJsonValue
)
final
;
private
slots
:
void
_pathHeights
(
bool
success
,
double
latStep
,
double
lonStep
,
const
QList
<
double
>&
heights
);
private:
TerrainAirMapQuery
_terrainQuery
;
};
Q_DECLARE_METATYPE
(
TerrainPathQuery
::
PathHeightInfo_t
)
...
...
@@ -165,7 +205,7 @@ private:
};
class
TerrainCarpetQuery
:
public
TerrainQuery
class
TerrainCarpetQuery
:
public
QObject
{
Q_OBJECT
...
...
@@ -183,12 +223,7 @@ signals:
/// Signalled when terrain data comes back from server
void
terrainData
(
bool
success
,
double
minHeight
,
double
maxHeight
,
const
QList
<
QList
<
double
>>&
carpet
);
protected:
// Overrides from TerrainQuery
void
_terrainData
(
bool
success
,
const
QJsonValue
&
dataJsonValue
)
final
;
private:
bool
_statsOnl
y
;
TerrainAirMapQuery
_terrainQuer
y
;
};
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