Skip to content

Commit

Permalink
Merge commit '6ff14d39316c60b94a691fd88078d091ed3d5978'
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomei committed Nov 27, 2023
2 parents 936f501 + 6ff14d3 commit 0debc99
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 69 deletions.
62 changes: 25 additions & 37 deletions agrolib/pragaProject/dialogMeteoComputation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,16 +492,13 @@ DialogMeteoComputation::DialogMeteoComputation(QSettings *settings, bool isMeteo
}
}


show();
exec();

}


void DialogMeteoComputation::done(bool res)
{

if(res) // ok was pressed
{
if ( (!saveClima && !checkValidData()) || (saveClima && saveClimaLayout.getList().empty()) )
Expand Down Expand Up @@ -714,14 +711,12 @@ void DialogMeteoComputation::done(bool res)
QDialog::done(QDialog::Accepted);
return;
}

}
else // cancel, close or exc was pressed
{
QDialog::done(QDialog::Rejected);
return;
}

}


Expand All @@ -741,7 +736,6 @@ void DialogMeteoComputation::checkYears()

void DialogMeteoComputation::displayPeriod(const QString value)
{

if (value == "Daily")
{
elaborationList.setCurrentText("No elaboration available");
Expand Down Expand Up @@ -936,12 +930,10 @@ void DialogMeteoComputation::displayPeriod(const QString value)
nrYear.setText("0");
nrYear.setEnabled(true);
}

}


}


void DialogMeteoComputation::listElaboration(const QString value)
{

Expand Down Expand Up @@ -994,9 +986,9 @@ void DialogMeteoComputation::listElaboration(const QString value)
{
anomaly.AnomalySetVariableElab(variableList.currentText());
}

}


void DialogMeteoComputation::listSecondElab(const QString value)
{

Expand Down Expand Up @@ -1069,25 +1061,23 @@ void DialogMeteoComputation::listSecondElab(const QString value)
}
settings->endArray();
settings->endGroup();


}


void DialogMeteoComputation::activeSecondParameter(const QString value)
{

if ( MapElabWithParam.find(value.toStdString()) == MapElabWithParam.end())
{
elab2Parameter.clear();
elab2Parameter.setReadOnly(true);
}
else
{
elab2Parameter.setReadOnly(false);
}

if ( MapElabWithParam.find(value.toStdString()) == MapElabWithParam.end())
{
elab2Parameter.clear();
elab2Parameter.setReadOnly(true);
}
else
{
elab2Parameter.setReadOnly(false);
}
}


void DialogMeteoComputation::readParameter(int state)
{

Expand Down Expand Up @@ -1122,10 +1112,8 @@ void DialogMeteoComputation::readParameter(int state)
climateDbElabList.addItem(climateDbElab[i]);
}
}

}


elab1Parameter.clear();
elab1Parameter.setReadOnly(true);
}
Expand All @@ -1135,7 +1123,6 @@ void DialogMeteoComputation::readParameter(int state)
adjustSize();
elab1Parameter.setReadOnly(false);
}

}


Expand Down Expand Up @@ -1320,14 +1307,15 @@ bool DialogMeteoComputation::checkValidData()
}
}
return true;

}


QList<QString> DialogMeteoComputation::getElabSaveList()
{
return saveClimaLayout.getList();
}


void DialogMeteoComputation::copyDataFromXML()
{
Crit3DElabList listXMLElab;
Expand Down Expand Up @@ -1376,6 +1364,7 @@ void DialogMeteoComputation::copyDataFromXML()
variableList.setCurrentText(QString::fromStdString(xmlVariable));
int elabIndex = elaborationList.findText(listXMLElab.listElab1()[index], Qt::MatchFixedString);
elaborationList.setCurrentIndex(elabIndex);

if ( (listXMLElab.listParam1()[index] != NODATA) && (!listXMLElab.listParam1IsClimate()[index]) )
{
elab1Parameter.setReadOnly(false);
Expand All @@ -1389,13 +1378,12 @@ void DialogMeteoComputation::copyDataFromXML()
climateDbElabList.setVisible(true);
adjustSize();

int index = climateDbElabList.findText(listXMLElab.listParam1ClimateField()[index], Qt::MatchFixedString);
if (index == -1)
int climateIndex = climateDbElabList.findText(listXMLElab.listParam1ClimateField()[index], Qt::MatchFixedString);
if (climateIndex == -1)
{
QMessageBox::information(nullptr, "climate field not found", "Check param1 climate field");
}
climateDbElabList.setCurrentIndex(index);

climateDbElabList.setCurrentIndex(climateIndex);
}
else
{
Expand Down Expand Up @@ -1474,12 +1462,12 @@ void DialogMeteoComputation::copyDataFromXML()
climateDbElabList.setVisible(true);
adjustSize();

int index = climateDbElabList.findText(listXMLAnomaly.listParam1ClimateField()[index], Qt::MatchFixedString);
if (index == -1)
int climateIndex = climateDbElabList.findText(listXMLAnomaly.listParam1ClimateField()[index], Qt::MatchFixedString);
if (climateIndex == -1)
{
QMessageBox::information(nullptr, "climate field not found", "Check param1 climate field");
}
climateDbElabList.setCurrentIndex(index);
climateDbElabList.setCurrentIndex(climateIndex);

}
else
Expand Down Expand Up @@ -1537,12 +1525,12 @@ void DialogMeteoComputation::copyDataFromXML()
{
anomaly.AnomalyReadParameter(1);

int index = climateDbElabList.findText(listXMLAnomaly.listRefParam1ClimateField()[index], Qt::MatchFixedString);
if (index == -1)
int climateIndex = climateDbElabList.findText(listXMLAnomaly.listRefParam1ClimateField()[index], Qt::MatchFixedString);
if (climateIndex == -1)
{
QMessageBox::information(nullptr, "climate field not found", "Check reference param1 climate field");
}
climateDbElabList.setCurrentIndex(index);
climateDbElabList.setCurrentIndex(climateIndex);
}
else
{
Expand Down
78 changes: 77 additions & 1 deletion agrolib/pragaProject/pragaProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,18 @@ void PragaProject::initializePragaProject()
pragaDailyMaps = nullptr;
users.clear();
lastElabTargetisGrid = false;

outputMeteoPointsDbHandler = nullptr;
outputMeteoPointsDbFileName = "";
outputMeteoPointsLoaded = false;
}

void PragaProject::clearPragaProject()
{
if (isProjectLoaded) clearProject();

closeOutputMeteoPointsDB();

users.clear();

dataRaster.clear();
Expand Down Expand Up @@ -2170,7 +2176,7 @@ bool PragaProject::interpolationMeteoGrid(meteoVariable myVar, frequencyType myF
}
else
{
if (! interpolationGridMain(myVar, myTime))
if (! interpolationGrid(myVar, myTime))
return false;
}

Expand Down Expand Up @@ -3542,3 +3548,73 @@ bool PragaProject::saveLogProceduresGrid(QString nameProc, QDate date)
}
return true;
}


