| 572 | } |
| 573 | |
| 574 | void LasReader::queueNextStandardChunk() |
| 575 | { |
| 576 | const uint64_t chunkSize = 50'000; |
| 577 | |
| 578 | if (d->nextFetchPoint >= d->end) |
| 579 | return; |
| 580 | |
| 581 | int chunk = d->nextFetchChunk; |
| 582 | uint64_t start = d->nextFetchPoint; |
| 583 | uint64_t count = (std::min)(chunkSize, d->end - start); |
| 584 | d->pool.add([this, chunk, count, start]() |
| 585 | { |
| 586 | LasStreamPtr lasStream = createStream(); |
| 587 | std::istream& in(*lasStream); |
| 588 | |
| 589 | las::TilePtr tile = std::make_unique<las::Tile>(chunk, count * d->header.pointSize); |
| 590 | in.seekg(d->header.pointOffset + start * d->header.pointSize); |
| 591 | in.read(tile->data(), tile->size()); |
| 592 | |
| 593 | { |
| 594 | std::unique_lock l(d->mutex); |
| 595 | for (las::TilePtr& t : d->tiles) |
| 596 | if (!t) |
| 597 | { |
| 598 | t = std::move(tile); |
| 599 | goto done; |
| 600 | } |
| 601 | d->tiles.push_back(std::move(tile)); |
| 602 | } |
| 603 | done: |
| 604 | d->processedCv.notify_one(); |
| 605 | }); |
| 606 | |
| 607 | // This check is just to prevent overflow. |
| 608 | if (d->nextFetchPoint > (std::numeric_limits<uint64_t>::max)() - chunkSize) |
| 609 | d->nextFetchPoint = d->end; |
| 610 | else |
| 611 | d->nextFetchPoint += chunkSize; |
| 612 | d->nextFetchChunk++; |
| 613 | } |
| 614 | |
| 615 | void LasReader::readExtraBytesVlr() |
| 616 | { |