From 6421a7fadc9e99cbe29eb54994b9e974dd49319b Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Mon, 29 Nov 2021 16:48:42 -0600 Subject: [PATCH] sort based on GPStime for COPC output (#94) --- bu/Processor.cpp | 19 ++++++++++++++++++- bu/Processor.hpp | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/bu/Processor.cpp b/bu/Processor.cpp index bbcf12c..f915066 100644 --- a/bu/Processor.cpp +++ b/bu/Processor.cpp @@ -450,7 +450,7 @@ void Processor::writeEptFile(const std::string& filename, pdal::PointTableRef ta pdal::Options wopts; wopts.add("extra_dims", "all"); wopts.add("software_id", "Entwine 1.0"); - wopts.add("compression", "laszip"); + wopts.add("compression", "lazperf"); wopts.add("filename", filename); wopts.add("offset_x", m_b.offset[0]); wopts.add("offset_y", m_b.offset[1]); @@ -470,6 +470,19 @@ void Processor::writeEptFile(const std::string& filename, pdal::PointTableRef ta w->execute(table); } +void Processor::sortChunk(const VoxelKey& key, pdal::PointViewPtr view) +{ + + using namespace pdal; + auto cmp = [](const PointRef& p1, const PointRef& p2) + { + bool result = p1.compare(pdal::Dimension::Id::GpsTime, p2); + return result; + }; + + std::stable_sort(view->begin(), view->end(), cmp); + +} void Processor::createChunk(const VoxelKey& key, pdal::PointViewPtr view) { using namespace pdal; @@ -480,7 +493,11 @@ void Processor::createChunk(const VoxelKey& key, pdal::PointViewPtr view) return; } + if (view->layout()->hasDim(Dimension::Id::GpsTime)) + sortChunk(key, view); + PointLayoutPtr layout = view->layout(); + int ebCount {0}; for (DimType dim : m_extraDims) ebCount += layout->dimSize(dim.m_id); diff --git a/bu/Processor.hpp b/bu/Processor.hpp index 140ca2a..a14ddd2 100644 --- a/bu/Processor.hpp +++ b/bu/Processor.hpp @@ -59,6 +59,7 @@ class Processor void writeEptFile(const std::string& filename, pdal::PointTableRef table, pdal::PointViewPtr view); void createChunk(const VoxelKey& key, pdal::PointViewPtr view); + void sortChunk(const VoxelKey& key, pdal::PointViewPtr view); void fillPointBuf(pdal::PointRef& point, std::vector& buf); VoxelInfo m_vi;