MCPcopy Create free account
hub / github.com/OSGeo/gdal / GDALInterpExtractValuesWindow

Function GDALInterpExtractValuesWindow

alg/gdal_interpolateatpoint.cpp:39–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37// Only valid for T = double or std::complex<double>
38template <typename T>
39bool GDALInterpExtractValuesWindow(GDALRasterBand *pBand,
40 std::unique_ptr<DoublePointsCache> &cache,
41 gdal::Vector2i point,
42 gdal::Vector2i dimensions, T *padfOut)
43{
44 constexpr int BLOCK_SIZE = 64;
45
46 const int nX = point.x();
47 const int nY = point.y();
48 const int nWidth = dimensions.x();
49 const int nHeight = dimensions.y();
50
51 // Request the DEM by blocks of BLOCK_SIZE * BLOCK_SIZE and put them
52 // in cache
53 if (!cache)
54 cache.reset(new DoublePointsCache{});
55
56 const int nXIters = (nX + nWidth - 1) / BLOCK_SIZE - nX / BLOCK_SIZE + 1;
57 const int nYIters = (nY + nHeight - 1) / BLOCK_SIZE - nY / BLOCK_SIZE + 1;
58 const int nRasterXSize = pBand->GetXSize();
59 const int nRasterYSize = pBand->GetYSize();
60 const bool bIsComplex =
61 CPL_TO_BOOL(GDALDataTypeIsComplex(pBand->GetRasterDataType()));
62
63 for (int iY = 0; iY < nYIters; iY++)
64 {
65 const int nBlockY = nY / BLOCK_SIZE + iY;
66 const int nReqYSize =
67 std::min(nRasterYSize - nBlockY * BLOCK_SIZE, BLOCK_SIZE);
68 const int nFirstLineInCachedBlock = (iY == 0) ? nY % BLOCK_SIZE : 0;
69 const int nFirstLineInOutput =
70 (iY == 0) ? 0
71 : BLOCK_SIZE - (nY % BLOCK_SIZE) + (iY - 1) * BLOCK_SIZE;
72 const int nLinesToCopy = (nYIters == 1) ? nHeight
73 : (iY == 0) ? BLOCK_SIZE - (nY % BLOCK_SIZE)
74 : (iY == nYIters - 1)
75 ? 1 + (nY + nHeight - 1) % BLOCK_SIZE
76 : BLOCK_SIZE;
77 for (int iX = 0; iX < nXIters; iX++)
78 {
79 const int nBlockX = nX / BLOCK_SIZE + iX;
80 const int nReqXSize =
81 std::min(nRasterXSize - nBlockX * BLOCK_SIZE, BLOCK_SIZE);
82 const uint64_t nKey =
83 (static_cast<uint64_t>(nBlockY) << 32) | nBlockX;
84 const int nFirstColInCachedBlock = (iX == 0) ? nX % BLOCK_SIZE : 0;
85 const int nFirstColInOutput =
86 (iX == 0)
87 ? 0
88 : BLOCK_SIZE - (nX % BLOCK_SIZE) + (iX - 1) * BLOCK_SIZE;
89 const int nColsToCopy = (nXIters == 1) ? nWidth
90 : (iX == 0) ? BLOCK_SIZE - (nX % BLOCK_SIZE)
91 : (iX == nXIters - 1)
92 ? 1 + (nX + nWidth - 1) % BLOCK_SIZE
93 : BLOCK_SIZE;
94
95#if 0
96 CPLDebug("RPC", "nY=%d nX=%d nBlockY=%d nBlockX=%d "

Callers 1

Calls 15

CPL_TO_BOOLFunction · 0.85
CPLDebugFunction · 0.85
xMethod · 0.80
yMethod · 0.80
tryGetMethod · 0.80
minFunction · 0.50
to_stringFunction · 0.50
resetMethod · 0.45
GetXSizeMethod · 0.45
GetYSizeMethod · 0.45
GetRasterDataTypeMethod · 0.45
RasterIOMethod · 0.45

Tested by

no test coverage detected