From 4410284d5932e6b2be7d74ff4a3ddd7016d77bc3 Mon Sep 17 00:00:00 2001 From: ftomei Date: Tue, 20 Aug 2024 18:48:26 +0200 Subject: [PATCH] fix get point properties --- dbMeteoPoints/download.cpp | 25 +++++++++++++++---------- dbMeteoPoints/download.h | 2 +- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/dbMeteoPoints/download.cpp b/dbMeteoPoints/download.cpp index 3d8c85e1a..69e9afa48 100644 --- a/dbMeteoPoints/download.cpp +++ b/dbMeteoPoints/download.cpp @@ -21,9 +21,9 @@ DbArkimet* Download::getDbArkimet() return _dbMeteo; } -bool Download::getPointProperties(QList datasetList) -{ +bool Download::getPointProperties(const QList &datasetList, QString &errorString) +{ bool result = true; QEventLoop loop; @@ -43,7 +43,7 @@ bool Download::getPointProperties(QList datasetList) if (reply->error() != QNetworkReply::NoError) { - qDebug() << "Network Error: " << reply->error(); + errorString = "Network Error: " + reply->errorString(); result = false; } else @@ -56,7 +56,12 @@ bool Download::getPointProperties(QList datasetList) qDebug() << "err: " << error->errorString() << " -> " << error->offset; // check validity of the document - if(! doc.isNull() && doc.isArray() ) + if(doc.isNull() || ! doc.isArray()) + { + errorString = "Invalid JSON"; + result = false; + } + else { QJsonArray jsonArr = doc.array(); @@ -68,21 +73,20 @@ bool Download::getPointProperties(QList datasetList) if (jsonDataset.isUndefined()) qDebug() << "jsonDataset: key id does not exist"; - else if (!jsonDataset.isString()) + else if (! jsonDataset.isString()) qDebug() << "jsonDataset: value is not string"; else + { foreach(QString item, _datasetsList) + { if (jsonDataset.toString().toUpper() == item.toUpper()) { this->downloadMetadata(obj); } + } + } } } - else - { - qDebug() << "Invalid JSON...\n"; - result = false; - } } delete reply; @@ -90,6 +94,7 @@ bool Download::getPointProperties(QList datasetList) return result; } + QMap Download::getArmiketIdList(QList datasetList) { diff --git a/dbMeteoPoints/download.h b/dbMeteoPoints/download.h index 06e77bc15..ab04e8acb 100644 --- a/dbMeteoPoints/download.h +++ b/dbMeteoPoints/download.h @@ -12,7 +12,7 @@ explicit Download(QString dbName, QObject* parent = nullptr); ~Download(); - bool getPointProperties(QList datasetList); + bool getPointProperties(const QList &datasetList, QString &errorString); bool getPointPropertiesFromId(QString id, Crit3DMeteoPoint* pointProp); QMap getArmiketIdList(QList datasetList); void downloadMetadata(QJsonObject obj);