Skip to content

Commit

Permalink
Support LAS start (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub authored Jul 21, 2021
1 parent 248d463 commit e2f4cbd
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
32 changes: 31 additions & 1 deletion epf/Epf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <unordered_set>

#include <pdal/pdal_features.hpp>
#include <pdal/Dimension.hpp>
#include <pdal/Metadata.hpp>
#include <pdal/StageFactory.hpp>
Expand Down Expand Up @@ -198,6 +199,7 @@ PointCount Epf::createFileInfo(const StringList& input, StringList dimNames,
{
using namespace pdal;

std::vector<FileInfo> tempFileInfos;
std::vector<std::string> filenames;
PointCount totalPoints = 0;

Expand Down Expand Up @@ -271,13 +273,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;
}

Expand Down
4 changes: 4 additions & 0 deletions epf/EpfTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
7 changes: 7 additions & 0 deletions epf/FileProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "FileProcessor.hpp"
#include "../untwine/ProgressWriter.hpp"

#include <pdal/pdal_features.hpp>
#include <pdal/StageFactory.hpp>
#include <pdal/filters/StreamCallbackFilter.hpp>

Expand All @@ -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);
Expand Down

0 comments on commit e2f4cbd

Please sign in to comment.