diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 1996f5918..9cd9e7ff8 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -122,10 +122,9 @@ 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 src/spatial/haversine.cu src/spatial/hausdorff.cu diff --git a/cpp/benchmarks/pairwise_linestring_distance.cu b/cpp/benchmarks/pairwise_linestring_distance.cu index e70c72cee..3e8c2f6d2 100644 --- a/cpp/benchmarks/pairwise_linestring_distance.cu +++ b/cpp/benchmarks/pairwise_linestring_distance.cu @@ -17,11 +17,10 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/cpp/benchmarks/point_in_polygon.cu b/cpp/benchmarks/point_in_polygon.cu index 6567bd47c..13033f8c9 100644 --- a/cpp/benchmarks/point_in_polygon.cu +++ b/cpp/benchmarks/point_in_polygon.cu @@ -17,8 +17,8 @@ #include #include -#include -#include +#include +#include #include #include diff --git a/cpp/benchmarks/points_in_range.cu b/cpp/benchmarks/points_in_range.cu index 1ebe6349f..b9bced1be 100644 --- a/cpp/benchmarks/points_in_range.cu +++ b/cpp/benchmarks/points_in_range.cu @@ -18,10 +18,10 @@ #include -#include #include -#include -#include +#include +#include +#include #include #include diff --git a/cpp/benchmarks/quadtree_on_points.cu b/cpp/benchmarks/quadtree_on_points.cu index 58c527105..4984834f7 100644 --- a/cpp/benchmarks/quadtree_on_points.cu +++ b/cpp/benchmarks/quadtree_on_points.cu @@ -14,8 +14,8 @@ * limitations under the License. */ -#include -#include +#include +#include #include #include diff --git a/cpp/doxygen/Doxyfile b/cpp/doxygen/Doxyfile index dfafd207d..1c66cb038 100644 --- a/cpp/doxygen/Doxyfile +++ b/cpp/doxygen/Doxyfile @@ -819,7 +819,7 @@ INPUT = main_page.md \ developer_guide/DOCUMENTATION.md \ developer_guide/DEVELOPER_GUIDE.md \ developer_guide/TESTING.md \ - developer_guide/REFACTORING_GUIDE.md \ + developer_guide/HEADER_ONLY_API_GUIDE.md \ ../include # This tag can be used to specify the character encoding of the source files @@ -1155,7 +1155,7 @@ HTML_FOOTER = # obsolete. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_STYLESHEET = +HTML_STYLESHEET = # The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined # cascading style sheets that are included after the standard style sheets diff --git a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md index dbac80d46..586310b19 100644 --- a/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md +++ b/cpp/doxygen/developer_guide/DEVELOPER_GUIDE.md @@ -6,8 +6,8 @@ refer to these additional files for further documentation of libcuspatial best p * [Documentation Guide](DOCUMENTATION.md) for guidelines on documenting libcuspatial code. * [Testing Guide](TESTING.md) for guidelines on writing unit tests. * [Benchmarking Guide](BENCHMARKING.md) for guidelines on writing unit benchmarks. -* [Refactoring Guide](REFACTORING_GUIDE.md) for guidelines on refactoring legacy column-based APIs - into header-only APIs. +* [Header-only API Guide](HEADER_ONLY_API_GUIDE.md) for guidelines on the header-only API and + column-based API. # Overview @@ -38,17 +38,16 @@ TODO: add terms External/public libcuspatial APIs are grouped based on functionality into an appropriately titled header file in `cuspatial/cpp/include/cuspatial/`. For example, -`cuspatial/cpp/include/cuspatial/coordinate_transform.hpp` contains the declarations of public API -functions related to transforming coordinates. Note the `.hpp` file extension used to indicate a -C++ header file that can be included from a `.cpp` source file. +`cuspatial/cpp/include/cuspatial/projection.hpp` contains the declarations of public API +functions related to coordinate projection transforms. Note the `.hpp` file extension used to +indicate a C++ header file that can be included from a `.cpp` source file. Header files should use the `#pragma once` include guard. -The naming of public column-based cuSpatial API headers should be consistent with the name of the -folder that contains the source files that implement the API. For example, the implementation of the -APIs found in `cuspatial/cpp/include/cuspatial/trajectory.hpp` are located in -`cuspatial/src/trajectory`. This rule obviously does not apply to the header-only API, since the -headers are the source files. +The folder that contains the source files that implement an API should be named consistently with +the name of the of the header for the API. For example, the implementation of the APIs found in +`cuspatial/cpp/include/cuspatial/trajectory.hpp` are located in `cuspatial/src/trajectory`. This +rule obviously does not apply to the header-only API, since the headers are the source files. Likewise, unit tests reside in folders corresponding to the names of the API headers, e.g. trajectory.hpp tests are in `cuspatial/tests/trajectory/`. @@ -56,9 +55,9 @@ trajectory.hpp tests are in `cuspatial/tests/trajectory/`. Internal API headers containing `detail` namespace definitions that are used across translation units inside libcuspatial should be placed in `include/cuspatial/detail`. -Note that (currently) header-only API files are in `include/cuspatial/experimental`, and their tests -are in `tests/experimental`. When the header-only refactoring is complete these should be renamed or -split into a separate library. +Header-only API files and column-based API headers are stored together in `include/cuspatial`. The +former use the `.cuh` extension because they almost universally require CUDA compilation. The latter +use the `.hpp` extension because they can be compiled with a standard C++ compiler. ## File extensions diff --git a/cpp/doxygen/developer_guide/REFACTORING_GUIDE.md b/cpp/doxygen/developer_guide/HEADER_ONLY_API_GUIDE.md similarity index 86% rename from cpp/doxygen/developer_guide/REFACTORING_GUIDE.md rename to cpp/doxygen/developer_guide/HEADER_ONLY_API_GUIDE.md index 3a7e92b4d..65bf1b7ab 100644 --- a/cpp/doxygen/developer_guide/REFACTORING_GUIDE.md +++ b/cpp/doxygen/developer_guide/HEADER_ONLY_API_GUIDE.md @@ -1,33 +1,34 @@ -# cuSpatial C++ API Refactoring Guide +# cuSpatial C++ header-only API Guide The original cuSpatial C++ API (libcuspatial) was designed to depend on RAPIDS libcudf and use -its core data types, especially `cudf::column`. For users who do not also use libcudf or other -RAPIDS APIS, depending on libcudf could be a big barrier to adoption of libcuspatial. libcudf is +its core data types, especially `cudf::column`. For users who do not also use libcudf or other +RAPIDS APIS, depending on libcudf could be a big barrier to adoption of libcuspatial. libcudf is a very large library and building it takes a lot of time. -Therefore, we are developing a standalone libcuspatial C++ API that does not depend on libcudf. This -is a header-only template API with an iterator-based interface. This has a number of advantages +Therefore, the core of cuSpatial is now implemented in a standalone C++ API that does not depend on +libcudf. This is a header-only template API with an iterator- and range-based interface. This has a +number of advantages. 1. With a header-only API, users can include and build exactly what they use. - 2. With a templated API, the API can be flexible to support a variety of basic data types, such + 2. With a templated API, the API can be flexible to support a variety of basic data types, such as float and double for positional data, and different integer sizes for indices. 3. By templating on iterator types, cuSpatial algorithms can be fused with transformations of the input data, by using "fancy" iterators. Examples include transform iterators and counting iterators. 4. Memory resources only need to be part of APIs that allocate temporary intermediate storage. - Output storage is allocated outside the API and an output iterator is passed as an argument. + Output storage is allocated outside the API and an output iterator is passed as an argument. The main disadvantages of this type of API are 1. Header-only APIs can increase compilation time for code that depends on them. - 2. Some users (especially our Python API) may prefer a cuDF-based API. + 2. Some users (especially the cuSpatial Python API) may prefer a cuDF-based API. -The good news is that by maintaining the existing libcudf-based C++ API as a layer above the header- -only libcuspatial API, we can avoid problem 1 and problem 2 for users of the legacy API. +The good news is that maintaining the existing libcudf-based C++ API as a layer above the header- +only libcuspatial API avoids problem 1 and problem 2 for users of the column-based API. ## Example API -Following is an example iterator-based API for `cuspatial::haversine_distance`. (See below for +Following is an example iterator-based API for `cuspatial::haversine_distance`. (See below for discussion of API documentation.) ```c++ @@ -47,7 +48,7 @@ OutputIt haversine_distance(LonLatItA a_lonlat_first, There are a few key points to notice. 1. The API is very similar to STL algorithms such as `std::transform`. - 2. All array inputs and outputs are iterator type templates. + 2. All array inputs and outputs are iterator type templates. 3. Longitude/Latitude data is passed as array of structures, using the `cuspatial::vec_2d` type (include/cuspatial/vec_2d.hpp). This is enforced using a `static_assert` in the function body (discussed later). @@ -60,7 +61,7 @@ There are a few key points to notice. 7. The size of the input and output ranges in the example API are equal, so the start and end of only the A range is provided (`a_lonlat_first` and `a_lonlat_last`). This mirrors STL APIs. 8. This API returns an iterator to the element past the last element written to the output. This - is inspired by `std::transform`, even though as with `transform`, many uses of + is inspired by `std::transform`, even though as with `transform`, many uses of `haversine_distance` will not need this returned iterator. 9. All APIs that run CUDA device code (including Thrust algorithms) or allocate memory take a CUDA stream on which to execute the device code and allocate memory. @@ -103,7 +104,7 @@ Following is the (Doxygen) documentation for the above `cuspatial::haversine_dis * otherwise. * @pre `b_lonlat_first` may equal `distance_first`, but the range `[b_lonlat_first, b_lonlat_last)` * shall not overlap the range `[distance_first, distance_first + (b_lonlat_last - b_lonlat_last)) - * otherwise. + * otherwise. * @pre All iterators must have the same `Location` type, with the same underlying floating-point * coordinate type (e.g. `cuspatial::vec_2d`). * @@ -119,13 +120,13 @@ Key points: 2. All parameters and all template parameters are documented. 3. States the C++ standard iterator concepts that must be implemented, and that iterators must be device-accessible. - 4. Documents requirements as preconditions using `@pre`. + 4. Documents requirements as preconditions using `@pre`. 5. Uses preconditions to explicitly document what input ranges are allowed to overlap. 6. Documents the units of any inputs or outputs that have them. ## cuSpatial libcudf-based C++ API (legacy API) -This is the existing API, unchanged by refactoring. Here is the existing +This is the existing API, unchanged by refactoring. Here is the existing `cuspatial::haversine_distance`: ```c++ @@ -142,9 +143,9 @@ OutputIt haversine_distance(LonLatItA a_lonlat_first, ``` key points: - 1. All input data are `cudf::column_view`. This is a type-erased container so determining the + 1. All input data are `cudf::column_view`. This is a type-erased container so determining the type of data must be done at run time. - 2. All inputs are arrays of scalars. Longitude and latitude are separate. + 2. All inputs are arrays of scalars. Longitude and latitude are separate. 3. The output is a returned `unique_ptr`. 4. The output is allocated inside the function using the passed memory resource. 5. The public API does not take a stream. There is a `detail` version of the API that takes a @@ -152,37 +153,34 @@ key points: ## File Structure -For now, libcuspatial APIs should be defined in a header file in the -`cpp/include/cuspatial/experimental/` directory. Later, as we adopt the new API, we will rename -the `experimental` directory. The API header should be named after the API. In the example, -`haversine.hpp` defines the `cuspatial::haversine_distance` API. +libcuspatial APIs should be defined in a header file in the `cpp/include/cuspatial/` directory. +The API header should be named after the API. In the example, `haversine.hpp` defines the `cuspatial::haversine_distance` API. -The implementation must also be in a header, but should be in the `cuspatial/experimental/detail` -directory. The implementation should be included from the API definition file, at the end of the -file. Example: +The implementation must also be in a header, but should be in the `cuspatial/detail` directory. The +implementation should be included from the API definition file, at the end of the file. Example: ```c++ ... // declaration of API above this point -#include +#include ``` ## Namespaces Public APIs are in the `cuspatial` namespace. Note that both the header-only API and the libcudf- -based API can live in the same namespace, because they are non-ambiguous (very different +based API can live in the same namespace, because they are non-ambiguous (very different parameters). Implementation of the header-only API should be in a `cuspatial::detail` namespace. ## Implementation -The main implementation should be in detail headers. +The main implementation should be in detail headers. ### Header-only API Implementation -Because it is a statically typed API, the header-only implementation can be much simpler than the -libcudf-based API, which requires run-time type dispatching. In the case of `haversine_distance`, it is -a simple matter of a few static asserts and dynamic expectation checks, followed by a call to +Because it is a statically typed API, the header-only implementation can be much simpler than the +libcudf-based API, which requires run-time type dispatching. In the case of `haversine_distance`, +it is a simple matter of a few static asserts and dynamic expectation checks, followed by a call to `thrust::transform` with a custom transform functor. ```c++ @@ -216,17 +214,17 @@ OutputIt haversine_distance(LonLatItA a_lonlat_first, ``` Note that we `static_assert` that the types of the iterator inputs match documented expectations. -We also do a runtime check that the radius is positive. Finally we just call `thrust::transform`, +We also do a runtime check that the radius is positive. Finally we just call `thrust::transform`, passing it an instance of `haversine_distance_functor`, which is a function of two `vec_2d` inputs that implements the Haversine distance formula. ### libcudf-based API Implementation -The substance of the refactoring is making the libcudf-based API a wrapper around the header-only -API. This mostly involves replacing business logic implementation in the type-dispatched functor -with a call to the header-only API. We also need to convert disjoint latitude and longitude inputs +The substance of the refactoring is making the libcudf-based API a wrapper around the header-only +API. This mostly involves replacing business logic implementation in the type-dispatched functor +with a call to the header-only API. We also need to convert disjoint latitude and longitude inputs into `vec_2d` structs. This is easily done using the `cuspatial::make_vec_2d_iterator` utility -provided in `type_utils.hpp`. +provided in `type_utils.hpp`. So, to refactor the libcudf-based API, we remove the following code. @@ -271,6 +269,6 @@ cuspatial::haversine_distance(lonlat_a, Existing libcudf-based API tests can mostly be left alone. New tests should be added to exercise the header-only API separately in case the libcudf-based API is removed. -Note that tests, like the header-only API, should not depend on libcudf or libcudf_test. The +Note that tests, like the header-only API, should not depend on libcudf or libcudf_test. The cuDF-based API made the mistake of depending on libcudf_test, which results in breakages of cuSpatial sometimes when libcudf_test changes. diff --git a/cpp/doxygen/developer_guide/TESTING.md b/cpp/doxygen/developer_guide/TESTING.md index 0e75e9d83..8fcb58b25 100644 --- a/cpp/doxygen/developer_guide/TESTING.md +++ b/cpp/doxygen/developer_guide/TESTING.md @@ -26,21 +26,24 @@ and the main iterator and container types supported by algorithms. Here are som ## Header-only and Column-based API tests -libcuspatial currently has two C++ APIs: the column-based API uses libcudf data structures as -input and output. These tests live in `cpp/tests/` and can use libcudf features for constructing -columns and tables. The header-only API does not depend on libcudf at all and so tests of these -APIs should not include any libcudf headers. These tests currently live in `cpp/tests/experimental`. - -Generally, we test algorithms and business logic in the header-only API's unit tests. -Column-based API tests should only cover specifics of the column-based API, such as type -handling, input validation, and exceptions that are only thrown by that API. +libcuspatial currently has two C++ APIs: the column-based API uses libcudf data structures as +input and output. These tests can use libcudf features for constructing columns and tables. The +header-only API does not depend on libcudf at all and so tests of these APIs should not include any +libcudf headers. Header-only and column-based API tests are located together in `cuspatial/tests`, +however header-only API tests are `.cu` files and column-based API files are `.cpp` files. + +Generally, we test algorithms and business logic in the header-only API's unit tests. +Column-based API tests should only cover specifics of the column-based API, such as type +handling, input validation, and exceptions that are only thrown by that API. Column-based API tests +typically also tests empty imputs, to ensure that empty column inputs result in empty column output +rather than throwing exceptions. ## Directory and File Naming The naming of unit test directories and source files should be consistent with the feature being -tested. For example, the tests for APIs in `point_in_polygon.hpp` should live in +tested. For example, the tests for APIs in `point_in_polygon.hpp` should live in `cuspatial/cpp/tests/point_in_polygon_test.cpp`. Each feature (or set of related features) should -have its own test source file named `_test.cu/cpp`. +have its own test source file named `_test.cu/cpp`. In the interest of improving compile time, whenever possible, test source files should be `.cpp` files because `nvcc` is slower than `gcc` in compiling host code. Note that `thrust::device_vector` @@ -52,7 +55,7 @@ Testing header-only APIs requires CUDA compilation so should be done in `.cu` fi ## Base Fixture -All libcuspatial unit tests should make use of a GTest +All libcuspatial unit tests should make use of a GTest ["Test Fixture"](https://github.com/google/googletest/blob/master/docs/primer.md#test-fixtures-using-the-same-data-configuration-for-multiple-tests-same-data-multiple-tests). Even if the fixture is empty, it should inherit from the base fixture `cuspatial::test::BaseFixture` found in `cpp/tests/base_fixture.hpp`. This ensures that RMM is properly initialized and @@ -65,7 +68,7 @@ Example: ## Typed Tests -In general, libcuspatial features must work across all supported types (for cuspatial this +In general, libcuspatial features must work across all supported types (for cuspatial this typically just means `float` and `double`). In order to automate the process of running the same tests across multiple types, we use GTest's [Typed Tests](https://github.com/google/googletest/blob/master/docs/advanced.md#typed-tests). @@ -91,10 +94,10 @@ list defined in `TestTypes` (`float, double`). ## Utilities libcuspatial test utilities include `cuspatial::test::expect_vector_equivalent()` in -`cpp/tests/utility/vector_equality()`. This function compares two containers using Google Test's +`cpp/tests/utility/vector_equality()`. This function compares two containers using Google Test's approximate matching for floating-point values. It can handle vectors of `cuspatial::vec_2d`, -where `T` is `float` or `double`. It automatically copies data in device containers to host -containers before comparing, so you can pass it one host and one device vector, for example. +where `T` is `float` or `double`. It automatically copies data in device containers to host +containers before comparing, so you can pass it one host and one device vector, for example. Example: 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/column/geometry_column_view.hpp b/cpp/include/cuspatial/column/geometry_column_view.hpp index 7d6ca6352..1c50cc253 100644 --- a/cpp/include/cuspatial/column/geometry_column_view.hpp +++ b/cpp/include/cuspatial/column/geometry_column_view.hpp @@ -16,7 +16,7 @@ #pragma once -#include +#include #include #include diff --git a/cpp/include/cuspatial/experimental/detail/algorithm/is_point_in_polygon.cuh b/cpp/include/cuspatial/detail/algorithm/is_point_in_polygon.cuh similarity index 96% rename from cpp/include/cuspatial/experimental/detail/algorithm/is_point_in_polygon.cuh rename to cpp/include/cuspatial/detail/algorithm/is_point_in_polygon.cuh index 40c5cce33..ef40f714f 100644 --- a/cpp/include/cuspatial/experimental/detail/algorithm/is_point_in_polygon.cuh +++ b/cpp/include/cuspatial/detail/algorithm/is_point_in_polygon.cuh @@ -16,12 +16,12 @@ #pragma once -#include +#include +#include #include -#include #include -#include +#include namespace cuspatial { namespace detail { diff --git a/cpp/include/cuspatial/experimental/detail/algorithm/point_linestring_distance.cuh b/cpp/include/cuspatial/detail/algorithm/point_linestring_distance.cuh similarity index 91% rename from cpp/include/cuspatial/experimental/detail/algorithm/point_linestring_distance.cuh rename to cpp/include/cuspatial/detail/algorithm/point_linestring_distance.cuh index 4b8cf4a6c..732e11990 100644 --- a/cpp/include/cuspatial/experimental/detail/algorithm/point_linestring_distance.cuh +++ b/cpp/include/cuspatial/detail/algorithm/point_linestring_distance.cuh @@ -16,9 +16,9 @@ #pragma once -#include -#include -#include +#include +#include +#include namespace cuspatial { namespace detail { 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/experimental/detail/derive_trajectories.cuh b/cpp/include/cuspatial/detail/derive_trajectories.cuh similarity index 100% rename from cpp/include/cuspatial/experimental/detail/derive_trajectories.cuh rename to cpp/include/cuspatial/detail/derive_trajectories.cuh diff --git a/cpp/include/cuspatial/experimental/detail/distance_utils.cuh b/cpp/include/cuspatial/detail/distance_utils.cuh similarity index 98% rename from cpp/include/cuspatial/experimental/detail/distance_utils.cuh rename to cpp/include/cuspatial/detail/distance_utils.cuh index db07dcb7d..5d1de5eca 100644 --- a/cpp/include/cuspatial/experimental/detail/distance_utils.cuh +++ b/cpp/include/cuspatial/detail/distance_utils.cuh @@ -15,9 +15,9 @@ */ #include -#include +#include +#include #include -#include #include #include diff --git a/cpp/include/cuspatial/experimental/detail/find/find_and_combine_segment.cuh b/cpp/include/cuspatial/detail/find/find_and_combine_segment.cuh similarity index 99% rename from cpp/include/cuspatial/experimental/detail/find/find_and_combine_segment.cuh rename to cpp/include/cuspatial/detail/find/find_and_combine_segment.cuh index ef6bb0d3b..b05e71b03 100644 --- a/cpp/include/cuspatial/experimental/detail/find/find_and_combine_segment.cuh +++ b/cpp/include/cuspatial/detail/find/find_and_combine_segment.cuh @@ -29,6 +29,7 @@ namespace cuspatial { namespace detail { /** + * @internal * @brief Kernel to merge segments, naive n^2 algorithm. */ template diff --git a/cpp/include/cuspatial/experimental/detail/find/find_duplicate_points.cuh b/cpp/include/cuspatial/detail/find/find_duplicate_points.cuh similarity index 100% rename from cpp/include/cuspatial/experimental/detail/find/find_duplicate_points.cuh rename to cpp/include/cuspatial/detail/find/find_duplicate_points.cuh diff --git a/cpp/include/cuspatial/experimental/detail/find/find_points_on_segments.cuh b/cpp/include/cuspatial/detail/find/find_points_on_segments.cuh similarity index 97% rename from cpp/include/cuspatial/experimental/detail/find/find_points_on_segments.cuh rename to cpp/include/cuspatial/detail/find/find_points_on_segments.cuh index 6239404e4..dfda0b8b1 100644 --- a/cpp/include/cuspatial/experimental/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 @@ -33,6 +33,7 @@ namespace cuspatial { namespace detail { /** + * @internal * @brief Functor to find if the given point is on any of the segments in the same pair */ template @@ -65,6 +66,7 @@ struct find_point_on_segment_functor { }; /** + * @internal * @brief Given a multipoint and a set of segments, for each point, if the point is * on any of the segments, set the `mergeable_flag` of the point to `1`. */ diff --git a/cpp/include/cuspatial/experimental/detail/functors.cuh b/cpp/include/cuspatial/detail/functors.cuh similarity index 98% rename from cpp/include/cuspatial/experimental/detail/functors.cuh rename to cpp/include/cuspatial/detail/functors.cuh index e3f37156c..1f390753d 100644 --- a/cpp/include/cuspatial/experimental/detail/functors.cuh +++ b/cpp/include/cuspatial/detail/functors.cuh @@ -17,7 +17,7 @@ #pragma once #include -#include +#include #include #include diff --git a/cpp/include/cuspatial/experimental/detail/geometry/linestring_ref.cuh b/cpp/include/cuspatial/detail/geometry/linestring_ref.cuh similarity index 96% rename from cpp/include/cuspatial/experimental/detail/geometry/linestring_ref.cuh rename to cpp/include/cuspatial/detail/geometry/linestring_ref.cuh index 251b33f21..37e4bb5aa 100644 --- a/cpp/include/cuspatial/experimental/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 #include diff --git a/cpp/include/cuspatial/experimental/detail/geometry/polygon_ref.cuh b/cpp/include/cuspatial/detail/geometry/polygon_ref.cuh similarity index 94% rename from cpp/include/cuspatial/experimental/detail/geometry/polygon_ref.cuh rename to cpp/include/cuspatial/detail/geometry/polygon_ref.cuh index 3c1dfeb68..882ae22ae 100644 --- a/cpp/include/cuspatial/experimental/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 #include #include diff --git a/cpp/include/cuspatial/experimental/detail/geometry_collection/multilinestring_ref.cuh b/cpp/include/cuspatial/detail/geometry_collection/multilinestring_ref.cuh similarity index 96% rename from cpp/include/cuspatial/experimental/detail/geometry_collection/multilinestring_ref.cuh rename to cpp/include/cuspatial/detail/geometry_collection/multilinestring_ref.cuh index b4c76ec32..7a76f92b8 100644 --- a/cpp/include/cuspatial/experimental/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 #include diff --git a/cpp/include/cuspatial/experimental/detail/geometry_collection/multipoint_ref.cuh b/cpp/include/cuspatial/detail/geometry_collection/multipoint_ref.cuh similarity index 100% rename from cpp/include/cuspatial/experimental/detail/geometry_collection/multipoint_ref.cuh rename to cpp/include/cuspatial/detail/geometry_collection/multipoint_ref.cuh diff --git a/cpp/include/cuspatial/experimental/detail/geometry_collection/multipolygon_ref.cuh b/cpp/include/cuspatial/detail/geometry_collection/multipolygon_ref.cuh similarity index 95% rename from cpp/include/cuspatial/experimental/detail/geometry_collection/multipolygon_ref.cuh rename to cpp/include/cuspatial/detail/geometry_collection/multipolygon_ref.cuh index 940c6ef83..78920afe5 100644 --- a/cpp/include/cuspatial/experimental/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 +#include #include diff --git a/cpp/include/cuspatial/experimental/detail/hausdorff.cuh b/cpp/include/cuspatial/detail/hausdorff.cuh similarity index 99% rename from cpp/include/cuspatial/experimental/detail/hausdorff.cuh rename to cpp/include/cuspatial/detail/hausdorff.cuh index b5a2b2329..022c4490b 100644 --- a/cpp/include/cuspatial/experimental/detail/hausdorff.cuh +++ b/cpp/include/cuspatial/detail/hausdorff.cuh @@ -18,8 +18,8 @@ #include #include +#include #include -#include #include #include diff --git a/cpp/include/cuspatial/experimental/detail/haversine.cuh b/cpp/include/cuspatial/detail/haversine.cuh similarity index 98% rename from cpp/include/cuspatial/experimental/detail/haversine.cuh rename to cpp/include/cuspatial/detail/haversine.cuh index 3ec9b1afb..06ebb191a 100644 --- a/cpp/include/cuspatial/experimental/detail/haversine.cuh +++ b/cpp/include/cuspatial/detail/haversine.cuh @@ -18,8 +18,8 @@ #include #include +#include #include -#include #include #include diff --git a/cpp/include/cuspatial/experimental/detail/indexing/construction/phase_1.cuh b/cpp/include/cuspatial/detail/index/construction/phase_1.cuh similarity index 99% rename from cpp/include/cuspatial/experimental/detail/indexing/construction/phase_1.cuh rename to cpp/include/cuspatial/detail/index/construction/phase_1.cuh index f6281a900..83866e01f 100644 --- a/cpp/include/cuspatial/experimental/detail/indexing/construction/phase_1.cuh +++ b/cpp/include/cuspatial/detail/index/construction/phase_1.cuh @@ -16,10 +16,10 @@ #pragma once +#include #include -#include +#include #include -#include #include #include diff --git a/cpp/include/cuspatial/experimental/detail/indexing/construction/phase_2.cuh b/cpp/include/cuspatial/detail/index/construction/phase_2.cuh similarity index 99% rename from cpp/include/cuspatial/experimental/detail/indexing/construction/phase_2.cuh rename to cpp/include/cuspatial/detail/index/construction/phase_2.cuh index ea95beba8..ffbb79c0d 100644 --- a/cpp/include/cuspatial/experimental/detail/indexing/construction/phase_2.cuh +++ b/cpp/include/cuspatial/detail/index/construction/phase_2.cuh @@ -16,7 +16,7 @@ #pragma once -#include +#include #include #include diff --git a/cpp/include/cuspatial/experimental/detail/indexing/construction/utilities.cuh b/cpp/include/cuspatial/detail/index/construction/utilities.cuh similarity index 100% rename from cpp/include/cuspatial/experimental/detail/indexing/construction/utilities.cuh rename to cpp/include/cuspatial/detail/index/construction/utilities.cuh 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/experimental/detail/join/get_quad_and_local_point_indices.cuh b/cpp/include/cuspatial/detail/join/get_quad_and_local_point_indices.cuh similarity index 100% rename from cpp/include/cuspatial/experimental/detail/join/get_quad_and_local_point_indices.cuh rename to cpp/include/cuspatial/detail/join/get_quad_and_local_point_indices.cuh diff --git a/cpp/include/cuspatial/experimental/detail/join/intersection.cuh b/cpp/include/cuspatial/detail/join/intersection.cuh similarity index 98% rename from cpp/include/cuspatial/experimental/detail/join/intersection.cuh rename to cpp/include/cuspatial/detail/join/intersection.cuh index e6fbc03e4..cf137311e 100644 --- a/cpp/include/cuspatial/experimental/detail/join/intersection.cuh +++ b/cpp/include/cuspatial/detail/join/intersection.cuh @@ -17,8 +17,8 @@ #pragma once #include -#include -#include +#include +#include #include #include diff --git a/cpp/include/cuspatial/experimental/detail/join/traversal.cuh b/cpp/include/cuspatial/detail/join/traversal.cuh similarity index 100% rename from cpp/include/cuspatial/experimental/detail/join/traversal.cuh rename to cpp/include/cuspatial/detail/join/traversal.cuh diff --git a/cpp/include/cuspatial/experimental/detail/linestring_distance.cuh b/cpp/include/cuspatial/detail/linestring_distance.cuh similarity index 99% rename from cpp/include/cuspatial/experimental/detail/linestring_distance.cuh rename to cpp/include/cuspatial/detail/linestring_distance.cuh index 97648d74b..02eed59f0 100644 --- a/cpp/include/cuspatial/experimental/detail/linestring_distance.cuh +++ b/cpp/include/cuspatial/detail/linestring_distance.cuh @@ -19,8 +19,8 @@ #include #include #include +#include #include -#include #include #include diff --git a/cpp/include/cuspatial/experimental/detail/linestring_intersection.cuh b/cpp/include/cuspatial/detail/linestring_intersection.cuh similarity index 96% rename from cpp/include/cuspatial/experimental/detail/linestring_intersection.cuh rename to cpp/include/cuspatial/detail/linestring_intersection.cuh index 17bd3ad36..984e753e8 100644 --- a/cpp/include/cuspatial/experimental/detail/linestring_intersection.cuh +++ b/cpp/include/cuspatial/detail/linestring_intersection.cuh @@ -17,16 +17,16 @@ #pragma once #include +#include +#include +#include +#include +#include #include #include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include #include #include diff --git a/cpp/include/cuspatial/experimental/detail/linestring_intersection_count.cuh b/cpp/include/cuspatial/detail/linestring_intersection_count.cuh similarity index 98% rename from cpp/include/cuspatial/experimental/detail/linestring_intersection_count.cuh rename to cpp/include/cuspatial/detail/linestring_intersection_count.cuh index 155d5c1c3..0985253ad 100644 --- a/cpp/include/cuspatial/experimental/detail/linestring_intersection_count.cuh +++ b/cpp/include/cuspatial/detail/linestring_intersection_count.cuh @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include diff --git a/cpp/include/cuspatial/experimental/detail/linestring_intersection_with_duplicates.cuh b/cpp/include/cuspatial/detail/linestring_intersection_with_duplicates.cuh similarity index 98% rename from cpp/include/cuspatial/experimental/detail/linestring_intersection_with_duplicates.cuh rename to cpp/include/cuspatial/detail/linestring_intersection_with_duplicates.cuh index c56c4bfbe..b6dd20b35 100644 --- a/cpp/include/cuspatial/experimental/detail/linestring_intersection_with_duplicates.cuh +++ b/cpp/include/cuspatial/detail/linestring_intersection_with_duplicates.cuh @@ -14,15 +14,14 @@ * limitations under the License. */ -#include +#include #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/cpp/include/cuspatial/experimental/detail/linestring_polygon_distance.cuh b/cpp/include/cuspatial/detail/linestring_polygon_distance.cuh similarity index 96% rename from cpp/include/cuspatial/experimental/detail/linestring_polygon_distance.cuh rename to cpp/include/cuspatial/detail/linestring_polygon_distance.cuh index 8e3eaac1c..aa0c7cc11 100644 --- a/cpp/include/cuspatial/experimental/detail/linestring_polygon_distance.cuh +++ b/cpp/include/cuspatial/detail/linestring_polygon_distance.cuh @@ -19,14 +19,14 @@ #include "distance_utils.cuh" #include +#include +#include #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include #include #include diff --git a/cpp/include/cuspatial/experimental/detail/point_distance.cuh b/cpp/include/cuspatial/detail/point_distance.cuh similarity index 98% rename from cpp/include/cuspatial/experimental/detail/point_distance.cuh rename to cpp/include/cuspatial/detail/point_distance.cuh index a48acdac1..72cd4634b 100644 --- a/cpp/include/cuspatial/experimental/detail/point_distance.cuh +++ b/cpp/include/cuspatial/detail/point_distance.cuh @@ -17,8 +17,8 @@ #pragma once #include +#include #include -#include #include #include diff --git a/cpp/include/cuspatial/detail/point_in_polygon.cuh b/cpp/include/cuspatial/detail/point_in_polygon.cuh new file mode 100644 index 000000000..ecf6dd0ba --- /dev/null +++ b/cpp/include/cuspatial/detail/point_in_polygon.cuh @@ -0,0 +1,263 @@ +/* + * 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 + +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 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; + + auto idx = blockIdx.x * blockDim.x + threadIdx.x; + + if (idx >= num_test_points) { return; } + + int32_t hit_mask = 0; + + Cart2d const test_point = test_points_first[idx]; + + // for each polygon + for (auto poly_idx = 0; poly_idx < num_polys; poly_idx++) { + auto [poly_begin, poly_end] = + poly_begin_end(poly_offsets_first, num_polys, num_rings, poly_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); + + hit_mask |= point_is_within << poly_idx; + } + result[idx] = hit_mask; +} + +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 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); + + if (num_test_points > 0) { + 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_polys <= std::numeric_limits::digits, + "Number of polygons cannot exceed 31"); + + auto [threads_per_block, num_blocks] = grid_1d(num_test_points); + + detail::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; +} + +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/experimental/detail/point_linestring_distance.cuh b/cpp/include/cuspatial/detail/point_linestring_distance.cuh similarity index 99% rename from cpp/include/cuspatial/experimental/detail/point_linestring_distance.cuh rename to cpp/include/cuspatial/detail/point_linestring_distance.cuh index baf17070d..c245cd83c 100644 --- a/cpp/include/cuspatial/experimental/detail/point_linestring_distance.cuh +++ b/cpp/include/cuspatial/detail/point_linestring_distance.cuh @@ -19,8 +19,8 @@ #include #include #include +#include #include -#include #include #include diff --git a/cpp/include/cuspatial/experimental/detail/point_linestring_nearest_points.cuh b/cpp/include/cuspatial/detail/point_linestring_nearest_points.cuh similarity index 99% rename from cpp/include/cuspatial/experimental/detail/point_linestring_nearest_points.cuh rename to cpp/include/cuspatial/detail/point_linestring_nearest_points.cuh index da1c3e14e..12464f645 100644 --- a/cpp/include/cuspatial/experimental/detail/point_linestring_nearest_points.cuh +++ b/cpp/include/cuspatial/detail/point_linestring_nearest_points.cuh @@ -19,8 +19,8 @@ #include #include #include +#include #include -#include #include #include diff --git a/cpp/include/cuspatial/experimental/detail/point_polygon_distance.cuh b/cpp/include/cuspatial/detail/point_polygon_distance.cuh similarity index 93% rename from cpp/include/cuspatial/experimental/detail/point_polygon_distance.cuh rename to cpp/include/cuspatial/detail/point_polygon_distance.cuh index b015f09c8..1729b6775 100644 --- a/cpp/include/cuspatial/experimental/detail/point_polygon_distance.cuh +++ b/cpp/include/cuspatial/detail/point_polygon_distance.cuh @@ -19,15 +19,14 @@ #include "distance_utils.cuh" #include -#include +#include #include #include #include #include -#include -#include -#include -#include +#include +#include +#include #include #include diff --git a/cpp/include/cuspatial/experimental/detail/point_quadtree.cuh b/cpp/include/cuspatial/detail/point_quadtree.cuh similarity index 98% rename from cpp/include/cuspatial/experimental/detail/point_quadtree.cuh rename to cpp/include/cuspatial/detail/point_quadtree.cuh index 3cda7a0dc..3e70d1fe2 100644 --- a/cpp/include/cuspatial/experimental/detail/point_quadtree.cuh +++ b/cpp/include/cuspatial/detail/point_quadtree.cuh @@ -16,10 +16,10 @@ #pragma once +#include +#include #include -#include -#include -#include +#include #include #include diff --git a/cpp/include/cuspatial/experimental/detail/points_in_range.cuh b/cpp/include/cuspatial/detail/points_in_range.cuh similarity index 98% rename from cpp/include/cuspatial/experimental/detail/points_in_range.cuh rename to cpp/include/cuspatial/detail/points_in_range.cuh index 0bf61d2a3..7a4432b51 100644 --- a/cpp/include/cuspatial/experimental/detail/points_in_range.cuh +++ b/cpp/include/cuspatial/detail/points_in_range.cuh @@ -17,8 +17,8 @@ #pragma once #include +#include #include -#include #include #include diff --git a/cpp/include/cuspatial/experimental/detail/quadtree_bbox_filtering.cuh b/cpp/include/cuspatial/detail/quadtree_bbox_filtering.cuh similarity index 97% rename from cpp/include/cuspatial/experimental/detail/quadtree_bbox_filtering.cuh rename to cpp/include/cuspatial/detail/quadtree_bbox_filtering.cuh index c6768720a..9ba8744d0 100644 --- a/cpp/include/cuspatial/experimental/detail/quadtree_bbox_filtering.cuh +++ b/cpp/include/cuspatial/detail/quadtree_bbox_filtering.cuh @@ -16,10 +16,10 @@ #pragma once -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/cpp/include/cuspatial/experimental/detail/quadtree_point_in_polygon.cuh b/cpp/include/cuspatial/detail/quadtree_point_in_polygon.cuh similarity index 95% rename from cpp/include/cuspatial/experimental/detail/quadtree_point_in_polygon.cuh rename to cpp/include/cuspatial/detail/quadtree_point_in_polygon.cuh index db507b76a..2a9594317 100644 --- a/cpp/include/cuspatial/experimental/detail/quadtree_point_in_polygon.cuh +++ b/cpp/include/cuspatial/detail/quadtree_point_in_polygon.cuh @@ -14,12 +14,12 @@ * limitations under the License. */ -#include +#include +#include #include -#include -#include -#include -#include +#include +#include +#include #include #include diff --git a/cpp/include/cuspatial/experimental/detail/quadtree_point_to_nearest_linestring.cuh b/cpp/include/cuspatial/detail/quadtree_point_to_nearest_linestring.cuh similarity index 97% rename from cpp/include/cuspatial/experimental/detail/quadtree_point_to_nearest_linestring.cuh rename to cpp/include/cuspatial/detail/quadtree_point_to_nearest_linestring.cuh index 112942edf..a317758d9 100644 --- a/cpp/include/cuspatial/experimental/detail/quadtree_point_to_nearest_linestring.cuh +++ b/cpp/include/cuspatial/detail/quadtree_point_to_nearest_linestring.cuh @@ -14,13 +14,13 @@ * limitations under the License. */ -#include +#include +#include #include #include -#include -#include -#include -#include +#include +#include +#include #include #include diff --git a/cpp/include/cuspatial/experimental/detail/ranges/enumerate_range.cuh b/cpp/include/cuspatial/detail/range/enumerate_range.cuh similarity index 97% rename from cpp/include/cuspatial/experimental/detail/ranges/enumerate_range.cuh rename to cpp/include/cuspatial/detail/range/enumerate_range.cuh index 4143bc8a5..6dbaf0f55 100644 --- a/cpp/include/cuspatial/experimental/detail/ranges/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/experimental/detail/ranges/multilinestring_range.cuh b/cpp/include/cuspatial/detail/range/multilinestring_range.cuh similarity index 97% rename from cpp/include/cuspatial/experimental/detail/ranges/multilinestring_range.cuh rename to cpp/include/cuspatial/detail/range/multilinestring_range.cuh index 2d16ddc58..5983efc00 100644 --- a/cpp/include/cuspatial/experimental/detail/ranges/multilinestring_range.cuh +++ b/cpp/include/cuspatial/detail/range/multilinestring_range.cuh @@ -23,13 +23,13 @@ #include #include -#include +#include #include -#include -#include -#include +#include +#include +#include +#include #include -#include #include diff --git a/cpp/include/cuspatial/experimental/detail/ranges/multipoint_range.cuh b/cpp/include/cuspatial/detail/range/multipoint_range.cuh similarity index 97% rename from cpp/include/cuspatial/experimental/detail/ranges/multipoint_range.cuh rename to cpp/include/cuspatial/detail/range/multipoint_range.cuh index 5b1ab4ec8..7e9c18cb3 100644 --- a/cpp/include/cuspatial/experimental/detail/ranges/multipoint_range.cuh +++ b/cpp/include/cuspatial/detail/range/multipoint_range.cuh @@ -22,10 +22,10 @@ #include #include -#include -#include +#include +#include +#include #include -#include namespace cuspatial { diff --git a/cpp/include/cuspatial/experimental/detail/ranges/multipolygon_range.cuh b/cpp/include/cuspatial/detail/range/multipolygon_range.cuh similarity index 98% rename from cpp/include/cuspatial/experimental/detail/ranges/multipolygon_range.cuh rename to cpp/include/cuspatial/detail/range/multipolygon_range.cuh index ec6e466ce..9bbf45bd8 100644 --- a/cpp/include/cuspatial/experimental/detail/ranges/multipolygon_range.cuh +++ b/cpp/include/cuspatial/detail/range/multipolygon_range.cuh @@ -17,13 +17,13 @@ #pragma once #include -#include +#include #include -#include -#include -#include +#include +#include +#include +#include #include -#include #include #include diff --git a/cpp/include/cuspatial/experimental/detail/sinusoidal_projection.cuh b/cpp/include/cuspatial/detail/sinusoidal_projection.cuh similarity index 98% rename from cpp/include/cuspatial/experimental/detail/sinusoidal_projection.cuh rename to cpp/include/cuspatial/detail/sinusoidal_projection.cuh index 87d350c38..03fa2128c 100644 --- a/cpp/include/cuspatial/experimental/detail/sinusoidal_projection.cuh +++ b/cpp/include/cuspatial/detail/sinusoidal_projection.cuh @@ -17,8 +17,8 @@ #pragma once #include +#include #include -#include #include #include diff --git a/cpp/include/cuspatial/experimental/detail/trajectory_distances_and_speeds.cuh b/cpp/include/cuspatial/detail/trajectory_distances_and_speeds.cuh similarity index 100% rename from cpp/include/cuspatial/experimental/detail/trajectory_distances_and_speeds.cuh rename to cpp/include/cuspatial/detail/trajectory_distances_and_speeds.cuh diff --git a/cpp/include/cuspatial/detail/utility/linestring.cuh b/cpp/include/cuspatial/detail/utility/linestring.cuh index 1a0d427ba..c64dfdc1c 100644 --- a/cpp/include/cuspatial/detail/utility/linestring.cuh +++ b/cpp/include/cuspatial/detail/utility/linestring.cuh @@ -17,8 +17,8 @@ #pragma once #include -#include -#include +#include +#include #include #include diff --git a/cpp/include/cuspatial/experimental/hausdorff.cuh b/cpp/include/cuspatial/distance/hausdorff.cuh similarity index 98% rename from cpp/include/cuspatial/experimental/hausdorff.cuh rename to cpp/include/cuspatial/distance/hausdorff.cuh index 18724530b..6fe38a006 100644 --- a/cpp/include/cuspatial/experimental/hausdorff.cuh +++ b/cpp/include/cuspatial/distance/hausdorff.cuh @@ -102,4 +102,4 @@ OutputIt directed_hausdorff_distance(PointIt points_first, } // namespace cuspatial -#include +#include diff --git a/cpp/include/cuspatial/experimental/haversine.cuh b/cpp/include/cuspatial/distance/haversine.cuh similarity index 98% rename from cpp/include/cuspatial/experimental/haversine.cuh rename to cpp/include/cuspatial/distance/haversine.cuh index a9345505b..dc1436fde 100644 --- a/cpp/include/cuspatial/experimental/haversine.cuh +++ b/cpp/include/cuspatial/distance/haversine.cuh @@ -76,4 +76,4 @@ OutputIt haversine_distance(LonLatItA a_lonlat_first, } // namespace cuspatial -#include +#include diff --git a/cpp/include/cuspatial/experimental/linestring_distance.cuh b/cpp/include/cuspatial/distance/linestring_distance.cuh similarity index 96% rename from cpp/include/cuspatial/experimental/linestring_distance.cuh rename to cpp/include/cuspatial/distance/linestring_distance.cuh index 31c7eaa6b..c6f0de964 100644 --- a/cpp/include/cuspatial/experimental/linestring_distance.cuh +++ b/cpp/include/cuspatial/distance/linestring_distance.cuh @@ -47,4 +47,4 @@ OutputIt pairwise_linestring_distance(MultiLinestringRange1 multilinestrings1, rmm::cuda_stream_view stream = rmm::cuda_stream_default); } // namespace cuspatial -#include +#include diff --git a/cpp/include/cuspatial/experimental/linestring_polygon_distance.cuh b/cpp/include/cuspatial/distance/linestring_polygon_distance.cuh similarity index 96% rename from cpp/include/cuspatial/experimental/linestring_polygon_distance.cuh rename to cpp/include/cuspatial/distance/linestring_polygon_distance.cuh index 1674ad54c..a1adf9222 100644 --- a/cpp/include/cuspatial/experimental/linestring_polygon_distance.cuh +++ b/cpp/include/cuspatial/distance/linestring_polygon_distance.cuh @@ -45,4 +45,4 @@ OutputIt pairwise_linestring_polygon_distance( rmm::cuda_stream_view stream = rmm::cuda_stream_default); } // namespace cuspatial -#include +#include diff --git a/cpp/include/cuspatial/experimental/point_distance.cuh b/cpp/include/cuspatial/distance/point_distance.cuh similarity index 96% rename from cpp/include/cuspatial/experimental/point_distance.cuh rename to cpp/include/cuspatial/distance/point_distance.cuh index 2dfad8b07..7d7321b53 100644 --- a/cpp/include/cuspatial/experimental/point_distance.cuh +++ b/cpp/include/cuspatial/distance/point_distance.cuh @@ -38,4 +38,4 @@ OutputIt pairwise_point_distance(MultiPointArrayViewA multipoints1, rmm::cuda_stream_view stream = rmm::cuda_stream_default); } // namespace cuspatial -#include +#include diff --git a/cpp/include/cuspatial/experimental/point_linestring_distance.cuh b/cpp/include/cuspatial/distance/point_linestring_distance.cuh similarity index 96% rename from cpp/include/cuspatial/experimental/point_linestring_distance.cuh rename to cpp/include/cuspatial/distance/point_linestring_distance.cuh index c3fc8b2a1..e5d467265 100644 --- a/cpp/include/cuspatial/experimental/point_linestring_distance.cuh +++ b/cpp/include/cuspatial/distance/point_linestring_distance.cuh @@ -44,4 +44,4 @@ OutputIt pairwise_point_linestring_distance( } // namespace cuspatial -#include +#include diff --git a/cpp/include/cuspatial/experimental/point_polygon_distance.cuh b/cpp/include/cuspatial/distance/point_polygon_distance.cuh similarity index 96% rename from cpp/include/cuspatial/experimental/point_polygon_distance.cuh rename to cpp/include/cuspatial/distance/point_polygon_distance.cuh index b2538a0ae..eb4674069 100644 --- a/cpp/include/cuspatial/experimental/point_polygon_distance.cuh +++ b/cpp/include/cuspatial/distance/point_polygon_distance.cuh @@ -44,4 +44,4 @@ OutputIt pairwise_point_polygon_distance(MultiPointRange multipoints, rmm::cuda_stream_view stream = rmm::cuda_stream_default); } // namespace cuspatial -#include +#include diff --git a/cpp/include/cuspatial/experimental/bounding_box.cuh b/cpp/include/cuspatial/experimental/bounding_box.cuh deleted file mode 100644 index 176463bf8..000000000 --- a/cpp/include/cuspatial/experimental/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 "detail/bounding_box.cuh" diff --git a/cpp/include/cuspatial/experimental/detail/bounding_box.cuh b/cpp/include/cuspatial/experimental/detail/bounding_box.cuh deleted file mode 100644 index adfa56a96..000000000 --- a/cpp/include/cuspatial/experimental/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/experimental/detail/linestring_bounding_boxes.cuh b/cpp/include/cuspatial/experimental/detail/linestring_bounding_boxes.cuh deleted file mode 100644 index ea86f17ef..000000000 --- a/cpp/include/cuspatial/experimental/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/experimental/detail/pairwise_point_in_polygon.cuh b/cpp/include/cuspatial/experimental/detail/pairwise_point_in_polygon.cuh deleted file mode 100644 index 8d0ce9cc9..000000000 --- a/cpp/include/cuspatial/experimental/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/experimental/detail/point_in_polygon.cuh b/cpp/include/cuspatial/experimental/detail/point_in_polygon.cuh deleted file mode 100644 index 4a1d9fff4..000000000 --- a/cpp/include/cuspatial/experimental/detail/point_in_polygon.cuh +++ /dev/null @@ -1,151 +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 - -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 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; - - auto idx = blockIdx.x * blockDim.x + threadIdx.x; - - if (idx >= num_test_points) { return; } - - int32_t hit_mask = 0; - - Cart2d const test_point = test_points_first[idx]; - - // for each polygon - for (auto poly_idx = 0; poly_idx < num_polys; 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; - - 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); - - hit_mask |= point_is_within << poly_idx; - } - result[idx] = hit_mask; -} - -} // namespace detail - -template -OutputIt 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); - - if (num_test_points > 0) { - 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_polys <= std::numeric_limits::digits, - "Number of polygons cannot exceed 31"); - - auto [threads_per_block, num_blocks] = grid_1d(num_test_points); - - detail::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/experimental/detail/polygon_bounding_boxes.cuh b/cpp/include/cuspatial/experimental/detail/polygon_bounding_boxes.cuh deleted file mode 100644 index 618fb05cf..000000000 --- a/cpp/include/cuspatial/experimental/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/experimental/linestring_bounding_boxes.cuh b/cpp/include/cuspatial/experimental/linestring_bounding_boxes.cuh deleted file mode 100644 index 4401161aa..000000000 --- a/cpp/include/cuspatial/experimental/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/experimental/pairwise_point_in_polygon.cuh b/cpp/include/cuspatial/experimental/pairwise_point_in_polygon.cuh deleted file mode 100644 index 129c79324..000000000 --- a/cpp/include/cuspatial/experimental/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/experimental/polygon_bounding_boxes.cuh b/cpp/include/cuspatial/experimental/polygon_bounding_boxes.cuh deleted file mode 100644 index 7cd61a3d6..000000000 --- a/cpp/include/cuspatial/experimental/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/include/cuspatial/experimental/trajectory_distances_and_speeds.cuh b/cpp/include/cuspatial/experimental/trajectory_distances_and_speeds.cuh deleted file mode 100644 index faadcb077..000000000 --- a/cpp/include/cuspatial/experimental/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 "detail/trajectory_distances_and_speeds.cuh" diff --git a/cpp/include/cuspatial/experimental/geometry/box.hpp b/cpp/include/cuspatial/geometry/box.hpp similarity index 97% rename from cpp/include/cuspatial/experimental/geometry/box.hpp rename to cpp/include/cuspatial/geometry/box.hpp index 993e29683..1041c4de2 100644 --- a/cpp/include/cuspatial/experimental/geometry/box.hpp +++ b/cpp/include/cuspatial/geometry/box.hpp @@ -16,7 +16,7 @@ #pragma once -#include +#include namespace cuspatial { diff --git a/cpp/include/cuspatial/experimental/geometry/linestring_ref.cuh b/cpp/include/cuspatial/geometry/linestring_ref.cuh similarity index 94% rename from cpp/include/cuspatial/experimental/geometry/linestring_ref.cuh rename to cpp/include/cuspatial/geometry/linestring_ref.cuh index 4d0092420..9637e870a 100644 --- a/cpp/include/cuspatial/experimental/geometry/linestring_ref.cuh +++ b/cpp/include/cuspatial/geometry/linestring_ref.cuh @@ -16,7 +16,7 @@ #pragma once #include -#include +#include namespace cuspatial { @@ -61,4 +61,5 @@ class linestring_ref { }; } // namespace cuspatial -#include + +#include diff --git a/cpp/include/cuspatial/experimental/geometry/polygon_ref.cuh b/cpp/include/cuspatial/geometry/polygon_ref.cuh similarity index 97% rename from cpp/include/cuspatial/experimental/geometry/polygon_ref.cuh rename to cpp/include/cuspatial/geometry/polygon_ref.cuh index 5905eab2c..1d51f45a7 100644 --- a/cpp/include/cuspatial/experimental/geometry/polygon_ref.cuh +++ b/cpp/include/cuspatial/geometry/polygon_ref.cuh @@ -65,4 +65,5 @@ class polygon_ref { }; } // namespace cuspatial -#include + +#include diff --git a/cpp/include/cuspatial/experimental/geometry/segment.cuh b/cpp/include/cuspatial/geometry/segment.cuh similarity index 97% rename from cpp/include/cuspatial/experimental/geometry/segment.cuh rename to cpp/include/cuspatial/geometry/segment.cuh index 91c9ac5a4..9cfaf3b8e 100644 --- a/cpp/include/cuspatial/experimental/geometry/segment.cuh +++ b/cpp/include/cuspatial/geometry/segment.cuh @@ -17,7 +17,7 @@ #pragma once #include -#include +#include #include diff --git a/cpp/include/cuspatial/vec_2d.hpp b/cpp/include/cuspatial/geometry/vec_2d.hpp similarity index 100% rename from cpp/include/cuspatial/vec_2d.hpp rename to cpp/include/cuspatial/geometry/vec_2d.hpp diff --git a/cpp/include/cuspatial/experimental/geometry_collection/multilinestring_ref.cuh b/cpp/include/cuspatial/geometry_collection/multilinestring_ref.cuh similarity index 94% rename from cpp/include/cuspatial/experimental/geometry_collection/multilinestring_ref.cuh rename to cpp/include/cuspatial/geometry_collection/multilinestring_ref.cuh index f6acc917d..872135f72 100644 --- a/cpp/include/cuspatial/experimental/geometry_collection/multilinestring_ref.cuh +++ b/cpp/include/cuspatial/geometry_collection/multilinestring_ref.cuh @@ -16,7 +16,7 @@ #pragma once #include -#include +#include namespace cuspatial { @@ -69,4 +69,4 @@ class multilinestring_ref { } // namespace cuspatial -#include +#include diff --git a/cpp/include/cuspatial/experimental/geometry_collection/multipoint_ref.cuh b/cpp/include/cuspatial/geometry_collection/multipoint_ref.cuh similarity index 96% rename from cpp/include/cuspatial/experimental/geometry_collection/multipoint_ref.cuh rename to cpp/include/cuspatial/geometry_collection/multipoint_ref.cuh index 3d44a75ce..0ebe2f71b 100644 --- a/cpp/include/cuspatial/experimental/geometry_collection/multipoint_ref.cuh +++ b/cpp/include/cuspatial/geometry_collection/multipoint_ref.cuh @@ -56,4 +56,4 @@ class multipoint_ref { } // namespace cuspatial -#include +#include diff --git a/cpp/include/cuspatial/experimental/geometry_collection/multipolygon_ref.cuh b/cpp/include/cuspatial/geometry_collection/multipolygon_ref.cuh similarity index 95% rename from cpp/include/cuspatial/experimental/geometry_collection/multipolygon_ref.cuh rename to cpp/include/cuspatial/geometry_collection/multipolygon_ref.cuh index 9affb3fba..e4ff5010f 100644 --- a/cpp/include/cuspatial/experimental/geometry_collection/multipolygon_ref.cuh +++ b/cpp/include/cuspatial/geometry_collection/multipolygon_ref.cuh @@ -16,7 +16,7 @@ #pragma once #include -#include +#include namespace cuspatial { @@ -79,4 +79,4 @@ class multipolygon_ref { } // namespace cuspatial -#include +#include diff --git a/cpp/include/cuspatial/experimental/iterator_factory.cuh b/cpp/include/cuspatial/iterator_factory.cuh similarity index 97% rename from cpp/include/cuspatial/experimental/iterator_factory.cuh rename to cpp/include/cuspatial/iterator_factory.cuh index 67c35e3fc..1f026512c 100644 --- a/cpp/include/cuspatial/experimental/iterator_factory.cuh +++ b/cpp/include/cuspatial/iterator_factory.cuh @@ -16,14 +16,14 @@ #pragma once -#include #include -#include +#include +#include #include -#include #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/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/experimental/linestring_intersection.cuh b/cpp/include/cuspatial/linestring_intersection.cuh similarity index 95% rename from cpp/include/cuspatial/experimental/linestring_intersection.cuh rename to cpp/include/cuspatial/linestring_intersection.cuh index 76e21b2ac..cbc7c03dc 100644 --- a/cpp/include/cuspatial/experimental/linestring_intersection.cuh +++ b/cpp/include/cuspatial/linestring_intersection.cuh @@ -16,8 +16,8 @@ #pragma once -#include -#include +#include +#include #include #include @@ -92,4 +92,4 @@ linestring_intersection_result pairwise_linestring_intersection( } // namespace cuspatial -#include +#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/experimental/point_in_polygon.cuh b/cpp/include/cuspatial/point_in_polygon.cuh similarity index 54% rename from cpp/include/cuspatial/experimental/point_in_polygon.cuh rename to cpp/include/cuspatial/point_in_polygon.cuh index 1d9c86c19..a0038f458 100644 --- a/cpp/include/cuspatial/experimental/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 +#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/include/cuspatial/experimental/point_linestring_nearest_points.cuh b/cpp/include/cuspatial/point_linestring_nearest_points.cuh similarity index 98% rename from cpp/include/cuspatial/experimental/point_linestring_nearest_points.cuh rename to cpp/include/cuspatial/point_linestring_nearest_points.cuh index 5815c20da..2d655b0ef 100644 --- a/cpp/include/cuspatial/experimental/point_linestring_nearest_points.cuh +++ b/cpp/include/cuspatial/point_linestring_nearest_points.cuh @@ -100,4 +100,4 @@ OutputIt pairwise_point_linestring_nearest_points( rmm::cuda_stream_view stream = rmm::cuda_stream_default); } // namespace cuspatial -#include +#include diff --git a/cpp/include/cuspatial/experimental/point_quadtree.cuh b/cpp/include/cuspatial/point_quadtree.cuh similarity index 98% rename from cpp/include/cuspatial/experimental/point_quadtree.cuh rename to cpp/include/cuspatial/point_quadtree.cuh index cb130d93a..a84b07558 100644 --- a/cpp/include/cuspatial/experimental/point_quadtree.cuh +++ b/cpp/include/cuspatial/point_quadtree.cuh @@ -16,8 +16,8 @@ #pragma once +#include #include -#include #include #include @@ -184,4 +184,4 @@ std::pair, point_quadtree> quadtree_on_points( } // namespace cuspatial -#include +#include diff --git a/cpp/include/cuspatial/experimental/points_in_range.cuh b/cpp/include/cuspatial/points_in_range.cuh similarity index 98% rename from cpp/include/cuspatial/experimental/points_in_range.cuh rename to cpp/include/cuspatial/points_in_range.cuh index a7acbaf62..79205e417 100644 --- a/cpp/include/cuspatial/experimental/points_in_range.cuh +++ b/cpp/include/cuspatial/points_in_range.cuh @@ -16,7 +16,7 @@ #pragma once -#include +#include #include @@ -115,4 +115,4 @@ OutputIt copy_points_in_range(vec_2d vertex_1, } // namespace cuspatial -#include +#include diff --git a/cpp/include/cuspatial/experimental/ranges/multilinestring_range.cuh b/cpp/include/cuspatial/range/multilinestring_range.cuh similarity index 98% rename from cpp/include/cuspatial/experimental/ranges/multilinestring_range.cuh rename to cpp/include/cuspatial/range/multilinestring_range.cuh index 3637c327e..04c280e04 100644 --- a/cpp/include/cuspatial/experimental/ranges/multilinestring_range.cuh +++ b/cpp/include/cuspatial/range/multilinestring_range.cuh @@ -17,11 +17,11 @@ #pragma once #include -#include -#include +#include +#include +#include #include #include -#include #include @@ -347,4 +347,4 @@ auto make_multilinestring_range(GeometryColumnView const& linestrings_column) } // namespace cuspatial -#include +#include diff --git a/cpp/include/cuspatial/experimental/ranges/multipoint_range.cuh b/cpp/include/cuspatial/range/multipoint_range.cuh similarity index 99% rename from cpp/include/cuspatial/experimental/ranges/multipoint_range.cuh rename to cpp/include/cuspatial/range/multipoint_range.cuh index 82323e9ed..1277d62b0 100644 --- a/cpp/include/cuspatial/experimental/ranges/multipoint_range.cuh +++ b/cpp/include/cuspatial/range/multipoint_range.cuh @@ -267,4 +267,4 @@ auto make_multipoint_range(GeometryColumnView const& points_column) } // namespace cuspatial -#include +#include diff --git a/cpp/include/cuspatial/experimental/ranges/multipolygon_range.cuh b/cpp/include/cuspatial/range/multipolygon_range.cuh similarity index 98% rename from cpp/include/cuspatial/experimental/ranges/multipolygon_range.cuh rename to cpp/include/cuspatial/range/multipolygon_range.cuh index 96129145f..4c0590c4b 100644 --- a/cpp/include/cuspatial/experimental/ranges/multipolygon_range.cuh +++ b/cpp/include/cuspatial/range/multipolygon_range.cuh @@ -19,10 +19,10 @@ #include #include -#include +#include +#include #include #include -#include namespace cuspatial { @@ -269,4 +269,4 @@ auto make_multipolygon_range(GeometryColumnView const& polygons_column) } // namespace cuspatial -#include +#include diff --git a/cpp/include/cuspatial/experimental/ranges/range.cuh b/cpp/include/cuspatial/range/range.cuh similarity index 100% rename from cpp/include/cuspatial/experimental/ranges/range.cuh rename to cpp/include/cuspatial/range/range.cuh diff --git a/cpp/include/cuspatial/experimental/sinusoidal_projection.cuh b/cpp/include/cuspatial/sinusoidal_projection.cuh similarity index 96% rename from cpp/include/cuspatial/experimental/sinusoidal_projection.cuh rename to cpp/include/cuspatial/sinusoidal_projection.cuh index 8e1b7a2cd..885577287 100644 --- a/cpp/include/cuspatial/experimental/sinusoidal_projection.cuh +++ b/cpp/include/cuspatial/sinusoidal_projection.cuh @@ -16,7 +16,7 @@ #pragma once -#include +#include #include @@ -66,4 +66,4 @@ OutputIt sinusoidal_projection(InputIt lon_lat_first, } // namespace cuspatial -#include +#include diff --git a/cpp/include/cuspatial/experimental/spatial_join.cuh b/cpp/include/cuspatial/spatial_join.cuh similarity index 95% rename from cpp/include/cuspatial/experimental/spatial_join.cuh rename to cpp/include/cuspatial/spatial_join.cuh index a90d56b7c..a9d53ec78 100644 --- a/cpp/include/cuspatial/experimental/spatial_join.cuh +++ b/cpp/include/cuspatial/spatial_join.cuh @@ -16,10 +16,10 @@ #pragma once -#include -#include -#include -#include +#include +#include +#include +#include #include #include @@ -189,6 +189,6 @@ quadtree_point_to_nearest_linestring( } // namespace cuspatial -#include -#include -#include +#include +#include +#include diff --git a/cpp/include/cuspatial/traits.hpp b/cpp/include/cuspatial/traits.hpp index d16a1e269..618f79487 100644 --- a/cpp/include/cuspatial/traits.hpp +++ b/cpp/include/cuspatial/traits.hpp @@ -16,7 +16,7 @@ #pragma once -#include +#include #include diff --git a/cpp/include/cuspatial/experimental/derive_trajectories.cuh b/cpp/include/cuspatial/trajectory.cuh similarity index 62% rename from cpp/include/cuspatial/experimental/derive_trajectories.cuh rename to cpp/include/cuspatial/trajectory.cuh index c5dbf64f5..a08d1f837 100644 --- a/cpp/include/cuspatial/experimental/derive_trajectories.cuh +++ b/cpp/include/cuspatial/trajectory.cuh @@ -88,10 +88,53 @@ 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 */ } // namespace cuspatial -#include +#include +#include diff --git a/cpp/include/cuspatial_test/geometry_generator.cuh b/cpp/include/cuspatial_test/geometry_generator.cuh index 209b4c545..d9214d447 100644 --- a/cpp/include/cuspatial_test/geometry_generator.cuh +++ b/cpp/include/cuspatial_test/geometry_generator.cuh @@ -18,8 +18,8 @@ #include #include -#include -#include +#include +#include #include #include diff --git a/cpp/include/cuspatial_test/random.cuh b/cpp/include/cuspatial_test/random.cuh index bff8ddabf..8cd6b71e2 100644 --- a/cpp/include/cuspatial_test/random.cuh +++ b/cpp/include/cuspatial_test/random.cuh @@ -18,7 +18,7 @@ #include #include -#include +#include #include diff --git a/cpp/include/cuspatial_test/test_util.cuh b/cpp/include/cuspatial_test/test_util.cuh index e30089ba4..cb9e5cafe 100644 --- a/cpp/include/cuspatial_test/test_util.cuh +++ b/cpp/include/cuspatial_test/test_util.cuh @@ -16,8 +16,8 @@ #pragma once +#include #include -#include #include #include diff --git a/cpp/include/cuspatial_test/vector_equality.hpp b/cpp/include/cuspatial_test/vector_equality.hpp index 204a1589d..06ab03073 100644 --- a/cpp/include/cuspatial_test/vector_equality.hpp +++ b/cpp/include/cuspatial_test/vector_equality.hpp @@ -16,9 +16,9 @@ #pragma once -#include +#include +#include #include -#include #include diff --git a/cpp/include/cuspatial_test/vector_factories.cuh b/cpp/include/cuspatial_test/vector_factories.cuh index 0e5ae930a..99a0fea80 100644 --- a/cpp/include/cuspatial_test/vector_factories.cuh +++ b/cpp/include/cuspatial_test/vector_factories.cuh @@ -16,12 +16,12 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include -#include #include #include diff --git a/cpp/include/doxygen_groups.h b/cpp/include/doxygen_groups.h index a80fbe9ab..4e7ea055e 100644 --- a/cpp/include/doxygen_groups.h +++ b/cpp/include/doxygen_groups.h @@ -104,14 +104,13 @@ * @{ * @brief Factory method to create coordinate iterators * - * CuSpatial functions inside `experimental` folder are header-only and only accepts - * input/output iterators on coordinates. These factory functions are convenient ways - * to create iterators from data in various format. + * CuSpatial header-only API functions only accept input/output iterators. These factory + * make it easier to create iterators from data in various formats. * @file iterator_factory.hpp * @} * @defgroup ranges Ranges * @{ - * @brief Abstract Data Type that Represents any containers represented by a start and end + * @brief Abstract Data Type that represents any containers represented by a start and end * iterator * * cuSpatial header only APIs accept ranges that provide flattened views of diff --git a/cpp/src/indexing/construction/point_quadtree.cu b/cpp/src/indexing/construction/point_quadtree.cu index a276d0b32..ce9623522 100644 --- a/cpp/src/indexing/construction/point_quadtree.cu +++ b/cpp/src/indexing/construction/point_quadtree.cu @@ -15,10 +15,10 @@ */ #include -#include -#include +#include +#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 8c427fe63..b90bad402 100644 --- a/cpp/src/join/quadtree_bbox_filtering.cu +++ b/cpp/src/join/quadtree_bbox_filtering.cu @@ -14,11 +14,11 @@ * limitations under the License. */ -#include -#include +#include +#include -#include #include +#include #include #include diff --git a/cpp/src/join/quadtree_point_in_polygon.cu b/cpp/src/join/quadtree_point_in_polygon.cu index 87b99f28e..3a9be80bb 100644 --- a/cpp/src/join/quadtree_point_in_polygon.cu +++ b/cpp/src/join/quadtree_point_in_polygon.cu @@ -14,10 +14,10 @@ * limitations under the License. */ -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/cpp/src/join/quadtree_point_to_nearest_linestring.cu b/cpp/src/join/quadtree_point_to_nearest_linestring.cu index a1ea45cbc..1a8f93293 100644 --- a/cpp/src/join/quadtree_point_to_nearest_linestring.cu +++ b/cpp/src/join/quadtree_point_to_nearest_linestring.cu @@ -16,9 +16,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include #include diff --git a/cpp/src/spatial/hausdorff.cu b/cpp/src/spatial/hausdorff.cu index 02940db64..2db067541 100644 --- a/cpp/src/spatial/hausdorff.cu +++ b/cpp/src/spatial/hausdorff.cu @@ -14,9 +14,9 @@ * limitations under the License. */ +#include #include -#include -#include +#include #include #include diff --git a/cpp/src/spatial/haversine.cu b/cpp/src/spatial/haversine.cu index b3521f3ba..d55e373a8 100644 --- a/cpp/src/spatial/haversine.cu +++ b/cpp/src/spatial/haversine.cu @@ -15,9 +15,9 @@ */ #include +#include #include -#include -#include +#include #include #include diff --git a/cpp/src/spatial/linestring_bounding_box.cu b/cpp/src/spatial/linestring_bounding_boxes.cu similarity index 97% rename from cpp/src/spatial/linestring_bounding_box.cu rename to cpp/src/spatial/linestring_bounding_boxes.cu index 8a8f0504c..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 #include diff --git a/cpp/src/spatial/linestring_distance.cu b/cpp/src/spatial/linestring_distance.cu index b9bd07b27..64c11970e 100644 --- a/cpp/src/spatial/linestring_distance.cu +++ b/cpp/src/spatial/linestring_distance.cu @@ -17,11 +17,11 @@ #include "../utility/double_boolean_dispatch.hpp" #include "../utility/iterator.hpp" +#include #include -#include -#include -#include -#include +#include +#include +#include #include #include diff --git a/cpp/src/spatial/linestring_intersection.cu b/cpp/src/spatial/linestring_intersection.cu index b0e8b42d3..f256cb70f 100644 --- a/cpp/src/spatial/linestring_intersection.cu +++ b/cpp/src/spatial/linestring_intersection.cu @@ -18,14 +18,13 @@ #include "../utility/multi_geometry_dispatch.hpp" #include -#include #include -#include -#include -#include +#include +#include +#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 ada232ea1..7e99fabd5 100644 --- a/cpp/src/spatial/linestring_polygon_distance.cu +++ b/cpp/src/spatial/linestring_polygon_distance.cu @@ -31,10 +31,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include 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 8e7c45db3..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_distance.cu b/cpp/src/spatial/point_distance.cu index b50f3d131..a61ab3f8a 100644 --- a/cpp/src/spatial/point_distance.cu +++ b/cpp/src/spatial/point_distance.cu @@ -17,11 +17,11 @@ #include "../utility/double_boolean_dispatch.hpp" #include "../utility/iterator.hpp" +#include #include -#include -#include -#include -#include +#include +#include +#include #include #include diff --git a/cpp/src/spatial/point_in_polygon.cu b/cpp/src/spatial/point_in_polygon.cu index c5e63b957..255a507cf 100644 --- a/cpp/src/spatial/point_in_polygon.cu +++ b/cpp/src/spatial/point_in_polygon.cu @@ -15,9 +15,9 @@ */ #include -#include -#include -#include +#include +#include +#include #include #include @@ -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/src/spatial/point_linestring_distance.cu b/cpp/src/spatial/point_linestring_distance.cu index e1084fdd0..f3d59655f 100644 --- a/cpp/src/spatial/point_linestring_distance.cu +++ b/cpp/src/spatial/point_linestring_distance.cu @@ -25,12 +25,11 @@ #include -#include +#include #include -#include -#include -#include -#include +#include +#include +#include #include diff --git a/cpp/src/spatial/point_linestring_nearest_points.cu b/cpp/src/spatial/point_linestring_nearest_points.cu index 378598738..5843e9d5d 100644 --- a/cpp/src/spatial/point_linestring_nearest_points.cu +++ b/cpp/src/spatial/point_linestring_nearest_points.cu @@ -17,10 +17,10 @@ #include "../utility/double_boolean_dispatch.hpp" #include "../utility/iterator.hpp" -#include -#include +#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 798ee86ad..1e410f13c 100644 --- a/cpp/src/spatial/point_polygon_distance.cu +++ b/cpp/src/spatial/point_polygon_distance.cu @@ -29,12 +29,11 @@ #include #include -#include +#include #include -#include -#include -#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 98% rename from cpp/src/spatial/polygon_bounding_box.cu rename to cpp/src/spatial/polygon_bounding_boxes.cu index e02d7b932..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 #include diff --git a/cpp/src/spatial/sinusoidal_projection.cu b/cpp/src/spatial/sinusoidal_projection.cu index 72e134c95..522c8dea0 100644 --- a/cpp/src/spatial/sinusoidal_projection.cu +++ b/cpp/src/spatial/sinusoidal_projection.cu @@ -15,9 +15,9 @@ */ #include -#include -#include -#include +#include +#include +#include #include #include diff --git a/cpp/src/spatial_window/spatial_window.cu b/cpp/src/spatial_window/spatial_window.cu index 99980ab7e..8ed1358a3 100644 --- a/cpp/src/spatial_window/spatial_window.cu +++ b/cpp/src/spatial_window/spatial_window.cu @@ -15,8 +15,8 @@ */ #include -#include -#include +#include +#include #include #include diff --git a/cpp/src/trajectory/derive_trajectories.cu b/cpp/src/trajectory/derive_trajectories.cu index f6c31c4f2..cfeeea77b 100644 --- a/cpp/src/trajectory/derive_trajectories.cu +++ b/cpp/src/trajectory/derive_trajectories.cu @@ -15,8 +15,8 @@ */ #include -#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 92df0d38c..8d441b9c4 100644 --- a/cpp/src/trajectory/trajectory_bounding_boxes.cu +++ b/cpp/src/trajectory/trajectory_bounding_boxes.cu @@ -14,9 +14,9 @@ * limitations under the License. */ +#include #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 cd7c59db4..a27f8b7f8 100644 --- a/cpp/src/trajectory/trajectory_distances_and_speeds.cu +++ b/cpp/src/trajectory/trajectory_distances_and_speeds.cu @@ -15,8 +15,8 @@ */ #include -#include -#include +#include +#include #include #include diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index 654b364b0..8f2a26f34 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -48,14 +48,15 @@ endfunction(ConfigureTest) ### test sources ################################################################################## ################################################################################################### -ConfigureTest(SINUSOIDAL_PROJECTION_TEST - spatial/sinusoidal_projection_test.cu) +# Column-based API -ConfigureTest(HAVERSINE_TEST - spatial/haversine_test.cpp) +# index +ConfigureTest(POINT_QUADTREE_TEST + index/point_quadtree_test.cpp) -ConfigureTest(HAUSDORFF_TEST - spatial/hausdorff_test.cpp) +# join +ConfigureTest(JOIN_QUADTREE_AND_BOUNDING_BOXES_TEST + join/join_quadtree_and_bounding_boxes_test.cpp) ConfigureTest(JOIN_POINT_TO_NEAREST_LINESTRING_TEST join/quadtree_point_to_nearest_linestring_test.cpp) @@ -63,45 +64,59 @@ ConfigureTest(JOIN_POINT_TO_NEAREST_LINESTRING_TEST ConfigureTest(JOIN_POINT_IN_POLYGON_TEST join/quadtree_point_in_polygon_test.cpp) -ConfigureTest(POINT_IN_POLYGON_TEST - spatial/point_in_polygon_test.cpp) - -ConfigureTest(PAIRWISE_POINT_IN_POLYGON_TEST - spatial/pairwise_point_in_polygon_test.cpp) - -ConfigureTest(POINT_QUADTREE_TEST - indexing/point_quadtree_test.cpp) +# projection +ConfigureTest(SINUSOIDAL_PROJECTION_TEST + projection/sinusoidal_projection_test.cpp) +# bounding boxes ConfigureTest(LINESTRING_BOUNDING_BOXES_TEST - spatial/linestring_bounding_boxes_test.cpp) + spatial/bounding_boxes/linestring_bounding_boxes_test.cpp) ConfigureTest(POLYGON_BOUNDING_BOXES_TEST - spatial/polygon_bounding_boxes_test.cpp) + spatial/bounding_boxes/polygon_bounding_boxes_test.cpp) + +# distance +ConfigureTest(HAVERSINE_TEST + spatial/distance/haversine_test.cpp) + +ConfigureTest(HAUSDORFF_TEST + spatial/distance/hausdorff_test.cpp) ConfigureTest(POINT_DISTANCE_TEST - spatial/point_distance_test.cpp) + spatial/distance/point_distance_test.cpp) ConfigureTest(POINT_LINESTRING_DISTANCE_TEST - spatial/point_linestring_distance_test.cpp) + spatial/distance/point_linestring_distance_test.cpp) ConfigureTest(LINESTRING_DISTANCE_TEST - spatial/linestring_distance_test.cpp) - -ConfigureTest(POINT_POLYGON_DISTANCE_TEST - spatial/point_polygon_distance_test.cpp) + spatial/distance/linestring_distance_test.cpp) ConfigureTest(LINESTRING_POLYGON_DISTANCE_TEST spatial/linestring_polygon_distance_test.cpp) +ConfigureTest(POINT_POLYGON_DISTANCE_TEST + spatial/distance/point_polygon_distance_test.cpp) + +#intersection ConfigureTest(LINESTRING_INTERSECTION_TEST - spatial/linestring_intersection_test.cpp) + spatial/intersection/linestring_intersection_test.cpp) +# nearest points ConfigureTest(POINT_LINESTRING_NEAREST_POINT_TEST - spatial/point_linestring_nearest_points_test.cpp) + spatial/nearest_points/point_linestring_nearest_points_test.cpp) -ConfigureTest(JOIN_QUADTREE_AND_BOUNDING_BOXES_TEST - join/join_quadtree_and_bounding_boxes_test.cpp) +# point in polygon +ConfigureTest(POINT_IN_POLYGON_TEST + spatial/point_in_polygon/point_in_polygon_test.cpp) + +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) +# trajectory ConfigureTest(TRAJECTORY_DISTANCES_AND_SPEEDS_TEST trajectory/test_trajectory_distances_and_speeds.cu) @@ -111,9 +126,7 @@ ConfigureTest(DERIVE_TRAJECTORIES_TEST ConfigureTest(TRAJECTORY_BOUNDING_BOXES_TEST trajectory/test_trajectory_bounding_boxes.cu) -ConfigureTest(SPATIAL_WINDOW_POINT_TEST - spatial_window/spatial_window_test.cpp) - +# utility ConfigureTest(UTILITY_TEST utility_test/test_float_equivalent.cu utility_test/test_multipoint_factory.cu @@ -121,87 +134,101 @@ ConfigureTest(UTILITY_TEST ) # Header-only API -ConfigureTest(HAVERSINE_TEST_EXP - experimental/spatial/haversine_test.cu) - -ConfigureTest(POINT_DISTANCE_TEST_EXP - experimental/spatial/point_distance_test.cu) -ConfigureTest(POINT_LINESTRING_DISTANCE_TEST_EXP - experimental/spatial/point_linestring_distance_test.cu) +# find / intersection util +ConfigureTest(FIND_TEST_EXP + find/find_and_combine_segments_test.cu + find/find_points_on_segments_test.cu + find/find_duplicate_points_test.cu) -ConfigureTest(POINT_POLYGON_DISTANCE_TEST_EXP - experimental/spatial/point_polygon_distance_test.cu) +# index +ConfigureTest(POINT_QUADTREE_TEST_EXP + index/point_quadtree_test.cu) -ConfigureTest(LINESTRING_POLYGON_DISTANCE_TEST_EXP - experimental/spatial/linestring_polygon_distance_test.cu) +# join +ConfigureTest(JOIN_QUADTREE_AND_BOUNDING_BOXES_TEST_EXP + join/join_quadtree_and_bounding_boxes_test.cu) -ConfigureTest(HAUSDORFF_TEST_EXP - experimental/spatial/hausdorff_test.cu) +ConfigureTest(JOIN_POINT_IN_POLYGON_SMALL_TEST_EXP + join/quadtree_point_in_polygon_test_small.cu) -ConfigureTest(LINESTRING_DISTANCE_TEST_EXP - experimental/spatial/linestring_distance_test.cu - experimental/spatial/linestring_distance_test_medium.cu) +ConfigureTest(JOIN_POINT_IN_POLYGON_LARGE_TEST_EXP + join/quadtree_point_in_polygon_test_large.cu) -ConfigureTest(LINESTRING_INTERSECTION_TEST_EXP - experimental/spatial/linestring_intersection_count_test.cu - experimental/spatial/linestring_intersection_intermediates_remove_if_test.cu - experimental/spatial/linestring_intersection_with_duplicates_test.cu - experimental/spatial/linestring_intersection_test.cu) +ConfigureTest(JOIN_POINT_TO_LINESTRING_SMALL_TEST_EXP + join/quadtree_point_to_nearest_linestring_test_small.cu) -ConfigureTest(POINT_LINESTRING_NEAREST_POINT_TEST_EXP - experimental/spatial/point_linestring_nearest_points_test.cu) +# operators +ConfigureTest(OPERATOR_TEST_EXP + operators/linestrings_test.cu) +# projection ConfigureTest(SINUSOIDAL_PROJECTION_TEST_EXP - experimental/spatial/sinusoidal_projection_test.cu) - -ConfigureTest(POINTS_IN_RANGE_TEST_EXP - experimental/spatial/points_in_range_test.cu) - -ConfigureTest(POINT_IN_POLYGON_TEST_EXP - experimental/spatial/point_in_polygon_test.cu) - -ConfigureTest(PAIRWISE_POINT_IN_POLYGON_TEST_EXP - experimental/spatial/pairwise_point_in_polygon_test.cu) + projection/sinusoidal_projection_test.cu) -ConfigureTest(DERIVE_TRAJECTORIES_TEST_EXP - experimental/trajectory/derive_trajectories_test.cu) +# range +ConfigureTest(RANGE_TEST_EXP + range/multilinestring_range_test.cu + range/multipolygon_range_test.cu) +# bounding boxes ConfigureTest(POINT_BOUNDING_BOXES_TEST_EXP - experimental/spatial/point_bounding_boxes_test.cu) + spatial/bounding_boxes/point_bounding_boxes_test.cu) ConfigureTest(POLYGON_BOUNDING_BOXES_TEST_EXP - experimental/spatial/polygon_bounding_boxes_test.cu) + spatial/bounding_boxes/polygon_bounding_boxes_test.cu) ConfigureTest(LINESTRING_BOUNDING_BOXES_TEST_EXP - experimental/spatial/linestring_bounding_boxes_test.cu) + spatial/bounding_boxes/linestring_bounding_boxes_test.cu) -ConfigureTest(TRAJECTORY_DISTANCES_AND_SPEEDS_TEST_EXP - experimental/trajectory/trajectory_distances_and_speeds_test.cu) +# distance +ConfigureTest(HAUSDORFF_TEST_EXP + spatial/distance/hausdorff_test.cu) -ConfigureTest(POINT_QUADTREE_TEST_EXP - experimental/indexing/point_quadtree_test.cu) +ConfigureTest(HAVERSINE_TEST_EXP + spatial/distance/haversine_test.cu) -ConfigureTest(OPERATOR_TEST_EXP - experimental/operators/linestrings_test.cu) +ConfigureTest(POINT_DISTANCE_TEST_EXP + spatial/distance/point_distance_test.cu) -ConfigureTest(FIND_TEST_EXP - experimental/find/find_and_combine_segments_test.cu - experimental/find/find_points_on_segments_test.cu - experimental/find/find_duplicate_points_test.cu) +ConfigureTest(POINT_LINESTRING_DISTANCE_TEST_EXP + spatial/distance/point_linestring_distance_test.cu) -ConfigureTest(JOIN_QUADTREE_AND_BOUNDING_BOXES_TEST_EXP - experimental/join/join_quadtree_and_bounding_boxes_test.cu) +ConfigureTest(POINT_POLYGON_DISTANCE_TEST_EXP + spatial/distance/point_polygon_distance_test.cu) -ConfigureTest(JOIN_POINT_IN_POLYGON_SMALL_TEST_EXP - experimental/join/quadtree_point_in_polygon_test_small.cu) +ConfigureTest(LINESTRING_POLYGON_DISTANCE_TEST_EXP + spatial/distance/linestring_polygon_distance_test.cu) -ConfigureTest(JOIN_POINT_IN_POLYGON_LARGE_TEST_EXP - experimental/join/quadtree_point_in_polygon_test_large.cu) +ConfigureTest(LINESTRING_DISTANCE_TEST_EXP + spatial/distance/linestring_distance_test.cu + spatial/distance/linestring_distance_test_medium.cu) -ConfigureTest(JOIN_POINT_TO_LINESTRING_SMALL_TEST_EXP - experimental/join/quadtree_point_to_nearest_linestring_test_small.cu) +# intersection +ConfigureTest(LINESTRING_INTERSECTION_TEST_EXP + spatial/intersection/linestring_intersection_count_test.cu + spatial/intersection/linestring_intersection_intermediates_remove_if_test.cu + spatial/intersection/linestring_intersection_with_duplicates_test.cu + spatial/intersection/linestring_intersection_test.cu) -ConfigureTest(RANGE_TEST_EXP - experimental/range/multilinestring_range_test.cu - experimental/range/multipolygon_range_test.cu) +# nearest points +ConfigureTest(POINT_LINESTRING_NEAREST_POINT_TEST_EXP + spatial/nearest_points/point_linestring_nearest_points_test.cu) + +# point in polygon +ConfigureTest(POINT_IN_POLYGON_TEST_EXP + spatial/point_in_polygon/point_in_polygon_test.cu) + +ConfigureTest(PAIRWISE_POINT_IN_POLYGON_TEST_EXP + spatial/point_in_polygon/pairwise_point_in_polygon_test.cu) + +# points in range +ConfigureTest(POINTS_IN_RANGE_TEST_EXP + spatial/points_in_range/points_in_range_test.cu) + +# trajectory +ConfigureTest(DERIVE_TRAJECTORIES_TEST_EXP + trajectory/derive_trajectories_test.cu) + +ConfigureTest(TRAJECTORY_DISTANCES_AND_SPEEDS_TEST_EXP + trajectory/trajectory_distances_and_speeds_test.cu) diff --git a/cpp/tests/experimental/find/find_and_combine_segments_test.cu b/cpp/tests/find/find_and_combine_segments_test.cu similarity index 97% rename from cpp/tests/experimental/find/find_and_combine_segments_test.cu rename to cpp/tests/find/find_and_combine_segments_test.cu index fa63bf77c..ea01d7e53 100644 --- a/cpp/tests/experimental/find/find_and_combine_segments_test.cu +++ b/cpp/tests/find/find_and_combine_segments_test.cu @@ -18,10 +18,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/cpp/tests/experimental/find/find_duplicate_points_test.cu b/cpp/tests/find/find_duplicate_points_test.cu similarity index 96% rename from cpp/tests/experimental/find/find_duplicate_points_test.cu rename to cpp/tests/find/find_duplicate_points_test.cu index 980e8282a..f4185227c 100644 --- a/cpp/tests/experimental/find/find_duplicate_points_test.cu +++ b/cpp/tests/find/find_duplicate_points_test.cu @@ -21,8 +21,8 @@ #include #include -#include -#include +#include +#include using namespace cuspatial; using namespace cuspatial::detail; diff --git a/cpp/tests/experimental/find/find_points_on_segments_test.cu b/cpp/tests/find/find_points_on_segments_test.cu similarity index 98% rename from cpp/tests/experimental/find/find_points_on_segments_test.cu rename to cpp/tests/find/find_points_on_segments_test.cu index 7248d7650..8981986bc 100644 --- a/cpp/tests/experimental/find/find_points_on_segments_test.cu +++ b/cpp/tests/find/find_points_on_segments_test.cu @@ -21,9 +21,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include diff --git a/cpp/tests/indexing/point_quadtree_test.cpp b/cpp/tests/index/point_quadtree_test.cpp similarity index 100% rename from cpp/tests/indexing/point_quadtree_test.cpp rename to cpp/tests/index/point_quadtree_test.cpp diff --git a/cpp/tests/experimental/indexing/point_quadtree_test.cu b/cpp/tests/index/point_quadtree_test.cu similarity index 99% rename from cpp/tests/experimental/indexing/point_quadtree_test.cu rename to cpp/tests/index/point_quadtree_test.cu index 10278ea4a..dd22df218 100644 --- a/cpp/tests/experimental/indexing/point_quadtree_test.cu +++ b/cpp/tests/index/point_quadtree_test.cu @@ -17,8 +17,8 @@ #include #include -#include -#include +#include +#include template struct QuadtreeOnPointIndexingTest : public ::testing::Test { 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/experimental/join/join_quadtree_and_bounding_boxes_test.cu b/cpp/tests/join/join_quadtree_and_bounding_boxes_test.cu similarity index 96% rename from cpp/tests/experimental/join/join_quadtree_and_bounding_boxes_test.cu rename to cpp/tests/join/join_quadtree_and_bounding_boxes_test.cu index ddb8f7df5..c68492769 100644 --- a/cpp/tests/experimental/join/join_quadtree_and_bounding_boxes_test.cu +++ b/cpp/tests/join/join_quadtree_and_bounding_boxes_test.cu @@ -19,8 +19,8 @@ #include #include -#include -#include +#include +#include // Note: the detailed correctness test of the join_quadtree_and_bounding_boxes() function is covered // by the quadtree_point_in_polygon_test_small.cu test file. diff --git a/cpp/tests/join/quadtree_point_in_polygon_test.cpp b/cpp/tests/join/quadtree_point_in_polygon_test.cpp index 93b32ffa7..c3d720c10 100644 --- a/cpp/tests/join/quadtree_point_in_polygon_test.cpp +++ b/cpp/tests/join/quadtree_point_in_polygon_test.cpp @@ -15,11 +15,11 @@ */ #include +#include #include +#include #include -#include #include -#include #include #include diff --git a/cpp/tests/experimental/join/quadtree_point_in_polygon_test_large.cu b/cpp/tests/join/quadtree_point_in_polygon_test_large.cu similarity index 97% rename from cpp/tests/experimental/join/quadtree_point_in_polygon_test_large.cu rename to cpp/tests/join/quadtree_point_in_polygon_test_large.cu index a982632c8..14a956016 100644 --- a/cpp/tests/experimental/join/quadtree_point_in_polygon_test_large.cu +++ b/cpp/tests/join/quadtree_point_in_polygon_test_large.cu @@ -20,11 +20,11 @@ #include #include +#include #include -#include -#include -#include -#include +#include +#include +#include #include #include diff --git a/cpp/tests/experimental/join/quadtree_point_in_polygon_test_small.cu b/cpp/tests/join/quadtree_point_in_polygon_test_small.cu similarity index 97% rename from cpp/tests/experimental/join/quadtree_point_in_polygon_test_small.cu rename to cpp/tests/join/quadtree_point_in_polygon_test_small.cu index f4e164877..52792dd9b 100644 --- a/cpp/tests/experimental/join/quadtree_point_in_polygon_test_small.cu +++ b/cpp/tests/join/quadtree_point_in_polygon_test_small.cu @@ -18,11 +18,11 @@ #include #include +#include #include -#include -#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 fbb3b0c19..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,11 +15,11 @@ */ #include +#include #include -#include +#include #include #include -#include #include #include diff --git a/cpp/tests/experimental/join/quadtree_point_to_nearest_linestring_test_small.cu b/cpp/tests/join/quadtree_point_to_nearest_linestring_test_small.cu similarity index 98% rename from cpp/tests/experimental/join/quadtree_point_to_nearest_linestring_test_small.cu rename to cpp/tests/join/quadtree_point_to_nearest_linestring_test_small.cu index e4ca29b6b..4f4f85837 100644 --- a/cpp/tests/experimental/join/quadtree_point_to_nearest_linestring_test_small.cu +++ b/cpp/tests/join/quadtree_point_to_nearest_linestring_test_small.cu @@ -18,11 +18,11 @@ #include #include +#include #include -#include -#include -#include -#include +#include +#include +#include #include diff --git a/cpp/tests/experimental/operators/linestrings_test.cu b/cpp/tests/operators/linestrings_test.cu similarity index 99% rename from cpp/tests/experimental/operators/linestrings_test.cu rename to cpp/tests/operators/linestrings_test.cu index bdfc508ea..356a115ed 100644 --- a/cpp/tests/experimental/operators/linestrings_test.cu +++ b/cpp/tests/operators/linestrings_test.cu @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include diff --git a/cpp/tests/spatial/sinusoidal_projection_test.cu b/cpp/tests/projection/sinusoidal_projection_test.cpp similarity index 100% rename from cpp/tests/spatial/sinusoidal_projection_test.cu rename to cpp/tests/projection/sinusoidal_projection_test.cpp diff --git a/cpp/tests/experimental/spatial/sinusoidal_projection_test.cu b/cpp/tests/projection/sinusoidal_projection_test.cu similarity index 99% rename from cpp/tests/experimental/spatial/sinusoidal_projection_test.cu rename to cpp/tests/projection/sinusoidal_projection_test.cu index 003d77a80..1b0db23c7 100644 --- a/cpp/tests/experimental/spatial/sinusoidal_projection_test.cu +++ b/cpp/tests/projection/sinusoidal_projection_test.cu @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include diff --git a/cpp/tests/experimental/range/multilinestring_range_test.cu b/cpp/tests/range/multilinestring_range_test.cu similarity index 99% rename from cpp/tests/experimental/range/multilinestring_range_test.cu rename to cpp/tests/range/multilinestring_range_test.cu index 9fcb0097e..0d00d5c5f 100644 --- a/cpp/tests/experimental/range/multilinestring_range_test.cu +++ b/cpp/tests/range/multilinestring_range_test.cu @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include diff --git a/cpp/tests/experimental/range/multipolygon_range_test.cu b/cpp/tests/range/multipolygon_range_test.cu similarity index 99% rename from cpp/tests/experimental/range/multipolygon_range_test.cu rename to cpp/tests/range/multipolygon_range_test.cu index b6b5bc340..1caa92b2e 100644 --- a/cpp/tests/experimental/range/multipolygon_range_test.cu +++ b/cpp/tests/range/multipolygon_range_test.cu @@ -18,8 +18,8 @@ #include #include -#include -#include +#include +#include #include #include diff --git a/cpp/tests/spatial/linestring_bounding_boxes_test.cpp b/cpp/tests/spatial/bounding_boxes/linestring_bounding_boxes_test.cpp similarity index 98% rename from cpp/tests/spatial/linestring_bounding_boxes_test.cpp rename to cpp/tests/spatial/bounding_boxes/linestring_bounding_boxes_test.cpp index fb409a22b..d742b0cc7 100644 --- a/cpp/tests/spatial/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/experimental/spatial/linestring_bounding_boxes_test.cu b/cpp/tests/spatial/bounding_boxes/linestring_bounding_boxes_test.cu similarity index 97% rename from cpp/tests/experimental/spatial/linestring_bounding_boxes_test.cu rename to cpp/tests/spatial/bounding_boxes/linestring_bounding_boxes_test.cu index 25bcb4f6e..53f3427b8 100644 --- a/cpp/tests/experimental/spatial/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 +#include #include diff --git a/cpp/tests/experimental/spatial/point_bounding_boxes_test.cu b/cpp/tests/spatial/bounding_boxes/point_bounding_boxes_test.cu similarity index 91% rename from cpp/tests/experimental/spatial/point_bounding_boxes_test.cu rename to cpp/tests/spatial/bounding_boxes/point_bounding_boxes_test.cu index c9d726e3f..e96c2b783 100644 --- a/cpp/tests/experimental/spatial/point_bounding_boxes_test.cu +++ b/cpp/tests/spatial/bounding_boxes/point_bounding_boxes_test.cu @@ -14,14 +14,14 @@ * limitations under the License. */ -#include "../trajectory/trajectory_test_utils.cuh" +#include "../../trajectory/trajectory_test_utils.cuh" #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/cpp/tests/spatial/polygon_bounding_boxes_test.cpp b/cpp/tests/spatial/bounding_boxes/polygon_bounding_boxes_test.cpp similarity index 99% rename from cpp/tests/spatial/polygon_bounding_boxes_test.cpp rename to cpp/tests/spatial/bounding_boxes/polygon_bounding_boxes_test.cpp index b161f9989..f933a2459 100644 --- a/cpp/tests/spatial/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/experimental/spatial/polygon_bounding_boxes_test.cu b/cpp/tests/spatial/bounding_boxes/polygon_bounding_boxes_test.cu similarity index 98% rename from cpp/tests/experimental/spatial/polygon_bounding_boxes_test.cu rename to cpp/tests/spatial/bounding_boxes/polygon_bounding_boxes_test.cu index fff8ef28a..de81d06e2 100644 --- a/cpp/tests/experimental/spatial/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 +#include #include diff --git a/cpp/tests/spatial/hausdorff_test.cpp b/cpp/tests/spatial/distance/hausdorff_test.cpp similarity index 100% rename from cpp/tests/spatial/hausdorff_test.cpp rename to cpp/tests/spatial/distance/hausdorff_test.cpp diff --git a/cpp/tests/experimental/spatial/hausdorff_test.cu b/cpp/tests/spatial/distance/hausdorff_test.cu similarity index 98% rename from cpp/tests/experimental/spatial/hausdorff_test.cu rename to cpp/tests/spatial/distance/hausdorff_test.cu index cb93c9e1e..17c47966a 100644 --- a/cpp/tests/experimental/spatial/hausdorff_test.cu +++ b/cpp/tests/spatial/distance/hausdorff_test.cu @@ -16,9 +16,9 @@ #include +#include #include -#include -#include +#include #include diff --git a/cpp/tests/spatial/haversine_test.cpp b/cpp/tests/spatial/distance/haversine_test.cpp similarity index 100% rename from cpp/tests/spatial/haversine_test.cpp rename to cpp/tests/spatial/distance/haversine_test.cpp diff --git a/cpp/tests/experimental/spatial/haversine_test.cu b/cpp/tests/spatial/distance/haversine_test.cu similarity index 99% rename from cpp/tests/experimental/spatial/haversine_test.cu rename to cpp/tests/spatial/distance/haversine_test.cu index f733e6445..f5fb77c15 100644 --- a/cpp/tests/experimental/spatial/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/linestring_distance_test.cpp b/cpp/tests/spatial/distance/linestring_distance_test.cpp similarity index 100% rename from cpp/tests/spatial/linestring_distance_test.cpp rename to cpp/tests/spatial/distance/linestring_distance_test.cpp diff --git a/cpp/tests/experimental/spatial/linestring_distance_test.cu b/cpp/tests/spatial/distance/linestring_distance_test.cu similarity index 99% rename from cpp/tests/experimental/spatial/linestring_distance_test.cu rename to cpp/tests/spatial/distance/linestring_distance_test.cu index 79727bee9..43051be9f 100644 --- a/cpp/tests/experimental/spatial/linestring_distance_test.cu +++ b/cpp/tests/spatial/distance/linestring_distance_test.cu @@ -17,11 +17,11 @@ #include #include +#include #include -#include -#include -#include -#include +#include +#include +#include #include #include diff --git a/cpp/tests/experimental/spatial/linestring_distance_test_medium.cu b/cpp/tests/spatial/distance/linestring_distance_test_medium.cu similarity index 99% rename from cpp/tests/experimental/spatial/linestring_distance_test_medium.cu rename to cpp/tests/spatial/distance/linestring_distance_test_medium.cu index 36bcb444d..e630aaeb4 100644 --- a/cpp/tests/experimental/spatial/linestring_distance_test_medium.cu +++ b/cpp/tests/spatial/distance/linestring_distance_test_medium.cu @@ -17,11 +17,11 @@ #include #include +#include #include -#include -#include -#include -#include +#include +#include +#include #include diff --git a/cpp/tests/experimental/spatial/linestring_polygon_distance_test.cu b/cpp/tests/spatial/distance/linestring_polygon_distance_test.cu similarity index 98% rename from cpp/tests/experimental/spatial/linestring_polygon_distance_test.cu rename to cpp/tests/spatial/distance/linestring_polygon_distance_test.cu index cdc9f7651..06b43a292 100644 --- a/cpp/tests/experimental/spatial/linestring_polygon_distance_test.cu +++ b/cpp/tests/spatial/distance/linestring_polygon_distance_test.cu @@ -18,10 +18,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/cpp/tests/spatial/point_distance_test.cpp b/cpp/tests/spatial/distance/point_distance_test.cpp similarity index 99% rename from cpp/tests/spatial/point_distance_test.cpp rename to cpp/tests/spatial/distance/point_distance_test.cpp index 841d142ef..d45e6459b 100644 --- a/cpp/tests/spatial/point_distance_test.cpp +++ b/cpp/tests/spatial/distance/point_distance_test.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include diff --git a/cpp/tests/experimental/spatial/point_distance_test.cu b/cpp/tests/spatial/distance/point_distance_test.cu similarity index 98% rename from cpp/tests/experimental/spatial/point_distance_test.cu rename to cpp/tests/spatial/distance/point_distance_test.cu index 517a4e605..7cdd43a7e 100644 --- a/cpp/tests/experimental/spatial/point_distance_test.cu +++ b/cpp/tests/spatial/distance/point_distance_test.cu @@ -18,12 +18,11 @@ #include -#include +#include #include -#include -#include -#include -#include +#include +#include +#include #include #include diff --git a/cpp/tests/spatial/point_linestring_distance_test.cpp b/cpp/tests/spatial/distance/point_linestring_distance_test.cpp similarity index 99% rename from cpp/tests/spatial/point_linestring_distance_test.cpp rename to cpp/tests/spatial/distance/point_linestring_distance_test.cpp index 870ab806d..9f922cdcb 100644 --- a/cpp/tests/spatial/point_linestring_distance_test.cpp +++ b/cpp/tests/spatial/distance/point_linestring_distance_test.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include diff --git a/cpp/tests/experimental/spatial/point_linestring_distance_test.cu b/cpp/tests/spatial/distance/point_linestring_distance_test.cu similarity index 98% rename from cpp/tests/experimental/spatial/point_linestring_distance_test.cu rename to cpp/tests/spatial/distance/point_linestring_distance_test.cu index 16fc520e2..b3b7086f2 100644 --- a/cpp/tests/experimental/spatial/point_linestring_distance_test.cu +++ b/cpp/tests/spatial/distance/point_linestring_distance_test.cu @@ -16,13 +16,12 @@ #include -#include +#include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include #include diff --git a/cpp/tests/spatial/point_polygon_distance_test.cpp b/cpp/tests/spatial/distance/point_polygon_distance_test.cpp similarity index 99% rename from cpp/tests/spatial/point_polygon_distance_test.cpp rename to cpp/tests/spatial/distance/point_polygon_distance_test.cpp index e881d2490..43d9b2c66 100644 --- a/cpp/tests/spatial/point_polygon_distance_test.cpp +++ b/cpp/tests/spatial/distance/point_polygon_distance_test.cpp @@ -17,8 +17,8 @@ #include #include #include +#include #include -#include #include #include diff --git a/cpp/tests/experimental/spatial/point_polygon_distance_test.cu b/cpp/tests/spatial/distance/point_polygon_distance_test.cu similarity index 98% rename from cpp/tests/experimental/spatial/point_polygon_distance_test.cu rename to cpp/tests/spatial/distance/point_polygon_distance_test.cu index 7e580e46f..2dae7fd0b 100644 --- a/cpp/tests/experimental/spatial/point_polygon_distance_test.cu +++ b/cpp/tests/spatial/distance/point_polygon_distance_test.cu @@ -17,10 +17,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/cpp/tests/experimental/spatial/intersection_test_utils.cuh b/cpp/tests/spatial/intersection/intersection_test_utils.cuh similarity index 97% rename from cpp/tests/experimental/spatial/intersection_test_utils.cuh rename to cpp/tests/spatial/intersection/intersection_test_utils.cuh index 432b735e5..34a93de64 100644 --- a/cpp/tests/experimental/spatial/intersection_test_utils.cuh +++ b/cpp/tests/spatial/intersection/intersection_test_utils.cuh @@ -17,7 +17,7 @@ #pragma once #include -#include +#include #include diff --git a/cpp/tests/experimental/spatial/linestring_intersection_count_test.cu b/cpp/tests/spatial/intersection/linestring_intersection_count_test.cu similarity index 99% rename from cpp/tests/experimental/spatial/linestring_intersection_count_test.cu rename to cpp/tests/spatial/intersection/linestring_intersection_count_test.cu index d9bd89a51..549bdf468 100644 --- a/cpp/tests/experimental/spatial/linestring_intersection_count_test.cu +++ b/cpp/tests/spatial/intersection/linestring_intersection_count_test.cu @@ -17,11 +17,11 @@ #include #include +#include #include -#include -#include +#include +#include #include -#include #include #include diff --git a/cpp/tests/experimental/spatial/linestring_intersection_intermediates_remove_if_test.cu b/cpp/tests/spatial/intersection/linestring_intersection_intermediates_remove_if_test.cu similarity index 98% rename from cpp/tests/experimental/spatial/linestring_intersection_intermediates_remove_if_test.cu rename to cpp/tests/spatial/intersection/linestring_intersection_intermediates_remove_if_test.cu index 227040cfa..f9f8504b1 100644 --- a/cpp/tests/experimental/spatial/linestring_intersection_intermediates_remove_if_test.cu +++ b/cpp/tests/spatial/intersection/linestring_intersection_intermediates_remove_if_test.cu @@ -17,12 +17,12 @@ #include #include +#include #include -#include -#include -#include +#include +#include +#include #include -#include #include #include diff --git a/cpp/tests/spatial/linestring_intersection_test.cpp b/cpp/tests/spatial/intersection/linestring_intersection_test.cpp similarity index 99% rename from cpp/tests/spatial/linestring_intersection_test.cpp rename to cpp/tests/spatial/intersection/linestring_intersection_test.cpp index 9110c7197..65a9b5d13 100644 --- a/cpp/tests/spatial/linestring_intersection_test.cpp +++ b/cpp/tests/spatial/intersection/linestring_intersection_test.cpp @@ -23,9 +23,9 @@ #include #include +#include #include #include -#include #include #include diff --git a/cpp/tests/experimental/spatial/linestring_intersection_test.cu b/cpp/tests/spatial/intersection/linestring_intersection_test.cu similarity index 99% rename from cpp/tests/experimental/spatial/linestring_intersection_test.cu rename to cpp/tests/spatial/intersection/linestring_intersection_test.cu index 3d4589016..7fb4f6d97 100644 --- a/cpp/tests/experimental/spatial/linestring_intersection_test.cu +++ b/cpp/tests/spatial/intersection/linestring_intersection_test.cu @@ -19,12 +19,11 @@ #include #include -#include #include -#include -#include +#include +#include +#include #include -#include #include #include diff --git a/cpp/tests/experimental/spatial/linestring_intersection_with_duplicates_test.cu b/cpp/tests/spatial/intersection/linestring_intersection_with_duplicates_test.cu similarity index 99% rename from cpp/tests/experimental/spatial/linestring_intersection_with_duplicates_test.cu rename to cpp/tests/spatial/intersection/linestring_intersection_with_duplicates_test.cu index f2fa6f1e5..f01f6b5e1 100644 --- a/cpp/tests/experimental/spatial/linestring_intersection_with_duplicates_test.cu +++ b/cpp/tests/spatial/intersection/linestring_intersection_with_duplicates_test.cu @@ -19,11 +19,11 @@ #include #include +#include #include -#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 89b6c0fe4..8bffe1d94 100644 --- a/cpp/tests/spatial/linestring_polygon_distance_test.cpp +++ b/cpp/tests/spatial/linestring_polygon_distance_test.cpp @@ -20,8 +20,8 @@ #include #include #include +#include #include -#include #include #include diff --git a/cpp/tests/spatial/point_linestring_nearest_points_test.cpp b/cpp/tests/spatial/nearest_points/point_linestring_nearest_points_test.cpp similarity index 99% rename from cpp/tests/spatial/point_linestring_nearest_points_test.cpp rename to cpp/tests/spatial/nearest_points/point_linestring_nearest_points_test.cpp index 3be28e671..6743db576 100644 --- a/cpp/tests/spatial/point_linestring_nearest_points_test.cpp +++ b/cpp/tests/spatial/nearest_points/point_linestring_nearest_points_test.cpp @@ -15,8 +15,8 @@ */ #include +#include #include -#include #include #include diff --git a/cpp/tests/experimental/spatial/point_linestring_nearest_points_test.cu b/cpp/tests/spatial/nearest_points/point_linestring_nearest_points_test.cu similarity index 99% rename from cpp/tests/experimental/spatial/point_linestring_nearest_points_test.cu rename to cpp/tests/spatial/nearest_points/point_linestring_nearest_points_test.cu index 5163a3287..d71a7e64d 100644 --- a/cpp/tests/experimental/spatial/point_linestring_nearest_points_test.cu +++ b/cpp/tests/spatial/nearest_points/point_linestring_nearest_points_test.cu @@ -16,11 +16,10 @@ #include -#include #include -#include -#include -#include +#include +#include +#include #include diff --git a/cpp/tests/spatial/pairwise_point_in_polygon_test.cpp b/cpp/tests/spatial/point_in_polygon/pairwise_point_in_polygon_test.cpp similarity index 99% rename from cpp/tests/spatial/pairwise_point_in_polygon_test.cpp rename to cpp/tests/spatial/point_in_polygon/pairwise_point_in_polygon_test.cpp index 97d9f7b7c..477d8ce90 100644 --- a/cpp/tests/spatial/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/experimental/spatial/pairwise_point_in_polygon_test.cu b/cpp/tests/spatial/point_in_polygon/pairwise_point_in_polygon_test.cu similarity index 99% rename from cpp/tests/experimental/spatial/pairwise_point_in_polygon_test.cu rename to cpp/tests/spatial/point_in_polygon/pairwise_point_in_polygon_test.cu index 3a807ccfa..c05c24f63 100644 --- a/cpp/tests/experimental/spatial/pairwise_point_in_polygon_test.cu +++ b/cpp/tests/spatial/point_in_polygon/pairwise_point_in_polygon_test.cu @@ -15,9 +15,9 @@ */ #include -#include -#include -#include +#include +#include +#include #include #include diff --git a/cpp/tests/spatial/point_in_polygon_test.cpp b/cpp/tests/spatial/point_in_polygon/point_in_polygon_test.cpp similarity index 100% rename from cpp/tests/spatial/point_in_polygon_test.cpp rename to cpp/tests/spatial/point_in_polygon/point_in_polygon_test.cpp diff --git a/cpp/tests/experimental/spatial/point_in_polygon_test.cu b/cpp/tests/spatial/point_in_polygon/point_in_polygon_test.cu similarity index 99% rename from cpp/tests/experimental/spatial/point_in_polygon_test.cu rename to cpp/tests/spatial/point_in_polygon/point_in_polygon_test.cu index 3777495df..cd85f11f6 100644 --- a/cpp/tests/experimental/spatial/point_in_polygon_test.cu +++ b/cpp/tests/spatial/point_in_polygon/point_in_polygon_test.cu @@ -15,9 +15,9 @@ */ #include -#include -#include -#include +#include +#include +#include #include diff --git a/cpp/tests/experimental/spatial/points_in_range_test.cu b/cpp/tests/spatial/points_in_range/points_in_range_test.cu similarity index 98% rename from cpp/tests/experimental/spatial/points_in_range_test.cu rename to cpp/tests/spatial/points_in_range/points_in_range_test.cu index e276d5d3c..ca638fbdc 100644 --- a/cpp/tests/experimental/spatial/points_in_range_test.cu +++ b/cpp/tests/spatial/points_in_range/points_in_range_test.cu @@ -17,8 +17,8 @@ #include #include -#include -#include +#include +#include #include #include diff --git a/cpp/tests/spatial_window/spatial_window_test.cpp b/cpp/tests/spatial/points_in_range/spatial_window_test.cpp similarity index 100% rename from cpp/tests/spatial_window/spatial_window_test.cpp rename to cpp/tests/spatial/points_in_range/spatial_window_test.cpp diff --git a/cpp/tests/experimental/trajectory/derive_trajectories_test.cu b/cpp/tests/trajectory/derive_trajectories_test.cu similarity index 97% rename from cpp/tests/experimental/trajectory/derive_trajectories_test.cu rename to cpp/tests/trajectory/derive_trajectories_test.cu index f81656e2c..cc47700c7 100644 --- a/cpp/tests/experimental/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 #include #include diff --git a/cpp/tests/experimental/trajectory/trajectory_distances_and_speeds_test.cu b/cpp/tests/trajectory/trajectory_distances_and_speeds_test.cu similarity index 97% rename from cpp/tests/experimental/trajectory/trajectory_distances_and_speeds_test.cu rename to cpp/tests/trajectory/trajectory_distances_and_speeds_test.cu index aa91751a6..666b3c20b 100644 --- a/cpp/tests/experimental/trajectory/trajectory_distances_and_speeds_test.cu +++ b/cpp/tests/trajectory/trajectory_distances_and_speeds_test.cu @@ -19,10 +19,10 @@ #include -#include -#include +#include +#include +#include #include -#include #include diff --git a/cpp/tests/experimental/trajectory/trajectory_test_utils.cuh b/cpp/tests/trajectory/trajectory_test_utils.cuh similarity index 99% rename from cpp/tests/experimental/trajectory/trajectory_test_utils.cuh rename to cpp/tests/trajectory/trajectory_test_utils.cuh index b7e503d0a..94112cdbe 100644 --- a/cpp/tests/experimental/trajectory/trajectory_test_utils.cuh +++ b/cpp/tests/trajectory/trajectory_test_utils.cuh @@ -17,8 +17,8 @@ #pragma once -#include -#include +#include +#include #include diff --git a/cpp/tests/utility_test/test_geometry_generators.cu b/cpp/tests/utility_test/test_geometry_generators.cu index 5ecaab106..d0b35e9e4 100644 --- a/cpp/tests/utility_test/test_geometry_generators.cu +++ b/cpp/tests/utility_test/test_geometry_generators.cu @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include