Skip to content

Commit

Permalink
fix mingw issues & update soil model table
Browse files Browse the repository at this point in the history
  • Loading branch information
giadasan committed Jun 26, 2024
1 parent 1f553d7 commit 6e10ea3
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 21 deletions.
2 changes: 1 addition & 1 deletion crop/landUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ bool loadLandUnitList(const QSqlDatabase &dbCrop, std::vector<Crit3DLandUnit> &l

int getLandUnitIndex(const std::vector<Crit3DLandUnit> &landUnitList, int idLandUnit)
{
for (int index = 0; index < landUnitList.size(); index++)
for (int index = 0; index < int(landUnitList.size()); index++)
if (landUnitList[index].id == idLandUnit)
return index;

Expand Down
14 changes: 7 additions & 7 deletions gis/gis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ namespace gis
if (!parametersCell.empty())
parametersCell.clear();
parametersCell.resize(initHeader.nrRows*initHeader.nrCols);
for (int i = 0; i < parametersCell.size(); i++)
for (int i = 0; i < int(parametersCell.size()); i++)
{
parametersCell[i].row = i / initHeader.nrCols;
parametersCell[i].col = i % initHeader.nrCols;
Expand All @@ -303,7 +303,7 @@ namespace gis
bool Crit3DRasterGrid::initializeParametersLatLonHeader(const Crit3DLatLonHeader& latLonHeader)
{
parametersCell.resize(latLonHeader.nrRows*latLonHeader.nrCols);
for (int i = 0; i < parametersCell.size(); i++)
for (int i = 0; i < int(parametersCell.size()); i++)
{
parametersCell[i].row = i / latLonHeader.nrCols;
parametersCell[i].col = i % latLonHeader.nrCols;
Expand Down Expand Up @@ -498,7 +498,7 @@ namespace gis

int index = row * header->nrCols + col;

if (index < parametersCell.size())
if (index < int(parametersCell.size()))
parameters = parametersCell[index].fittingParameters;

return parameters;
Expand Down Expand Up @@ -538,16 +538,16 @@ namespace gis
for (j = col-1; j < col+2; j++)
{
index = i * header->nrCols + j;
if (index >= 0 && index < parametersCell.size() && (parametersCell[index].fittingParameters.size() == activeProxyNr) && (i != row || j !=col))
if (index >= 0 && index < int(parametersCell.size()) && (parametersCell[index].fittingParameters.size() == activeProxyNr) && (i != row || j !=col))
findFirst = 1;
if (findFirst==1) break;
}
if (findFirst==1) break;
}

for (k = 0; k < parametersCell[index].fittingParameters.size(); k++)
for (k = 0; k < int(parametersCell[index].fittingParameters.size()); k++)
{
for (l = 0; l < parametersCell[index].fittingParameters[k].size(); l++)
for (l = 0; l < int(parametersCell[index].fittingParameters[k].size()); l++)
{
avg = 0;
counter = 0;
Expand All @@ -556,7 +556,7 @@ namespace gis
for (int m = j; m < col+2; m++)
{
index = h * header->nrCols + m;
if (index >= 0 && index < parametersCell.size() && (parametersCell[index].fittingParameters.size() == activeProxyNr) && (i != row || j !=col))
if (index >= 0 && index < int(parametersCell.size()) && (parametersCell[index].fittingParameters.size() == activeProxyNr) && (i != row || j !=col))
{
avg += parametersCell[index].fittingParameters[k][l];
counter++;
Expand Down
2 changes: 1 addition & 1 deletion gis/gisIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ namespace gis
// remove the curly braces, split the values ​​and remove the spaces
cleanBraces(valueStr);
vector<string> infoStr = splitCommaDelimited(valueStr);
for (int i = 0; i < infoStr.size(); i++)
for (int i = 0; i < int(infoStr.size()); i++)
{
cleanSpaces(infoStr[i]);
}
Expand Down
20 changes: 10 additions & 10 deletions mathFunctions/furtherMathFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ double multilinear(std::vector<double> &x, std::vector<double> &par)
return NODATA;

double y = 0;
for (int i=0; i < x.size(); i++)
for (int i=0; i < int(x.size()); i++)
y += par[i] * x[i];

y += par[x.size()];
Expand Down Expand Up @@ -1136,13 +1136,13 @@ namespace interpolation
double meanObs=0;
double RSS=0;
double TSS=0;
for (int i=0;i<obs.size();i++)
for (int i=0;i<int(obs.size());i++)
{
meanObs += obs[i];
}
meanObs /= obs.size();
//compute RSS and TSS
for (int i=0;i<obs.size();i++)
for (int i=0;i<int(obs.size());i++)
{
RSS += (obs[i]-sim[i])*(obs[i]-sim[i]);
TSS += (obs[i]-meanObs)*(obs[i]-meanObs);
Expand All @@ -1164,7 +1164,7 @@ namespace interpolation
double sum_squared_weighted_data = 0.0;

// Calculate the necessary sums for weighted variance calculation
for (int i = 0; i < data.size(); i++)
for (int i = 0; i < int(data.size()); i++)
{
sum_weights += weights[i];
sum_weighted_data += data[i] * weights[i];
Expand All @@ -1188,15 +1188,15 @@ namespace interpolation

// Calculate the weighted mean of the observed values
double sum_weights = 0.0;
for (int i = 0; i < observed.size(); i++)
for (int i = 0; i < int(observed.size()); i++)
{
weighted_mean_observed += observed[i] * weights[i];
sum_weights += weights[i];
}
weighted_mean_observed /= sum_weights;

// Calculate the sums needed for weighted R-squared calculation
for (int i = 0; i < observed.size(); i++)
for (int i = 0; i < int(observed.size()); i++)
{
double weighted_residual = weights[i] * (observed[i] - predicted[i]);
sum_weighted_squared_residuals += weighted_residual * weighted_residual;
Expand All @@ -1219,13 +1219,13 @@ namespace interpolation
//double weighted_mean_observed = 0.0;


for (int i = 0; i < observed.size(); i++)
for (int i = 0; i < int(observed.size()); i++)
{
double weighted_residual = weights[i] * (observed[i] - predicted[i]);
sum_weighted_squared_residuals += weighted_residual * weighted_residual;
}
double standardError;
if (observed.size() > (nrPredictors+1))
if (int(observed.size()) > (nrPredictors+1))
standardError = sqrt(sum_weighted_squared_residuals/(observed.size()-nrPredictors-1));
else
standardError = sqrt(sum_weighted_squared_residuals/(observed.size()-1));
Expand Down Expand Up @@ -1943,7 +1943,7 @@ namespace interpolation
double error;
double norm = 0;

for (int i = 0; i < y.size(); i++)
for (int i = 0; i < int(y.size()); i++)
{
error = y[i] - func(myFunc,x[i], parameters);
norm += error * error * weights[i] * weights[i];
Expand Down Expand Up @@ -2009,7 +2009,7 @@ namespace interpolation
{
for (int dir = 0; dir < 2; ++dir)
{
for (int paramIndex = 0; paramIndex < numParamsToVary; ++paramIndex)
for (int paramIndex = 0; paramIndex < int(numParamsToVary); ++paramIndex)
{

fittingMarquardt_nDimension_noSquares_singleFunction(func,parametersMin,
Expand Down
10 changes: 10 additions & 0 deletions soilWidget/tabHorizons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,16 @@ void TabHorizons::checkComputedValues(int horizonNum)
tableModel->item(horizonNum,5)->setBackground(Qt::yellow);
}

if (horizon->dbData.effectiveCohesion == NODATA)
{
tableModel->item(horizonNum,11)->setBackground(Qt::yellow);
}

if (horizon->dbData.frictionAngle == NODATA)
{
tableModel->item(horizonNum,12)->setBackground(Qt::yellow);
}

}


Expand Down
4 changes: 2 additions & 2 deletions utilities/utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,12 +672,12 @@ bool writeJson(const QString & ancestor, const std::vector <QString> &fieldNames

bool isFloat = false;

for (int i=0; i < values.size(); i++)
for (int i=0; i < int(values.size()); i++)
{
if (values[i].size() != fieldNames.size() || values[i].size() != dataType.size()) return false;

recordObject.empty();
for (int j=0; j < values[i].size(); j++)
for (int j=0; j < int(values[i].size()); j++)
{
if (dataType[j] == "float")
recordObject.insert(fieldNames[j], values[i][j].toFloat(&isFloat));
Expand Down

0 comments on commit 6e10ea3

Please sign in to comment.