@@ -234,8 +234,10 @@ void ViewshedExecutor::setOutputNormal(Lines &lines, int pos, double dfZ)
234234 result += adjustment;
235235 }
236236 else
237- result = (cur + oOpts.targetHeight < dfZ) ? oOpts.invisibleVal
238- : oOpts.visibleVal ;
237+ {
238+ double cellHeight = cur + oOpts.targetHeight ;
239+ result = (cellHeight < dfZ) ? oOpts.invisibleVal : oOpts.visibleVal ;
240+ }
239241 cur = std::max (cur, dfZ);
240242}
241243
@@ -287,7 +289,6 @@ bool ViewshedExecutor::readLine(int nLine, Lines &lines)
287289
288290 if (sdMode ())
289291 {
290- lines.input = lines.cur ;
291292 double nodata = m_sdBand.GetNoDataValue ();
292293 CPLErr sdStatus = m_sdBand.RasterIO (
293294 GF_Read, oOutExtent.xStart , nLine, oOutExtent.xSize (), 1 ,
@@ -490,6 +491,11 @@ bool ViewshedExecutor::processFirstLine(Lines &lines)
490491 m_dfZObserver += lines.cur [m_nX];
491492
492493 LineLimits ll = adjustHeight (nYOffset, lines);
494+
495+ std::vector<double > savedInput;
496+ if (sdMode ())
497+ savedInput = lines.cur ;
498+
493499 if (oCurExtent.containsX (m_nX))
494500 {
495501 if (ll.leftMin != ll.rightMin )
@@ -517,7 +523,7 @@ bool ViewshedExecutor::processFirstLine(Lines &lines)
517523 lines.prev = lines.cur ;
518524 if (sdMode ())
519525 {
520- lines.cur = std::move (lines. input );
526+ lines.cur = std::move (savedInput );
521527 process (true );
522528 lines.prevTmp = lines.cur ;
523529 }
@@ -1013,6 +1019,10 @@ bool ViewshedExecutor::processLine(int nLine, Lines &lines)
10131019 // Adjust height of the read line.
10141020 LineLimits ll = adjustHeight (nYOffset, lines);
10151021
1022+ std::vector<double > savedLine;
1023+ if (sdMode ())
1024+ savedLine = lines.cur ;
1025+
10161026 auto process = [this , nYOffset, &ll, &lines](bool sdCalc)
10171027 {
10181028 CPLJobQueuePtr pQueue = m_pool.CreateJobQueue ();
@@ -1043,7 +1053,7 @@ bool ViewshedExecutor::processLine(int nLine, Lines &lines)
10431053 {
10441054 lines.prev = std::move (lines.prevTmp );
10451055 lines.prevTmp = std::move (lines.cur );
1046- lines.cur = std::move (lines. input );
1056+ lines.cur = std::move (savedLine );
10471057 // Handle initial position on the line.
10481058 if (!masked && oCurExtent.containsX (m_nX))
10491059 {
0 commit comments