From 84cc7032e65affdc2bc883228fa651986fb62509 Mon Sep 17 00:00:00 2001 From: Andrew Bell Date: Fri, 22 Jan 2021 08:56:19 -0500 Subject: [PATCH] Support LAS start --- epf/Epf.cpp | 32 +++++++++++++++++++++++++++++++- epf/EpfTypes.hpp | 4 ++++ epf/FileProcessor.cpp | 7 +++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/epf/Epf.cpp b/epf/Epf.cpp index d54ecfd..033ba7f 100644 --- a/epf/Epf.cpp +++ b/epf/Epf.cpp @@ -20,6 +20,7 @@ #include +#include #include #include #include @@ -185,6 +186,7 @@ PointCount Epf::createFileInfo(const StringList& input, StringList dimNames, { using namespace pdal; + std::vector tempFileInfos; std::vector filenames; PointCount totalPoints = 0; @@ -247,13 +249,41 @@ PointCount Epf::createFileInfo(const StringList& input, StringList dimNames, std::cerr << "Files have mismatched SRS values. Using SRS from '" << m_srsFileInfo.filename << "'.\n"; fi.srs = qi.m_srs; - fileInfos.push_back(fi); + tempFileInfos.push_back(fi); if (!m_srsFileInfo.valid() && qi.m_srs.valid()) m_srsFileInfo = fi; m_grid.expand(qi.m_bounds, qi.m_pointCount); totalPoints += fi.numPoints; } + + +#ifdef PDAL_LAS_START + PointCount ChunkSize = 5000000; + for (const FileInfo& fi : tempFileInfos) + { + if (fi.driver != "readers.las" || fi.numPoints < ChunkSize) + { + fileInfos.push_back(fi); + continue; + } + PointCount remaining = fi.numPoints; + pdal::PointId start = 0; + while (remaining) + { + FileInfo lasFi(fi); + lasFi.numPoints = (std::min)(ChunkSize, remaining); + lasFi.start = start; + fileInfos.push_back(lasFi); + + start += ChunkSize; + remaining -= lasFi.numPoints; + } + } +#else + fileInfos = std::move(tempFileInfos); +#endif + return totalPoints; } diff --git a/epf/EpfTypes.hpp b/epf/EpfTypes.hpp index f0740e6..895d6e8 100644 --- a/epf/EpfTypes.hpp +++ b/epf/EpfTypes.hpp @@ -41,10 +41,14 @@ constexpr int NumFileProcessors = 8; struct FileInfo { + FileInfo() : numPoints(0), start(0) + {} + std::string filename; std::string driver; DimInfoList dimInfo; uint64_t numPoints; + uint64_t start; pdal::BOX3D bounds; pdal::SpatialReference srs; diff --git a/epf/FileProcessor.cpp b/epf/FileProcessor.cpp index 07e498b..f02faa4 100644 --- a/epf/FileProcessor.cpp +++ b/epf/FileProcessor.cpp @@ -14,6 +14,7 @@ #include "FileProcessor.hpp" #include "../untwine/ProgressWriter.hpp" +#include #include #include @@ -29,8 +30,14 @@ FileProcessor::FileProcessor(const FileInfo& fi, size_t pointSize, const Grid& g void FileProcessor::run() { + pdal::Options opts; opts.add("filename", m_fi.filename); + opts.add("count", m_fi.numPoints); +#ifdef PDAL_LAS_START + if (m_fi.driver == "readers.las") + opts.add("start", m_fi.start); +#endif pdal::StageFactory factory; pdal::Stage *s = factory.createStage(m_fi.driver);