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

Method read

io/PtxReader.cpp:248–379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246}
247
248point_count_t PtxReader::read(PointViewPtr view, point_count_t numPts)
249{
250 PointId index = view->size();
251 point_count_t count = 0;
252
253 PtxHeader header;
254 size_t line = 1;
255 point_count_t countPerHeader = 0;
256 std::string buf;
257
258 while (m_istream && m_istream->good() && count < numPts)
259 {
260 if (countPerHeader == 0 ||
261 countPerHeader == (header.m_columns * header.m_rows))
262 {
263 // Either we are at the start of the file OR we have finished
264 // reading the expected number of points for our previous header.
265 // In either case we expect now to read the next header.
266
267 if (m_istream->peek() == EOF)
268 break; // We have reached the end of the file, so we break out!
269
270 // Read next header. This will throw on failure. We are a bit
271 // stricter about this than we are with point read failures.
272
273 try
274 {
275 header = readHeader();
276 }
277 catch (...)
278 {
279 log()->get(LogLevel::Error) << "Line " << line <<
280 " in '" << m_filename << "' contains an invalid header!"
281 << std::endl;
282 throw;
283 }
284
285 line += 10;
286 countPerHeader = 0;
287 }
288
289 ++countPerHeader;
290
291 std::getline(*m_istream, buf);
292 ++line;
293 if (buf.empty())
294 continue;
295
296 const StringList fields = Utils::split2(buf, ' ');
297 if (fields.size() != m_dimensions.size())
298 {
299 // As mentioned above. We assume each cloud in the Ptx file has
300 // the same number of fields.
301
302 log()->get(LogLevel::Error) << "Line " << line <<
303 " in '" << m_filename << "' contains " << fields.size() <<
304 " fields when " << m_dimensions.size() << " were expected. "
305 "Ignoring." << std::endl;

Callers

nothing calls this directly

Calls 8

applyTransformMethod · 0.80
fromStringFunction · 0.70
logFunction · 0.50
sizeMethod · 0.45
getMethod · 0.45
emptyMethod · 0.45
whatMethod · 0.45
setFieldMethod · 0.45

Tested by

no test coverage detected