@@ -219,6 +219,15 @@ double ViewshedExecutor::calcHeightAdjFactor()
219219// / dfZ Minimum observable height at cell.
220220void ViewshedExecutor::setOutput (double &dfResult, double &dfCellVal,
221221 double dfZ)
222+ {
223+ if (!m_sdCalc)
224+ setOutputNormal (dfResult, dfCellVal, dfZ);
225+ else
226+ setOutputSd (dfResult, dfCellVal, dfZ);
227+ }
228+
229+ void ViewshedExecutor::setOutputNormal (double &dfResult, double &dfCellVal,
230+ double dfZ)
222231{
223232 if (oOpts.outputMode != OutputMode::Normal)
224233 {
@@ -232,6 +241,25 @@ void ViewshedExecutor::setOutput(double &dfResult, double &dfCellVal,
232241 dfCellVal = std::max (dfCellVal, dfZ);
233242}
234243
244+ void ViewshedExecutor::setOutputSd (double &dfResult, double &dfCellVal,
245+ double dfZ)
246+ {
247+ assert (oOpts.outputMode == OutputMode::Normal);
248+ if (dfResult == oOpts.invisibleVal )
249+ {
250+ double cellHeight = dfCellVal + oOpts.targetHeight ;
251+ if (cellHeight > dfZ)
252+ dfResult = oOpts.maybeVisibleVal ;
253+ }
254+ // ABELL
255+ /* *
256+ if (lines.sd[pixel] <= 1)
257+ dfCellVal = std::max(dfZ, dfCellVal);
258+ else
259+ dfCellVal = dfZ;
260+ **/
261+ }
262+
235263// / Read a line of raster data.
236264// /
237265// / @param nLine Line number to read.
@@ -464,21 +492,27 @@ bool ViewshedExecutor::processFirstLine(Lines &lines)
464492 lines.result [m_nX] = oOpts.visibleVal ;
465493 }
466494
467- // ABELL
468- if (!oCurExtent.containsY (m_nY))
469- processFirstLineTopOrBottom (ll, lines);
470- else
495+ auto process = [this , &ll, &lines](bool sdCalc)
471496 {
472- CPLJobQueuePtr pQueue = m_pool.CreateJobQueue ();
473- pQueue->SubmitJob ([&]() { processFirstLineLeft (ll, lines); });
474- pQueue->SubmitJob ([&]() { processFirstLineRight (ll, lines); });
475- pQueue->WaitCompletion ();
476- }
477- // ABELL
497+ m_sdCalc = sdCalc;
498+ if (!oCurExtent.containsY (m_nY))
499+ processFirstLineTopOrBottom (ll, lines);
500+ else
501+ {
502+ CPLJobQueuePtr pQueue = m_pool.CreateJobQueue ();
503+ pQueue->SubmitJob ([&]() { processFirstLineLeft (ll, lines); });
504+ pQueue->SubmitJob ([&]() { processFirstLineRight (ll, lines); });
505+ pQueue->WaitCompletion ();
506+ }
507+ sdCalc = false ;
508+ };
509+
510+ process (false );
478511 if (sdMode ())
479512 {
513+ lines.cur = std::move (lines.input );
514+ process (true );
480515 }
481- // ABELL
482516
483517 if (oOpts.pitchMasking ())
484518 applyPitchMask (lines.result , lines.pitchMask );
@@ -947,11 +981,22 @@ bool ViewshedExecutor::processLine(int nLine, Lines &lines)
947981 maskInitial (lines.result , nLine);
948982 }
949983
950- // process left half then right half of line
951- CPLJobQueuePtr pQueue = m_pool.CreateJobQueue ();
952- pQueue->SubmitJob ([&]() { processLineLeft (nYOffset, ll, lines); });
953- pQueue->SubmitJob ([&]() { processLineRight (nYOffset, ll, lines); });
954- pQueue->WaitCompletion ();
984+ auto process = [this , nYOffset, &ll, &lines](bool sdCalc)
985+ {
986+ m_sdCalc = sdCalc;
987+ CPLJobQueuePtr pQueue = m_pool.CreateJobQueue ();
988+ pQueue->SubmitJob ([&]() { processLineLeft (nYOffset, ll, lines); });
989+ pQueue->SubmitJob ([&]() { processLineRight (nYOffset, ll, lines); });
990+ pQueue->WaitCompletion ();
991+ m_sdCalc = false ;
992+ };
993+
994+ process (false );
995+ if (sdMode ())
996+ {
997+ lines.cur = std::move (lines.input );
998+ process (true );
999+ }
9551000
9561001 if (oOpts.pitchMasking ())
9571002 applyPitchMask (lines.result , lines.pitchMask );
0 commit comments