void PragaProject::closeOutputMeteoPointsDB()
{
if (outputMeteoPointsDbHandler != nullptr)
{
delete outputMeteoPointsDbHandler;
outputMeteoPointsDbHandler = nullptr;
}

outputMeteoPointsLoaded = false;
outputPoints.clear();
}


bool PragaProject::loadOutputMeteoPointsDB(QString fileName)
{
if (fileName.isEmpty())
return false;

closeOutputMeteoPointsDB();
errorString = "";
logInfo("Load output meteo points = " + fileName);

QString outputDbName = getCompleteFileName(fileName, PATH_METEOPOINT);
if (! QFile(outputDbName).exists())
{
errorString = "Output meteo points DB does not exists:\n" + outputDbName;
return false;
}

outputMeteoPointsDbHandler = new Crit3DMeteoPointsDbHandler(outputDbName);
if (! outputMeteoPointsDbHandler->error.isEmpty())
{
errorString = "Function loadOutputMeteoPointsDB:\n" + outputDbName
+ "\n" + outputMeteoPointsDbHandler->error;
return false;
}

QList<Crit3DMeteoPoint> listMeteoPoints;
if (! outputMeteoPointsDbHandler->getPropertiesFromDb(listMeteoPoints, gisSettings, errorString))
{
errorString = "Error in reading table 'point_properties'\n" + errorString;
return false;
}

if (listMeteoPoints.empty())
{
errorString = "Missing data in the table 'point_properties'";
return false;
}
// set output points
outputPoints.resize(listMeteoPoints.size());
for (int i=0; i < listMeteoPoints.size(); i++)
{
outputPoints[i].id = listMeteoPoints[i].id;
outputPoints[i].latitude = listMeteoPoints[i].latitude;
outputPoints[i].longitude = listMeteoPoints[i].longitude;
outputPoints[i].utm = listMeteoPoints[i].point.utm;
outputPoints[i].z = listMeteoPoints[i].point.z;
outputPoints[i].active = listMeteoPoints[i].active;
}
listMeteoPoints.clear();

outputMeteoPointsDbFileName = outputDbName;
outputMeteoPointsLoaded = true;
logInfo("Output meteo points DB = " + outputMeteoPointsDbFileName);

return true;
}
12 changes: 11 additions & 1 deletion agrolib/pragaProject/pragaProject.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
void deleteSynchWidget();

public:
QString projectPragaFolder;
QList<QString> users;

gis::Crit3DRasterGrid dataRaster;
Crit3DDailyMeteoMaps* pragaDailyMaps;
PragaHourlyMeteoMaps* pragaHourlyMaps;
Expand All @@ -71,9 +73,14 @@
Crit3DPointStatisticsWidget* pointStatisticsWidget;
Crit3DHomogeneityWidget* homogeneityWidget;
Crit3DSynchronicityWidget* synchronicityWidget;

std::string synchReferencePoint;

ImportDataXML* importData;
QString projectPragaFolder;

Crit3DMeteoPointsDbHandler* outputMeteoPointsDbHandler;
QString outputMeteoPointsDbFileName;
bool outputMeteoPointsLoaded;

#ifdef NETCDF
NetCDFHandler netCDF;
Expand All @@ -91,6 +98,9 @@
bool loadPragaProject(QString myFileName);
bool loadPragaSettings();

void closeOutputMeteoPointsDB();
bool loadOutputMeteoPointsDB(QString fileName);

gis::Crit3DRasterGrid* getPragaMapFromVar(meteoVariable myVar);

bool downloadDailyDataArkimet(QList<QString> variables, bool prec0024, QDate startDate, QDate endDate, bool showInfo);
Expand Down
Loading

0 comments on commit 0debc99

Please sign in to comment.