Skip to content

Commit

Permalink
fix get point properties
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomei committed Aug 20, 2024
1 parent 8506815 commit 4410284
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
25 changes: 15 additions & 10 deletions dbMeteoPoints/download.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ DbArkimet* Download::getDbArkimet()
return _dbMeteo;
}

bool Download::getPointProperties(QList<QString> datasetList)
{

bool Download::getPointProperties(const QList<QString> &datasetList, QString &errorString)
{
bool result = true;
QEventLoop loop;

Expand All @@ -43,7 +43,7 @@ bool Download::getPointProperties(QList<QString> datasetList)

if (reply->error() != QNetworkReply::NoError)
{
qDebug() << "Network Error: " << reply->error();
errorString = "Network Error: " + reply->errorString();
result = false;
}
else
Expand All @@ -56,7 +56,12 @@ bool Download::getPointProperties(QList<QString> 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();

Expand All @@ -68,28 +73,28 @@ bool Download::getPointProperties(QList<QString> 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;
delete manager;
return result;
}


QMap<QString, QString> Download::getArmiketIdList(QList<QString> datasetList)
{

Expand Down
2 changes: 1 addition & 1 deletion dbMeteoPoints/download.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
explicit Download(QString dbName, QObject* parent = nullptr);
~Download();

bool getPointProperties(QList<QString> datasetList);
bool getPointProperties(const QList<QString> &datasetList, QString &errorString);
bool getPointPropertiesFromId(QString id, Crit3DMeteoPoint* pointProp);
QMap<QString,QString> getArmiketIdList(QList<QString> datasetList);
void downloadMetadata(QJsonObject obj);
Expand Down

0 comments on commit 4410284

Please sign in to comment.