-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #1006 Closes #1007 I realized that the `join_quadtree_and_bounding_boxes()` tests are redundant to the `quadtree_point_in_polygon` tests and `quadtree_point_to_nearest_linestring` tests since the "small" test is duplicated in those. So I eliminated that test and added expectations for `join_quadtree_and_bounding_boxes` in those tests. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Robert Maynard (https://github.com/robertmaynard) - Paul Taylor (https://github.com/trxcllnt) URL: #1019
- Loading branch information
Showing
11 changed files
with
299 additions
and
649 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
cpp/tests/experimental/join/join_quadtree_and_bounding_boxes_test.cu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright (c) 2020-2023, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <cuspatial_test/base_fixture.hpp> | ||
#include <cuspatial_test/vector_equality.hpp> | ||
#include <cuspatial_test/vector_factories.cuh> | ||
|
||
#include <cuspatial/error.hpp> | ||
#include <cuspatial/experimental/point_quadtree.cuh> | ||
#include <cuspatial/experimental/spatial_join.cuh> | ||
|
||
// Note: the detailed correctness test of the join_quadtree_and_bounding_boxes() function is covered | ||
// by the quadtree_point_in_polygon_test_small.cu test file. | ||
|
||
template <typename T> | ||
struct JoinQuadtreeAndBoundingBoxesErrorTest : public cuspatial::test::BaseFixture { | ||
}; | ||
|
||
using TestTypes = ::testing::Types<float, double>; | ||
|
||
TYPED_TEST_CASE(JoinQuadtreeAndBoundingBoxesErrorTest, TestTypes); | ||
|
||
TYPED_TEST(JoinQuadtreeAndBoundingBoxesErrorTest, test_empty) | ||
{ | ||
using T = TypeParam; | ||
|
||
using namespace cuspatial; | ||
using cuspatial::vec_2d; | ||
using cuspatial::test::make_device_vector; | ||
|
||
vec_2d<T> v_min{0.0, 0.0}; | ||
T const scale{1.0}; | ||
uint8_t const max_depth{1}; | ||
|
||
auto empty_quadtree = point_quadtree_ref{nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}; | ||
|
||
auto empty_bboxes = rmm::device_uvector<box<T>>{0, this->stream()}; | ||
|
||
auto [polygon_idx, quad_idx] = cuspatial::join_quadtree_and_bounding_boxes(empty_quadtree, | ||
empty_bboxes.begin(), | ||
empty_bboxes.end(), | ||
v_min, | ||
scale, | ||
max_depth, | ||
this->stream()); | ||
|
||
auto expected_polygon_idx = rmm::device_uvector<std::uint32_t>{0, this->stream()}; | ||
auto expected_quad_idx = rmm::device_uvector<std::uint32_t>{0, this->stream()}; | ||
|
||
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected_polygon_idx, polygon_idx); | ||
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected_quad_idx, quad_idx); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright (c) 2020-2023, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <cuspatial/error.hpp> | ||
#include <cuspatial/point_quadtree.hpp> | ||
|
||
#include <cudf/column/column_view.hpp> | ||
#include <cudf/table/table.hpp> | ||
#include <cudf/table/table_view.hpp> | ||
|
||
#include <cudf_test/base_fixture.hpp> | ||
#include <cudf_test/column_utilities.hpp> | ||
#include <cudf_test/column_wrapper.hpp> | ||
#include <cudf_test/table_utilities.hpp> | ||
#include <cudf_test/type_lists.hpp> | ||
|
||
struct QuadtreeOnPointErrorTest : public cudf::test::BaseFixture { | ||
}; | ||
|
||
TYPED_TEST_CASE(QuadtreeOnPointIndexingTest, cudf::test::FloatingPointTypes); | ||
|
||
TEST_F(QuadtreeOnPointErrorTest, test_empty) | ||
{ | ||
using T = float; | ||
using namespace cudf::test; | ||
const int8_t max_depth = 1; | ||
uint32_t min_size = 1; | ||
double scale = 1.0; | ||
double x_min = 0, x_max = 1, y_min = 0, y_max = 1; | ||
|
||
fixed_width_column_wrapper<T> x({}); | ||
fixed_width_column_wrapper<T> y({}); | ||
|
||
auto quadtree_pair = | ||
cuspatial::quadtree_on_points(x, y, x_min, x_max, y_min, y_max, scale, max_depth, min_size); | ||
auto& quadtree = std::get<1>(quadtree_pair); | ||
|
||
CUSPATIAL_EXPECTS( | ||
quadtree->num_columns() == 5, | ||
"a quadtree table must have 5 columns (keys, levels, is_node, lengths, offsets)"); | ||
|
||
CUSPATIAL_EXPECTS(quadtree->num_rows() == 0, | ||
"the resulting quadtree must have a single quadrant"); | ||
} | ||
|
||
TEST_F(QuadtreeOnPointErrorTest, test_x_y_size_mismatch) | ||
{ | ||
using T = float; | ||
using namespace cudf::test; | ||
const int8_t max_depth = 1; | ||
uint32_t min_size = 1; | ||
double scale = 1.0; | ||
double x_min = 0, x_max = 1, y_min = 0, y_max = 1; | ||
|
||
fixed_width_column_wrapper<T> x({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); | ||
fixed_width_column_wrapper<T> y({0, 1, 2, 3, 4, 5, 6, 7, 8}); | ||
|
||
EXPECT_THROW( | ||
cuspatial::quadtree_on_points(x, y, x_min, x_max, y_min, y_max, scale, max_depth, min_size), | ||
cuspatial::logic_error); | ||
} |
Oops, something went wrong.