Skip to content

Commit

Permalink
Merge commit '7c622c9313cdadd2fd8ce136e8f6ef851e837600'
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomei committed Feb 2, 2024
2 parents 7c69792 + 7c622c9 commit ff6d5f2
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 24 deletions.
74 changes: 52 additions & 22 deletions agrolib/homogeneityWidget/homogeneityWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,16 +351,19 @@ void Crit3DHomogeneityWidget::plotAnnualSeries()
meteoPointTemp.nrObsDataDaysD = 0;
bool dataAlreadyLoaded = false;
int validYears = 0;
if (vectorYears.empty())
{
validYears = computeAnnualSeriesOnPointFromDaily(&myError, meteoPointsDbHandler, nullptr,
&meteoPointTemp, &clima, false, isAnomaly, meteoSettings, myAnnualSeries, vectorYears, dataAlreadyLoaded);
std::vector<int> vectorYears;
validYears = computeAnnualSeriesOnPointFromDaily(&myError, meteoPointsDbHandler, nullptr,
&meteoPointTemp, &clima, false, isAnomaly, meteoSettings, myAnnualSeries, vectorYears, dataAlreadyLoaded);

yearsMissing = false;
if (vectorYears[vectorYears.size()-1] - vectorYears[0] + 1 != vectorYears.size()-1)
{
yearsMissing = true;
}
if (validYears == 0)
{
myAnnualSeries.clear();
return;
}
bool yearsMissing = false;
if (vectorYears[vectorYears.size()-1] - vectorYears[0] + 1 != vectorYears.size()-1)
{
yearsMissing = true;
}

QDate endDate(QDate(lastYear, 12, 31));
Expand All @@ -370,26 +373,52 @@ void Crit3DHomogeneityWidget::plotAnnualSeries()
if (idPointsJointed.size() != 1 && (lastDateCopyed < lastDate || yearsMissing))
{
// mancano dei dati, controllare joint stations
for (int i = 1; i<idPointsJointed.size(); i++)
if (yearsMissing)
{
QDate lastDateNew = meteoPointsDbHandler->getLastDate(daily, idPointsJointed[i]).date();
if (lastDateNew > lastDateCopyed)
std::vector<int> vectorMissing;
int posMissing, n;
for (int y = 0; y<vectorYears.size()-1; y++)
{
int indexMp;
for (int j = 0; j<meteoPointsNearDistanceList.size(); j++)
posMissing = vectorYears[y+1]-vectorYears[y]-1;
n = 1;
while (posMissing != 0)
{
if (meteoPointsNearDistanceList[j].id == idPointsJointed[i])
{
indexMp = j;
break;
}
vectorMissing.push_back(vectorYears[y]+n);
posMissing = posMissing - 1;
n = n + 1;
}
}
for (int y = 0; y < vectorMissing.size(); y++)
{
for (int i = 1; i<idPointsJointed.size(); i++)
{
// TO DO
}
for (QDate myDate=lastDateCopyed.addDays(1); myDate<=lastDateNew; myDate=myDate.addDays(1))
}
}
if (lastDateCopyed < lastDate)
{
for (int i = 1; i<idPointsJointed.size(); i++)
{
QDate lastDateNew = meteoPointsDbHandler->getLastDate(daily, idPointsJointed[i]).date();
if (lastDateNew > lastDateCopyed)
{
setMpValues(meteoPointsNearDistanceList[indexMp], &meteoPointTemp, myDate, myVar, meteoSettings);
int indexMp;
for (int j = 0; j<meteoPointsNearDistanceList.size(); j++)
{
if (meteoPointsNearDistanceList[j].id == idPointsJointed[i])
{
indexMp = j;
break;
}
}
for (QDate myDate=lastDateCopyed.addDays(1); myDate<=lastDateNew; myDate=myDate.addDays(1))
{
setMpValues(meteoPointsNearDistanceList[indexMp], &meteoPointTemp, myDate, myVar, meteoSettings);
}
}
lastDateCopyed = lastDateNew;
}
lastDateCopyed = lastDateNew;
}
dataAlreadyLoaded = true;
vectorYears.clear();
Expand Down Expand Up @@ -492,6 +521,7 @@ void Crit3DHomogeneityWidget::plotAnnualSeries()
averageValue = sum / validYears;
// draw
annualSeriesChartView->draw(years, seriesToView);
return;
}
else
{
Expand Down
2 changes: 0 additions & 2 deletions agrolib/homogeneityWidget/homogeneityWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@
QDate firstDaily;
QDate lastDaily;
std::vector<float> myAnnualSeries;
std::vector<int> vectorYears;
bool yearsMissing;
QList<std::string> sortedId;
std::vector<float> distanceId;
QMap<QString, std::string> mapNameId;
Expand Down

0 comments on commit ff6d5f2

Please sign in to comment.