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

Method initializeLocal

io/LasReader.cpp:296–461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

294}
295
296void LasReader::initializeLocal(PointTableRef table, MetadataNode& m)
297{
298 try
299 {
300 d->extraDims = las::parse(d->opts.extraDimSpec, false);
301 }
302 catch (const las::error& err)
303 {
304 throwError(err.what());
305 }
306
307 std::string error;
308 d->ignoreVlrs = las::parseIgnoreVlrs(d->opts.ignoreVLROption, error);
309 if (error.size())
310 throwError(error);
311
312 // This will throw if the stream can't be opened.
313 LasStreamPtr lasStream = createStream();
314 std::istream& stream(*lasStream);
315
316 stream.seekg(0);
317 // Always try to read as if we have 1.4 size.
318 char headerBuf[las::Header::Size14];
319 stream.read(headerBuf, las::Header::Size14);
320 if (stream.gcount() < (std::streamsize)las::Header::Size12)
321 throwError("Couldn't read LAS header. File size insufficient.");
322 d->header.fill(headerBuf, las::Header::Size14);
323
324 uint64_t fileSize = Utils::fileSize(m_filename);
325 StringList errors = d->header.validate(fileSize);
326 if (errors.size())
327 throwError(errors.front());
328 if (d->header.has14PointFormat() && !d->header.useWkt())
329 log()->get(LogLevel::Warning) <<
330 "Global encoding WKT flag not set for point format 6 - 10.\n";
331
332 // Set the queue function based on whether we're compressed or not.
333 d->queueNext = d->header.dataCompressed() ?
334 std::bind(&LasReader::queueNextCompressedChunk, this) :
335 std::bind(&LasReader::queueNextStandardChunk, this);
336
337 // Set the load function based on whether we're 1.4 format or not.
338 using namespace std::placeholders;
339 d->loadPoint = d->header.has14PointFormat() ?
340 std::bind(&LasReader::loadPointV14, this, _1, _2, _3) :
341 std::bind(&LasReader::loadPointV10, this, _1, _2, _3);
342
343 // Go peek into header and see if we are COPC
344 // If we over-read the file, the error state will be set, but things are really fine for
345 // a zero-point file, so clear the error.
346 stream.clear();
347 stream.seekg(377);
348 char copcBuf[4] {};
349 stream.read(copcBuf, 4);
350 m.add("copc", ::memcmp(copcBuf, "copc", 4) == 0);
351
352 // Read VLRs.
353 // Clear the error state since the seek or read above may have failed but the file could

Callers

nothing calls this directly

Calls 15

parseIgnoreVlrsFunction · 0.85
shouldIgnoreVlrFunction · 0.85
extractHeaderMetadataFunction · 0.85
extractSrsMetadataFunction · 0.85
addVlrMetadataFunction · 0.85
dataCompressedMethod · 0.80
resizeMethod · 0.80
mustUseWktMethod · 0.80
privateMetadataMethod · 0.80
parseFunction · 0.50
fileSizeFunction · 0.50
logFunction · 0.50

Tested by

no test coverage detected