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

Method PointGrid

pdal/private/PointGrid.hpp:52–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50
51public:
52 PointGrid(BOX2D bounds, const PointView& view, int approxPerCell = 200) :
53 m_bounds(bounds), m_view(view), m_approxPerCell(approxPerCell)
54 {
55 int pointsPerCell = (approxPerCell > 0 ? approxPerCell : 1);
56 double cells = std::floor(std::sqrt(static_cast<double>(view.size()) / pointsPerCell));
57 cells = std::max(cells, 1.0);
58 if (cells >= (std::numeric_limits<uint16_t>::max)())
59 throw pdal_error("PointGrid: Too many cells requested.");
60 m_cells1d = static_cast<uint16_t>(cells);
61
62 // Adding a small amount to make sure the max value is in a cell.
63 m_xlen = (m_bounds.maxx - m_bounds.minx) / m_cells1d + .0001;
64 m_ylen = (m_bounds.maxy - m_bounds.miny) / m_cells1d + .0001;
65 m_cells.resize(m_cells1d * m_cells1d);
66 }
67
68 void add(double x, double y, PointId id)
69 {

Callers

nothing calls this directly

Calls 2

resizeMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected