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

Method queueNextCompressedChunk

io/LasReader.cpp:516–572  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

514}
515
516void LasReader::queueNextCompressedChunk()
517{
518 if ((d->nextFetchChunk >= d->chunkInfo.numChunks()) ||
519 (d->chunkInfo.firstPoint(d->nextFetchChunk) >= d->end))
520 return;
521
522 uint32_t chunk = d->nextFetchChunk;
523 uint32_t start = (uint32_t)d->nextFetchPoint;
524
525 d->pool.add([this, chunk, start]()
526 {
527 uint32_t chunkpoints = d->chunkInfo.chunkPoints(chunk);
528 uint64_t chunkoffset = d->chunkInfo.chunkOffset(chunk);
529 uint32_t chunksize = d->chunkInfo.chunkSize(chunk);
530
531 LasStreamPtr lasStream = createStream();
532 std::istream& in(*lasStream);
533
534 std::vector<char> buf(chunksize);
535 in.seekg(chunkoffset);
536 in.read(buf.data(), buf.size());
537
538 int32_t tilepoints = chunkpoints - start;
539 las::TilePtr tile = std::make_unique<las::Tile>(chunk, tilepoints * d->header.pointSize);
540
541 lazperf::reader::chunk_decompressor decomp(d->header.pointFormat(), d->header.ebCount(),
542 buf.data());
543
544 // We have to decompress all the points, even if we're discarding the points at
545 // the front because nextFetchPoint isn't 0. Just reuse the front of the tile
546 // buffer for discarded points.
547 char *pos = tile->data();
548 for (uint32_t i = 0; i < chunkpoints; ++i)
549 {
550 decomp.decompress(pos);
551
552 // Advance the point location in the tile if we're keeping the point.
553 if (i >= start)
554 pos += d->header.pointSize;
555 }
556 {
557 std::unique_lock l(d->mutex);
558 for (las::TilePtr& t : d->tiles)
559 if (!t)
560 {
561 t = std::move(tile);
562 goto done;
563 }
564 d->tiles.push_back(std::move(tile));
565 }
566 done:
567 d->processedCv.notify_one();
568 });
569 d->nextFetchChunk++;
570 // After the first chunk, we always start at 0.
571 d->nextFetchPoint = 0;
572}
573

Callers

nothing calls this directly

Calls 12

numChunksMethod · 0.80
firstPointMethod · 0.80
chunkPointsMethod · 0.80
chunkOffsetMethod · 0.80
chunkSizeMethod · 0.80
ebCountMethod · 0.80
addMethod · 0.45
readMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
pointFormatMethod · 0.45
decompressMethod · 0.45

Tested by

no test coverage detected