diff --git a/agrolib/climate/climate.cpp b/agrolib/climate/climate.cpp index 2d60db1c..540c58d8 100644 --- a/agrolib/climate/climate.cpp +++ b/agrolib/climate/climate.cpp @@ -1691,7 +1691,12 @@ bool elaborateDailyAggrVarFromDailyFromStartDate(meteoVariable myVar, Crit3DMete for (QDate myDate = first; myDate<=last; myDate=myDate.addDays(1)) { - unsigned int index = firstDate.daysTo(myDate); + unsigned long index = firstDate.daysTo(myDate); + if (index >= meteoPoint.obsDataD.size()) + { + break; + } + switch(myVar) { case dailyThomDaytime: diff --git a/agrolib/pointStatisticsWidget/pointStatisticsWidget.cpp b/agrolib/pointStatisticsWidget/pointStatisticsWidget.cpp index 035d4a2c..2874ff75 100644 --- a/agrolib/pointStatisticsWidget/pointStatisticsWidget.cpp +++ b/agrolib/pointStatisticsWidget/pointStatisticsWidget.cpp @@ -48,35 +48,41 @@ Crit3DPointStatisticsWidget::Crit3DPointStatisticsWidget(bool isGrid, Crit3DMete this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); this->setAttribute(Qt::WA_DeleteOnClose); + // joint stations idPoints << this->meteoPoints[0].id; - QList jointStationsMyMp = meteoPointsDbHandler->getJointStations(QString::fromStdString(this->meteoPoints[0].id)); - for (int j = 0; j jointStationsMyMp; + if (meteoPointsDbHandler != nullptr) { - idPoints << jointStationsMyMp[j].toStdString(); - // load all Data + jointStationsMyMp = meteoPointsDbHandler->getJointStations(QString::fromStdString(this->meteoPoints[0].id)); + for (int j = 0; jgetFirstDate(daily, jointStationsMyMp[j].toStdString()).date(); - QDate lastDaily = meteoPointsDbHandler->getLastDate(daily, jointStationsMyMp[j].toStdString()).date(); + QDate firstDaily = meteoPointsDbHandler->getFirstDate(daily, jointStationsMyMp[j].toStdString()).date(); + QDate lastDaily = meteoPointsDbHandler->getLastDate(daily, jointStationsMyMp[j].toStdString()).date(); - QDateTime firstHourly = meteoPointsDbHandler->getFirstDate(hourly, jointStationsMyMp[j].toStdString()); - QDateTime lastHourly = meteoPointsDbHandler->getLastDate(hourly, jointStationsMyMp[j].toStdString()); - for (int n = 0; nmeteoPoints.size(); n++) - { - if (this->meteoPoints[n].id == jointStationsMyMp[j].toStdString()) + QDateTime firstHourly = meteoPointsDbHandler->getFirstDate(hourly, jointStationsMyMp[j].toStdString()); + QDateTime lastHourly = meteoPointsDbHandler->getLastDate(hourly, jointStationsMyMp[j].toStdString()); + for (int n = 0; nmeteoPoints.size(); n++) { - jointStationsSelected.addItem(QString::fromStdString(this->meteoPoints[n].id)+" "+QString::fromStdString(this->meteoPoints[n].name)); - if (firstDaily.isValid() && lastDaily.isValid()) + if (this->meteoPoints[n].id == jointStationsMyMp[j].toStdString()) { - meteoPointsDbHandler->loadDailyData(getCrit3DDate(firstDaily), getCrit3DDate(lastDaily), &(this->meteoPoints[n])); - } - if (firstHourly.isValid() && lastHourly.isValid()) - { - meteoPointsDbHandler->loadHourlyData(getCrit3DDate(firstHourly.date()), getCrit3DDate(lastHourly.date()), &(this->meteoPoints[n])); + jointStationsSelected.addItem(QString::fromStdString(this->meteoPoints[n].id)+" "+QString::fromStdString(this->meteoPoints[n].name)); + if (firstDaily.isValid() && lastDaily.isValid()) + { + meteoPointsDbHandler->loadDailyData(getCrit3DDate(firstDaily), getCrit3DDate(lastDaily), &(this->meteoPoints[n])); + } + if (firstHourly.isValid() && lastHourly.isValid()) + { + meteoPointsDbHandler->loadHourlyData(getCrit3DDate(firstHourly.date()), getCrit3DDate(lastHourly.date()), &(this->meteoPoints[n])); + } + break; } - break; } } } + // layout QVBoxLayout *mainLayout = new QVBoxLayout(); QHBoxLayout *upperLayout = new QHBoxLayout();