Skip to content

Commit

Permalink
fix for reading H3 dimension
Browse files Browse the repository at this point in the history
  • Loading branch information
ibell13 committed Oct 1, 2024
1 parent 363201e commit 98b857c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 9 additions & 2 deletions filters/HexBinFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ void HexBin::initialize()
}


void HexBin::prepared(PointTableRef table)
{
const PointLayoutPtr layout(table.layout());
m_h3Dim = layout->hasDim(Dimension::Id::H3);
}


void HexBin::ready(PointTableRef table)
{
m_count = 0;
Expand Down Expand Up @@ -169,7 +176,7 @@ void HexBin::filter(PointView& view)

bool HexBin::processOne(PointRef& point)
{
if (m_isH3 && point.hasDim(Dimension::Id::H3))
if (m_isH3 && m_h3Dim)
{
// this should throw a more descriptive error
m_grid->addH3Dim(point.getFieldAs<H3Index>(Dimension::Id::H3));
Expand All @@ -188,7 +195,7 @@ bool HexBin::processOne(PointRef& point)
void HexBin::spatialReferenceChanged(const SpatialReference& srs)
{
m_srs = srs;
if (!m_grid->checkSRS(m_srs)) {
if (!m_grid->checkSRS(m_srs) && !m_h3Dim) {
std::ostringstream oss;
oss << "Cannot find H3 hexbin locations with spatial reference: ("
<< m_srs.getProj4() << ")! Input must be EPSG:4326";
Expand Down
2 changes: 2 additions & 0 deletions filters/HexBinFilter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ class PDAL_DLL HexBin : public Filter, public Streamable
int m_h3Res;
SpatialReference m_srs;
std::string m_driver;
bool m_h3Dim;

virtual void addArgs(ProgramArgs& args);
virtual void initialize();
virtual void prepared(PointTableRef table);
virtual void ready(PointTableRef table);
virtual void filter(PointView& view);
virtual bool processOne(PointRef& point);
Expand Down

0 comments on commit 98b857c

Please sign in to comment.