Skip to content

Commit

Permalink
Make hexbin streamable (#2172)
Browse files Browse the repository at this point in the history
* Make hexbin streamable.
Close #2170

* reflect OSRSpatialReference::IsProjected to pdal::SpatialReference (#2171)

* Remove private headers.  Use info for stage name.
  • Loading branch information
abellgithub committed Sep 14, 2018
1 parent 5eff6ba commit fa7f5ab
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 23 deletions.
37 changes: 32 additions & 5 deletions filters/HexBinFilter.cpp
Expand Up @@ -34,9 +34,9 @@

#include "HexBinFilter.hpp"

#include "private/hexer/HexGrid.hpp"
#include "private/hexer/HexIter.hpp"
#include <pdal/Polygon.hpp>
#include <pdal/StageFactory.hpp>

using namespace hexer;

Expand All @@ -50,6 +50,25 @@ static PluginInfo const s_info = PluginInfo(

CREATE_STATIC_STAGE(HexBin, s_info)

HexBin::HexBin()
{}


HexBin::~HexBin()
{}

std::string HexBin::getName() const
{
return s_info.name;
}


hexer::HexGrid *HexBin::grid() const
{
return m_grid.get();
}


void HexBin::addArgs(ProgramArgs& args)
{
args.add("sample_size", "Sample size for auto-edge length calculation",
Expand Down Expand Up @@ -82,16 +101,25 @@ void HexBin::ready(PointTableRef table)

void HexBin::filter(PointView& view)
{
PointRef p(view, 0);
for (PointId idx = 0; idx < view.size(); ++idx)
{
double x = view.getFieldAs<double>(pdal::Dimension::Id::X, idx);
double y = view.getFieldAs<double>(pdal::Dimension::Id::Y, idx);
m_grid->addPoint(x, y);
p.setPointId(idx);
processOne(p);
}
m_count += view.size();
}


bool HexBin::processOne(PointRef& point)
{
double x = point.getFieldAs<double>(Dimension::Id::X);
double y = point.getFieldAs<double>(Dimension::Id::Y);
m_grid->addPoint(x, y);
return true;
}


void HexBin::done(PointTableRef table)
{
m_grid->processSample();
Expand All @@ -110,7 +138,6 @@ void HexBin::done(PointTableRef table)
return;
}


std::ostringstream offsets;
offsets << "MULTIPOINT (";
for (int i = 0; i < 6; ++i)
Expand Down
28 changes: 15 additions & 13 deletions filters/HexBinFilter.hpp
Expand Up @@ -35,26 +35,30 @@
#pragma once

#include <pdal/Filter.hpp>
#include <pdal/Streamable.hpp>
#include <pdal/util/ProgramArgs.hpp>


#include "private/hexer/Mathpair.hpp"
#include "private/hexer/HexGrid.hpp"
#include "private/hexer/Processor.hpp"
namespace hexer
{
class HexGrid;
};

namespace pdal
{

class PDAL_DLL HexBin : public Filter
class PDAL_DLL HexBin : public Filter, public Streamable
{
public:
HexBin() : Filter()
{}
std::string getName() const { return "filters.hexbin"; }
HexBin();
~HexBin();

hexer::HexGrid* grid() const { return m_grid.get(); }
private:
HexBin& operator=(const HexBin&) = delete;
HexBin(const HexBin&) = delete;

std::string getName() const;
hexer::HexGrid* grid() const;

private:
std::unique_ptr<hexer::HexGrid> m_grid;
std::string m_xDimName;
std::string m_yDimName;
Expand All @@ -71,10 +75,8 @@ class PDAL_DLL HexBin : public Filter
virtual void addArgs(ProgramArgs& args);
virtual void ready(PointTableRef table);
virtual void filter(PointView& view);
virtual bool processOne(PointRef& point);
virtual void done(PointTableRef table);

HexBin& operator=(const HexBin&); // not implemented
HexBin(const HexBin&); // not implemented
};

} // namespace pdal
7 changes: 2 additions & 5 deletions test/data/pipeline/nonstreamable.json.in
Expand Up @@ -2,11 +2,8 @@
"pipeline":[
"@CMAKE_SOURCE_DIR@/test/data/las/1.2-with-color.las",
{
"type":"filters.hexbin",
"edge_size":0.0,
"threshold":10,
"sample_size":5000,
"precision":4
"type":"filters.chipper"
"capacity": 100,
},
"@CMAKE_SOURCE_DIR@/test/temp/hexbin.las"
]
Expand Down

0 comments on commit fa7f5ab

Please sign in to comment.