Cell::PooledStack LasZipStorage::read( const arbiter::Endpoint& endpoint, PointPool& pool, const Id& id) const { const std::string basename(m_metadata.basename(id) + ".laz"); std::string localFile(endpoint.prefixedRoot() + basename); if (!endpoint.isLocal()) { const std::string tmp(arbiter::fs::getTempPath()); localFile = tmp + basename; static const arbiter::drivers::Fs fs; fs.put(localFile, *io::ensureGet(endpoint, basename)); } CellTable table(pool, makeUnique<Schema>(Schema::normalize(pool.schema()))); if (auto preview = Executor::get().preview(localFile)) { table.resize(preview->numPoints); } if (!Executor::get().run(table, localFile)) { throw std::runtime_error("Could not execute laszip chunk " + localFile); } return table.acquire(); }
virtual Cell::PooledStack read( const arbiter::Endpoint& endpoint, PointPool& pool, const Id& id) const override { auto data(io::ensureGet(endpoint, m_metadata.basename(id))); const Tail tail(*data, m_tailFields); const char* pos(data->data()); const Schema& schema(pool.schema()); const std::size_t pointSize(schema.pointSize()); const std::size_t numPoints(data->size() / pointSize); const std::size_t numBytes(data->size() + tail.size()); BinaryPointTable table(schema); pdal::PointRef pointRef(table, 0); if (pointSize * numPoints != data->size()) { throw std::runtime_error("Invalid binary chunk size"); } if (tail.numPoints() && tail.numPoints() != numPoints) { throw std::runtime_error("Invalid binary chunk numPoints"); } if (tail.numBytes() && tail.numBytes() != numBytes) { throw std::runtime_error("Invalid binary chunk numBytes"); } Data::PooledStack dataStack(pool.dataPool().acquire(numPoints)); Cell::PooledStack cellStack(pool.cellPool().acquire(numPoints)); for (Cell& cell : cellStack) { table.setPoint(pos); Data::PooledNode dataNode(dataStack.popOne()); std::copy(pos, pos + pointSize, *dataNode); cell.set(pointRef, std::move(dataNode)); pos += pointSize; } assert(dataStack.empty()); return cellStack; }
Cell::PooledStack LazPerfStorage::read( const arbiter::Endpoint& endpoint, PointPool& pool, const Id& id) const { auto compressed(io::ensureGet(endpoint, m_metadata.basename(id))); const Tail tail(*compressed, m_tailFields); const Schema& schema(pool.schema()); const std::size_t pointSize(schema.pointSize()); const std::size_t numPoints(tail.numPoints()); const std::size_t numBytes(compressed->size() + tail.size()); BinaryPointTable table(schema); pdal::PointRef pointRef(table, 0); if (id >= m_metadata.structure().coldIndexBegin() && !numPoints) { throw std::runtime_error("Invalid lazperf chunk - no numPoints"); } if (tail.numBytes() && tail.numBytes() != numBytes) { std::cout << tail.numBytes() << " != " << numBytes << std::endl; throw std::runtime_error("Invalid lazperf chunk numBytes"); } Data::PooledStack dataStack(pool.dataPool().acquire(numPoints)); Cell::PooledStack cellStack(pool.cellPool().acquire(numPoints)); DecompressionStream stream(*compressed); pdal::LazPerfDecompressor<DecompressionStream> decompressor( stream, schema.pdalLayout().dimTypes()); for (Cell& cell : cellStack) { Data::PooledNode dataNode(dataStack.popOne()); table.setPoint(*dataNode); decompressor.decompress(*dataNode, pointSize); cell.set(pointRef, std::move(dataNode)); } assert(dataStack.empty()); return cellStack; }
PooledInfoStack Compression::decompress( const std::vector<char>& data, const std::size_t numPoints, PointPool& pointPool) { PooledDataStack dataStack(pointPool.dataPool().acquire(numPoints)); PooledInfoStack infoStack(pointPool.infoPool().acquire(numPoints)); BinaryPointTable table(pointPool.schema()); pdal::PointRef pointRef(table, 0); const std::size_t pointSize(pointPool.schema().pointSize()); DecompressionStream decompressionStream(data); pdal::LazPerfDecompressor<DecompressionStream> decompressor( decompressionStream, pointPool.schema().pdalLayout().dimTypes()); RawInfoNode* info(infoStack.head()); char* pos(nullptr); while (info) { info->construct(dataStack.popOne()); pos = info->val().data(); decompressor.decompress(pos, pointSize); table.setPoint(pos); info->val().point(pointRef); info = info->next(); } return infoStack; }
std::unique_ptr<PooledPointTable> PooledPointTable::create( PointPool& pointPool, Process process, const Delta* delta, const Origin origin) { if (!delta) { return makeUnique<PooledPointTable>(pointPool, process, origin); } else { return makeUnique<ConvertingPointTable>( pointPool, process, origin, *delta, makeUnique<Schema>(Schema::normalize(pointPool.schema()))); } }