libcuspatial  23.12.00
Loading...
Searching...
No Matches
geometry_fixtures.hpp
1/*
2 * Copyright (c) 2023, NVIDIA CORPORATION.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <cuspatial_test/base_fixture.hpp>
20#include <cuspatial_test/column_factories.hpp>
21
23#include <cuspatial/types.hpp>
24
25#include <rmm/cuda_stream_view.hpp>
26#include <rmm/mr/device/per_device_resource.hpp>
27
28#include <cudf/utilities/default_stream.hpp>
29
30namespace cuspatial {
31namespace test {
32
38template <typename T>
40 protected:
41 // TODO: explore SetUpTestSuite to perform per-test-suite initialization, saving expenses.
42 // However, this requires making `stream` method a static member.
43 EmptyGeometryColumnBase(rmm::cuda_stream_view stream)
44 {
46
47 std::tie(_, empty_point_column) = make_point_column<T>({}, stream);
48 std::tie(_, empty_linestring_column) = make_linestring_column<T>({0}, {}, stream);
49 std::tie(_, empty_polygon_column) = make_polygon_column<T>({0}, {0}, {}, stream);
50 std::tie(_, empty_multipoint_column) = make_point_column<T>({0}, {}, stream);
51 std::tie(_, empty_multilinestring_column) = make_linestring_column<T>({0}, {0}, {}, stream);
52 std::tie(_, empty_multipolygon_column) = make_polygon_column<T>({0}, {0}, {0}, {}, stream);
53 }
54
55 geometry_column_view empty_point()
56 {
58 empty_point_column->view(), collection_type_id::SINGLE, geometry_type_id::POINT);
59 }
60
61 geometry_column_view empty_multipoint()
62 {
64 empty_multipoint_column->view(), collection_type_id::MULTI, geometry_type_id::POINT);
65 }
66
67 geometry_column_view empty_linestring()
68 {
70 empty_linestring_column->view(), collection_type_id::SINGLE, geometry_type_id::LINESTRING);
71 }
72
73 geometry_column_view empty_multilinestring()
74 {
75 return geometry_column_view(empty_multilinestring_column->view(),
76 collection_type_id::MULTI,
77 geometry_type_id::LINESTRING);
78 }
79
80 geometry_column_view empty_polygon()
81 {
83 empty_polygon_column->view(), collection_type_id::SINGLE, geometry_type_id::POLYGON);
84 }
85
86 geometry_column_view empty_multipolygon()
87 {
89 empty_multipolygon_column->view(), collection_type_id::MULTI, geometry_type_id::POLYGON);
90 }
91
92 std::unique_ptr<cudf::column> empty_point_column;
93 std::unique_ptr<cudf::column> empty_linestring_column;
94 std::unique_ptr<cudf::column> empty_polygon_column;
95 std::unique_ptr<cudf::column> empty_multipoint_column;
96 std::unique_ptr<cudf::column> empty_multilinestring_column;
97 std::unique_ptr<cudf::column> empty_multipolygon_column;
98};
99
105template <typename T>
107 protected:
108 // TODO: explore SetUpTestSuite to perform per-test-suite initialization, saving expenses.
109 // However, this requires making `stream` method a static member.
110 OneGeometryColumnBase(rmm::cuda_stream_view stream)
111 {
113
114 std::tie(_, one_point_column) = make_point_column<T>({0, 0}, stream);
115 std::tie(_, one_linestring_column) = make_linestring_column<T>({0, 2}, {0, 0, 1, 1}, stream);
116 std::tie(_, one_polygon_column) =
117 make_polygon_column<T>({0, 1}, {0, 4}, {0, 0, 1, 0, 1, 1, 0, 0}, stream);
118 std::tie(_, one_multipoint_column) = make_point_column<T>({0, 1}, {0, 0}, stream);
119 std::tie(_, one_multilinestring_column) =
120 make_linestring_column<T>({0, 1}, {0, 2}, {0, 0, 1, 1}, stream);
121 std::tie(_, one_multipolygon_column) =
122 make_polygon_column<T>({0, 1}, {0, 1}, {0, 4}, {0, 0, 1, 0, 1, 1, 0, 0}, stream);
123 }
124
125 geometry_column_view one_point()
126 {
128 one_point_column->view(), collection_type_id::SINGLE, geometry_type_id::POINT);
129 }
130
131 geometry_column_view one_multipoint()
132 {
134 one_multipoint_column->view(), collection_type_id::MULTI, geometry_type_id::POINT);
135 }
136
137 geometry_column_view one_linestring()
138 {
140 one_linestring_column->view(), collection_type_id::SINGLE, geometry_type_id::LINESTRING);
141 }
142
143 geometry_column_view one_multilinestring()
144 {
146 one_multilinestring_column->view(), collection_type_id::MULTI, geometry_type_id::LINESTRING);
147 }
148
149 geometry_column_view one_polygon()
150 {
152 one_polygon_column->view(), collection_type_id::SINGLE, geometry_type_id::POLYGON);
153 }
154
155 geometry_column_view one_multipolygon()
156 {
158 one_multipolygon_column->view(), collection_type_id::MULTI, geometry_type_id::POLYGON);
159 }
160
161 std::unique_ptr<cudf::column> one_point_column;
162 std::unique_ptr<cudf::column> one_linestring_column;
163 std::unique_ptr<cudf::column> one_polygon_column;
164 std::unique_ptr<cudf::column> one_multipoint_column;
165 std::unique_ptr<cudf::column> one_multilinestring_column;
166 std::unique_ptr<cudf::column> one_multipolygon_column;
167};
168
169template <typename T>
171 EmptyGeometryColumnFixture() : EmptyGeometryColumnBase<T>(this->stream()) {}
172};
173
174template <typename T>
176 OneGeometryColumnFixture() : EmptyGeometryColumnBase<T>(this->stream()) {}
177};
178
180 public EmptyGeometryColumnBase<float>,
181 public OneGeometryColumnBase<float> {
183 : EmptyGeometryColumnBase<float>(this->stream()), OneGeometryColumnBase<float>(this->stream())
184 {
185 }
186};
187
189 public EmptyGeometryColumnBase<float>,
190 public EmptyGeometryColumnBase<double> {
192 : EmptyGeometryColumnBase<float>(this->stream()),
193 EmptyGeometryColumnBase<double>(this->stream())
194 {
195 }
196};
197
198} // namespace test
199} // namespace cuspatial
A non-owning, immutable view of a geometry column.
Base test fixture class from which libcuspatial test with no parameterization or only with type param...
Test Fixture that initializes empty geometry columns.
Test Fixture that initializes one geometry column.
rmm::cuda_stream_view stream()
Returns cuda_stream_view that should be used for computation in tests inheriting from this fixture.
collection_type_id
The underlying collection type of a geometry_column_view.
Definition types.hpp:31