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

Method doOneNoDomain

filters/NeighborClassifierFilter.cpp:121–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119
120
121void NeighborClassifierFilter::doOneNoDomain(PointRef &point, PointRef &temp,
122 KD3Index &kdi)
123{
124 PointIdList iSrc = kdi.neighbors(point, m_k);
125 double thresh = iSrc.size()/2.0;
126
127 // vote NNs
128 using CountMap = std::map<int, unsigned int>;
129 CountMap counts;
130 //std::map<int, unsigned int> counts;
131 for (PointId id : iSrc)
132 {
133 temp.setPointId(id);
134 counts[temp.getFieldAs<int>(m_dimId)]++;
135 }
136
137 // pick winner of the vote
138 auto pr = *std::max_element(counts.begin(), counts.end(),
139 [](CountMap::const_reference p1, CountMap::const_reference p2)
140 { return p1.second < p2.second; });
141
142 // update point
143 auto oldclass = point.getFieldAs<int>(m_dimId);
144 auto newclass = pr.first;
145 if (pr.second > thresh && oldclass != newclass)
146 m_newClass[point.pointId()] = newclass;
147}
148
149// update point. kdi and temp both reference the NN point cloud
150bool NeighborClassifierFilter::doOne(PointRef& point, PointRef &temp,

Callers

nothing calls this directly

Calls 5

setPointIdMethod · 0.80
neighborsMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected