Skip to content

Commit

Permalink
Check for empty PointView in ELM filter
Browse files Browse the repository at this point in the history
  • Loading branch information
chambbj committed Feb 11, 2020
1 parent a8f82c2 commit 2aa48b8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions filters/ELMFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ void ELMFilter::addDimensions(PointLayoutPtr layout)

void ELMFilter::filter(PointView& view)
{
if (!view.size())
return;

BOX2D bounds;
calculateBounds(view, bounds);

Expand Down
23 changes: 23 additions & 0 deletions test/unit/filters/ELMFilterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@

#include <pdal/pdal_test_main.hpp>

#include <io/BufferReader.hpp>
#include <io/TextReader.hpp>
#include <filters/ELMFilter.hpp>
#include <pdal/StageFactory.hpp>

#include "Support.hpp"

Expand Down Expand Up @@ -98,3 +100,24 @@ TEST(ELMFilterTest, test2)
EXPECT_EQ(noise, 7);
}

TEST(ELMFilterTest, emptyView)
{
PointTable table;
table.layout()->registerDims(
{Dimension::Id::X, Dimension::Id::Y, Dimension::Id::Z});

PointViewPtr view(new PointView(table));
BufferReader reader;
reader.addView(view);

StageFactory factory;
Stage* filter(factory.createStage("filters.elm"));
filter->setInput(reader);
filter->prepare(table);

PointViewSet s = filter->execute(table);
EXPECT_EQ(s.size(), 1u);

PointViewPtr v = *s.begin();
EXPECT_EQ(v->size(), 0u);
}

0 comments on commit 2aa48b8

Please sign in to comment.