Skip to content

Commit

Permalink
Fix multipolygon geometry iterator. (#1402)
Browse files Browse the repository at this point in the history
This PR fixes a bug in the multipolygon geometry iterator. The geometry iterator was returning part iterators by mistake, which masked an issue that we were patching out in rapids-cmake's CCCL. See rapidsai/rapids-cmake#511.

With this fix, we can remove that patch from rapids-cmake's CCCL: rapidsai/rapids-cmake#640

Authors:
  - Bradley Dice (https://github.com/bdice)
  - Paul Taylor (https://github.com/trxcllnt)

Approvers:
  - Michael Schellenberger Costa (https://github.com/miscco)
  - Mark Harris (https://github.com/harrism)
  - Michael Wang (https://github.com/isVoid)
  - Paul Taylor (https://github.com/trxcllnt)

URL: #1402
  • Loading branch information
bdice authored Jul 9, 2024
1 parent e51e8b0 commit 20ef0e7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
6 changes: 3 additions & 3 deletions cpp/include/cuspatial/range/multipolygon_range.cuh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, NVIDIA CORPORATION.
* Copyright (c) 2023-2024, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -115,10 +115,10 @@ class multipolygon_range {
CUSPATIAL_HOST_DEVICE auto point_end();

/// Return the iterator to the first geometry offset in the range.
CUSPATIAL_HOST_DEVICE auto geometry_offset_begin() { return _part_begin; }
CUSPATIAL_HOST_DEVICE auto geometry_offset_begin() { return _geometry_begin; }

/// Return the iterator to the one past the last geometry offset in the range.
CUSPATIAL_HOST_DEVICE auto geometry_offset_end() { return _part_end; }
CUSPATIAL_HOST_DEVICE auto geometry_offset_end() { return _geometry_end; }

/// Return the iterator to the first part offset in the range.
CUSPATIAL_HOST_DEVICE auto part_offset_begin() { return _part_begin; }
Expand Down
24 changes: 20 additions & 4 deletions cpp/include/cuspatial_test/vector_factories.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,26 @@ class multipolygon_array {
{
auto [geometry_offsets, part_offsets, ring_offsets, coordinates] = arr.to_host();

return os << "Geometry Offsets:\n\t{" << geometry_offsets << "}\n"
<< "Part Offsets:\n\t{" << part_offsets << "}\n"
<< "Ring Offsets: \n\t{" << ring_offsets << "}\n"
<< "Coordinates: \n\t{" << coordinates << "}\n";
auto print_vector = [&](auto const& vec) {
for (auto it = vec.begin(); it != vec.end(); it++) {
os << *it;
if (std::next(it) != vec.end()) { os << ", "; }
}
};

os << "Geometry Offsets:\n\t{";
print_vector(geometry_offsets);
os << "}\n";
os << "Part Offsets:\n\t{";
print_vector(part_offsets);
os << "}\n";
os << "Ring Offsets: \n\t{";
print_vector(ring_offsets);
os << "}\n";
os << "Coordinates: \n\t{";
print_vector(coordinates);
os << "}\n";
return os;
}

protected:
Expand Down
4 changes: 2 additions & 2 deletions cpp/tests/range/multipolygon_range_test.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, NVIDIA CORPORATION.
* Copyright (c) 2023-2024, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -1069,7 +1069,7 @@ class MultipolygonRangeOneTest : public MultipolygonRangeTestBase<T> {
void test_geometry_offsets_it()
{
rmm::device_uvector<std::size_t> d_offsets = this->copy_geometry_offsets();
auto expected = make_device_vector<std::size_t>({0, 1});
auto expected = make_device_vector<std::size_t>({0, 2});

CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_offsets, expected);
}
Expand Down

0 comments on commit 20ef0e7

Please sign in to comment.