Skip to content

Commit f15283b

Browse files
Andrew BellAndrew Bell
authored andcommitted
Test.
1 parent d920792 commit f15283b

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

alg/viewshed/viewshed_executor.cpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
* SPDX-License-Identifier: MIT
1212
****************************************************************************/
1313

14+
//ABELL
15+
#include <iostream>
16+
1417
#include <algorithm>
1518
#include <atomic>
1619
#include <cassert>
@@ -299,6 +302,8 @@ bool ViewshedExecutor::readLine(int nLine, std::vector<Cell> &vThisLine)
299302

300303
for (size_t i = 0; i < line.size(); ++i)
301304
vThisLine[i].val = line[i];
305+
if (nLine == 2424)
306+
std::cerr << "Cur[530] = " << vThisLine[530].val << "!\n";
302307

303308
if (sdMode())
304309
{
@@ -321,6 +326,8 @@ bool ViewshedExecutor::readLine(int nLine, std::vector<Cell> &vThisLine)
321326
}
322327
for (size_t i = 0; i < line.size(); ++i)
323328
vThisLine[i].sd = (line[i] == nodata ? 1000.0 : line[i]);
329+
if (nLine == 2424)
330+
std::cerr << "SD[530] = " << vThisLine[530].sd << "!\n";
324331
}
325332

326333
return true;
@@ -543,9 +550,13 @@ bool ViewshedExecutor::processFirstLine(std::vector<Cell> &vLastLine)
543550
else
544551
{
545552
CPLJobQueuePtr pQueue = m_pool.CreateJobQueue();
553+
/*
546554
pQueue->SubmitJob([&]() { processFirstLineLeft(ll, vThisLine); });
547555
pQueue->SubmitJob([&]() { processFirstLineRight(ll, vThisLine); });
548556
pQueue->WaitCompletion();
557+
**/
558+
processFirstLineLeft(ll, vThisLine);
559+
processFirstLineRight(ll, vThisLine);
549560
}
550561

551562
if (oOpts.pitchMasking())
@@ -608,6 +619,8 @@ void ViewshedExecutor::processFirstLineTopOrBottom(const LineLimits &ll,
608619
void ViewshedExecutor::processFirstLineLeft(const LineLimits &ll,
609620
std::vector<Cell> &vThisLine)
610621
{
622+
std::cerr << "Left!\n";
623+
611624
int iEnd = ll.left - 1;
612625
int iStart = m_nX - 1; // One left of the observer.
613626

@@ -617,6 +630,8 @@ void ViewshedExecutor::processFirstLineLeft(const LineLimits &ll,
617630

618631
iStart = oCurExtent.clampX(iStart);
619632

633+
std::cerr << "m_nX/m_nY = " << m_nX << "/" << m_nY << "!\n";
634+
std::cerr << "maybe val = " << oOpts.maybeVisibleVal << "!\n";
620635
// If the start cell is next to the observer, just mark it visible.
621636
if (iStart + 1 == m_nX || iStart + 1 == oCurExtent.xStop)
622637
{
@@ -922,6 +937,11 @@ void ViewshedExecutor::processLineLeft(int nYOffset, LineLimits &ll,
922937
dfSdZ = oZcalc(nXOffset, nYOffset, vThisLine[iPixel + 1].sd,
923938
vLastLine[iPixel].sd, vLastLine[iPixel + 1].sd);
924939
}
940+
if (nLine == 2424 && iPixel == 530)
941+
{
942+
std::cerr << "Val/SD val/Z/sdZ = " << vThisLine[iPixel].val << "/" << vThisLine[iPixel].sd << "/" <<
943+
dfZ << "/" << dfSdZ << "!\n";
944+
}
925945
setOutput(vThisLine[iPixel].result, vThisLine[iPixel].val,
926946
vThisLine[iPixel].sd, dfZ, dfSdZ);
927947
}
@@ -1071,12 +1091,23 @@ bool ViewshedExecutor::processLine(int nLine, std::vector<Cell> &vLastLine)
10711091
}
10721092

10731093
// process left half then right half of line
1094+
/**
10741095
CPLJobQueuePtr pQueue = m_pool.CreateJobQueue();
10751096
pQueue->SubmitJob([&]()
10761097
{ processLineLeft(nYOffset, ll, vThisLine, vLastLine); });
10771098
pQueue->SubmitJob(
10781099
[&]() { processLineRight(nYOffset, ll, vThisLine, vLastLine); });
10791100
pQueue->WaitCompletion();
1101+
**/
1102+
processLineLeft(nYOffset, ll, vThisLine, vLastLine);
1103+
processLineRight(nYOffset, ll, vThisLine, vLastLine);
1104+
1105+
/**
1106+
for (int i = 0; i < vThisLine.size(); ++i)
1107+
if (vThisLine[i].result == 2)
1108+
std::cerr << "Maybe[" << i << ", " << nLine << "] = " <<
1109+
vThisLine[i].result << "!\n";
1110+
**/
10801111

10811112
if (oOpts.pitchMasking())
10821113
applyPitchMask(vThisLine, vPitchMaskVal);
@@ -1152,6 +1183,7 @@ bool ViewshedExecutor::run()
11521183
// scan upwards
11531184
int yStart = oCurExtent.clampY(m_nY);
11541185
std::atomic<bool> err(false);
1186+
/**
11551187
CPLJobQueuePtr pQueue = m_pool.CreateJobQueue();
11561188
pQueue->SubmitJob(
11571189
[&]()
@@ -1175,6 +1207,26 @@ bool ViewshedExecutor::run()
11751207
if (!processLine(nLine, vLastLine))
11761208
err = true;
11771209
});
1210+
**/
1211+
1212+
{
1213+
std::vector<Cell> vLastLine = vFirstLine;
1214+
1215+
for (int nLine = yStart - 1; nLine >= oCurExtent.yStart && !err;
1216+
nLine--)
1217+
if (!processLine(nLine, vLastLine))
1218+
err = true;
1219+
}
1220+
1221+
// scan downwards
1222+
{
1223+
std::vector<Cell> vLastLine = vFirstLine;
1224+
1225+
for (int nLine = yStart + 1; nLine < oCurExtent.yStop && !err;
1226+
nLine++)
1227+
if (!processLine(nLine, vLastLine))
1228+
err = true;
1229+
}
11781230
return true;
11791231
}
11801232

0 commit comments

Comments
 (0)