Skip to content

Commit

Permalink
tiledb: support duplicate coordinate values (#3047)
Browse files Browse the repository at this point in the history
  • Loading branch information
normanb committed Apr 28, 2020
1 parent 1652d55 commit 90d280b
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
4 changes: 3 additions & 1 deletion plugins/tiledb/io/TileDBWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,9 @@ void TileDBWriter::initialize()
{
opts = m_args->m_defaults["coords"];
}

#if TILEDB_VERSION_MAJOR > 1
m_schema->set_allows_dups(true);
#endif
m_schema->set_coords_filter_list(
*createFilterList(*m_ctx, opts));
}
Expand Down
56 changes: 56 additions & 0 deletions plugins/tiledb/test/TileDBWriterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,4 +387,60 @@ namespace pdal
tiledb::FilterList flAtts = att.filter_list();
EXPECT_EQ(flAtts.nfilters(), 0U);
}

#if TILEDB_VERSION_MAJOR > 1
TEST_F(TileDBWriterTest, dup_points)
{
Options reader_options;
FauxReader reader;
BOX3D bounds(1.0, 1.0, 1.0, 2.0, 2.0, 2.0);
reader_options.add("bounds", bounds);
reader_options.add("mode", "constant");
reader_options.add("count", count);
reader.setOptions(reader_options);

tiledb::Context ctx;
tiledb::VFS vfs(ctx);
std::string pth = Support::temppath("tiledb_test_dups");

Options writer_options;
writer_options.add("array_name", pth);

if (vfs.is_dir(pth))
{
vfs.remove_dir(pth);
}

TileDBWriter writer;
writer.setOptions(writer_options);
writer.setInput(reader);

FixedPointTable table(count);
writer.prepare(table);
writer.execute(table);

tiledb::Array array(ctx, pth, TILEDB_READ);
auto domain = array.non_empty_domain<double>();
std::vector<double> subarray;

for (const auto& kv: domain)
{
subarray.push_back(kv.second.first);
subarray.push_back(kv.second.second);
}

tiledb::Query q(ctx, array, TILEDB_READ);
q.set_subarray(subarray);

auto max_el = array.max_buffer_elements(subarray);
std::vector<double> coords(max_el[TILEDB_COORDS].second);
q.set_coordinates(coords);
q.submit();
array.close();

EXPECT_EQ(reader.count() * 3, coords.size());
for (const double& v : coords)
EXPECT_EQ(v, 1.0);
}
#endif
}

0 comments on commit 90d280b

Please sign in to comment.