Skip to content

Commit

Permalink
fix assign index map
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomei committed Jul 9, 2024
1 parent 84d054b commit 258c413
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
4 changes: 3 additions & 1 deletion agrolib/gis/gis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,9 @@ namespace gis
c = -1;

float valueBoundary = rasterRef.getValueFromRowCol(row + r, col + c);
return isEqual(valueBoundary, rasterRef.header->flag);
bool isBoundary = isEqual(valueBoundary, rasterRef.header->flag);

return isBoundary;
}


Expand Down
23 changes: 14 additions & 9 deletions bin/CRITERIA3D/shared/project3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,23 +470,27 @@ void Project3D::setIndexMaps()
{
if (! isEqual(DEM.value[row][col], DEM.header->flag))
{
int checkIndex;
bool checkIndex = false;
if (layer == 0)
{
// surface (check land use)
checkIndex = getLandUnitIndexRowCol(row, col);
// surface (check only land use)
if (getLandUnitIndexRowCol(row, col) != NODATA)
checkIndex = true;
}
else
{
// sub-surface (check soil)
checkIndex = getSoilIndex(row, col);
if (! isWithinSoil(checkIndex, layerDepth.at(layer)))
// sub-surface (check land use and soil)
if (getLandUnitIndexRowCol(row, col) != NODATA)
{
checkIndex = NODATA;
int soilIndex = getSoilIndex(row, col);
if (isWithinSoil(soilIndex, layerDepth.at(layer)))
{
checkIndex = true;
}
}
}

if (checkIndex != NODATA)
if (checkIndex)
{
indexMap.at(layer).value[row][col] = currentIndex;
currentIndex++;
Expand Down Expand Up @@ -1244,7 +1248,8 @@ int Project3D::getSoilIndex(long row, long col)

bool Project3D::isWithinSoil(int soilIndex, double depth)
{
if (soilIndex == int(NODATA) || soilIndex >= int(soilList.size())) return false;
if (soilIndex == int(NODATA) || soilIndex >= int(soilList.size()))
return false;

// check if depth is lower than lowerDepth of last horizon
unsigned int lastHorizon = soilList[unsigned(soilIndex)].nrHorizons -1;
Expand Down

0 comments on commit 258c413

Please sign in to comment.