Skip to content

Commit

Permalink
Allow zero results from TileDB query (#2967)
Browse files Browse the repository at this point in the history
  • Loading branch information
normanb committed Mar 10, 2020
1 parent c05e769 commit 3c720fb
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
1 change: 1 addition & 0 deletions pdal/PointTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ class PDAL_DLL StreamPointTable : public SimplePointTable
StreamPointTable(PointLayout& layout, point_count_t capacity)
: SimplePointTable(layout)
, m_capacity(capacity)
, m_numPoints(0)
, m_skips(m_capacity, false)
{}

Expand Down
17 changes: 12 additions & 5 deletions plugins/tiledb/io/TileDBReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,19 @@ bool TileDBReader::processPoint(PointRef& point)
}
}

for (DimInfo& dim : m_dims)
if (!setField(point, dim, m_offset))
throwError("Invalid dimension type when setting data.");
if (m_resultSize > 0)
{
for (DimInfo& dim : m_dims)
if (!setField(point, dim, m_offset))
throwError("Invalid dimension type when setting data.");

++m_offset;
return true;
++m_offset;
return true;
}
else
{
return false;
}
}

point_count_t TileDBReader::read(PointViewPtr view, point_count_t count)
Expand Down
18 changes: 18 additions & 0 deletions plugins/tiledb/test/TileDBReaderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,24 @@ class TileDBReaderTest : public ::testing::Test
EXPECT_EQ(table.numPoints(), 50);
}

TEST_F(TileDBReaderTest, read_zero_bbox)
{
tiledb::Context ctx;
tiledb::VFS vfs(ctx);
std::string pth(Support::datapath("tiledb/array"));
Options options;
options.add("array_name", pth);
options.add("bbox3d", "([1.1, 1.2], [1.1, 1.2], [1.1, 1.2])");

TileDBReader reader;
reader.setOptions(options);

FixedPointTable table(100);
reader.prepare(table);
reader.execute(table);
EXPECT_EQ(table.numPoints(), 0);
}

TEST_F(TileDBReaderTest, read)
{
class Checker : public Filter, public Streamable
Expand Down

0 comments on commit 3c720fb

Please sign in to comment.