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

Method filter

filters/HagDelaunayFilter.cpp:152–233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150
151
152void HagDelaunayFilter::filter(PointView& view)
153{
154 using namespace pdal::Dimension;
155
156 PointViewPtr gView = view.makeNew();
157 PointViewPtr ngView = view.makeNew();
158
159 // Separate into ground and non-ground views.
160 for (PointId i = 0; i < view.size(); ++i)
161 {
162 if (view.getFieldAs<uint8_t>(Id::Classification, i) ==
163 m_class)
164 {
165 view.setField(Id::HeightAboveGround, i, 0);
166 gView->appendPoint(view, i);
167 }
168 else
169 ngView->appendPoint(view, i);
170 }
171 BOX2D gBounds;
172 gView->calculateBounds(gBounds);
173
174 // Bail if there weren't any points classified as ground.
175 if (gView->size() == 0)
176 log()->get(LogLevel::Error) << "Input PointView does not have any "
177 "points classified as ground.\n";
178
179 // Build the 2D KD-tree.
180 const KD2Index& kdi = gView->build2dIndex();
181
182 // Find Z difference between non-ground points and the nearest
183 // neighbor (2D) in the ground view or between non-ground points and the
184 // locally-computed surface (Delaunay triangultion of the neighborhood).
185 for (PointId i = 0; i < ngView->size(); ++i)
186 {
187 PointRef point = ngView->point(i);
188
189 // Non-ground view point for which we're trying to calc HAG
190 double x0 = point.getFieldAs<double>(Id::X);
191 double y0 = point.getFieldAs<double>(Id::Y);
192 double z0 = point.getFieldAs<double>(Id::Z);
193
194 PointIdList ids(m_count);
195 std::vector<double> sqr_dists(m_count);
196 kdi.knnSearch(x0, y0, m_count, &ids, &sqr_dists);
197
198 // Closest ground point.
199 double x = gView->getFieldAs<double>(Id::X, ids[0]);
200 double y = gView->getFieldAs<double>(Id::Y, ids[0]);
201 double z = gView->getFieldAs<double>(Id::Z, ids[0]);
202
203 double z1;
204 // If the close ground point is at the same X/Y as the non-ground
205 // point, we're done. Also, if there's only one ground point, we
206 // just use that.
207 if ((x0 == x && y0 == y) || ids.size() == 1)
208 {
209 z1 = z;

Callers

nothing calls this directly

Calls 10

delaunay_interp_groundFunction · 0.85
appendPointMethod · 0.80
calculateBoundsMethod · 0.80
pointMethod · 0.80
logFunction · 0.50
sizeMethod · 0.45
setFieldMethod · 0.45
getMethod · 0.45
knnSearchMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected