MCPcopy Create free account
hub / github.com/PDAL/PDAL / fillPercentiles

Method fillPercentiles

io/private/GDALGrid.cpp:480–503  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

478
479
480void GDALGrid::fillPercentiles(const size_t& idx, std::vector<double>& values)
481{
482 std::sort(values.begin(), values.end());
483 //!! This check is mostly for testing
484 if (values.size() != static_cast<size_t>(m_count->at(idx)))
485 {
486 throw error("Mismatch in size of accumulated values and count raster; "
487 "expected " + std::to_string(m_count->at(idx)) + " values, got " +
488 std::to_string(values.size()));
489 return;
490 }
491 //!! Could use nth_element?
492 for (auto& [pct, raster] : m_pctls)
493 {
494 const double pctIdxExact = (pct / 100.0) * (m_count->at(idx) - 1);
495 const size_t pctIdxFloor = static_cast<size_t>(pctIdxExact);
496 double fraction = pctIdxExact - pctIdxFloor;
497 if (!fraction)
498 (*raster)[idx] = values[pctIdxFloor];
499 else
500 (*raster)[idx] = values[pctIdxFloor] + fraction *
501 (values[pctIdxFloor + 1] - values[pctIdxFloor]);
502 }
503}
504
505
506void GDALGrid::finalize()

Callers

nothing calls this directly

Calls 5

atMethod · 0.80
errorClass · 0.50
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected