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

Method readPoint

pdal/DbWriter.cpp:237–272  ·  view source on GitHub ↗

Read a point's data packed into a buffer. \param[in] view PointView to read from. \param[in] idx Index of point to read. \param[in] outbuf Buffer to write to. \return Number of bytes written to buffer.

Source from the content-addressed store, hash-verified

235/// \param[in] outbuf Buffer to write to.
236/// \return Number of bytes written to buffer.
237size_t DbWriter::readPoint(const PointView& view, PointId idx, char *outbuf)
238{
239 using namespace Dimension;
240
241 // Read the data for the output dimensions from the view into the outbuf.
242 view.getPackedPoint(m_dimTypes, idx, outbuf);
243
244 auto iconvert = [](const XForm& xform, Id dim,
245 const char *inpos, char *outpos)
246 {
247 double d;
248 int32_t i;
249
250 memcpy(&d, inpos, sizeof(double));
251 d = xform.toScaled(d);
252 if (!Utils::numericCast(d, i))
253 {
254 std::ostringstream oss;
255 oss << "Unable to convert double to int32 for packed DB output: ";
256 oss << Dimension::name(dim) << ": (" << d << ").";
257 throw pdal_error(oss.str());
258 }
259 memcpy(outpos, &i, sizeof(int32_t));
260 };
261
262 if (m_xOffsets.first >= 0)
263 iconvert(m_scaling.m_xXform, Id::X, outbuf + (size_t)m_xOffsets.first,
264 outbuf + (size_t)m_xOffsets.second);
265 if (m_yOffsets.first >= 0)
266 iconvert(m_scaling.m_yXform, Id::Y, outbuf + (size_t)m_yOffsets.first,
267 outbuf + (size_t)m_yOffsets.second);
268 if (m_zOffsets.first >= 0)
269 iconvert(m_scaling.m_zXform, Id::Z, outbuf + (size_t)m_zOffsets.first,
270 outbuf + (size_t)m_zOffsets.second);
271 return m_dbPointSize;
272}
273
274} // namespace pdal

Callers 1

readPointsMethod · 0.45

Calls 4

numericCastFunction · 0.85
toScaledMethod · 0.80
strMethod · 0.80
nameFunction · 0.70

Tested by

no test coverage detected