From c9d3028f852ea1f6bb378b69e32effedb6b362cb Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Sun, 7 Jul 2024 12:03:26 -0700 Subject: [PATCH] Fix multipolygon geometry iterator. --- .../cuspatial/range/multipolygon_range.cuh | 6 ++--- .../cuspatial_test/vector_factories.cuh | 24 +++++++++++++++---- cpp/tests/range/multipolygon_range_test.cu | 4 ++-- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/cpp/include/cuspatial/range/multipolygon_range.cuh b/cpp/include/cuspatial/range/multipolygon_range.cuh index 1aae07346..83379ba97 100644 --- a/cpp/include/cuspatial/range/multipolygon_range.cuh +++ b/cpp/include/cuspatial/range/multipolygon_range.cuh @@ -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. @@ -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; } diff --git a/cpp/include/cuspatial_test/vector_factories.cuh b/cpp/include/cuspatial_test/vector_factories.cuh index 9d3e8a31a..a261e6e3f 100644 --- a/cpp/include/cuspatial_test/vector_factories.cuh +++ b/cpp/include/cuspatial_test/vector_factories.cuh @@ -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: diff --git a/cpp/tests/range/multipolygon_range_test.cu b/cpp/tests/range/multipolygon_range_test.cu index 1ba2d9935..1e93ef136 100644 --- a/cpp/tests/range/multipolygon_range_test.cu +++ b/cpp/tests/range/multipolygon_range_test.cu @@ -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. @@ -1069,7 +1069,7 @@ class MultipolygonRangeOneTest : public MultipolygonRangeTestBase { void test_geometry_offsets_it() { rmm::device_uvector d_offsets = this->copy_geometry_offsets(); - auto expected = make_device_vector({0, 1}); + auto expected = make_device_vector({0, 2}); CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_offsets, expected); }