@@ -373,6 +373,13 @@ bool Viewshed::calcExtents(int nX, int nY, const GDALGeoTransform &invGT)
373373bool Viewshed::run (GDALRasterBandH band, GDALProgressFunc pfnProgress,
374374 void *pProgressArg)
375375{
376+ DatasetPtr sdDataset;
377+ if (oOpts.sdFilename .size ())
378+ {
379+ GDALDatasetH ds = GDALOpen (oOpts.sdFilename .c_str (), GA_ReadOnly);
380+ sdDataset.reset (GDALDataset::FromHandle (ds));
381+ pSdBand = sdDataset->GetRasterBand (1 );
382+ }
376383 pSrcBand = static_cast <GDALRasterBand *>(band);
377384
378385 GDALGeoTransform fwdTransform, invTransform;
@@ -443,10 +450,20 @@ bool Viewshed::run(GDALRasterBandH band, GDALProgressFunc pfnProgress,
443450
444451 // Execute the viewshed algorithm.
445452 GDALRasterBand *pDstBand = poDstDS->GetRasterBand (1 );
446- ViewshedExecutor executor (*pSrcBand, *pDstBand, nX, nY, oOutExtent,
447- oCurExtent, oOpts, oProgress,
448- /* emitWarningIfNoData = */ true );
449- executor.run ();
453+ if (pSdBand)
454+ {
455+ ViewshedExecutor executor (*pSrcBand, *pDstBand, *pSdBand, nX, nY,
456+ oOutExtent, oCurExtent, oOpts, oProgress,
457+ /* emitWarningIfNoData = */ true );
458+ executor.run ();
459+ }
460+ else
461+ {
462+ ViewshedExecutor executor (*pSrcBand, *pDstBand, nX, nY, oOutExtent,
463+ oCurExtent, oOpts, oProgress,
464+ /* emitWarningIfNoData = */ true );
465+ executor.run ();
466+ }
450467 oProgress.emit (1 );
451468 return static_cast <bool >(poDstDS);
452469}
0 commit comments