Skip to content

Commit c75d744

Browse files
committed
Base viewshed updates for standard-deviation.
1 parent 84b16fe commit c75d744

File tree

7 files changed

+427
-252
lines changed

7 files changed

+427
-252
lines changed

alg/viewshed/viewshed.cpp

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,13 @@ bool Viewshed::calcExtents(int nX, int nY, const GDALGeoTransform &invGT)
373373
bool 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
}

alg/viewshed/viewshed.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class Viewshed
6969
Window oCurExtent{};
7070
DatasetPtr poDstDS{};
7171
GDALRasterBand *pSrcBand = nullptr;
72+
GDALRasterBand *pSdBand = nullptr;
7273

7374
DatasetPtr execute(int nX, int nY, const std::string &outFilename);
7475
void setOutput(double &dfResult, double &dfCellVal, double dfZ);

0 commit comments

Comments
 (0)