Skip to content

Commit

Permalink
Don't write chunks when there are no points.
Browse files Browse the repository at this point in the history
Close #80
  • Loading branch information
abellgithub committed Sep 30, 2021
1 parent 1b482fc commit 9c4013a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
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

0 comments on commit 9c4013a

Please sign in to comment.