Unverified Commit aeae385a authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #6677 from DonLakeFlyer/TerrainPathQuery

Fix: Terrain path query
parents a27bf5cb ab2f8c6b
......@@ -412,7 +412,7 @@ void TransectStyleComplexItem::_reallyQueryTransectsPathHeightInfo(void)
if (transectPoints.count() > 1) {
_terrainPolyPathQuery = new TerrainPolyPathQuery(this);
connect(_terrainPolyPathQuery, &TerrainPolyPathQuery::terrainData, this, &TransectStyleComplexItem::_polyPathTerrainData);
connect(_terrainPolyPathQuery, &TerrainPolyPathQuery::terrainDataReceived, this, &TransectStyleComplexItem::_polyPathTerrainData);
_terrainPolyPathQuery->requestData(transectPoints);
}
}
......
......@@ -186,7 +186,7 @@ void VisualMissionItem::_reallyUpdateTerrainAltitude(void)
_lastLatTerrainQuery = coord.latitude();
_lastLonTerrainQuery = coord.longitude();
TerrainAtCoordinateQuery* terrain = new TerrainAtCoordinateQuery(this);
connect(terrain, &TerrainAtCoordinateQuery::terrainData, this, &VisualMissionItem::_terrainDataReceived);
connect(terrain, &TerrainAtCoordinateQuery::terrainDataReceived, this, &VisualMissionItem::_terrainDataReceived);
QList<QGeoCoordinate> rgCoord;
rgCoord.append(coordinate());
terrain->requestData(rgCoord);
......
......@@ -43,8 +43,22 @@ QGCView {
id: categoryColumn
spacing: ScreenTools.defaultFontPixelHeight / 2
QGCButton {
text: qsTr("Clear All")
onClicked: {
var logCats = QGroundControl.loggingCategories()
for (var i=0; i<logCats.length; i++) {
QGroundControl.setCategoryLoggingOn(logCats[i], false)
}
QGroundControl.updateLoggingFilterRules()
categoryRepeater.model = undefined
categoryRepeater.model = QGroundControl.loggingCategories()
}
}
Repeater {
model: QGroundControl.loggingCategories()
id: categoryRepeater
model: QGroundControl.loggingCategories()
QGCCheckBox {
text: modelData
......
......@@ -41,7 +41,7 @@ TerrainAirMapQuery::TerrainAirMapQuery(QObject* parent)
void TerrainAirMapQuery::requestCoordinateHeights(const QList<QGeoCoordinate>& coordinates)
{
if (qgcApp()->runningUnitTests()) {
emit coordinateHeights(false, QList<double>());
emit coordinateHeightsReceived(false, QList<double>());
return;
}
......@@ -62,7 +62,7 @@ void TerrainAirMapQuery::requestCoordinateHeights(const QList<QGeoCoordinate>& c
void TerrainAirMapQuery::requestPathHeights(const QGeoCoordinate& fromCoord, const QGeoCoordinate& toCoord)
{
if (qgcApp()->runningUnitTests()) {
emit pathHeights(false, qQNaN(), qQNaN(), QList<double>());
emit pathHeightsReceived(false, qQNaN(), qQNaN(), QList<double>());
return;
}
......@@ -82,7 +82,7 @@ void TerrainAirMapQuery::requestPathHeights(const QGeoCoordinate& fromCoord, con
void TerrainAirMapQuery::requestCarpetHeights(const QGeoCoordinate& swCoord, const QGeoCoordinate& neCoord, bool statsOnly)
{
if (qgcApp()->runningUnitTests()) {
emit carpetHeights(false, qQNaN(), qQNaN(), QList<QList<double>>());
emit carpetHeightsReceived(false, qQNaN(), qQNaN(), QList<QList<double>>());
return;
}
......@@ -204,13 +204,13 @@ void TerrainAirMapQuery::_requestFailed(void)
{
switch (_queryMode) {
case QueryModeCoordinates:
emit coordinateHeights(false /* success */, QList<double>() /* heights */);
emit coordinateHeightsReceived(false /* success */, QList<double>() /* heights */);
break;
case QueryModePath:
emit pathHeights(false /* success */, qQNaN() /* latStep */, qQNaN() /* lonStep */, QList<double>() /* heights */);
emit pathHeightsReceived(false /* success */, qQNaN() /* latStep */, qQNaN() /* lonStep */, QList<double>() /* heights */);
break;
case QueryModeCarpet:
emit carpetHeights(false /* success */, qQNaN() /* minHeight */, qQNaN() /* maxHeight */, QList<QList<double>>() /* carpet */);
emit carpetHeightsReceived(false /* success */, qQNaN() /* minHeight */, qQNaN() /* maxHeight */, QList<QList<double>>() /* carpet */);
break;
}
}
......@@ -223,7 +223,7 @@ void TerrainAirMapQuery::_parseCoordinateData(const QJsonValue& coordinateJson)
heights.append(dataArray[i].toDouble());
}
emit coordinateHeights(true /* success */, heights);
emit coordinateHeightsReceived(true /* success */, heights);
}
void TerrainAirMapQuery::_parsePathData(const QJsonValue& pathJson)
......@@ -240,7 +240,7 @@ void TerrainAirMapQuery::_parsePathData(const QJsonValue& pathJson)
heights.append(profileValue.toDouble());
}
emit pathHeights(true /* success */, latStep, lonStep, heights);
emit pathHeightsReceived(true /* success */, latStep, lonStep, heights);
}
void TerrainAirMapQuery::_parseCarpetData(const QJsonValue& carpetJson)
......@@ -266,7 +266,7 @@ void TerrainAirMapQuery::_parseCarpetData(const QJsonValue& carpetJson)
}
}
emit carpetHeights(true /*success*/, minHeight, maxHeight, carpet);
emit carpetHeightsReceived(true /*success*/, minHeight, maxHeight, carpet);
}
TerrainOfflineAirMapQuery::TerrainOfflineAirMapQuery(QObject* parent)
......@@ -278,7 +278,7 @@ TerrainOfflineAirMapQuery::TerrainOfflineAirMapQuery(QObject* parent)
void TerrainOfflineAirMapQuery::requestCoordinateHeights(const QList<QGeoCoordinate>& coordinates)
{
if (qgcApp()->runningUnitTests()) {
emit coordinateHeights(false, QList<double>());
emit coordinateHeightsReceived(false, QList<double>());
return;
}
......@@ -292,7 +292,7 @@ void TerrainOfflineAirMapQuery::requestCoordinateHeights(const QList<QGeoCoordin
void TerrainOfflineAirMapQuery::requestPathHeights(const QGeoCoordinate& fromCoord, const QGeoCoordinate& toCoord)
{
if (qgcApp()->runningUnitTests()) {
emit pathHeights(false, qQNaN(), qQNaN(), QList<double>());
emit pathHeightsReceived(false, qQNaN(), qQNaN(), QList<double>());
return;
}
......@@ -302,7 +302,7 @@ void TerrainOfflineAirMapQuery::requestPathHeights(const QGeoCoordinate& fromCoo
void TerrainOfflineAirMapQuery::requestCarpetHeights(const QGeoCoordinate& swCoord, const QGeoCoordinate& neCoord, bool statsOnly)
{
if (qgcApp()->runningUnitTests()) {
emit carpetHeights(false, qQNaN(), qQNaN(), QList<QList<double>>());
emit carpetHeightsReceived(false, qQNaN(), qQNaN(), QList<QList<double>>());
return;
}
......@@ -315,17 +315,17 @@ void TerrainOfflineAirMapQuery::requestCarpetHeights(const QGeoCoordinate& swCoo
void TerrainOfflineAirMapQuery::_signalCoordinateHeights(bool success, QList<double> heights)
{
emit coordinateHeights(success, heights);
emit coordinateHeightsReceived(success, heights);
}
void TerrainOfflineAirMapQuery::_signalPathHeights(bool success, double latStep, double lonStep, const QList<double>& heights)
{
emit pathHeights(success, latStep, lonStep, heights);
emit pathHeightsReceived(success, latStep, lonStep, heights);
}
void TerrainOfflineAirMapQuery::_signalCarpetHeights(bool success, double minHeight, double maxHeight, const QList<QList<double>>& carpet)
{
emit carpetHeights(success, minHeight, maxHeight, carpet);
emit carpetHeightsReceived(success, minHeight, maxHeight, carpet);
}
TerrainTileManager::TerrainTileManager(void)
......@@ -335,11 +335,13 @@ TerrainTileManager::TerrainTileManager(void)
void TerrainTileManager::addCoordinateQuery(TerrainOfflineAirMapQuery* terrainQueryInterface, const QList<QGeoCoordinate>& coordinates)
{
qCDebug(TerrainQueryLog) << "TerrainTileManager::addCoordinateQuery count" << coordinates.count();
if (coordinates.length() > 0) {
QList<double> altitudes;
if (!_getAltitudesForCoordinates(coordinates, altitudes)) {
QueuedRequestInfo_t queuedRequestInfo = { terrainQueryInterface, QueryMode::QueryModeCoordinates, coordinates };
QueuedRequestInfo_t queuedRequestInfo = { terrainQueryInterface, QueryMode::QueryModeCoordinates, 0, 0, coordinates };
_requestQueue.append(queuedRequestInfo);
return;
}
......@@ -351,31 +353,32 @@ void TerrainTileManager::addCoordinateQuery(TerrainOfflineAirMapQuery* terrainQu
void TerrainTileManager::addPathQuery(TerrainOfflineAirMapQuery* terrainQueryInterface, const QGeoCoordinate &startPoint, const QGeoCoordinate &endPoint)
{
// Convert to individual coordinate queries
QList<QGeoCoordinate> coordinates;
double lat = startPoint.latitude();
double lon = startPoint.longitude();
double steps = ceil(endPoint.distanceTo(startPoint) / TerrainTile::terrainAltitudeSpacing);
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));
}
// We always have one too many and we always want the last one to be the endpoint
coordinates.last() = endPoint;
double latStep = coordinates[1].latitude() - coordinates[0].latitude();
double lonStep = coordinates[1].longitude() - coordinates[0].longitude();
qCDebug(TerrainQueryLog) << "TerrainTileManager::addPathQuery start:end:coordCount" << startPoint << endPoint << coordinates.count();
QList<double> altitudes;
if (!_getAltitudesForCoordinates(coordinates, altitudes)) {
QueuedRequestInfo_t queuedRequestInfo = { terrainQueryInterface, QueryMode::QueryModePath, coordinates };
QueuedRequestInfo_t queuedRequestInfo = { terrainQueryInterface, QueryMode::QueryModePath, latStep, lonStep, 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);
terrainQueryInterface->_signalPathHeights(coordinates.count() == altitudes.count(), latStep, lonStep, altitudes);
}
bool TerrainTileManager::_getAltitudesForCoordinates(const QList<QGeoCoordinate>& coordinates, QList<double>& altitudes)
......@@ -421,6 +424,8 @@ void TerrainTileManager::_tileFailed(void)
foreach (const QueuedRequestInfo_t& requestInfo, _requestQueue) {
if (requestInfo.queryMode == QueryMode::QueryModeCoordinates) {
requestInfo.terrainQueryInterface->_signalCoordinateHeights(false, noAltitudes);
} else if (requestInfo.queryMode == QueryMode::QueryModePath) {
requestInfo.terrainQueryInterface->_signalPathHeights(false, requestInfo.latStep, requestInfo.lonStep, noAltitudes);
}
}
_requestQueue.clear();
......@@ -473,9 +478,13 @@ void TerrainTileManager::_terrainDone(QByteArray responseBytes, QNetworkReply::N
// now try to query the data again
for (int i = _requestQueue.count() - 1; i >= 0; i--) {
QList<double> altitudes;
if (_getAltitudesForCoordinates(_requestQueue[i].coordinates, altitudes)) {
if (_requestQueue[i].queryMode == QueryMode::QueryModeCoordinates) {
_requestQueue[i].terrainQueryInterface->_signalCoordinateHeights(_requestQueue[i].coordinates.count() == altitudes.count(), altitudes);
QueuedRequestInfo_t& requestInfo = _requestQueue[i];
if (_getAltitudesForCoordinates(requestInfo.coordinates, altitudes)) {
if (requestInfo.queryMode == QueryMode::QueryModeCoordinates) {
requestInfo.terrainQueryInterface->_signalCoordinateHeights(requestInfo.coordinates.count() == altitudes.count(), altitudes);
} else if (requestInfo.queryMode == QueryMode::QueryModePath) {
requestInfo.terrainQueryInterface->_signalPathHeights(requestInfo.coordinates.count() == altitudes.count(), requestInfo.latStep, requestInfo.lonStep, altitudes);
}
_requestQueue.removeAt(i);
}
......@@ -495,7 +504,7 @@ TerrainAtCoordinateBatchManager::TerrainAtCoordinateBatchManager(void)
_batchTimer.setSingleShot(true);
_batchTimer.setInterval(_batchTimeout);
connect(&_batchTimer, &QTimer::timeout, this, &TerrainAtCoordinateBatchManager::_sendNextBatch);
connect(&_terrainQuery, &TerrainQueryInterface::coordinateHeights, this, &TerrainAtCoordinateBatchManager::_coordinateHeights);
connect(&_terrainQuery, &TerrainQueryInterface::coordinateHeightsReceived, this, &TerrainAtCoordinateBatchManager::_coordinateHeights);
}
void TerrainAtCoordinateBatchManager::addQuery(TerrainAtCoordinateQuery* terrainAtCoordinateQuery, const QList<QGeoCoordinate>& coordinates)
......@@ -512,7 +521,7 @@ void TerrainAtCoordinateBatchManager::addQuery(TerrainAtCoordinateQuery* terrain
void TerrainAtCoordinateBatchManager::_sendNextBatch(void)
{
qCDebug(TerrainQueryLog) << "_sendNextBatch _state:_requestQueue.count:_sentRequests.count" << _stateToString(_state) << _requestQueue.count() << _sentRequests.count();
qCDebug(TerrainQueryLog) << "TerrainAtCoordinateBatchManager::_sendNextBatch _state:_requestQueue.count:_sentRequests.count" << _stateToString(_state) << _requestQueue.count() << _sentRequests.count();
if (_state != State::Idle) {
// Waiting for last download the complete, wait some more
......@@ -540,7 +549,7 @@ void TerrainAtCoordinateBatchManager::_sendNextBatch(void)
}
}
_requestQueue = _requestQueue.mid(requestQueueAdded);
qCDebug(TerrainQueryLog) << "TerrainAtCoordinateBatchManager::_sendNextBatch - batch count:request queue count" << coords.count() << _requestQueue.count();
qCDebug(TerrainQueryLog) << "_sendNextBatch - batch count:request queue count" << coords.count() << _requestQueue.count();
_state = State::Downloading;
_terrainQuery.requestCoordinateHeights(coords);
......@@ -601,7 +610,7 @@ void TerrainAtCoordinateBatchManager::_coordinateHeights(bool success, QList<dou
{
_state = State::Idle;
qCDebug(TerrainQueryLog) << "_coordinateHeights success:count" << success << heights.count();
qCDebug(TerrainQueryLog) << "TerrainAtCoordinateBatchManager::_coordinateHeights success:count" << success << heights.count();
if (!success) {
_batchFailed();
......@@ -641,14 +650,14 @@ void TerrainAtCoordinateQuery::requestData(const QList<QGeoCoordinate>& coordina
void TerrainAtCoordinateQuery::_signalTerrainData(bool success, QList<double>& heights)
{
emit terrainData(success, heights);
emit terrainDataReceived(success, heights);
}
TerrainPathQuery::TerrainPathQuery(QObject* parent)
: QObject(parent)
{
qRegisterMetaType<PathHeightInfo_t>();
connect(&_terrainQuery, &TerrainQueryInterface::pathHeights, this, &TerrainPathQuery::_pathHeights);
connect(&_terrainQuery, &TerrainQueryInterface::pathHeightsReceived, this, &TerrainPathQuery::_pathHeights);
}
void TerrainPathQuery::requestData(const QGeoCoordinate& fromCoord, const QGeoCoordinate& toCoord)
......@@ -662,14 +671,14 @@ void TerrainPathQuery::_pathHeights(bool success, double latStep, double lonStep
pathHeightInfo.latStep = latStep;
pathHeightInfo.lonStep = lonStep;
pathHeightInfo.heights = heights;
emit terrainData(success, pathHeightInfo);
emit terrainDataReceived(success, pathHeightInfo);
}
TerrainPolyPathQuery::TerrainPolyPathQuery(QObject* parent)
: QObject (parent)
, _curIndex (0)
{
connect(&_pathQuery, &TerrainPathQuery::terrainData, this, &TerrainPolyPathQuery::_terrainDataReceived);
connect(&_pathQuery, &TerrainPathQuery::terrainDataReceived, this, &TerrainPolyPathQuery::_terrainDataReceived);
}
void TerrainPolyPathQuery::requestData(const QVariantList& polyPath)
......@@ -699,7 +708,7 @@ void TerrainPolyPathQuery::_terrainDataReceived(bool success, const TerrainPathQ
if (!success) {
_rgPathHeightInfo.clear();
emit terrainData(false /* success */, _rgPathHeightInfo);
emit terrainDataReceived(false /* success */, _rgPathHeightInfo);
return;
}
......@@ -708,7 +717,7 @@ void TerrainPolyPathQuery::_terrainDataReceived(bool success, const TerrainPathQ
if (++_curIndex >= _rgCoords.count() - 1) {
// We've finished all requests
qCDebug(TerrainQueryLog) << "TerrainPolyPathQuery::_terrainDataReceived complete";
emit terrainData(true /* success */, _rgPathHeightInfo);
emit terrainDataReceived(true /* success */, _rgPathHeightInfo);
} else {
_pathQuery.requestData(_rgCoords[_curIndex], _rgCoords[_curIndex+1]);
}
......@@ -717,7 +726,7 @@ void TerrainPolyPathQuery::_terrainDataReceived(bool success, const TerrainPathQ
TerrainCarpetQuery::TerrainCarpetQuery(QObject* parent)
: QObject(parent)
{
connect(&_terrainQuery, &TerrainQueryInterface::carpetHeights, this, &TerrainCarpetQuery::terrainData);
connect(&_terrainQuery, &TerrainQueryInterface::carpetHeightsReceived, this, &TerrainCarpetQuery::terrainDataReceived);
}
void TerrainCarpetQuery::requestData(const QGeoCoordinate& swCoord, const QGeoCoordinate& neCoord, bool statsOnly)
......
......@@ -50,9 +50,9 @@ public:
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);
void coordinateHeightsReceived(bool success, QList<double> heights);
void pathHeightsReceived(bool success, double latStep, double lonStep, const QList<double>& heights);
void carpetHeightsReceived(bool success, double minHeight, double maxHeight, const QList<QList<double>>& carpet);
};
/// AirMap online implementation of terrain queries
......@@ -136,6 +136,7 @@ private:
typedef struct {
TerrainOfflineAirMapQuery* terrainQueryInterface;
QueryMode queryMode;
double latStep, lonStep;
QList<QGeoCoordinate> coordinates;
} QueuedRequestInfo_t;
......@@ -210,7 +211,7 @@ public:
void _signalTerrainData(bool success, QList<double>& heights);
signals:
void terrainData(bool success, QList<double> heights);
void terrainDataReceived(bool success, QList<double> heights);
};
class TerrainPathQuery : public QObject
......@@ -233,7 +234,7 @@ public:
signals:
/// Signalled when terrain data comes back from server
void terrainData(bool success, const PathHeightInfo_t& pathHeightInfo);
void terrainDataReceived(bool success, const PathHeightInfo_t& pathHeightInfo);
private slots:
void _pathHeights(bool success, double latStep, double lonStep, const QList<double>& heights);
......@@ -259,7 +260,7 @@ public:
signals:
/// Signalled when terrain data comes back from server
void terrainData(bool success, const QList<TerrainPathQuery::PathHeightInfo_t>& rgPathHeightInfo);
void terrainDataReceived(bool success, const QList<TerrainPathQuery::PathHeightInfo_t>& rgPathHeightInfo);
private slots:
void _terrainDataReceived(bool success, const TerrainPathQuery::PathHeightInfo_t& pathHeightInfo);
......@@ -288,7 +289,7 @@ public:
signals:
/// Signalled when terrain data comes back from server
void terrainData(bool success, double minHeight, double maxHeight, const QList<QList<double>>& carpet);
void terrainDataReceived(bool success, double minHeight, double maxHeight, const QList<QList<double>>& carpet);
private:
TerrainAirMapQuery _terrainQuery;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment