Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't write chunks when there are no points. #81

Merged
merged 1 commit into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions bu/CopcSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ int CopcSupport::extraByteSize(const DimInfoList& dims) const
/// \return The offset of the chunk in the file.
uint64_t CopcSupport::newChunk(const VoxelKey& key, int32_t size, int32_t count)
{
// Chunks of size zero are a special case.
if (count == 0)
{
m_hierarchy[key] = { 0, 0, 0 };
return 0;
}

uint64_t chunkStart = m_pointPos;
m_pointPos += size;
assert(count <= (std::numeric_limits<int32_t>::max)() && count >= 0);
Expand Down
12 changes: 7 additions & 5 deletions bu/Processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <lazperf/lazperf.hpp>
#include <lazperf/writers.hpp>
#include <lazperf/readers.hpp>

#include "Processor.hpp"
#include "PyramidManager.hpp"
Expand Down Expand Up @@ -127,11 +128,6 @@ void Processor::sample(Index& accepted, Index& rejected)

void Processor::write(Index& accepted, Index& rejected)
{
/**
std::cerr << m_vi.key() << " Accepted/Rejected/num points = " <<
accepted.size() << "/" << rejected.size() << "/" << m_vi.numPoints() << "!\n";
**/

// If this is the final key, append any remaining file infos as accepted points and
// write the accepted points as compressed.
if (m_vi.key() == VoxelKey(0, 0, 0, 0))
Expand Down Expand Up @@ -469,6 +465,12 @@ void Processor::createChunk(const VoxelKey& key, pdal::PointViewPtr view)
{
using namespace pdal;

if (view->size() == 0)
{
m_manager.newChunk(key, 0, 0);
return;
}

PointLayoutPtr layout = view->layout();
int ebCount {0};
for (DimType dim : m_extraDims)
Expand Down