From 36dab3fdbb3acb6b5d6fa8843a6587c520fe3e03 Mon Sep 17 00:00:00 2001 From: lauracosta Date: Thu, 22 Feb 2024 17:49:19 +0100 Subject: [PATCH 1/2] init always obsDataM --- dbMeteoGrid/dbMeteoGrid.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/dbMeteoGrid/dbMeteoGrid.cpp b/dbMeteoGrid/dbMeteoGrid.cpp index 91f10d1ab..a63a0f23f 100644 --- a/dbMeteoGrid/dbMeteoGrid.cpp +++ b/dbMeteoGrid/dbMeteoGrid.cpp @@ -2308,11 +2308,7 @@ bool Crit3DMeteoGridDbHandler::loadGridAllMonthlyData(QString &myError, QDate fi myError = "Missing MeteoPoint id"; return false; } - - if (_meteoGrid->meteoPointPointer(row,col)->nrObsDataDaysM == 0) - { - _meteoGrid->meteoPointPointer(row,col)->initializeObsDataM(numberOfMonths, firstDate.month(), firstDate.year()); - } + _meteoGrid->meteoPointPointer(row,col)->initializeObsDataM(numberOfMonths, firstDate.month(), firstDate.year()); } if (! _meteoGrid->meteoPointPointer(row,col)->setMeteoPointValueM(getCrit3DDate(date), variable, value)) return false; From a81d8f44d2201bb6d3e226034ea4f69eb1654140 Mon Sep 17 00:00:00 2001 From: lauracosta Date: Thu, 22 Feb 2024 19:07:43 +0100 Subject: [PATCH 2/2] fix init monthly data --- dbMeteoGrid/dbMeteoGrid.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/dbMeteoGrid/dbMeteoGrid.cpp b/dbMeteoGrid/dbMeteoGrid.cpp index a63a0f23f..291c2d919 100644 --- a/dbMeteoGrid/dbMeteoGrid.cpp +++ b/dbMeteoGrid/dbMeteoGrid.cpp @@ -2248,6 +2248,15 @@ bool Crit3DMeteoGridDbHandler::loadGridAllMonthlyData(QString &myError, QDate fi return false; } + // init all monthly data + for (int row = 0; row < gridStructure().header().nrRows; row++) + { + for (int col = 0; col < gridStructure().header().nrCols; col++) + { + _meteoGrid->meteoPointPointer(row,col)->initializeObsDataM(numberOfMonths, firstDate.month(), firstDate.year()); + } + } + QSqlQuery qry(_db); QDate date; unsigned row, col; @@ -2308,7 +2317,6 @@ bool Crit3DMeteoGridDbHandler::loadGridAllMonthlyData(QString &myError, QDate fi myError = "Missing MeteoPoint id"; return false; } - _meteoGrid->meteoPointPointer(row,col)->initializeObsDataM(numberOfMonths, firstDate.month(), firstDate.year()); } if (! _meteoGrid->meteoPointPointer(row,col)->setMeteoPointValueM(getCrit3DDate(date), variable, value)) return false;