Skip to content

Commit 4cb3f35

Browse files
committed
Checkpoint.
1 parent 08ab218 commit 4cb3f35

File tree

2 files changed

+37
-6
lines changed

2 files changed

+37
-6
lines changed

alg/viewshed/viewshed_executor.cpp

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,25 @@ bool ViewshedExecutor::readLine(int nLine, Lines &lines)
240240
}
241241

242242
if (sdMode())
243+
{
243244
lines.input = lines.cur;
245+
double nodata = m_sdBand.GetNoDataValue();
246+
int sdStatus = m_sdBand.RasterIO(
247+
GF_Read, oOutExtent.xStart, nLine, oOutExtent.xSize(), 1,
248+
lines.sd.data(), oOutExtent.xSize(), 1, GDT_Float64, 0, 0, nullptr);
249+
if (sdStatus)
250+
{
251+
CPLError(CE_Failure, CPLE_AppDefined,
252+
"RasterIO error when reading SD band at position (%d,%d), "
253+
"size (%d,%d)",
254+
oOutExtent.xStart, nLine, oOutExtent.xSize(), 1);
255+
return false;
256+
}
257+
// Set the SD to 1000 if nodata is found.
258+
for (size_t i = 0; i < lines.sd.size(); ++i)
259+
if (lines.sd[i] == nodata)
260+
lines.sd[i] = 1000.0;
261+
}
244262

245263
// Initialize the result line.
246264
// In DEM mode the base is the pre-adjustment value. In ground mode the base is zero.
@@ -433,6 +451,7 @@ bool ViewshedExecutor::processFirstLine(Lines &lines)
433451
lines.result[m_nX] = oOpts.visibleVal;
434452
}
435453

454+
//ABELL
436455
if (!oCurExtent.containsY(m_nY))
437456
processFirstLineTopOrBottom(ll, lines);
438457
else
@@ -442,6 +461,11 @@ bool ViewshedExecutor::processFirstLine(Lines &lines)
442461
pQueue->SubmitJob([&]() { processFirstLineRight(ll, lines); });
443462
pQueue->WaitCompletion();
444463
}
464+
//ABELL
465+
if (sdMode())
466+
{
467+
}
468+
//ABELL
445469

446470
if (oOpts.pitchMasking())
447471
applyPitchMask(lines.result, lines.pitchMask);
@@ -797,10 +821,10 @@ void ViewshedExecutor::processLineLeft(int nYOffset, LineLimits &ll,
797821
double dfZ;
798822
if (nXOffset == nYOffset)
799823
{
800-
if (nXOffset == 1)
824+
if (nYOffset == 1)
801825
dfZ = *pThis;
802826
else
803-
dfZ = CalcHeightLine(nXOffset, *(pLast + 1));
827+
dfZ = CalcHeightLine(nYOffset, *(pLast + 1));
804828
}
805829
else
806830
dfZ =
@@ -856,10 +880,10 @@ void ViewshedExecutor::processLineRight(int nYOffset, LineLimits &ll,
856880
double dfZ;
857881
if (nXOffset == nYOffset)
858882
{
859-
if (nXOffset == 1)
883+
if (nYOffset == 1)
860884
dfZ = *pThis;
861885
else
862-
dfZ = CalcHeightLine(nXOffset, *(pLast - 1));
886+
dfZ = CalcHeightLine(nYOffset, *(pLast - 1));
863887
}
864888
else
865889
dfZ =
@@ -987,6 +1011,8 @@ bool ViewshedExecutor::run()
9871011
if (oOpts.pitchMasking())
9881012
firstLine.pitchMask.resize(oOutExtent.xSize(),
9891013
std::numeric_limits<double>::quiet_NaN());
1014+
if (sdMode())
1015+
firstLine.sd.resize(oOutExtent.xSize());
9901016

9911017
m_dfHeightAdjFactor = calcHeightAdjFactor();
9921018

@@ -1015,6 +1041,8 @@ bool ViewshedExecutor::run()
10151041
lines.pitchMask.resize(
10161042
oOutExtent.xSize(),
10171043
std::numeric_limits<double>::quiet_NaN());
1044+
if (sdMode())
1045+
lines.sd.resize(oOutExtent.xSize());
10181046

10191047
for (int nLine = yStart - 1; nLine >= oCurExtent.yStart && !err;
10201048
nLine--)
@@ -1038,6 +1066,8 @@ bool ViewshedExecutor::run()
10381066
lines.pitchMask.resize(
10391067
oOutExtent.xSize(),
10401068
std::numeric_limits<double>::quiet_NaN());
1069+
if (sdMode())
1070+
lines.sd.resize(oOutExtent.xSize());
10411071

10421072
for (int nLine = yStart + 1; nLine < oCurExtent.yStop && !err;
10431073
nLine++)

alg/viewshed/viewshed_executor.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,17 @@ struct Lines
3838
std::vector<double>
3939
pitchMask; //!< Height/indicator values for pitch masking.
4040
std::vector<double> input; //!< Copy of input data when in SD mode.
41+
std::vector<double> sd; //!< SD mask.
4142

4243
/// Constructor
43-
Lines() : cur(), result(), prev(), pitchMask(), input()
44+
Lines() : cur(), result(), prev(), pitchMask(), input(), sd()
4445
{
4546
}
4647

4748
/// Constructor that initializes to line length
4849
/// \param lineLen Line length.
4950
explicit Lines(size_t lineLen)
50-
: cur(lineLen), result(lineLen), prev(), pitchMask(), input()
51+
: cur(lineLen), result(lineLen), prev(), pitchMask(), input(), sd()
5152
{
5253
}
5354
};

0 commit comments

Comments
 (0)