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
ac9fbc8a
Commit
ac9fbc8a
authored
Mar 21, 2018
by
Andreas Bircher
Browse files
remove deadlock and enable path queries
parent
f01cd04c
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/Terrain/TerrainQuery.cc
View file @
ac9fbc8a
...
...
@@ -237,12 +237,16 @@ void TerrainOfflineAirMapQuery::requestCoordinateHeights(const QList<QGeoCoordin
void
TerrainOfflineAirMapQuery
::
requestPathHeights
(
const
QGeoCoordinate
&
fromCoord
,
const
QGeoCoordinate
&
toCoord
)
{
// TODO
_terrainTileManager
->
addPathQuery
(
this
,
fromCoord
,
toCoord
);
}
void
TerrainOfflineAirMapQuery
::
requestCarpetHeights
(
const
QGeoCoordinate
&
swCoord
,
const
QGeoCoordinate
&
neCoord
,
bool
statsOnly
)
{
// TODO
Q_UNUSED
(
swCoord
);
Q_UNUSED
(
neCoord
);
Q_UNUSED
(
statsOnly
);
qWarning
()
<<
"Carpet queries are currently not supported from offline air map data"
;
}
void
TerrainOfflineAirMapQuery
::
_signalCoordinateHeights
(
bool
success
,
QList
<
double
>
heights
)
...
...
@@ -252,12 +256,12 @@ void TerrainOfflineAirMapQuery::_signalCoordinateHeights(bool success, QList<dou
void
TerrainOfflineAirMapQuery
::
_signalPathHeights
(
bool
success
,
double
latStep
,
double
lonStep
,
const
QList
<
double
>&
heights
)
{
// TODO
emit
pathHeights
(
success
,
latStep
,
lonStep
,
heights
);
}
void
TerrainOfflineAirMapQuery
::
_signalCarpetHeights
(
bool
success
,
double
minHeight
,
double
maxHeight
,
const
QList
<
QList
<
double
>>&
carpet
)
{
// TODO
emit
carpetHeights
(
success
,
minHeight
,
maxHeight
,
carpet
);
}
TerrainTileManager
::
TerrainTileManager
(
void
)
...
...
@@ -271,7 +275,7 @@ void TerrainTileManager::addCoordinateQuery(TerrainOfflineAirMapQuery* terrainQu
QList
<
double
>
altitudes
;
if
(
!
_getAltitudesForCoordinates
(
coordinates
,
altitudes
))
{
QueuedRequestInfo_t
queuedRequestInfo
=
{
terrainQueryInterface
,
coordinates
,
QueryMode
::
QueryModeCoordinates
};
QueuedRequestInfo_t
queuedRequestInfo
=
{
terrainQueryInterface
,
QueryMode
::
QueryModeCoordinates
,
coordinates
};
_requestQueue
.
append
(
queuedRequestInfo
);
return
;
}
...
...
@@ -281,6 +285,35 @@ void TerrainTileManager::addCoordinateQuery(TerrainOfflineAirMapQuery* terrainQu
}
}
void
TerrainTileManager
::
addPathQuery
(
TerrainOfflineAirMapQuery
*
terrainQueryInterface
,
const
QGeoCoordinate
&
startPoint
,
const
QGeoCoordinate
&
endPoint
)
{
QList
<
QGeoCoordinate
>
coordinates
;
double
lat
=
startPoint
.
latitude
();
double
lon
=
startPoint
.
longitude
();
double
latDiff
=
endPoint
.
latitude
()
-
lat
;
double
lonDiff
=
endPoint
.
longitude
()
-
lon
;
double
steps
=
ceil
(
endPoint
.
distanceTo
(
startPoint
)
/
TerrainTile
::
terrainAltitudeSpacing
);
for
(
double
i
=
0.0
;
i
<=
steps
;
i
=
i
+
1
)
{
coordinates
.
append
(
QGeoCoordinate
(
lat
+
latDiff
*
i
/
steps
,
lon
+
lonDiff
*
i
/
steps
));
}
QList
<
double
>
altitudes
;
if
(
!
_getAltitudesForCoordinates
(
coordinates
,
altitudes
))
{
QueuedRequestInfo_t
queuedRequestInfo
=
{
terrainQueryInterface
,
QueryMode
::
QueryModePath
,
coordinates
};
_requestQueue
.
append
(
queuedRequestInfo
);
return
;
}
qCDebug
(
TerrainQueryLog
)
<<
"All altitudes taken from cached data"
;
double
stepLat
=
0
;
double
stepLon
=
0
;
if
(
coordinates
.
count
()
>
1
)
{
stepLat
=
coordinates
[
1
].
latitude
()
-
coordinates
[
0
].
latitude
();
stepLon
=
coordinates
[
1
].
longitude
()
-
coordinates
[
0
].
longitude
();
}
terrainQueryInterface
->
_signalPathHeights
(
coordinates
.
count
()
==
altitudes
.
count
(),
stepLat
,
stepLon
,
altitudes
);
}
bool
TerrainTileManager
::
_getAltitudesForCoordinates
(
const
QList
<
QGeoCoordinate
>&
coordinates
,
QList
<
double
>&
altitudes
)
{
foreach
(
const
QGeoCoordinate
&
coordinate
,
coordinates
)
{
...
...
@@ -457,8 +490,8 @@ void TerrainAtCoordinateBatchManager::_sendNextBatch(void)
}
_requestQueue
.
clear
();
_terrainQuery
.
requestCoordinateHeights
(
coords
);
_state
=
State
::
Downloading
;
_terrainQuery
.
requestCoordinateHeights
(
coords
);
}
void
TerrainAtCoordinateBatchManager
::
_batchFailed
(
void
)
...
...
src/Terrain/TerrainQuery.h
View file @
ac9fbc8a
...
...
@@ -114,7 +114,8 @@ class TerrainTileManager : public QObject {
public:
TerrainTileManager
(
void
);
void
addCoordinateQuery
(
TerrainOfflineAirMapQuery
*
terrainQueryInterface
,
const
QList
<
QGeoCoordinate
>&
coordinates
);
void
addCoordinateQuery
(
TerrainOfflineAirMapQuery
*
terrainQueryInterface
,
const
QList
<
QGeoCoordinate
>&
coordinates
);
void
addPathQuery
(
TerrainOfflineAirMapQuery
*
terrainQueryInterface
,
const
QGeoCoordinate
&
startPoint
,
const
QGeoCoordinate
&
endPoint
);
private
slots
:
void
_fetchedTile
(
void
);
/// slot to handle fetched elevation tiles
...
...
@@ -133,8 +134,8 @@ private:
typedef
struct
{
TerrainOfflineAirMapQuery
*
terrainQueryInterface
;
QList
<
QGeoCoordinate
>
coordinates
;
QueryMode
queryMode
;
QList
<
QGeoCoordinate
>
coordinates
;
}
QueuedRequestInfo_t
;
void
_tileFailed
(
void
);
...
...
src/TerrainTile.h
View file @
ac9fbc8a
...
...
@@ -77,6 +77,9 @@ public:
*/
QGeoCoordinate
centerCoordinate
(
void
)
const
;
/// Approximate spacing of the elevation data measurement points
static
constexpr
double
terrainAltitudeSpacing
=
30.0
;
private:
inline
int
_latToDataIndex
(
double
latitude
)
const
;
inline
int
_lonToDataIndex
(
double
longitude
)
const
;
...
...
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