From 493eedb029b057b34af3e26bd9557cc08bdb2186 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Wed, 26 Apr 2023 03:11:52 +0000 Subject: [PATCH 01/18] consolidate bounding boxes headers and name consistently --- cpp/CMakeLists.txt | 4 +- cpp/include/cuspatial/bounding_box.cuh | 82 -------- cpp/include/cuspatial/bounding_boxes.cuh | 179 +++++++++++++++++ ...on_bounding_box.hpp => bounding_boxes.hpp} | 28 +++ cpp/include/cuspatial/detail/bounding_box.cuh | 90 --------- .../cuspatial/detail/bounding_boxes.cuh | 185 ++++++++++++++++++ .../detail/linestring_bounding_boxes.cuh | 73 ------- .../detail/polygon_bounding_boxes.cuh | 86 -------- .../cuspatial/linestring_bounding_box.hpp | 55 ------ .../cuspatial/linestring_bounding_boxes.cuh | 73 ------- .../cuspatial/polygon_bounding_boxes.cuh | 82 -------- ...ng_box.cu => linestring_bounding_boxes.cu} | 3 +- ...nding_box.cu => polygon_bounding_boxes.cu} | 2 +- .../trajectory/trajectory_bounding_boxes.cu | 2 +- .../join_quadtree_and_bounding_boxes_test.cpp | 2 +- .../join/quadtree_point_in_polygon_test.cpp | 2 +- .../quadtree_point_in_polygon_test_large.cu | 2 +- .../quadtree_point_in_polygon_test_small.cu | 2 +- ...dtree_point_to_nearest_linestring_test.cpp | 2 +- ..._point_to_nearest_linestring_test_small.cu | 2 +- .../linestring_bounding_boxes_test.cpp | 2 +- .../linestring_bounding_boxes_test.cu | 2 +- .../point_bounding_boxes_test.cu | 2 +- .../polygon_bounding_boxes_test.cpp | 2 +- .../polygon_bounding_boxes_test.cu | 2 +- 25 files changed, 408 insertions(+), 558 deletions(-) delete mode 100644 cpp/include/cuspatial/bounding_box.cuh create mode 100644 cpp/include/cuspatial/bounding_boxes.cuh rename cpp/include/cuspatial/{polygon_bounding_box.hpp => bounding_boxes.hpp} (64%) delete mode 100644 cpp/include/cuspatial/detail/bounding_box.cuh create mode 100644 cpp/include/cuspatial/detail/bounding_boxes.cuh delete mode 100644 cpp/include/cuspatial/detail/linestring_bounding_boxes.cuh delete mode 100644 cpp/include/cuspatial/detail/polygon_bounding_boxes.cuh delete mode 100644 cpp/include/cuspatial/linestring_bounding_box.hpp delete mode 100644 cpp/include/cuspatial/linestring_bounding_boxes.cuh delete mode 100644 cpp/include/cuspatial/polygon_bounding_boxes.cuh rename cpp/src/spatial/{linestring_bounding_box.cu => linestring_bounding_boxes.cu} (98%) rename cpp/src/spatial/{polygon_bounding_box.cu => polygon_bounding_boxes.cu} (99%) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 1996f5918..d1cdb4e85 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -122,8 +122,8 @@ add_library(cuspatial src/join/quadtree_point_in_polygon.cu src/join/quadtree_point_to_nearest_linestring.cu src/join/quadtree_bbox_filtering.cu - src/spatial/polygon_bounding_box.cu - src/spatial/linestring_bounding_box.cu + src/spatial/linestring_bounding_boxes.cu + src/spatial/polygon_bounding_boxes.cu src/spatial/point_in_polygon.cu src/spatial/pairwise_point_in_polygon.cu src/spatial_window/spatial_window.cu diff --git a/cpp/include/cuspatial/bounding_box.cuh b/cpp/include/cuspatial/bounding_box.cuh deleted file mode 100644 index 78c213f96..000000000 --- a/cpp/include/cuspatial/bounding_box.cuh +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2022, 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. - */ - -#pragma once - -#include - -#include - -namespace cuspatial { - -/** - * @addtogroup spatial_relationship - * @{ - */ - -/** - * @brief Compute the spatial bounding boxes of sequences of points. - * - * Computes a bounding box around all points within each group (consecutive points with the same - * ID). This function can be applied to trajectory data, polygon vertices, linestring vertices, or - * any grouped point data. - * - * Before merging bounding boxes, each point may be expanded into a bounding box using an - * optional @p expansion_radius. The point is expanded to a box with coordinates - * `(point.x - expansion_radius, point.y - expansion_radius)` and - * `(point.x + expansion_radius, point.y + expansion_radius)`. - * - * @note Assumes Object IDs and points are presorted by ID. - * - * @tparam IdInputIt Iterator over object IDs. Must meet the requirements of - * [LegacyRandomAccessIterator][LinkLRAI] and be device-readable. - * @tparam PointInputIt Iterator over points. Must meet the requirements of - * [LegacyRandomAccessIterator][LinkLRAI] and be device-readable. - * @tparam BoundingBoxOutputIt Iterator over output bounding boxes. Each element is a tuple of two - * points representing corners of the axis-aligned bounding box. The type of the points is the same - * as the `value_type` of PointInputIt. Must meet the requirements of - * [LegacyRandomAccessIterator][LinkLRAI] and be device-writeable. - * - * @param ids_first beginning of the range of input object ids - * @param ids_last end of the range of input object ids - * @param points_first beginning of the range of input point (x,y) coordinates - * @param bounding_boxes_first beginning of the range of output bounding boxes, one per trajectory - * @param expansion_radius radius to add to each point when computing its bounding box. - * @param stream the CUDA stream on which to perform computations. - * - * @return An iterator to the end of the range of output bounding boxes. - * - * [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator - * "LegacyRandomAccessIterator" - */ -template > -BoundingBoxOutputIt point_bounding_boxes(IdInputIt ids_first, - IdInputIt ids_last, - PointInputIt points_first, - BoundingBoxOutputIt bounding_boxes_first, - T expansion_radius = T{0}, - rmm::cuda_stream_view stream = rmm::cuda_stream_default); - -/** - * @} // end of doxygen group - */ - -} // namespace cuspatial - -#include diff --git a/cpp/include/cuspatial/bounding_boxes.cuh b/cpp/include/cuspatial/bounding_boxes.cuh new file mode 100644 index 000000000..157a6e06a --- /dev/null +++ b/cpp/include/cuspatial/bounding_boxes.cuh @@ -0,0 +1,179 @@ +/* + * Copyright (c) 2022, 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. + */ + +#pragma once + +#include + +#include + +namespace cuspatial { + +/** + * @addtogroup spatial_relationship + * @{ + */ + +/** + * @brief Compute the spatial bounding boxes of sequences of points. + * + * Computes a bounding box around all points within each group (consecutive points with the same + * ID). This function can be applied to trajectory data, polygon vertices, linestring vertices, or + * any grouped point data. + * + * Before merging bounding boxes, each point may be expanded into a bounding box using an + * optional @p expansion_radius. The point is expanded to a box with coordinates + * `(point.x - expansion_radius, point.y - expansion_radius)` and + * `(point.x + expansion_radius, point.y + expansion_radius)`. + * + * @note Assumes Object IDs and points are presorted by ID. + * + * @tparam IdInputIt Iterator over object IDs. Must meet the requirements of + * [LegacyRandomAccessIterator][LinkLRAI] and be device-readable. + * @tparam PointInputIt Iterator over points. Must meet the requirements of + * [LegacyRandomAccessIterator][LinkLRAI] and be device-readable. + * @tparam BoundingBoxOutputIt Iterator over output bounding boxes. Each element is a tuple of two + * points representing corners of the axis-aligned bounding box. The type of the points is the same + * as the `value_type` of PointInputIt. Must meet the requirements of + * [LegacyRandomAccessIterator][LinkLRAI] and be device-writeable. + * + * @param ids_first beginning of the range of input object ids + * @param ids_last end of the range of input object ids + * @param points_first beginning of the range of input point (x,y) coordinates + * @param bounding_boxes_first beginning of the range of output bounding boxes, one per trajectory + * @param expansion_radius radius to add to each point when computing its bounding box. + * @param stream the CUDA stream on which to perform computations. + * + * @return An iterator to the end of the range of output bounding boxes. + * + * [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator + * "LegacyRandomAccessIterator" + */ +template > +BoundingBoxOutputIt point_bounding_boxes(IdInputIt ids_first, + IdInputIt ids_last, + PointInputIt points_first, + BoundingBoxOutputIt bounding_boxes_first, + T expansion_radius = T{0}, + rmm::cuda_stream_view stream = rmm::cuda_stream_default); + +/** + * @brief Compute minimum bounding box for each linestring. + * + * @tparam LinestringOffsetIterator Iterator type to linestring offsets. Must meet the requirements + * of [LegacyRandomAccessIterator][LinkLRAI] and be device-readable. + * @tparam VertexIterator Iterator type to linestring vertices. Must meet the requirements of + * [LegacyRandomAccessIterator][LinkLRAI] and be device-readable. + * @tparam BoundingBoxIterator Iterator type to bounding boxes. Must be writable using data of type + * `cuspatial::box`. Must meet the requirements of [LegacyRandomAccessIterator][LinkLRAI] and be + * device-writeable. + * @tparam T The coordinate data value type. + * @tparam IndexT The offset data value type. + * @param linestring_offsets_first Iterator to beginning of the range of input polygon offsets. + * @param linestring_offsets_last Iterator to end of the range of input polygon offsets. + * @param linestring_vertices_first Iterator to beginning of the range of input polygon vertices. + * @param linestring_vertices_last Iterator to end of the range of input polygon vertices. + * @param bounding_boxes_first Iterator to beginning of the range of output bounding boxes. + * @param expansion_radius Optional radius to expand each vertex of the output bounding boxes. + * @param stream the CUDA stream on which to perform computations and allocate memory. + * + * @return An iterator to the end of the range of output bounding boxes. + * + * @pre For compatibility with GeoArrow, the number of linestring offsets + * `std::distance(linestring_offsets_first, linestring_offsets_last)` should be one more than the + * number of linestrings. The final offset is not used by this function, but the number of offsets + * determines the output size. + * + * [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator + * "LegacyRandomAccessIterator" + */ +template , + class IndexT = iterator_value_type> +BoundingBoxIterator linestring_bounding_boxes( + LinestringOffsetIterator linestring_offsets_first, + LinestringOffsetIterator linestring_offsets_last, + VertexIterator linestring_vertices_first, + VertexIterator linestring_vertices_last, + BoundingBoxIterator bounding_boxes_first, + T expansion_radius = T{0}, + rmm::cuda_stream_view stream = rmm::cuda_stream_default); + +/** + * @brief Compute minimum bounding box for each polygon. + * + * @tparam PolygonOffsetIterator Iterator type to polygon offsets. Must meet the requirements of + * [LegacyRandomAccessIterator][LinkLRAI] and be device-readable. + * @tparam RingOffsetIterator Iterator type to polygon ring offsets. Must meet the requirements of + * [LegacyRandomAccessIterator][LinkLRAI] and be device-readable. + * @tparam VertexIterator Iterator type to polygon vertices. Must meet the requirements of + * [LegacyRandomAccessIterator][LinkLRAI] and be device-readable. + * @tparam BoundingBoxIterator Iterator type to bounding boxes. Must be writable using data of type + * `cuspatial::box`. Must meet the requirements of [LegacyRandomAccessIterator][LinkLRAI] and be + * device-writeable. + * @tparam T The coordinate data value type. + * @tparam IndexT The offset data value type. + * @param polygon_offsets_first Iterator to beginning of the range of input polygon offsets. + * @param polygon_offsets_last Iterator to end of the range of input polygon offsets. + * @param polygon_ring_offsets_first Iterator to beginning of the range of input polygon ring + * offsets. + * @param polygon_ring_offsets_last Iterator to end of the range of input polygon ring offsets. + * @param polygon_vertices_first Iterator to beginning of the range of input polygon vertices. + * @param polygon_vertices_last Iterator to end of the range of input polygon vertices. + * @param bounding_boxes_first Iterator to beginning of the range of output bounding boxes. + * @param expansion_radius Optional radius to expand each vertex of the output bounding boxes. + * @param stream the CUDA stream on which to perform computations and allocate memory. + * + * @return An iterator to the end of the range of output bounding boxes. + * + * @pre For compatibility with GeoArrow, the number of polygon offsets + * `std::distance(polygon_offsets_first, polygon_offsets_last)` should be one more than the number + * of polygons. The number of ring offsets `std::distance(polygon_ring_offsets_first, + * polygon_ring_offsets_last)` should be one more than the number of total rings. The + * final offset in each range is not used by this function, but the number of polygon offsets + * determines the output size. + * + * [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator + * "LegacyRandomAccessIterator" + */ +template , + class IndexT = iterator_value_type> +BoundingBoxIterator polygon_bounding_boxes(PolygonOffsetIterator polygon_offsets_first, + PolygonOffsetIterator polygon_offsets_last, + RingOffsetIterator polygon_ring_offsets_first, + RingOffsetIterator polygon_ring_offsets_last, + VertexIterator polygon_vertices_first, + VertexIterator polygon_vertices_last, + BoundingBoxIterator bounding_boxes_first, + T expansion_radius = T{0}, + rmm::cuda_stream_view stream = rmm::cuda_stream_default); + +/** + * @} // end of doxygen group + */ + +} // namespace cuspatial + +#include diff --git a/cpp/include/cuspatial/polygon_bounding_box.hpp b/cpp/include/cuspatial/bounding_boxes.hpp similarity index 64% rename from cpp/include/cuspatial/polygon_bounding_box.hpp rename to cpp/include/cuspatial/bounding_boxes.hpp index 942df4dd6..f76c9254d 100644 --- a/cpp/include/cuspatial/polygon_bounding_box.hpp +++ b/cpp/include/cuspatial/bounding_boxes.hpp @@ -24,6 +24,34 @@ namespace cuspatial { +/** + * @brief Compute minimum bounding boxes of a set of linestrings and an expansion radius. + * + * @ingroup spatial_relationship + * + * @param linestring_offsets Begin indices of the first point in each linestring (i.e. prefix-sum) + * @param x Linestring point x-coordinates + * @param y Linestring point y-coordinates + * @param expansion_radius Radius of each linestring point + * + * @return a cudf table of bounding boxes as four columns of the same type as `x` and `y`: + * x_min - the minimum x-coordinate of each bounding box + * y_min - the minimum y-coordinate of each bounding box + * x_max - the maximum x-coordinate of each bounding box + * y_max - the maximum y-coordinate of each bounding box + * + * @pre For compatibility with GeoArrow, the size of @p linestring_offsets should be one more than + * the number of linestrings to process. The final offset is not used by this function, but the + * number of offsets determines the output size. + */ + +std::unique_ptr linestring_bounding_boxes( + cudf::column_view const& linestring_offsets, + cudf::column_view const& x, + cudf::column_view const& y, + double expansion_radius, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + /** * @brief Compute minimum bounding box for each polygon in a list. * diff --git a/cpp/include/cuspatial/detail/bounding_box.cuh b/cpp/include/cuspatial/detail/bounding_box.cuh deleted file mode 100644 index 7855ed91f..000000000 --- a/cpp/include/cuspatial/detail/bounding_box.cuh +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2022, 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. - */ - -#pragma once - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -namespace cuspatial { - -namespace detail { - -template -struct point_bounding_box { - vec_2d box_offset{}; - - CUSPATIAL_HOST_DEVICE point_bounding_box(T expansion_radius = T{0}) - : box_offset{expansion_radius, expansion_radius} - { - } - - inline CUSPATIAL_HOST_DEVICE box operator()(vec_2d const& point) - { - return box{point - box_offset, point + box_offset}; - } -}; - -template -struct box_minmax { - inline CUSPATIAL_HOST_DEVICE box operator()(box const& a, box const& b) - { - return {box_min(box_min(a.v1, a.v2), b.v1), box_max(box_max(a.v1, a.v2), b.v2)}; - } -}; - -} // namespace detail - -template -BoundingBoxOutputIt point_bounding_boxes(IdInputIt ids_first, - IdInputIt ids_last, - PointInputIt points_first, - BoundingBoxOutputIt bounding_boxes_first, - T expansion_radius, - rmm::cuda_stream_view stream) -{ - static_assert(std::is_floating_point_v, "expansion_radius must be a floating-point type"); - - using CoordinateType = iterator_vec_base_type; - using IdType = iterator_value_type; - - auto point_bboxes_first = thrust::make_transform_iterator( - points_first, - detail::point_bounding_box{static_cast(expansion_radius)}); - - [[maybe_unused]] auto [_, bounding_boxes_last] = - thrust::reduce_by_key(rmm::exec_policy(stream), - ids_first, - ids_last, - point_bboxes_first, - thrust::make_discard_iterator(), - bounding_boxes_first, - thrust::equal_to(), - detail::box_minmax{}); - - return bounding_boxes_last; -} - -} // namespace cuspatial diff --git a/cpp/include/cuspatial/detail/bounding_boxes.cuh b/cpp/include/cuspatial/detail/bounding_boxes.cuh new file mode 100644 index 000000000..2e2e3f6e5 --- /dev/null +++ b/cpp/include/cuspatial/detail/bounding_boxes.cuh @@ -0,0 +1,185 @@ +/* + * Copyright (c) 2022, 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. + */ + +#pragma once + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +namespace cuspatial { + +namespace detail { + +template +struct point_bounding_box { + vec_2d box_offset{}; + + CUSPATIAL_HOST_DEVICE point_bounding_box(T expansion_radius = T{0}) + : box_offset{expansion_radius, expansion_radius} + { + } + + inline CUSPATIAL_HOST_DEVICE box operator()(vec_2d const& point) + { + return box{point - box_offset, point + box_offset}; + } +}; + +template +struct box_minmax { + inline CUSPATIAL_HOST_DEVICE box operator()(box const& a, box const& b) + { + return {box_min(box_min(a.v1, a.v2), b.v1), box_max(box_max(a.v1, a.v2), b.v2)}; + } +}; + +} // namespace detail + +template +BoundingBoxOutputIt point_bounding_boxes(IdInputIt ids_first, + IdInputIt ids_last, + PointInputIt points_first, + BoundingBoxOutputIt bounding_boxes_first, + T expansion_radius, + rmm::cuda_stream_view stream) +{ + static_assert(std::is_floating_point_v, "expansion_radius must be a floating-point type"); + + using CoordinateType = iterator_vec_base_type; + using IdType = iterator_value_type; + + auto point_bboxes_first = thrust::make_transform_iterator( + points_first, + detail::point_bounding_box{static_cast(expansion_radius)}); + + [[maybe_unused]] auto [_, bounding_boxes_last] = + thrust::reduce_by_key(rmm::exec_policy(stream), + ids_first, + ids_last, + point_bboxes_first, + thrust::make_discard_iterator(), + bounding_boxes_first, + thrust::equal_to(), + detail::box_minmax{}); + + return bounding_boxes_last; +} + +template +BoundingBoxIterator linestring_bounding_boxes(LinestringOffsetIterator linestring_offsets_first, + LinestringOffsetIterator linestring_offsets_last, + VertexIterator linestring_vertices_first, + VertexIterator linestring_vertices_last, + BoundingBoxIterator bounding_boxes_first, + T expansion_radius, + rmm::cuda_stream_view stream) +{ + static_assert(is_same>(), + "expansion_radius type must match vertex floating-point type"); + + static_assert(is_floating_point(), "Only floating point polygon vertices supported"); + + static_assert(is_vec_2d>, + "Input vertices must be cuspatial::vec_2d"); + + static_assert(cuspatial::is_integral>(), + "Offset iterators must have integral value type."); + + // GeoArrow: Number of linestrings is number of offsets minus one. + auto const num_linestrings = std::distance(linestring_offsets_first, linestring_offsets_last) - 1; + auto const num_vertices = std::distance(linestring_vertices_first, linestring_vertices_last); + + if (num_linestrings == 0 || num_vertices == 0) { return bounding_boxes_first; } + + auto vertex_ids_iter = + make_geometry_id_iterator(linestring_offsets_first, linestring_offsets_last); + + return point_bounding_boxes(vertex_ids_iter, + vertex_ids_iter + num_vertices, + linestring_vertices_first, + bounding_boxes_first, + expansion_radius, + stream); +} + +template +BoundingBoxIterator polygon_bounding_boxes(PolygonOffsetIterator polygon_offsets_first, + PolygonOffsetIterator polygon_offsets_last, + RingOffsetIterator polygon_ring_offsets_first, + RingOffsetIterator polygon_ring_offsets_last, + VertexIterator polygon_vertices_first, + VertexIterator polygon_vertices_last, + BoundingBoxIterator bounding_boxes_first, + T expansion_radius, + rmm::cuda_stream_view stream) +{ + static_assert(is_same>(), + "expansion_radius type must match vertex floating-point type"); + + static_assert(is_floating_point(), "Only floating point polygon vertices supported"); + + static_assert(is_vec_2d>, + "Input vertices must be cuspatial::vec_2d"); + + static_assert(cuspatial::is_integral, + iterator_value_type>(), + "OffsetIterators must have integral value type."); + + auto const num_polys = std::distance(polygon_offsets_first, polygon_offsets_last) - 1; + auto const num_rings = std::distance(polygon_ring_offsets_first, polygon_ring_offsets_last) - 1; + auto const num_vertices = std::distance(polygon_vertices_first, polygon_vertices_last); + + if (num_polys > 0) { + CUSPATIAL_EXPECTS_VALID_POLYGON_SIZES( + num_vertices, + std::distance(polygon_offsets_first, polygon_offsets_last), + std::distance(polygon_ring_offsets_first, polygon_ring_offsets_last)); + + if (num_polys == 0 || num_rings == 0 || num_vertices == 0) { return bounding_boxes_first; } + + auto vertex_ids_iter = make_geometry_id_iterator( + polygon_offsets_first, polygon_offsets_last, polygon_ring_offsets_first); + + return point_bounding_boxes(vertex_ids_iter, + vertex_ids_iter + num_vertices, + polygon_vertices_first, + bounding_boxes_first, + expansion_radius, + stream); + } + return bounding_boxes_first; +} + +} // namespace cuspatial diff --git a/cpp/include/cuspatial/detail/linestring_bounding_boxes.cuh b/cpp/include/cuspatial/detail/linestring_bounding_boxes.cuh deleted file mode 100644 index cc88c3053..000000000 --- a/cpp/include/cuspatial/detail/linestring_bounding_boxes.cuh +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2022, 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. - */ - -#pragma once - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -namespace cuspatial { - -template -BoundingBoxIterator linestring_bounding_boxes(LinestringOffsetIterator linestring_offsets_first, - LinestringOffsetIterator linestring_offsets_last, - VertexIterator linestring_vertices_first, - VertexIterator linestring_vertices_last, - BoundingBoxIterator bounding_boxes_first, - T expansion_radius, - rmm::cuda_stream_view stream) -{ - static_assert(is_same>(), - "expansion_radius type must match vertex floating-point type"); - - static_assert(is_floating_point(), "Only floating point polygon vertices supported"); - - static_assert(is_vec_2d>, - "Input vertices must be cuspatial::vec_2d"); - - static_assert(cuspatial::is_integral>(), - "Offset iterators must have integral value type."); - - // GeoArrow: Number of linestrings is number of offsets minus one. - auto const num_linestrings = std::distance(linestring_offsets_first, linestring_offsets_last) - 1; - auto const num_vertices = std::distance(linestring_vertices_first, linestring_vertices_last); - - if (num_linestrings == 0 || num_vertices == 0) { return bounding_boxes_first; } - - auto vertex_ids_iter = - make_geometry_id_iterator(linestring_offsets_first, linestring_offsets_last); - - return point_bounding_boxes(vertex_ids_iter, - vertex_ids_iter + num_vertices, - linestring_vertices_first, - bounding_boxes_first, - expansion_radius, - stream); -} -} // namespace cuspatial diff --git a/cpp/include/cuspatial/detail/polygon_bounding_boxes.cuh b/cpp/include/cuspatial/detail/polygon_bounding_boxes.cuh deleted file mode 100644 index 0d4844329..000000000 --- a/cpp/include/cuspatial/detail/polygon_bounding_boxes.cuh +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2022-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. - */ - -#pragma once - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -namespace cuspatial { - -template -BoundingBoxIterator polygon_bounding_boxes(PolygonOffsetIterator polygon_offsets_first, - PolygonOffsetIterator polygon_offsets_last, - RingOffsetIterator polygon_ring_offsets_first, - RingOffsetIterator polygon_ring_offsets_last, - VertexIterator polygon_vertices_first, - VertexIterator polygon_vertices_last, - BoundingBoxIterator bounding_boxes_first, - T expansion_radius, - rmm::cuda_stream_view stream) -{ - static_assert(is_same>(), - "expansion_radius type must match vertex floating-point type"); - - static_assert(is_floating_point(), "Only floating point polygon vertices supported"); - - static_assert(is_vec_2d>, - "Input vertices must be cuspatial::vec_2d"); - - static_assert(cuspatial::is_integral, - iterator_value_type>(), - "OffsetIterators must have integral value type."); - - auto const num_polys = std::distance(polygon_offsets_first, polygon_offsets_last) - 1; - auto const num_rings = std::distance(polygon_ring_offsets_first, polygon_ring_offsets_last) - 1; - auto const num_vertices = std::distance(polygon_vertices_first, polygon_vertices_last); - - if (num_polys > 0) { - CUSPATIAL_EXPECTS_VALID_POLYGON_SIZES( - num_vertices, - std::distance(polygon_offsets_first, polygon_offsets_last), - std::distance(polygon_ring_offsets_first, polygon_ring_offsets_last)); - - if (num_polys == 0 || num_rings == 0 || num_vertices == 0) { return bounding_boxes_first; } - - auto vertex_ids_iter = make_geometry_id_iterator( - polygon_offsets_first, polygon_offsets_last, polygon_ring_offsets_first); - - return point_bounding_boxes(vertex_ids_iter, - vertex_ids_iter + num_vertices, - polygon_vertices_first, - bounding_boxes_first, - expansion_radius, - stream); - } - return bounding_boxes_first; -} -} // namespace cuspatial diff --git a/cpp/include/cuspatial/linestring_bounding_box.hpp b/cpp/include/cuspatial/linestring_bounding_box.hpp deleted file mode 100644 index e39177c52..000000000 --- a/cpp/include/cuspatial/linestring_bounding_box.hpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2020-2022, 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. - */ - -#pragma once - -#include - -#include - -#include - -namespace cuspatial { - -/** - * @brief Compute minimum bounding boxes of a set of linestrings and an expansion radius. - * - * @ingroup spatial_relationship - * - * @param linestring_offsets Begin indices of the first point in each linestring (i.e. prefix-sum) - * @param x Linestring point x-coordinates - * @param y Linestring point y-coordinates - * @param expansion_radius Radius of each linestring point - * - * @return a cudf table of bounding boxes as four columns of the same type as `x` and `y`: - * x_min - the minimum x-coordinate of each bounding box - * y_min - the minimum y-coordinate of each bounding box - * x_max - the maximum x-coordinate of each bounding box - * y_max - the maximum y-coordinate of each bounding box - * - * @pre For compatibility with GeoArrow, the size of @p linestring_offsets should be one more than - * the number of linestrings to process. The final offset is not used by this function, but the - * number of offsets determines the output size. - */ - -std::unique_ptr linestring_bounding_boxes( - cudf::column_view const& linestring_offsets, - cudf::column_view const& x, - cudf::column_view const& y, - double expansion_radius, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); - -} // namespace cuspatial diff --git a/cpp/include/cuspatial/linestring_bounding_boxes.cuh b/cpp/include/cuspatial/linestring_bounding_boxes.cuh deleted file mode 100644 index 62e18f3cd..000000000 --- a/cpp/include/cuspatial/linestring_bounding_boxes.cuh +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2022, 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. - */ - -#pragma once - -#include - -#include - -namespace cuspatial { - -/** - * @brief Compute minimum bounding box for each linestring. - * - * @ingroup spatial_relationship - * - * @tparam LinestringOffsetIterator Iterator type to linestring offsets. Must meet the requirements - * of [LegacyRandomAccessIterator][LinkLRAI] and be device-readable. - * @tparam VertexIterator Iterator type to linestring vertices. Must meet the requirements of - * [LegacyRandomAccessIterator][LinkLRAI] and be device-readable. - * @tparam BoundingBoxIterator Iterator type to bounding boxes. Must be writable using data of type - * `cuspatial::box`. Must meet the requirements of [LegacyRandomAccessIterator][LinkLRAI] and be - * device-writeable. - * @tparam T The coordinate data value type. - * @tparam IndexT The offset data value type. - * @param linestring_offsets_first Iterator to beginning of the range of input polygon offsets. - * @param linestring_offsets_last Iterator to end of the range of input polygon offsets. - * @param linestring_vertices_first Iterator to beginning of the range of input polygon vertices. - * @param linestring_vertices_last Iterator to end of the range of input polygon vertices. - * @param bounding_boxes_first Iterator to beginning of the range of output bounding boxes. - * @param expansion_radius Optional radius to expand each vertex of the output bounding boxes. - * @param stream the CUDA stream on which to perform computations and allocate memory. - * - * @return An iterator to the end of the range of output bounding boxes. - * - * @pre For compatibility with GeoArrow, the number of linestring offsets - * `std::distance(linestring_offsets_first, linestring_offsets_last)` should be one more than the - * number of linestrings. The final offset is not used by this function, but the number of offsets - * determines the output size. - * - * [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator - * "LegacyRandomAccessIterator" - */ -template , - class IndexT = iterator_value_type> -BoundingBoxIterator linestring_bounding_boxes( - LinestringOffsetIterator linestring_offsets_first, - LinestringOffsetIterator linestring_offsets_last, - VertexIterator linestring_vertices_first, - VertexIterator linestring_vertices_last, - BoundingBoxIterator bounding_boxes_first, - T expansion_radius = T{0}, - rmm::cuda_stream_view stream = rmm::cuda_stream_default); - -} // namespace cuspatial - -#include diff --git a/cpp/include/cuspatial/polygon_bounding_boxes.cuh b/cpp/include/cuspatial/polygon_bounding_boxes.cuh deleted file mode 100644 index 7cee2be26..000000000 --- a/cpp/include/cuspatial/polygon_bounding_boxes.cuh +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2022, 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. - */ - -#pragma once - -#include - -#include - -namespace cuspatial { - -/** - * @brief Compute minimum bounding box for each polygon. - * - * @ingroup spatial_relationship - * - * @tparam PolygonOffsetIterator Iterator type to polygon offsets. Must meet the requirements of - * [LegacyRandomAccessIterator][LinkLRAI] and be device-readable. - * @tparam RingOffsetIterator Iterator type to polygon ring offsets. Must meet the requirements of - * [LegacyRandomAccessIterator][LinkLRAI] and be device-readable. - * @tparam VertexIterator Iterator type to polygon vertices. Must meet the requirements of - * [LegacyRandomAccessIterator][LinkLRAI] and be device-readable. - * @tparam BoundingBoxIterator Iterator type to bounding boxes. Must be writable using data of type - * `cuspatial::box`. Must meet the requirements of [LegacyRandomAccessIterator][LinkLRAI] and be - * device-writeable. - * @tparam T The coordinate data value type. - * @tparam IndexT The offset data value type. - * @param polygon_offsets_first Iterator to beginning of the range of input polygon offsets. - * @param polygon_offsets_last Iterator to end of the range of input polygon offsets. - * @param polygon_ring_offsets_first Iterator to beginning of the range of input polygon ring - * offsets. - * @param polygon_ring_offsets_last Iterator to end of the range of input polygon ring offsets. - * @param polygon_vertices_first Iterator to beginning of the range of input polygon vertices. - * @param polygon_vertices_last Iterator to end of the range of input polygon vertices. - * @param bounding_boxes_first Iterator to beginning of the range of output bounding boxes. - * @param expansion_radius Optional radius to expand each vertex of the output bounding boxes. - * @param stream the CUDA stream on which to perform computations and allocate memory. - * - * @return An iterator to the end of the range of output bounding boxes. - * - * @pre For compatibility with GeoArrow, the number of polygon offsets - * `std::distance(polygon_offsets_first, polygon_offsets_last)` should be one more than the number - * of polygons. The number of ring offsets `std::distance(polygon_ring_offsets_first, - * polygon_ring_offsets_last)` should be one more than the number of total rings. The - * final offset in each range is not used by this function, but the number of polygon offsets - * determines the output size. - * - * [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator - * "LegacyRandomAccessIterator" - */ -template , - class IndexT = iterator_value_type> -BoundingBoxIterator polygon_bounding_boxes(PolygonOffsetIterator polygon_offsets_first, - PolygonOffsetIterator polygon_offsets_last, - RingOffsetIterator polygon_ring_offsets_first, - RingOffsetIterator polygon_ring_offsets_last, - VertexIterator polygon_vertices_first, - VertexIterator polygon_vertices_last, - BoundingBoxIterator bounding_boxes_first, - T expansion_radius = T{0}, - rmm::cuda_stream_view stream = rmm::cuda_stream_default); - -} // namespace cuspatial - -#include diff --git a/cpp/src/spatial/linestring_bounding_box.cu b/cpp/src/spatial/linestring_bounding_boxes.cu similarity index 98% rename from cpp/src/spatial/linestring_bounding_box.cu rename to cpp/src/spatial/linestring_bounding_boxes.cu index c47a6cf8d..86b6aeb75 100644 --- a/cpp/src/spatial/linestring_bounding_box.cu +++ b/cpp/src/spatial/linestring_bounding_boxes.cu @@ -14,10 +14,9 @@ * limitations under the License. */ -#include +#include #include #include -#include #include #include diff --git a/cpp/src/spatial/polygon_bounding_box.cu b/cpp/src/spatial/polygon_bounding_boxes.cu similarity index 99% rename from cpp/src/spatial/polygon_bounding_box.cu rename to cpp/src/spatial/polygon_bounding_boxes.cu index f8b0c5f17..9fdca1bd5 100644 --- a/cpp/src/spatial/polygon_bounding_box.cu +++ b/cpp/src/spatial/polygon_bounding_boxes.cu @@ -16,8 +16,8 @@ #include +#include #include -#include #include #include diff --git a/cpp/src/trajectory/trajectory_bounding_boxes.cu b/cpp/src/trajectory/trajectory_bounding_boxes.cu index f790f86e8..8d441b9c4 100644 --- a/cpp/src/trajectory/trajectory_bounding_boxes.cu +++ b/cpp/src/trajectory/trajectory_bounding_boxes.cu @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include #include diff --git a/cpp/tests/join/join_quadtree_and_bounding_boxes_test.cpp b/cpp/tests/join/join_quadtree_and_bounding_boxes_test.cpp index d0fe5586a..e7d6d5948 100644 --- a/cpp/tests/join/join_quadtree_and_bounding_boxes_test.cpp +++ b/cpp/tests/join/join_quadtree_and_bounding_boxes_test.cpp @@ -14,9 +14,9 @@ * limitations under the License. */ +#include #include #include -#include #include #include diff --git a/cpp/tests/join/quadtree_point_in_polygon_test.cpp b/cpp/tests/join/quadtree_point_in_polygon_test.cpp index 6206e8b45..c3d720c10 100644 --- a/cpp/tests/join/quadtree_point_in_polygon_test.cpp +++ b/cpp/tests/join/quadtree_point_in_polygon_test.cpp @@ -15,10 +15,10 @@ */ #include +#include #include #include #include -#include #include #include diff --git a/cpp/tests/join/quadtree_point_in_polygon_test_large.cu b/cpp/tests/join/quadtree_point_in_polygon_test_large.cu index c66879986..14a956016 100644 --- a/cpp/tests/join/quadtree_point_in_polygon_test_large.cu +++ b/cpp/tests/join/quadtree_point_in_polygon_test_large.cu @@ -20,10 +20,10 @@ #include #include +#include #include #include #include -#include #include #include diff --git a/cpp/tests/join/quadtree_point_in_polygon_test_small.cu b/cpp/tests/join/quadtree_point_in_polygon_test_small.cu index 500628bab..52792dd9b 100644 --- a/cpp/tests/join/quadtree_point_in_polygon_test_small.cu +++ b/cpp/tests/join/quadtree_point_in_polygon_test_small.cu @@ -18,9 +18,9 @@ #include #include +#include #include #include -#include #include #include diff --git a/cpp/tests/join/quadtree_point_to_nearest_linestring_test.cpp b/cpp/tests/join/quadtree_point_to_nearest_linestring_test.cpp index a04b590a3..d78cda350 100644 --- a/cpp/tests/join/quadtree_point_to_nearest_linestring_test.cpp +++ b/cpp/tests/join/quadtree_point_to_nearest_linestring_test.cpp @@ -15,9 +15,9 @@ */ #include +#include #include #include -#include #include #include diff --git a/cpp/tests/join/quadtree_point_to_nearest_linestring_test_small.cu b/cpp/tests/join/quadtree_point_to_nearest_linestring_test_small.cu index a27997a96..4f4f85837 100644 --- a/cpp/tests/join/quadtree_point_to_nearest_linestring_test_small.cu +++ b/cpp/tests/join/quadtree_point_to_nearest_linestring_test_small.cu @@ -18,8 +18,8 @@ #include #include +#include #include -#include #include #include #include diff --git a/cpp/tests/spatial/bounding_boxes/linestring_bounding_boxes_test.cpp b/cpp/tests/spatial/bounding_boxes/linestring_bounding_boxes_test.cpp index fb409a22b..d742b0cc7 100644 --- a/cpp/tests/spatial/bounding_boxes/linestring_bounding_boxes_test.cpp +++ b/cpp/tests/spatial/bounding_boxes/linestring_bounding_boxes_test.cpp @@ -14,8 +14,8 @@ * limitations under the License. */ +#include #include -#include #include #include diff --git a/cpp/tests/spatial/bounding_boxes/linestring_bounding_boxes_test.cu b/cpp/tests/spatial/bounding_boxes/linestring_bounding_boxes_test.cu index d18a32e73..53f3427b8 100644 --- a/cpp/tests/spatial/bounding_boxes/linestring_bounding_boxes_test.cu +++ b/cpp/tests/spatial/bounding_boxes/linestring_bounding_boxes_test.cu @@ -17,10 +17,10 @@ #include #include +#include #include #include #include -#include #include diff --git a/cpp/tests/spatial/bounding_boxes/point_bounding_boxes_test.cu b/cpp/tests/spatial/bounding_boxes/point_bounding_boxes_test.cu index 2d00a1a91..c0f5e758b 100644 --- a/cpp/tests/spatial/bounding_boxes/point_bounding_boxes_test.cu +++ b/cpp/tests/spatial/bounding_boxes/point_bounding_boxes_test.cu @@ -18,7 +18,7 @@ #include -#include +#include #include #include #include diff --git a/cpp/tests/spatial/bounding_boxes/polygon_bounding_boxes_test.cpp b/cpp/tests/spatial/bounding_boxes/polygon_bounding_boxes_test.cpp index b161f9989..f933a2459 100644 --- a/cpp/tests/spatial/bounding_boxes/polygon_bounding_boxes_test.cpp +++ b/cpp/tests/spatial/bounding_boxes/polygon_bounding_boxes_test.cpp @@ -14,8 +14,8 @@ * limitations under the License. */ +#include #include -#include #include #include diff --git a/cpp/tests/spatial/bounding_boxes/polygon_bounding_boxes_test.cu b/cpp/tests/spatial/bounding_boxes/polygon_bounding_boxes_test.cu index 6ad497312..de81d06e2 100644 --- a/cpp/tests/spatial/bounding_boxes/polygon_bounding_boxes_test.cu +++ b/cpp/tests/spatial/bounding_boxes/polygon_bounding_boxes_test.cu @@ -17,10 +17,10 @@ #include #include +#include #include #include #include -#include #include From bd8d7c09780943341fe987e4332c72036a615130 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Wed, 26 Apr 2023 03:26:37 +0000 Subject: [PATCH 02/18] Consolidate iterator factories --- .../pairwise_linestring_distance.cu | 1 - cpp/benchmarks/points_in_range.cu | 2 +- .../detail/find/find_points_on_segments.cuh | 2 +- .../detail/geometry/linestring_ref.cuh | 2 +- .../cuspatial/detail/geometry/polygon_ref.cuh | 2 +- .../multilinestring_ref.cuh | 2 +- .../geometry_collection/multipolygon_ref.cuh | 2 +- cpp/include/cuspatial/detail/iterator.hpp | 32 ------------------- ...inestring_intersection_with_duplicates.cuh | 1 - .../detail/point_polygon_distance.cuh | 1 - .../detail/quadtree_bbox_filtering.cuh | 2 +- .../detail/quadtree_point_in_polygon.cuh | 2 +- .../quadtree_point_to_nearest_linestring.cuh | 2 +- .../detail/range/enumerate_range.cuh | 2 +- .../detail/range/multilinestring_range.cuh | 2 +- .../detail/range/multipoint_range.cuh | 2 +- .../detail/range/multipolygon_range.cuh | 2 +- cpp/include/cuspatial/iterator_factory.cuh | 13 +++++++- cpp/include/cuspatial/spatial_join.cuh | 2 +- cpp/src/join/quadtree_bbox_filtering.cu | 2 +- cpp/src/spatial/linestring_intersection.cu | 1 - .../spatial/linestring_polygon_distance.cu | 1 - cpp/src/spatial/point_linestring_distance.cu | 1 - cpp/src/spatial/point_polygon_distance.cu | 1 - .../point_bounding_boxes_test.cu | 2 +- .../linestring_polygon_distance_test.cu | 2 +- .../spatial/distance/point_distance_test.cu | 1 - .../point_linestring_distance_test.cu | 1 - .../distance/point_polygon_distance_test.cu | 2 +- .../linestring_intersection_test.cu | 1 - .../point_linestring_nearest_points_test.cu | 1 - .../trajectory/derive_trajectories_test.cu | 2 +- .../trajectory_distances_and_speeds_test.cu | 2 +- 33 files changed, 32 insertions(+), 64 deletions(-) delete mode 100644 cpp/include/cuspatial/detail/iterator.hpp diff --git a/cpp/benchmarks/pairwise_linestring_distance.cu b/cpp/benchmarks/pairwise_linestring_distance.cu index 8abc97f96..293e8c960 100644 --- a/cpp/benchmarks/pairwise_linestring_distance.cu +++ b/cpp/benchmarks/pairwise_linestring_distance.cu @@ -17,7 +17,6 @@ #include #include -#include #include #include #include diff --git a/cpp/benchmarks/points_in_range.cu b/cpp/benchmarks/points_in_range.cu index f9c6d20f8..b9bced1be 100644 --- a/cpp/benchmarks/points_in_range.cu +++ b/cpp/benchmarks/points_in_range.cu @@ -18,9 +18,9 @@ #include -#include #include #include +#include #include #include diff --git a/cpp/include/cuspatial/detail/find/find_points_on_segments.cuh b/cpp/include/cuspatial/detail/find/find_points_on_segments.cuh index fcf7a6283..dfda0b8b1 100644 --- a/cpp/include/cuspatial/detail/find/find_points_on_segments.cuh +++ b/cpp/include/cuspatial/detail/find/find_points_on_segments.cuh @@ -19,9 +19,9 @@ #include #include -#include #include #include +#include #include #include diff --git a/cpp/include/cuspatial/detail/geometry/linestring_ref.cuh b/cpp/include/cuspatial/detail/geometry/linestring_ref.cuh index f18fab4d8..37e4bb5aa 100644 --- a/cpp/include/cuspatial/detail/geometry/linestring_ref.cuh +++ b/cpp/include/cuspatial/detail/geometry/linestring_ref.cuh @@ -16,8 +16,8 @@ #pragma once #include -#include #include +#include #include #include diff --git a/cpp/include/cuspatial/detail/geometry/polygon_ref.cuh b/cpp/include/cuspatial/detail/geometry/polygon_ref.cuh index 35374e23c..882ae22ae 100644 --- a/cpp/include/cuspatial/detail/geometry/polygon_ref.cuh +++ b/cpp/include/cuspatial/detail/geometry/polygon_ref.cuh @@ -16,9 +16,9 @@ #pragma once #include -#include #include #include +#include #include #include diff --git a/cpp/include/cuspatial/detail/geometry_collection/multilinestring_ref.cuh b/cpp/include/cuspatial/detail/geometry_collection/multilinestring_ref.cuh index f3894515d..7a76f92b8 100644 --- a/cpp/include/cuspatial/detail/geometry_collection/multilinestring_ref.cuh +++ b/cpp/include/cuspatial/detail/geometry_collection/multilinestring_ref.cuh @@ -17,8 +17,8 @@ #pragma once #include -#include #include +#include #include diff --git a/cpp/include/cuspatial/detail/geometry_collection/multipolygon_ref.cuh b/cpp/include/cuspatial/detail/geometry_collection/multipolygon_ref.cuh index d033722e2..78920afe5 100644 --- a/cpp/include/cuspatial/detail/geometry_collection/multipolygon_ref.cuh +++ b/cpp/include/cuspatial/detail/geometry_collection/multipolygon_ref.cuh @@ -1,9 +1,9 @@ #pragma once #include -#include #include #include +#include #include diff --git a/cpp/include/cuspatial/detail/iterator.hpp b/cpp/include/cuspatial/detail/iterator.hpp deleted file mode 100644 index 05b8a7aa2..000000000 --- a/cpp/include/cuspatial/detail/iterator.hpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2022, 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. - */ - -#pragma once -#include - -#include -#include - -namespace cuspatial { -namespace detail { - -template -inline CUSPATIAL_HOST_DEVICE auto make_counting_transform_iterator(IndexType start, UnaryFunction f) -{ - return thrust::make_transform_iterator(thrust::make_counting_iterator(start), f); -} -} // namespace detail -} // namespace cuspatial diff --git a/cpp/include/cuspatial/detail/linestring_intersection_with_duplicates.cuh b/cpp/include/cuspatial/detail/linestring_intersection_with_duplicates.cuh index 3971ba085..b6dd20b35 100644 --- a/cpp/include/cuspatial/detail/linestring_intersection_with_duplicates.cuh +++ b/cpp/include/cuspatial/detail/linestring_intersection_with_duplicates.cuh @@ -14,7 +14,6 @@ * limitations under the License. */ -#include #include #include #include diff --git a/cpp/include/cuspatial/detail/point_polygon_distance.cuh b/cpp/include/cuspatial/detail/point_polygon_distance.cuh index 0a244aadc..1729b6775 100644 --- a/cpp/include/cuspatial/detail/point_polygon_distance.cuh +++ b/cpp/include/cuspatial/detail/point_polygon_distance.cuh @@ -20,7 +20,6 @@ #include #include -#include #include #include #include diff --git a/cpp/include/cuspatial/detail/quadtree_bbox_filtering.cuh b/cpp/include/cuspatial/detail/quadtree_bbox_filtering.cuh index f7a39fd9f..9ba8744d0 100644 --- a/cpp/include/cuspatial/detail/quadtree_bbox_filtering.cuh +++ b/cpp/include/cuspatial/detail/quadtree_bbox_filtering.cuh @@ -16,9 +16,9 @@ #pragma once -#include #include #include +#include #include #include diff --git a/cpp/include/cuspatial/detail/quadtree_point_in_polygon.cuh b/cpp/include/cuspatial/detail/quadtree_point_in_polygon.cuh index 54977fa7c..2a9594317 100644 --- a/cpp/include/cuspatial/detail/quadtree_point_in_polygon.cuh +++ b/cpp/include/cuspatial/detail/quadtree_point_in_polygon.cuh @@ -15,9 +15,9 @@ */ #include -#include #include #include +#include #include #include #include diff --git a/cpp/include/cuspatial/detail/quadtree_point_to_nearest_linestring.cuh b/cpp/include/cuspatial/detail/quadtree_point_to_nearest_linestring.cuh index 3ac8a6338..a317758d9 100644 --- a/cpp/include/cuspatial/detail/quadtree_point_to_nearest_linestring.cuh +++ b/cpp/include/cuspatial/detail/quadtree_point_to_nearest_linestring.cuh @@ -15,10 +15,10 @@ */ #include -#include #include #include #include +#include #include #include #include diff --git a/cpp/include/cuspatial/detail/range/enumerate_range.cuh b/cpp/include/cuspatial/detail/range/enumerate_range.cuh index 4143bc8a5..6dbaf0f55 100644 --- a/cpp/include/cuspatial/detail/range/enumerate_range.cuh +++ b/cpp/include/cuspatial/detail/range/enumerate_range.cuh @@ -17,7 +17,7 @@ #pragma once #include -#include +#include #include #include diff --git a/cpp/include/cuspatial/detail/range/multilinestring_range.cuh b/cpp/include/cuspatial/detail/range/multilinestring_range.cuh index 775037c42..5983efc00 100644 --- a/cpp/include/cuspatial/detail/range/multilinestring_range.cuh +++ b/cpp/include/cuspatial/detail/range/multilinestring_range.cuh @@ -24,10 +24,10 @@ #include #include -#include #include #include #include +#include #include #include diff --git a/cpp/include/cuspatial/detail/range/multipoint_range.cuh b/cpp/include/cuspatial/detail/range/multipoint_range.cuh index 3caad3a1d..7e9c18cb3 100644 --- a/cpp/include/cuspatial/detail/range/multipoint_range.cuh +++ b/cpp/include/cuspatial/detail/range/multipoint_range.cuh @@ -22,9 +22,9 @@ #include #include -#include #include #include +#include #include namespace cuspatial { diff --git a/cpp/include/cuspatial/detail/range/multipolygon_range.cuh b/cpp/include/cuspatial/detail/range/multipolygon_range.cuh index ad276fee9..9bbf45bd8 100644 --- a/cpp/include/cuspatial/detail/range/multipolygon_range.cuh +++ b/cpp/include/cuspatial/detail/range/multipolygon_range.cuh @@ -18,11 +18,11 @@ #include #include -#include #include #include #include #include +#include #include #include diff --git a/cpp/include/cuspatial/iterator_factory.cuh b/cpp/include/cuspatial/iterator_factory.cuh index a409cc6da..1f026512c 100644 --- a/cpp/include/cuspatial/iterator_factory.cuh +++ b/cpp/include/cuspatial/iterator_factory.cuh @@ -16,7 +16,6 @@ #pragma once -#include #include #include #include @@ -24,6 +23,7 @@ #include #include +#include #include #include #include @@ -35,6 +35,17 @@ namespace cuspatial { namespace detail { + +/** + * @internal + * @brief Helper to create a `transform_iterator` that transforms sequential values. + */ +template +inline CUSPATIAL_HOST_DEVICE auto make_counting_transform_iterator(IndexType start, UnaryFunction f) +{ + return thrust::make_transform_iterator(thrust::make_counting_iterator(start), f); +} + /** * @internal * @brief Helper to convert a tuple of elements into a `vec_2d` diff --git a/cpp/include/cuspatial/spatial_join.cuh b/cpp/include/cuspatial/spatial_join.cuh index 1b960e32c..a9d53ec78 100644 --- a/cpp/include/cuspatial/spatial_join.cuh +++ b/cpp/include/cuspatial/spatial_join.cuh @@ -16,9 +16,9 @@ #pragma once -#include #include #include +#include #include #include diff --git a/cpp/src/join/quadtree_bbox_filtering.cu b/cpp/src/join/quadtree_bbox_filtering.cu index d5e20c353..b90bad402 100644 --- a/cpp/src/join/quadtree_bbox_filtering.cu +++ b/cpp/src/join/quadtree_bbox_filtering.cu @@ -17,8 +17,8 @@ #include #include -#include #include +#include #include #include diff --git a/cpp/src/spatial/linestring_intersection.cu b/cpp/src/spatial/linestring_intersection.cu index e80adf442..f256cb70f 100644 --- a/cpp/src/spatial/linestring_intersection.cu +++ b/cpp/src/spatial/linestring_intersection.cu @@ -18,7 +18,6 @@ #include "../utility/multi_geometry_dispatch.hpp" #include -#include #include #include #include diff --git a/cpp/src/spatial/linestring_polygon_distance.cu b/cpp/src/spatial/linestring_polygon_distance.cu index 7e99fabd5..978cff1cd 100644 --- a/cpp/src/spatial/linestring_polygon_distance.cu +++ b/cpp/src/spatial/linestring_polygon_distance.cu @@ -29,7 +29,6 @@ #include #include -#include #include #include #include diff --git a/cpp/src/spatial/point_linestring_distance.cu b/cpp/src/spatial/point_linestring_distance.cu index 6f2786b51..5f852fffa 100644 --- a/cpp/src/spatial/point_linestring_distance.cu +++ b/cpp/src/spatial/point_linestring_distance.cu @@ -25,7 +25,6 @@ #include -#include #include #include #include diff --git a/cpp/src/spatial/point_polygon_distance.cu b/cpp/src/spatial/point_polygon_distance.cu index 52eea1309..efd88a24c 100644 --- a/cpp/src/spatial/point_polygon_distance.cu +++ b/cpp/src/spatial/point_polygon_distance.cu @@ -29,7 +29,6 @@ #include #include -#include #include #include #include diff --git a/cpp/tests/spatial/bounding_boxes/point_bounding_boxes_test.cu b/cpp/tests/spatial/bounding_boxes/point_bounding_boxes_test.cu index c0f5e758b..e96c2b783 100644 --- a/cpp/tests/spatial/bounding_boxes/point_bounding_boxes_test.cu +++ b/cpp/tests/spatial/bounding_boxes/point_bounding_boxes_test.cu @@ -19,9 +19,9 @@ #include #include -#include #include #include +#include #include #include diff --git a/cpp/tests/spatial/distance/linestring_polygon_distance_test.cu b/cpp/tests/spatial/distance/linestring_polygon_distance_test.cu index 0d3ef91f0..132544f00 100644 --- a/cpp/tests/spatial/distance/linestring_polygon_distance_test.cu +++ b/cpp/tests/spatial/distance/linestring_polygon_distance_test.cu @@ -18,8 +18,8 @@ #include #include -#include #include +#include #include #include diff --git a/cpp/tests/spatial/distance/point_distance_test.cu b/cpp/tests/spatial/distance/point_distance_test.cu index 1b1f9ff90..97d708aa7 100644 --- a/cpp/tests/spatial/distance/point_distance_test.cu +++ b/cpp/tests/spatial/distance/point_distance_test.cu @@ -18,7 +18,6 @@ #include -#include #include #include #include diff --git a/cpp/tests/spatial/distance/point_linestring_distance_test.cu b/cpp/tests/spatial/distance/point_linestring_distance_test.cu index f16df5f10..54744f2bd 100644 --- a/cpp/tests/spatial/distance/point_linestring_distance_test.cu +++ b/cpp/tests/spatial/distance/point_linestring_distance_test.cu @@ -16,7 +16,6 @@ #include -#include #include #include #include diff --git a/cpp/tests/spatial/distance/point_polygon_distance_test.cu b/cpp/tests/spatial/distance/point_polygon_distance_test.cu index 01536a4af..eaeee981f 100644 --- a/cpp/tests/spatial/distance/point_polygon_distance_test.cu +++ b/cpp/tests/spatial/distance/point_polygon_distance_test.cu @@ -17,8 +17,8 @@ #include #include -#include #include +#include #include #include diff --git a/cpp/tests/spatial/intersection/linestring_intersection_test.cu b/cpp/tests/spatial/intersection/linestring_intersection_test.cu index d0bf58b11..7fb4f6d97 100644 --- a/cpp/tests/spatial/intersection/linestring_intersection_test.cu +++ b/cpp/tests/spatial/intersection/linestring_intersection_test.cu @@ -19,7 +19,6 @@ #include #include -#include #include #include #include diff --git a/cpp/tests/spatial/nearest_points/point_linestring_nearest_points_test.cu b/cpp/tests/spatial/nearest_points/point_linestring_nearest_points_test.cu index 42b0a552a..d71a7e64d 100644 --- a/cpp/tests/spatial/nearest_points/point_linestring_nearest_points_test.cu +++ b/cpp/tests/spatial/nearest_points/point_linestring_nearest_points_test.cu @@ -16,7 +16,6 @@ #include -#include #include #include #include diff --git a/cpp/tests/trajectory/derive_trajectories_test.cu b/cpp/tests/trajectory/derive_trajectories_test.cu index a52b8e6c7..c4f64a9fe 100644 --- a/cpp/tests/trajectory/derive_trajectories_test.cu +++ b/cpp/tests/trajectory/derive_trajectories_test.cu @@ -18,8 +18,8 @@ #include "trajectory_test_utils.cuh" #include -#include #include +#include #include #include diff --git a/cpp/tests/trajectory/trajectory_distances_and_speeds_test.cu b/cpp/tests/trajectory/trajectory_distances_and_speeds_test.cu index f7fd2eddd..e84a37e84 100644 --- a/cpp/tests/trajectory/trajectory_distances_and_speeds_test.cu +++ b/cpp/tests/trajectory/trajectory_distances_and_speeds_test.cu @@ -19,8 +19,8 @@ #include -#include #include +#include #include #include From 0b36d494fef069b3bc7ac0a6aaa4ff653ebb097a Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Wed, 26 Apr 2023 03:31:20 +0000 Subject: [PATCH 03/18] Consolidate trajectory headers --- ...derive_trajectories.cuh => trajectory.cuh} | 43 +++++++++++ .../trajectory_distances_and_speeds.cuh | 76 ------------------- cpp/src/trajectory/derive_trajectories.cu | 2 +- .../trajectory_distances_and_speeds.cu | 2 +- .../trajectory/derive_trajectories_test.cu | 2 +- .../trajectory_distances_and_speeds_test.cu | 2 +- 6 files changed, 47 insertions(+), 80 deletions(-) rename cpp/include/cuspatial/{derive_trajectories.cuh => trajectory.cuh} (63%) delete mode 100644 cpp/include/cuspatial/trajectory_distances_and_speeds.cuh diff --git a/cpp/include/cuspatial/derive_trajectories.cuh b/cpp/include/cuspatial/trajectory.cuh similarity index 63% rename from cpp/include/cuspatial/derive_trajectories.cuh rename to cpp/include/cuspatial/trajectory.cuh index e647f28bc..a08d1f837 100644 --- a/cpp/include/cuspatial/derive_trajectories.cuh +++ b/cpp/include/cuspatial/trajectory.cuh @@ -88,6 +88,48 @@ std::unique_ptr> derive_trajectories( rmm::cuda_stream_view stream = rmm::cuda_stream_default, rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); +/** + * @brief Compute the total distance (in meters) and average speed (in m/s) of objects in + * trajectories. + * + * @note Assumes object_id, timestamp, x, y presorted by (object_id, timestamp). + * + * @tparam IdInputIt Iterator over object IDs. Must meet the requirements of + * [LegacyRandomAccessIterator][LinkLRAI] and be device-readable. + * @tparam PointInputIt Iterator over points. Must meet the requirements of + * [LegacyRandomAccessIterator][LinkLRAI] and be device-readable. + * @tparam TimestampInputIt Iterator over timestamps. Must meet the requirements of + * [LegacyRandomAccessIterator][LinkLRAI] and be device-readable. + * @tparam OutputIt Iterator over output (distance, speed) pairs. Must meet the requirements of + * [LegacyRandomAccessIterator][LinkLRAI] and be device-writeable. + * @tparam IndexT The type of the object IDs. + * + * @param num_trajectories number of trajectories (unique object ids) + * @param ids_first beginning of the range of input object ids + * @param ids_last end of the range of input object ids + * @param points_first beginning of the range of input point (x,y) coordinates + * @param timestamps_first beginning of the range of input timestamps + * @param distances_and_speeds_first beginning of the range of output (distance, speed) pairs + * @param stream the CUDA stream on which to perform computations and allocate memory. + * + * @return An iterator to the end of the range of output (distance, speed) pairs. + * + * [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator + * "LegacyRandomAccessIterator" + */ +template > +OutputIt trajectory_distances_and_speeds(IndexT num_trajectories, + IdInputIt ids_first, + IdInputIt ids_last, + PointInputIt points_first, + TimestampInputIt timestamps_first, + OutputIt distances_and_speeds_first, + rmm::cuda_stream_view stream = rmm::cuda_stream_default); + /** * @} // end of doxygen group */ @@ -95,3 +137,4 @@ std::unique_ptr> derive_trajectories( } // namespace cuspatial #include +#include diff --git a/cpp/include/cuspatial/trajectory_distances_and_speeds.cuh b/cpp/include/cuspatial/trajectory_distances_and_speeds.cuh deleted file mode 100644 index 81fc9c5a2..000000000 --- a/cpp/include/cuspatial/trajectory_distances_and_speeds.cuh +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2022, 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 - -#include - -namespace cuspatial { - -/** - * @addtogroup trajectory_api - * @{ - */ - -/** - * @brief Compute the total distance (in meters) and average speed (in m/s) of objects in - * trajectories. - * - * @note Assumes object_id, timestamp, x, y presorted by (object_id, timestamp). - * - * @tparam IdInputIt Iterator over object IDs. Must meet the requirements of - * [LegacyRandomAccessIterator][LinkLRAI] and be device-readable. - * @tparam PointInputIt Iterator over points. Must meet the requirements of - * [LegacyRandomAccessIterator][LinkLRAI] and be device-readable. - * @tparam TimestampInputIt Iterator over timestamps. Must meet the requirements of - * [LegacyRandomAccessIterator][LinkLRAI] and be device-readable. - * @tparam OutputIt Iterator over output (distance, speed) pairs. Must meet the requirements of - * [LegacyRandomAccessIterator][LinkLRAI] and be device-writeable. - * @tparam IndexT The type of the object IDs. - * - * @param num_trajectories number of trajectories (unique object ids) - * @param ids_first beginning of the range of input object ids - * @param ids_last end of the range of input object ids - * @param points_first beginning of the range of input point (x,y) coordinates - * @param timestamps_first beginning of the range of input timestamps - * @param distances_and_speeds_first beginning of the range of output (distance, speed) pairs - * @param stream the CUDA stream on which to perform computations and allocate memory. - * - * @return An iterator to the end of the range of output (distance, speed) pairs. - * - * [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator - * "LegacyRandomAccessIterator" - */ -template > -OutputIt trajectory_distances_and_speeds(IndexT num_trajectories, - IdInputIt ids_first, - IdInputIt ids_last, - PointInputIt points_first, - TimestampInputIt timestamps_first, - OutputIt distances_and_speeds_first, - rmm::cuda_stream_view stream = rmm::cuda_stream_default); - -/** - * @} // end of doxygen group - */ - -} // namespace cuspatial - -#include diff --git a/cpp/src/trajectory/derive_trajectories.cu b/cpp/src/trajectory/derive_trajectories.cu index cb760f1be..cfeeea77b 100644 --- a/cpp/src/trajectory/derive_trajectories.cu +++ b/cpp/src/trajectory/derive_trajectories.cu @@ -14,9 +14,9 @@ * limitations under the License. */ -#include #include #include +#include #include #include diff --git a/cpp/src/trajectory/trajectory_distances_and_speeds.cu b/cpp/src/trajectory/trajectory_distances_and_speeds.cu index d239ec907..a27f8b7f8 100644 --- a/cpp/src/trajectory/trajectory_distances_and_speeds.cu +++ b/cpp/src/trajectory/trajectory_distances_and_speeds.cu @@ -16,8 +16,8 @@ #include #include +#include #include -#include #include #include diff --git a/cpp/tests/trajectory/derive_trajectories_test.cu b/cpp/tests/trajectory/derive_trajectories_test.cu index c4f64a9fe..cc47700c7 100644 --- a/cpp/tests/trajectory/derive_trajectories_test.cu +++ b/cpp/tests/trajectory/derive_trajectories_test.cu @@ -17,9 +17,9 @@ #include "cuspatial_test/vector_equality.hpp" #include "trajectory_test_utils.cuh" -#include #include #include +#include #include #include diff --git a/cpp/tests/trajectory/trajectory_distances_and_speeds_test.cu b/cpp/tests/trajectory/trajectory_distances_and_speeds_test.cu index e84a37e84..666b3c20b 100644 --- a/cpp/tests/trajectory/trajectory_distances_and_speeds_test.cu +++ b/cpp/tests/trajectory/trajectory_distances_and_speeds_test.cu @@ -21,8 +21,8 @@ #include #include +#include #include -#include #include From 70515f172e9f991f551536e8ae501729f318fd9b Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Wed, 26 Apr 2023 04:26:09 +0000 Subject: [PATCH 04/18] Consolidate and DRY up point_in_polygon APIs --- cpp/CMakeLists.txt | 1 - .../detail/pairwise_point_in_polygon.cuh | 136 ---------------- .../cuspatial/detail/point_in_polygon.cuh | 120 +++++++++++++- .../cuspatial/pairwise_point_in_polygon.cuh | 112 ------------- .../cuspatial/pairwise_point_in_polygon.hpp | 87 ---------- cpp/include/cuspatial/point_in_polygon.cuh | 87 ++++++++++ cpp/include/cuspatial/point_in_polygon.hpp | 49 ++++++ cpp/src/spatial/pairwise_point_in_polygon.cu | 153 ------------------ cpp/src/spatial/point_in_polygon.cu | 90 ++++++++--- .../pairwise_point_in_polygon_test.cpp | 2 +- .../pairwise_point_in_polygon_test.cu | 2 +- 11 files changed, 320 insertions(+), 519 deletions(-) delete mode 100644 cpp/include/cuspatial/detail/pairwise_point_in_polygon.cuh delete mode 100644 cpp/include/cuspatial/pairwise_point_in_polygon.cuh delete mode 100644 cpp/include/cuspatial/pairwise_point_in_polygon.hpp delete mode 100644 cpp/src/spatial/pairwise_point_in_polygon.cu diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index d1cdb4e85..9cd9e7ff8 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -125,7 +125,6 @@ add_library(cuspatial src/spatial/linestring_bounding_boxes.cu src/spatial/polygon_bounding_boxes.cu src/spatial/point_in_polygon.cu - src/spatial/pairwise_point_in_polygon.cu src/spatial_window/spatial_window.cu src/spatial/haversine.cu src/spatial/hausdorff.cu diff --git a/cpp/include/cuspatial/detail/pairwise_point_in_polygon.cuh b/cpp/include/cuspatial/detail/pairwise_point_in_polygon.cuh deleted file mode 100644 index 14951b711..000000000 --- a/cpp/include/cuspatial/detail/pairwise_point_in_polygon.cuh +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2022-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. - */ - -#pragma once - -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include - -namespace cuspatial { -namespace detail { - -template ::difference_type, - class Cart2dItBDiffType = typename std::iterator_traits::difference_type, - class OffsetItADiffType = typename std::iterator_traits::difference_type, - class OffsetItBDiffType = typename std::iterator_traits::difference_type> -__global__ void pairwise_point_in_polygon_kernel(Cart2dItA test_points_first, - Cart2dItADiffType const num_test_points, - OffsetIteratorA poly_offsets_first, - OffsetItADiffType const num_polys, - OffsetIteratorB ring_offsets_first, - OffsetItBDiffType const num_rings, - Cart2dItB poly_points_first, - Cart2dItBDiffType const num_poly_points, - OutputIt result) -{ - using Cart2d = iterator_value_type; - using OffsetType = iterator_value_type; - for (auto idx = threadIdx.x + blockIdx.x * blockDim.x; idx < num_test_points; - idx += gridDim.x * blockDim.x) { - Cart2d const test_point = test_points_first[idx]; - // for the matching polygon - OffsetType poly_begin = poly_offsets_first[idx]; - OffsetType poly_end = (idx + 1 < num_polys) ? poly_offsets_first[idx + 1] : num_rings; - bool const point_is_within = is_point_in_polygon(test_point, - poly_begin, - poly_end, - ring_offsets_first, - num_rings, - poly_points_first, - num_poly_points); - result[idx] = point_is_within; - } -} - -} // namespace detail - -template -OutputIt pairwise_point_in_polygon(Cart2dItA test_points_first, - Cart2dItA test_points_last, - OffsetIteratorA polygon_offsets_first, - OffsetIteratorA polygon_offsets_last, - OffsetIteratorB poly_ring_offsets_first, - OffsetIteratorB poly_ring_offsets_last, - Cart2dItB polygon_points_first, - Cart2dItB polygon_points_last, - OutputIt output, - rmm::cuda_stream_view stream) -{ - using T = iterator_vec_base_type; - - static_assert(is_same_floating_point>(), - "Underlying type of Cart2dItA and Cart2dItB must be the same floating point type"); - static_assert( - is_same, iterator_value_type, iterator_value_type>(), - "Inputs must be cuspatial::vec_2d"); - - static_assert(cuspatial::is_integral, - iterator_value_type>(), - "OffsetIterators must point to integral type."); - - static_assert(std::is_same_v, int32_t>, - "OutputIt must point to 32 bit integer type."); - - auto const num_test_points = std::distance(test_points_first, test_points_last); - auto const num_polys = std::distance(polygon_offsets_first, polygon_offsets_last) - 1; - auto const num_rings = std::distance(poly_ring_offsets_first, poly_ring_offsets_last) - 1; - auto const num_poly_points = std::distance(polygon_points_first, polygon_points_last); - - CUSPATIAL_EXPECTS_VALID_POLYGON_SIZES( - num_poly_points, - std::distance(polygon_offsets_first, polygon_offsets_last), - std::distance(poly_ring_offsets_first, poly_ring_offsets_last)); - - CUSPATIAL_EXPECTS(num_test_points == num_polys, - "Must pass in an equal number of points and polygons"); - - auto [threads_per_block, num_blocks] = grid_1d(num_test_points); - detail::pairwise_point_in_polygon_kernel<<>>( - test_points_first, - num_test_points, - polygon_offsets_first, - num_polys, - poly_ring_offsets_first, - num_rings, - polygon_points_first, - num_poly_points, - output); - CUSPATIAL_CHECK_CUDA(stream.value()); - - return output + num_test_points; -} - -} // namespace cuspatial diff --git a/cpp/include/cuspatial/detail/point_in_polygon.cuh b/cpp/include/cuspatial/detail/point_in_polygon.cuh index bf841391a..ecf6dd0ba 100644 --- a/cpp/include/cuspatial/detail/point_in_polygon.cuh +++ b/cpp/include/cuspatial/detail/point_in_polygon.cuh @@ -32,6 +32,21 @@ namespace cuspatial { namespace detail { +// Get the begin and end offsets of a polygon +template > +__device__ auto poly_begin_end(OffsetIteratorA poly_offsets_first, + OffsetItADiffType const num_polys, + OffsetItADiffType const num_rings, + OffsetType const poly_idx) +{ + auto poly_idx_next = poly_idx + 1; + OffsetType poly_begin = poly_offsets_first[poly_idx]; + OffsetType poly_end = (poly_idx_next < num_polys) ? poly_offsets_first[poly_idx_next] : num_rings; + return std::make_pair(poly_begin, poly_end); +} + template ::difference_type, + class Cart2dItBDiffType = typename std::iterator_traits::difference_type, + class OffsetItADiffType = typename std::iterator_traits::difference_type, + class OffsetItBDiffType = typename std::iterator_traits::difference_type> +__global__ void pairwise_point_in_polygon_kernel(Cart2dItA test_points_first, + Cart2dItADiffType const num_test_points, + OffsetIteratorA poly_offsets_first, + OffsetItADiffType const num_polys, + OffsetIteratorB ring_offsets_first, + OffsetItBDiffType const num_rings, + Cart2dItB poly_points_first, + Cart2dItBDiffType const num_poly_points, + OutputIt result) +{ + using Cart2d = iterator_value_type; + using OffsetType = iterator_value_type; + for (auto idx = threadIdx.x + blockIdx.x * blockDim.x; idx < num_test_points; + idx += gridDim.x * blockDim.x) { + Cart2d const test_point = test_points_first[idx]; + + // for the matching polygon + auto [poly_begin, poly_end] = poly_begin_end(poly_offsets_first, num_polys, num_rings, idx); + + bool const point_is_within = is_point_in_polygon(test_point, + poly_begin, + poly_end, + ring_offsets_first, + num_rings, + poly_points_first, + num_poly_points); + result[idx] = point_is_within; + } +} + } // namespace detail template +OutputIt pairwise_point_in_polygon(Cart2dItA test_points_first, + Cart2dItA test_points_last, + OffsetIteratorA polygon_offsets_first, + OffsetIteratorA polygon_offsets_last, + OffsetIteratorB poly_ring_offsets_first, + OffsetIteratorB poly_ring_offsets_last, + Cart2dItB polygon_points_first, + Cart2dItB polygon_points_last, + OutputIt output, + rmm::cuda_stream_view stream) +{ + using T = iterator_vec_base_type; + + static_assert(is_same_floating_point>(), + "Underlying type of Cart2dItA and Cart2dItB must be the same floating point type"); + static_assert( + is_same, iterator_value_type, iterator_value_type>(), + "Inputs must be cuspatial::vec_2d"); + + static_assert(cuspatial::is_integral, + iterator_value_type>(), + "OffsetIterators must point to integral type."); + + static_assert(std::is_same_v, int32_t>, + "OutputIt must point to 32 bit integer type."); + + auto const num_test_points = std::distance(test_points_first, test_points_last); + auto const num_polys = std::distance(polygon_offsets_first, polygon_offsets_last) - 1; + auto const num_rings = std::distance(poly_ring_offsets_first, poly_ring_offsets_last) - 1; + auto const num_poly_points = std::distance(polygon_points_first, polygon_points_last); + + CUSPATIAL_EXPECTS_VALID_POLYGON_SIZES( + num_poly_points, + std::distance(polygon_offsets_first, polygon_offsets_last), + std::distance(poly_ring_offsets_first, poly_ring_offsets_last)); + + CUSPATIAL_EXPECTS(num_test_points == num_polys, + "Must pass in an equal number of points and polygons"); + + auto [threads_per_block, num_blocks] = grid_1d(num_test_points); + detail::pairwise_point_in_polygon_kernel<<>>( + test_points_first, + num_test_points, + polygon_offsets_first, + num_polys, + poly_ring_offsets_first, + num_rings, + polygon_points_first, + num_poly_points, + output); + CUSPATIAL_CHECK_CUDA(stream.value()); + + return output + num_test_points; +} + } // namespace cuspatial diff --git a/cpp/include/cuspatial/pairwise_point_in_polygon.cuh b/cpp/include/cuspatial/pairwise_point_in_polygon.cuh deleted file mode 100644 index ac921556a..000000000 --- a/cpp/include/cuspatial/pairwise_point_in_polygon.cuh +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2022, 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. - */ - -#pragma once - -#include - -namespace cuspatial { - -/** - * @ingroup spatial_relationship - * - * @brief Given (point, polygon) pairs, tests whether the point of each pair is inside the polygon - * of the pair. - * - * Tests whether each point is inside a corresponding polygon. Points on the edges of the - * polygon are not considered to be inside. - * Polygons are a collection of one or more rings. Rings are a collection of three or more vertices. - * - * Each input point will map to one `int32_t` element in the output. - * - * - * @tparam Cart2dItA iterator type for point array. Must meet - * the requirements of [LegacyRandomAccessIterator][LinkLRAI] and be device-accessible. - * @tparam Cart2dItB iterator type for point array. Must meet - * the requirements of [LegacyRandomAccessIterator][LinkLRAI] and be device-accessible. - * @tparam OffsetIteratorA iterator type for offset array. Must meet - * the requirements of [LegacyRandomAccessIterator][LinkLRAI] and be device-accessible. - * @tparam OffsetIteratorB iterator type for offset array. Must meet - * the requirements of [LegacyRandomAccessIterator][LinkLRAI] and be device-accessible. - * @tparam OutputIt iterator type for output array. Must meet - * the requirements of [LegacyRandomAccessIterator][LinkLRAI], be device-accessible, mutable and - * iterate on `int32_t` type. - * - * @param test_points_first begin of range of test points - * @param test_points_last end of range of test points - * @param polygon_offsets_first begin of range of indices to the first ring in each polygon - * @param polygon_offsets_last end of range of indices to the first ring in each polygon - * @param ring_offsets_first begin of range of indices to the first point in each ring - * @param ring_offsets_last end of range of indices to the first point in each ring - * @param polygon_points_first begin of range of polygon points - * @param polygon_points_last end of range of polygon points - * @param output begin iterator to the output buffer - * @param stream The CUDA stream to use for kernel launches. - * @return iterator to one past the last element in the output buffer - * - * @note Direction of rings does not matter. - * @note This algorithm supports the ESRI shapefile format, but assumes all polygons are "clean" (as - * defined by the format), and does _not_ verify whether the input adheres to the shapefile format. - * @note The points of the rings must be explicitly closed. - * @note Overlapping rings negate each other. This behavior is not limited to a single negation, - * allowing for "islands" within the same polygon. - * @note `poly_ring_offsets` must contain only the rings that make up the polygons indexed by - * `poly_offsets`. If there are rings in `poly_ring_offsets` that are not part of the polygons in - * `poly_offsets`, results are likely to be incorrect and behavior is undefined. - * - * ``` - * poly w/two rings poly w/four rings - * +-----------+ +------------------------+ - * :███████████: :████████████████████████: - * :███████████: :██+------------------+██: - * :██████+----:------+ :██: +----+ +----+ :██: - * :██████: :██████: :██: :████: :████: :██: - * +------;----+██████: :██: :----: :----: :██: - * :███████████: :██+------------------+██: - * :███████████: :████████████████████████: - * +-----------+ +------------------------+ - * ``` - * - * @pre All point iterators must have the same `vec_2d` value type, with the same underlying - * floating-point coordinate type (e.g. `cuspatial::vec_2d`). - * @pre All offset iterators must have the same integral value type. - * @pre Output iterator must be mutable and iterate on int32_t type. - * - * @throw cuspatial::logic_error polygon has less than 1 ring. - * @throw cuspatial::logic_error polygon has less than 4 vertices. - * - * [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator - * "LegacyRandomAccessIterator" - */ -template -OutputIt pairwise_point_in_polygon(Cart2dItA test_points_first, - Cart2dItA test_points_last, - OffsetIteratorA polygon_offsets_first, - OffsetIteratorA polygon_offsets_last, - OffsetIteratorB poly_ring_offsets_first, - OffsetIteratorB poly_ring_offsets_last, - Cart2dItB polygon_points_first, - Cart2dItB polygon_points_last, - OutputIt output, - rmm::cuda_stream_view stream = rmm::cuda_stream_default); - -} // namespace cuspatial - -#include diff --git a/cpp/include/cuspatial/pairwise_point_in_polygon.hpp b/cpp/include/cuspatial/pairwise_point_in_polygon.hpp deleted file mode 100644 index 76563d2fc..000000000 --- a/cpp/include/cuspatial/pairwise_point_in_polygon.hpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2020-2022, 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. - */ - -#pragma once - -#include -#include -#include - -#include - -#include - -namespace cuspatial { - -/** - * @addtogroup spatial_relationship - * @{ - */ - -/** - * @brief Given (point, polygon pairs), tests whether the point of each pair is inside the polygon - * of the pair. - * - * Tests that each point is or is not inside of the polygon in the corresponding index. - * Polygons are a collection of one or more * rings. Rings are a collection of three or more - * vertices. - * - * @param[in] test_points_x: x-coordinates of points to test - * @param[in] test_points_y: y-coordinates of points to test - * @param[in] poly_offsets: beginning index of the first ring in each polygon - * @param[in] poly_ring_offsets: beginning index of the first point in each ring - * @param[in] poly_points_x: x-coordinates of polygon points - * @param[in] poly_points_y: y-coordinates of polygon points - * - * @returns A column of booleans for each point/polygon pair. - * - * @note Direction of rings does not matter. - * @note Supports open or closed polygon formats. - * @note This algorithm supports the ESRI shapefile format, but assumes all polygons are "clean" (as - * defined by the format), and does _not_ verify whether the input adheres to the shapefile format. - * @note Overlapping rings negate each other. This behavior is not limited to a single negation, - * allowing for "islands" within the same polygon. - * @note `poly_ring_offsets` must contain only the rings that make up the polygons indexed by - * `poly_offsets`. If there are rings in `poly_ring_offsets` that are not part of the polygons in - * `poly_offsets`, results are likely to be incorrect and behavior is undefined. - * - * ``` - * poly w/two rings poly w/four rings - * +-----------+ +------------------------+ - * :███████████: :████████████████████████: - * :███████████: :██+------------------+██: - * :██████+----:------+ :██: +----+ +----+ :██: - * :██████: :██████: :██: :████: :████: :██: - * +------;----+██████: :██: :----: :----: :██: - * :███████████: :██+------------------+██: - * :███████████: :████████████████████████: - * +-----------+ +------------------------+ - * ``` - */ -std::unique_ptr pairwise_point_in_polygon( - cudf::column_view const& test_points_x, - cudf::column_view const& test_points_y, - cudf::column_view const& poly_offsets, - cudf::column_view const& poly_ring_offsets, - cudf::column_view const& poly_points_x, - cudf::column_view const& poly_points_y, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); - -/** - * @} // end of doxygen group - */ - -} // namespace cuspatial diff --git a/cpp/include/cuspatial/point_in_polygon.cuh b/cpp/include/cuspatial/point_in_polygon.cuh index 8fcda7f80..a0038f458 100644 --- a/cpp/include/cuspatial/point_in_polygon.cuh +++ b/cpp/include/cuspatial/point_in_polygon.cuh @@ -110,6 +110,93 @@ OutputIt point_in_polygon(Cart2dItA test_points_first, OutputIt output, rmm::cuda_stream_view stream = rmm::cuda_stream_default); +/** + * @ingroup spatial_relationship + * + * @brief Given (point, polygon) pairs, tests whether the point of each pair is inside the polygon + * of the pair. + * + * Tests whether each point is inside a corresponding polygon. Points on the edges of the + * polygon are not considered to be inside. + * Polygons are a collection of one or more rings. Rings are a collection of three or more vertices. + * + * Each input point will map to one `int32_t` element in the output. + * + * + * @tparam Cart2dItA iterator type for point array. Must meet + * the requirements of [LegacyRandomAccessIterator][LinkLRAI] and be device-accessible. + * @tparam Cart2dItB iterator type for point array. Must meet + * the requirements of [LegacyRandomAccessIterator][LinkLRAI] and be device-accessible. + * @tparam OffsetIteratorA iterator type for offset array. Must meet + * the requirements of [LegacyRandomAccessIterator][LinkLRAI] and be device-accessible. + * @tparam OffsetIteratorB iterator type for offset array. Must meet + * the requirements of [LegacyRandomAccessIterator][LinkLRAI] and be device-accessible. + * @tparam OutputIt iterator type for output array. Must meet + * the requirements of [LegacyRandomAccessIterator][LinkLRAI], be device-accessible, mutable and + * iterate on `int32_t` type. + * + * @param test_points_first begin of range of test points + * @param test_points_last end of range of test points + * @param polygon_offsets_first begin of range of indices to the first ring in each polygon + * @param polygon_offsets_last end of range of indices to the first ring in each polygon + * @param ring_offsets_first begin of range of indices to the first point in each ring + * @param ring_offsets_last end of range of indices to the first point in each ring + * @param polygon_points_first begin of range of polygon points + * @param polygon_points_last end of range of polygon points + * @param output begin iterator to the output buffer + * @param stream The CUDA stream to use for kernel launches. + * @return iterator to one past the last element in the output buffer + * + * @note Direction of rings does not matter. + * @note This algorithm supports the ESRI shapefile format, but assumes all polygons are "clean" (as + * defined by the format), and does _not_ verify whether the input adheres to the shapefile format. + * @note The points of the rings must be explicitly closed. + * @note Overlapping rings negate each other. This behavior is not limited to a single negation, + * allowing for "islands" within the same polygon. + * @note `poly_ring_offsets` must contain only the rings that make up the polygons indexed by + * `poly_offsets`. If there are rings in `poly_ring_offsets` that are not part of the polygons in + * `poly_offsets`, results are likely to be incorrect and behavior is undefined. + * + * ``` + * poly w/two rings poly w/four rings + * +-----------+ +------------------------+ + * :███████████: :████████████████████████: + * :███████████: :██+------------------+██: + * :██████+----:------+ :██: +----+ +----+ :██: + * :██████: :██████: :██: :████: :████: :██: + * +------;----+██████: :██: :----: :----: :██: + * :███████████: :██+------------------+██: + * :███████████: :████████████████████████: + * +-----------+ +------------------------+ + * ``` + * + * @pre All point iterators must have the same `vec_2d` value type, with the same underlying + * floating-point coordinate type (e.g. `cuspatial::vec_2d`). + * @pre All offset iterators must have the same integral value type. + * @pre Output iterator must be mutable and iterate on int32_t type. + * + * @throw cuspatial::logic_error polygon has less than 1 ring. + * @throw cuspatial::logic_error polygon has less than 4 vertices. + * + * [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator + * "LegacyRandomAccessIterator" + */ +template +OutputIt pairwise_point_in_polygon(Cart2dItA test_points_first, + Cart2dItA test_points_last, + OffsetIteratorA polygon_offsets_first, + OffsetIteratorA polygon_offsets_last, + OffsetIteratorB poly_ring_offsets_first, + OffsetIteratorB poly_ring_offsets_last, + Cart2dItB polygon_points_first, + Cart2dItB polygon_points_last, + OutputIt output, + rmm::cuda_stream_view stream = rmm::cuda_stream_default); + } // namespace cuspatial #include diff --git a/cpp/include/cuspatial/point_in_polygon.hpp b/cpp/include/cuspatial/point_in_polygon.hpp index 36703e450..11e7381c3 100644 --- a/cpp/include/cuspatial/point_in_polygon.hpp +++ b/cpp/include/cuspatial/point_in_polygon.hpp @@ -80,6 +80,55 @@ std::unique_ptr point_in_polygon( cudf::column_view const& poly_points_y, rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); +/** + * @brief Given (point, polygon pairs), tests whether the point of each pair is inside the polygon + * of the pair. + * + * Tests that each point is or is not inside of the polygon in the corresponding index. + * Polygons are a collection of one or more * rings. Rings are a collection of three or more + * vertices. + * + * @param[in] test_points_x: x-coordinates of points to test + * @param[in] test_points_y: y-coordinates of points to test + * @param[in] poly_offsets: beginning index of the first ring in each polygon + * @param[in] poly_ring_offsets: beginning index of the first point in each ring + * @param[in] poly_points_x: x-coordinates of polygon points + * @param[in] poly_points_y: y-coordinates of polygon points + * + * @returns A column of booleans for each point/polygon pair. + * + * @note Direction of rings does not matter. + * @note Supports open or closed polygon formats. + * @note This algorithm supports the ESRI shapefile format, but assumes all polygons are "clean" (as + * defined by the format), and does _not_ verify whether the input adheres to the shapefile format. + * @note Overlapping rings negate each other. This behavior is not limited to a single negation, + * allowing for "islands" within the same polygon. + * @note `poly_ring_offsets` must contain only the rings that make up the polygons indexed by + * `poly_offsets`. If there are rings in `poly_ring_offsets` that are not part of the polygons in + * `poly_offsets`, results are likely to be incorrect and behavior is undefined. + * + * ``` + * poly w/two rings poly w/four rings + * +-----------+ +------------------------+ + * :███████████: :████████████████████████: + * :███████████: :██+------------------+██: + * :██████+----:------+ :██: +----+ +----+ :██: + * :██████: :██████: :██: :████: :████: :██: + * +------;----+██████: :██: :----: :----: :██: + * :███████████: :██+------------------+██: + * :███████████: :████████████████████████: + * +-----------+ +------------------------+ + * ``` + */ +std::unique_ptr pairwise_point_in_polygon( + cudf::column_view const& test_points_x, + cudf::column_view const& test_points_y, + cudf::column_view const& poly_offsets, + cudf::column_view const& poly_ring_offsets, + cudf::column_view const& poly_points_x, + cudf::column_view const& poly_points_y, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + /** * @} // end of doxygen group */ diff --git a/cpp/src/spatial/pairwise_point_in_polygon.cu b/cpp/src/spatial/pairwise_point_in_polygon.cu deleted file mode 100644 index b263c223b..000000000 --- a/cpp/src/spatial/pairwise_point_in_polygon.cu +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (c) 2022-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 -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include - -namespace { - -struct pairwise_point_in_polygon_functor { - template - static constexpr bool is_supported() - { - return std::is_floating_point::value; - } - - template ()>* = nullptr, typename... Args> - std::unique_ptr operator()(Args&&...) - { - CUSPATIAL_FAIL("Non-floating point operation is not supported"); - } - - template ()>* = nullptr> - std::unique_ptr operator()(cudf::column_view const& test_points_x, - cudf::column_view const& test_points_y, - cudf::column_view const& poly_offsets, - cudf::column_view const& poly_ring_offsets, - cudf::column_view const& poly_points_x, - cudf::column_view const& poly_points_y, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr) - { - auto size = test_points_x.size(); - auto tid = cudf::type_to_id(); - auto type = cudf::data_type{tid}; - auto results = - cudf::make_fixed_width_column(type, size, cudf::mask_state::UNALLOCATED, stream, mr); - - if (results->size() == 0) { return results; } - - auto points_begin = - cuspatial::make_vec_2d_iterator(test_points_x.begin(), test_points_y.begin()); - auto polygon_offsets_begin = poly_offsets.begin(); - auto ring_offsets_begin = poly_ring_offsets.begin(); - auto polygon_points_begin = - cuspatial::make_vec_2d_iterator(poly_points_x.begin(), poly_points_y.begin()); - auto results_begin = results->mutable_view().begin(); - - cuspatial::pairwise_point_in_polygon(points_begin, - points_begin + test_points_x.size(), - polygon_offsets_begin, - polygon_offsets_begin + poly_offsets.size(), - ring_offsets_begin, - ring_offsets_begin + poly_ring_offsets.size(), - polygon_points_begin, - polygon_points_begin + poly_points_x.size(), - results_begin, - stream); - - return results; - } -}; -} // anonymous namespace - -namespace cuspatial { - -namespace detail { - -std::unique_ptr pairwise_point_in_polygon(cudf::column_view const& test_points_x, - cudf::column_view const& test_points_y, - cudf::column_view const& poly_offsets, - cudf::column_view const& poly_ring_offsets, - cudf::column_view const& poly_points_x, - cudf::column_view const& poly_points_y, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr) -{ - return cudf::type_dispatcher(test_points_x.type(), - pairwise_point_in_polygon_functor(), - test_points_x, - test_points_y, - poly_offsets, - poly_ring_offsets, - poly_points_x, - poly_points_y, - stream, - mr); -} - -} // namespace detail - -std::unique_ptr pairwise_point_in_polygon(cudf::column_view const& test_points_x, - cudf::column_view const& test_points_y, - cudf::column_view const& poly_offsets, - cudf::column_view const& poly_ring_offsets, - cudf::column_view const& poly_points_x, - cudf::column_view const& poly_points_y, - rmm::mr::device_memory_resource* mr) -{ - CUSPATIAL_EXPECTS( - test_points_x.size() == test_points_y.size() and poly_points_x.size() == poly_points_y.size(), - "All points must have both x and y values"); - - CUSPATIAL_EXPECTS(test_points_x.type() == test_points_y.type() and - test_points_x.type() == poly_points_x.type() and - test_points_x.type() == poly_points_y.type(), - "All points much have the same type for both x and y"); - - CUSPATIAL_EXPECTS(not test_points_x.has_nulls() && not test_points_y.has_nulls(), - "Test points must not contain nulls"); - - CUSPATIAL_EXPECTS(not poly_points_x.has_nulls() && not poly_points_y.has_nulls(), - "Polygon points must not contain nulls"); - - CUSPATIAL_EXPECTS(test_points_x.size() == std::max(poly_offsets.size() - 1, 0), - "Must pass in the same number of points as polygons."); - - return cuspatial::detail::pairwise_point_in_polygon(test_points_x, - test_points_y, - poly_offsets, - poly_ring_offsets, - poly_points_x, - poly_points_y, - rmm::cuda_stream_default, - mr); -} - -} // namespace cuspatial diff --git a/cpp/src/spatial/point_in_polygon.cu b/cpp/src/spatial/point_in_polygon.cu index 22ff97609..255a507cf 100644 --- a/cpp/src/spatial/point_in_polygon.cu +++ b/cpp/src/spatial/point_in_polygon.cu @@ -52,6 +52,7 @@ struct point_in_polygon_functor { cudf::column_view const& poly_ring_offsets, cudf::column_view const& poly_points_x, cudf::column_view const& poly_points_y, + bool pairwise, rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr) { @@ -71,16 +72,30 @@ struct point_in_polygon_functor { cuspatial::make_vec_2d_iterator(poly_points_x.begin(), poly_points_y.begin()); auto results_begin = results->mutable_view().begin(); - cuspatial::point_in_polygon(points_begin, - points_begin + test_points_x.size(), - polygon_offsets_begin, - polygon_offsets_begin + poly_offsets.size(), - ring_offsets_begin, - ring_offsets_begin + poly_ring_offsets.size(), - polygon_points_begin, - polygon_points_begin + poly_points_x.size(), - results_begin, - stream); + if (pairwise) { + cuspatial::pairwise_point_in_polygon(points_begin, + points_begin + test_points_x.size(), + polygon_offsets_begin, + polygon_offsets_begin + poly_offsets.size(), + ring_offsets_begin, + ring_offsets_begin + poly_ring_offsets.size(), + polygon_points_begin, + polygon_points_begin + poly_points_x.size(), + results_begin, + stream); + + } else { + cuspatial::point_in_polygon(points_begin, + points_begin + test_points_x.size(), + polygon_offsets_begin, + polygon_offsets_begin + poly_offsets.size(), + ring_offsets_begin, + ring_offsets_begin + poly_ring_offsets.size(), + polygon_points_begin, + polygon_points_begin + poly_points_x.size(), + results_begin, + stream); + } return results; } @@ -97,9 +112,30 @@ std::unique_ptr point_in_polygon(cudf::column_view const& test_poi cudf::column_view const& poly_ring_offsets, cudf::column_view const& poly_points_x, cudf::column_view const& poly_points_y, + bool pairwise, rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr) { + CUSPATIAL_EXPECTS( + test_points_x.size() == test_points_y.size() and poly_points_x.size() == poly_points_y.size(), + "All points must have both x and y values"); + + CUSPATIAL_EXPECTS(test_points_x.type() == test_points_y.type() and + test_points_x.type() == poly_points_x.type() and + test_points_x.type() == poly_points_y.type(), + "All points much have the same type for both x and y"); + + CUSPATIAL_EXPECTS(not test_points_x.has_nulls() && not test_points_y.has_nulls(), + "Test points must not contain nulls"); + + CUSPATIAL_EXPECTS(not poly_points_x.has_nulls() && not poly_points_y.has_nulls(), + "Polygon points must not contain nulls"); + + if (pairwise) { + CUSPATIAL_EXPECTS(test_points_x.size() == std::max(poly_offsets.size() - 1, 0), + "Must pass in the same number of points as polygons."); + } + return cudf::type_dispatcher(test_points_x.type(), point_in_polygon_functor(), test_points_x, @@ -108,6 +144,7 @@ std::unique_ptr point_in_polygon(cudf::column_view const& test_poi poly_ring_offsets, poly_points_x, poly_points_y, + pairwise, stream, mr); } @@ -122,27 +159,32 @@ std::unique_ptr point_in_polygon(cudf::column_view const& test_poi cudf::column_view const& poly_points_y, rmm::mr::device_memory_resource* mr) { - CUSPATIAL_EXPECTS( - test_points_x.size() == test_points_y.size() and poly_points_x.size() == poly_points_y.size(), - "All points must have both x and y values"); - - CUSPATIAL_EXPECTS(test_points_x.type() == test_points_y.type() and - test_points_x.type() == poly_points_x.type() and - test_points_x.type() == poly_points_y.type(), - "All points much have the same type for both x and y"); - - CUSPATIAL_EXPECTS(not test_points_x.has_nulls() && not test_points_y.has_nulls(), - "Test points must not contain nulls"); - - CUSPATIAL_EXPECTS(not poly_points_x.has_nulls() && not poly_points_y.has_nulls(), - "Polygon points must not contain nulls"); + return cuspatial::detail::point_in_polygon(test_points_x, + test_points_y, + poly_offsets, + poly_ring_offsets, + poly_points_x, + poly_points_y, + false, + rmm::cuda_stream_default, + mr); +} +std::unique_ptr pairwise_point_in_polygon(cudf::column_view const& test_points_x, + cudf::column_view const& test_points_y, + cudf::column_view const& poly_offsets, + cudf::column_view const& poly_ring_offsets, + cudf::column_view const& poly_points_x, + cudf::column_view const& poly_points_y, + rmm::mr::device_memory_resource* mr) +{ return cuspatial::detail::point_in_polygon(test_points_x, test_points_y, poly_offsets, poly_ring_offsets, poly_points_x, poly_points_y, + true, rmm::cuda_stream_default, mr); } diff --git a/cpp/tests/spatial/point_in_polygon/pairwise_point_in_polygon_test.cpp b/cpp/tests/spatial/point_in_polygon/pairwise_point_in_polygon_test.cpp index 97d9f7b7c..477d8ce90 100644 --- a/cpp/tests/spatial/point_in_polygon/pairwise_point_in_polygon_test.cpp +++ b/cpp/tests/spatial/point_in_polygon/pairwise_point_in_polygon_test.cpp @@ -15,7 +15,7 @@ */ #include -#include +#include #include #include diff --git a/cpp/tests/spatial/point_in_polygon/pairwise_point_in_polygon_test.cu b/cpp/tests/spatial/point_in_polygon/pairwise_point_in_polygon_test.cu index 13ae6a456..c05c24f63 100644 --- a/cpp/tests/spatial/point_in_polygon/pairwise_point_in_polygon_test.cu +++ b/cpp/tests/spatial/point_in_polygon/pairwise_point_in_polygon_test.cu @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include From 972c049dbb09d67ceca23a0340649bee59a407e7 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Wed, 26 Apr 2023 04:34:16 +0000 Subject: [PATCH 05/18] Consolidate intersection headers --- .../{linestring_intersection.cuh => intersection.cuh} | 0 .../{linestring_intersection.hpp => intersection.hpp} | 0 cpp/src/spatial/linestring_intersection.cu | 4 ++-- .../spatial/intersection/linestring_intersection_test.cpp | 2 +- .../spatial/intersection/linestring_intersection_test.cu | 4 ++-- 5 files changed, 5 insertions(+), 5 deletions(-) rename cpp/include/cuspatial/{linestring_intersection.cuh => intersection.cuh} (100%) rename cpp/include/cuspatial/{linestring_intersection.hpp => intersection.hpp} (100%) diff --git a/cpp/include/cuspatial/linestring_intersection.cuh b/cpp/include/cuspatial/intersection.cuh similarity index 100% rename from cpp/include/cuspatial/linestring_intersection.cuh rename to cpp/include/cuspatial/intersection.cuh diff --git a/cpp/include/cuspatial/linestring_intersection.hpp b/cpp/include/cuspatial/intersection.hpp similarity index 100% rename from cpp/include/cuspatial/linestring_intersection.hpp rename to cpp/include/cuspatial/intersection.hpp diff --git a/cpp/src/spatial/linestring_intersection.cu b/cpp/src/spatial/linestring_intersection.cu index f256cb70f..760854692 100644 --- a/cpp/src/spatial/linestring_intersection.cu +++ b/cpp/src/spatial/linestring_intersection.cu @@ -20,9 +20,9 @@ #include #include #include +#include +#include #include -#include -#include #include #include diff --git a/cpp/tests/spatial/intersection/linestring_intersection_test.cpp b/cpp/tests/spatial/intersection/linestring_intersection_test.cpp index 65a9b5d13..b48d1b057 100644 --- a/cpp/tests/spatial/intersection/linestring_intersection_test.cpp +++ b/cpp/tests/spatial/intersection/linestring_intersection_test.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include diff --git a/cpp/tests/spatial/intersection/linestring_intersection_test.cu b/cpp/tests/spatial/intersection/linestring_intersection_test.cu index 7fb4f6d97..dee79f139 100644 --- a/cpp/tests/spatial/intersection/linestring_intersection_test.cu +++ b/cpp/tests/spatial/intersection/linestring_intersection_test.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-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. @@ -21,8 +21,8 @@ #include #include +#include #include -#include #include #include From 3708b6f8c50a86b6c8605a2582f54b0ff6961011 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Wed, 26 Apr 2023 05:16:59 +0000 Subject: [PATCH 06/18] Consolidate distance headers --- cpp/benchmarks/hausdorff_benchmark.cpp | 4 +- .../pairwise_linestring_distance.cu | 4 +- .../detail/{ => distance}/distance_utils.cuh | 2 + .../detail/{ => distance}/hausdorff.cuh | 0 .../detail/{ => distance}/haversine.cuh | 0 .../{ => distance}/linestring_distance.cuh | 0 .../linestring_polygon_distance.cuh | 0 .../detail/{ => distance}/point_distance.cuh | 0 .../point_linestring_distance.cuh | 0 .../{ => distance}/point_polygon_distance.cuh | 0 cpp/include/cuspatial/distance.cuh | 278 +++++++++++++ cpp/include/cuspatial/distance.hpp | 371 ++++++++++++++++++ cpp/include/cuspatial/distance/hausdorff.hpp | 100 ----- cpp/include/cuspatial/distance/haversine.hpp | 56 --- .../distance/linestring_distance.hpp | 123 ------ .../distance/linestring_polygon_distance.hpp | 49 --- .../cuspatial/distance/point_distance.hpp | 46 --- .../distance/point_linestring_distance.hpp | 102 ----- .../distance/point_polygon_distance.hpp | 49 --- cpp/include/cuspatial/hausdorff.cuh | 105 ----- cpp/include/cuspatial/haversine.cuh | 79 ---- cpp/include/cuspatial/linestring_distance.cuh | 50 --- .../cuspatial/linestring_polygon_distance.cuh | 48 --- cpp/include/cuspatial/point_distance.cuh | 41 -- .../cuspatial/point_linestring_distance.cuh | 47 --- .../cuspatial/point_polygon_distance.cuh | 47 --- cpp/src/spatial/hausdorff.cu | 4 +- cpp/src/spatial/haversine.cu | 4 +- cpp/src/spatial/linestring_distance.cu | 4 +- .../spatial/linestring_polygon_distance.cu | 2 +- cpp/src/spatial/point_distance.cu | 4 +- cpp/src/spatial/point_linestring_distance.cu | 4 +- cpp/src/spatial/point_polygon_distance.cu | 2 +- cpp/tests/spatial/distance/hausdorff_test.cpp | 7 +- cpp/tests/spatial/distance/hausdorff_test.cu | 2 +- cpp/tests/spatial/distance/haversine_test.cpp | 4 +- cpp/tests/spatial/distance/haversine_test.cu | 2 +- .../distance/linestring_distance_test.cpp | 4 +- .../distance/linestring_distance_test.cu | 4 +- .../linestring_distance_test_medium.cu | 4 +- .../linestring_polygon_distance_test.cu | 2 +- .../spatial/distance/point_distance_test.cpp | 4 +- .../spatial/distance/point_distance_test.cu | 2 +- .../point_linestring_distance_test.cpp | 4 +- .../point_linestring_distance_test.cu | 2 +- .../distance/point_polygon_distance_test.cpp | 2 +- .../distance/point_polygon_distance_test.cu | 2 +- .../linestring_polygon_distance_test.cpp | 2 +- .../cuspatial/_lib/cpp/distance/hausdorff.pxd | 4 +- .../cuspatial/_lib/cpp/distance/haversine.pxd | 4 +- .../_lib/cpp/distance/linestring_distance.pxd | 4 +- .../_lib/cpp/distance/point_distance.pxd | 4 +- .../distance/point_linestring_distance.pxd | 4 +- .../cpp/distance/point_polygon_distance.pxd | 2 +- ..._box.pxd => linestring_bounding_boxes.pxd} | 4 +- .../_lib/cpp/linestring_intersection.pxd | 2 +- .../_lib/cpp/pairwise_point_in_polygon.pxd | 4 +- ...ing_box.pxd => polygon_bounding_boxes.pxd} | 4 +- .../cuspatial/_lib/cpp/projection.pxd | 2 +- .../_lib/linestring_bounding_boxes.pyx | 4 +- .../cuspatial/_lib/polygon_bounding_boxes.pyx | 4 +- 61 files changed, 714 insertions(+), 1004 deletions(-) rename cpp/include/cuspatial/detail/{ => distance}/distance_utils.cuh (99%) rename cpp/include/cuspatial/detail/{ => distance}/hausdorff.cuh (100%) rename cpp/include/cuspatial/detail/{ => distance}/haversine.cuh (100%) rename cpp/include/cuspatial/detail/{ => distance}/linestring_distance.cuh (100%) rename cpp/include/cuspatial/detail/{ => distance}/linestring_polygon_distance.cuh (100%) rename cpp/include/cuspatial/detail/{ => distance}/point_distance.cuh (100%) rename cpp/include/cuspatial/detail/{ => distance}/point_linestring_distance.cuh (100%) rename cpp/include/cuspatial/detail/{ => distance}/point_polygon_distance.cuh (100%) create mode 100644 cpp/include/cuspatial/distance.cuh create mode 100644 cpp/include/cuspatial/distance.hpp delete mode 100644 cpp/include/cuspatial/distance/hausdorff.hpp delete mode 100644 cpp/include/cuspatial/distance/haversine.hpp delete mode 100644 cpp/include/cuspatial/distance/linestring_distance.hpp delete mode 100644 cpp/include/cuspatial/distance/linestring_polygon_distance.hpp delete mode 100644 cpp/include/cuspatial/distance/point_distance.hpp delete mode 100644 cpp/include/cuspatial/distance/point_linestring_distance.hpp delete mode 100644 cpp/include/cuspatial/distance/point_polygon_distance.hpp delete mode 100644 cpp/include/cuspatial/hausdorff.cuh delete mode 100644 cpp/include/cuspatial/haversine.cuh delete mode 100644 cpp/include/cuspatial/linestring_distance.cuh delete mode 100644 cpp/include/cuspatial/linestring_polygon_distance.cuh delete mode 100644 cpp/include/cuspatial/point_distance.cuh delete mode 100644 cpp/include/cuspatial/point_linestring_distance.cuh delete mode 100644 cpp/include/cuspatial/point_polygon_distance.cuh rename python/cuspatial/cuspatial/_lib/cpp/{linestring_bounding_box.pxd => linestring_bounding_boxes.pxd} (78%) rename python/cuspatial/cuspatial/_lib/cpp/{polygon_bounding_box.pxd => polygon_bounding_boxes.pxd} (80%) diff --git a/cpp/benchmarks/hausdorff_benchmark.cpp b/cpp/benchmarks/hausdorff_benchmark.cpp index 8ff80c331..10ffced0e 100644 --- a/cpp/benchmarks/hausdorff_benchmark.cpp +++ b/cpp/benchmarks/hausdorff_benchmark.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include #include diff --git a/cpp/benchmarks/pairwise_linestring_distance.cu b/cpp/benchmarks/pairwise_linestring_distance.cu index 293e8c960..e8f7258d5 100644 --- a/cpp/benchmarks/pairwise_linestring_distance.cu +++ b/cpp/benchmarks/pairwise_linestring_distance.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-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. @@ -17,9 +17,9 @@ #include #include +#include #include #include -#include #include #include diff --git a/cpp/include/cuspatial/detail/distance_utils.cuh b/cpp/include/cuspatial/detail/distance/distance_utils.cuh similarity index 99% rename from cpp/include/cuspatial/detail/distance_utils.cuh rename to cpp/include/cuspatial/detail/distance/distance_utils.cuh index 5d1de5eca..fc8454baa 100644 --- a/cpp/include/cuspatial/detail/distance_utils.cuh +++ b/cpp/include/cuspatial/detail/distance/distance_utils.cuh @@ -14,6 +14,8 @@ * limitations under the License. */ +#pragma once + #include #include #include diff --git a/cpp/include/cuspatial/detail/hausdorff.cuh b/cpp/include/cuspatial/detail/distance/hausdorff.cuh similarity index 100% rename from cpp/include/cuspatial/detail/hausdorff.cuh rename to cpp/include/cuspatial/detail/distance/hausdorff.cuh diff --git a/cpp/include/cuspatial/detail/haversine.cuh b/cpp/include/cuspatial/detail/distance/haversine.cuh similarity index 100% rename from cpp/include/cuspatial/detail/haversine.cuh rename to cpp/include/cuspatial/detail/distance/haversine.cuh diff --git a/cpp/include/cuspatial/detail/linestring_distance.cuh b/cpp/include/cuspatial/detail/distance/linestring_distance.cuh similarity index 100% rename from cpp/include/cuspatial/detail/linestring_distance.cuh rename to cpp/include/cuspatial/detail/distance/linestring_distance.cuh diff --git a/cpp/include/cuspatial/detail/linestring_polygon_distance.cuh b/cpp/include/cuspatial/detail/distance/linestring_polygon_distance.cuh similarity index 100% rename from cpp/include/cuspatial/detail/linestring_polygon_distance.cuh rename to cpp/include/cuspatial/detail/distance/linestring_polygon_distance.cuh diff --git a/cpp/include/cuspatial/detail/point_distance.cuh b/cpp/include/cuspatial/detail/distance/point_distance.cuh similarity index 100% rename from cpp/include/cuspatial/detail/point_distance.cuh rename to cpp/include/cuspatial/detail/distance/point_distance.cuh diff --git a/cpp/include/cuspatial/detail/point_linestring_distance.cuh b/cpp/include/cuspatial/detail/distance/point_linestring_distance.cuh similarity index 100% rename from cpp/include/cuspatial/detail/point_linestring_distance.cuh rename to cpp/include/cuspatial/detail/distance/point_linestring_distance.cuh diff --git a/cpp/include/cuspatial/detail/point_polygon_distance.cuh b/cpp/include/cuspatial/detail/distance/point_polygon_distance.cuh similarity index 100% rename from cpp/include/cuspatial/detail/point_polygon_distance.cuh rename to cpp/include/cuspatial/detail/distance/point_polygon_distance.cuh diff --git a/cpp/include/cuspatial/distance.cuh b/cpp/include/cuspatial/distance.cuh new file mode 100644 index 000000000..425fb93ef --- /dev/null +++ b/cpp/include/cuspatial/distance.cuh @@ -0,0 +1,278 @@ +/* + * Copyright (c) 2022-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. + */ + +#pragma once + +#include +#include + +#include + +#include + +namespace cuspatial { + +/** + * @addtogroup distance + */ + +/** + * @brief Compute haversine distances between points in set A to the corresponding points in set B. + * + * Computes N haversine distances, where N is `std::distance(a_lonlat_first, a_lonlat_last)`. + * The distance for each `a_lonlat[i]` and `b_lonlat[i]` point pair is assigned to + * `distance_first[i]`. `distance_first` must be an iterator to output storage allocated for N + * distances. + * + * Computed distances will have the same units as `radius`. + * + * https://en.wikipedia.org/wiki/Haversine_formula + * + * @param[in] a_lonlat_first: beginning of range of (longitude, latitude) locations in set A + * @param[in] a_lonlat_last: end of range of (longitude, latitude) locations in set A + * @param[in] b_lonlat_first: beginning of range of (longitude, latitude) locations in set B + * @param[out] distance_first: beginning of output range of haversine distances + * @param[in] radius: radius of the sphere on which the points reside. default: 6371.0 + * (approximate radius of Earth in km) + * @param[in] stream: The CUDA stream on which to perform computations and allocate memory. + * + * @tparam LonLatItA Iterator to input location set A. Must meet the requirements of + * [LegacyRandomAccessIterator][LinkLRAI] and be device-accessible. + * @tparam LonLatItB Iterator to input location set B. Must meet the requirements of + * [LegacyRandomAccessIterator][LinkLRAI] and be device-accessible. + * @tparam OutputIt Output iterator. Must meet the requirements of + * [LegacyRandomAccessIterator][LinkLRAI] and be device-accessible and mutable. + * @tparam T The underlying coordinate type. Must be a floating-point type. + * + * @pre All iterators must have the same `Location` type, with the same underlying floating-point + * coordinate type (e.g. `cuspatial::vec_2d`). + * + * @return Output iterator to the element past the last distance computed. + * + * [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator + * "LegacyRandomAccessIterator" + */ +template > +OutputIt haversine_distance(LonLatItA a_lonlat_first, + LonLatItA a_lonlat_last, + LonLatItB b_lonlat_first, + OutputIt distance_first, + T const radius = EARTH_RADIUS_KM, + rmm::cuda_stream_view stream = rmm::cuda_stream_default); + +/** + * @brief Computes Hausdorff distances for all pairs in a collection of spaces + * + * https://en.wikipedia.org/wiki/Hausdorff_distance + * + * Example in 1D (this function operates in 2D): + * ``` + * spaces + * [0 2 5] [9] [3 7] + * + * spaces represented as points per space and concatenation of all points + * [0 2 5 9 3 7] [3 1 2] + * + * note: the following matrices are visually separated to highlight the relationship of a pair of + * points with the pair of spaces from which it is produced + * + * cartesian product of all + * points by pair of spaces distance between points + * +----------+----+-------+ +---------+---+------+ + * : 00 02 05 : 09 : 03 07 : : 0 2 5 : 9 : 3 7 : + * : 20 22 25 : 29 : 23 27 : : 2 0 3 : 7 : 1 5 : + * : 50 52 55 : 59 : 53 57 : : 5 3 0 : 4 : 2 2 : + * +----------+----+-------+ +---------+---+------+ + * : 90 92 95 : 99 : 93 97 : : 9 7 4 : 0 : 6 2 : + * +----------+----+-------+ +---------+---+------+ + * : 30 32 35 : 39 : 33 37 : : 3 1 2 : 6 : 0 4 : + * : 70 72 75 : 79 : 73 77 : : 7 5 2 : 2 : 4 0 : + * +----------+----+-------+ +---------+---+------+ + + * minimum distance from + * every point in one Hausdorff distance is + * space to any point in the maximum of the + * the other space minimum distances + * +----------+----+-------+ +---------+---+------+ + * : 0 : 9 : 3 : : 0 : 9 : 3 : + * : 0 : 7 : 1 : : : : : + * : 0 : 4 : 2 : : : : : + * +----------+----+-------+ +---------+---+------+ + * : 4 : 0 : 2 : : 4 : 0 : 2 : + * +----------+----+-------+ +---------+---+------+ + * : 1 : 6 : 0 : : : 6 : 0 : + * : 2 : 2 : 0 : : 2 : : : + * +----------+----+-------+ +---------+---+------+ + * + * returned as concatenation of columns + * [0 2 4 3 0 2 9 6 0] + * ``` + * + * @param[in] points_first: xs: beginning of range of (x,y) points + * @param[in] points_lasts: xs: end of range of (x,y) points + * @param[in] space_offsets_first: beginning of range of indices to each space. + * @param[in] space_offsets_first: end of range of indices to each space. Last index is the last + * @param[in] distance_first: beginning of range of output Hausdorff distance for each pair of + * spaces + * + * @tparam PointIt Iterator to input points. Points must be of a type that is convertible to + * `cuspatial::vec_2d`. Must meet the requirements of [LegacyRandomAccessIterator][LinkLRAI] and + * be device-accessible. + * @tparam OffsetIt Iterator to space offsets. Value type must be integral. Must meet the + * requirements of [LegacyRandomAccessIterator][LinkLRAI] and be device-accessible. + * @tparam OutputIt Output iterator. Must meet the requirements of + * [LegacyRandomAccessIterator][LinkLRAI] and be device-accessible and mutable. + * + * @pre All iterators must have the same underlying floating-point value type. + * + * @return Output iterator to the element past the last distance computed. + * + * @note Hausdorff distances are asymmetrical + */ +template +OutputIt directed_hausdorff_distance(PointIt points_first, + PointIt points_last, + OffsetIt space_offsets_first, + OffsetIt space_offsets_last, + OutputIt distance_first, + rmm::cuda_stream_view stream = rmm::cuda_stream_default); + +/** + * @brief Compute pairwise (multi)point-to-(multi)point Cartesian distance + * + * Computes the cartesian distance between each pair of multipoints. + * + * @tparam MultiPointArrayViewA An instance of template type `array_view::multipoint_array` + * @tparam MultiPointArrayViewB An instance of template type `array_view::multipoint_array` + * + * @param multipoints1 Range of first multipoint in each distance pair. + * @param multipoints2 Range of second multipoint in each distance pair. + * @return Iterator past the last distance computed + */ +template +OutputIt pairwise_point_distance(MultiPointArrayViewA multipoints1, + MultiPointArrayViewB multipoints2, + OutputIt distances_first, + rmm::cuda_stream_view stream = rmm::cuda_stream_default); + +/** + * @brief Compute pairwise multipoint to multilinestring distance + * + * @tparam MultiPointRange an instance of template type `multipoint_range` + * @tparam MultiLinestringRange an instance of template type `multilinestring_range` + * @tparam OutputIt iterator type for output array. Must meet the requirements of [LRAI](LinkLRAI). + * + * @param multipoints The range of multipoints, one per computed distance pair + * @param multilinestrings The range of multilinestrings, one per computed distance pair + * @param stream The CUDA stream to use for device memory operations and kernel launches. + * @return Output iterator to the element past the last distance computed. + * + * [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator + * "LegacyRandomAccessIterator" + */ +template +OutputIt pairwise_point_linestring_distance( + MultiPointRange multipoints, + MultiLinestringRange multilinestrings, + OutputIt distances_first, + rmm::cuda_stream_view stream = rmm::cuda_stream_default); + +/** + * @brief Computes pairwise multipoint to multipolygon distance + * + * @tparam MultiPointRange An instance of template type `multipoint_range` + * @tparam MultiPolygonRange An instance of template type `multipolygon_range` + * @tparam OutputIt iterator type for output array. Must meet the requirements of [LRAI](LinkLRAI). + * Must be an iterator to type convertible from floating points. + * + * @param multipoints Range of multipoints, one per computed distance pair. + * @param multipolygons Range of multilinestrings, one per computed distance pair. + * @param stream The CUDA stream on which to perform computations + * @return Output Iterator past the last distance computed + * + * [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator + * "LegacyRandomAccessIterator" + */ +template +OutputIt pairwise_point_polygon_distance(MultiPointRange multipoints, + MultiPolygonRange multipoiygons, + OutputIt distances_first, + rmm::cuda_stream_view stream = rmm::cuda_stream_default); + +/** + * @copybrief cuspatial::pairwise_linestring_distance + * + * The shortest distance between two linestrings is defined as the shortest distance + * between all pairs of segments of the two linestrings. If any of the segments intersect, + * the distance is 0. + * + * @tparam MultiLinestringRange an instance of template type `multilinestring_range` + * @tparam OutputIt iterator type for output array. Must meet the requirements of [LRAI](LinkLRAI) + * and be device writable. + * + * @param multilinestrings1 Range object of the lhs multilinestring array + * @param multilinestrings2 Range object of the rhs multilinestring array + * @param stream The CUDA stream to use for device memory operations and kernel launches. + * @return Output iterator to the element past the last distance computed. + * + * [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator + * "LegacyRandomAccessIterator" + */ +template +OutputIt pairwise_linestring_distance(MultiLinestringRange1 multilinestrings1, + MultiLinstringRange2 multilinestrings2, + OutputIt distances_first, + rmm::cuda_stream_view stream = rmm::cuda_stream_default); + +/** + * @brief Computes pairwise multilinestring to multipolygon distance + * + * @tparam MultiLinestringRange An instance of template type `multipoint_range` + * @tparam MultiPolygonRange An instance of template type `multipolygon_range` + * @tparam OutputIt iterator type for output array. Must meet the requirements of [LRAI](LinkLRAI). + * Must be an iterator to type convertible from floating points. + * + * @param multilinestrings Range of multilinestrings, one per computed distance pair. + * @param multipolygons Range of multipolygons, one per computed distance pair. + * @param stream The CUDA stream on which to perform computations + * @return Output Iterator past the last distance computed + * + * [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator + * "LegacyRandomAccessIterator" + */ +template +OutputIt pairwise_linestring_polygon_distance( + MultiLinestringRange multilinestrings, + MultiPolygonRange multipoiygons, + OutputIt distances_first, + rmm::cuda_stream_view stream = rmm::cuda_stream_default); + +/** + * @} // end of doxygen group + */ + +} // namespace cuspatial + +#include +#include +#include +#include +#include +#include +#include diff --git a/cpp/include/cuspatial/distance.hpp b/cpp/include/cuspatial/distance.hpp new file mode 100644 index 000000000..de9d3e116 --- /dev/null +++ b/cpp/include/cuspatial/distance.hpp @@ -0,0 +1,371 @@ +/* + * 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. + */ + +#pragma once + +#include +#include + +#include +#include +#include +#include + +#include + +#include + +namespace cuspatial { + +/** + * @addtogroup distance + */ + +/** + * @brief Compute haversine distances between points in set A and the corresponding points in set B. + * + * https://en.wikipedia.org/wiki/Haversine_formula + * + * @param[in] a_lon: longitude of points in set A + * @param[in] a_lat: latitude of points in set A + * @param[in] b_lon: longitude of points in set B + * @param[in] b_lat: latitude of points in set B + * @param[in] radius: radius of the sphere on which the points reside. default: 6371.0 (aprx. radius + * of earth in km) + * + * @return array of distances for all (a_lon[i], a_lat[i]) and (b_lon[i], b_lat[i]) point pairs + */ +std::unique_ptr haversine_distance( + cudf::column_view const& a_lon, + cudf::column_view const& a_lat, + cudf::column_view const& b_lon, + cudf::column_view const& b_lat, + double const radius = EARTH_RADIUS_KM, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + +/** + * @brief computes Hausdorff distances for all pairs in a collection of spaces + * + * @ingroup distance + * + * https://en.wikipedia.org/wiki/Hausdorff_distance + * + * Example in 1D (this function operates in 2D): + * ``` + * spaces + * [0 2 5] [9] [3 7] + * + * spaces represented as points per space and concatenation of all points + * [0 2 5 9 3 7] [3 1 2] + * + * note: the following matrices are visually separated to highlight the relationship of a pair of + * points with the pair of spaces from which it is produced + * + * cartesian product of all + * points by pair of spaces distance between points + * +----------+----+-------+ +---------+---+------+ + * : 00 02 05 : 09 : 03 07 : : 0 2 5 : 9 : 3 7 : + * : 20 22 25 : 29 : 23 27 : : 2 0 3 : 7 : 1 5 : + * : 50 52 55 : 59 : 53 57 : : 5 3 0 : 4 : 2 2 : + * +----------+----+-------+ +---------+---+------+ + * : 90 92 95 : 99 : 93 97 : : 9 7 4 : 0 : 6 2 : + * +----------+----+-------+ +---------+---+------+ + * : 30 32 35 : 39 : 33 37 : : 3 1 2 : 6 : 0 4 : + * : 70 72 75 : 79 : 73 77 : : 7 5 2 : 2 : 4 0 : + * +----------+----+-------+ +---------+---+------+ + + * minimum distance from + * every point in one Hausdorff distance is + * space to any point in the maximum of the + * the other space minimum distances + * +----------+----+-------+ +---------+---+------+ + * : 0 : 9 : 3 : : 0 : 9 : 3 : + * : 0 : 7 : 1 : : : : : + * : 0 : 4 : 2 : : : : : + * +----------+----+-------+ +---------+---+------+ + * : 4 : 0 : 2 : : 4 : 0 : 2 : + * +----------+----+-------+ +---------+---+------+ + * : 1 : 6 : 0 : : : 6 : 0 : + * : 2 : 2 : 0 : : 2 : : : + * +----------+----+-------+ +---------+---+------+ + * + * Returns: + * column: [0 4 2 9 0 6 3 2 0] + * table_view: [0 4 2] [9 0 6] [3 2 0] + * + * ``` + * + * @param[in] xs: x component of points + * @param[in] ys: y component of points + * @param[in] space_offsets: beginning index of each space, plus the last space's end offset. + * + * @returns An owning object of the result of the hausdorff distances. + * A table view containing the split view for each input space. + * + * @throw cudf::cuda_error if `xs` and `ys` lengths differ + * @throw cudf::cuda_error if `xs` and `ys` types differ + * @throw cudf::cuda_error if `space_offsets` size is less than `xs` and `xy` + * @throw cudf::cuda_error if `xs`, `ys`, or `space_offsets` has nulls + * + * @note Hausdorff distances are asymmetrical + */ +std::pair, cudf::table_view> directed_hausdorff_distance( + cudf::column_view const& xs, + cudf::column_view const& ys, + cudf::column_view const& space_offsets, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + +/** + * @brief Compute pairwise (multi)point-to-(multi)point Cartesian distance + * + * Computes the cartesian distance between each pair of the multipoints. If input is + * a single point column, the offset of the column should be std::nullopt. + * + * @param points1_xy Column of xy-coordinates of the first point in each pair + * @param multipoints1_offset Index to the first point of each multipoint in points1_xy + * @param points2_xy Column of xy-coordinates of the second point in each pair + * @param multipoints2_offset Index to the second point of each multipoint in points2_xy + * @return Column of distances between each pair of input points + */ + +std::unique_ptr pairwise_point_distance( + std::optional> multipoints1_offset, + cudf::column_view const& points1_xy, + std::optional> multipoints2_offset, + cudf::column_view const& points2_xy, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + +/** + * @brief Compute distance between pairs of points and linestrings + * + * The distance between a point and a linestring is defined as the minimum distance + * between the point and any segment of the linestring. For each input point, this + * function returns the distance between the point and the corresponding linestring. + * + * The following example contains 2 pairs of points and linestrings. + * ``` + * First pair: + * Point: (0, 0) + * Linestring: (0, 1) -> (1, 0) -> (2, 0) + * + * Second pair: + * Point: (1, 1) + * Linestring: (0, 0) -> (1, 1) -> (2, 0) -> (3, 0) -> (3, 1) + * + * The input of the above example is: + * multipoint_geometry_offsets: nullopt + * points_xy: {0, 1, 0, 1} + * multilinestring_geometry_offsets: nullopt + * linestring_part_offsets: {0, 3, 8} + * linestring_xy: {0, 1, 1, 0, 2, 0, 0, 0, 1, 1, 2, 0, 3, 0, 3, 1} + * + * Result: {sqrt(2)/2, 0} + * ``` + * + * The following example contains 3 pairs of MultiPoint and MultiLinestring. + * ``` + * First pair: + * MultiPoint: (0, 1) + * MultiLinestring: (0, -1) -> (-2, -3), (-4, -5) -> (-5, -6) + * + * Second pair: + * MultiPoint: (2, 3), (4, 5) + * MultiLinestring: (7, 8) -> (8, 9) + * + * Third pair: + * MultiPoint: (6, 7), (8, 9) + * MultiLinestring: (9, 10) -> (10, 11) + + * The input of the above example is: + * multipoint_geometry_offsets: {0, 1, 3, 5} + * points_xy: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} + * multilinestring_geometry_offsets: {0, 2, 3, 5} + * linestring_part_offsets: {0, 2, 4, 6, 8} + * linestring_points_xy: {0, -1, -2, -3, -4, -5, -5, -6, 7, 8, 8, 9, 9, 10, 10 ,11} + * + * Result: {2.0, 4.24264, 1.41421} + * ``` + * + * @param multipoint_geometry_offsets Beginning and ending indices to each geometry in the + * multi-point + * @param points_xy Interleaved x, y-coordinates of points + * @param multilinestring_geometry_offsets Beginning and ending indices to each geometry in the + * multi-linestring + * @param linestring_part_offsets Beginning and ending indices for each linestring in the point + * array. Because the coordinates are interleaved, the actual starting position for the coordinate + * of linestring `i` is `2*linestring_part_offsets[i]`. + * @param linestring_points_xy Interleaved x, y-coordinates of linestring points. + * @param mr Device memory resource used to allocate the returned column. + * @return A column containing the distance between each pair of corresponding points and + * linestrings. + * + * @note Any optional geometry indices, if is `nullopt`, implies the underlying geometry contains + * only one component. Otherwise, it contains multiple components. + * + * @throws cuspatial::logic_error if the number of (multi)points and (multi)linestrings do not + * match. + * @throws cuspatial::logic_error if the any of the point arrays have mismatched types. + */ +std::unique_ptr pairwise_point_linestring_distance( + std::optional> multipoint_geometry_offsets, + cudf::column_view const& points_xy, + std::optional> multilinestring_geometry_offsets, + cudf::device_span linestring_part_offsets, + cudf::column_view const& linestring_points_xy, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + +/** + * @brief Compute pairwise (multi)point-to-(multi)polygon Cartesian distance + * + * @param multipoints Geometry column of multipoints + * @param multipolygons Geometry column of multipolygons + * @param mr Device memory resource used to allocate the returned column. + * @return Column of distances between each pair of input geometries, same type as input coordinate + * types. + * + * @throw cuspatial::logic_error if `multipoints` and `multipolygons` has different coordinate + * types. + * @throw cuspatial::logic_error if `multipoints` is not a point column and `multipolygons` is not a + * polygon column. + * @throw cuspatial::logic_error if input column sizes mismatch. + */ + +std::unique_ptr pairwise_point_polygon_distance( + geometry_column_view const& multipoints, + geometry_column_view const& multipolygons, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + +/** + * @brief Compute shortest distance between pairs of linestrings + * + * The shortest distance between two linestrings is defined as the shortest distance + * between all pairs of segments of the two linestrings. If any of the segments intersect, + * the distance is 0. The shortest distance between two multilinestrings is defined as the + * the shortest distance between all pairs of linestrings of the two multilinestrings. + * + * The following example contains 4 pairs of linestrings. The first array is a single linestring + * array and the second array is a multilinestring array. + * ``` + * First pair: + * (0, 1) -> (1, 0) -> (-1, 0) + * {(1, 1) -> (2, 1) -> (2, 0) -> (3, 0)} + * + * | + * * #---# + * | \ | + * ----O---*---#---# + * | / + * * + * | + * + * The shortest distance between the two linestrings is the distance + * from point (1, 1) to segment (0, 1) -> (1, 0), which is sqrt(2)/2. + * + * Second pair: + * + * (0, 0) -> (0, 1) + * {(1, 0) -> (1, 1) -> (1, 2), (1, -1) -> (1, -2) -> (1, -3)} + * + * The linestrings in the pairs are parallel. Their distance is 1 (point (0, 0) to point (1, 0)). + * + * Third pair: + * + * (0, 0) -> (2, 2) -> (-2, 0) + * {(2, 0) -> (0, 2), (0, 2) -> (-2, 0)} + * + * The linestrings in the pairs intersect, so their distance is 0. + * + * Forth pair: + * + * (2, 2) -> (-2, -2) + * {(1, 1) -> (5, 5) -> (10, 0), (-1, -1) -> (-5, -5) -> (-10, 0)} + * + * These linestrings contain colinear and overlapping sections, so + * their distance is 0. + * + * The input of above example is: + * multilinestring1_geometry_offsets: nullopt + * linestring1_part_offsets: {0, 3, 5, 8, 10} + * linestring1_points_xy: + * {0, 1, 1, 0, -1, 0, 0, 0, 0, 1, 0, 0, 2, 2, -2, 0, 2, 2, -2, -2} + * + * multilinestring2_geometry_offsets: {0, 1, 3, 5, 7} + * linestring2_offsets: {0, 4, 7, 10, 12, 14, 17, 20} + * linestring2_points_xy: {1, 1, 2, 1, 2, 0, 3, 0, 1, 0, 1, 1, 1, 2, 1, -1, 1, -2, 1, -3, 2, 0, 0, + * 2, 0, 2, -2, 0, 1, 1, 5, 5, 10, 0, -1, -1, -5, -5, -10, 0} + * + * Result: {sqrt(2.0)/2, 1, 0, 0} + * ``` + * + * @param multilinestring1_geometry_offsets Beginning and ending indices to each multilinestring in + * the first multilinestring array. + * @param linestring1_part_offsets Beginning and ending indices for each linestring in the point + * array. Because the coordinates are interleaved, the actual starting position for the coordinate + * of linestring `i` is `2*linestring_part_offsets[i]`. + * @param linestring1_points_xy Interleaved x, y-coordinates of linestring points. + * @param multilinestring2_geometry_offsets Beginning and ending indices to each multilinestring in + * the second multilinestring array. + * @param linestring2_part_offsets Beginning and ending indices for each linestring in the point + * array. Because the coordinates are interleaved, the actual starting position for the coordinate + * of linestring `i` is `2*linestring_part_offsets[i]`. + * @param linestring2_points_xy Interleaved x, y-coordinates of linestring points. + * @param mr Device memory resource used to allocate the returned column's device memory + * @return A column of shortest distances between each pair of (multi)linestrings + * + * @note If `multilinestring_geometry_offset` is std::nullopt, the input is a single linestring + * array. + * @note If any of the linestring contains less than 2 points, the behavior is undefined. + * + * @throw cuspatial::logic_error if `linestring1_offsets.size() != linestring2_offsets.size()` + * @throw cuspatial::logic_error if any of the point arrays have mismatched types. + * @throw cuspatial::logic_error if any linestring has fewer than 2 points. + * + */ +std::unique_ptr pairwise_linestring_distance( + std::optional> multilinestring1_geometry_offsets, + cudf::device_span linestring1_part_offsets, + cudf::column_view const& linestring1_points_xy, + std::optional> multilinestring2_geometry_offsets, + cudf::device_span linestring2_part_offsets, + cudf::column_view const& linestring2_points_xy, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + +/** + * @brief Compute pairwise (multi)linestring-to-(multi)polygon Cartesian distance + * + * @param multilinestrings Geometry column of multilinestrings + * @param multipolygons Geometry column of multipolygons + * @param mr Device memory resource used to allocate the returned column. + * @return Column of distances between each pair of input geometries, same type as input coordinate + * types. + * + * @throw cuspatial::logic_error if `multilinestrings` and `multipolygons` have different coordinate + * types. + * @throw cuspatial::logic_error if `multilinestrings` is not a linestring column and + * `multipolygons` is not a polygon column. + * @throw cuspatial::logic_error if input column sizes mismatch. + */ + +std::unique_ptr pairwise_linestring_polygon_distance( + geometry_column_view const& multilinestrings, + geometry_column_view const& multipolygons, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + +/** + * @} // end of doxygen group + */ + +} // namespace cuspatial diff --git a/cpp/include/cuspatial/distance/hausdorff.hpp b/cpp/include/cuspatial/distance/hausdorff.hpp deleted file mode 100644 index 27f4aa600..000000000 --- a/cpp/include/cuspatial/distance/hausdorff.hpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2019-2022, 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. - */ - -#pragma once - -#include -#include - -#include - -#include - -namespace cuspatial { - -/** - * @brief computes Hausdorff distances for all pairs in a collection of spaces - * - * @ingroup distance - * - * https://en.wikipedia.org/wiki/Hausdorff_distance - * - * Example in 1D (this function operates in 2D): - * ``` - * spaces - * [0 2 5] [9] [3 7] - * - * spaces represented as points per space and concatenation of all points - * [0 2 5 9 3 7] [3 1 2] - * - * note: the following matrices are visually separated to highlight the relationship of a pair of - * points with the pair of spaces from which it is produced - * - * cartesian product of all - * points by pair of spaces distance between points - * +----------+----+-------+ +---------+---+------+ - * : 00 02 05 : 09 : 03 07 : : 0 2 5 : 9 : 3 7 : - * : 20 22 25 : 29 : 23 27 : : 2 0 3 : 7 : 1 5 : - * : 50 52 55 : 59 : 53 57 : : 5 3 0 : 4 : 2 2 : - * +----------+----+-------+ +---------+---+------+ - * : 90 92 95 : 99 : 93 97 : : 9 7 4 : 0 : 6 2 : - * +----------+----+-------+ +---------+---+------+ - * : 30 32 35 : 39 : 33 37 : : 3 1 2 : 6 : 0 4 : - * : 70 72 75 : 79 : 73 77 : : 7 5 2 : 2 : 4 0 : - * +----------+----+-------+ +---------+---+------+ - - * minimum distance from - * every point in one Hausdorff distance is - * space to any point in the maximum of the - * the other space minimum distances - * +----------+----+-------+ +---------+---+------+ - * : 0 : 9 : 3 : : 0 : 9 : 3 : - * : 0 : 7 : 1 : : : : : - * : 0 : 4 : 2 : : : : : - * +----------+----+-------+ +---------+---+------+ - * : 4 : 0 : 2 : : 4 : 0 : 2 : - * +----------+----+-------+ +---------+---+------+ - * : 1 : 6 : 0 : : : 6 : 0 : - * : 2 : 2 : 0 : : 2 : : : - * +----------+----+-------+ +---------+---+------+ - * - * Returns: - * column: [0 4 2 9 0 6 3 2 0] - * table_view: [0 4 2] [9 0 6] [3 2 0] - * - * ``` - * - * @param[in] xs: x component of points - * @param[in] ys: y component of points - * @param[in] space_offsets: beginning index of each space, plus the last space's end offset. - * - * @returns An owning object of the result of the hausdorff distances. - * A table view containing the split view for each input space. - * - * @throw cudf::cuda_error if `xs` and `ys` lengths differ - * @throw cudf::cuda_error if `xs` and `ys` types differ - * @throw cudf::cuda_error if `space_offsets` size is less than `xs` and `xy` - * @throw cudf::cuda_error if `xs`, `ys`, or `space_offsets` has nulls - * - * @note Hausdorff distances are asymmetrical - */ -std::pair, cudf::table_view> directed_hausdorff_distance( - cudf::column_view const& xs, - cudf::column_view const& ys, - cudf::column_view const& space_offsets, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); - -} // namespace cuspatial diff --git a/cpp/include/cuspatial/distance/haversine.hpp b/cpp/include/cuspatial/distance/haversine.hpp deleted file mode 100644 index 3e66610cc..000000000 --- a/cpp/include/cuspatial/distance/haversine.hpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2020-2022, 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. - */ - -#pragma once - -#include - -#include -#include - -#include - -namespace cuspatial { - -/** - * @brief Compute haversine distances between points in set A and the corresponding points in set B. - * - * @ingroup distance - * - * https://en.wikipedia.org/wiki/Haversine_formula - * - * @param[in] a_lon: longitude of points in set A - * @param[in] a_lat: latitude of points in set A - * @param[in] b_lon: longitude of points in set B - * @param[in] b_lat: latitude of points in set B - * @param[in] radius: radius of the sphere on which the points reside. default: 6371.0 (aprx. radius - * of earth in km) - * - * @return array of distances for all (a_lon[i], a_lat[i]) and (b_lon[i], b_lat[i]) point pairs - */ -std::unique_ptr haversine_distance( - cudf::column_view const& a_lon, - cudf::column_view const& a_lat, - cudf::column_view const& b_lon, - cudf::column_view const& b_lat, - double const radius = EARTH_RADIUS_KM, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); - -/** - * @} // end of doxygen group - */ - -} // namespace cuspatial diff --git a/cpp/include/cuspatial/distance/linestring_distance.hpp b/cpp/include/cuspatial/distance/linestring_distance.hpp deleted file mode 100644 index 051f016c3..000000000 --- a/cpp/include/cuspatial/distance/linestring_distance.hpp +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2022, 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. - */ - -#pragma once - -#include -#include - -#include - -#include - -namespace cuspatial { - -/** - * @brief Compute shortest distance between pairs of linestrings - * @ingroup distance - * - * The shortest distance between two linestrings is defined as the shortest distance - * between all pairs of segments of the two linestrings. If any of the segments intersect, - * the distance is 0. The shortest distance between two multilinestrings is defined as the - * the shortest distance between all pairs of linestrings of the two multilinestrings. - * - * The following example contains 4 pairs of linestrings. The first array is a single linestring - * array and the second array is a multilinestring array. - * ``` - * First pair: - * (0, 1) -> (1, 0) -> (-1, 0) - * {(1, 1) -> (2, 1) -> (2, 0) -> (3, 0)} - * - * | - * * #---# - * | \ | - * ----O---*---#---# - * | / - * * - * | - * - * The shortest distance between the two linestrings is the distance - * from point (1, 1) to segment (0, 1) -> (1, 0), which is sqrt(2)/2. - * - * Second pair: - * - * (0, 0) -> (0, 1) - * {(1, 0) -> (1, 1) -> (1, 2), (1, -1) -> (1, -2) -> (1, -3)} - * - * The linestrings in the pairs are parallel. Their distance is 1 (point (0, 0) to point (1, 0)). - * - * Third pair: - * - * (0, 0) -> (2, 2) -> (-2, 0) - * {(2, 0) -> (0, 2), (0, 2) -> (-2, 0)} - * - * The linestrings in the pairs intersect, so their distance is 0. - * - * Forth pair: - * - * (2, 2) -> (-2, -2) - * {(1, 1) -> (5, 5) -> (10, 0), (-1, -1) -> (-5, -5) -> (-10, 0)} - * - * These linestrings contain colinear and overlapping sections, so - * their distance is 0. - * - * The input of above example is: - * multilinestring1_geometry_offsets: nullopt - * linestring1_part_offsets: {0, 3, 5, 8, 10} - * linestring1_points_xy: - * {0, 1, 1, 0, -1, 0, 0, 0, 0, 1, 0, 0, 2, 2, -2, 0, 2, 2, -2, -2} - * - * multilinestring2_geometry_offsets: {0, 1, 3, 5, 7} - * linestring2_offsets: {0, 4, 7, 10, 12, 14, 17, 20} - * linestring2_points_xy: {1, 1, 2, 1, 2, 0, 3, 0, 1, 0, 1, 1, 1, 2, 1, -1, 1, -2, 1, -3, 2, 0, 0, - * 2, 0, 2, -2, 0, 1, 1, 5, 5, 10, 0, -1, -1, -5, -5, -10, 0} - * - * Result: {sqrt(2.0)/2, 1, 0, 0} - * ``` - * - * @param multilinestring1_geometry_offsets Beginning and ending indices to each multilinestring in - * the first multilinestring array. - * @param linestring1_part_offsets Beginning and ending indices for each linestring in the point - * array. Because the coordinates are interleaved, the actual starting position for the coordinate - * of linestring `i` is `2*linestring_part_offsets[i]`. - * @param linestring1_points_xy Interleaved x, y-coordinates of linestring points. - * @param multilinestring2_geometry_offsets Beginning and ending indices to each multilinestring in - * the second multilinestring array. - * @param linestring2_part_offsets Beginning and ending indices for each linestring in the point - * array. Because the coordinates are interleaved, the actual starting position for the coordinate - * of linestring `i` is `2*linestring_part_offsets[i]`. - * @param linestring2_points_xy Interleaved x, y-coordinates of linestring points. - * @param mr Device memory resource used to allocate the returned column's device memory - * @return A column of shortest distances between each pair of (multi)linestrings - * - * @note If `multilinestring_geometry_offset` is std::nullopt, the input is a single linestring - * array. - * @note If any of the linestring contains less than 2 points, the behavior is undefined. - * - * @throw cuspatial::logic_error if `linestring1_offsets.size() != linestring2_offsets.size()` - * @throw cuspatial::logic_error if any of the point arrays have mismatched types. - * @throw cuspatial::logic_error if any linestring has fewer than 2 points. - * - */ -std::unique_ptr pairwise_linestring_distance( - std::optional> multilinestring1_geometry_offsets, - cudf::device_span linestring1_part_offsets, - cudf::column_view const& linestring1_points_xy, - std::optional> multilinestring2_geometry_offsets, - cudf::device_span linestring2_part_offsets, - cudf::column_view const& linestring2_points_xy, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); -} // namespace cuspatial diff --git a/cpp/include/cuspatial/distance/linestring_polygon_distance.hpp b/cpp/include/cuspatial/distance/linestring_polygon_distance.hpp deleted file mode 100644 index 62b84e432..000000000 --- a/cpp/include/cuspatial/distance/linestring_polygon_distance.hpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 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. - */ - -#pragma once - -#include - -#include - -#include - -namespace cuspatial { - -/** - * @ingroup distance - * @brief Compute pairwise (multi)linestring-to-(multi)polygon Cartesian distance - * - * @param multilinestrings Geometry column of multilinestrings - * @param multipolygons Geometry column of multipolygons - * @param mr Device memory resource used to allocate the returned column. - * @return Column of distances between each pair of input geometries, same type as input coordinate - * types. - * - * @throw cuspatial::logic_error if `multilinestrings` and `multipolygons` have different coordinate - * types. - * @throw cuspatial::logic_error if `multilinestrings` is not a linestring column and - * `multipolygons` is not a polygon column. - * @throw cuspatial::logic_error if input column sizes mismatch. - */ - -std::unique_ptr pairwise_linestring_polygon_distance( - geometry_column_view const& multilinestrings, - geometry_column_view const& multipolygons, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); - -} // namespace cuspatial diff --git a/cpp/include/cuspatial/distance/point_distance.hpp b/cpp/include/cuspatial/distance/point_distance.hpp deleted file mode 100644 index 0a5af08e0..000000000 --- a/cpp/include/cuspatial/distance/point_distance.hpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2022, 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. - */ - -#pragma once - -#include - -#include - -namespace cuspatial { - -/** - * @ingroup distance - * @brief Compute pairwise (multi)point-to-(multi)point Cartesian distance - * - * Computes the cartesian distance between each pair of the multipoints. If input is - * a single point column, the offset of the column should be std::nullopt. - * - * @param points1_xy Column of xy-coordinates of the first point in each pair - * @param multipoints1_offset Index to the first point of each multipoint in points1_xy - * @param points2_xy Column of xy-coordinates of the second point in each pair - * @param multipoints2_offset Index to the second point of each multipoint in points2_xy - * @return Column of distances between each pair of input points - */ - -std::unique_ptr pairwise_point_distance( - std::optional> multipoints1_offset, - cudf::column_view const& points1_xy, - std::optional> multipoints2_offset, - cudf::column_view const& points2_xy, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); - -} // namespace cuspatial diff --git a/cpp/include/cuspatial/distance/point_linestring_distance.hpp b/cpp/include/cuspatial/distance/point_linestring_distance.hpp deleted file mode 100644 index 4f75cabe7..000000000 --- a/cpp/include/cuspatial/distance/point_linestring_distance.hpp +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2022, 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 - -#include - -namespace cuspatial { - -/** - * @brief Compute distance between pairs of points and linestrings - * - * The distance between a point and a linestring is defined as the minimum distance - * between the point and any segment of the linestring. For each input point, this - * function returns the distance between the point and the corresponding linestring. - * - * The following example contains 2 pairs of points and linestrings. - * ``` - * First pair: - * Point: (0, 0) - * Linestring: (0, 1) -> (1, 0) -> (2, 0) - * - * Second pair: - * Point: (1, 1) - * Linestring: (0, 0) -> (1, 1) -> (2, 0) -> (3, 0) -> (3, 1) - * - * The input of the above example is: - * multipoint_geometry_offsets: nullopt - * points_xy: {0, 1, 0, 1} - * multilinestring_geometry_offsets: nullopt - * linestring_part_offsets: {0, 3, 8} - * linestring_xy: {0, 1, 1, 0, 2, 0, 0, 0, 1, 1, 2, 0, 3, 0, 3, 1} - * - * Result: {sqrt(2)/2, 0} - * ``` - * - * The following example contains 3 pairs of MultiPoint and MultiLinestring. - * ``` - * First pair: - * MultiPoint: (0, 1) - * MultiLinestring: (0, -1) -> (-2, -3), (-4, -5) -> (-5, -6) - * - * Second pair: - * MultiPoint: (2, 3), (4, 5) - * MultiLinestring: (7, 8) -> (8, 9) - * - * Third pair: - * MultiPoint: (6, 7), (8, 9) - * MultiLinestring: (9, 10) -> (10, 11) - - * The input of the above example is: - * multipoint_geometry_offsets: {0, 1, 3, 5} - * points_xy: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} - * multilinestring_geometry_offsets: {0, 2, 3, 5} - * linestring_part_offsets: {0, 2, 4, 6, 8} - * linestring_points_xy: {0, -1, -2, -3, -4, -5, -5, -6, 7, 8, 8, 9, 9, 10, 10 ,11} - * - * Result: {2.0, 4.24264, 1.41421} - * ``` - * - * @param multipoint_geometry_offsets Beginning and ending indices to each geometry in the - * multi-point - * @param points_xy Interleaved x, y-coordinates of points - * @param multilinestring_geometry_offsets Beginning and ending indices to each geometry in the - * multi-linestring - * @param linestring_part_offsets Beginning and ending indices for each linestring in the point - * array. Because the coordinates are interleaved, the actual starting position for the coordinate - * of linestring `i` is `2*linestring_part_offsets[i]`. - * @param linestring_points_xy Interleaved x, y-coordinates of linestring points. - * @param mr Device memory resource used to allocate the returned column. - * @return A column containing the distance between each pair of corresponding points and - * linestrings. - * - * @note Any optional geometry indices, if is `nullopt`, implies the underlying geometry contains - * only one component. Otherwise, it contains multiple components. - * - * @throws cuspatial::logic_error if the number of (multi)points and (multi)linestrings do not - * match. - * @throws cuspatial::logic_error if the any of the point arrays have mismatched types. - */ -std::unique_ptr pairwise_point_linestring_distance( - std::optional> multipoint_geometry_offsets, - cudf::column_view const& points_xy, - std::optional> multilinestring_geometry_offsets, - cudf::device_span linestring_part_offsets, - cudf::column_view const& linestring_points_xy, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); - -} // namespace cuspatial diff --git a/cpp/include/cuspatial/distance/point_polygon_distance.hpp b/cpp/include/cuspatial/distance/point_polygon_distance.hpp deleted file mode 100644 index 97276b581..000000000 --- a/cpp/include/cuspatial/distance/point_polygon_distance.hpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 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. - */ - -#pragma once - -#include - -#include - -#include - -namespace cuspatial { - -/** - * @ingroup distance - * @brief Compute pairwise (multi)point-to-(multi)polygon Cartesian distance - * - * @param multipoints Geometry column of multipoints - * @param multipolygons Geometry column of multipolygons - * @param mr Device memory resource used to allocate the returned column. - * @return Column of distances between each pair of input geometries, same type as input coordinate - * types. - * - * @throw cuspatial::logic_error if `multipoints` and `multipolygons` has different coordinate - * types. - * @throw cuspatial::logic_error if `multipoints` is not a point column and `multipolygons` is not a - * polygon column. - * @throw cuspatial::logic_error if input column sizes mismatch. - */ - -std::unique_ptr pairwise_point_polygon_distance( - geometry_column_view const& multipoints, - geometry_column_view const& multipolygons, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); - -} // namespace cuspatial diff --git a/cpp/include/cuspatial/hausdorff.cuh b/cpp/include/cuspatial/hausdorff.cuh deleted file mode 100644 index 6fe38a006..000000000 --- a/cpp/include/cuspatial/hausdorff.cuh +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2022, 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. - */ - -#pragma once - -#include - -#include - -namespace cuspatial { - -/** - * @ingroup distance - * @brief Computes Hausdorff distances for all pairs in a collection of spaces - * - * https://en.wikipedia.org/wiki/Hausdorff_distance - * - * Example in 1D (this function operates in 2D): - * ``` - * spaces - * [0 2 5] [9] [3 7] - * - * spaces represented as points per space and concatenation of all points - * [0 2 5 9 3 7] [3 1 2] - * - * note: the following matrices are visually separated to highlight the relationship of a pair of - * points with the pair of spaces from which it is produced - * - * cartesian product of all - * points by pair of spaces distance between points - * +----------+----+-------+ +---------+---+------+ - * : 00 02 05 : 09 : 03 07 : : 0 2 5 : 9 : 3 7 : - * : 20 22 25 : 29 : 23 27 : : 2 0 3 : 7 : 1 5 : - * : 50 52 55 : 59 : 53 57 : : 5 3 0 : 4 : 2 2 : - * +----------+----+-------+ +---------+---+------+ - * : 90 92 95 : 99 : 93 97 : : 9 7 4 : 0 : 6 2 : - * +----------+----+-------+ +---------+---+------+ - * : 30 32 35 : 39 : 33 37 : : 3 1 2 : 6 : 0 4 : - * : 70 72 75 : 79 : 73 77 : : 7 5 2 : 2 : 4 0 : - * +----------+----+-------+ +---------+---+------+ - - * minimum distance from - * every point in one Hausdorff distance is - * space to any point in the maximum of the - * the other space minimum distances - * +----------+----+-------+ +---------+---+------+ - * : 0 : 9 : 3 : : 0 : 9 : 3 : - * : 0 : 7 : 1 : : : : : - * : 0 : 4 : 2 : : : : : - * +----------+----+-------+ +---------+---+------+ - * : 4 : 0 : 2 : : 4 : 0 : 2 : - * +----------+----+-------+ +---------+---+------+ - * : 1 : 6 : 0 : : : 6 : 0 : - * : 2 : 2 : 0 : : 2 : : : - * +----------+----+-------+ +---------+---+------+ - * - * returned as concatenation of columns - * [0 2 4 3 0 2 9 6 0] - * ``` - * - * @param[in] points_first: xs: beginning of range of (x,y) points - * @param[in] points_lasts: xs: end of range of (x,y) points - * @param[in] space_offsets_first: beginning of range of indices to each space. - * @param[in] space_offsets_first: end of range of indices to each space. Last index is the last - * @param[in] distance_first: beginning of range of output Hausdorff distance for each pair of - * spaces - * - * @tparam PointIt Iterator to input points. Points must be of a type that is convertible to - * `cuspatial::vec_2d`. Must meet the requirements of [LegacyRandomAccessIterator][LinkLRAI] and - * be device-accessible. - * @tparam OffsetIt Iterator to space offsets. Value type must be integral. Must meet the - * requirements of [LegacyRandomAccessIterator][LinkLRAI] and be device-accessible. - * @tparam OutputIt Output iterator. Must meet the requirements of - * [LegacyRandomAccessIterator][LinkLRAI] and be device-accessible and mutable. - * - * @pre All iterators must have the same underlying floating-point value type. - * - * @return Output iterator to the element past the last distance computed. - * - * @note Hausdorff distances are asymmetrical - */ -template -OutputIt directed_hausdorff_distance(PointIt points_first, - PointIt points_last, - OffsetIt space_offsets_first, - OffsetIt space_offsets_last, - OutputIt distance_first, - rmm::cuda_stream_view stream = rmm::cuda_stream_default); - -} // namespace cuspatial - -#include diff --git a/cpp/include/cuspatial/haversine.cuh b/cpp/include/cuspatial/haversine.cuh deleted file mode 100644 index dc1436fde..000000000 --- a/cpp/include/cuspatial/haversine.cuh +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2022, 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. - */ - -#pragma once - -#include -#include - -#include - -#include - -namespace cuspatial { - -/** - * @brief Compute haversine distances between points in set A to the corresponding points in set B. - * - * @ingroup distance - * - * Computes N haversine distances, where N is `std::distance(a_lonlat_first, a_lonlat_last)`. - * The distance for each `a_lonlat[i]` and `b_lonlat[i]` point pair is assigned to - * `distance_first[i]`. `distance_first` must be an iterator to output storage allocated for N - * distances. - * - * Computed distances will have the same units as `radius`. - * - * https://en.wikipedia.org/wiki/Haversine_formula - * - * @param[in] a_lonlat_first: beginning of range of (longitude, latitude) locations in set A - * @param[in] a_lonlat_last: end of range of (longitude, latitude) locations in set A - * @param[in] b_lonlat_first: beginning of range of (longitude, latitude) locations in set B - * @param[out] distance_first: beginning of output range of haversine distances - * @param[in] radius: radius of the sphere on which the points reside. default: 6371.0 - * (approximate radius of Earth in km) - * @param[in] stream: The CUDA stream on which to perform computations and allocate memory. - * - * @tparam LonLatItA Iterator to input location set A. Must meet the requirements of - * [LegacyRandomAccessIterator][LinkLRAI] and be device-accessible. - * @tparam LonLatItB Iterator to input location set B. Must meet the requirements of - * [LegacyRandomAccessIterator][LinkLRAI] and be device-accessible. - * @tparam OutputIt Output iterator. Must meet the requirements of - * [LegacyRandomAccessIterator][LinkLRAI] and be device-accessible and mutable. - * @tparam T The underlying coordinate type. Must be a floating-point type. - * - * @pre All iterators must have the same `Location` type, with the same underlying floating-point - * coordinate type (e.g. `cuspatial::vec_2d`). - * - * @return Output iterator to the element past the last distance computed. - * - * [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator - * "LegacyRandomAccessIterator" - */ -template > -OutputIt haversine_distance(LonLatItA a_lonlat_first, - LonLatItA a_lonlat_last, - LonLatItB b_lonlat_first, - OutputIt distance_first, - T const radius = EARTH_RADIUS_KM, - rmm::cuda_stream_view stream = rmm::cuda_stream_default); - -} // namespace cuspatial - -#include diff --git a/cpp/include/cuspatial/linestring_distance.cuh b/cpp/include/cuspatial/linestring_distance.cuh deleted file mode 100644 index c6f0de964..000000000 --- a/cpp/include/cuspatial/linestring_distance.cuh +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2022, 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. - */ - -#pragma once - -#include - -namespace cuspatial { - -/** - * @ingroup distance - * @copybrief cuspatial::pairwise_linestring_distance - * - * The shortest distance between two linestrings is defined as the shortest distance - * between all pairs of segments of the two linestrings. If any of the segments intersect, - * the distance is 0. - * - * @tparam MultiLinestringRange an instance of template type `multilinestring_range` - * @tparam OutputIt iterator type for output array. Must meet the requirements of [LRAI](LinkLRAI) - * and be device writable. - * - * @param multilinestrings1 Range object of the lhs multilinestring array - * @param multilinestrings2 Range object of the rhs multilinestring array - * @param stream The CUDA stream to use for device memory operations and kernel launches. - * @return Output iterator to the element past the last distance computed. - * - * [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator - * "LegacyRandomAccessIterator" - */ -template -OutputIt pairwise_linestring_distance(MultiLinestringRange1 multilinestrings1, - MultiLinstringRange2 multilinestrings2, - OutputIt distances_first, - rmm::cuda_stream_view stream = rmm::cuda_stream_default); -} // namespace cuspatial - -#include diff --git a/cpp/include/cuspatial/linestring_polygon_distance.cuh b/cpp/include/cuspatial/linestring_polygon_distance.cuh deleted file mode 100644 index a1adf9222..000000000 --- a/cpp/include/cuspatial/linestring_polygon_distance.cuh +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 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. - */ - -#pragma once - -#include - -namespace cuspatial { - -/** - * @ingroup distance - * @brief Computes pairwise multilinestring to multipolygon distance - * - * @tparam MultiLinestringRange An instance of template type `multipoint_range` - * @tparam MultiPolygonRange An instance of template type `multipolygon_range` - * @tparam OutputIt iterator type for output array. Must meet the requirements of [LRAI](LinkLRAI). - * Must be an iterator to type convertible from floating points. - * - * @param multilinestrings Range of multilinestrings, one per computed distance pair. - * @param multipolygons Range of multipolygons, one per computed distance pair. - * @param stream The CUDA stream on which to perform computations - * @return Output Iterator past the last distance computed - * - * [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator - * "LegacyRandomAccessIterator" - */ -template -OutputIt pairwise_linestring_polygon_distance( - MultiLinestringRange multilinestrings, - MultiPolygonRange multipoiygons, - OutputIt distances_first, - rmm::cuda_stream_view stream = rmm::cuda_stream_default); -} // namespace cuspatial - -#include diff --git a/cpp/include/cuspatial/point_distance.cuh b/cpp/include/cuspatial/point_distance.cuh deleted file mode 100644 index 7d7321b53..000000000 --- a/cpp/include/cuspatial/point_distance.cuh +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2022, 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. - */ - -#pragma once - -#include - -namespace cuspatial { - -/** - * @ingroup distance - * @copybrief cuspatial::pairwise_point_distance - * - * @tparam MultiPointArrayViewA An instance of template type `array_view::multipoint_array` - * @tparam MultiPointArrayViewB An instance of template type `array_view::multipoint_array` - * - * @param multipoints1 Range of first multipoint in each distance pair. - * @param multipoints2 Range of second multipoint in each distance pair. - * @return Iterator past the last distance computed - */ -template -OutputIt pairwise_point_distance(MultiPointArrayViewA multipoints1, - MultiPointArrayViewB multipoints2, - OutputIt distances_first, - rmm::cuda_stream_view stream = rmm::cuda_stream_default); -} // namespace cuspatial - -#include diff --git a/cpp/include/cuspatial/point_linestring_distance.cuh b/cpp/include/cuspatial/point_linestring_distance.cuh deleted file mode 100644 index e5d467265..000000000 --- a/cpp/include/cuspatial/point_linestring_distance.cuh +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2022, 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. - */ - -#pragma once - -#include - -namespace cuspatial { - -/** - * @brief Compute pairwise multipoint to multilinestring distance - * - * @tparam MultiPointRange an instance of template type `multipoint_range` - * @tparam MultiLinestringRange an instance of template type `multilinestring_range` - * @tparam OutputIt iterator type for output array. Must meet the requirements of [LRAI](LinkLRAI). - * - * @param multipoints The range of multipoints, one per computed distance pair - * @param multilinestrings The range of multilinestrings, one per computed distance pair - * @param stream The CUDA stream to use for device memory operations and kernel launches. - * @return Output iterator to the element past the last distance computed. - * - * [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator - * "LegacyRandomAccessIterator" - */ -template -OutputIt pairwise_point_linestring_distance( - MultiPointRange multipoints, - MultiLinestringRange multilinestrings, - OutputIt distances_first, - rmm::cuda_stream_view stream = rmm::cuda_stream_default); - -} // namespace cuspatial - -#include diff --git a/cpp/include/cuspatial/point_polygon_distance.cuh b/cpp/include/cuspatial/point_polygon_distance.cuh deleted file mode 100644 index eb4674069..000000000 --- a/cpp/include/cuspatial/point_polygon_distance.cuh +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 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. - */ - -#pragma once - -#include - -namespace cuspatial { - -/** - * @ingroup distance - * @brief Computes pairwise multipoint to multipolygon distance - * - * @tparam MultiPointRange An instance of template type `multipoint_range` - * @tparam MultiPolygonRange An instance of template type `multipolygon_range` - * @tparam OutputIt iterator type for output array. Must meet the requirements of [LRAI](LinkLRAI). - * Must be an iterator to type convertible from floating points. - * - * @param multipoints Range of multipoints, one per computed distance pair. - * @param multipolygons Range of multilinestrings, one per computed distance pair. - * @param stream The CUDA stream on which to perform computations - * @return Output Iterator past the last distance computed - * - * [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator - * "LegacyRandomAccessIterator" - */ -template -OutputIt pairwise_point_polygon_distance(MultiPointRange multipoints, - MultiPolygonRange multipoiygons, - OutputIt distances_first, - rmm::cuda_stream_view stream = rmm::cuda_stream_default); -} // namespace cuspatial - -#include diff --git a/cpp/src/spatial/hausdorff.cu b/cpp/src/spatial/hausdorff.cu index 530e0ecad..9706b5bf6 100644 --- a/cpp/src/spatial/hausdorff.cu +++ b/cpp/src/spatial/hausdorff.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -14,8 +14,8 @@ * limitations under the License. */ +#include #include -#include #include #include diff --git a/cpp/src/spatial/haversine.cu b/cpp/src/spatial/haversine.cu index c85ec9957..45c736c2f 100644 --- a/cpp/src/spatial/haversine.cu +++ b/cpp/src/spatial/haversine.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * 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. @@ -15,8 +15,8 @@ */ #include +#include #include -#include #include #include diff --git a/cpp/src/spatial/linestring_distance.cu b/cpp/src/spatial/linestring_distance.cu index 82cca68c2..8133d2a6f 100644 --- a/cpp/src/spatial/linestring_distance.cu +++ b/cpp/src/spatial/linestring_distance.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-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. @@ -17,10 +17,10 @@ #include "../utility/double_boolean_dispatch.hpp" #include "../utility/iterator.hpp" +#include #include #include #include -#include #include #include diff --git a/cpp/src/spatial/linestring_polygon_distance.cu b/cpp/src/spatial/linestring_polygon_distance.cu index 978cff1cd..d07a97baa 100644 --- a/cpp/src/spatial/linestring_polygon_distance.cu +++ b/cpp/src/spatial/linestring_polygon_distance.cu @@ -29,9 +29,9 @@ #include #include +#include #include #include -#include #include #include #include diff --git a/cpp/src/spatial/point_distance.cu b/cpp/src/spatial/point_distance.cu index 2b8776894..c0fe8d778 100644 --- a/cpp/src/spatial/point_distance.cu +++ b/cpp/src/spatial/point_distance.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-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. @@ -17,10 +17,10 @@ #include "../utility/double_boolean_dispatch.hpp" #include "../utility/iterator.hpp" +#include #include #include #include -#include #include #include diff --git a/cpp/src/spatial/point_linestring_distance.cu b/cpp/src/spatial/point_linestring_distance.cu index 5f852fffa..ed0b0ab7d 100644 --- a/cpp/src/spatial/point_linestring_distance.cu +++ b/cpp/src/spatial/point_linestring_distance.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-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. @@ -25,9 +25,9 @@ #include +#include #include #include -#include #include #include diff --git a/cpp/src/spatial/point_polygon_distance.cu b/cpp/src/spatial/point_polygon_distance.cu index efd88a24c..e4053d972 100644 --- a/cpp/src/spatial/point_polygon_distance.cu +++ b/cpp/src/spatial/point_polygon_distance.cu @@ -29,9 +29,9 @@ #include #include +#include #include #include -#include #include #include #include diff --git a/cpp/tests/spatial/distance/hausdorff_test.cpp b/cpp/tests/spatial/distance/hausdorff_test.cpp index 6cf59c9a8..2111e3330 100644 --- a/cpp/tests/spatial/distance/hausdorff_test.cpp +++ b/cpp/tests/spatial/distance/hausdorff_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * 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. @@ -14,10 +14,11 @@ * limitations under the License. */ -#include -#include +#include #include +#include + #include #include #include diff --git a/cpp/tests/spatial/distance/hausdorff_test.cu b/cpp/tests/spatial/distance/hausdorff_test.cu index 5c9b0aecf..453ee02f3 100644 --- a/cpp/tests/spatial/distance/hausdorff_test.cu +++ b/cpp/tests/spatial/distance/hausdorff_test.cu @@ -16,9 +16,9 @@ #include +#include #include #include -#include #include diff --git a/cpp/tests/spatial/distance/haversine_test.cpp b/cpp/tests/spatial/distance/haversine_test.cpp index c91b899dd..351bfce93 100644 --- a/cpp/tests/spatial/distance/haversine_test.cpp +++ b/cpp/tests/spatial/distance/haversine_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include #include diff --git a/cpp/tests/spatial/distance/haversine_test.cu b/cpp/tests/spatial/distance/haversine_test.cu index 8428143c3..b0798a37d 100644 --- a/cpp/tests/spatial/distance/haversine_test.cu +++ b/cpp/tests/spatial/distance/haversine_test.cu @@ -16,8 +16,8 @@ #include +#include #include -#include #include diff --git a/cpp/tests/spatial/distance/linestring_distance_test.cpp b/cpp/tests/spatial/distance/linestring_distance_test.cpp index b4622980b..7fc25497e 100644 --- a/cpp/tests/spatial/distance/linestring_distance_test.cpp +++ b/cpp/tests/spatial/distance/linestring_distance_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-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. @@ -15,7 +15,7 @@ */ #include -#include +#include #include #include diff --git a/cpp/tests/spatial/distance/linestring_distance_test.cu b/cpp/tests/spatial/distance/linestring_distance_test.cu index 5cb285a5a..cb9836392 100644 --- a/cpp/tests/spatial/distance/linestring_distance_test.cu +++ b/cpp/tests/spatial/distance/linestring_distance_test.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-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. @@ -17,10 +17,10 @@ #include #include +#include #include #include #include -#include #include #include #include diff --git a/cpp/tests/spatial/distance/linestring_distance_test_medium.cu b/cpp/tests/spatial/distance/linestring_distance_test_medium.cu index efda52407..bdc991b06 100644 --- a/cpp/tests/spatial/distance/linestring_distance_test_medium.cu +++ b/cpp/tests/spatial/distance/linestring_distance_test_medium.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-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. @@ -17,10 +17,10 @@ #include #include +#include #include #include #include -#include #include #include diff --git a/cpp/tests/spatial/distance/linestring_polygon_distance_test.cu b/cpp/tests/spatial/distance/linestring_polygon_distance_test.cu index 132544f00..bf74b731b 100644 --- a/cpp/tests/spatial/distance/linestring_polygon_distance_test.cu +++ b/cpp/tests/spatial/distance/linestring_polygon_distance_test.cu @@ -18,9 +18,9 @@ #include #include +#include #include #include -#include #include #include diff --git a/cpp/tests/spatial/distance/point_distance_test.cpp b/cpp/tests/spatial/distance/point_distance_test.cpp index d45e6459b..d16e2b5b1 100644 --- a/cpp/tests/spatial/distance/point_distance_test.cpp +++ b/cpp/tests/spatial/distance/point_distance_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-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. @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include #include diff --git a/cpp/tests/spatial/distance/point_distance_test.cu b/cpp/tests/spatial/distance/point_distance_test.cu index 97d708aa7..573c5232a 100644 --- a/cpp/tests/spatial/distance/point_distance_test.cu +++ b/cpp/tests/spatial/distance/point_distance_test.cu @@ -18,10 +18,10 @@ #include +#include #include #include #include -#include #include #include diff --git a/cpp/tests/spatial/distance/point_linestring_distance_test.cpp b/cpp/tests/spatial/distance/point_linestring_distance_test.cpp index 9f922cdcb..e35efa260 100644 --- a/cpp/tests/spatial/distance/point_linestring_distance_test.cpp +++ b/cpp/tests/spatial/distance/point_linestring_distance_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-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. @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include #include diff --git a/cpp/tests/spatial/distance/point_linestring_distance_test.cu b/cpp/tests/spatial/distance/point_linestring_distance_test.cu index 54744f2bd..e684f2a1b 100644 --- a/cpp/tests/spatial/distance/point_linestring_distance_test.cu +++ b/cpp/tests/spatial/distance/point_linestring_distance_test.cu @@ -16,10 +16,10 @@ #include +#include #include #include #include -#include #include #include diff --git a/cpp/tests/spatial/distance/point_polygon_distance_test.cpp b/cpp/tests/spatial/distance/point_polygon_distance_test.cpp index 43d9b2c66..dfb486b69 100644 --- a/cpp/tests/spatial/distance/point_polygon_distance_test.cpp +++ b/cpp/tests/spatial/distance/point_polygon_distance_test.cpp @@ -15,7 +15,7 @@ */ #include -#include +#include #include #include #include diff --git a/cpp/tests/spatial/distance/point_polygon_distance_test.cu b/cpp/tests/spatial/distance/point_polygon_distance_test.cu index eaeee981f..2cee8da4b 100644 --- a/cpp/tests/spatial/distance/point_polygon_distance_test.cu +++ b/cpp/tests/spatial/distance/point_polygon_distance_test.cu @@ -17,9 +17,9 @@ #include #include +#include #include #include -#include #include #include diff --git a/cpp/tests/spatial/linestring_polygon_distance_test.cpp b/cpp/tests/spatial/linestring_polygon_distance_test.cpp index 8bffe1d94..7b5b73642 100644 --- a/cpp/tests/spatial/linestring_polygon_distance_test.cpp +++ b/cpp/tests/spatial/linestring_polygon_distance_test.cpp @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include #include diff --git a/python/cuspatial/cuspatial/_lib/cpp/distance/hausdorff.pxd b/python/cuspatial/cuspatial/_lib/cpp/distance/hausdorff.pxd index 6b6f81d5c..7fcebe35f 100644 --- a/python/cuspatial/cuspatial/_lib/cpp/distance/hausdorff.pxd +++ b/python/cuspatial/cuspatial/_lib/cpp/distance/hausdorff.pxd @@ -1,4 +1,4 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2023, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr from libcpp.utility cimport pair @@ -8,7 +8,7 @@ from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table_view cimport table_view -cdef extern from "cuspatial/distance/hausdorff.hpp" \ +cdef extern from "cuspatial/distance.hpp" \ namespace "cuspatial" nogil: cdef pair[unique_ptr[column], table_view] directed_hausdorff_distance( diff --git a/python/cuspatial/cuspatial/_lib/cpp/distance/haversine.pxd b/python/cuspatial/cuspatial/_lib/cpp/distance/haversine.pxd index 4e39c6ad5..236c919fc 100644 --- a/python/cuspatial/cuspatial/_lib/cpp/distance/haversine.pxd +++ b/python/cuspatial/cuspatial/_lib/cpp/distance/haversine.pxd @@ -1,11 +1,11 @@ -# Copyright (c) 2019-2020, NVIDIA CORPORATION. +# Copyright (c) 2019-2023, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr from cudf._lib.column cimport column, column_view -cdef extern from "cuspatial/distance/haversine.hpp" \ +cdef extern from "cuspatial/distance.hpp" \ namespace "cuspatial" nogil: cdef unique_ptr[column] haversine_distance( const column_view& a_lon, diff --git a/python/cuspatial/cuspatial/_lib/cpp/distance/linestring_distance.pxd b/python/cuspatial/cuspatial/_lib/cpp/distance/linestring_distance.pxd index a4d2a940b..3c14745c5 100644 --- a/python/cuspatial/cuspatial/_lib/cpp/distance/linestring_distance.pxd +++ b/python/cuspatial/cuspatial/_lib/cpp/distance/linestring_distance.pxd @@ -1,4 +1,4 @@ -# Copyright (c) 2022, NVIDIA CORPORATION. +# Copyright (c) 2022-2023, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr @@ -9,7 +9,7 @@ from cudf._lib.cpp.column.column_view cimport column_view from cuspatial._lib.cpp.optional cimport optional -cdef extern from "cuspatial/distance/linestring_distance.hpp" \ +cdef extern from "cuspatial/distance.hpp" \ namespace "cuspatial" nogil: cdef unique_ptr[column] pairwise_linestring_distance( const optional[column_view] multilinestring1_geometry_offsets, diff --git a/python/cuspatial/cuspatial/_lib/cpp/distance/point_distance.pxd b/python/cuspatial/cuspatial/_lib/cpp/distance/point_distance.pxd index 7ed67251b..7b6a921b6 100644 --- a/python/cuspatial/cuspatial/_lib/cpp/distance/point_distance.pxd +++ b/python/cuspatial/cuspatial/_lib/cpp/distance/point_distance.pxd @@ -1,4 +1,4 @@ -# Copyright (c) 2022, NVIDIA CORPORATION. +# Copyright (c) 2022-2023, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr @@ -10,7 +10,7 @@ from cudf._lib.cpp.types cimport size_type from cuspatial._lib.cpp.optional cimport optional -cdef extern from "cuspatial/distance/point_distance.hpp" \ +cdef extern from "cuspatial/distance.hpp" \ namespace "cuspatial" nogil: cdef unique_ptr[column] pairwise_point_distance( const optional[column_view] multipoint1_offsets, diff --git a/python/cuspatial/cuspatial/_lib/cpp/distance/point_linestring_distance.pxd b/python/cuspatial/cuspatial/_lib/cpp/distance/point_linestring_distance.pxd index 40c3d9bf3..56d431875 100644 --- a/python/cuspatial/cuspatial/_lib/cpp/distance/point_linestring_distance.pxd +++ b/python/cuspatial/cuspatial/_lib/cpp/distance/point_linestring_distance.pxd @@ -1,4 +1,4 @@ -# Copyright (c) 2022, NVIDIA CORPORATION. +# Copyright (c) 2022-2023, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr @@ -10,7 +10,7 @@ from cudf._lib.cpp.types cimport size_type from cuspatial._lib.cpp.optional cimport optional -cdef extern from "cuspatial/distance/point_linestring_distance.hpp" \ +cdef extern from "cuspatial/distance.hpp" \ namespace "cuspatial" nogil: cdef unique_ptr[column] pairwise_point_linestring_distance( const optional[column_view] multipoint_geometry_offsets, diff --git a/python/cuspatial/cuspatial/_lib/cpp/distance/point_polygon_distance.pxd b/python/cuspatial/cuspatial/_lib/cpp/distance/point_polygon_distance.pxd index 020bd4574..63f659184 100644 --- a/python/cuspatial/cuspatial/_lib/cpp/distance/point_polygon_distance.pxd +++ b/python/cuspatial/cuspatial/_lib/cpp/distance/point_polygon_distance.pxd @@ -9,7 +9,7 @@ from cuspatial._lib.cpp.column.geometry_column_view cimport ( ) -cdef extern from "cuspatial/distance/point_polygon_distance.hpp" \ +cdef extern from "cuspatial/distance.hpp" \ namespace "cuspatial" nogil: cdef unique_ptr[column] pairwise_point_polygon_distance( const geometry_column_view & multipoints, diff --git a/python/cuspatial/cuspatial/_lib/cpp/linestring_bounding_box.pxd b/python/cuspatial/cuspatial/_lib/cpp/linestring_bounding_boxes.pxd similarity index 78% rename from python/cuspatial/cuspatial/_lib/cpp/linestring_bounding_box.pxd rename to python/cuspatial/cuspatial/_lib/cpp/linestring_bounding_boxes.pxd index b17f31ca8..fa458a6cf 100644 --- a/python/cuspatial/cuspatial/_lib/cpp/linestring_bounding_box.pxd +++ b/python/cuspatial/cuspatial/_lib/cpp/linestring_bounding_boxes.pxd @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2022, NVIDIA CORPORATION. +# Copyright (c) 2020-2023, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr @@ -6,7 +6,7 @@ from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table -cdef extern from "cuspatial/linestring_bounding_box.hpp" \ +cdef extern from "cuspatial/bounding_boxes.hpp" \ namespace "cuspatial" nogil: cdef unique_ptr[table] linestring_bounding_boxes( const column_view & linestring_offsets, diff --git a/python/cuspatial/cuspatial/_lib/cpp/linestring_intersection.pxd b/python/cuspatial/cuspatial/_lib/cpp/linestring_intersection.pxd index 71424a23f..0478c87de 100644 --- a/python/cuspatial/cuspatial/_lib/cpp/linestring_intersection.pxd +++ b/python/cuspatial/cuspatial/_lib/cpp/linestring_intersection.pxd @@ -9,7 +9,7 @@ from cuspatial._lib.cpp.column.geometry_column_view cimport ( ) -cdef extern from "cuspatial/linestring_intersection.hpp" \ +cdef extern from "cuspatial/intersection.hpp" \ namespace "cuspatial" nogil: struct linestring_intersection_column_result: diff --git a/python/cuspatial/cuspatial/_lib/cpp/pairwise_point_in_polygon.pxd b/python/cuspatial/cuspatial/_lib/cpp/pairwise_point_in_polygon.pxd index 90149e590..a9f1f7622 100644 --- a/python/cuspatial/cuspatial/_lib/cpp/pairwise_point_in_polygon.pxd +++ b/python/cuspatial/cuspatial/_lib/cpp/pairwise_point_in_polygon.pxd @@ -1,11 +1,11 @@ -# Copyright (c) 2022, NVIDIA CORPORATION. +# Copyright (c) 2022-2023, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr from cudf._lib.column cimport column, column_view -cdef extern from "cuspatial/pairwise_point_in_polygon.hpp" \ +cdef extern from "cuspatial/point_in_polygon.hpp" \ namespace "cuspatial" nogil: cdef unique_ptr[column] pairwise_point_in_polygon( const column_view & test_points_x, diff --git a/python/cuspatial/cuspatial/_lib/cpp/polygon_bounding_box.pxd b/python/cuspatial/cuspatial/_lib/cpp/polygon_bounding_boxes.pxd similarity index 80% rename from python/cuspatial/cuspatial/_lib/cpp/polygon_bounding_box.pxd rename to python/cuspatial/cuspatial/_lib/cpp/polygon_bounding_boxes.pxd index 46fdbf2e1..a6d28f965 100644 --- a/python/cuspatial/cuspatial/_lib/cpp/polygon_bounding_box.pxd +++ b/python/cuspatial/cuspatial/_lib/cpp/polygon_bounding_boxes.pxd @@ -1,4 +1,4 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2023, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr @@ -6,7 +6,7 @@ from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table -cdef extern from "cuspatial/polygon_bounding_box.hpp" \ +cdef extern from "cuspatial/bounding_boxes.hpp" \ namespace "cuspatial" nogil: cdef unique_ptr[table] polygon_bounding_boxes( const column_view & poly_offsets, diff --git a/python/cuspatial/cuspatial/_lib/cpp/projection.pxd b/python/cuspatial/cuspatial/_lib/cpp/projection.pxd index e02aa8b47..3c85461e7 100644 --- a/python/cuspatial/cuspatial/_lib/cpp/projection.pxd +++ b/python/cuspatial/cuspatial/_lib/cpp/projection.pxd @@ -1,4 +1,4 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2023, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr from libcpp.pair cimport pair diff --git a/python/cuspatial/cuspatial/_lib/linestring_bounding_boxes.pyx b/python/cuspatial/cuspatial/_lib/linestring_bounding_boxes.pyx index 823ad9960..28815cc57 100644 --- a/python/cuspatial/cuspatial/_lib/linestring_bounding_boxes.pyx +++ b/python/cuspatial/cuspatial/_lib/linestring_bounding_boxes.pyx @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2022, NVIDIA CORPORATION. +# Copyright (c) 2020-2023, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr from libcpp.utility cimport move @@ -8,7 +8,7 @@ from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table from cudf._lib.utils cimport columns_from_unique_ptr -from cuspatial._lib.cpp.linestring_bounding_box cimport ( +from cuspatial._lib.cpp.linestring_bounding_boxes cimport ( linestring_bounding_boxes as cpp_linestring_bounding_boxes, ) diff --git a/python/cuspatial/cuspatial/_lib/polygon_bounding_boxes.pyx b/python/cuspatial/cuspatial/_lib/polygon_bounding_boxes.pyx index 8b68700c6..d9419fe7b 100644 --- a/python/cuspatial/cuspatial/_lib/polygon_bounding_boxes.pyx +++ b/python/cuspatial/cuspatial/_lib/polygon_bounding_boxes.pyx @@ -1,4 +1,4 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2023, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr from libcpp.utility cimport move @@ -8,7 +8,7 @@ from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table from cudf._lib.utils cimport columns_from_unique_ptr -from cuspatial._lib.cpp.polygon_bounding_box cimport ( +from cuspatial._lib.cpp.polygon_bounding_boxes cimport ( polygon_bounding_boxes as cpp_polygon_bounding_boxes, ) From 39ae61a48e936d6acc46e5c3554c16e9ae5df3cf Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Wed, 26 Apr 2023 05:23:10 +0000 Subject: [PATCH 07/18] Consolidate intersection detail --- .../detail/{ => intersection}/linestring_intersection.cuh | 6 +++--- .../{ => intersection}/linestring_intersection_count.cuh | 0 .../linestring_intersection_with_duplicates.cuh | 2 +- cpp/include/cuspatial/intersection.cuh | 4 ++-- .../intersection/linestring_intersection_count_test.cu | 4 ++-- .../linestring_intersection_intermediates_remove_if_test.cu | 2 +- .../linestring_intersection_with_duplicates_test.cu | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) rename cpp/include/cuspatial/detail/{ => intersection}/linestring_intersection.cuh (98%) rename cpp/include/cuspatial/detail/{ => intersection}/linestring_intersection_count.cuh (100%) rename cpp/include/cuspatial/detail/{ => intersection}/linestring_intersection_with_duplicates.cuh (99%) diff --git a/cpp/include/cuspatial/detail/linestring_intersection.cuh b/cpp/include/cuspatial/detail/intersection/linestring_intersection.cuh similarity index 98% rename from cpp/include/cuspatial/detail/linestring_intersection.cuh rename to cpp/include/cuspatial/detail/intersection/linestring_intersection.cuh index 984e753e8..db9b28075 100644 --- a/cpp/include/cuspatial/detail/linestring_intersection.cuh +++ b/cpp/include/cuspatial/detail/intersection/linestring_intersection.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-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. @@ -20,8 +20,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/cpp/include/cuspatial/detail/linestring_intersection_count.cuh b/cpp/include/cuspatial/detail/intersection/linestring_intersection_count.cuh similarity index 100% rename from cpp/include/cuspatial/detail/linestring_intersection_count.cuh rename to cpp/include/cuspatial/detail/intersection/linestring_intersection_count.cuh diff --git a/cpp/include/cuspatial/detail/linestring_intersection_with_duplicates.cuh b/cpp/include/cuspatial/detail/intersection/linestring_intersection_with_duplicates.cuh similarity index 99% rename from cpp/include/cuspatial/detail/linestring_intersection_with_duplicates.cuh rename to cpp/include/cuspatial/detail/intersection/linestring_intersection_with_duplicates.cuh index b6dd20b35..e240acb88 100644 --- a/cpp/include/cuspatial/detail/linestring_intersection_with_duplicates.cuh +++ b/cpp/include/cuspatial/detail/intersection/linestring_intersection_with_duplicates.cuh @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include #include #include diff --git a/cpp/include/cuspatial/intersection.cuh b/cpp/include/cuspatial/intersection.cuh index cbc7c03dc..331e6eb0a 100644 --- a/cpp/include/cuspatial/intersection.cuh +++ b/cpp/include/cuspatial/intersection.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-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. @@ -92,4 +92,4 @@ linestring_intersection_result pairwise_linestring_intersection( } // namespace cuspatial -#include +#include diff --git a/cpp/tests/spatial/intersection/linestring_intersection_count_test.cu b/cpp/tests/spatial/intersection/linestring_intersection_count_test.cu index 549bdf468..24467462e 100644 --- a/cpp/tests/spatial/intersection/linestring_intersection_count_test.cu +++ b/cpp/tests/spatial/intersection/linestring_intersection_count_test.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-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. @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include #include diff --git a/cpp/tests/spatial/intersection/linestring_intersection_intermediates_remove_if_test.cu b/cpp/tests/spatial/intersection/linestring_intersection_intermediates_remove_if_test.cu index f9f8504b1..eb36d5e35 100644 --- a/cpp/tests/spatial/intersection/linestring_intersection_intermediates_remove_if_test.cu +++ b/cpp/tests/spatial/intersection/linestring_intersection_intermediates_remove_if_test.cu @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include #include diff --git a/cpp/tests/spatial/intersection/linestring_intersection_with_duplicates_test.cu b/cpp/tests/spatial/intersection/linestring_intersection_with_duplicates_test.cu index f01f6b5e1..195968615 100644 --- a/cpp/tests/spatial/intersection/linestring_intersection_with_duplicates_test.cu +++ b/cpp/tests/spatial/intersection/linestring_intersection_with_duplicates_test.cu @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include #include From cac1da54415c1a07f00a746d80267f3507c23d59 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Wed, 26 Apr 2023 05:25:54 +0000 Subject: [PATCH 08/18] Consolidate join detail headers --- .../cuspatial/detail/{ => join}/quadtree_bbox_filtering.cuh | 0 .../detail/{ => join}/quadtree_point_in_polygon.cuh | 0 .../{ => join}/quadtree_point_to_nearest_linestring.cuh | 0 cpp/include/cuspatial/spatial_join.cuh | 6 +++--- 4 files changed, 3 insertions(+), 3 deletions(-) rename cpp/include/cuspatial/detail/{ => join}/quadtree_bbox_filtering.cuh (100%) rename cpp/include/cuspatial/detail/{ => join}/quadtree_point_in_polygon.cuh (100%) rename cpp/include/cuspatial/detail/{ => join}/quadtree_point_to_nearest_linestring.cuh (100%) diff --git a/cpp/include/cuspatial/detail/quadtree_bbox_filtering.cuh b/cpp/include/cuspatial/detail/join/quadtree_bbox_filtering.cuh similarity index 100% rename from cpp/include/cuspatial/detail/quadtree_bbox_filtering.cuh rename to cpp/include/cuspatial/detail/join/quadtree_bbox_filtering.cuh diff --git a/cpp/include/cuspatial/detail/quadtree_point_in_polygon.cuh b/cpp/include/cuspatial/detail/join/quadtree_point_in_polygon.cuh similarity index 100% rename from cpp/include/cuspatial/detail/quadtree_point_in_polygon.cuh rename to cpp/include/cuspatial/detail/join/quadtree_point_in_polygon.cuh diff --git a/cpp/include/cuspatial/detail/quadtree_point_to_nearest_linestring.cuh b/cpp/include/cuspatial/detail/join/quadtree_point_to_nearest_linestring.cuh similarity index 100% rename from cpp/include/cuspatial/detail/quadtree_point_to_nearest_linestring.cuh rename to cpp/include/cuspatial/detail/join/quadtree_point_to_nearest_linestring.cuh diff --git a/cpp/include/cuspatial/spatial_join.cuh b/cpp/include/cuspatial/spatial_join.cuh index a9d53ec78..9815d5f4f 100644 --- a/cpp/include/cuspatial/spatial_join.cuh +++ b/cpp/include/cuspatial/spatial_join.cuh @@ -189,6 +189,6 @@ quadtree_point_to_nearest_linestring( } // namespace cuspatial -#include -#include -#include +#include +#include +#include From b3c172f8087389c2ea131bff428670cb4a4eb8ff Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Wed, 26 Apr 2023 05:29:22 +0000 Subject: [PATCH 09/18] consolidate trajectory detail headers --- .../detail/{ => trajectory}/derive_trajectories.cuh | 0 .../{ => trajectory}/trajectory_distances_and_speeds.cuh | 0 cpp/include/cuspatial/trajectory.cuh | 6 +++--- 3 files changed, 3 insertions(+), 3 deletions(-) rename cpp/include/cuspatial/detail/{ => trajectory}/derive_trajectories.cuh (100%) rename cpp/include/cuspatial/detail/{ => trajectory}/trajectory_distances_and_speeds.cuh (100%) diff --git a/cpp/include/cuspatial/detail/derive_trajectories.cuh b/cpp/include/cuspatial/detail/trajectory/derive_trajectories.cuh similarity index 100% rename from cpp/include/cuspatial/detail/derive_trajectories.cuh rename to cpp/include/cuspatial/detail/trajectory/derive_trajectories.cuh diff --git a/cpp/include/cuspatial/detail/trajectory_distances_and_speeds.cuh b/cpp/include/cuspatial/detail/trajectory/trajectory_distances_and_speeds.cuh similarity index 100% rename from cpp/include/cuspatial/detail/trajectory_distances_and_speeds.cuh rename to cpp/include/cuspatial/detail/trajectory/trajectory_distances_and_speeds.cuh diff --git a/cpp/include/cuspatial/trajectory.cuh b/cpp/include/cuspatial/trajectory.cuh index a08d1f837..f6c5d76f4 100644 --- a/cpp/include/cuspatial/trajectory.cuh +++ b/cpp/include/cuspatial/trajectory.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-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. @@ -136,5 +136,5 @@ OutputIt trajectory_distances_and_speeds(IndexT num_trajectories, } // namespace cuspatial -#include -#include +#include +#include From 0fc5df1679a8524233c2724f7161a3fa9c9dd0a7 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Wed, 26 Apr 2023 05:42:44 +0000 Subject: [PATCH 10/18] Rename nearest_points --- ...int_linestring_nearest_points.cuh => nearest_points.cuh} | 0 ...int_linestring_nearest_points.hpp => nearest_points.hpp} | 0 cpp/src/spatial/point_linestring_nearest_points.cu | 6 +++--- .../nearest_points/point_linestring_nearest_points_test.cpp | 4 ++-- .../nearest_points/point_linestring_nearest_points_test.cu | 2 +- ...int_linestring_nearest_points.pxd => nearest_points.pxd} | 4 ++-- python/cuspatial/cuspatial/_lib/nearest_points.pyx | 4 +++- 7 files changed, 11 insertions(+), 9 deletions(-) rename cpp/include/cuspatial/{point_linestring_nearest_points.cuh => nearest_points.cuh} (100%) rename cpp/include/cuspatial/{point_linestring_nearest_points.hpp => nearest_points.hpp} (100%) rename python/cuspatial/cuspatial/_lib/cpp/{point_linestring_nearest_points.pxd => nearest_points.pxd} (89%) diff --git a/cpp/include/cuspatial/point_linestring_nearest_points.cuh b/cpp/include/cuspatial/nearest_points.cuh similarity index 100% rename from cpp/include/cuspatial/point_linestring_nearest_points.cuh rename to cpp/include/cuspatial/nearest_points.cuh diff --git a/cpp/include/cuspatial/point_linestring_nearest_points.hpp b/cpp/include/cuspatial/nearest_points.hpp similarity index 100% rename from cpp/include/cuspatial/point_linestring_nearest_points.hpp rename to cpp/include/cuspatial/nearest_points.hpp diff --git a/cpp/src/spatial/point_linestring_nearest_points.cu b/cpp/src/spatial/point_linestring_nearest_points.cu index 5843e9d5d..9e15cc225 100644 --- a/cpp/src/spatial/point_linestring_nearest_points.cu +++ b/cpp/src/spatial/point_linestring_nearest_points.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-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. @@ -19,8 +19,8 @@ #include #include -#include -#include +#include +#include #include #include diff --git a/cpp/tests/spatial/nearest_points/point_linestring_nearest_points_test.cpp b/cpp/tests/spatial/nearest_points/point_linestring_nearest_points_test.cpp index 6743db576..47f69853b 100644 --- a/cpp/tests/spatial/nearest_points/point_linestring_nearest_points_test.cpp +++ b/cpp/tests/spatial/nearest_points/point_linestring_nearest_points_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-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. @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include diff --git a/cpp/tests/spatial/nearest_points/point_linestring_nearest_points_test.cu b/cpp/tests/spatial/nearest_points/point_linestring_nearest_points_test.cu index d71a7e64d..dfeac5cb2 100644 --- a/cpp/tests/spatial/nearest_points/point_linestring_nearest_points_test.cu +++ b/cpp/tests/spatial/nearest_points/point_linestring_nearest_points_test.cu @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include diff --git a/python/cuspatial/cuspatial/_lib/cpp/point_linestring_nearest_points.pxd b/python/cuspatial/cuspatial/_lib/cpp/nearest_points.pxd similarity index 89% rename from python/cuspatial/cuspatial/_lib/cpp/point_linestring_nearest_points.pxd rename to python/cuspatial/cuspatial/_lib/cpp/nearest_points.pxd index 1f66dfe61..826505c30 100644 --- a/python/cuspatial/cuspatial/_lib/cpp/point_linestring_nearest_points.pxd +++ b/python/cuspatial/cuspatial/_lib/cpp/nearest_points.pxd @@ -1,4 +1,4 @@ -# Copyright (c) 2022, NVIDIA CORPORATION. +# Copyright (c) 2022-2023, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr @@ -7,7 +7,7 @@ from cudf._lib.column cimport column, column_view from cuspatial._lib.cpp.optional cimport optional -cdef extern from "cuspatial/point_linestring_nearest_points.hpp" \ +cdef extern from "cuspatial/nearest_points.hpp" \ namespace "cuspatial" nogil: cdef struct point_linestring_nearest_points_result: diff --git a/python/cuspatial/cuspatial/_lib/nearest_points.pyx b/python/cuspatial/cuspatial/_lib/nearest_points.pyx index fd8267419..7a6d656ef 100644 --- a/python/cuspatial/cuspatial/_lib/nearest_points.pyx +++ b/python/cuspatial/cuspatial/_lib/nearest_points.pyx @@ -1,10 +1,12 @@ +# Copyright (c) 2022-2023, NVIDIA CORPORATION. + from libcpp.utility cimport move from cudf._lib.column cimport Column from cudf._lib.cpp.column.column_view cimport column_view from cuspatial._lib.cpp.optional cimport optional -from cuspatial._lib.cpp.point_linestring_nearest_points cimport ( +from cuspatial._lib.cpp.nearest_points cimport ( pairwise_point_linestring_nearest_points as c_func, point_linestring_nearest_points_result, ) From a9c5e5712b045505c88f5d22e272549e3e53de1b Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Wed, 26 Apr 2023 05:43:21 +0000 Subject: [PATCH 11/18] Projection rename and doxygen_groups --- .../sinusoidal_projection.cuh | 2 +- ...nusoidal_projection.cuh => projection.cuh} | 14 +++++++-- cpp/include/doxygen_groups.h | 30 ++++++++----------- cpp/src/spatial/sinusoidal_projection.cu | 4 +-- .../projection/sinusoidal_projection_test.cu | 2 +- 5 files changed, 29 insertions(+), 23 deletions(-) rename cpp/include/cuspatial/detail/{ => projection}/sinusoidal_projection.cuh (98%) rename cpp/include/cuspatial/{sinusoidal_projection.cuh => projection.cuh} (93%) diff --git a/cpp/include/cuspatial/detail/sinusoidal_projection.cuh b/cpp/include/cuspatial/detail/projection/sinusoidal_projection.cuh similarity index 98% rename from cpp/include/cuspatial/detail/sinusoidal_projection.cuh rename to cpp/include/cuspatial/detail/projection/sinusoidal_projection.cuh index 03fa2128c..24ec762bd 100644 --- a/cpp/include/cuspatial/detail/sinusoidal_projection.cuh +++ b/cpp/include/cuspatial/detail/projection/sinusoidal_projection.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-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. diff --git a/cpp/include/cuspatial/sinusoidal_projection.cuh b/cpp/include/cuspatial/projection.cuh similarity index 93% rename from cpp/include/cuspatial/sinusoidal_projection.cuh rename to cpp/include/cuspatial/projection.cuh index 885577287..ae6d4ea72 100644 --- a/cpp/include/cuspatial/sinusoidal_projection.cuh +++ b/cpp/include/cuspatial/projection.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-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. @@ -24,6 +24,11 @@ namespace cuspatial { +/** + * @addtogroup spatial_join + * @{ + */ + /** * @brief Sinusoidal projection of longitude/latitude relative to origin to Cartesian (x/y) * coordinates in km. @@ -64,6 +69,11 @@ OutputIt sinusoidal_projection(InputIt lon_lat_first, vec_2d origin, rmm::cuda_stream_view stream = rmm::cuda_stream_default); +/** + * @addtogroup spatial_join + * @{ + */ + } // namespace cuspatial -#include +#include diff --git a/cpp/include/doxygen_groups.h b/cpp/include/doxygen_groups.h index 4e7ea055e..b689c1f10 100644 --- a/cpp/include/doxygen_groups.h +++ b/cpp/include/doxygen_groups.h @@ -42,46 +42,37 @@ * * This module contains APIs that transforms cartesian and geodesic coordinates. * @file projection.hpp - * @file coordinate_transform.hpp - * @file sinusoidal_projection.cuh + * @file projection.cuh * @} * @defgroup distance Distance * @{ * @brief Distance computation APIs * - * @file point_distance.hpp - * @file point_distance.cuh - * @file point_linestring_distance.hpp - * @file point_linestring_distance.cuh - * @file linestring_distance.hpp - * @file linestring_distance.cuh - * @file hausdorff.hpp - * @file hausdorff.cuh - * @file haversine.hpp - * @file haversine.cuh + * @file distance.hpp + * @file distance.cuh * @} * @defgroup spatial_relationship Spatial Relationship * @{ * @brief APIs related to spatial relationship * - @file bounding_box.hpp + @file bounding_boxes.hpp + @file bounding_boxes.cuh * @file point_in_polygon.hpp * @file point_in_polygon.cuh - * @file polygon_bounding_box.hpp - * @file linestring_bounding_box.hpp * @file spatial_window.hpp * @} * @defgroup nearest_points Nearest Points * @{ * @brief APIs to compute the nearest points between geometries - * @file point_linestring_nearest_points.hpp - * @file point_linestring_nearest_points.cuh + * @file nearest_points.hpp + * @file nearest_points.cuh * @} * @} * @defgroup trajectory_api Trajectory APIs * @{ * @brief APIs related to trajectories * @file trajectory.hpp + * @file trajectory.cuh * @} * @defgroup spatial_indexing Spatial Indexing * @{ @@ -97,7 +88,11 @@ * @{ * @brief Type declarations for cuspatial * @file types.hpp + * @file box.hpp * @file vec_2d.hpp + * @file linestring_ref.cuh + * @file polygon_ref.cuh + * @file segment.cuh * @file geometry_column_view.hpp * * @defgroup type_factories Factory Methods @@ -118,6 +113,7 @@ * @file range.cuh * @file multipoint_range.cuh * @file multilinestring_range.cuh + * @file multipolygon_range.cuh * @} * @defgroup exception Exception * @{ diff --git a/cpp/src/spatial/sinusoidal_projection.cu b/cpp/src/spatial/sinusoidal_projection.cu index 522c8dea0..1be4ade40 100644 --- a/cpp/src/spatial/sinusoidal_projection.cu +++ b/cpp/src/spatial/sinusoidal_projection.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include diff --git a/cpp/tests/projection/sinusoidal_projection_test.cu b/cpp/tests/projection/sinusoidal_projection_test.cu index 1b0db23c7..41c2202e1 100644 --- a/cpp/tests/projection/sinusoidal_projection_test.cu +++ b/cpp/tests/projection/sinusoidal_projection_test.cu @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include From a11eeeb55ef4319f007b8fd5ef19ee3a8680e6a4 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Wed, 26 Apr 2023 06:03:58 +0000 Subject: [PATCH 12/18] Consistent naming for points_in_range --- cpp/CMakeLists.txt | 2 +- ...spatial_window.hpp => points_in_range.hpp} | 34 ++++----- .../points_in_range.cu} | 72 +++++++++---------- cpp/tests/CMakeLists.txt | 4 +- ...ndow_test.cpp => points_in_range_test.cpp} | 24 +++---- .../cuspatial/cuspatial/_lib/CMakeLists.txt | 2 +- .../cuspatial/_lib/cpp/points_in_range.pxd | 18 +++++ .../cuspatial/_lib/cpp/spatial_window.pxd | 18 ----- ...spatial_window.pyx => points_in_range.pyx} | 26 +++---- .../cuspatial/core/spatial/filtering.py | 4 +- 10 files changed, 99 insertions(+), 105 deletions(-) rename cpp/include/cuspatial/{spatial_window.hpp => points_in_range.hpp} (62%) rename cpp/src/{spatial_window/spatial_window.cu => spatial/points_in_range.cu} (55%) rename cpp/tests/spatial/points_in_range/{spatial_window_test.cpp => points_in_range_test.cpp} (80%) create mode 100644 python/cuspatial/cuspatial/_lib/cpp/points_in_range.pxd delete mode 100644 python/cuspatial/cuspatial/_lib/cpp/spatial_window.pxd rename python/cuspatial/cuspatial/_lib/{spatial_window.pyx => points_in_range.pyx} (54%) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 9cd9e7ff8..9b5ec49f3 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -125,7 +125,7 @@ add_library(cuspatial src/spatial/linestring_bounding_boxes.cu src/spatial/polygon_bounding_boxes.cu src/spatial/point_in_polygon.cu - src/spatial_window/spatial_window.cu + src/spatial/points_in_range.cu src/spatial/haversine.cu src/spatial/hausdorff.cu src/spatial/linestring_distance.cu diff --git a/cpp/include/cuspatial/spatial_window.hpp b/cpp/include/cuspatial/points_in_range.hpp similarity index 62% rename from cpp/include/cuspatial/spatial_window.hpp rename to cpp/include/cuspatial/points_in_range.hpp index fb13466c2..248835b1e 100644 --- a/cpp/include/cuspatial/spatial_window.hpp +++ b/cpp/include/cuspatial/points_in_range.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * 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. @@ -27,35 +27,35 @@ namespace cuspatial { /** - * @brief Find all points (x,y) that fall within a rectangular query window. + * @brief Find all points (x,y) that fall within a rectangular query range. * * @ingroup spatial_relationship * - * A point (x, y) is in the window if `x > window_min_x && x < window_min_y && y > window_min_y && y - * < window_max_y`. + * A point (x, y) is in the range if `x > range_min_x && x < range_min_y && y > range_min_y && y + * < range_max_y`. * - * Swaps `window_min_x` and `window_max_x` if `window_min_x > window_max_x`. - * Swaps `window_min_y` and `window_max_y` if `window_min_y > window_max_y`. + * Swaps `range_min_x` and `range_max_x` if `range_min_x > range_max_x`. + * Swaps `range_min_y` and `range_max_y` if `range_min_y > range_max_y`. * - * The window coordinates and the (x, y) points to be tested are assumed to be defined in the same + * The range coordinates and the (x, y) points to be tested are assumed to be defined in the same * coordinate system. * - * @param[in] window_min_x lower x-coordinate of the query window - * @param[in] window_max_x upper x-coordinate of the query window - * @param[in] window_min_y lower y-coordinate of the query window - * @param[in] window_max_y upper y-coordinate of the query window + * @param[in] range_min_x lower x-coordinate of the query range + * @param[in] range_max_x upper x-coordinate of the query range + * @param[in] range_min_y lower y-coordinate of the query range + * @param[in] range_max_y upper y-coordinate of the query range * @param[in] x x-coordinates of points to be queried * @param[in] y y-coordinates of points to be queried * @param[in] mr Optional `device_memory_resource` to use for allocating the output table * * @returns A table with two columns of the same type as the input columns. Columns 0, 1 are the - * (x, y) coordinates of the points in the input that fall within the query window. + * (x, y) coordinates of the points in the input that fall within the query range. */ -std::unique_ptr points_in_spatial_window( - double window_min_x, - double window_max_x, - double window_min_y, - double window_max_y, +std::unique_ptr points_in_range( + double range_min_x, + double range_max_x, + double range_min_y, + double range_max_y, cudf::column_view const& x, cudf::column_view const& y, rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); diff --git a/cpp/src/spatial_window/spatial_window.cu b/cpp/src/spatial/points_in_range.cu similarity index 55% rename from cpp/src/spatial_window/spatial_window.cu rename to cpp/src/spatial/points_in_range.cu index 8ed1358a3..df6f60c6a 100644 --- a/cpp/src/spatial_window/spatial_window.cu +++ b/cpp/src/spatial/points_in_range.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * 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. @@ -31,14 +31,14 @@ namespace { -// Type-dispatch functor that creates the spatial window filter of the correct type. +// Type-dispatch functor that creates the spatial range filter of the correct type. // Only floating point types are supported. -struct spatial_window_dispatch { +struct points_in_range_dispatch { template ::value>* = nullptr> - std::unique_ptr operator()(double window_min_x, - double window_max_x, - double window_min_y, - double window_max_y, + std::unique_ptr operator()(double range_min_x, + double range_max_x, + double range_min_y, + double range_max_y, cudf::column_view const& x, cudf::column_view const& y, rmm::cuda_stream_view stream, @@ -46,13 +46,11 @@ struct spatial_window_dispatch { { auto points_begin = cuspatial::make_vec_2d_iterator(x.begin(), y.begin()); - auto window_min = - cuspatial::vec_2d{static_cast(window_min_x), static_cast(window_min_y)}; - auto window_max = - cuspatial::vec_2d{static_cast(window_max_x), static_cast(window_max_y)}; + auto range_min = cuspatial::vec_2d{static_cast(range_min_x), static_cast(range_min_y)}; + auto range_max = cuspatial::vec_2d{static_cast(range_max_x), static_cast(range_max_y)}; auto output_size = cuspatial::count_points_in_range( - window_min, window_max, points_begin, points_begin + x.size(), stream); + range_min, range_max, points_begin, points_begin + x.size(), stream); std::vector> cols{}; cols.reserve(2); @@ -67,7 +65,7 @@ struct spatial_window_dispatch { output_y->mutable_view().begin()); cuspatial::copy_points_in_range( - window_min, window_max, points_begin, points_begin + x.size(), output_zip, stream); + range_min, range_max, points_begin, points_begin + x.size(), output_zip, stream); return std::make_unique(std::move(cols)); } @@ -88,19 +86,19 @@ namespace cuspatial { namespace detail { /* - * Return all points (x,y) that fall within a query window (x1,y1,x2,y2) + * Return all points (x,y) that fall within a query range (x1,y1,x2,y2) * see query.hpp * * Detail version that takes a stream. */ -std::unique_ptr points_in_spatial_window(double window_min_x, - double window_max_x, - double window_min_y, - double window_max_y, - cudf::column_view const& x, - cudf::column_view const& y, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr) +std::unique_ptr points_in_range(double range_min_x, + double range_max_x, + double range_min_y, + double range_max_y, + cudf::column_view const& x, + cudf::column_view const& y, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) { CUSPATIAL_EXPECTS(x.type() == y.type(), "Type mismatch between x and y arrays"); CUSPATIAL_EXPECTS(x.size() == y.size(), "Size mismatch between x and y arrays"); @@ -108,11 +106,11 @@ std::unique_ptr points_in_spatial_window(double window_min_x, CUSPATIAL_EXPECTS(not(x.has_nulls() || y.has_nulls()), "NULL point data not supported"); return cudf::type_dispatcher(x.type(), - spatial_window_dispatch(), - window_min_x, - window_max_x, - window_min_y, - window_max_y, + points_in_range_dispatch(), + range_min_x, + range_max_x, + range_min_y, + range_max_y, x, y, stream, @@ -122,19 +120,19 @@ std::unique_ptr points_in_spatial_window(double window_min_x, } // namespace detail /* - * Return all points (x,y) that fall within a query window (x1,y1,x2,y2) + * Return all points (x,y) that fall within a query range (x1,y1,x2,y2) * see query.hpp */ -std::unique_ptr points_in_spatial_window(double window_min_x, - double window_max_x, - double window_min_y, - double window_max_y, - cudf::column_view const& x, - cudf::column_view const& y, - rmm::mr::device_memory_resource* mr) +std::unique_ptr points_in_range(double range_min_x, + double range_max_x, + double range_min_y, + double range_max_y, + cudf::column_view const& x, + cudf::column_view const& y, + rmm::mr::device_memory_resource* mr) { - return detail::points_in_spatial_window( - window_min_x, window_max_x, window_min_y, window_max_y, x, y, rmm::cuda_stream_default, mr); + return detail::points_in_range( + range_min_x, range_max_x, range_min_y, range_max_y, x, y, rmm::cuda_stream_default, mr); } } // namespace cuspatial diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index 8f2a26f34..8fc3e1d8b 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -113,8 +113,8 @@ ConfigureTest(PAIRWISE_POINT_IN_POLYGON_TEST spatial/point_in_polygon/pairwise_point_in_polygon_test.cpp) # points in range -ConfigureTest(SPATIAL_WINDOW_POINT_TEST - spatial/points_in_range/spatial_window_test.cpp) +ConfigureTest(POINTS_IN_RANGE_TEST + spatial/points_in_range/points_in_range_test.cpp) # trajectory ConfigureTest(TRAJECTORY_DISTANCES_AND_SPEEDS_TEST diff --git a/cpp/tests/spatial/points_in_range/spatial_window_test.cpp b/cpp/tests/spatial/points_in_range/points_in_range_test.cpp similarity index 80% rename from cpp/tests/spatial/points_in_range/spatial_window_test.cpp rename to cpp/tests/spatial/points_in_range/points_in_range_test.cpp index 3d56bce16..37f7b153d 100644 --- a/cpp/tests/spatial/points_in_range/spatial_window_test.cpp +++ b/cpp/tests/spatial/points_in_range/points_in_range_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * 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. @@ -15,7 +15,7 @@ */ #include -#include +#include #include @@ -41,9 +41,8 @@ TEST_F(SpatialWindowErrorTest, TypeMismatch) auto points_x = cudf::test::fixed_width_column_wrapper({1.0, 2.0, 3.0}); auto points_y = cudf::test::fixed_width_column_wrapper({0.0, 1.0, 2.0}); - EXPECT_THROW( - auto result = cuspatial::points_in_spatial_window(1.5, 5.5, 1.5, 5.5, points_x, points_y), - cuspatial::logic_error); + EXPECT_THROW(auto result = cuspatial::points_in_range(1.5, 5.5, 1.5, 5.5, points_x, points_y), + cuspatial::logic_error); } TEST_F(SpatialWindowErrorTest, SizeMismatch) @@ -51,9 +50,8 @@ TEST_F(SpatialWindowErrorTest, SizeMismatch) auto points_x = cudf::test::fixed_width_column_wrapper({1.0, 2.0, 3.0}); auto points_y = cudf::test::fixed_width_column_wrapper({0.0}); - EXPECT_THROW( - auto result = cuspatial::points_in_spatial_window(1.5, 5.5, 1.5, 5.5, points_x, points_y), - cuspatial::logic_error); + EXPECT_THROW(auto result = cuspatial::points_in_range(1.5, 5.5, 1.5, 5.5, points_x, points_y), + cuspatial::logic_error); } struct IsFloat { @@ -73,9 +71,8 @@ TYPED_TEST(SpatialWindowUnsupportedTypesTest, ShouldThrow) auto points_x = cudf::test::fixed_width_column_wrapper({1.0, 2.0, 3.0}); auto points_y = cudf::test::fixed_width_column_wrapper({0.0, 1.0, 2.0}); - EXPECT_THROW( - auto result = cuspatial::points_in_spatial_window(1.5, 5.5, 1.5, 5.5, points_x, points_y), - cuspatial::logic_error); + EXPECT_THROW(auto result = cuspatial::points_in_range(1.5, 5.5, 1.5, 5.5, points_x, points_y), + cuspatial::logic_error); } template @@ -90,7 +87,6 @@ TYPED_TEST(SpatialWindowUnsupportedChronoTypesTest, ShouldThrow) auto points_x = cudf::test::fixed_width_column_wrapper({R{1}, R{2}, R{3}}); auto points_y = cudf::test::fixed_width_column_wrapper({R{0}, R{1}, R{2}}); - EXPECT_THROW( - auto result = cuspatial::points_in_spatial_window(1.5, 5.5, 1.5, 5.5, points_x, points_y), - cuspatial::logic_error); + EXPECT_THROW(auto result = cuspatial::points_in_range(1.5, 5.5, 1.5, 5.5, points_x, points_y), + cuspatial::logic_error); } diff --git a/python/cuspatial/cuspatial/_lib/CMakeLists.txt b/python/cuspatial/cuspatial/_lib/CMakeLists.txt index 4ffbfc7dc..e368ed478 100644 --- a/python/cuspatial/cuspatial/_lib/CMakeLists.txt +++ b/python/cuspatial/cuspatial/_lib/CMakeLists.txt @@ -18,13 +18,13 @@ set(cython_sources intersection.pyx nearest_points.pyx point_in_polygon.pyx + points_in_range.pyx pairwise_point_in_polygon.pyx polygon_bounding_boxes.pyx linestring_bounding_boxes.pyx quadtree.pyx spatial.pyx spatial_join.pyx - spatial_window.pyx trajectory.pyx types.pyx utils.pyx diff --git a/python/cuspatial/cuspatial/_lib/cpp/points_in_range.pxd b/python/cuspatial/cuspatial/_lib/cpp/points_in_range.pxd new file mode 100644 index 000000000..e6534dc7b --- /dev/null +++ b/python/cuspatial/cuspatial/_lib/cpp/points_in_range.pxd @@ -0,0 +1,18 @@ +# Copyright (c) 2020-2023, NVIDIA CORPORATION. + +from libcpp.memory cimport unique_ptr + +from cudf._lib.column cimport column, column_view +from cudf._lib.cpp.table.table cimport table, table_view + + +cdef extern from "cuspatial/points_in_range.hpp" namespace "cuspatial" nogil: + cdef unique_ptr[table] points_in_range \ + "cuspatial::points_in_range" ( + double range_min_x, + double range_max_x, + double range_min_y, + double range_max_y, + const column_view & x, + const column_view & y + ) except + diff --git a/python/cuspatial/cuspatial/_lib/cpp/spatial_window.pxd b/python/cuspatial/cuspatial/_lib/cpp/spatial_window.pxd deleted file mode 100644 index 1d69f2719..000000000 --- a/python/cuspatial/cuspatial/_lib/cpp/spatial_window.pxd +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. - -from libcpp.memory cimport unique_ptr - -from cudf._lib.column cimport column, column_view -from cudf._lib.cpp.table.table cimport table, table_view - - -cdef extern from "cuspatial/spatial_window.hpp" namespace "cuspatial" nogil: - cdef unique_ptr[table] points_in_spatial_window \ - "cuspatial::points_in_spatial_window" ( - double window_min_x, - double window_max_x, - double window_min_y, - double window_max_y, - const column_view & x, - const column_view & y - ) except + diff --git a/python/cuspatial/cuspatial/_lib/spatial_window.pyx b/python/cuspatial/cuspatial/_lib/points_in_range.pyx similarity index 54% rename from python/cuspatial/cuspatial/_lib/spatial_window.pyx rename to python/cuspatial/cuspatial/_lib/points_in_range.pyx index 3e1ced019..e54b60a6b 100644 --- a/python/cuspatial/cuspatial/_lib/spatial_window.pyx +++ b/python/cuspatial/cuspatial/_lib/points_in_range.pyx @@ -1,4 +1,4 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2023, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr from libcpp.utility cimport move @@ -7,16 +7,16 @@ from cudf._lib.column cimport Column, column_view from cudf._lib.cpp.table.table cimport table from cudf._lib.utils cimport data_from_unique_ptr -from cuspatial._lib.cpp.spatial_window cimport ( - points_in_spatial_window as cpp_points_in_spatial_window, +from cuspatial._lib.cpp.points_in_range cimport ( + points_in_range as cpp_points_in_range, ) -cpdef points_in_spatial_window( - double window_min_x, - double window_max_x, - double window_min_y, - double window_max_y, +cpdef points_in_range( + double range_min_x, + double range_max_x, + double range_min_y, + double range_max_y, Column x, Column y ): @@ -27,11 +27,11 @@ cpdef points_in_spatial_window( with nogil: c_result = move( - cpp_points_in_spatial_window( - window_min_x, - window_max_x, - window_min_y, - window_max_y, + cpp_points_in_range( + range_min_x, + range_max_x, + range_min_y, + range_max_y, x_v, y_v ) diff --git a/python/cuspatial/cuspatial/core/spatial/filtering.py b/python/cuspatial/cuspatial/core/spatial/filtering.py index be7689e1d..5775298a6 100644 --- a/python/cuspatial/cuspatial/core/spatial/filtering.py +++ b/python/cuspatial/cuspatial/core/spatial/filtering.py @@ -3,7 +3,7 @@ from cudf import DataFrame from cudf.core.column import as_column -from cuspatial._lib import spatial_window +from cuspatial._lib import points_in_range from cuspatial.core.geoseries import GeoSeries from cuspatial.utils.column_utils import contains_only_points @@ -52,7 +52,7 @@ def points_in_spatial_window(points: GeoSeries, min_x, max_x, min_y, max_y): ys = as_column(points.points.y) res_xy = DataFrame._from_data( - *spatial_window.points_in_spatial_window( + *points_in_range.points_in_range( min_x, max_x, min_y, max_y, xs, ys ) ).interleave_columns() From b84eabd21dd7bc2c1c07d2b23a96c5b5b9a3802f Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Wed, 26 Apr 2023 06:12:42 +0000 Subject: [PATCH 13/18] style --- python/cuspatial/cuspatial/_lib/nearest_points.pyx | 2 +- python/cuspatial/cuspatial/core/spatial/filtering.py | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/python/cuspatial/cuspatial/_lib/nearest_points.pyx b/python/cuspatial/cuspatial/_lib/nearest_points.pyx index 7a6d656ef..d8ecebc58 100644 --- a/python/cuspatial/cuspatial/_lib/nearest_points.pyx +++ b/python/cuspatial/cuspatial/_lib/nearest_points.pyx @@ -5,11 +5,11 @@ from libcpp.utility cimport move from cudf._lib.column cimport Column from cudf._lib.cpp.column.column_view cimport column_view -from cuspatial._lib.cpp.optional cimport optional from cuspatial._lib.cpp.nearest_points cimport ( pairwise_point_linestring_nearest_points as c_func, point_linestring_nearest_points_result, ) +from cuspatial._lib.cpp.optional cimport optional from cuspatial._lib.utils cimport unwrap_pyoptcol diff --git a/python/cuspatial/cuspatial/core/spatial/filtering.py b/python/cuspatial/cuspatial/core/spatial/filtering.py index 5775298a6..615784fee 100644 --- a/python/cuspatial/cuspatial/core/spatial/filtering.py +++ b/python/cuspatial/cuspatial/core/spatial/filtering.py @@ -52,8 +52,6 @@ def points_in_spatial_window(points: GeoSeries, min_x, max_x, min_y, max_y): ys = as_column(points.points.y) res_xy = DataFrame._from_data( - *points_in_range.points_in_range( - min_x, max_x, min_y, max_y, xs, ys - ) + *points_in_range.points_in_range(min_x, max_x, min_y, max_y, xs, ys) ).interleave_columns() return GeoSeries.from_points_xy(res_xy) From a634428d299f0fed6359651f0ec3e95bfb27151e Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Thu, 27 Apr 2023 00:54:31 +0000 Subject: [PATCH 14/18] Fix cython --- .../cuspatial/_lib/cpp/distance/linestring_polygon_distance.pxd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/cuspatial/cuspatial/_lib/cpp/distance/linestring_polygon_distance.pxd b/python/cuspatial/cuspatial/_lib/cpp/distance/linestring_polygon_distance.pxd index 82a4f1834..8505a380f 100644 --- a/python/cuspatial/cuspatial/_lib/cpp/distance/linestring_polygon_distance.pxd +++ b/python/cuspatial/cuspatial/_lib/cpp/distance/linestring_polygon_distance.pxd @@ -9,7 +9,7 @@ from cuspatial._lib.cpp.column.geometry_column_view cimport ( ) -cdef extern from "cuspatial/distance/linestring_polygon_distance.hpp" \ +cdef extern from "cuspatial/distance.hpp" \ namespace "cuspatial" nogil: cdef unique_ptr[column] pairwise_linestring_polygon_distance( const geometry_column_view & multilinestrings, From 1725c4b77532464144bb28f0e7f4e12f9b35e440 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Thu, 27 Apr 2023 02:24:33 +0000 Subject: [PATCH 15/18] Clean up ingroup/addtogroup doxygen --- cpp/doxygen/developer_guide/DOCUMENTATION.md | 5 +- cpp/include/cuspatial/bounding_boxes.hpp | 13 +++-- .../cuspatial/column/geometry_column_view.hpp | 3 +- cpp/include/cuspatial/distance.cuh | 24 ++++++++++ cpp/include/cuspatial/distance.hpp | 2 - cpp/include/cuspatial/nearest_points.hpp | 11 ++++- cpp/include/cuspatial/point_in_polygon.cuh | 13 +++-- cpp/include/cuspatial/points_in_range.cuh | 12 +++-- cpp/include/cuspatial/points_in_range.hpp | 10 +++- cpp/include/cuspatial/polygon_distance.cuh | 47 ------------------- .../cuspatial/range/multilinestring_range.cuh | 13 +++-- .../cuspatial/range/multipoint_range.cuh | 13 +++-- .../cuspatial/range/multipolygon_range.cuh | 12 +++-- cpp/include/doxygen_groups.h | 4 +- 14 files changed, 100 insertions(+), 82 deletions(-) delete mode 100644 cpp/include/cuspatial/polygon_distance.cuh diff --git a/cpp/doxygen/developer_guide/DOCUMENTATION.md b/cpp/doxygen/developer_guide/DOCUMENTATION.md index ef71ce79c..2a83c3dd7 100644 --- a/cpp/doxygen/developer_guide/DOCUMENTATION.md +++ b/cpp/doxygen/developer_guide/DOCUMENTATION.md @@ -475,8 +475,9 @@ from the [doxygen_groups.h](../include/doxygen_groups.h) file. } // namespace cuspatial -You can also use the \@addtogroup with a `@{ ... @}` pair to automatically include doxygen comment -blocks as part of a group. +When a file contains multiple functions, classes, or structs in the same group you should instead +use the \@addtogroup with a `@{ ... @}` pair to automatically include doxygen comment blocks as +part of a group. namespace cuspatial { /** diff --git a/cpp/include/cuspatial/bounding_boxes.hpp b/cpp/include/cuspatial/bounding_boxes.hpp index f76c9254d..9229eb7c2 100644 --- a/cpp/include/cuspatial/bounding_boxes.hpp +++ b/cpp/include/cuspatial/bounding_boxes.hpp @@ -24,11 +24,14 @@ namespace cuspatial { +/** + * @addtogroup spatial_relationship + * @{ + */ + /** * @brief Compute minimum bounding boxes of a set of linestrings and an expansion radius. * - * @ingroup spatial_relationship - * * @param linestring_offsets Begin indices of the first point in each linestring (i.e. prefix-sum) * @param x Linestring point x-coordinates * @param y Linestring point y-coordinates @@ -55,8 +58,6 @@ std::unique_ptr linestring_bounding_boxes( /** * @brief Compute minimum bounding box for each polygon in a list. * - * @ingroup spatial_relationship - * * @param poly_offsets Begin indices of the first ring in each polygon (i.e. prefix-sum) * @param ring_offsets Begin indices of the first point in each ring (i.e. prefix-sum) * @param x Polygon point x-coordinates @@ -82,4 +83,8 @@ std::unique_ptr polygon_bounding_boxes( double expansion_radius = 0.0, rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); +/** + * @} // end of doxygen group + */ + } // namespace cuspatial diff --git a/cpp/include/cuspatial/column/geometry_column_view.hpp b/cpp/include/cuspatial/column/geometry_column_view.hpp index 1c50cc253..f872c4d37 100644 --- a/cpp/include/cuspatial/column/geometry_column_view.hpp +++ b/cpp/include/cuspatial/column/geometry_column_view.hpp @@ -25,9 +25,10 @@ namespace cuspatial { /** - * @ingroup cuspatial_types * @brief A non-owning, immutable view of a geometry column. * + * @ingroup cuspatial_types + * * A geometry column is GeoArrow compliant, except that the data type for * the coordinates is List, instead of FixedSizeList[n_dim]. This is * because libcudf does not support FixedSizeList type. Currently, an diff --git a/cpp/include/cuspatial/distance.cuh b/cpp/include/cuspatial/distance.cuh index 425fb93ef..6f7da67d4 100644 --- a/cpp/include/cuspatial/distance.cuh +++ b/cpp/include/cuspatial/distance.cuh @@ -27,6 +27,7 @@ namespace cuspatial { /** * @addtogroup distance + * @{ */ /** @@ -263,6 +264,28 @@ OutputIt pairwise_linestring_polygon_distance( OutputIt distances_first, rmm::cuda_stream_view stream = rmm::cuda_stream_default); +/** + * @brief Computes pairwise multipolygon to multipolygon distance + * + * @tparam MultiPolygonRangeA An instance of template type `multipolygon_range` + * @tparam MultiPolygonRangeB An instance of template type `multipolygon_range` + * @tparam OutputIt iterator type for output array. Must meet the requirements of [LRAI](LinkLRAI). + * Must be an iterator to type convertible from floating points. + * + * @param lhs The first multipolygon range to compute distance from + * @param rhs The second multipolygon range to compute distance to + * @param stream The CUDA stream on which to perform computations + * @return Output Iterator past the last distance computed + * + * [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator + * "LegacyRandomAccessIterator" + */ +template +OutputIt pairwise_polygon_distance(MultipolygonRangeA lhs, + MultipolygonRangeB rhs, + OutputIt distances_first, + rmm::cuda_stream_view stream = rmm::cuda_stream_default); + /** * @} // end of doxygen group */ @@ -276,3 +299,4 @@ OutputIt pairwise_linestring_polygon_distance( #include #include #include +#include diff --git a/cpp/include/cuspatial/distance.hpp b/cpp/include/cuspatial/distance.hpp index de9d3e116..113707b72 100644 --- a/cpp/include/cuspatial/distance.hpp +++ b/cpp/include/cuspatial/distance.hpp @@ -59,8 +59,6 @@ std::unique_ptr haversine_distance( /** * @brief computes Hausdorff distances for all pairs in a collection of spaces * - * @ingroup distance - * * https://en.wikipedia.org/wiki/Hausdorff_distance * * Example in 1D (this function operates in 2D): diff --git a/cpp/include/cuspatial/nearest_points.hpp b/cpp/include/cuspatial/nearest_points.hpp index 17c022be5..640a1c9b6 100644 --- a/cpp/include/cuspatial/nearest_points.hpp +++ b/cpp/include/cuspatial/nearest_points.hpp @@ -24,7 +24,11 @@ namespace cuspatial { /** - * @ingroup nearest_points + * @addtogroup nearest_points + * @{ + */ + +/** * @brief Container for the result of `pairwise_point_linestring_nearest_points` */ struct point_linestring_nearest_points_result { @@ -45,7 +49,6 @@ struct point_linestring_nearest_points_result { }; /** - * @ingroup nearest_points * @brief Compute the nearest points and geometry ID between pairs of (multi)point and * (multi)linestring * @@ -164,4 +167,8 @@ point_linestring_nearest_points_result pairwise_point_linestring_nearest_points( cudf::column_view linestring_points_xy, rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); +/** + * @} // end of doxygen group + */ + } // namespace cuspatial diff --git a/cpp/include/cuspatial/point_in_polygon.cuh b/cpp/include/cuspatial/point_in_polygon.cuh index a0038f458..6ae058acd 100644 --- a/cpp/include/cuspatial/point_in_polygon.cuh +++ b/cpp/include/cuspatial/point_in_polygon.cuh @@ -21,8 +21,11 @@ namespace cuspatial { /** - * @ingroup spatial_relationship - * + * @addtogroup spatial_relationship + * @{ + */ + +/** * @brief Tests whether the specified points are inside any of the specified polygons. * * Tests whether points are inside at most 31 polygons. Polygons are a collection of one or more @@ -111,8 +114,6 @@ OutputIt point_in_polygon(Cart2dItA test_points_first, rmm::cuda_stream_view stream = rmm::cuda_stream_default); /** - * @ingroup spatial_relationship - * * @brief Given (point, polygon) pairs, tests whether the point of each pair is inside the polygon * of the pair. * @@ -197,6 +198,10 @@ OutputIt pairwise_point_in_polygon(Cart2dItA test_points_first, OutputIt output, rmm::cuda_stream_view stream = rmm::cuda_stream_default); +/** + * @} // end of doxygen group + */ + } // namespace cuspatial #include diff --git a/cpp/include/cuspatial/points_in_range.cuh b/cpp/include/cuspatial/points_in_range.cuh index 79205e417..5b12ab690 100644 --- a/cpp/include/cuspatial/points_in_range.cuh +++ b/cpp/include/cuspatial/points_in_range.cuh @@ -24,11 +24,13 @@ namespace cuspatial { +/** + * @addtogroup nearest_points + */ + /** * @brief Count of points (x,y) that fall within a query range. * - * @ingroup spatial_relationship - * * The query range is defined by a pair of opposite vertices within the coordinate system of the * input points, `v1` and `v2`. A point (x, y) is in the range if `x` lies between `v1.x` and `v2.x` * and `y` lies between `v1.y` and `v2.y`. A point is only counted if it is strictly within the @@ -66,8 +68,6 @@ typename thrust::iterator_traits::difference_type count_points_in_range /** * @brief Copies points (x,y) that fall within a query range. * - * @ingroup spatial_relationship - * * The query range is defined by a pair of opposite vertices of a quadrilateral within the * coordinate system of the input points, `v1` and `v2`. A point (x, y) is in the range if `x` lies * between `v1.x` and `v2.x` and `y` lies between `v1.y` and `v2.y`. A point is only counted if it @@ -113,6 +113,10 @@ OutputIt copy_points_in_range(vec_2d vertex_1, OutputIt output_points_first, rmm::cuda_stream_view stream = rmm::cuda_stream_default); +/** + * @} // end of doxygen group + */ + } // namespace cuspatial #include diff --git a/cpp/include/cuspatial/points_in_range.hpp b/cpp/include/cuspatial/points_in_range.hpp index 248835b1e..7bd23c2c0 100644 --- a/cpp/include/cuspatial/points_in_range.hpp +++ b/cpp/include/cuspatial/points_in_range.hpp @@ -26,11 +26,13 @@ namespace cuspatial { +/** + * @addtogroup spatial_relationship + */ + /** * @brief Find all points (x,y) that fall within a rectangular query range. * - * @ingroup spatial_relationship - * * A point (x, y) is in the range if `x > range_min_x && x < range_min_y && y > range_min_y && y * < range_max_y`. * @@ -60,4 +62,8 @@ std::unique_ptr points_in_range( cudf::column_view const& y, rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); +/** + * @} // end of doxygen group + */ + } // namespace cuspatial diff --git a/cpp/include/cuspatial/polygon_distance.cuh b/cpp/include/cuspatial/polygon_distance.cuh deleted file mode 100644 index c8e138df2..000000000 --- a/cpp/include/cuspatial/polygon_distance.cuh +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 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. - */ - -#pragma once - -#include - -namespace cuspatial { - -/** - * @ingroup distance - * @brief Computes pairwise multipolygon to multipolygon distance - * - * @tparam MultiPolygonRangeA An instance of template type `multipolygon_range` - * @tparam MultiPolygonRangeB An instance of template type `multipolygon_range` - * @tparam OutputIt iterator type for output array. Must meet the requirements of [LRAI](LinkLRAI). - * Must be an iterator to type convertible from floating points. - * - * @param lhs The first multipolygon range to compute distance from - * @param rhs The second multipolygon range to compute distance to - * @param stream The CUDA stream on which to perform computations - * @return Output Iterator past the last distance computed - * - * [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator - * "LegacyRandomAccessIterator" - */ -template -OutputIt pairwise_polygon_distance(MultipolygonRangeA lhs, - MultipolygonRangeB rhs, - OutputIt distances_first, - rmm::cuda_stream_view stream = rmm::cuda_stream_default); -} // namespace cuspatial - -#include diff --git a/cpp/include/cuspatial/range/multilinestring_range.cuh b/cpp/include/cuspatial/range/multilinestring_range.cuh index 04c280e04..00c12dd07 100644 --- a/cpp/include/cuspatial/range/multilinestring_range.cuh +++ b/cpp/include/cuspatial/range/multilinestring_range.cuh @@ -27,9 +27,12 @@ namespace cuspatial { +/** + * @addtogroup ranges + */ + /** * @brief Non-owning range-based interface to multilinestring data - * @ingroup ranges * * Provides a range-based interface to contiguous storage of multilinestring data, to make it easier * to access and iterate over multilinestrings, linestrings and points. @@ -211,7 +214,6 @@ class multilinestring_range { /** * @brief Create a multilinestring_range object from size and start iterators - * @ingroup ranges * * @tparam GeometryIteratorDiffType Index type of the size of the geometry array * @tparam PartIteratorDiffType Index type of the size of the part array @@ -260,7 +262,6 @@ auto make_multilinestring_range(GeometryIteratorDiffType num_multilinestrings, /** * @brief Create a range object of multilinestring data from offset and point ranges - * @ingroup ranges * * @tparam IntegerRange1 Range to integers * @tparam IntegerRange2 Range to integers @@ -285,7 +286,6 @@ auto make_multilinestring_range(IntegerRange1 geometry_offsets, } /** - * @ingroup ranges * @brief Create a range object of multilinestring from cuspatial::geometry_column_view. * Specialization for linestrings column. * @@ -315,7 +315,6 @@ auto make_multilinestring_range(GeometryColumnView const& linestrings_column) } /** - * @ingroup ranges * @brief Create a range object of multilinestring from cuspatial::geometry_column_view. * Specialization for multilinestrings column. * @@ -345,6 +344,10 @@ auto make_multilinestring_range(GeometryColumnView const& linestrings_column) points_it + points_xy.size() / 2); }; +/** + * @} // end of doxygen group + */ + } // namespace cuspatial #include diff --git a/cpp/include/cuspatial/range/multipoint_range.cuh b/cpp/include/cuspatial/range/multipoint_range.cuh index 1277d62b0..b41edbd7e 100644 --- a/cpp/include/cuspatial/range/multipoint_range.cuh +++ b/cpp/include/cuspatial/range/multipoint_range.cuh @@ -24,9 +24,13 @@ namespace cuspatial { +/** + * @addtogroup ranges + * @{ + */ + /** * @brief Non-owning range-based interface to multipoint data - * @ingroup ranges * * Provides a range-based interface to contiguous storage of multipoint data, to make it easier * to access and iterate over multipoints and points. @@ -160,7 +164,6 @@ class multipoint_range { /** * @brief Create a multipoint_range object of from size and start iterators - * @ingroup ranges * * @tparam GeometryIteratorDiffType Index type of the size of the geometry array * @tparam VecIteratorDiffType Index type of the size of the point array @@ -212,7 +215,6 @@ auto make_multipoint_range(IntegerRange geometry_offsets, PointRange points) } /** - * @ingroup ranges * @brief Create a range object of multipoints from cuspatial::geometry_column_view. * Specialization for points column. * @@ -239,7 +241,6 @@ auto make_multipoint_range(GeometryColumnView const& points_column) } /** - * @ingroup ranges * @brief Create a range object of multipoints from cuspatial::geometry_column_view. * Specialization for multipoints column. * @@ -265,6 +266,10 @@ auto make_multipoint_range(GeometryColumnView const& points_column) points_it + points_xy.size() / 2); }; +/** + * @} // end of doxygen group + */ + } // namespace cuspatial #include diff --git a/cpp/include/cuspatial/range/multipolygon_range.cuh b/cpp/include/cuspatial/range/multipolygon_range.cuh index 8a5e99841..1b8947345 100644 --- a/cpp/include/cuspatial/range/multipolygon_range.cuh +++ b/cpp/include/cuspatial/range/multipolygon_range.cuh @@ -26,9 +26,13 @@ namespace cuspatial { +/** + * @addtogroup ranges + * @{ + */ + /** * @brief Non-owning range-based interface to multipolygon data - * @ingroup ranges * * Provides a range-based interface to contiguous storage of multipolygon data, to make it easier * to access and iterate over multipolygons, polygons, rings and points. @@ -211,7 +215,6 @@ class multipolygon_range { }; /** - * @ingroup ranges * @brief Create a range object of multipolygon from cuspatial::geometry_column_view. * Specialization for polygons column. * @@ -245,7 +248,6 @@ auto make_multipolygon_range(GeometryColumnView const& polygons_column) } /** - * @ingroup ranges * @brief Create a range object of multipolygon from cuspatial::geometry_column_view. * Specialization for multipolygons column. * @@ -278,6 +280,10 @@ auto make_multipolygon_range(GeometryColumnView const& polygons_column) points_it + points_xy.size() / 2); }; +/** + * @} // end of doxygen group + */ + } // namespace cuspatial #include diff --git a/cpp/include/doxygen_groups.h b/cpp/include/doxygen_groups.h index b689c1f10..152e67bd8 100644 --- a/cpp/include/doxygen_groups.h +++ b/cpp/include/doxygen_groups.h @@ -24,8 +24,8 @@ // Below are the main groups that doxygen uses to build // the Modules page in the specified order. // -// To add a new API to an existing group, just use the -// @ingroup tag in the API's doxygen comment. +// To add a new API to an existing group, just use the @ingroup tag in the API's Doxygen +// comment or @addtogroup in the file, inside the namespace. // Add a new group by first specifying in the hierarchy below. /** From 71d6816dbf7469d41463230128af350ad65f0b17 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Thu, 27 Apr 2023 02:29:17 +0000 Subject: [PATCH 16/18] Fix include --- cpp/tests/spatial/distance/polygon_distance_test.cu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/tests/spatial/distance/polygon_distance_test.cu b/cpp/tests/spatial/distance/polygon_distance_test.cu index f8300713a..47a663824 100644 --- a/cpp/tests/spatial/distance/polygon_distance_test.cu +++ b/cpp/tests/spatial/distance/polygon_distance_test.cu @@ -18,9 +18,9 @@ #include #include +#include #include #include -#include #include #include From ce5c8772ea6e6de11139769045cb02b9a7b57c63 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Mon, 1 May 2023 22:53:23 +0000 Subject: [PATCH 17/18] Move linestring_polygon_distance_test.cpp --- cpp/tests/CMakeLists.txt | 2 +- .../spatial/{ => distance}/linestring_polygon_distance_test.cpp | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename cpp/tests/spatial/{ => distance}/linestring_polygon_distance_test.cpp (100%) diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index c74263540..73b51f34a 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -92,7 +92,7 @@ ConfigureTest(LINESTRING_DISTANCE_TEST spatial/distance/linestring_distance_test.cpp) ConfigureTest(LINESTRING_POLYGON_DISTANCE_TEST - spatial/linestring_polygon_distance_test.cpp) + spatial/distance/linestring_polygon_distance_test.cpp) ConfigureTest(POINT_POLYGON_DISTANCE_TEST spatial/distance/point_polygon_distance_test.cpp) diff --git a/cpp/tests/spatial/linestring_polygon_distance_test.cpp b/cpp/tests/spatial/distance/linestring_polygon_distance_test.cpp similarity index 100% rename from cpp/tests/spatial/linestring_polygon_distance_test.cpp rename to cpp/tests/spatial/distance/linestring_polygon_distance_test.cpp From 000c4b6e8c6a527bbcb6ecebd2165e2fb93cbe96 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Tue, 2 May 2023 20:55:45 +0000 Subject: [PATCH 18/18] Fix include. --- cpp/src/spatial/polygon_distance.cu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/src/spatial/polygon_distance.cu b/cpp/src/spatial/polygon_distance.cu index 8d3192e13..3a24f04cf 100644 --- a/cpp/src/spatial/polygon_distance.cu +++ b/cpp/src/spatial/polygon_distance.cu @@ -28,9 +28,9 @@ #include #include +#include #include #include -#include #include #include