repo_id stringlengths 21 96 | file_path stringlengths 31 155 | content stringlengths 1 92.9M | __index_level_0__ int64 0 0 |
|---|---|---|---|
rapidsai_public_repos/cuspatial/cpp/include/cuspatial/detail | rapidsai_public_repos/cuspatial/cpp/include/cuspatial/detail/utility/floating_point.cuh | /*
* 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 <cuspatial/cuda_utils.hpp>
#include <cmath>
#include <cstdint>
#include <type_traits>
namespace cuspatial {
namespace detail {
constexpr unsigned default_max_ulp = 4;
template <int size, typename = void>
struct uint_selector;
template <int size>
struct uint_selector<size, std::enable_if_t<size == 2>> {
using type = uint16_t;
};
template <int size>
struct uint_selector<size, std::enable_if_t<size == 4>> {
using type = uint32_t;
};
template <int size>
struct uint_selector<size, std::enable_if_t<size == 8>> {
using type = uint64_t;
};
template <typename Bits>
Bits constexpr sign_bit_mask()
{
return Bits{1} << 8 * sizeof(Bits) - 1;
}
template <typename T>
union FloatingPointBits {
using Bits = typename uint_selector<sizeof(T)>::type;
CUSPATIAL_HOST_DEVICE FloatingPointBits(T float_number) : _f(float_number) {}
T _f;
Bits _b;
};
/**
* @internal
* @brief Converts integer of sign-magnitude representation to biased representation.
*
* Biased representation has 1 representation of zero while sign-magnitude has 2.
* This conversion will collapse the two representations into 1. This is in line with
* our expectation that a positive number 1 differ from a negative number -1 by 2 hops
* instead of 3 in biased representation.
*
* Example:
* Assume `N` bits in the type `Bits`. In total 2^(N-1) representable numbers.
* (N=4):
* |--------------| |-----------------|
* decimal -2^3+1 -0 +0 2^3-1
* SaM 1111 1000 0000 0111
*
* In SaM, 0 is represented twice. In biased representation we need to collapse
* them to single representation, resulting in 1 more representable number in
* biased form.
*
* Naturally, lowest bit should map to the smallest number representable in the range.
* With 1 more representable number in biased form, we discard the lowest bit and start
* at the next lowest bit.
* |--------------|-----------------|
* decimal -2^3+1 0 2^3-1
* biased 0001 0111 1110
*
* The following implements the mapping independently in negative and positive range.
*
* Read http://en.wikipedia.org/wiki/Signed_number_representations for more
* details on signed number representations.
*
* @tparam Bits Unsigned type to store the bits
* @param sam Sign and magnitude representation
* @return Biased representation
*/
template <typename Bits>
std::enable_if_t<std::is_unsigned_v<Bits>, Bits> CUSPATIAL_HOST_DEVICE
signmagnitude_to_biased(Bits const& sam)
{
return sam & sign_bit_mask<Bits>() ? ~sam + 1 : sam | sign_bit_mask<Bits>();
}
/**
* @brief Floating-point equivalence comparator based on ULP (Unit in the last place).
*
* @note to compare if two floating points `flhs` and `frhs` are equivalent,
* use float_equal(flhs, frhs), instead of `float_equal(flhs-frhs, 0)`.
* See "Infernal Zero" section of
* https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
*
* @tparam T Type of floating point
* @tparam max_ulp Maximum tolerable unit in the last place
* @param flhs First floating point to compare
* @param frhs Second floating point to compare
* @return `true` if two floating points differ by less or equal to `ulp`.
*/
template <typename T, unsigned max_ulp = default_max_ulp>
bool CUSPATIAL_HOST_DEVICE float_equal(T const& flhs, T const& frhs)
{
FloatingPointBits<T> lhs{flhs};
FloatingPointBits<T> rhs{frhs};
if (std::isnan(lhs._f) || std::isnan(rhs._f)) return false;
auto lhsbiased = signmagnitude_to_biased(lhs._b);
auto rhsbiased = signmagnitude_to_biased(rhs._b);
return lhsbiased >= rhsbiased ? (lhsbiased - rhsbiased) <= max_ulp
: (rhsbiased - lhsbiased) <= max_ulp;
}
} // namespace detail
} // namespace cuspatial
| 0 |
rapidsai_public_repos/cuspatial/cpp/include/cuspatial/detail | rapidsai_public_repos/cuspatial/cpp/include/cuspatial/detail/utility/zero_data.cuh |
/*
* 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 <cuspatial/traits.hpp>
#include <rmm/cuda_stream_view.hpp>
namespace cuspatial {
namespace detail {
/**
* @brief Zero set a data range on device
*
* @tparam Iterator type of iterator to the range
* @param begin Start iterator to the range
* @param end End iterator to the range
* @param stream CUDA stream used for device memory operations and kernel launches
*/
template <typename Iterator>
void zero_data_async(Iterator begin, Iterator end, rmm::cuda_stream_view stream)
{
using value_type = iterator_value_type<Iterator>;
auto dst = thrust::raw_pointer_cast(&*begin);
auto size = thrust::distance(begin, end) * sizeof(value_type);
cudaMemsetAsync(dst, 0, size, stream.value());
}
} // namespace detail
} // namespace cuspatial
| 0 |
rapidsai_public_repos/cuspatial/cpp/include/cuspatial/detail | rapidsai_public_repos/cuspatial/cpp/include/cuspatial/detail/find/find_and_combine_segment.cuh | /*
* 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 <cuspatial/cuda_utils.hpp>
#include <cuspatial/detail/utility/linestring.cuh>
#include <cuspatial/error.hpp>
#include <cuspatial/iterator_factory.cuh>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <ranger/ranger.hpp>
#include <thrust/sort.h>
#include <thrust/uninitialized_fill.h>
namespace cuspatial {
namespace detail {
/**
* @internal
* @pre All segments in range @p segments , it is presorted using `segment_comparator`.
*
* @brief Kernel to merge segments. Each thread works on one segment space, within each space,
* `segment_comparator` guarantees that segments with same slope are grouped together. We call
* each of such group is a "mergeable group". Within each mergeable group, the first segment is
* the "leading segment". The algorithm behave as follows:
*
* 1. For each mergeable group, loop over the rest of the segments in the group and see if it is
* mergeable with the leading segment. If it is, overwrite the leading segment with the merged
* result. Then mark the segment as merged by setting the flag to 1. This makes sure the inner loop
* for each merged segment is not run again.
* 2. Repeat 1 until all mergeable group is processed.
*/
template <typename OffsetRange, typename SegmentRange, typename OutputIt>
void __global__ simple_find_and_combine_segments_kernel(OffsetRange offsets,
SegmentRange segments,
OutputIt merged_flag)
{
for (auto pair_idx : ranger::grid_stride_range(offsets.size() - 1)) {
// Zero-initialize flags for all segments in current space.
for (auto i = offsets[pair_idx]; i < offsets[pair_idx + 1]; i++) {
merged_flag[i] = 0;
}
// For each of the segment, loop over the rest of the segment in the space and see
// if it is mergeable with the current segment.
// Note that if the current segment is already merged. Skip checking.
for (auto i = offsets[pair_idx]; i < offsets[pair_idx + 1] && merged_flag[i] != 1; i++) {
for (auto j = i + 1; j < offsets[pair_idx + 1]; j++) {
auto res = maybe_merge_segments(segments[i], segments[j]);
if (res.has_value()) {
// segments[i] can be merged from segments[j]
segments[i] = res.value();
merged_flag[j] = 1;
}
}
}
}
}
/**
* @brief Comparator for sorting the segment range.
*
* This comparator makes sure that the segment range is sorted such that:
* 1. Segments with the same space id are grouped together.
* 2. Segments within the same space are grouped by their slope.
* 3. Within each slope group, segments are sorted by their lower left point.
*/
template <typename index_t, typename T>
struct segment_comparator {
bool __device__ operator()(thrust::tuple<index_t, segment<T>> const& lhs,
thrust::tuple<index_t, segment<T>> const& rhs) const
{
auto lhs_index = thrust::get<0>(lhs);
auto rhs_index = thrust::get<0>(rhs);
auto lhs_segment = thrust::get<1>(lhs);
auto rhs_segment = thrust::get<1>(rhs);
// Compare space id
if (lhs_index == rhs_index) {
// Compare slope
if (lhs_segment.collinear(rhs_segment)) {
// Sort by the lower left point of the segment.
return lhs_segment.lower_left() < rhs_segment.lower_left();
}
return lhs_segment.slope() < rhs_segment.slope();
}
return lhs_index < rhs_index;
}
};
/**
* @internal
* @brief For each pair of mergeable segment, overwrites the first segment with merged result,
* sets the flag for the second segment as 1.
*
* @note This function will alter the input segment range by rearranging the order of the segments
* within each space so that merging kernel can take place.
*/
template <typename OffsetRange, typename SegmentRange, typename OutputIt>
void find_and_combine_segment(OffsetRange offsets,
SegmentRange segments,
OutputIt merged_flag,
rmm::cuda_stream_view stream)
{
using index_t = typename OffsetRange::value_type;
using T = typename SegmentRange::value_type::value_type;
auto num_spaces = offsets.size() - 1;
if (num_spaces == 0) return;
// Construct a key iterator using the offsets of the segment and the segment itself.
auto space_id_iter = make_geometry_id_iterator<index_t>(offsets.begin(), offsets.end());
auto space_id_segment_iter = thrust::make_zip_iterator(space_id_iter, segments.begin());
thrust::sort_by_key(rmm::exec_policy(stream),
space_id_segment_iter,
space_id_segment_iter + segments.size(),
segments.begin(),
segment_comparator<index_t, T>{});
auto [threads_per_block, num_blocks] = grid_1d(num_spaces);
simple_find_and_combine_segments_kernel<<<num_blocks, threads_per_block, 0, stream.value()>>>(
offsets, segments, merged_flag);
CUSPATIAL_CHECK_CUDA(stream.value());
}
} // namespace detail
} // namespace cuspatial
| 0 |
rapidsai_public_repos/cuspatial/cpp/include/cuspatial/detail | rapidsai_public_repos/cuspatial/cpp/include/cuspatial/detail/find/find_duplicate_points.cuh | /*
* 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 <cuspatial/cuda_utils.hpp>
#include <cuspatial/error.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <ranger/ranger.hpp>
#include <thrust/uninitialized_fill.h>
namespace cuspatial {
namespace detail {
/**
* @internal
* @brief Kernel to compute duplicate points in each multipoint. Naive N^2 algorithm.
*/
template <typename MultiPointRange, typename OutputIt>
void __global__ find_duplicate_points_kernel_simple(MultiPointRange multipoints,
OutputIt duplicate_flags)
{
for (auto idx : ranger::grid_stride_range(multipoints.size())) {
auto multipoint = multipoints[idx];
auto global_offset = multipoints.offsets_begin()[idx];
// Zero-initialize duplicate_flags for all points in the current space
for (auto i = 0; i < multipoint.size(); ++i) {
duplicate_flags[i + global_offset] = 0;
}
// Loop over the point range to find duplicates, skipping if the point is already marked as
// duplicate.
for (auto i = 0; i < multipoint.size() && duplicate_flags[i + global_offset] != 1; ++i) {
for (auto j = i + 1; j < multipoint.size(); ++j) {
if (multipoint[i] == multipoint[j]) duplicate_flags[j + global_offset] = 1;
}
}
}
}
/**
* @internal
* @brief For each multipoint, find the duplicate points.
*
* If a point has duplicates, all but one flags for the duplicates will be set to 1.
* There is no guarantee which of the duplicates will not be set.
*/
template <typename MultiPointRange, typename OutputIt>
void find_duplicate_points(MultiPointRange multipoints,
OutputIt duplicate_flags,
rmm::cuda_stream_view stream)
{
if (multipoints.size() == 0) return;
auto [threads_per_block, num_blocks] = grid_1d(multipoints.size());
find_duplicate_points_kernel_simple<<<num_blocks, threads_per_block, 0, stream.value()>>>(
multipoints, duplicate_flags);
CUSPATIAL_CHECK_CUDA(stream.value());
}
} // namespace detail
} // namespace cuspatial
| 0 |
rapidsai_public_repos/cuspatial/cpp/include/cuspatial/detail | rapidsai_public_repos/cuspatial/cpp/include/cuspatial/detail/find/find_points_on_segments.cuh | /*
* 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 <cuspatial_test/test_util.cuh>
#include <cuspatial/cuda_utils.hpp>
#include <cuspatial/detail/utility/linestring.cuh>
#include <cuspatial/error.hpp>
#include <cuspatial/iterator_factory.cuh>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/tabulate.h>
#include <thrust/tuple.h>
namespace cuspatial {
namespace detail {
/**
* @internal
* @brief Functor to find if the given point is on any of the segments in the same pair
*/
template <typename MultiPointRange, typename OffsetsRange, typename SegmentsRange>
struct find_point_on_segment_functor {
MultiPointRange multipoints;
OffsetsRange segment_offsets;
SegmentsRange segments;
find_point_on_segment_functor(MultiPointRange multipoints,
OffsetsRange segment_offsets,
SegmentsRange segments)
: multipoints(multipoints), segment_offsets(segment_offsets), segments(segments)
{
}
template <typename IndexType>
uint8_t __device__ operator()(IndexType i)
{
auto point = thrust::raw_reference_cast(multipoints.point_begin()[i]);
auto geometry_idx = multipoints.geometry_idx_from_point_idx(i);
for (auto segment_idx = segment_offsets[geometry_idx];
segment_idx < segment_offsets[geometry_idx + 1];
segment_idx++) {
auto const& segment = thrust::raw_reference_cast(segments[segment_idx]);
if (is_point_on_segment(segment, point)) return true;
}
return false;
}
};
/**
* @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`.
*/
template <typename MultiPointRange,
typename OffsetsRange,
typename SegmentsRange,
typename OutputIt1>
void find_points_on_segments(MultiPointRange multipoints,
OffsetsRange segment_offsets,
SegmentsRange segments,
OutputIt1 mergeable_flag,
rmm::cuda_stream_view stream)
{
using index_t = typename MultiPointRange::index_t;
CUSPATIAL_EXPECTS(multipoints.size() == segment_offsets.size() - 1,
"Input should contain the same number of pairs.");
if (segments.size() == 0) return;
thrust::tabulate(rmm::exec_policy(stream),
mergeable_flag,
mergeable_flag + multipoints.num_points(),
find_point_on_segment_functor{multipoints, segment_offsets, segments});
}
} // namespace detail
} // namespace cuspatial
| 0 |
rapidsai_public_repos/cuspatial/cpp/include/cuspatial | rapidsai_public_repos/cuspatial/cpp/include/cuspatial/range/multilinestring_range.cuh | /*
* 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 <cuspatial/cuda_utils.hpp>
#include <cuspatial/detail/range/enumerate_range.cuh>
#include <cuspatial/geometry/segment.cuh>
#include <cuspatial/geometry/vec_2d.hpp>
#include <cuspatial/traits.hpp>
#include <cuspatial/types.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <thrust/pair.h>
namespace cuspatial {
/**
* @addtogroup ranges
*/
/**
* @brief Non-owning range-based interface to multilinestring data
*
* Provides a range-based interface to contiguous storage of multilinestring data, to make it easier
* to access and iterate over multilinestrings, linestrings and points.
*
* Conforms to GeoArrow's specification of multilinestring:
* https://github.com/geopandas/geo-arrow-spec/blob/main/format.md
*
* @tparam GeometryIterator iterator type for the geometry offset array. Must meet
* the requirements of [LegacyRandomAccessIterator][LinkLRAI].
* @tparam PartIterator iterator type for the part offset array. Must meet
* the requirements of [LegacyRandomAccessIterator][LinkLRAI].
* @tparam VecIterator iterator type for the point array. Must meet
* the requirements of [LegacyRandomAccessIterator][LinkLRAI].
*
* @note Though this object is host/device compatible,
* The underlying iterator must be device accessible if used in device kernel.
*
* [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator
* "LegacyRandomAccessIterator"
*/
template <typename GeometryIterator, typename PartIterator, typename VecIterator>
class multilinestring_range {
public:
using geometry_it_t = GeometryIterator;
using part_it_t = PartIterator;
using point_it_t = VecIterator;
using point_t = iterator_value_type<VecIterator>;
using element_t = iterator_vec_base_type<VecIterator>;
CUSPATIAL_HOST_DEVICE multilinestring_range(GeometryIterator geometry_begin,
GeometryIterator geometry_end,
PartIterator part_begin,
PartIterator part_end,
VecIterator points_begin,
VecIterator points_end);
/// Return the number of multilinestrings in the array.
CUSPATIAL_HOST_DEVICE auto size() { return num_multilinestrings(); }
/// Return the number of multilinestrings in the array.
CUSPATIAL_HOST_DEVICE auto num_multilinestrings();
/// Return the total number of linestrings in the array.
CUSPATIAL_HOST_DEVICE auto num_linestrings();
/// Return the total number of points in the array.
CUSPATIAL_HOST_DEVICE auto num_points();
/// Return the iterator to the first multilinestring in the range.
CUSPATIAL_HOST_DEVICE auto multilinestring_begin();
/// Return the iterator to the one past the last multilinestring in the range.
CUSPATIAL_HOST_DEVICE auto multilinestring_end();
/// Return the iterator to the first multilinestring in the range.
CUSPATIAL_HOST_DEVICE auto begin() { return multilinestring_begin(); }
/// Return the iterator to the one past the last multilinestring in the range.
CUSPATIAL_HOST_DEVICE auto end() { return multilinestring_end(); }
/// Return the iterator to the first point in the range.
CUSPATIAL_HOST_DEVICE auto point_begin() { return _point_begin; }
/// Return the iterator to the one past the last point in the range.
CUSPATIAL_HOST_DEVICE auto point_end() { return _point_end; }
/// Return the iterator to the first geometry offset in the range.
CUSPATIAL_HOST_DEVICE auto geometry_offset_begin() { return _geometry_begin; }
/// Return the iterator to the one past the last geometry offset in the range.
CUSPATIAL_HOST_DEVICE auto geometry_offset_end() { return _geometry_end; }
/// Return the iterator to the first part offset in the range.
CUSPATIAL_HOST_DEVICE auto part_offset_begin() { return _part_begin; }
/// Return the iterator to the one past the last part offset in the range.
CUSPATIAL_HOST_DEVICE auto part_offset_end() { return _part_end; }
/// Given the index of a point, return the part (linestring) index where the point locates.
template <typename IndexType>
CUSPATIAL_HOST_DEVICE auto part_idx_from_point_idx(IndexType point_idx);
/// Given the index of a segment, return the part (linestring) index where the segment locates.
/// If the segment id is invalid, returns nullopt.
template <typename IndexType>
CUSPATIAL_HOST_DEVICE
thrust::optional<typename thrust::iterator_traits<PartIterator>::difference_type>
part_idx_from_segment_idx(IndexType point_idx);
/// Given the index of a part (linestring), return the geometry (multilinestring) index
/// where the linestring locates.
template <typename IndexType>
CUSPATIAL_HOST_DEVICE auto geometry_idx_from_part_idx(IndexType part_idx);
/// Given the index of a point, return the geometry (multilinestring) index where the
/// point locates.
template <typename IndexType>
CUSPATIAL_HOST_DEVICE auto geometry_idx_from_point_idx(IndexType point_idx);
// Given index to a linestring, return the index of the linestring inside its multilinestring.
template <typename IndexType>
CUSPATIAL_HOST_DEVICE auto intra_part_idx(IndexType global_part_idx);
// Given index to a point, return the index of the point inside its linestring.
template <typename IndexType>
CUSPATIAL_HOST_DEVICE auto intra_point_idx(IndexType global_point_idx);
/// Given an index of a segment, returns true if the index is valid.
/// The index of a segment is the same as the index to the starting point of the segment.
/// Thus, the index to the last point of a linestring is an invalid segment index.
template <typename IndexType1, typename IndexType2>
CUSPATIAL_HOST_DEVICE bool is_valid_segment_id(IndexType1 segment_idx, IndexType2 part_idx);
/// Returns the segment given a segment index.
template <typename IndexType>
CUSPATIAL_HOST_DEVICE auto segment(IndexType segment_idx);
/// Returns an iterator to the counts of points per multilinestring
CUSPATIAL_HOST_DEVICE auto multilinestring_point_count_begin();
/// Returns an iterator to the counts of segments per multilinestring
CUSPATIAL_HOST_DEVICE auto multilinestring_point_count_end();
/// Returns an iterator to the counts of points per multilinestring
CUSPATIAL_HOST_DEVICE auto multilinestring_linestring_count_begin();
/// Returns an iterator to the counts of points per multilinestring
CUSPATIAL_HOST_DEVICE auto multilinestring_linestring_count_end();
/// @internal
/// Returns the owning class that provides views into the segments of the multilinestring range
/// Can only be constructed on host
auto _segments(rmm::cuda_stream_view);
/// Returns the `multilinestring_idx`th multilinestring in the range.
template <typename IndexType>
CUSPATIAL_HOST_DEVICE auto operator[](IndexType multilinestring_idx);
/// Range Casts
/// Casts the multilinestring range into a multipoint range.
/// This treats each multilinestring as simply a collection of points,
/// ignoring all edges in the multilinestring.
CUSPATIAL_HOST_DEVICE auto as_multipoint_range();
protected:
GeometryIterator _geometry_begin;
GeometryIterator _geometry_end;
PartIterator _part_begin;
PartIterator _part_end;
VecIterator _point_begin;
VecIterator _point_end;
private:
/// @internal
/// Return the iterator to the part index where the point locates.
template <typename IndexType>
CUSPATIAL_HOST_DEVICE auto _part_iter_from_point_idx(IndexType point_idx);
/// @internal
/// Return the iterator to the geometry index where the part locates.
template <typename IndexType>
CUSPATIAL_HOST_DEVICE auto _geometry_iter_from_part_idx(IndexType part_idx);
};
/**
* @brief Create a multilinestring_range object from size and start iterators
*
* @tparam GeometryIteratorDiffType Index type of the size of the geometry array
* @tparam PartIteratorDiffType Index type of the size of the part array
* @tparam VecIteratorDiffType Index type of the size of the point array
* @tparam GeometryIterator iterator type for offset array. Must meet
* the requirements of [LegacyRandomAccessIterator][LinkLRAI].
* @tparam PartIterator iterator type for the part offset array. Must meet
* the requirements of [LegacyRandomAccessIterator][LinkLRAI].
* @tparam VecIterator iterator type for the point array. Must meet
* the requirements of [LegacyRandomAccessIterator][LinkLRAI].
*
* @note Iterators must be device-accessible if the view is intended to be
* used on device.
*
* @param num_multilinestrings Number of multilinestrings in the array.
* @param geometry_begin Iterator to the start of the geometry array.
* @param num_linestrings Number of linestrings in the underlying parts array.
* @param part_begin Iterator to the start of the part array.
* @param num_points Number of points in the underlying points array.
* @param point_begin Iterator to the start of the point array.
* @return A `multilinestring_range` object
*
* [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator
* "LegacyRandomAccessIterator"
*/
template <typename GeometryIteratorDiffType,
typename PartIteratorDiffType,
typename VecIteratorDiffType,
typename GeometryIterator,
typename PartIterator,
typename VecIterator>
auto make_multilinestring_range(GeometryIteratorDiffType num_multilinestrings,
GeometryIterator geometry_begin,
PartIteratorDiffType num_linestrings,
PartIterator part_begin,
VecIteratorDiffType num_points,
VecIterator point_begin)
{
return multilinestring_range{geometry_begin,
geometry_begin + num_multilinestrings + 1,
part_begin,
part_begin + num_linestrings + 1,
point_begin,
point_begin + num_points};
}
/**
* @brief Create a range object of multilinestring data from offset and point ranges
*
* @tparam IntegerRange1 Range to integers
* @tparam IntegerRange2 Range to integers
* @tparam PointRange Range to points
*
* @param geometry_offsets Range to multilinestring geometry offsets
* @param part_offsets Range to linestring part offsets
* @param points Range to underlying points
* @return A multilinestring_range object
*/
template <typename IntegerRange1, typename IntegerRange2, typename PointRange>
auto make_multilinestring_range(IntegerRange1 geometry_offsets,
IntegerRange2 part_offsets,
PointRange points)
{
return multilinestring_range(geometry_offsets.begin(),
geometry_offsets.end(),
part_offsets.begin(),
part_offsets.end(),
points.begin(),
points.end());
}
/**
* @brief Create a range object of multilinestring from cuspatial::geometry_column_view.
* Specialization for linestrings column.
*
* @pre linestrings_column must be a cuspatial::geometry_column_view
*/
template <collection_type_id Type,
typename T,
typename IndexType,
typename GeometryColumnView,
CUSPATIAL_ENABLE_IF(Type == collection_type_id::SINGLE)>
auto make_multilinestring_range(GeometryColumnView const& linestrings_column)
{
CUSPATIAL_EXPECTS(linestrings_column.geometry_type() == geometry_type_id::LINESTRING,
"Must be Linestring geometry type.");
auto geometry_iter = thrust::make_counting_iterator(0);
auto const& part_offsets = linestrings_column.offsets();
auto const& points_xy = linestrings_column.child().child(1); // Ignores x-y offset {0, 2, 4...}
auto points_it = make_vec_2d_iterator(points_xy.template begin<T>());
return multilinestring_range(geometry_iter,
geometry_iter + part_offsets.size(),
part_offsets.template begin<IndexType>(),
part_offsets.template end<IndexType>(),
points_it,
points_it + points_xy.size() / 2);
}
/**
* @brief Create a range object of multilinestring from cuspatial::geometry_column_view.
* Specialization for multilinestrings column.
*
* @pre linestring_column must be a cuspatial::geometry_column_view
*/
template <collection_type_id Type,
typename T,
typename IndexType,
CUSPATIAL_ENABLE_IF(Type == collection_type_id::MULTI),
typename GeometryColumnView>
auto make_multilinestring_range(GeometryColumnView const& linestrings_column)
{
CUSPATIAL_EXPECTS(linestrings_column.geometry_type() == geometry_type_id::LINESTRING,
"Must be Linestring geometry type.");
auto const& geometry_offsets = linestrings_column.offsets();
auto const& parts = linestrings_column.child();
auto const& part_offsets = parts.child(0);
auto const& points_xy = parts.child(1).child(1); // Ignores x-y offset {0, 2, 4...}
auto points_it = make_vec_2d_iterator(points_xy.template begin<T>());
return multilinestring_range(geometry_offsets.template begin<IndexType>(),
geometry_offsets.template end<IndexType>(),
part_offsets.template begin<IndexType>(),
part_offsets.template end<IndexType>(),
points_it,
points_it + points_xy.size() / 2);
};
/**
* @} // end of doxygen group
*/
} // namespace cuspatial
#include <cuspatial/detail/range/multilinestring_range.cuh>
| 0 |
rapidsai_public_repos/cuspatial/cpp/include/cuspatial | rapidsai_public_repos/cuspatial/cpp/include/cuspatial/range/multipoint_range.cuh | /*
* 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 <cuspatial/cuda_utils.hpp>
#include <cuspatial/traits.hpp>
#include <cuspatial/types.hpp>
#include <thrust/iterator/counting_iterator.h>
namespace cuspatial {
/**
* @addtogroup ranges
* @{
*/
/**
* @brief Non-owning range-based interface to multipoint data
*
* Provides a range-based interface to contiguous storage of multipoint data, to make it easier
* to access and iterate over multipoints and points.
*
* Conforms to GeoArrow's specification of multipoint array:
* https://github.com/geopandas/geo-arrow-spec/blob/main/format.md
*
* @tparam GeometryIterator iterator type for the offset array. Must meet
* the requirements of [LegacyRandomAccessIterator][LinkLRAI].
* @tparam VecIterator iterator type for the point array. Must meet
* the requirements of [LegacyRandomAccessIterator][LinkLRAI].
*
* @note Though this object is host/device compatible,
* The underlying iterator should be device-accessible if used in a device kernel.
*
* [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator
* "LegacyRandomAccessIterator"
*/
template <typename GeometryIterator, typename VecIterator>
class multipoint_range {
public:
using geometry_it_t = GeometryIterator;
using point_it_t = VecIterator;
using index_t = iterator_value_type<geometry_it_t>;
using point_t = iterator_value_type<point_it_t>;
using element_t = iterator_vec_base_type<point_it_t>;
/**
* @brief Construct a new multipoint array object
*/
CUSPATIAL_HOST_DEVICE multipoint_range(GeometryIterator geometry_begin,
GeometryIterator geometry_end,
VecIterator points_begin,
VecIterator points_end);
/**
* @brief Returns the number of multipoints in the array.
*/
CUSPATIAL_HOST_DEVICE auto num_multipoints();
/**
* @brief Returns the number of points in the array.
*/
CUSPATIAL_HOST_DEVICE auto num_points();
/**
* @brief Returns the number of multipoints in the array.
*/
CUSPATIAL_HOST_DEVICE auto size() { return num_multipoints(); }
/**
* @brief Returns the iterator to the first multipoint in the multipoint array.
*/
CUSPATIAL_HOST_DEVICE auto multipoint_begin();
/**
* @brief Returns the iterator past the last multipoint in the multipoint array.
*/
CUSPATIAL_HOST_DEVICE auto multipoint_end();
/**
* @brief Returns the iterator to the start of the multipoint array.
*/
CUSPATIAL_HOST_DEVICE auto begin() { return multipoint_begin(); }
/**
* @brief Returns the iterator past the last multipoint in the multipoint array.
*/
CUSPATIAL_HOST_DEVICE auto end() { return multipoint_end(); }
/**
* @brief Returns the iterator to the start of the underlying point array.
*/
CUSPATIAL_HOST_DEVICE auto point_begin();
/**
* @brief Returns the iterator to the end of the underlying point array.
*/
CUSPATIAL_HOST_DEVICE auto point_end();
/**
* @brief Returns the iterator to the start of the underlying offsets array.
*/
CUSPATIAL_HOST_DEVICE auto offsets_begin();
/**
* @brief Returns the iterator to the end of the underlying offsets array.
*/
CUSPATIAL_HOST_DEVICE auto offsets_end();
/**
* @brief Returns the geometry index of the given point index.
*/
template <typename IndexType>
CUSPATIAL_HOST_DEVICE auto geometry_idx_from_point_idx(IndexType point_idx) const;
/**
* @brief Returns the `idx`th multipoint in the array.
*
* @tparam IndexType type of the index
* @param idx the index to the multipoint
* @return a multipoint object
*/
template <typename IndexType>
CUSPATIAL_HOST_DEVICE auto operator[](IndexType idx);
/**
* @brief Returns the `idx`th point in the array.
*
* @tparam IndexType type of the index
* @param idx the index to the point
* @return a vec_2d object
*/
template <typename IndexType>
CUSPATIAL_HOST_DEVICE auto point(IndexType idx);
/**
* @brief Returns `true` if the range contains only single points
* Undefined behavior if the range is an empty range.
*/
CUSPATIAL_HOST_DEVICE bool is_single_point_range();
protected:
/// Iterator to the start of the index array of start positions to each multipoint.
GeometryIterator _geometry_begin;
/// Iterator to the past-the-end of the index array of start positions to each multipoint.
GeometryIterator _geometry_end;
/// Iterator to the start of the point array.
VecIterator _points_begin;
/// Iterator to the past-the-end position of the point array.
VecIterator _points_end;
};
/**
* @brief Create a multipoint_range object of from size and start iterators
*
* @tparam GeometryIteratorDiffType Index type of the size of the geometry array
* @tparam VecIteratorDiffType Index type of the size of the point array
* @tparam GeometryIterator iterator type for offset array. Must meet
* the requirements of [LegacyRandomAccessIterator][LinkLRAI].
* @tparam VecIterator iterator type for the point array. Must meet
* the requirements of [LegacyRandomAccessIterator][LinkLRAI].
*
* @note Iterators should be device-accessible if the view is intended to be
* used on device.
*
* @param num_multipoints Number of multipoints in the array
* @param geometry_begin Iterator to the start of the geometry offset array
* @param num_points Number of underlying points in the multipoint array
* @param point_begin Iterator to the start of the points array
* @return Range to multipoint array
* [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator
* "LegacyRandomAccessIterator"
*/
template <typename GeometryIteratorDiffType,
typename VecIteratorDiffType,
typename GeometryIterator,
typename VecIterator>
multipoint_range<GeometryIterator, VecIterator> make_multipoint_range(
GeometryIteratorDiffType num_multipoints,
GeometryIterator geometry_begin,
VecIteratorDiffType num_points,
VecIterator point_begin)
{
return multipoint_range<GeometryIterator, VecIterator>{
geometry_begin, geometry_begin + num_multipoints + 1, point_begin, point_begin + num_points};
}
/**
* @brief Create multipoint_range object from offset and point ranges
*
* @tparam IntegerRange Range to integers
* @tparam PointRange Range to points
*
* @param geometry_offsets Range to multipoints geometry offsets
* @param points Range to underlying parts
* @return A multipoint_range object
*/
template <typename IntegerRange, typename PointRange>
auto make_multipoint_range(IntegerRange geometry_offsets, PointRange points)
{
return multipoint_range(
geometry_offsets.begin(), geometry_offsets.end(), points.begin(), points.end());
}
/**
* @brief Create a range object of multipoints from cuspatial::geometry_column_view.
* Specialization for points column.
*
* @pre points_column must be a cuspatial::geometry_column_view
*/
template <collection_type_id Type,
typename T,
typename IndexType,
CUSPATIAL_ENABLE_IF(Type == collection_type_id::SINGLE),
typename GeometryColumnView>
auto make_multipoint_range(GeometryColumnView const& points_column)
{
CUSPATIAL_EXPECTS(points_column.geometry_type() == geometry_type_id::POINT,
"Must be POINT geometry type.");
auto geometry_iter = thrust::make_counting_iterator(0);
auto const& points_xy = points_column.child(); // Ignores x-y offset {0, 2, 4...}
auto points_it = make_vec_2d_iterator(points_xy.template begin<T>());
return multipoint_range(geometry_iter,
thrust::next(geometry_iter, points_column.size() + 1),
points_it,
points_it + points_xy.size() / 2);
}
/**
* @brief Create a range object of multipoints from cuspatial::geometry_column_view.
* Specialization for multipoints column.
*
* @pre multipoints_column must be a cuspatial::geometry_column_view
*/
template <collection_type_id Type,
typename T,
typename IndexType,
CUSPATIAL_ENABLE_IF(Type == collection_type_id::MULTI),
typename GeometryColumnView>
auto make_multipoint_range(GeometryColumnView const& points_column)
{
CUSPATIAL_EXPECTS(points_column.geometry_type() == geometry_type_id::POINT,
"Must be POINT geometry type.");
auto const& geometry_offsets = points_column.offsets();
auto const& points_xy = points_column.child().child(1); // Ignores x-y offset {0, 2, 4...}
auto points_it = make_vec_2d_iterator(points_xy.template begin<T>());
return multipoint_range(geometry_offsets.template begin<IndexType>(),
geometry_offsets.template end<IndexType>(),
points_it,
points_it + points_xy.size() / 2);
};
/**
* @} // end of doxygen group
*/
} // namespace cuspatial
#include <cuspatial/detail/range/multipoint_range.cuh>
| 0 |
rapidsai_public_repos/cuspatial/cpp/include/cuspatial | rapidsai_public_repos/cuspatial/cpp/include/cuspatial/range/range.cuh | /*
* 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 <cuspatial/cuda_utils.hpp>
#include <cuspatial/traits.hpp>
#include <thrust/detail/raw_reference_cast.h>
#include <thrust/distance.h>
namespace cuspatial {
/**
* @brief Abstract Data Type (ADT) for any containers representable with a start and end iterator.
*
* This is similar to a span, except that the iterators can be composed of generators.
*
* @note Although this structure can be used on device and host code, this structure does not
* provide implicit device-host transfer. It is up to developer's prudence not to access device
* memory from host or the reverse.
*
* @tparam Type of both start and end iterator. IteratorType must satisfy
* LegacyRandomAccessIterator[LinkLRAI].
*
* [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator
* "LegacyRandomAccessIterator"
*/
template <typename IteratorType>
class range {
public:
using value_type = iterator_value_type<IteratorType>;
range(IteratorType begin, IteratorType end) : _begin(begin), _end(end) {}
/// Return the start iterator to the range
auto CUSPATIAL_HOST_DEVICE begin() { return _begin; }
/// Return the end iterator to the range
auto CUSPATIAL_HOST_DEVICE end() { return _end; }
/// Return the size of the range
auto CUSPATIAL_HOST_DEVICE size() { return thrust::distance(_begin, _end); }
/// Access the `i`th element in the range
template <typename IndexType>
auto& CUSPATIAL_HOST_DEVICE operator[](IndexType i)
{
return thrust::raw_reference_cast(_begin[i]);
}
private:
IteratorType _begin;
IteratorType _end;
};
} // namespace cuspatial
| 0 |
rapidsai_public_repos/cuspatial/cpp/include/cuspatial | rapidsai_public_repos/cuspatial/cpp/include/cuspatial/range/multipolygon_range.cuh | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <cuspatial/cuda_utils.hpp>
#include <cuspatial/detail/range/enumerate_range.cuh>
#include <cuspatial/geometry/vec_2d.hpp>
#include <cuspatial/traits.hpp>
#include <cuspatial/types.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <thrust/pair.h>
namespace cuspatial {
/**
* @addtogroup ranges
* @{
*/
/**
* @brief Non-owning range-based interface to multipolygon data
*
* Provides a range-based interface to contiguous storage of multipolygon data, to make it easier
* to access and iterate over multipolygons, polygons, rings and points.
*
* Conforms to GeoArrow's specification of multipolygon:
* https://github.com/geopandas/geo-arrow-spec/blob/main/format.md
*
* @tparam GeometryIterator iterator type for the geometry offset array. Must meet
* the requirements of [LegacyRandomAccessIterator][LinkLRAI].
* @tparam PartIterator iterator type for the part offset array. Must meet
* the requirements of [LegacyRandomAccessIterator][LinkLRAI].
* @tparam RingIterator iterator type for the ring offset array. Must meet
* the requirements of [LegacyRandomAccessIterator][LinkLRAI].
* @tparam VecIterator iterator type for the point array. Must meet
* the requirements of [LegacyRandomAccessIterator][LinkLRAI].
*
* @note Though this object is host/device compatible,
* The underlying iterator must be device accessible if used in device kernel.
*
* [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator
* "LegacyRandomAccessIterator"
*/
template <typename GeometryIterator,
typename PartIterator,
typename RingIterator,
typename VecIterator>
class multipolygon_range {
public:
using geometry_it_t = GeometryIterator;
using part_it_t = PartIterator;
using ring_it_t = RingIterator;
using point_it_t = VecIterator;
using point_t = iterator_value_type<VecIterator>;
using index_t = iterator_value_type<GeometryIterator>;
using element_t = iterator_vec_base_type<VecIterator>;
multipolygon_range(GeometryIterator geometry_begin,
GeometryIterator geometry_end,
PartIterator part_begin,
PartIterator part_end,
RingIterator ring_begin,
RingIterator ring_end,
VecIterator points_begin,
VecIterator points_end);
/// Return the number of multipolygons in the array.
CUSPATIAL_HOST_DEVICE auto size() { return num_multipolygons(); }
/// Return the number of multipolygons in the array.
CUSPATIAL_HOST_DEVICE auto num_multipolygons();
/// Return the total number of polygons in the array.
CUSPATIAL_HOST_DEVICE auto num_polygons();
/// Return the total number of rings in the array.
CUSPATIAL_HOST_DEVICE auto num_rings();
/// Return the total number of points in the array.
CUSPATIAL_HOST_DEVICE auto num_points();
/// Return the iterator to the first multipolygon in the range.
CUSPATIAL_HOST_DEVICE auto multipolygon_begin();
/// Return the iterator to the one past the last multipolygon in the range.
CUSPATIAL_HOST_DEVICE auto multipolygon_end();
/// Return the iterator to the first multipolygon in the range.
CUSPATIAL_HOST_DEVICE auto begin() { return multipolygon_begin(); }
/// Return the iterator to the one past the last multipolygon in the range.
CUSPATIAL_HOST_DEVICE auto end() { return multipolygon_end(); }
/// Return the iterator to the first point in the range.
CUSPATIAL_HOST_DEVICE auto point_begin();
/// Return the iterator to the one past the last point in the range.
CUSPATIAL_HOST_DEVICE auto point_end();
/// Return the iterator to the first geometry offset in the range.
CUSPATIAL_HOST_DEVICE auto geometry_offset_begin() { return _part_begin; }
/// Return the iterator to the one past the last geometry offset in the range.
CUSPATIAL_HOST_DEVICE auto geometry_offset_end() { return _part_end; }
/// Return the iterator to the first part offset in the range.
CUSPATIAL_HOST_DEVICE auto part_offset_begin() { return _part_begin; }
/// Return the iterator to the one past the last part offset in the range.
CUSPATIAL_HOST_DEVICE auto part_offset_end() { return _part_end; }
/// Return the iterator to the first ring offset in the range.
CUSPATIAL_HOST_DEVICE auto ring_offset_begin() { return _ring_begin; }
/// Return the iterator to the one past the last ring offset in the range.
CUSPATIAL_HOST_DEVICE auto ring_offset_end() { return _ring_end; }
/// Given the index of a point, return the index of the ring that contains the point.
template <typename IndexType>
CUSPATIAL_HOST_DEVICE auto ring_idx_from_point_idx(IndexType point_idx);
/// Given the index of a ring, return the index of the part (polygon) that contains the point.
template <typename IndexType>
CUSPATIAL_HOST_DEVICE auto part_idx_from_ring_idx(IndexType ring_idx);
/// Given the index of a part (polygon), return the index of the geometry (multipolygon) that
/// contains the part.
template <typename IndexType>
CUSPATIAL_HOST_DEVICE auto geometry_idx_from_part_idx(IndexType part_idx);
/// Returns the `multipolygon_idx`th multipolygon in the range.
template <typename IndexType>
CUSPATIAL_HOST_DEVICE auto operator[](IndexType multipolygon_idx);
/// Returns an iterator to the number of points of the first multipolygon
/// @note The count includes the duplicate first and last point of the ring.
CUSPATIAL_HOST_DEVICE auto multipolygon_point_count_begin();
/// Returns the one past the iterator to the number of points of the last multipolygon
/// @note The count includes the duplicate first and last point of the ring.
CUSPATIAL_HOST_DEVICE auto multipolygon_point_count_end();
/// Returns an iterator to the number of rings of the first multipolygon
CUSPATIAL_HOST_DEVICE auto multipolygon_ring_count_begin();
/// Returns the one past the iterator to the number of rings of the last multipolygon
CUSPATIAL_HOST_DEVICE auto multipolygon_ring_count_end();
/// @internal
/// Returns the owning class that provides views into the segments of the multipolygon range
/// Can only be constructed on host.
auto _segments(rmm::cuda_stream_view);
/// Range Casting
/// Cast the range of multipolygons as a range of multipoints, ignoring all edge connections and
/// ring relationships.
CUSPATIAL_HOST_DEVICE auto as_multipoint_range();
/// Cast the range of multipolygons as a range of multilinestrings, ignoring ring relationships.
CUSPATIAL_HOST_DEVICE auto as_multilinestring_range();
protected:
GeometryIterator _geometry_begin;
GeometryIterator _geometry_end;
PartIterator _part_begin;
PartIterator _part_end;
RingIterator _ring_begin;
RingIterator _ring_end;
VecIterator _point_begin;
VecIterator _point_end;
private:
template <typename IndexType1, typename IndexType2>
CUSPATIAL_HOST_DEVICE bool is_valid_segment_id(IndexType1 segment_idx, IndexType2 ring_idx);
};
/**
* @brief Create a multipoylgon_range object of from size and start iterators
*
* @tparam GeometryIteratorDiffType Integer type of the size of the geometry offset array
* @tparam PartIteratorDiffType Integer type of the size of the part offset array
* @tparam RingIteratorDiffType Integer type of the size of the ring offset array
* @tparam VecIteratorDiffType Integer type of the size of the point array
* @tparam GeometryIterator iterator type for offset array. Must meet
* the requirements of [LegacyRandomAccessIterator][LinkLRAI].
* @tparam PartIterator iterator type for offset array. Must meet
* the requirements of [LegacyRandomAccessIterator][LinkLRAI].
* @tparam RingIterator iterator type for offset array. Must meet
* the requirements of [LegacyRandomAccessIterator][LinkLRAI].
* @tparam VecIterator iterator type for the point array. Must meet
* the requirements of [LegacyRandomAccessIterator][LinkLRAI].
*
* @note Iterators should be device-accessible if the view is intended to be
* used on device.
*
* @param num_multipolygons Number of multipolygons in the array
* @param geometry_begin Iterator to the start of the geometry offset array
* @param num_polygons Number of polygons in the array
* @param part_begin Iterator to the start of the part offset array
* @param num_rings Number of rings in the array
* @param ring_begin Iterator to the start of the ring offset array
* @param num_points Number of underlying points in the multipoint array
* @param point_begin Iterator to the start of the points array
* @return range to multipolygon array
*
* [LinkLRAI]: https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator
* "LegacyRandomAccessIterator"
*/
template <typename GeometryIteratorDiffType,
typename PartIteratorDiffType,
typename RingIteratorDiffType,
typename VecIteratorDiffType,
typename GeometryIterator,
typename PartIterator,
typename RingIterator,
typename VecIterator>
multipolygon_range<GeometryIterator, PartIterator, RingIterator, VecIterator>
make_multipolygon_range(GeometryIteratorDiffType num_multipolygons,
GeometryIterator geometry_begin,
PartIteratorDiffType num_polygons,
PartIterator part_begin,
RingIteratorDiffType num_rings,
RingIterator ring_begin,
VecIteratorDiffType num_points,
VecIterator point_begin)
{
return multipolygon_range{
geometry_begin,
thrust::next(geometry_begin, num_multipolygons + 1),
part_begin,
thrust::next(part_begin, num_polygons + 1),
ring_begin,
thrust::next(ring_begin, num_rings + 1),
point_begin,
thrust::next(point_begin, num_points),
};
}
/**
* @brief Create a range object of multipolygon from cuspatial::geometry_column_view.
* Specialization for polygons column.
*
* @pre polygons_column must be a cuspatial::geometry_column_view
*/
template <collection_type_id Type,
typename T,
typename IndexType,
typename GeometryColumnView,
CUSPATIAL_ENABLE_IF(Type == collection_type_id::SINGLE)>
auto make_multipolygon_range(GeometryColumnView const& polygons_column)
{
CUSPATIAL_EXPECTS(polygons_column.geometry_type() == geometry_type_id::POLYGON,
"Must be polygon geometry type.");
auto geometry_iter = thrust::make_counting_iterator(0);
auto const& part_offsets = polygons_column.offsets();
auto const& ring_offsets = polygons_column.child().child(0);
auto const& points_xy =
polygons_column.child().child(1).child(1); // Ignores x-y offset {0, 2, 4...}
auto points_it = make_vec_2d_iterator(points_xy.template begin<T>());
return multipolygon_range(geometry_iter,
geometry_iter + part_offsets.size(),
part_offsets.template begin<IndexType>(),
part_offsets.template end<IndexType>(),
ring_offsets.template begin<IndexType>(),
ring_offsets.template end<IndexType>(),
points_it,
points_it + points_xy.size() / 2);
}
/**
* @brief Create a range object of multipolygon from cuspatial::geometry_column_view.
* Specialization for multipolygons column.
*
* @pre polygon_column must be a cuspatial::geometry_column_view
*/
template <collection_type_id Type,
typename T,
typename IndexType,
CUSPATIAL_ENABLE_IF(Type == collection_type_id::MULTI),
typename GeometryColumnView>
auto make_multipolygon_range(GeometryColumnView const& polygons_column)
{
CUSPATIAL_EXPECTS(polygons_column.geometry_type() == geometry_type_id::POLYGON,
"Must be polygon geometry type.");
auto const& geometry_offsets = polygons_column.offsets();
auto const& part_offsets = polygons_column.child().child(0);
auto const& ring_offsets = polygons_column.child().child(1).child(0);
auto const& points_xy =
polygons_column.child().child(1).child(1).child(1); // Ignores x-y offset {0, 2, 4...}
auto points_it = make_vec_2d_iterator(points_xy.template begin<T>());
return multipolygon_range(geometry_offsets.template begin<IndexType>(),
geometry_offsets.template end<IndexType>(),
part_offsets.template begin<IndexType>(),
part_offsets.template end<IndexType>(),
ring_offsets.template begin<IndexType>(),
ring_offsets.template end<IndexType>(),
points_it,
points_it + points_xy.size() / 2);
};
/**
* @} // end of doxygen group
*/
} // namespace cuspatial
#include <cuspatial/detail/range/multipolygon_range.cuh>
| 0 |
rapidsai_public_repos/cuspatial/cpp/include/cuspatial | rapidsai_public_repos/cuspatial/cpp/include/cuspatial/column/geometry_column_view.hpp | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <cuspatial/range/range.cuh>
#include <cuspatial/types.hpp>
#include <cudf/lists/lists_column_view.hpp>
#include <cudf/types.hpp>
namespace cuspatial {
/**
* @brief A non-owning, immutable view of a geometry column.
*
* @ingroup cuspatial_types
*
* A geometry column is GeoArrow compliant, except that the data type for
* the coordinates is List<T>, instead of FixedSizeList<T>[n_dim]. This is
* because libcudf does not support FixedSizeList type. Currently, an
* even sequence (0, 2, 4, ...) is used for the offsets of the coordinate
* column.
*/
class geometry_column_view : private cudf::lists_column_view {
public:
geometry_column_view(cudf::column_view const& column,
collection_type_id collection_type,
geometry_type_id geometry_type);
geometry_column_view(geometry_column_view&&) = default;
geometry_column_view(const geometry_column_view&) = default;
~geometry_column_view() = default;
geometry_column_view& operator=(geometry_column_view const&) = default;
geometry_column_view& operator=(geometry_column_view&&) = default;
geometry_type_id geometry_type() const { return _geometry_type; }
collection_type_id collection_type() const { return _collection_type; }
cudf::data_type coordinate_type() const;
using cudf::lists_column_view::child;
using cudf::lists_column_view::offsets;
using cudf::lists_column_view::size;
protected:
collection_type_id _collection_type;
geometry_type_id _geometry_type;
};
} // namespace cuspatial
| 0 |
rapidsai_public_repos/cuspatial/cpp | rapidsai_public_repos/cuspatial/cpp/cuproj/CMakeLists.txt | #=============================================================================
# Copyright (c) 2023, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================
cmake_minimum_required(VERSION 3.23.1 FATAL_ERROR)
include(../../fetch_rapids.cmake)
include(rapids-cmake)
include(rapids-cpm)
include(rapids-cuda)
include(rapids-export)
include(rapids-find)
rapids_cuda_init_architectures(CUPROJ)
project(CUPROJ VERSION 23.12.00 LANGUAGES C CXX CUDA)
# Needed because GoogleBenchmark changes the state of FindThreads.cmake,
# causing subsequent runs to have different values for the `Threads::Threads` target.
# Setting this flag ensures `Threads::Threads` is the same value in first run and subsequent runs.
set(THREADS_PREFER_PTHREAD_FLAG ON)
# Must come after enable_language(CUDA)
# Use `-isystem <path>` instead of `-isystem=<path>`
# because the former works with clangd intellisense
set(CMAKE_INCLUDE_SYSTEM_FLAG_CUDA "-isystem ")
###################################################################################################
# - build options ---------------------------------------------------------------------------------
option(BUILD_SHARED_LIBS "Build cuproj shared libraries" ON)
option(USE_NVTX "Build with NVTX support" ON)
option(BUILD_TESTS "Configure CMake to build tests" OFF)
option(BUILD_BENCHMARKS "Configure CMake to build (google) benchmarks" OFF)
option(PER_THREAD_DEFAULT_STREAM "Build with per-thread default stream" OFF)
option(DISABLE_DEPRECATION_WARNING "Disable warnings generated from deprecated declarations." OFF)
# Option to enable line info in CUDA device compilation to allow introspection when profiling / memchecking
option(CUDA_ENABLE_LINEINFO "Enable the -lineinfo option for nvcc (useful for cuda-memcheck / profiler" OFF)
# cudart can be statically linked or dynamically linked. The python ecosystem wants dynamic linking
option(CUDA_STATIC_RUNTIME "Statically link the CUDA toolkit runtime and libraries" OFF)
message(STATUS "CUPROJ: Build with NVTX support: ${USE_NVTX}")
message(STATUS "CUPROJ: Configure CMake to build tests: ${BUILD_TESTS}")
message(STATUS "CUPROJ: Configure CMake to build (google) benchmarks: ${BUILD_BENCHMARKS}")
message(STATUS "CUPROJ: Build with per-thread default stream: ${PER_THREAD_DEFAULT_STREAM}")
message(STATUS "CUPROJ: Disable warnings generated from deprecated declarations: ${DISABLE_DEPRECATION_WARNING}")
message(STATUS "CUPROJ: Enable the -lineinfo option for nvcc (useful for cuda-memcheck / profiler: ${CUDA_ENABLE_LINEINFO}")
message(STATUS "CUPROJ: Statically link the CUDA toolkit runtime and libraries: ${CUDA_STATIC_RUNTIME}")
# Set a default build type if none was specified
rapids_cmake_build_type("Release")
set(CUPROJ_BUILD_TESTS ${BUILD_TESTS})
set(CUPROJ_BUILD_BENCHMARKS ${BUILD_BENCHMARKS})
set(CUPROJ_CXX_FLAGS "")
set(CUPROJ_CUDA_FLAGS "")
set(CUPROJ_CXX_DEFINITIONS "")
set(CUPROJ_CUDA_DEFINITIONS "")
# Set RMM logging level
set(RMM_LOGGING_LEVEL "INFO" CACHE STRING "Choose the logging level.")
set_property(CACHE RMM_LOGGING_LEVEL PROPERTY STRINGS "TRACE" "DEBUG" "INFO" "WARN" "ERROR" "CRITICAL" "OFF")
message(STATUS "CUPROJ: RMM_LOGGING_LEVEL = '${RMM_LOGGING_LEVEL}'.")
###################################################################################################
# - compiler options ------------------------------------------------------------------------------
rapids_cuda_init_runtime(USE_STATIC ${CUDA_STATIC_RUNTIME})
# * find CUDAToolkit package
# * determine GPU architectures
# * enable the CMake CUDA language
# * set other CUDA compilation flags
include(cmake/modules/ConfigureCUDA.cmake)
###################################################################################################
# - dependencies ----------------------------------------------------------------------------------
# add third party dependencies using CPM
rapids_cpm_init()
include(cmake/thirdparty/get_rmm.cmake)
# find or install GoogleTest and Proj
if (CUPROJ_BUILD_TESTS)
include(cmake/thirdparty/get_gtest.cmake)
include(cmake/thirdparty/get_proj.cmake)
endif()
###################################################################################################
# - library targets -------------------------------------------------------------------------------
add_library(cuproj INTERFACE)
add_library(cuproj::cuproj ALIAS cuproj)
target_link_libraries(cuproj INTERFACE rmm::rmm)
set_target_properties(cuproj
PROPERTIES BUILD_RPATH "\$ORIGIN"
INSTALL_RPATH "\$ORIGIN"
# set target compile options
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
CUDA_STANDARD 17
CUDA_STANDARD_REQUIRED ON
POSITION_INDEPENDENT_CODE ON
INTERFACE_POSITION_INDEPENDENT_CODE ON
)
target_compile_options(cuproj
INTERFACE "$<$<COMPILE_LANGUAGE:CXX>:${CUPROJ_CXX_FLAGS}>"
"$<$<COMPILE_LANGUAGE:CUDA>:${CUPROJ_CUDA_FLAGS}>"
)
target_compile_definitions(cuproj
INTERFACE "$<$<COMPILE_LANGUAGE:CXX>:${CUPROJ_CXX_DEFINITIONS}>"
"$<$<COMPILE_LANGUAGE:CUDA>:${CUPROJ_CUDA_DEFINITIONS}>"
)
# Specify include paths for the current target and dependents
target_include_directories(cuproj
INTERFACE "$<BUILD_INTERFACE:${CUPROJ_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")
# Per-thread default stream
if(PER_THREAD_DEFAULT_STREAM)
target_compile_definitions(cuproj INTERFACE CUDA_API_PER_THREAD_DEFAULT_STREAM)
endif()
# Disable NVTX if necessary
if(NOT USE_NVTX)
target_compile_definitions(cuproj INTERFACE NVTX_DISABLE)
endif()
# Define spdlog level
target_compile_definitions(cuproj INTERFACE "SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${RMM_LOGGING_LEVEL}")
###################################################################################################
# - add tests -------------------------------------------------------------------------------------
if(CUPROJ_BUILD_TESTS)
# include CTest module -- automatically calls enable_testing()
include(CTest)
add_subdirectory(tests)
endif()
###################################################################################################
# - add benchmarks --------------------------------------------------------------------------------
if(CUPROJ_BUILD_BENCHMARKS)
# Find or install GoogleBench
include(${rapids-cmake-dir}/cpm/gbench.cmake)
rapids_cpm_gbench()
# Find or install NVBench Temporarily force downloading of fmt because current versions of nvbench
# do not support the latest version of fmt, which is automatically pulled into our conda
# environments by mamba.
set(CPM_DOWNLOAD_fmt TRUE)
include(${rapids-cmake-dir}/cpm/nvbench.cmake)
rapids_cpm_nvbench()
add_subdirectory(benchmarks)
endif()
###################################################################################################
# - install targets -------------------------------------------------------------------------------
rapids_cmake_install_lib_dir(lib_dir)
include(CPack)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME cuproj)
install(TARGETS cuproj
DESTINATION ${lib_dir}
EXPORT cuproj-exports)
install(DIRECTORY ${CUPROJ_SOURCE_DIR}/include/cuproj
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
set(doc_string
[=[
Provide targets for the cuproj library.
cuproj is a GPU-accelerated library for transformation of geospatial coordinates between coordinates
reference systems.
Imported Targets
^^^^^^^^^^^^^^^^
If cuproj is found, this module defines the following IMPORTED GLOBAL
targets:
cuproj::cuproj - The main cuproj library.
]=]
)
rapids_export(
INSTALL cuproj
EXPORT_SET cuproj-exports
GLOBAL_TARGETS cuproj
NAMESPACE cuproj::
DOCUMENTATION doc_string
)
################################################################################################
# - build export -------------------------------------------------------------------------------
rapids_export(
BUILD cuproj
EXPORT_SET cuproj-exports
GLOBAL_TARGETS cuproj
NAMESPACE cuproj::
DOCUMENTATION doc_string
)
# ##################################################################################################
# * build documentation ----------------------------------------------------------------------------
find_package(Doxygen)
if(DOXYGEN_FOUND)
# doc targets for cuproj
add_custom_command(
OUTPUT CUPROJ_DOXYGEN
WORKING_DIRECTORY ${CUPROJ_SOURCE_DIR}/doxygen
COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile
VERBATIM
COMMENT "Custom command for building cuproj doxygen docs."
)
add_custom_target(
docs_cuproj
DEPENDS CUPROJ_DOXYGEN
COMMENT "Custom command for building cuproj doxygen docs."
)
endif()
| 0 |
rapidsai_public_repos/cuspatial/cpp | rapidsai_public_repos/cuspatial/cpp/cuproj/README.md | # <div align="left"><img src="https://rapids.ai/assets/images/rapids_logo.png" width="90px"/> cuProj: GPU-Accelerated Coordinate Projection</div>
## Overview
cuProj is a generic coordinate transformation library that transforms geospatial coordinates from
one coordinate reference system (CRS) to another. This includes cartographic projections as well as
geodetic transformations. cuProj is implemented in CUDA C++ to run on GPUs to provide the highest
performance.
libcuproj is a CUDA C++ library that provides the header-only C++ API for cuProj. It is designed
to implement coordinate projections and transforms compatible with the [Proj](https://proj.org/)
library. The C++ API does not match the API of Proj, but it is designed to eventually expand to
support many of the same features and transformations that Proj supports.
Currently libcuproj only supports a subset of the Proj transformations. The following
transformations are supported:
- WGS84 to/from UTM
## Example
The C++ API is designed to be easy to use. The following example shows how to transform a point in
Sydney, Australia from WGS84 (lat, lon) coordinates to UTM zone 56S (x, y) coordinates.
```cpp
#include <cuproj/projection_factories.cuh>
#include <cuproj/vec_2d.hpp>
// Make a projection to convert WGS84 (lat, lon) coordinates to UTM zone 56S (x, y) coordinates
auto proj = cuproj::make_projection<cuproj::vec_2d<T>>("EPSG:4326", "EPSG:32756");
cuproj::vec_2d<T> sydney{-33.858700, 151.214000}; // Sydney, NSW, Australia
thrust::device_vector<cuproj::vec_2d<T>> d_in{1, sydney};
thrust::device_vector<cuproj::vec_2d<T>> d_out(d_in.size());
// Convert the coordinates. Works the same with a vector of many coordinates.
proj.transform(d_in.begin(), d_in.end(), d_out.begin(), cuproj::direction::FORWARD);
```
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj | rapidsai_public_repos/cuspatial/cpp/cuproj/include/doxygen_groups.h | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file
* @brief Doxygen group definitions
*/
// This header is only processed by doxygen and does
// not need to be included in any source file.
// Below are the main groups that doxygen uses to build
// the Modules page in the specified order.
//
// To add a new API to an existing group, just use the @ingroup tag in the API's Doxygen
// comment or @addtogroup in the file, inside the namespace.
// Add a new group by first specifying in the hierarchy below.
/**
* @defgroup constants Constants
* @{
* @brief Constants used in cuProj APIs
* @file constants.hpp
* @}
* @defgroup cuproj_types Types
* @{
* @brief Type declarations for cuproj
* @file ellipsoid.hpp
* @file projection.hpp
* @file vec_2d.hpp
* @}
* @defgroup projection_factories Projection Factory Functions
* @{
* @brief Factory functions to create coordinate projections
*
* These factories make it easier to create projections from a variety of sources.
* @file projection_factories.cuh
* @}
* @defgroup projection_parameters Projection Parameters
* @{
* @brief Projection parameters used in cuProj APIs
* @file projection_parameters.hpp
* @}
* @defgroup operations Operations
* @{
* @brief Projection pipeline operations
* @file operation/operation.cuh
* @file operation/axis_swap.cuh
* @file operation/clamp_angular_coordinates.cuh
* @file operation/degrees_to_radians.cuh
* @file operation/offset_scale_cartesian_coordinates.cuh
* @file operation/transverse_mercator.cuh
* @}
* @defgroup exception Exception
* @{
* @brief cuProj exception types
* @file error.hpp
* @}
*/
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj/include | rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj/constants.hpp | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <cmath>
namespace cuproj {
/**
* @addtogroup constants
* @{
*/
// TODO, use C++20 numerical constants when we can
/// Pi * 2.0
template <typename T>
static constexpr T M_TWOPI = T{2.0} * M_PI; // 6.283185307179586476925286766559005l;
/// Epsilon in radians used for hysteresis in wrapping angles to e.g. [-pi,pi]
template <typename T>
static constexpr T EPSILON_RADIANS = T{1e-12};
/// Conversion factor from degrees to radians
template <typename T>
constexpr T DEG_TO_RAD = T{0.017453292519943295769236907684886};
/// Conversion factor from radians to degrees
template <typename T>
constexpr T RAD_TO_DEG = T{57.295779513082320876798154814105};
/**
* @} // end of doxygen group
*/
} // namespace cuproj
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj/include | rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj/projection.cuh | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <cuproj/detail/pipeline.cuh>
#include <cuproj/ellipsoid.hpp>
#include <cuproj/operation/operation.cuh>
#include <cuproj/projection_parameters.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/device_vector.h>
#include <thrust/transform.h>
#include <iterator>
#include <type_traits>
namespace cuproj {
/**
* @addtogroup cuproj_types
* @{
* @file
*/
/**
* @brief A projection transforms coordinates between coordinate reference systems
*
* Projections are constructed from a list of operations to be applied to coordinates.
* The operations are applied in order, either forward or inverse.
*
* @tparam Coordinate the coordinate type
* @tparam T the coordinate value type
*/
template <typename Coordinate, typename T = typename Coordinate::value_type>
class projection {
public:
/**
* @brief Construct a new projection object
*
* @param operations the list of operations to apply to coordinates
* @param params the projection parameters
* @param dir the default order to execute the operations, FORWARD or INVERSE
*/
projection(std::vector<operation_type> const& operations,
projection_parameters<T> const& params,
direction dir = direction::FORWARD)
: params_(params), constructed_direction_(dir)
{
setup(operations);
}
/**
* @brief Transform a range of coordinates
*
* @tparam CoordIter the coordinate iterator type
* @param first the start of the coordinate range
* @param last the end of the coordinate range
* @param result the output coordinate range
* @param dir the direction of the transform, FORWARD or INVERSE. If INVERSE, the operations will
* run in the reverse order of the direction specified in the constructor.
* @param stream the CUDA stream on which to run the transform
*/
template <class InputCoordIter, class OutputCoordIter>
void transform(InputCoordIter first,
InputCoordIter last,
OutputCoordIter result,
direction dir,
rmm::cuda_stream_view stream = rmm::cuda_stream_default) const
{
dir = (constructed_direction_ == direction::FORWARD) ? dir : reverse(dir);
if (dir == direction::FORWARD) {
auto pipe = detail::pipeline<Coordinate, direction::FORWARD>{
params_, operations_.data().get(), operations_.size()};
thrust::transform(rmm::exec_policy(stream), first, last, result, pipe);
} else {
auto pipe = detail::pipeline<Coordinate, direction::INVERSE>{
params_, operations_.data().get(), operations_.size()};
thrust::transform(rmm::exec_policy(stream), first, last, result, pipe);
}
}
private:
void setup(std::vector<operation_type> const& operations)
{
std::for_each(operations.begin(), operations.end(), [&](auto const& op) {
switch (op) {
case operation_type::TRANSVERSE_MERCATOR: {
auto op = transverse_mercator<Coordinate>{params_};
params_ = op.setup(params_);
break;
}
// TODO: some ops don't have setup. Should we make them all have setup?
default: break;
}
});
operations_.resize(operations.size());
thrust::copy(operations.begin(), operations.end(), operations_.begin());
}
thrust::device_vector<operation_type> operations_;
projection_parameters<T> params_;
direction constructed_direction_{direction::FORWARD};
};
/**
* @} // end of doxygen group
*/
} // namespace cuproj
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj/include | rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj/error.hpp | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <cuproj/assert.cuh>
#include <cuda_runtime_api.h>
#include <stdexcept>
#include <string>
namespace cuproj {
/**
* @addtogroup exception
* @{
*/
/**
* @brief Exception thrown when logical precondition is violated.
*
* This exception should not be thrown directly and is instead thrown by the
* CUPROJ_EXPECTS macro.
*
*/
struct logic_error : public std::logic_error {
logic_error(char const* const message) : std::logic_error(message) {}
logic_error(std::string const& message) : std::logic_error(message) {}
};
/**
* @brief Exception thrown when a CUDA error is encountered.
*/
struct cuda_error : public std::runtime_error {
cuda_error(std::string const& message) : std::runtime_error(message) {}
};
/**
* @} // end of doxygen group
*/
} // namespace cuproj
#define CUPROJ_STRINGIFY_DETAIL(x) #x
#define CUPROJ_STRINGIFY(x) CUPROJ_STRINGIFY_DETAIL(x)
/**
* @brief Macro for checking (pre-)conditions that throws an exception when
* a condition is violated.
*
* Example usage:
*
* @code
* CUPROJ_EXPECTS(lhs->dtype == rhs->dtype, "Column type mismatch");
* @endcode
*
* @param[in] cond Expression that evaluates to true or false
* @param[in] reason String literal description of the reason that cond is
* expected to be true
* @throw cuproj::logic_error if the condition evaluates to false.
*/
#define CUPROJ_EXPECTS(cond, reason) \
(!!(cond)) ? static_cast<void>(0) \
: throw cuproj::logic_error("cuProj failure at: " __FILE__ \
":" CUPROJ_STRINGIFY(__LINE__) ": " reason)
/**
* @brief Macro for checking (pre-)conditions that throws an exception when
* a condition is violated.
*
* Example usage:
*
* @code
* CUPROJ_HOST_DEVICE_EXPECTS(lhs->dtype == rhs->dtype, "Column type
*mismatch");
* @endcode
*
* @param[in] cond Expression that evaluates to true or false
* @param[in] reason String literal description of the reason that cond is
* expected to be true
*
* (if on host)
* @throw cuproj::logic_error if the condition evaluates to false.
* (if on device)
* program terminates and assertion error message is printed to stderr.
*/
#ifndef __CUDA_ARCH__
#define CUPROJ_HOST_DEVICE_EXPECTS(cond, reason) CUPROJ_EXPECTS(cond, reason)
#else
#define CUPROJ_HOST_DEVICE_EXPECTS(cond, reason) cuproj_assert(cond&& reason)
#endif
/**
* @brief Indicates that an erroneous code path has been taken.
*
* In host code, throws a `cuproj::logic_error`.
*
*
* Example usage:
* ```
* CUPROJ_FAIL("Non-arithmetic operation is not supported");
* ```
*
* @param[in] reason String literal description of the reason
*/
#define CUPROJ_FAIL(reason) \
throw cuproj::logic_error("cuProj failure at: " __FILE__ ":" CUPROJ_STRINGIFY( \
__LINE__) ":" \
" " reason)
namespace cuproj {
namespace detail {
inline void throw_cuda_error(cudaError_t error, const char* file, unsigned int line)
{
throw cuproj::cuda_error(std::string{"CUDA error encountered at: " + std::string{file} + ":" +
std::to_string(line) + ": " + std::to_string(error) + " " +
cudaGetErrorName(error) + " " + cudaGetErrorString(error)});
}
} // namespace detail
} // namespace cuproj
/**
* @brief Error checking macro for CUDA runtime API functions.
*
* Invokes a CUDA runtime API function call, if the call does not return
* cudaSuccess, invokes cudaGetLastError() to clear the error and throws an
* exception detailing the CUDA error that occurred
*/
#define CUPROJ_CUDA_TRY(call) \
do { \
cudaError_t const status = (call); \
if (cudaSuccess != status) { \
cudaGetLastError(); \
cuproj::detail::throw_cuda_error(status, __FILE__, __LINE__); \
} \
} while (0);
/**
* @brief Debug macro to check for CUDA errors
*
* In a non-release build, this macro will synchronize the specified stream
* before error checking. In both release and non-release builds, this macro
* checks for any pending CUDA errors from previous calls. If an error is
* reported, an exception is thrown detailing the CUDA error that occurred.
*
* The intent of this macro is to provide a mechanism for synchronous and
* deterministic execution for debugging asynchronous CUDA execution. It should
* be used after any asynchronous CUDA call, e.g., cudaMemcpyAsync, or an
* asynchronous kernel launch.
*/
#ifndef NDEBUG
#define CUPROJ_CHECK_CUDA(stream) \
do { \
CUPROJ_CUDA_TRY(cudaStreamSynchronize(stream)); \
CUPROJ_CUDA_TRY(cudaPeekAtLastError()); \
} while (0);
#else
#define CUPROJ_CHECK_CUDA(stream) CUPROJ_CUDA_TRY(cudaPeekAtLastError());
#endif
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj/include | rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj/vec_2d.hpp | /*
* 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 <cuproj/detail/utility/cuda.hpp>
#include <cuproj/detail/utility/floating_point.hpp>
#include <algorithm>
#include <ostream>
namespace cuproj {
/**
* @addtogroup types
* @{
*/
/**
* @brief A generic 2D vector type.
*
* This is the base type used in cuspatial for both Longitude/Latitude (LonLat) coordinate pairs and
* Cartesian (X/Y) coordinate pairs. For LonLat pairs, the `x` member represents Longitude, and `y`
* represents Latitude.
*
* @tparam T the base type for the coordinates
*/
template <typename T>
class alignas(2 * sizeof(T)) vec_2d {
public:
using value_type = T;
value_type x;
value_type y;
private:
/**
* @brief Output stream operator for `vec_2d<T>` for human-readable formatting
*/
friend std::ostream& operator<<(std::ostream& os, vec_2d<T> const& vec)
{
return os << "(" << vec.x << "," << vec.y << ")";
}
/**
* @brief Compare two 2D vectors for equality.
*/
friend bool CUPROJ_HOST_DEVICE operator==(vec_2d<T> const& lhs, vec_2d<T> const& rhs)
{
return detail::float_equal<T>(lhs.x, rhs.x) && detail::float_equal(lhs.y, rhs.y);
}
/**
* @brief Element-wise addition of two 2D vectors.
*/
friend vec_2d<T> CUPROJ_HOST_DEVICE operator+(vec_2d<T> const& a, vec_2d<T> const& b)
{
return vec_2d<T>{a.x + b.x, a.y + b.y};
}
/**
* @brief Element-wise subtraction of two 2D vectors.
*/
friend vec_2d<T> CUPROJ_HOST_DEVICE operator-(vec_2d<T> const& a, vec_2d<T> const& b)
{
return vec_2d<T>{a.x - b.x, a.y - b.y};
}
/**
* @brief Invert a 2D vector.
*/
friend vec_2d<T> CUPROJ_HOST_DEVICE operator-(vec_2d<T> const& a)
{
return vec_2d<T>{-a.x, -a.y};
}
/**
* @brief Scale a 2D vector by a factor @p r.
*/
friend vec_2d<T> CUPROJ_HOST_DEVICE operator*(vec_2d<T> vec, T const& r)
{
return vec_2d<T>{vec.x * r, vec.y * r};
}
/**
* @brief Scale a 2d vector by ratio @p r.
*/
friend vec_2d<T> CUPROJ_HOST_DEVICE operator*(T const& r, vec_2d<T> vec) { return vec * r; }
/**
* @brief Translate a 2D point
*/
friend vec_2d<T>& CUPROJ_HOST_DEVICE operator+=(vec_2d<T>& a, vec_2d<T> const& b)
{
a.x += b.x;
a.y += b.y;
return a;
}
/**
* @brief Translate a 2D point
*/
friend vec_2d<T>& CUPROJ_HOST_DEVICE operator-=(vec_2d<T>& a, vec_2d<T> const& b)
{
return a += -b;
}
/**
* @brief Less than operator for two 2D points.
*
* Orders two points first by x, then by y.
*/
friend bool CUPROJ_HOST_DEVICE operator<(vec_2d<T> const& lhs, vec_2d<T> const& rhs)
{
if (lhs.x < rhs.x)
return true;
else if (lhs.x == rhs.x)
return lhs.y < rhs.y;
return false;
}
/**
* @brief Greater than operator for two 2D points.
*/
friend bool CUPROJ_HOST_DEVICE operator>(vec_2d<T> const& lhs, vec_2d<T> const& rhs)
{
return rhs < lhs;
}
/**
* @brief Less than or equal to operator for two 2D points.
*/
friend bool CUPROJ_HOST_DEVICE operator<=(vec_2d<T> const& lhs, vec_2d<T> const& rhs)
{
return !(lhs > rhs);
}
/**
* @brief Greater than or equal to operator for two 2D points.
*/
friend bool CUPROJ_HOST_DEVICE operator>=(vec_2d<T> const& lhs, vec_2d<T> const& rhs)
{
return !(lhs < rhs);
}
};
// Deduction guide enables CTAD
template <typename T>
vec_2d(T x, T y) -> vec_2d<T>;
/**
* @brief Compute dot product of two 2D vectors.
*/
template <typename T>
T CUPROJ_HOST_DEVICE dot(vec_2d<T> const& a, vec_2d<T> const& b)
{
return a.x * b.x + a.y * b.y;
}
/**
* @brief Compute 2D determinant of a 2x2 matrix with column vectors @p a and @p b.
*/
template <typename T>
T CUPROJ_HOST_DEVICE det(vec_2d<T> const& a, vec_2d<T> const& b)
{
return a.x * b.y - a.y * b.x;
}
/**
* @brief Return a new vec_2d made up of the minimum x- and y-components of two input vec_2d values.
*/
template <typename T>
vec_2d<T> CUPROJ_HOST_DEVICE box_min(vec_2d<T> const& a, vec_2d<T> const& b)
{
#ifdef __CUDA_ARCH__
return vec_2d<T>{::min(a.x, b.x), ::min(a.y, b.y)};
#else
return vec_2d<T>{std::min(a.x, b.x), std::min(a.y, b.y)};
#endif
}
/**
* @brief Return a new vec_2d made up of the minimum x- and y-components of two input vec_2d values.
*/
template <typename T>
vec_2d<T> CUPROJ_HOST_DEVICE box_max(vec_2d<T> const& a, vec_2d<T> const& b)
{
#ifdef __CUDA_ARCH__
return vec_2d<T>{::max(a.x, b.x), ::max(a.y, b.y)};
#else
return vec_2d<T>{std::max(a.x, b.x), std::max(a.y, b.y)};
#endif
}
/**
* @brief Compute the midpoint of `first` and `second`.
*/
template <typename T>
vec_2d<T> CUPROJ_HOST_DEVICE midpoint(vec_2d<T> const& first, vec_2d<T> const& second)
{
return (first + second) * T{0.5};
}
/**
* @} // end of doxygen group
*/
} // namespace cuproj
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj/include | rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj/assert.cuh | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <cuda_runtime.h>
/**
* @brief `assert`-like macro for device code
*
* This is effectively the same as the standard `assert` macro, except it
* relies on the `__PRETTY_FUNCTION__` macro which is specific to GCC and Clang
* to produce better assert messages.
*/
#if !defined(NDEBUG) && defined(__CUDA_ARCH__) && (defined(__clang__) || defined(__GNUC__))
#define __ASSERT_STR_HELPER(x) #x
#define cuproj_assert(e) \
((e) ? static_cast<void>(0) \
: __assert_fail(__ASSERT_STR_HELPER(e), __FILE__, __LINE__, __PRETTY_FUNCTION__))
#else
#define cuproj_assert(e) (static_cast<void>(0))
#endif
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj/include | rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj/ellipsoid.hpp | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <cassert>
#include <cmath>
namespace cuproj {
/**
* @addtogroup ellipsoid
* @{
*/
/**
* @brief Ellipsoid parameters
*
* @tparam T Floating point type
*/
template <typename T>
struct ellipsoid {
ellipsoid() = default;
/**
* @brief Construct an ellipsoid from semi-major axis and inverse flattening
*
* @param a Semi-major axis
* @param inverse_flattening Inverse flattening (a / (a - b), where b is the semi-minor axis)
*/
constexpr ellipsoid(T a, T inverse_flattening) : a(a)
{
assert(inverse_flattening != 0.0);
b = a * (1. - 1. / inverse_flattening);
f = 1.0 / inverse_flattening;
es = 2 * f - f * f;
e = sqrt(es);
alpha = asin(e);
n = pow(tan(alpha / 2), 2);
}
T a{}; // semi-major axis
T b{}; // semi-minor axis
T e{}; // first eccentricity
T es{}; // first eccentricity squared
T alpha{}; // angular eccentricity
T f{}; // flattening
T n{}; // third flattening
};
/**
* @brief Create the WGS84 ellipsoid
*
* @tparam T Floating point type
* @return The WGS84 ellipsoid
*/
template <typename T>
constexpr ellipsoid<T> make_ellipsoid_wgs84()
{
return ellipsoid<T>{T{6378137.0}, T{298.257223563}};
}
/**
* @} // end of doxygen group
*/
} // namespace cuproj
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj/include | rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj/projection_parameters.hpp | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <cuproj/ellipsoid.hpp>
namespace cuproj {
/**
* @addtogroup projection_parameters
* @{
*/
/**
* @brief Hemisphere identifier for projections
*/
enum class hemisphere { NORTH, SOUTH };
/**
* @brief Projection parameters
*
* Storage for parameters for projections. This is a POD type that is passed to
* the projection operators.
*
* @tparam T Coordinate value type
*/
template <typename T>
struct projection_parameters {
projection_parameters(
ellipsoid<T> const& e, int utm_zone, hemisphere utm_hemisphere, T lam0, T prime_meridian_offset)
: ellipsoid_(e),
utm_zone_(utm_zone),
utm_hemisphere_{utm_hemisphere},
lam0_(lam0),
prime_meridian_offset_(prime_meridian_offset)
{
}
ellipsoid<T> ellipsoid_{}; ///< Ellipsoid parameters
int utm_zone_{-1}; ///< UTM zone
hemisphere utm_hemisphere_{hemisphere::NORTH}; ///< UTM hemisphere
T lam0_{}; ///< Central meridian
T prime_meridian_offset_{}; ///< Offset from Greenwich
T k0{}; // scaling
T phi0{}; // central parallel
T x0{}; // false easting
T y0{}; // false northing
struct tmerc_params {
T Qn{}; // Meridian quadrant, scaled to the projection
T Zb{}; // Radius vector in polar coord. systems
T cgb[6]{}; // Constants for Gauss -> Geo lat
T cbg[6]{}; // Constants for Geo lat -> Gauss
T utg[6]{}; // Constants for transverse Mercator -> geo
T gtu[6]{}; // Constants for geo -> transverse Mercator
};
tmerc_params tmerc_params_{};
};
/**
* @} // end of doxygen group
*/
} // namespace cuproj
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj/include | rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj/projection_factories.cuh | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <cuproj/error.hpp>
#include <cuproj/projection.cuh>
#include <cuproj/projection_parameters.hpp>
#include <memory>
namespace cuproj {
/**
* @addtogroup projection_factories
* @{
*/
namespace detail {
/**
* @internal
* @brief A class to represent EPSG codes
*/
class epsg_code {
public:
/// Construct an epsg_code from a string
explicit epsg_code(std::string const& str) : str_(str)
{
std::transform(str_.begin(), str_.end(), str_.begin(), ::toupper);
CUPROJ_EXPECTS(valid_prefix(), "EPSG code must start with 'EPSG:'");
try {
epsg_ = std::stoi(str_.substr(str_.find_first_not_of("EPSG:")));
} catch (std::invalid_argument const&) {
CUPROJ_FAIL("Invalid EPSG code");
}
}
/// Construct an epsg_code from an integer
explicit epsg_code(int code) : str_("EPSG:" + std::to_string(code)), epsg_(code) {}
explicit operator std::string() const { return str_; } //< Return the EPSG code as a string
explicit operator int() const { return epsg_; } //< Return the EPSG code as an integer
// Return true if the EPSG code is for WGS84 (4326), false otherwise
inline bool is_wgs_84() const { return epsg_ == 4326; }
/// Return a [zone, hemisphere] pair for the UTM zone corresponding to the EPSG code
inline auto to_utm_zone()
{
if (epsg_ >= 32601 && epsg_ <= 32660) {
return std::make_pair(epsg_ - 32600, hemisphere::NORTH);
} else if (epsg_ >= 32701 && epsg_ <= 32760) {
return std::make_pair(epsg_ - 32700, hemisphere::SOUTH);
} else {
CUPROJ_FAIL("Unsupported UTM EPSG code. Must be in range [32601, 32760] or [32701, 32760]]");
}
}
private:
std::string str_;
int epsg_;
/// Return true if the EPSG code is valid, false otherwise
inline bool valid_prefix() const { return str_.find("EPSG:") == 0; }
};
} // namespace detail
/**
* @brief Create a WGS84<-->UTM projection for the given UTM zone and hemisphere
*
* @tparam Coordinate the coordinate type
* @tparam Coordinate::value_type the coordinate value type
* @param zone the UTM zone
* @param hemisphere the UTM hemisphere
* @param dir if FORWARD, create a projection from UTM to WGS84, otherwise create a projection
* from WGS84 to UTM
* @return a unique_ptr to a projection object implementing the requested transformation
*/
template <typename Coordinate, typename T = typename Coordinate::value_type>
projection<Coordinate>* make_utm_projection(int zone,
hemisphere hemisphere,
direction dir = direction::FORWARD)
{
projection_parameters<T> tmerc_proj_params{
make_ellipsoid_wgs84<T>(), zone, hemisphere, T{0}, T{0}};
std::vector<cuproj::operation_type> h_utm_pipeline{
operation_type::AXIS_SWAP,
operation_type::DEGREES_TO_RADIANS,
operation_type::CLAMP_ANGULAR_COORDINATES,
operation_type::TRANSVERSE_MERCATOR,
operation_type::OFFSET_SCALE_CARTESIAN_COORDINATES};
return new projection<Coordinate>(h_utm_pipeline, tmerc_proj_params, dir);
}
/**
* @brief Create a projection object from EPSG codes
*
* @throw cuproj::logic_error if the EPSG codes describe a transformation that is not supported
*
* @note Currently only WGS84 to UTM and UTM to WGS84 are supported, so one of the EPSG codes must
* be "EPSG:4326" (WGS84) and the other must be a UTM EPSG code.
*
* @tparam Coordinate the coordinate type
* @param src_epsg the source EPSG code
* @param dst_epsg the destination EPSG code
* @return a unique_ptr to a projection object implementing the transformation between the two EPSG
* codes
*/
template <typename Coordinate>
cuproj::projection<Coordinate>* make_projection(detail::epsg_code const& src_epsg,
detail::epsg_code const& dst_epsg)
{
detail::epsg_code src_code{src_epsg};
detail::epsg_code dst_code{dst_epsg};
auto dir = [&]() {
if (src_code.is_wgs_84()) {
return direction::FORWARD;
} else {
std::swap(src_code, dst_code);
CUPROJ_EXPECTS(src_code.is_wgs_84(), "Unsupported CRS combination.");
return direction::INVERSE;
}
}();
auto [dst_zone, dst_hemisphere] = dst_code.to_utm_zone();
return make_utm_projection<Coordinate>(dst_zone, dst_hemisphere, dir);
}
/**
* @brief Create a projection object from EPSG codes as "EPSG:XXXX" strings
*
* @throw cuproj::logic_error if the EPSG codes describe a transformation that is not supported
*
* @note Currently only WGS84 to UTM and UTM to WGS84 are supported, so one of the EPSG codes must
* be "EPSG:4326" (WGS84) and the other must be a UTM EPSG code.
*
* @note Auth strings are case insensitive
*
* @tparam Coordinate the coordinate type
* @param src_epsg the source EPSG code
* @param dst_epsg the destination EPSG code
* @return a pointer to a projection object implementing the transformation between the two EPSG
* codes
*/
template <typename Coordinate>
cuproj::projection<Coordinate>* make_projection(std::string const& src_epsg,
std::string const& dst_epsg)
{
detail::epsg_code src_code{src_epsg};
detail::epsg_code dst_code{dst_epsg};
return make_projection<Coordinate>(src_code, dst_code);
}
/**
* @brief Create a projection object from integer EPSG codes
*
* @throw cuproj::logic_error if the EPSG codes describe a transformation that is not supported
*
* @note Currently only WGS84 to UTM and UTM to WGS84 are supported, so one of the EPSG codes must
* be 4326 (WGS84) and the other must be a UTM EPSG code.
*
* @tparam Coordinate the coordinate type
* @param src_epsg the source EPSG code
* @param dst_epsg the destination EPSG code
* @return a pointer to a projection object implementing the transformation between the two EPSG
* codes
*/
template <typename Coordinate>
cuproj::projection<Coordinate>* make_projection(int src_epsg, int const& dst_epsg)
{
detail::epsg_code src_code{src_epsg};
detail::epsg_code dst_code{dst_epsg};
return make_projection<Coordinate>(detail::epsg_code(src_epsg), detail::epsg_code(dst_epsg));
}
/**
* @} // end of doxygen group
*/
} // namespace cuproj
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj | rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj/detail/wrap_to_pi.hpp | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <cuproj/constants.hpp>
#include <cuproj/detail/utility/cuda.hpp>
namespace cuproj {
namespace detail {
/**
* @brief Wrap/normalize an angle in radians to the -pi:pi range.
*
* @tparam T data type
* @param longitude The angle to normalize
* @return The normalized angle
*/
template <typename T>
CUPROJ_HOST_DEVICE T wrap_to_pi(T angle)
{
// Let angle slightly overshoot, to avoid spurious sign switching of longitudes at the date line
if (fabs(angle) < M_PI + EPSILON_RADIANS<T>) return angle;
// adjust to 0..2pi range
angle += M_PI;
// remove integral # of 'revolutions'
angle -= M_TWOPI<T> * floor(angle / M_TWOPI<T>);
// adjust back to -pi..pi range
return angle - M_PI;
}
} // namespace detail
} // namespace cuproj
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj | rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj/detail/wrap_to_pi.cuh | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <cuproj/constants.hpp>
namespace cuproj {
namespace detail {
/**
* @brief Wrap/normalize an angle in radians to the -pi:pi range.
*
* @tparam T data type
* @param longitude The angle to normalize
* @return The normalized angle
*/
template <typename T>
__host__ __device__ T wrap_to_pi(T angle)
{
// Let angle slightly overshoot, to avoid spurious sign switching of longitudes at the date line
if (fabs(angle) < M_PI + EPSILON_RADIANS<T>) return angle;
// adjust to 0..2pi range
angle += M_PI;
// remove integral # of 'revolutions'
angle -= M_TWOPI<T> * floor(angle / M_TWOPI<T>);
// adjust back to -pi..pi range
return angle - M_PI;
}
} // namespace detail
} // namespace cuproj
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj | rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj/detail/pipeline.cuh | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <cuproj/operation/axis_swap.cuh>
#include <cuproj/operation/clamp_angular_coordinates.cuh>
#include <cuproj/operation/degrees_to_radians.cuh>
#include <cuproj/operation/offset_scale_cartesian_coordinates.cuh>
#include <cuproj/operation/operation.cuh>
#include <cuproj/operation/transverse_mercator.cuh>
#include <thrust/execution_policy.h>
#include <thrust/for_each.h>
#include <iterator>
namespace cuproj {
namespace detail {
/**
* @internal
* @brief A pipeline of projection operations applied in order to a coordinate
*
* @tparam Coordinate the coordinate type
* @tparam dir The direction of the pipeline, FORWARD or INVERSE
* @tparam T the coordinate value type
*/
template <typename Coordinate,
direction dir = direction::FORWARD,
typename T = typename Coordinate::value_type>
class pipeline {
public:
using iterator_type = std::conditional_t<dir == direction::FORWARD,
operation_type const*,
std::reverse_iterator<operation_type const*>>;
/**
* @brief Construct a new pipeline object with the given operations and parameters
*
* @param params The projection parameters
* @param ops The operations to apply
* @param num_stages The number of operations to apply
*/
pipeline(projection_parameters<T> const& params,
operation_type const* ops,
std::size_t num_stages)
: params_(params), d_ops(ops), num_stages(num_stages)
{
if constexpr (dir == direction::FORWARD) {
first_ = d_ops;
} else {
first_ = std::reverse_iterator(d_ops + num_stages);
}
}
/**
* @brief Apply the pipeline to the given coordinate
*
* @param c The coordinate to transform
* @return The transformed coordinate
*/
__device__ Coordinate operator()(Coordinate const& c) const
{
Coordinate c_out{c};
thrust::for_each_n(thrust::seq, first_, num_stages, [&](auto const& op) {
switch (op) {
case operation_type::AXIS_SWAP: {
auto op = axis_swap<Coordinate>{};
c_out = op(c_out, dir);
break;
}
case operation_type::DEGREES_TO_RADIANS: {
auto op = degrees_to_radians<Coordinate>{};
c_out = op(c_out, dir);
break;
}
case operation_type::CLAMP_ANGULAR_COORDINATES: {
auto op = clamp_angular_coordinates<Coordinate>{params_};
c_out = op(c_out, dir);
break;
}
case operation_type::OFFSET_SCALE_CARTESIAN_COORDINATES: {
auto op = offset_scale_cartesian_coordinates<Coordinate>{params_};
c_out = op(c_out, dir);
break;
}
case operation_type::TRANSVERSE_MERCATOR: {
auto op = transverse_mercator<Coordinate>{params_};
c_out = op(c_out, dir);
break;
}
}
});
return c_out;
}
private:
projection_parameters<T> params_;
operation_type const* d_ops;
iterator_type first_;
std::size_t num_stages;
};
} // namespace detail
} // namespace cuproj
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj/detail | rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj/detail/utility/floating_point.hpp | /*
* 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 <cuproj/detail/utility/cuda.hpp>
#include <cmath>
#include <cstdint>
#include <type_traits>
namespace cuproj {
namespace detail {
constexpr unsigned default_max_ulp = 4;
template <int size, typename = void>
struct uint_selector;
template <int size>
struct uint_selector<size, std::enable_if_t<size == 2>> {
using type = uint16_t;
};
template <int size>
struct uint_selector<size, std::enable_if_t<size == 4>> {
using type = uint32_t;
};
template <int size>
struct uint_selector<size, std::enable_if_t<size == 8>> {
using type = uint64_t;
};
template <typename Bits>
Bits constexpr sign_bit_mask()
{
return Bits{1} << 8 * sizeof(Bits) - 1;
}
template <typename T>
union FloatingPointBits {
using Bits = typename uint_selector<sizeof(T)>::type;
CUPROJ_HOST_DEVICE FloatingPointBits(T float_number) : _f(float_number) {}
T _f;
Bits _b;
};
/**
* @internal
* @brief Converts integer of sign-magnitude representation to biased representation.
*
* Biased representation has 1 representation of zero while sign-magnitude has 2.
* This conversion will collapse the two representations into 1. This is in line with
* our expectation that a positive number 1 differ from a negative number -1 by 2 hops
* instead of 3 in biased representation.
*
* Example:
* Assume `N` bits in the type `Bits`. In total 2^(N-1) representable numbers.
* (N=4):
* |--------------| |-----------------|
* decimal -2^3+1 -0 +0 2^3-1
* SaM 1111 1000 0000 0111
*
* In SaM, 0 is represented twice. In biased representation we need to collapse
* them to single representation, resulting in 1 more representable number in
* biased form.
*
* Naturally, lowest bit should map to the smallest number representable in the range.
* With 1 more representable number in biased form, we discard the lowest bit and start
* at the next lowest bit.
* |--------------|-----------------|
* decimal -2^3+1 0 2^3-1
* biased 0001 0111 1110
*
* The following implements the mapping independently in negative and positive range.
*
* Read http://en.wikipedia.org/wiki/Signed_number_representations for more
* details on signed number representations.
*
* @tparam Bits Unsigned type to store the bits
* @param sam Sign and magnitude representation
* @return Biased representation
*/
template <typename Bits>
std::enable_if_t<std::is_unsigned_v<Bits>, Bits> CUPROJ_HOST_DEVICE
signmagnitude_to_biased(Bits const& sam)
{
return sam & sign_bit_mask<Bits>() ? ~sam + 1 : sam | sign_bit_mask<Bits>();
}
/**
* @brief Floating-point equivalence comparator based on ULP (Unit in the last place).
*
* @note to compare if two floating points `flhs` and `frhs` are equivalent,
* use float_equal(flhs, frhs), instead of `float_equal(flhs-frhs, 0)`.
* See "Infernal Zero" section of
* https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
*
* @tparam T Type of floating point
* @tparam max_ulp Maximum tolerable unit in the last place
* @param flhs First floating point to compare
* @param frhs Second floating point to compare
* @return `true` if two floating points differ by less or equal to `ulp`.
*/
template <typename T, unsigned max_ulp = default_max_ulp>
bool CUPROJ_HOST_DEVICE float_equal(T const& flhs, T const& frhs)
{
FloatingPointBits<T> lhs{flhs};
FloatingPointBits<T> rhs{frhs};
if (std::isnan(lhs._f) || std::isnan(rhs._f)) return false;
auto lhsbiased = signmagnitude_to_biased(lhs._b);
auto rhsbiased = signmagnitude_to_biased(rhs._b);
return lhsbiased >= rhsbiased ? (lhsbiased - rhsbiased) <= max_ulp
: (rhsbiased - lhsbiased) <= max_ulp;
}
} // namespace detail
} // namespace cuproj
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj/detail | rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj/detail/utility/cuda.hpp | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <utility>
#ifdef __CUDACC__
#define CUPROJ_HOST_DEVICE __host__ __device__
#else
#define CUPROJ_HOST_DEVICE
#endif
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj | rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj/operation/transverse_mercator.cuh | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Code in this file is originally from the [OSGeo/PROJ project](https://github.com/OSGeo/PROJ)
// and has been modified to run on the GPU using CUDA.
//
// PROJ License from https://github.com/OSGeo/PROJ/blob/9.2/COPYING:
// Note however that the file it is taken from did not have a copyright notice.
/*
Copyright information can be found in source files.
--------------
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
// The following text is taken from the PROJ file
// [tmerc.cpp](https://github.com/OSGeo/PROJ/blob/9.2/src/projections/tmerc.cpp)
// see the file LICENSE_PROJ in the cuspatial repository root directory for the original PROJ
// license text.
/*****************************************************************************/
//
// Exact Transverse Mercator functions
//
//
// The code in this file is largly based upon procedures:
//
// Written by: Knud Poder and Karsten Engsager
//
// Based on math from: R.Koenig and K.H. Weise, "Mathematische
// Grundlagen der hoeheren Geodaesie und Kartographie,
// Springer-Verlag, Berlin/Goettingen" Heidelberg, 1951.
//
// Modified and used here by permission of Reference Networks
// Division, Kort og Matrikelstyrelsen (KMS), Copenhagen, Denmark
//
/*****************************************************************************/
#pragma once
#include <cuproj/detail/utility/cuda.hpp>
#include <cuproj/detail/wrap_to_pi.hpp>
#include <cuproj/ellipsoid.hpp>
#include <cuproj/operation/operation.cuh>
#include <cuproj/projection_parameters.hpp>
#include <thrust/iterator/transform_iterator.h>
#include <assert.h>
namespace cuproj {
/**
* @addtogroup operations
* @{
*/
namespace detail {
/**
* @brief Evaluate Gaussian<-->Geographic trigonometric series
*
* @tparam T data type
* @param p1 pointer to the first element of the array
* @param len_p1 length of the array
* @param B The argument to the trigonometric series
* @param cos_2B precomputed cos(2*B)
* @param sin_2B precomputed sin(2*B)
* @return The value of the trigonometric series at B
*/
template <typename T>
inline static CUPROJ_HOST_DEVICE T gatg(T const* p1, int len_p1, T B, T cos_2B, T sin_2B)
{
T h = 0, h1, h2 = 0;
T const two_cos_2B = 2 * cos_2B;
T const* p = p1 + len_p1;
h1 = *--p;
while (p - p1) {
h = -h2 + two_cos_2B * h1 + *--p;
h2 = h1;
h1 = h;
}
return (B + h * sin_2B);
}
/**
* @brief Clenshaw summation for complex numbers
*
* @see https://en.wikipedia.org/wiki/Clenshaw_algorithm
*
* @tparam T data type
* @param a coefficients
* @param size size of coefficients
* @param sin_arg_r precomputed sin(arg_r)
* @param cos_arg_r precomputed cos(arg_r)
* @param sinh_arg_i precomputed sinh(arg_i)
* @param cosh_arg_i precomputed cosh(arg_i)
* @param R real part of the summation
* @param I imaginary part of the summation
* @return The real part of the summation at arg_r
*/
template <typename T>
inline static CUPROJ_HOST_DEVICE T clenshaw_complex(
T const* a, int size, T sin_arg_r, T cos_arg_r, T sinh_arg_i, T cosh_arg_i, T* R, T* I)
{
T r, i, hr, hr1, hr2, hi, hi1, hi2;
// arguments
T const* p = a + size;
r = 2 * cos_arg_r * cosh_arg_i;
i = -2 * sin_arg_r * sinh_arg_i;
// summation loop
hi1 = hr1 = hi = 0;
hr = *--p;
for (; a - p;) {
hr2 = hr1;
hi2 = hi1;
hr1 = hr;
hi1 = hi;
hr = -hr2 + r * hr1 - i * hi1 + *--p;
hi = -hi2 + i * hr1 + r * hi1;
}
r = sin_arg_r * cosh_arg_i;
i = cos_arg_r * sinh_arg_i;
*R = r * hr - i * hi;
*I = r * hi + i * hr;
return *R;
}
/**
* @brief Clenshaw summation for real numbers
*
* @see https://en.wikipedia.org/wiki/Clenshaw_algorithm
*
* @tparam T data type
* @param a pointer to array of coefficients
* @param size number of coefficients
* @param arg_r argument value
* @return the summation at arg_r
*/
template <typename T>
static CUPROJ_HOST_DEVICE T clenshaw_real(T const* a, int size, T arg_r)
{
T r, hr, hr1, hr2, cos_arg_r;
T const* p = a + size;
cos_arg_r = cos(arg_r);
r = 2 * cos_arg_r;
// summation loop
hr1 = 0;
hr = *--p;
for (; a - p;) {
hr2 = hr1;
hr1 = hr;
hr = -hr2 + r * hr1 + *--p;
}
return sin(arg_r) * hr;
}
} // namespace detail
template <typename Coordinate, typename T = typename Coordinate::value_type>
class transverse_mercator : operation<Coordinate> {
public:
static constexpr int ETMERC_ORDER = 6; ///< 6th order series expansion
/**
* @brief construct a transverse mercator projection
*
* @param params projection parameters
*/
CUPROJ_HOST_DEVICE transverse_mercator(projection_parameters<T> const& params) : params_(params)
{
}
/**
* @brief Perform UTM projection for a single coordinate
*
* @param coord the coordinate to project
* @param dir direction of projection
* @return projected coordinate
*/
CUPROJ_HOST_DEVICE Coordinate operator()(Coordinate const& coord, direction dir) const
{
if (dir == direction::FORWARD)
return forward(coord);
else
return inverse(coord);
}
static constexpr T utm_central_meridian = T{500000}; // false easting center of UTM zone
// false northing center of UTM zone
static constexpr T utm_central_parallel(hemisphere h)
{
return (h == hemisphere::NORTH) ? T{0} : T{10000000};
}
/**
* @brief Set up the projection parameters for transverse mercator projection
*
* @param input_params projection parameters
* @return projection parameters modified for transverse mercator projection
*/
projection_parameters<T> setup(projection_parameters<T> const& input_params)
{
params_ = input_params;
// so we don't have to qualify the class name everywhere.
auto& params = params_;
auto& tmerc_params = params_.tmerc_params_;
auto& ellipsoid = params_.ellipsoid_;
assert(ellipsoid.es > 0);
params.x0 = utm_central_meridian;
params.y0 = utm_central_parallel(params.utm_hemisphere_);
if (params.utm_zone_ > 0 && params.utm_zone_ <= 60) {
--params.utm_zone_;
} else {
params.utm_zone_ = lround((floor((detail::wrap_to_pi(params.lam0_) + M_PI) * 30. / M_PI)));
params.utm_zone_ = std::clamp(params.utm_zone_, 0, 59);
}
params.lam0_ = (params.utm_zone_ + .5) * M_PI / 30. - M_PI;
params.k0 = T{0.9996};
params.phi0 = T{0};
// third flattening
T const n = ellipsoid.n;
T np = n;
// COEFFICIENTS OF TRIG SERIES GEO <-> GAUSS
// cgb := Gaussian -> Geodetic, KW p190 - 191 (61) - (62)
// cbg := Geodetic -> Gaussian, KW p186 - 187 (51) - (52)
// ETMERC_ORDER = 6th degree : Engsager and Poder: ICC2007
tmerc_params.cgb[0] =
n *
(2 + n * (-2 / 3.0 + n * (-2 + n * (116 / 45.0 + n * (26 / 45.0 + n * (-2854 / 675.0))))));
tmerc_params.cbg[0] =
n * (-2 + n * (2 / 3.0 +
n * (4 / 3.0 + n * (-82 / 45.0 + n * (32 / 45.0 + n * (4642 / 4725.0))))));
np *= n;
tmerc_params.cgb[1] =
np * (7 / 3.0 + n * (-8 / 5.0 + n * (-227 / 45.0 + n * (2704 / 315.0 + n * (2323 / 945.0)))));
tmerc_params.cbg[1] =
np * (5 / 3.0 + n * (-16 / 15.0 + n * (-13 / 9.0 + n * (904 / 315.0 + n * (-1522 / 945.0)))));
np *= n;
// n^5 coeff corrected from 1262/105 -> -1262/105
tmerc_params.cgb[2] =
np * (56 / 15.0 + n * (-136 / 35.0 + n * (-1262 / 105.0 + n * (73814 / 2835.0))));
tmerc_params.cbg[2] =
np * (-26 / 15.0 + n * (34 / 21.0 + n * (8 / 5.0 + n * (-12686 / 2835.0))));
np *= n;
// n^5 coeff corrected from 322/35 -> 332/35
tmerc_params.cgb[3] = np * (4279 / 630.0 + n * (-332 / 35.0 + n * (-399572 / 14175.0)));
tmerc_params.cbg[3] = np * (1237 / 630.0 + n * (-12 / 5.0 + n * (-24832 / 14175.0)));
np *= n;
tmerc_params.cgb[4] = np * (4174 / 315.0 + n * (-144838 / 6237.0));
tmerc_params.cbg[4] = np * (-734 / 315.0 + n * (109598 / 31185.0));
np *= n;
tmerc_params.cgb[5] = np * (601676 / 22275.0);
tmerc_params.cbg[5] = np * (444337 / 155925.0);
// Constants of the projections
// Transverse Mercator (UTM, ITM, etc)
np = n * n;
// Norm. meridian quadrant, K&W p.50 (96), p.19 (38b), p.5 (2)
tmerc_params.Qn = params.k0 / (1 + n) * (1 + np * (1 / 4.0 + np * (1 / 64.0 + np / 256.0)));
// coef of trig series
// utg := ell. N, E -> sph. N, E, KW p194 (65)
// gtu := sph. N, E -> ell. N, E, KW p196 (69)
tmerc_params.utg[0] =
n * (-0.5 +
n * (2 / 3.0 +
n * (-37 / 96.0 + n * (1 / 360.0 + n * (81 / 512.0 + n * (-96199 / 604800.0))))));
tmerc_params.gtu[0] =
n * (0.5 + n * (-2 / 3.0 + n * (5 / 16.0 + n * (41 / 180.0 +
n * (-127 / 288.0 + n * (7891 / 37800.0))))));
tmerc_params.utg[1] =
np * (-1 / 48.0 +
n * (-1 / 15.0 + n * (437 / 1440.0 + n * (-46 / 105.0 + n * (1118711 / 3870720.0)))));
tmerc_params.gtu[1] =
np * (13 / 48.0 +
n * (-3 / 5.0 + n * (557 / 1440.0 + n * (281 / 630.0 + n * (-1983433 / 1935360.0)))));
np *= n;
tmerc_params.utg[2] =
np * (-17 / 480.0 + n * (37 / 840.0 + n * (209 / 4480.0 + n * (-5569 / 90720.0))));
tmerc_params.gtu[2] =
np * (61 / 240.0 + n * (-103 / 140.0 + n * (15061 / 26880.0 + n * (167603 / 181440.0))));
np *= n;
tmerc_params.utg[3] = np * (-4397 / 161280.0 + n * (11 / 504.0 + n * (830251 / 7257600.0)));
tmerc_params.gtu[3] = np * (49561 / 161280.0 + n * (-179 / 168.0 + n * (6601661 / 7257600.0)));
np *= n;
tmerc_params.utg[4] = np * (-4583 / 161280.0 + n * (108847 / 3991680.0));
tmerc_params.gtu[4] = np * (34729 / 80640.0 + n * (-3418889 / 1995840.0));
np *= n;
tmerc_params.utg[5] = np * (-20648693 / 638668800.0);
tmerc_params.gtu[5] = np * (212378941 / 319334400.0);
// Gaussian latitude value of the origin latitude
T const Z = detail::gatg(
tmerc_params.cbg, ETMERC_ORDER, params.phi0, cos(2 * params.phi0), sin(2 * params.phi0));
// Origin northing minus true northing at the origin latitude
// i.e. true northing = N - P->Zb
tmerc_params.Zb =
-tmerc_params.Qn * (Z + detail::clenshaw_real(tmerc_params.gtu, ETMERC_ORDER, 2 * Z));
return params;
}
private:
/**
* @brief Forward projection, from geographic to transverse mercator.
*
* @param coord Geographic coordinate (lat, lon) in radians.
* @return Transverse mercator coordinate (x, y) in meters.
*/
CUPROJ_HOST_DEVICE Coordinate forward(Coordinate const& coord) const
{
// so we don't have to qualify the class name everywhere.
auto& tmerc_params = this->params_.tmerc_params_;
auto& ellipsoid = this->params_.ellipsoid_;
// ell. LAT, LNG -> Gaussian LAT, LNG
T Cn =
detail::gatg(tmerc_params.cbg, ETMERC_ORDER, coord.y, cos(2 * coord.y), sin(2 * coord.y));
// Gaussian LAT, LNG -> compl. sph. LAT
T const sin_Cn = sin(Cn);
T const cos_Cn = cos(Cn);
T const sin_Ce = sin(coord.x);
T const cos_Ce = cos(coord.x);
T const cos_Cn_cos_Ce = cos_Cn * cos_Ce;
Cn = atan2(sin_Cn, cos_Cn_cos_Ce);
T const inv_denom_tan_Ce = 1. / hypot(sin_Cn, cos_Cn_cos_Ce);
T const tan_Ce = sin_Ce * cos_Cn * inv_denom_tan_Ce;
// Variant of the above: found not to be measurably faster
// T const sin_Ce_cos_Cn = sin_Ce*cos_Cn;
// T const denom = sqrt(1 - sin_Ce_cos_Cn * sin_Ce_cos_Cn);
// T const tan_Ce = sin_Ce_cos_Cn / denom;
// compl. sph. N, E -> ell. norm. N, E
T Ce = asinh(tan_Ce); /* Replaces: Ce = log(tan(FORTPI + Ce*0.5)); */
// Non-optimized version:
// T const sin_arg_r = sin(2*Cn);
// T const cos_arg_r = cos(2*Cn);
//
// Given:
// sin(2 * Cn) = 2 sin(Cn) cos(Cn)
// sin(atan(y)) = y / sqrt(1 + y^2)
// cos(atan(y)) = 1 / sqrt(1 + y^2)
// ==> sin(2 * Cn) = 2 tan_Cn / (1 + tan_Cn^2)
//
// cos(2 * Cn) = 2cos^2(Cn) - 1
// = 2 / (1 + tan_Cn^2) - 1
//
T const two_inv_denom_tan_Ce = 2 * inv_denom_tan_Ce;
T const two_inv_denom_tan_Ce_square = two_inv_denom_tan_Ce * inv_denom_tan_Ce;
T const tmp_r = cos_Cn_cos_Ce * two_inv_denom_tan_Ce_square;
T const sin_arg_r = sin_Cn * tmp_r;
T const cos_arg_r = cos_Cn_cos_Ce * tmp_r - 1;
// Non-optimized version:
// T const sinh_arg_i = sinh(2*Ce);
// T const cosh_arg_i = cosh(2*Ce);
//
// Given
// sinh(2 * Ce) = 2 sinh(Ce) cosh(Ce)
// sinh(asinh(y)) = y
// cosh(asinh(y)) = sqrt(1 + y^2)
// ==> sinh(2 * Ce) = 2 tan_Ce sqrt(1 + tan_Ce^2)
//
// cosh(2 * Ce) = 2cosh^2(Ce) - 1
// = 2 * (1 + tan_Ce^2) - 1
//
// and 1+tan_Ce^2 = 1 + sin_Ce^2 * cos_Cn^2 / (sin_Cn^2 + cos_Cn^2 *
// cos_Ce^2) = (sin_Cn^2 + cos_Cn^2 * cos_Ce^2 + sin_Ce^2 * cos_Cn^2) /
// (sin_Cn^2 + cos_Cn^2 * cos_Ce^2) = 1. / (sin_Cn^2 + cos_Cn^2 * cos_Ce^2)
// = inv_denom_tan_Ce^2
T const sinh_arg_i = tan_Ce * two_inv_denom_tan_Ce;
T const cosh_arg_i = two_inv_denom_tan_Ce_square - 1;
T dCn, dCe;
Cn += detail::clenshaw_complex(
tmerc_params.gtu, ETMERC_ORDER, sin_arg_r, cos_arg_r, sinh_arg_i, cosh_arg_i, &dCn, &dCe);
Ce += dCe;
CUPROJ_HOST_DEVICE_EXPECTS(fabs(Ce) <= 2.623395162778, // value comes from PROJ
"Coordinate transform outside projection domain");
Coordinate xy{0.0, 0.0};
xy.y = tmerc_params.Qn * Cn + tmerc_params.Zb; // Northing
xy.x = tmerc_params.Qn * Ce; // Easting
return xy;
}
/**
* @brief inverse transform, from projected to geographic coordinate
* @param coord projected coordinate (x, y) in meters
* @return geographic coordinate (lon, lat) in radians
*/
CUPROJ_HOST_DEVICE Coordinate inverse(Coordinate const& coord) const
{
// so we don't have to qualify the class name everywhere.
auto& tmerc_params = this->params_.tmerc_params_;
auto& ellipsoid = this->params_.ellipsoid_;
// normalize N, E
T Cn = (coord.y - tmerc_params.Zb) / tmerc_params.Qn;
T Ce = coord.x / tmerc_params.Qn;
CUPROJ_HOST_DEVICE_EXPECTS(fabs(Ce) <= 2.623395162778, // value comes from PROJ
"Coordinate transform outside projection domain");
// norm. N, E -> compl. sph. LAT, LNG
T const sin_arg_r = sin(2 * Cn);
T const cos_arg_r = cos(2 * Cn);
// T const sinh_arg_i = sinh(2*Ce);
// T const cosh_arg_i = cosh(2*Ce);
T const exp_2_Ce = exp(2 * Ce);
T const half_inv_exp_2_Ce = T{0.5} / exp_2_Ce;
T const sinh_arg_i = T{0.5} * exp_2_Ce - half_inv_exp_2_Ce;
T const cosh_arg_i = T{0.5} * exp_2_Ce + half_inv_exp_2_Ce;
T dCn_ignored, dCe;
Cn += detail::clenshaw_complex(tmerc_params.utg,
ETMERC_ORDER,
sin_arg_r,
cos_arg_r,
sinh_arg_i,
cosh_arg_i,
&dCn_ignored,
&dCe);
Ce += dCe;
// compl. sph. LAT -> Gaussian LAT, LNG
T const sin_Cn = sin(Cn);
T const cos_Cn = cos(Cn);
#if 0
// Non-optimized version:
T sin_Ce, cos_Ce;
Ce = atan (sinh (Ce)); // Replaces: Ce = 2*(atan(exp(Ce)) - FORTPI);
sin_Ce = sin (Ce);
cos_Ce = cos (Ce);
Ce = atan2 (sin_Ce, cos_Ce*cos_Cn);
Cn = atan2 (sin_Cn*cos_Ce, hypot (sin_Ce, cos_Ce*cos_Cn));
#else
// One can divide both member of Ce = atan2(...) by cos_Ce, which
// gives: Ce = atan2 (tan_Ce, cos_Cn) = atan2(sinh(Ce), cos_Cn)
//
// and the same for Cn = atan2(...)
// Cn = atan2 (sin_Cn, hypot (sin_Ce, cos_Ce*cos_Cn)/cos_Ce)
// = atan2 (sin_Cn, hypot (sin_Ce/cos_Ce, cos_Cn))
// = atan2 (sin_Cn, hypot (tan_Ce, cos_Cn))
// = atan2 (sin_Cn, hypot (sinhCe, cos_Cn))
T const sinhCe = sinh(Ce);
Ce = atan2(sinhCe, cos_Cn);
T const modulus_Ce = hypot(sinhCe, cos_Cn);
Cn = atan2(sin_Cn, modulus_Ce);
#endif
// Gaussian LAT, LNG -> ell. LAT, LNG
// Optimization of the computation of cos(2*Cn) and sin(2*Cn)
T const tmp = 2 * modulus_Ce / (sinhCe * sinhCe + 1);
T const sin_2_Cn = sin_Cn * tmp;
T const cos_2_Cn = tmp * modulus_Ce - 1.;
// T const cos_2_Cn = cos(2 * Cn);
// T const sin_2_Cn = sin(2 * Cn);
return Coordinate{Ce, detail::gatg(tmerc_params.cgb, ETMERC_ORDER, Cn, cos_2_Cn, sin_2_Cn)};
}
/**
* @brief Get the origin longitude
*
* @return the origin longitude in radians
*/
T lam0() const { return this->params_.lam0_; }
private:
projection_parameters<T> params_{};
};
/**
* @} // end of doxygen group
*/
} // namespace cuproj
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj | rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj/operation/clamp_angular_coordinates.cuh | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <cuproj/detail/utility/cuda.hpp>
#include <cuproj/detail/wrap_to_pi.hpp>
#include <cuproj/error.hpp>
#include <cuproj/operation/operation.cuh>
#include <cuproj/projection_parameters.hpp>
#include <thrust/iterator/transform_iterator.h>
#include <algorithm>
namespace cuproj {
/**
* @addtogroup operations
* @{
*/
/**
* @brief Clamp angular coordinates to the valid range and offset by the central meridian (lam0) and
* an optional prime meridian offset.
*
* @tparam Coordinate the coordinate type
* @tparam T the coordinate value type
*/
template <typename Coordinate, typename T = typename Coordinate::value_type>
class clamp_angular_coordinates : operation<Coordinate> {
public:
/**
* @brief Construct a new clamp angular coordinates object
*
* @param params the projection parameters
*/
CUPROJ_HOST_DEVICE clamp_angular_coordinates(projection_parameters<T> const& params)
: lam0_(params.lam0_), prime_meridian_offset_(params.prime_meridian_offset_)
{
}
// projection_parameters<T> setup(projection_parameters<T> const& params) { return params; }
/**
* @brief Clamp angular coordinate to the valid range
*
* @param coord The coordinate to clamp
* @param dir The direction of the operation
* @return The clamped coordinate
*/
CUPROJ_HOST_DEVICE Coordinate operator()(Coordinate const& coord, direction dir) const
{
if (dir == direction::FORWARD)
return forward(coord);
else
return inverse(coord);
}
private:
/**
* @brief Forward clamping operation
*
* Offsets the longitude by the prime meridian offset and central meridian (lam0) and clamps the
* latitude to the range -pi/2..pi/2 radians (-90..90 degrees) and the longitude to the range
* -pi..pi radians (-180..180 degrees).
*
* @param coord The coordinate to clamp
* @return The clamped coordinate
*/
CUPROJ_HOST_DEVICE Coordinate forward(Coordinate const& coord) const
{
// check for latitude or longitude over-range
T t = (coord.y < 0 ? -coord.y : coord.y) - M_PI_2;
CUPROJ_HOST_DEVICE_EXPECTS(t <= EPSILON_RADIANS<T>, "Invalid latitude");
CUPROJ_HOST_DEVICE_EXPECTS(coord.x <= 10 || coord.x >= -10, "Invalid longitude");
Coordinate xy = coord;
/* Clamp latitude to -pi/2..pi/2 degree range */
auto half_pi = static_cast<T>(M_PI_2);
xy.y = std::clamp(xy.y, -half_pi, half_pi);
// Distance from central meridian, taking system zero meridian into account
xy.x = (xy.x - prime_meridian_offset_) - lam0_;
// Ensure longitude is in the -pi:pi range
xy.x = detail::wrap_to_pi(xy.x);
return xy;
}
/**
* @brief Inverse clamping operation
*
* Reverse-offsets the longitude by the prime meridian offset and central meridian
* and clamps the longitude to the range -pi..pi radians (-180..180 degrees)
*
* @param coord The coordinate to clamp
* @return The clamped coordinate
*/
CUPROJ_HOST_DEVICE Coordinate inverse(Coordinate const& coord) const
{
Coordinate xy = coord;
// Distance from central meridian, taking system zero meridian into account
xy.x += prime_meridian_offset_ + lam0_;
// Ensure longitude is in the -pi:pi range
xy.x = detail::wrap_to_pi(xy.x);
return xy;
}
T lam0_{}; // central meridian
T prime_meridian_offset_{};
};
/**
* @} // end of doxygen group
*/
} // namespace cuproj
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj | rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj/operation/offset_scale_cartesian_coordinates.cuh | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <cuproj/detail/utility/cuda.hpp>
#include <cuproj/ellipsoid.hpp>
#include <cuproj/operation/operation.cuh>
#include <cuproj/projection_parameters.hpp>
#include <thrust/iterator/transform_iterator.h>
#include <algorithm>
namespace cuproj {
/**
* @addtogroup operations
* @{
*/
/**
* @brief Given Cartesian coordinates (x, y) in meters, offset and scale them
* to the projection's origin and scale (ellipsoidal semi-major axis).
*
* @tparam Coordinate coordinate type
* @tparam T coordinate value type
*/
template <typename Coordinate, typename T = typename Coordinate::value_type>
class offset_scale_cartesian_coordinates : operation<Coordinate> {
public:
/**
* @brief Constructor
*
* @param params projection parameters, including the ellipsoid semi-major axis
* and the projection origin
*/
CUPROJ_HOST_DEVICE offset_scale_cartesian_coordinates(projection_parameters<T> const& params)
: a_(params.ellipsoid_.a), ra_(T{1.0} / a_), x0_(params.x0), y0_(params.y0)
{
}
/**
* @brief Offset and scale a single coordinate
*
* @param coord the coordinate to offset and scale
* @param dir the direction of the operation, either forward or inverse
* @return the offset and scaled coordinate
*/
CUPROJ_HOST_DEVICE Coordinate operator()(Coordinate const& coord, direction dir) const
{
if (dir == direction::FORWARD)
return forward(coord);
else
return inverse(coord);
}
private:
/**
* @brief Scale a coordinate by the ellipsoid semi-major axis and offset it by
* the projection origin
*
* @param coord the coordinate to offset and scale
* @return the offset and scaled coordinate
*/
CUPROJ_HOST_DEVICE Coordinate forward(Coordinate const& coord) const
{
return coord * a_ + Coordinate{x0_, y0_};
};
/**
* @brief Offset a coordinate by the projection origin and scale it by the
* inverse of the ellipsoid semi-major axis
*
* @param coord the coordinate to offset and scale
* @return the offset and scaled coordinate
*/
CUPROJ_HOST_DEVICE Coordinate inverse(Coordinate const& coord) const
{
return (coord - Coordinate{x0_, y0_}) * ra_;
};
T a_; // ellipsoid semi-major axis
T ra_; // inverse of ellipsoid semi-major axis
T x0_; // projection origin x
T y0_; // projection origin y
};
/**
* @} // end of doxygen group
*/
} // namespace cuproj
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj | rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj/operation/axis_swap.cuh | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <cuproj/detail/utility/cuda.hpp>
#include <cuproj/operation/operation.cuh>
namespace cuproj {
/**
* @addtogroup operations
* @{
*/
/**
* @brief Axis swap operation: swap x and y coordinates
*
* @tparam Coordinate the coordinate type
*/
template <typename Coordinate>
struct axis_swap : operation<Coordinate> {
/**
* @brief Swap x and y coordinates
*
* @param coord the coordinate to swap
* @param dir (unused) the direction of the operation
* @return the swapped coordinate
*/
CUPROJ_HOST_DEVICE Coordinate operator()(Coordinate const& coord, direction) const
{
return Coordinate{coord.y, coord.x};
}
};
/**
* @} // end of doxygen group
*/
} // namespace cuproj
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj | rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj/operation/operation.cuh | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <cuproj/detail/utility/cuda.hpp>
#include <cuproj/projection_parameters.hpp>
namespace cuproj {
/**
* @addtogroup operations
* @{
*/
/**
* @brief Enumerates the different types of transform operations
*
* This enum is used to identify the type of transform operation in the transform pipeline. Each
* operation_type has a corresponding class that implements the operation.
*/
enum operation_type {
AXIS_SWAP,
DEGREES_TO_RADIANS,
CLAMP_ANGULAR_COORDINATES,
OFFSET_SCALE_CARTESIAN_COORDINATES,
TRANSVERSE_MERCATOR
};
/// Enumerates the direction of a transform operation
enum direction { FORWARD, INVERSE };
/// Returns the opposite of a direction
inline direction reverse(direction dir)
{
return dir == direction::FORWARD ? direction::INVERSE : direction::FORWARD;
}
/**
* @brief Base class for all transform operations
*
* This class is used to define the interface for all transform operations. A transform operation
* is a function object that takes a coordinate and returns a coordinate. Operations are composed
* together to form a transform pipeline by cuproj::projection.
*
* @tparam Coordinate
* @tparam Coordinate::value_type
*/
template <typename Coordinate, typename T = typename Coordinate::value_type>
class operation {
public:
/**
* @brief Applies the transform operation to a coordinate
*
* @param c Coordinate to transform
* @param dir Direction of transform
* @return Coordinate
*/
CUPROJ_HOST_DEVICE Coordinate operator()(Coordinate const& c, direction dir) const { return c; }
/**
* @brief Modifies the projection parameters for the transform operation
*
* Some (but not all) operations require additional parameters to be set in the projection_params
* object. This function is called by cuproj::projection::setup() to allow the operation to
* modify the parameters as needed.
*
* The final project_parameters are passed to every operation in the transform pipeline.
*
* @param params Projection parameters
* @return The modified parameters
*/
projection_parameters<T> setup(projection_parameters<T> const& params) { return params; };
};
/**
* @} // end of doxygen group
*/
} // namespace cuproj
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj | rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj/operation/degrees_to_radians.cuh | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <cuproj/constants.hpp>
#include <cuproj/detail/utility/cuda.hpp>
#include <cuproj/operation/operation.cuh>
namespace cuproj {
/**
* @addtogroup operations
* @{
*/
/**
* @brief Converts degrees to radians and vice versa
*
* @tparam Coordinate The coordinate type
*/
template <typename Coordinate>
class degrees_to_radians : operation<Coordinate> {
public:
/**
* @brief Converts degrees to radians and vice versa
*
* @param coord The coordinate to convert
* @param dir The direction of the conversion: FORWARD converts degrees to radians, INVERSE
* converts radians to degrees
* @return The converted coordinate
*/
CUPROJ_HOST_DEVICE Coordinate operator()(Coordinate const& coord, direction dir) const
{
if (dir == direction::FORWARD)
return forward(coord);
else
return inverse(coord);
}
private:
/**
* @brief Converts degrees to radians
*
* @param coord The coordinate to convert (lat, lon) in degrees
* @return The converted coordinate (lat, lon) in radians
*/
CUPROJ_HOST_DEVICE Coordinate forward(Coordinate const& coord) const
{
using T = typename Coordinate::value_type;
return Coordinate{coord.x * DEG_TO_RAD<T>, coord.y * DEG_TO_RAD<T>};
}
/**
* @brief Converts radians to degrees
*
* @param coord The coordinate to convert (lat, lon) in radians
* @return The converted coordinate (lat, lon) in degrees
*/
CUPROJ_HOST_DEVICE Coordinate inverse(Coordinate const& coord) const
{
using T = typename Coordinate::value_type;
return Coordinate{coord.x * RAD_TO_DEG<T>, coord.y * RAD_TO_DEG<T>};
}
};
/**
* @} // end of doxygen group
*/
} // namespace cuproj
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj/include | rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj_test/coordinate_generator.cuh | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <rmm/exec_policy.hpp>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/iterator/transform_iterator.h>
#include <thrust/tabulate.h>
namespace cuproj_test {
// Generate a grid of coordinates
template <typename Coord>
struct grid_generator {
Coord min_corner{};
Coord max_corner{};
Coord spacing{};
int num_points_x{};
grid_generator(Coord const& min_corner,
Coord const& max_corner,
int num_points_x,
int num_points_y)
: min_corner(min_corner), max_corner(max_corner), num_points_x(num_points_x)
{
spacing = Coord{(max_corner.x - min_corner.x) / num_points_x,
(max_corner.y - min_corner.y) / num_points_y};
}
__device__ Coord operator()(int i) const
{
return min_corner + Coord{(i % num_points_x) * spacing.x, (i / num_points_x) * spacing.y};
}
};
// Create a Vector containing a grid of coordinates between the min and max corners
template <typename Coord, typename Vector>
auto make_grid_array(Coord const& min_corner,
Coord const& max_corner,
int num_points_x,
int num_points_y)
{
auto gen = grid_generator(min_corner, max_corner, num_points_x, num_points_y);
Vector grid(num_points_x * num_points_y);
thrust::tabulate(rmm::exec_policy(), grid.begin(), grid.end(), gen);
return grid;
}
} // namespace cuproj_test
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj/include | rapidsai_public_repos/cuspatial/cpp/cuproj/include/cuproj_test/convert_coordinates.hpp | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <proj.h>
#include <algorithm>
#include <type_traits>
namespace cuproj_test {
// Convert coordinates from a x-y struct to a PJ_COORD struct or vice versa
template <typename InVector, typename OutVector>
void convert_coordinates(InVector const& in, OutVector& out)
{
using in_coord_type = typename InVector::value_type;
using out_coord_type = typename OutVector::value_type;
static_assert(
(std::is_same_v<out_coord_type, PJ_COORD> != std::is_same_v<in_coord_type, PJ_COORD>),
"Invalid coordinate vector conversion");
if constexpr (std::is_same_v<in_coord_type, PJ_COORD>) {
using T = typename out_coord_type::value_type;
auto proj_coord_to_coordinate = [](auto const& c) {
return out_coord_type{static_cast<T>(c.xy.x), static_cast<T>(c.xy.y)};
};
std::transform(in.begin(), in.end(), out.begin(), proj_coord_to_coordinate);
} else if constexpr (std::is_same_v<out_coord_type, PJ_COORD>) {
auto coordinate_to_proj_coord = [](auto const& c) { return PJ_COORD{c.x, c.y, 0, 0}; };
std::transform(in.begin(), in.end(), out.begin(), coordinate_to_proj_coord);
}
}
} // namespace cuproj_test
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj | rapidsai_public_repos/cuspatial/cpp/cuproj/tests/CMakeLists.txt | #=============================================================================
# Copyright (c) 2023, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================
###################################################################################################
# - compiler function -----------------------------------------------------------------------------
function(ConfigureTest CMAKE_TEST_NAME)
add_executable(${CMAKE_TEST_NAME} ${ARGN})
target_compile_options(${CMAKE_TEST_NAME}
PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${CUPROJ_CXX_FLAGS}>"
"$<$<COMPILE_LANGUAGE:CUDA>:${CUPROJ_CUDA_FLAGS}>")
target_include_directories(${CMAKE_TEST_NAME}
PRIVATE "$<BUILD_INTERFACE:${CUPROJ_SOURCE_DIR}>"
"$<BUILD_INTERFACE:${CUPROJ_SOURCE_DIR}/src>"
../../../cpp/include)
set_target_properties(
${CMAKE_TEST_NAME}
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "$<BUILD_INTERFACE:${CUPROJ_BINARY_DIR}/gtests>"
INSTALL_RPATH "\$ORIGIN/../../../lib"
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
CUDA_STANDARD 17
CUDA_STANDARD_REQUIRED ON
)
target_link_libraries(${CMAKE_TEST_NAME} GTest::gtest_main GTest::gmock_main PROJ::proj cuproj)
add_test(NAME ${CMAKE_TEST_NAME} COMMAND ${CMAKE_TEST_NAME})
install(
TARGETS ${CMAKE_TEST_NAME}
COMPONENT testing
DESTINATION bin/gtests/libcuspatial # add to libcuspatial CI testing
EXCLUDE_FROM_ALL
)
endfunction(ConfigureTest)
###################################################################################################
### test sources ##################################################################################
###################################################################################################
# index
ConfigureTest(WGS_TO_UTM_TEST
wgs_to_utm_test.cu)
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj | rapidsai_public_repos/cuspatial/cpp/cuproj/tests/wgs_to_utm_test.cu | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cuproj_test/convert_coordinates.hpp>
#include <cuproj_test/coordinate_generator.cuh>
#include <cuproj/error.hpp>
#include <cuproj/projection_factories.cuh>
#include <cuproj/vec_2d.hpp>
#include <cuspatial_test/vector_equality.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <thrust/tabulate.h>
#include <proj.h>
#include <gtest/gtest.h>
#include <cmath>
#include <iostream>
#include <type_traits>
template <typename T>
struct ProjectionTest : public ::testing::Test {};
using TestTypes = ::testing::Types<float, double>;
TYPED_TEST_CASE(ProjectionTest, TestTypes);
template <typename T>
using coordinate = typename cuspatial::vec_2d<T>;
// run a test using the cuproj library
template <typename T>
void run_cuproj_test(thrust::host_vector<coordinate<T>> const& input,
thrust::host_vector<coordinate<T>> const& expected,
cuproj::projection<coordinate<T>> const& proj,
cuproj::direction dir,
T tolerance = T{0}) // 0 for 1-ulp comparison
{
thrust::device_vector<coordinate<T>> d_in = input;
thrust::device_vector<coordinate<T>> d_out(d_in.size());
proj.transform(d_in.begin(), d_in.end(), d_out.begin(), dir);
#ifndef NDEBUG
std::cout << "expected " << std::setprecision(20) << expected[0].x << " " << expected[0].y
<< std::endl;
coordinate<T> c_out = d_out[0];
std::cout << "Device: " << std::setprecision(20) << c_out.x << " " << c_out.y << std::endl;
#endif
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected, d_out, tolerance);
}
// run a test using the proj library for comparison
void run_proj_test(thrust::host_vector<PJ_COORD>& coords,
char const* epsg_src,
char const* epsg_dst)
{
PJ_CONTEXT* C = proj_context_create();
PJ* P = proj_create_crs_to_crs(C, epsg_src, epsg_dst, nullptr);
proj_trans_array(P, PJ_FWD, coords.size(), coords.data());
proj_destroy(P);
proj_context_destroy(C);
}
// Run a test using the cuproj library in both directions, comparing to the proj library
template <typename T, typename DeviceVector>
void run_forward_and_inverse(DeviceVector const& input,
T tolerance = T{0},
std::string const& utm_epsg = "EPSG:32756")
{
// note there are two notions of direction here. The direction of the construction of the
// projection is determined by the order of the epsg strings. The direction of the transform is
// determined by the direction argument to the transform method. This test runs both directions
// for a single projection, with the order of construction determined by the inverted template
// parameter. This is needed because a user may construct either a UTM->WGS84 or WGS84->UTM
// projection, and we want to test both directions for each.
thrust::host_vector<coordinate<T>> h_input(input.begin(), input.end());
thrust::host_vector<PJ_COORD> pj_input{input.size()};
cuproj_test::convert_coordinates(h_input, pj_input);
thrust::host_vector<PJ_COORD> pj_expected(pj_input);
char const* epsg_src = "EPSG:4326";
char const* epsg_dst = utm_epsg.c_str();
auto run = [&]() {
run_proj_test(pj_expected, epsg_src, epsg_dst);
thrust::host_vector<coordinate<T>> h_expected{pj_expected.size()};
cuproj_test::convert_coordinates(pj_expected, h_expected);
auto proj = cuproj::make_projection<coordinate<T>>(epsg_src, epsg_dst);
run_cuproj_test(h_input, h_expected, *proj, cuproj::direction::FORWARD, tolerance);
run_cuproj_test(h_expected, h_input, *proj, cuproj::direction::INVERSE, tolerance);
};
// forward construction
run();
// invert construction
pj_input = pj_expected;
cuproj_test::convert_coordinates(pj_input, h_input);
std::swap(epsg_src, epsg_dst);
run();
}
// Just test construction of the projection from supported EPSG codes
TYPED_TEST(ProjectionTest, make_projection_valid_epsg)
{
using T = TypeParam;
{ // auth:code strings
cuproj::make_projection<coordinate<T>>("EPSG:4326", "EPSG:32756");
cuproj::make_projection<coordinate<T>>("EPSG:32756", "EPSG:4326");
cuproj::make_projection<coordinate<T>>("EPSG:4326", "EPSG:32601");
cuproj::make_projection<coordinate<T>>("EPSG:32601", "EPSG:4326");
}
{ // int epsg codes
cuproj::make_projection<coordinate<T>>(4326, 32756);
cuproj::make_projection<coordinate<T>>(32756, 4326);
cuproj::make_projection<coordinate<T>>(4326, 32601);
cuproj::make_projection<coordinate<T>>(32601, 4326);
}
}
// Test that construction of the projection from unsupported EPSG codes throws
// expected exceptions
TYPED_TEST(ProjectionTest, invalid_epsg)
{
using T = TypeParam;
{ // auth:code strings
EXPECT_THROW(cuproj::make_projection<coordinate<T>>("EPSG:4326", "EPSG:756"),
cuproj::logic_error);
EXPECT_THROW(cuproj::make_projection<coordinate<T>>("EPSG:4326", "UTM:32756"),
cuproj::logic_error);
EXPECT_THROW(cuproj::make_projection<coordinate<T>>("EPSG:32611", "EPSG:32756"),
cuproj::logic_error);
}
{ // int codes
EXPECT_THROW(cuproj::make_projection<coordinate<T>>(4326, 756), cuproj::logic_error);
EXPECT_THROW(cuproj::make_projection<coordinate<T>>(32611, 32756), cuproj::logic_error);
}
}
// Test on a single coordinate
TYPED_TEST(ProjectionTest, one)
{
using T = TypeParam;
coordinate<T> sydney{-33.858700, 151.214000}; // Sydney, NSW, Australia
std::vector<coordinate<T>> input{sydney};
// We can expect nanometer accuracy with double precision. The precision ratio of
// double to single precision is 2^53 / 2^24 == 2^29 ~= 10^9, then we should
// expect meter (10^9 nanometer) accuracy with single precision.
T tolerance = std::is_same_v<T, double> ? T{1e-9} : T{1.0};
run_forward_and_inverse<T>(input, tolerance, "EPSG:32756");
}
// Test on a grid of coordinates
template <typename T>
void test_grid(coordinate<T> const& min_corner,
coordinate<T> max_corner,
int num_points_xy,
std::string const& utm_epsg)
{
auto input = cuproj_test::make_grid_array<coordinate<T>, rmm::device_vector<coordinate<T>>>(
min_corner, max_corner, num_points_xy, num_points_xy);
thrust::host_vector<coordinate<T>> h_input(input);
// We can expect nanometer accuracy with double precision. The precision ratio of
// double to single precision is 2^53 / 2^24 == 2^29 ~= 10^9, then we should
// expect meter (10^9 nanometer) accuracy with single precision.
// For large arrays seem to need to relax the tolerance a bit to match PROJ results.
// 1um for double and 10m for float seems like reasonable accuracy while not allowing excessive
// variance from PROJ results.
T tolerance = std::is_same_v<T, double> ? T{1e-6} : T{10};
run_forward_and_inverse<T>(h_input, tolerance);
}
TYPED_TEST(ProjectionTest, many)
{
int num_points_xy = 100;
// Test with grids of coordinates covering various locations on the globe
// Sydney Harbour
{
coordinate<TypeParam> min_corner{-33.9, 151.2};
coordinate<TypeParam> max_corner{-33.7, 151.3};
std::string epsg = "EPSG:32756";
test_grid<TypeParam>(min_corner, max_corner, num_points_xy, epsg);
}
// London, UK
{
coordinate<TypeParam> min_corner{51.0, -1.0};
coordinate<TypeParam> max_corner{52.0, 1.0};
std::string epsg = "EPSG:32630";
test_grid<TypeParam>(min_corner, max_corner, num_points_xy, epsg);
}
// Svalbard
{
coordinate<TypeParam> min_corner{77.0, 15.0};
coordinate<TypeParam> max_corner{79.0, 20.0};
std::string epsg = "EPSG:32633";
test_grid<TypeParam>(min_corner, max_corner, num_points_xy, epsg);
}
// Ushuaia, Argentina
{
coordinate<TypeParam> min_corner{-55.0, -70.0};
coordinate<TypeParam> max_corner{-53.0, -65.0};
std::string epsg = "EPSG:32719";
test_grid<TypeParam>(min_corner, max_corner, num_points_xy, epsg);
}
// McMurdo Station, Antarctica
{
coordinate<TypeParam> min_corner{-78.0, 165.0};
coordinate<TypeParam> max_corner{-77.0, 170.0};
std::string epsg = "EPSG:32706";
test_grid<TypeParam>(min_corner, max_corner, num_points_xy, epsg);
}
// Singapore
{
coordinate<TypeParam> min_corner{1.0, 103.0};
coordinate<TypeParam> max_corner{2.0, 104.0};
std::string epsg = "EPSG:32648";
test_grid<TypeParam>(min_corner, max_corner, num_points_xy, epsg);
}
}
// Test the code in the readme
TYPED_TEST(ProjectionTest, readme_example)
{
using T = TypeParam;
// Make a projection to convert WGS84 (lat, lon) coordinates to UTM zone 56S (x, y) coordinates
auto* proj = cuproj::make_projection<cuproj::vec_2d<T>>("EPSG:4326", "EPSG:32756");
cuproj::vec_2d<T> sydney{-33.858700, 151.214000}; // Sydney, NSW, Australia
thrust::device_vector<cuproj::vec_2d<T>> d_in{1, sydney};
thrust::device_vector<cuproj::vec_2d<T>> d_out(d_in.size());
// Convert the coordinates. Works the same with a vector of many coordinates.
proj->transform(d_in.begin(), d_in.end(), d_out.begin(), cuproj::direction::FORWARD);
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj | rapidsai_public_repos/cuspatial/cpp/cuproj/benchmarks/wgs_to_utm_bench.cu | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cuproj/projection_factories.cuh>
#include <cuspatial/geometry/vec_2d.hpp>
#include <cuproj_test/convert_coordinates.hpp>
#include <cuproj_test/coordinate_generator.cuh>
#include <benchmarks/fixture/benchmark_fixture.hpp>
#include <benchmarks/synchronization/synchronization.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_vector.hpp>
#include <thrust/host_vector.h>
#include <type_traits>
template <typename T>
using coordinate = typename cuspatial::vec_2d<T>;
static char const* epsg_src = "EPSG:4326";
static char const* epsg_dst = "EPSG:32756";
template <typename T>
auto make_input(std::size_t grid_side)
{
// Sydney Harbour
coordinate<T> min_corner{-33.9, 151.2};
coordinate<T> max_corner{-33.7, 151.3};
auto input = cuproj_test::make_grid_array<coordinate<T>, rmm::device_vector<coordinate<T>>>(
min_corner, max_corner, grid_side, grid_side);
return input;
}
template <typename T>
static void cuproj_wgs_to_utm_benchmark(benchmark::State& state)
{
auto const num_points = state.range(0);
auto const grid_side{static_cast<std::size_t>(sqrt(num_points))};
auto input = make_input<T>(grid_side);
rmm::device_vector<coordinate<T>> output(input.size());
auto proj = cuproj::make_projection<coordinate<T>>(epsg_src, epsg_dst);
for (auto _ : state) {
cuda_event_timer raii(state, true);
proj->transform(input.begin(),
input.end(),
output.begin(),
cuproj::direction::FORWARD,
rmm::cuda_stream_default);
}
state.SetItemsProcessed(num_points * state.iterations());
}
void proj_wgs_to_utm_benchmark(benchmark::State& state)
{
using T = double;
auto const num_points = state.range(0);
auto const grid_side{static_cast<std::size_t>(sqrt(num_points))};
auto d_input = make_input<T>(grid_side);
auto input = thrust::host_vector<coordinate<T>>(d_input);
std::vector<PJ_COORD> pj_input(input.size());
PJ_CONTEXT* C = proj_context_create();
PJ* P = proj_create_crs_to_crs(C, epsg_src, epsg_dst, nullptr);
for (auto _ : state) {
state.PauseTiming();
cuproj_test::convert_coordinates(input, pj_input);
state.ResumeTiming();
proj_trans_array(P, PJ_FWD, pj_input.size(), pj_input.data());
}
state.SetItemsProcessed(num_points * state.iterations());
}
class proj_utm_benchmark : public ::benchmark::Fixture {};
// Edit these for GPUs/CPUs with larger or smaller memory.
// For double precision, its' 16 bytes per (x,y) point, x2 for input and output
// 10^8 points -> 3.2GB+, 10^9 points -> 32GB+
// H100 80GB is plenty for 10^9 points
constexpr int range_min = 100;
constexpr int range_max = 100'000'000;
BENCHMARK_DEFINE_F(proj_utm_benchmark, forward_double)(::benchmark::State& state)
{
proj_wgs_to_utm_benchmark(state);
}
BENCHMARK_REGISTER_F(proj_utm_benchmark, forward_double)
->RangeMultiplier(10)
->Range(range_min, range_max)
->Unit(benchmark::kMillisecond);
class cuproj_utm_benchmark : public cuspatial::benchmark {};
#define UTM_CUPROJ_BENCHMARK_DEFINE(name, type) \
BENCHMARK_DEFINE_F(cuproj_utm_benchmark, name)(::benchmark::State & state) \
{ \
cuproj_wgs_to_utm_benchmark<type>(state); \
} \
BENCHMARK_REGISTER_F(cuproj_utm_benchmark, name) \
->RangeMultiplier(10) \
->Range(range_min, range_max) \
->UseManualTime() \
->Unit(benchmark::kMillisecond);
UTM_CUPROJ_BENCHMARK_DEFINE(forward_float, float);
UTM_CUPROJ_BENCHMARK_DEFINE(forward_double, double);
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj | rapidsai_public_repos/cuspatial/cpp/cuproj/benchmarks/CMakeLists.txt | #=============================================================================
# Copyright (c) 2023, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================
###################################################################################################
# - compiler function -----------------------------------------------------------------------------
# Use an OBJECT library so we only compile common source files only once
add_library(cuproj_benchmark_common OBJECT
synchronization/synchronization.cpp)
target_compile_features(cuproj_benchmark_common PUBLIC cxx_std_17 cuda_std_17)
target_link_libraries(cuproj_benchmark_common
PUBLIC benchmark::benchmark cudf::cudftestutil cuproj)
target_compile_options(cuproj_benchmark_common
PUBLIC "$<$<COMPILE_LANGUAGE:CXX>:${CUPROJ_CXX_FLAGS}>"
"$<$<COMPILE_LANGUAGE:CUDA>:${CUPROJ_CUDA_FLAGS}>")
target_include_directories(cuproj_benchmark_common
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
"$<BUILD_INTERFACE:${CUPROJ_SOURCE_DIR}>"
"$<BUILD_INTERFACE:${CUPROJ_SOURCE_DIR}/src>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../include>")
function(ConfigureBench CMAKE_BENCH_NAME)
add_executable(${CMAKE_BENCH_NAME} ${ARGN})
set_target_properties(${CMAKE_BENCH_NAME}
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "$<BUILD_INTERFACE:${CUPROJ_BINARY_DIR}/benchmarks>"
INSTALL_RPATH "\$ORIGIN/../../../lib"
)
target_link_libraries(${CMAKE_BENCH_NAME} PRIVATE benchmark::benchmark_main cuproj_benchmark_common PROJ::proj)
install(
TARGETS ${CMAKE_BENCH_NAME}
COMPONENT benchmark
DESTINATION bin/benchmarks/libcuproj
EXCLUDE_FROM_ALL
)
endfunction()
# This function takes in a benchmark name and benchmark source for nvbench benchmarks and handles
# setting all of the associated properties and linking to build the benchmark
function(ConfigureNVBench CMAKE_BENCH_NAME)
add_executable(${CMAKE_BENCH_NAME} ${ARGN})
set_target_properties(
${CMAKE_BENCH_NAME}
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "$<BUILD_INTERFACE:${CUPROJ_BINARY_DIR}/benchmarks>"
INSTALL_RPATH "\$ORIGIN/../../../lib"
)
target_compile_features(${CMAKE_BENCH_NAME} PUBLIC cxx_std_17 cuda_std_17)
target_compile_options(${CMAKE_BENCH_NAME}
PUBLIC "$<$<COMPILE_LANGUAGE:CXX>:${CUPROJ_CXX_FLAGS}>"
"$<$<COMPILE_LANGUAGE:CUDA>:${CUPROJ_CUDA_FLAGS}>")
target_include_directories(${CMAKE_BENCH_NAME}
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
"$<BUILD_INTERFACE:${CUPROJ_SOURCE_DIR}>"
"$<BUILD_INTERFACE:${CUPROJ_SOURCE_DIR}/src>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../include>")
target_link_libraries(
${CMAKE_BENCH_NAME} PRIVATE cuproj nvbench::main
)
install(
TARGETS ${CMAKE_BENCH_NAME}
COMPONENT benchmark
DESTINATION bin/benchmarks/libcuproj
EXCLUDE_FROM_ALL
)
endfunction()
###################################################################################################
### benchmark sources #############################################################################
###################################################################################################
ConfigureBench(WGS_TO_UTM_BENCH wgs_to_utm_bench.cu)
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj/benchmarks | rapidsai_public_repos/cuspatial/cpp/cuproj/benchmarks/synchronization/synchronization.cpp | /*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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 "synchronization.hpp"
#include <cuproj/error.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_buffer.hpp>
cuda_event_timer::cuda_event_timer(benchmark::State& state,
bool flush_l2_cache,
rmm::cuda_stream_view stream)
: stream(stream), p_state(&state)
{
// flush all of L2$
if (flush_l2_cache) {
int current_device = 0;
CUPROJ_CUDA_TRY(cudaGetDevice(¤t_device));
int l2_cache_bytes = 0;
CUPROJ_CUDA_TRY(
cudaDeviceGetAttribute(&l2_cache_bytes, cudaDevAttrL2CacheSize, current_device));
if (l2_cache_bytes > 0) {
const int memset_value = 0;
rmm::device_buffer l2_cache_buffer(l2_cache_bytes, stream);
CUPROJ_CUDA_TRY(
cudaMemsetAsync(l2_cache_buffer.data(), memset_value, l2_cache_bytes, stream.value()));
}
}
CUPROJ_CUDA_TRY(cudaEventCreate(&start));
CUPROJ_CUDA_TRY(cudaEventCreate(&stop));
CUPROJ_CUDA_TRY(cudaEventRecord(start, stream.value()));
}
cuda_event_timer::~cuda_event_timer()
{
CUPROJ_CUDA_TRY(cudaEventRecord(stop, stream.value()));
CUPROJ_CUDA_TRY(cudaEventSynchronize(stop));
float milliseconds = 0.0f;
CUPROJ_CUDA_TRY(cudaEventElapsedTime(&milliseconds, start, stop));
p_state->SetIterationTime(milliseconds / (1000.0f));
CUPROJ_CUDA_TRY(cudaEventDestroy(start));
CUPROJ_CUDA_TRY(cudaEventDestroy(stop));
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj/benchmarks | rapidsai_public_repos/cuspatial/cpp/cuproj/benchmarks/synchronization/synchronization.hpp | /*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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.
*/
/**
* @file synchronization.hpp
* @brief This is the header file for `cuda_event_timer`.
**/
/**
* @brief This class serves as a wrapper for using `cudaEvent_t` as the user
* defined timer within the framework of google benchmark
* (https://github.com/google/benchmark).
*
* It is built on top of the idea of Resource acquisition is initialization
* (RAII). In the following we show a minimal example of how to use this class.
#include <benchmark/benchmark.h>
static void sample_cuda_benchmark(benchmark::State& state) {
for (auto _ : state){
rmm::cuda_stream_view stream{}; // default stream, could be another stream
// Create (Construct) an object of this class. You HAVE to pass in the
// benchmark::State object you are using. It measures the time from its
// creation to its destruction that is spent on the specified CUDA stream.
// It also clears the L2 cache by cudaMemset'ing a device buffer that is of
// the size of the L2 cache (if flush_l2_cache is set to true and there is
// an L2 cache on the current device).
cuda_event_timer raii(state, true, stream); // flush_l2_cache = true
// Now perform the operations that is to be benchmarked
sample_kernel<<<1, 256, 0, stream.value()>>>(); // Possibly launching a CUDA kernel
}
}
// Register the function as a benchmark. You will need to set the `UseManualTime()`
// flag in order to use the timer embedded in this class.
BENCHMARK(sample_cuda_benchmark)->UseManualTime();
**/
#ifndef CUDF_BENCH_SYNCHRONIZATION_H
#define CUDF_BENCH_SYNCHRONIZATION_H
// Google Benchmark library
#include <benchmark/benchmark.h>
#include <cudf/types.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <driver_types.h>
class cuda_event_timer {
public:
/**
* @brief This c'tor clears the L2$ by cudaMemset'ing a buffer of L2$ size
* and starts the timer.
*
* @param[in,out] state This is the benchmark::State whose timer we are going
* to update.
* @param[in] flush_l2_cache_ whether or not to flush the L2 cache before
* every iteration.
* @param[in] stream_ The CUDA stream we are measuring time on.
**/
cuda_event_timer(benchmark::State& state,
bool flush_l2_cache,
rmm::cuda_stream_view stream = rmm::cuda_stream_default);
// The user must provide a benchmark::State object to set
// the timer so we disable the default c'tor.
cuda_event_timer() = delete;
// The d'tor stops the timer and performs a synchronization.
// Time of the benchmark::State object provided to the c'tor
// will be set to the value given by `cudaEventElapsedTime`.
~cuda_event_timer();
private:
cudaEvent_t start;
cudaEvent_t stop;
rmm::cuda_stream_view stream;
benchmark::State* p_state;
};
#endif
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj/benchmarks | rapidsai_public_repos/cuspatial/cpp/cuproj/benchmarks/fixture/benchmark_fixture.hpp | /*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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 <benchmark/benchmark.h>
#include <rmm/mr/device/cuda_memory_resource.hpp>
#include <rmm/mr/device/owning_wrapper.hpp>
#include <rmm/mr/device/per_device_resource.hpp>
#include <rmm/mr/device/pool_memory_resource.hpp>
namespace cuspatial {
namespace {
// memory resource factory helpers
inline auto make_cuda() { return std::make_shared<rmm::mr::cuda_memory_resource>(); }
inline auto make_pool()
{
return rmm::mr::make_owning_wrapper<rmm::mr::pool_memory_resource>(make_cuda());
}
} // namespace
/**
* @brief Google Benchmark fixture for libcuspatial benchmarks
*
* libcuspatial benchmarks should use a fixture derived from this fixture class to
* ensure that the RAPIDS Memory Manager pool mode is used in benchmarks, which
* eliminates memory allocation / deallocation performance overhead from the
* benchmark.
*
* The SetUp and TearDown methods of this fixture initialize RMM into pool mode
* and finalize it, respectively. These methods are called automatically by
* Google Benchmark
*
* Example:
*
* template <class T>
* class my_benchmark : public cuspatial::benchmark {
* public:
* using TypeParam = T;
* };
*
* Then:
*
* BENCHMARK_TEMPLATE_DEFINE_F(my_benchmark, my_test_name, int)
* (::benchmark::State& state) {
* for (auto _ : state) {
* // benchmark stuff
* }
* }
*
* BENCHMARK_REGISTER_F(my_benchmark, my_test_name)->Range(128, 512);
*/
class benchmark : public ::benchmark::Fixture {
public:
virtual void SetUp(const ::benchmark::State& state) override
{
mr = make_pool();
rmm::mr::set_current_device_resource(mr.get()); // set default resource to pool
}
virtual void TearDown(const ::benchmark::State& state) override
{
// reset default resource to the initial resource
rmm::mr::set_current_device_resource(nullptr);
mr.reset();
}
// eliminate partial override warnings (see benchmark/benchmark.h)
void SetUp(::benchmark::State& st) override { SetUp(const_cast<const ::benchmark::State&>(st)); }
void TearDown(::benchmark::State& st) override
{
TearDown(const_cast<const ::benchmark::State&>(st));
}
std::shared_ptr<rmm::mr::device_memory_resource> mr;
};
}; // namespace cuspatial
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj/cmake | rapidsai_public_repos/cuspatial/cpp/cuproj/cmake/modules/ConfigureCUDA.cmake | #=============================================================================
# Copyright (c) 2023, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================
if(CMAKE_COMPILER_IS_GNUCXX)
list(APPEND CUPROJ_CXX_FLAGS -Wall -Werror -Wno-unknown-pragmas -Wno-error=deprecated-declarations)
if(CUPROJ_BUILD_TESTS OR CUPROJ_BUILD_BENCHMARKS)
# Suppress parentheses warning which causes gmock to fail
list(APPEND CUPROJ_CUDA_FLAGS -Xcompiler=-Wno-parentheses)
endif()
endif(CMAKE_COMPILER_IS_GNUCXX)
list(APPEND CUPROJ_CUDA_FLAGS --expt-extended-lambda --expt-relaxed-constexpr)
# set warnings as errors
if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 11.2.0)
list(APPEND CUPROJ_CUDA_FLAGS -Werror=all-warnings)
endif()
list(APPEND CUPROJ_CUDA_FLAGS -Xcompiler=-Wall,-Werror,-Wno-error=deprecated-declarations)
# Produce smallest binary size
list(APPEND CUPROJ_CUDA_FLAGS -Xfatbin=-compress-all)
if(DISABLE_DEPRECATION_WARNING)
list(APPEND CUPROJ_CXX_FLAGS -Wno-deprecated-declarations)
list(APPEND CUPROJ_CUDA_FLAGS -Xcompiler=-Wno-deprecated-declarations)
endif()
# Option to enable line info in CUDA device compilation to allow introspection when profiling / memchecking
if(CUDA_ENABLE_LINEINFO)
list(APPEND CUPROJ_CUDA_FLAGS -lineinfo)
endif()
# Debug options
if(CMAKE_BUILD_TYPE MATCHES Debug)
message(STATUS "CUSPATIAL: Building with debugging flags")
list(APPEND CUPROJ_CUDA_FLAGS -G -Xcompiler=-rdynamic)
endif()
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj/cmake | rapidsai_public_repos/cuspatial/cpp/cuproj/cmake/thirdparty/get_proj.cmake | # =============================================================================
# Copyright (c) 2023, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied. See the License for the specific language governing permissions and limitations under
# the License.
# =============================================================================
# This function finds osgeo/proj and sets any additional necessary environment variables.
function(find_and_configure_proj VERSION)
include(${rapids-cmake-dir}/cpm/find.cmake)
# Find or install Proj
rapids_cpm_find(
PROJ ${VERSION}
GLOBAL_TARGETS PROJ::proj
BUILD_EXPORT_SET cuproj-exports
INSTALL_EXPORT_SET cuproj-exports
CPM_ARGS
GIT_REPOSITORY https://github.com/osgeo/proj.git
GIT_TAG ${VERSION}
GIT_SHALLOW TRUE
)
endfunction()
find_and_configure_proj(9.2.0)
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj/cmake | rapidsai_public_repos/cuspatial/cpp/cuproj/cmake/thirdparty/get_gtest.cmake | # =============================================================================
# Copyright (c) 2023, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied. See the License for the specific language governing permissions and limitations under
# the License.
# =============================================================================
# This function finds gtest and sets any additional necessary environment variables.
function(find_and_configure_gtest)
include(${rapids-cmake-dir}/cpm/gtest.cmake)
# Find or install GoogleTest
rapids_cpm_gtest(BUILD_EXPORT_SET cuproj-testing-exports INSTALL_EXPORT_SET cuproj-testing-exports)
if(GTest_ADDED)
rapids_export(
BUILD GTest
VERSION ${GTest_VERSION}
EXPORT_SET GTestTargets
GLOBAL_TARGETS gtest gmock gtest_main gmock_main
NAMESPACE GTest::
)
include("${rapids-cmake-dir}/export/find_package_root.cmake")
rapids_export_find_package_root(
BUILD GTest [=[${CMAKE_CURRENT_LIST_DIR}]=] cuproj-testing-exports
)
endif()
endfunction()
find_and_configure_gtest()
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj/cmake | rapidsai_public_repos/cuspatial/cpp/cuproj/cmake/thirdparty/get_rmm.cmake | # =============================================================================
# Copyright (c) 2020-2023, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied. See the License for the specific language governing permissions and limitations under
# the License.
# =============================================================================
# This function finds rmm and sets any additional necessary environment variables.
function(find_and_configure_rmm)
include(${rapids-cmake-dir}/cpm/rmm.cmake)
# Find or install RMM
rapids_cpm_rmm(BUILD_EXPORT_SET cuproj-exports INSTALL_EXPORT_SET cuproj-exports)
endfunction()
find_and_configure_rmm()
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj | rapidsai_public_repos/cuspatial/cpp/cuproj/doxygen/DoxygenLayout.xml | <doxygenlayout version="1.0">
<!-- Generated by doxygen 1.8.13 -->
<!-- Navigation index tabs for HTML output -->
<navindex>
<tab type="mainpage" visible="yes" title=""/>
<tab type="pages" visible="yes" title="" intro=""/>
<!-- <tab type="user" url="@ref DEVELOPER_GUIDE" title="Developer Guide"/> -->
<tab type="modules" visible="yes" title="" intro=""/>
<tab type="namespaces" visible="yes" title="">
<tab type="namespacelist" visible="yes" title="" intro=""/>
<tab type="namespacemembers" visible="yes" title="" intro=""/>
</tab>
<tab type="classes" visible="yes" title="">
<tab type="classlist" visible="yes" title="" intro=""/>
<tab type="classindex" visible="$ALPHABETICAL_INDEX" title=""/>
<tab type="hierarchy" visible="yes" title="" intro=""/>
<tab type="classmembers" visible="yes" title="" intro=""/>
</tab>
<tab type="files" visible="yes" title="">
<tab type="filelist" visible="yes" title="" intro=""/>
<tab type="globals" visible="yes" title="" intro=""/>
</tab>
<tab type="examples" visible="yes" title="" intro=""/>
</navindex>
<!-- Layout definition for a class page -->
<class>
<briefdescription visible="yes"/>
<includes visible="$SHOW_INCLUDE_FILES"/>
<inheritancegraph visible="$CLASS_GRAPH"/>
<collaborationgraph visible="$COLLABORATION_GRAPH"/>
<memberdecl>
<nestedclasses visible="yes" title=""/>
<publictypes title=""/>
<services title=""/>
<interfaces title=""/>
<publicslots title=""/>
<signals title=""/>
<publicmethods title=""/>
<publicstaticmethods title=""/>
<publicattributes title=""/>
<publicstaticattributes title=""/>
<protectedtypes title=""/>
<protectedslots title=""/>
<protectedmethods title=""/>
<protectedstaticmethods title=""/>
<protectedattributes title=""/>
<protectedstaticattributes title=""/>
<packagetypes title=""/>
<packagemethods title=""/>
<packagestaticmethods title=""/>
<packageattributes title=""/>
<packagestaticattributes title=""/>
<properties title=""/>
<events title=""/>
<privatetypes title=""/>
<privateslots title=""/>
<privatemethods title=""/>
<privatestaticmethods title=""/>
<privateattributes title=""/>
<privatestaticattributes title=""/>
<friends title=""/>
<related title="" subtitle=""/>
<membergroups visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
<memberdef>
<inlineclasses title=""/>
<typedefs title=""/>
<enums title=""/>
<services title=""/>
<interfaces title=""/>
<constructors title=""/>
<functions title=""/>
<related title=""/>
<variables title=""/>
<properties title=""/>
<events title=""/>
</memberdef>
<allmemberslink visible="yes"/>
<usedfiles visible="$SHOW_USED_FILES"/>
<authorsection visible="yes"/>
</class>
<!-- Layout definition for a namespace page -->
<namespace>
<briefdescription visible="yes"/>
<memberdecl>
<nestednamespaces visible="yes" title=""/>
<constantgroups visible="yes" title=""/>
<classes visible="yes" title=""/>
<typedefs title=""/>
<enums title=""/>
<functions title=""/>
<variables title=""/>
<membergroups visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
<memberdef>
<inlineclasses title=""/>
<typedefs title=""/>
<enums title=""/>
<functions title=""/>
<variables title=""/>
</memberdef>
<authorsection visible="yes"/>
</namespace>
<!-- Layout definition for a file page -->
<file>
<briefdescription visible="yes"/>
<includes visible="$SHOW_INCLUDE_FILES"/>
<includegraph visible="$INCLUDE_GRAPH"/>
<includedbygraph visible="$INCLUDED_BY_GRAPH"/>
<sourcelink visible="yes"/>
<memberdecl>
<classes visible="yes" title=""/>
<namespaces visible="yes" title=""/>
<constantgroups visible="yes" title=""/>
<defines title=""/>
<typedefs title=""/>
<enums title=""/>
<functions title=""/>
<variables title=""/>
<membergroups visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
<memberdef>
<inlineclasses title=""/>
<defines title=""/>
<typedefs title=""/>
<enums title=""/>
<functions title=""/>
<variables title=""/>
</memberdef>
<authorsection/>
</file>
<!-- Layout definition for a group page -->
<group>
<briefdescription visible="yes"/>
<groupgraph visible="$GROUP_GRAPHS"/>
<memberdecl>
<nestedgroups visible="yes" title=""/>
<dirs visible="yes" title=""/>
<files visible="yes" title=""/>
<namespaces visible="yes" title=""/>
<classes visible="yes" title=""/>
<defines title=""/>
<typedefs title=""/>
<enums title=""/>
<enumvalues title=""/>
<functions title=""/>
<variables title=""/>
<signals title=""/>
<publicslots title=""/>
<protectedslots title=""/>
<privateslots title=""/>
<events title=""/>
<properties title=""/>
<friends title=""/>
<membergroups visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
<memberdef>
<pagedocs/>
<inlineclasses title=""/>
<defines title=""/>
<typedefs title=""/>
<enums title=""/>
<enumvalues title=""/>
<functions title=""/>
<variables title=""/>
<signals title=""/>
<publicslots title=""/>
<protectedslots title=""/>
<privateslots title=""/>
<events title=""/>
<properties title=""/>
<friends title=""/>
</memberdef>
<authorsection visible="yes"/>
</group>
<!-- Layout definition for a directory page -->
<directory>
<briefdescription visible="yes"/>
<directorygraph visible="yes"/>
<memberdecl>
<dirs visible="yes"/>
<files visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
</directory>
</doxygenlayout>
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj | rapidsai_public_repos/cuspatial/cpp/cuproj/doxygen/modify_fences.sh | #!/bin/bash
# Copyright (c) 2022, NVIDIA CORPORATION.
# This script modifies the GitHub Markdown style code fences in our MD files
# into the PHP style that Doxygen supports, allowing us to display code
# properly both on the GitHub GUI and in published Doxygen documentation.
sed 's/```c++/```{.cpp}/g' "$@"
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj | rapidsai_public_repos/cuspatial/cpp/cuproj/doxygen/main_page.md | cuProj is a generic coordinate transformation library that transforms geospatial coordinates from
one coordinate reference system (CRS) to another. This includes cartographic projections as well as
geodetic transformations. cuProj is implemented in CUDA C++ to run on GPUs to provide the highest
performance.
libcuproj is a CUDA C++ library that provides the header-only C++ API for cuProj. It is designed
to implement coordinate projections and transforms compatible with the [Proj](https://proj.org/)
library. The C++ API does not match the API of Proj, but it is designed to eventually expand to
support many of the same features and transformations that Proj supports.
Currently libcuproj only supports a subset of the Proj transformations. The following
transformations are supported:
- WGS84 to/from UTM
## Example
The C++ API is designed to be easy to use. The following example shows how to transform a point in
Sydney, Australia from WGS84 (lat, lon) coordinates to UTM zone 56S (x, y) coordinates.
```cpp
#include <cuproj/projection_factories.cuh>
#include <cuproj/vec_2d.hpp>
// Make a projection to convert WGS84 (lat, lon) coordinates to UTM zone 56S (x, y) coordinates
auto proj = cuproj::make_projection<cuproj::vec_2d<T>>("EPSG:4326", "EPSG:32756");
cuproj::vec_2d<T> sydney{-33.858700, 151.214000}; // Sydney, NSW, Australia
thrust::device_vector<cuproj::vec_2d<T>> d_in{1, sydney};
thrust::device_vector<cuproj::vec_2d<T>> d_out(d_in.size());
// Convert the coordinates. Works the same with a vector of many coordinates.
proj.transform(d_in.begin(), d_in.end(), d_out.begin(), cuproj::direction::FORWARD);
```
## Useful Links
- [RAPIDS Home Page](https://rapids.ai)
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj | rapidsai_public_repos/cuspatial/cpp/cuproj/doxygen/Doxyfile | # Doxyfile 1.9.7
# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project.
#
# All text after a double hash (##) is considered a comment and is placed in
# front of the TAG it is preceding.
#
# All text after a single hash (#) is considered a comment and will be ignored.
# The format is:
# TAG = value [value, ...]
# For lists, items can also be appended using:
# TAG += value [value, ...]
# Values that contain spaces should be placed between quotes (\" \").
#
# Note:
#
# Use doxygen to compare the used configuration file with the template
# configuration file:
# doxygen -x [configFile]
# Use doxygen to compare the used configuration file with the template
# configuration file without replacing the environment variables or CMake type
# replacement variables:
# doxygen -x_noenv [configFile]
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
# This tag specifies the encoding used for all characters in the configuration
# file that follow. The default is UTF-8 which is also the encoding used for all
# text before the first occurrence of this tag. Doxygen uses libiconv (or the
# iconv built into libc) for the transcoding. See
# https://www.gnu.org/software/libiconv/ for the list of possible encodings.
# The default value is: UTF-8.
DOXYFILE_ENCODING = UTF-8
# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by
# double-quotes, unless you are using Doxywizard) that should identify the
# project for which the documentation is generated. This name is used in the
# title of most generated pages and in a few other places.
# The default value is: My Project.
PROJECT_NAME = libcuproj
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = 23.12.00
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
# quick idea about the purpose of the project. Keep the description short.
PROJECT_BRIEF =
# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
# in the documentation. The maximum height of the logo should not exceed 55
# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
# the logo to the output directory.
PROJECT_LOGO =
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
# into which the generated documentation will be written. If a relative path is
# entered, it will be relative to the location where doxygen was started. If
# left blank the current directory will be used.
OUTPUT_DIRECTORY =
# If the CREATE_SUBDIRS tag is set to YES then doxygen will create up to 4096
# sub-directories (in 2 levels) under the output directory of each output format
# and will distribute the generated files over these directories. Enabling this
# option can be useful when feeding doxygen a huge amount of source files, where
# putting all generated files in the same directory would otherwise causes
# performance problems for the file system. Adapt CREATE_SUBDIRS_LEVEL to
# control the number of sub-directories.
# The default value is: NO.
CREATE_SUBDIRS = NO
# Controls the number of sub-directories that will be created when
# CREATE_SUBDIRS tag is set to YES. Level 0 represents 16 directories, and every
# level increment doubles the number of directories, resulting in 4096
# directories at level 8 which is the default and also the maximum value. The
# sub-directories are organized in 2 levels, the first level always has a fixed
# number of 16 directories.
# Minimum value: 0, maximum value: 8, default value: 8.
# This tag requires that the tag CREATE_SUBDIRS is set to YES.
CREATE_SUBDIRS_LEVEL = 8
# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII
# characters to appear in the names of generated files. If set to NO, non-ASCII
# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode
# U+3044.
# The default value is: NO.
ALLOW_UNICODE_NAMES = NO
# The OUTPUT_LANGUAGE tag is used to specify the language in which all
# documentation generated by doxygen is written. Doxygen will use this
# information to generate all constant output in the proper language.
# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Bulgarian,
# Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, English
# (United States), Esperanto, Farsi (Persian), Finnish, French, German, Greek,
# Hindi, Hungarian, Indonesian, Italian, Japanese, Japanese-en (Japanese with
# English messages), Korean, Korean-en (Korean with English messages), Latvian,
# Lithuanian, Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese,
# Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish,
# Swedish, Turkish, Ukrainian and Vietnamese.
# The default value is: English.
OUTPUT_LANGUAGE = English
# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member
# descriptions after the members that are listed in the file and class
# documentation (similar to Javadoc). Set to NO to disable this.
# The default value is: YES.
BRIEF_MEMBER_DESC = YES
# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief
# description of a member or function before the detailed description
#
# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
# brief descriptions will be completely suppressed.
# The default value is: YES.
REPEAT_BRIEF = YES
# This tag implements a quasi-intelligent brief description abbreviator that is
# used to form the text in various listings. Each string in this list, if found
# as the leading text of the brief description, will be stripped from the text
# and the result, after processing the whole list, is used as the annotated
# text. Otherwise, the brief description is used as-is. If left blank, the
# following values are used ($name is automatically replaced with the name of
# the entity):The $name class, The $name widget, The $name file, is, provides,
# specifies, contains, represents, a, an and the.
ABBREVIATE_BRIEF =
# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
# doxygen will generate a detailed section even if there is only a brief
# description.
# The default value is: NO.
ALWAYS_DETAILED_SEC = NO
# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
# inherited members of a class in the documentation of that class as if those
# members were ordinary class members. Constructors, destructors and assignment
# operators of the base classes will not be shown.
# The default value is: NO.
INLINE_INHERITED_MEMB = NO
# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path
# before files name in the file list and in the header files. If set to NO the
# shortest path that makes the file name unique will be used
# The default value is: YES.
FULL_PATH_NAMES = NO
# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path.
# Stripping is only done if one of the specified strings matches the left-hand
# part of the path. The tag can be used to show relative paths in the file list.
# If left blank the directory from which doxygen is run is used as the path to
# strip.
#
# Note that you can specify absolute paths here, but also relative paths, which
# will be relative from the directory where doxygen is started.
# This tag requires that the tag FULL_PATH_NAMES is set to YES.
STRIP_FROM_PATH =
# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the
# path mentioned in the documentation of a class, which tells the reader which
# header file to include in order to use a class. If left blank only the name of
# the header file containing the class definition is used. Otherwise one should
# specify the list of include paths that are normally passed to the compiler
# using the -I flag.
STRIP_FROM_INC_PATH =
# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but
# less readable) file names. This can be useful is your file systems doesn't
# support long names like on DOS, Mac, or CD-ROM.
# The default value is: NO.
SHORT_NAMES = NO
# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the
# first line (until the first dot) of a Javadoc-style comment as the brief
# description. If set to NO, the Javadoc-style will behave just like regular Qt-
# style comments (thus requiring an explicit @brief command for a brief
# description.)
# The default value is: NO.
JAVADOC_AUTOBRIEF = NO
# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line
# such as
# /***************
# as being the beginning of a Javadoc-style comment "banner". If set to NO, the
# Javadoc-style will behave just like regular comments and it will not be
# interpreted by doxygen.
# The default value is: NO.
JAVADOC_BANNER = NO
# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first
# line (until the first dot) of a Qt-style comment as the brief description. If
# set to NO, the Qt-style will behave just like regular Qt-style comments (thus
# requiring an explicit \brief command for a brief description.)
# The default value is: NO.
QT_AUTOBRIEF = NO
# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a
# multi-line C++ special comment block (i.e. a block of //! or /// comments) as
# a brief description. This used to be the default behavior. The new default is
# to treat a multi-line C++ comment block as a detailed description. Set this
# tag to YES if you prefer the old behavior instead.
#
# Note that setting this tag to YES also means that rational rose comments are
# not recognized any more.
# The default value is: NO.
MULTILINE_CPP_IS_BRIEF = NO
# By default Python docstrings are displayed as preformatted text and doxygen's
# special commands cannot be used. By setting PYTHON_DOCSTRING to NO the
# doxygen's special commands can be used and the contents of the docstring
# documentation blocks is shown as doxygen documentation.
# The default value is: YES.
PYTHON_DOCSTRING = YES
# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the
# documentation from any documented member that it re-implements.
# The default value is: YES.
INHERIT_DOCS = YES
# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new
# page for each member. If set to NO, the documentation of a member will be part
# of the file/class/namespace that contains it.
# The default value is: NO.
SEPARATE_MEMBER_PAGES = NO
# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen
# uses this value to replace tabs by spaces in code fragments.
# Minimum value: 1, maximum value: 16, default value: 4.
TAB_SIZE = 4
# This tag can be used to specify a number of aliases that act as commands in
# the documentation. An alias has the form:
# name=value
# For example adding
# "sideeffect=@par Side Effects:^^"
# will allow you to put the command \sideeffect (or @sideeffect) in the
# documentation, which will result in a user-defined paragraph with heading
# "Side Effects:". Note that you cannot put \n's in the value part of an alias
# to insert newlines (in the resulting output). You can put ^^ in the value part
# of an alias to insert a newline as if a physical newline was in the original
# file. When you need a literal { or } or , in the value part of an alias you
# have to escape them by means of a backslash (\), this can lead to conflicts
# with the commands \{ and \} for these it is advised to use the version @{ and
# @} or use a double escape (\\{ and \\})
ALIASES =
# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
# only. Doxygen will then generate output that is more tailored for C. For
# instance, some of the names that are used will be different. The list of all
# members will be omitted, etc.
# The default value is: NO.
OPTIMIZE_OUTPUT_FOR_C = NO
# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or
# Python sources only. Doxygen will then generate output that is more tailored
# for that language. For instance, namespaces will be presented as packages,
# qualified scopes will look different, etc.
# The default value is: NO.
OPTIMIZE_OUTPUT_JAVA = NO
# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
# sources. Doxygen will then generate output that is tailored for Fortran.
# The default value is: NO.
OPTIMIZE_FOR_FORTRAN = NO
# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
# sources. Doxygen will then generate output that is tailored for VHDL.
# The default value is: NO.
OPTIMIZE_OUTPUT_VHDL = NO
# Set the OPTIMIZE_OUTPUT_SLICE tag to YES if your project consists of Slice
# sources only. Doxygen will then generate output that is more tailored for that
# language. For instance, namespaces will be presented as modules, types will be
# separated into more groups, etc.
# The default value is: NO.
OPTIMIZE_OUTPUT_SLICE = NO
# Doxygen selects the parser to use depending on the extension of the files it
# parses. With this tag you can assign which parser to use for a given
# extension. Doxygen has a built-in mapping, but you can override or extend it
# using this tag. The format is ext=language, where ext is a file extension, and
# language is one of the parsers supported by doxygen: IDL, Java, JavaScript,
# Csharp (C#), C, C++, Lex, D, PHP, md (Markdown), Objective-C, Python, Slice,
# VHDL, Fortran (fixed format Fortran: FortranFixed, free formatted Fortran:
# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser
# tries to guess whether the code is fixed or free formatted code, this is the
# default for Fortran type files). For instance to make doxygen treat .inc files
# as Fortran files (default is PHP), and .f files as C (default is Fortran),
# use: inc=Fortran f=C.
#
# Note: For files without extension you can use no_extension as a placeholder.
#
# Note that for custom extensions you also need to set FILE_PATTERNS otherwise
# the files are not read by doxygen. When specifying no_extension you should add
# * to the FILE_PATTERNS.
#
# Note see also the list of default file extension mappings.
EXTENSION_MAPPING = cu=C++ \
cuh=C++
# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments
# according to the Markdown format, which allows for more readable
# documentation. See https://daringfireball.net/projects/markdown/ for details.
# The output of markdown processing is further processed by doxygen, so you can
# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in
# case of backward compatibilities issues.
# The default value is: YES.
MARKDOWN_SUPPORT = YES
# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up
# to that level are automatically included in the table of contents, even if
# they do not have an id attribute.
# Note: This feature currently applies only to Markdown headings.
# Minimum value: 0, maximum value: 99, default value: 5.
# This tag requires that the tag MARKDOWN_SUPPORT is set to YES.
TOC_INCLUDE_HEADINGS = 5
# The MARKDOWN_ID_STYLE tag can be used to specify the algorithm used to
# generate identifiers for the Markdown headings. Note: Every identifier is
# unique.
# Possible values are: DOXYGEN Use a fixed 'autotoc_md' string followed by a
# sequence number starting at 0. and GITHUB Use the lower case version of title
# with any whitespace replaced by '-' and punctations characters removed..
# The default value is: DOXYGEN.
# This tag requires that the tag MARKDOWN_SUPPORT is set to YES.
MARKDOWN_ID_STYLE = DOXYGEN
# When enabled doxygen tries to link words that correspond to documented
# classes, or namespaces to their corresponding documentation. Such a link can
# be prevented in individual cases by putting a % sign in front of the word or
# globally by setting AUTOLINK_SUPPORT to NO.
# The default value is: YES.
AUTOLINK_SUPPORT = YES
# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
# to include (a tag file for) the STL sources as input, then you should set this
# tag to YES in order to let doxygen match functions declarations and
# definitions whose arguments contain STL classes (e.g. func(std::string);
# versus func(std::string) {}). This also make the inheritance and collaboration
# diagrams that involve STL classes more complete and accurate.
# The default value is: NO.
BUILTIN_STL_SUPPORT = NO
# If you use Microsoft's C++/CLI language, you should set this option to YES to
# enable parsing support.
# The default value is: NO.
CPP_CLI_SUPPORT = NO
# Set the SIP_SUPPORT tag to YES if your project consists of sip (see:
# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen
# will parse them like normal C++ but will assume all classes use public instead
# of private inheritance when no explicit protection keyword is present.
# The default value is: NO.
SIP_SUPPORT = NO
# For Microsoft's IDL there are propget and propput attributes to indicate
# getter and setter methods for a property. Setting this option to YES will make
# doxygen to replace the get and set methods by a property in the documentation.
# This will only work if the methods are indeed getting or setting a simple
# type. If this is not the case, or you want to show the methods anyway, you
# should set this option to NO.
# The default value is: YES.
IDL_PROPERTY_SUPPORT = YES
# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
# tag is set to YES then doxygen will reuse the documentation of the first
# member in the group (if any) for the other members of the group. By default
# all members of a group must be documented explicitly.
# The default value is: NO.
DISTRIBUTE_GROUP_DOC = NO
# If one adds a struct or class to a group and this option is enabled, then also
# any nested class or struct is added to the same group. By default this option
# is disabled and one has to add nested compounds explicitly via \ingroup.
# The default value is: NO.
GROUP_NESTED_COMPOUNDS = NO
# Set the SUBGROUPING tag to YES to allow class member groups of the same type
# (for instance a group of public functions) to be put as a subgroup of that
# type (e.g. under the Public Functions section). Set it to NO to prevent
# subgrouping. Alternatively, this can be done per class using the
# \nosubgrouping command.
# The default value is: YES.
SUBGROUPING = YES
# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions
# are shown inside the group in which they are included (e.g. using \ingroup)
# instead of on a separate page (for HTML and Man pages) or section (for LaTeX
# and RTF).
#
# Note that this feature does not work in combination with
# SEPARATE_MEMBER_PAGES.
# The default value is: NO.
INLINE_GROUPED_CLASSES = NO
# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions
# with only public data fields or simple typedef fields will be shown inline in
# the documentation of the scope in which they are defined (i.e. file,
# namespace, or group documentation), provided this scope is documented. If set
# to NO, structs, classes, and unions are shown on a separate page (for HTML and
# Man pages) or section (for LaTeX and RTF).
# The default value is: NO.
INLINE_SIMPLE_STRUCTS = NO
# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or
# enum is documented as struct, union, or enum with the name of the typedef. So
# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
# with name TypeT. When disabled the typedef will appear as a member of a file,
# namespace, or class. And the struct will be named TypeS. This can typically be
# useful for C code in case the coding convention dictates that all compound
# types are typedef'ed and only the typedef is referenced, never the tag name.
# The default value is: NO.
TYPEDEF_HIDES_STRUCT = NO
# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This
# cache is used to resolve symbols given their name and scope. Since this can be
# an expensive process and often the same symbol appears multiple times in the
# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small
# doxygen will become slower. If the cache is too large, memory is wasted. The
# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range
# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536
# symbols. At the end of a run doxygen will report the cache usage and suggest
# the optimal cache size from a speed point of view.
# Minimum value: 0, maximum value: 9, default value: 0.
LOOKUP_CACHE_SIZE = 0
# The NUM_PROC_THREADS specifies the number of threads doxygen is allowed to use
# during processing. When set to 0 doxygen will based this on the number of
# cores available in the system. You can set it explicitly to a value larger
# than 0 to get more control over the balance between CPU load and processing
# speed. At this moment only the input processing can be done using multiple
# threads. Since this is still an experimental feature the default is set to 1,
# which effectively disables parallel processing. Please report any issues you
# encounter. Generating dot graphs in parallel is controlled by the
# DOT_NUM_THREADS setting.
# Minimum value: 0, maximum value: 32, default value: 1.
NUM_PROC_THREADS = 1
# If the TIMESTAMP tag is set different from NO then each generated page will
# contain the date or date and time when the page was generated. Setting this to
# NO can help when comparing the output of multiple runs.
# Possible values are: YES, NO, DATETIME and DATE.
# The default value is: NO.
TIMESTAMP = NO
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in
# documentation are documented, even if no documentation was available. Private
# class members and static file members will be hidden unless the
# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES.
# Note: This will also disable the warnings about undocumented members that are
# normally produced when WARNINGS is set to YES.
# The default value is: NO.
EXTRACT_ALL = NO
# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will
# be included in the documentation.
# The default value is: NO.
EXTRACT_PRIVATE = NO
# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual
# methods of a class will be included in the documentation.
# The default value is: NO.
EXTRACT_PRIV_VIRTUAL = NO
# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal
# scope will be included in the documentation.
# The default value is: NO.
EXTRACT_PACKAGE = NO
# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be
# included in the documentation.
# The default value is: NO.
EXTRACT_STATIC = NO
# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined
# locally in source files will be included in the documentation. If set to NO,
# only classes defined in header files are included. Does not have any effect
# for Java sources.
# The default value is: YES.
EXTRACT_LOCAL_CLASSES = YES
# This flag is only useful for Objective-C code. If set to YES, local methods,
# which are defined in the implementation section but not in the interface are
# included in the documentation. If set to NO, only methods in the interface are
# included.
# The default value is: NO.
EXTRACT_LOCAL_METHODS = NO
# If this flag is set to YES, the members of anonymous namespaces will be
# extracted and appear in the documentation as a namespace called
# 'anonymous_namespace{file}', where file will be replaced with the base name of
# the file that contains the anonymous namespace. By default anonymous namespace
# are hidden.
# The default value is: NO.
EXTRACT_ANON_NSPACES = NO
# If this flag is set to YES, the name of an unnamed parameter in a declaration
# will be determined by the corresponding definition. By default unnamed
# parameters remain unnamed in the output.
# The default value is: YES.
RESOLVE_UNNAMED_PARAMS = YES
# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all
# undocumented members inside documented classes or files. If set to NO these
# members will be included in the various overviews, but no documentation
# section is generated. This option has no effect if EXTRACT_ALL is enabled.
# The default value is: NO.
HIDE_UNDOC_MEMBERS = NO
# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all
# undocumented classes that are normally visible in the class hierarchy. If set
# to NO, these classes will be included in the various overviews. This option
# will also hide undocumented C++ concepts if enabled. This option has no effect
# if EXTRACT_ALL is enabled.
# The default value is: NO.
HIDE_UNDOC_CLASSES = NO
# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend
# declarations. If set to NO, these declarations will be included in the
# documentation.
# The default value is: NO.
HIDE_FRIEND_COMPOUNDS = NO
# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any
# documentation blocks found inside the body of a function. If set to NO, these
# blocks will be appended to the function's detailed documentation block.
# The default value is: NO.
HIDE_IN_BODY_DOCS = NO
# The INTERNAL_DOCS tag determines if documentation that is typed after a
# \internal command is included. If the tag is set to NO then the documentation
# will be excluded. Set it to YES to include the internal documentation.
# The default value is: NO.
INTERNAL_DOCS = NO
# With the correct setting of option CASE_SENSE_NAMES doxygen will better be
# able to match the capabilities of the underlying filesystem. In case the
# filesystem is case sensitive (i.e. it supports files in the same directory
# whose names only differ in casing), the option must be set to YES to properly
# deal with such files in case they appear in the input. For filesystems that
# are not case sensitive the option should be set to NO to properly deal with
# output files written for symbols that only differ in casing, such as for two
# classes, one named CLASS and the other named Class, and to also support
# references to files without having to specify the exact matching casing. On
# Windows (including Cygwin) and MacOS, users should typically set this option
# to NO, whereas on Linux or other Unix flavors it should typically be set to
# YES.
# Possible values are: SYSTEM, NO and YES.
# The default value is: SYSTEM.
CASE_SENSE_NAMES = YES
# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with
# their full class and namespace scopes in the documentation. If set to YES, the
# scope will be hidden.
# The default value is: NO.
HIDE_SCOPE_NAMES = NO
# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will
# append additional text to a page's title, such as Class Reference. If set to
# YES the compound reference will be hidden.
# The default value is: NO.
HIDE_COMPOUND_REFERENCE= NO
# If the SHOW_HEADERFILE tag is set to YES then the documentation for a class
# will show which file needs to be included to use the class.
# The default value is: YES.
SHOW_HEADERFILE = YES
# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of
# the files that are included by a file in the documentation of that file.
# The default value is: YES.
SHOW_INCLUDE_FILES = YES
# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each
# grouped member an include statement to the documentation, telling the reader
# which file to include in order to use the member.
# The default value is: NO.
SHOW_GROUPED_MEMB_INC = NO
# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include
# files with double quotes in the documentation rather than with sharp brackets.
# The default value is: NO.
FORCE_LOCAL_INCLUDES = NO
# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the
# documentation for inline members.
# The default value is: YES.
INLINE_INFO = YES
# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the
# (detailed) documentation of file and class members alphabetically by member
# name. If set to NO, the members will appear in declaration order.
# The default value is: YES.
SORT_MEMBER_DOCS = YES
# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief
# descriptions of file, namespace and class members alphabetically by member
# name. If set to NO, the members will appear in declaration order. Note that
# this will also influence the order of the classes in the class list.
# The default value is: NO.
SORT_BRIEF_DOCS = NO
# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the
# (brief and detailed) documentation of class members so that constructors and
# destructors are listed first. If set to NO the constructors will appear in the
# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS.
# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief
# member documentation.
# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting
# detailed member documentation.
# The default value is: NO.
SORT_MEMBERS_CTORS_1ST = NO
# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy
# of group names into alphabetical order. If set to NO the group names will
# appear in their defined order.
# The default value is: NO.
SORT_GROUP_NAMES = NO
# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by
# fully-qualified names, including namespaces. If set to NO, the class list will
# be sorted only by class name, not including the namespace part.
# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
# Note: This option applies only to the class list, not to the alphabetical
# list.
# The default value is: NO.
SORT_BY_SCOPE_NAME = NO
# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper
# type resolution of all parameters of a function it will reject a match between
# the prototype and the implementation of a member function even if there is
# only one candidate or it is obvious which candidate to choose by doing a
# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still
# accept a match between prototype and implementation in such cases.
# The default value is: NO.
STRICT_PROTO_MATCHING = NO
# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo
# list. This list is created by putting \todo commands in the documentation.
# The default value is: YES.
GENERATE_TODOLIST = YES
# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test
# list. This list is created by putting \test commands in the documentation.
# The default value is: YES.
GENERATE_TESTLIST = YES
# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug
# list. This list is created by putting \bug commands in the documentation.
# The default value is: YES.
GENERATE_BUGLIST = YES
# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO)
# the deprecated list. This list is created by putting \deprecated commands in
# the documentation.
# The default value is: YES.
GENERATE_DEPRECATEDLIST= YES
# The ENABLED_SECTIONS tag can be used to enable conditional documentation
# sections, marked by \if <section_label> ... \endif and \cond <section_label>
# ... \endcond blocks.
ENABLED_SECTIONS =
# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the
# initial value of a variable or macro / define can have for it to appear in the
# documentation. If the initializer consists of more lines than specified here
# it will be hidden. Use a value of 0 to hide initializers completely. The
# appearance of the value of individual variables and macros / defines can be
# controlled using \showinitializer or \hideinitializer command in the
# documentation regardless of this setting.
# Minimum value: 0, maximum value: 10000, default value: 30.
MAX_INITIALIZER_LINES = 30
# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at
# the bottom of the documentation of classes and structs. If set to YES, the
# list will mention the files that were used to generate the documentation.
# The default value is: YES.
SHOW_USED_FILES = YES
# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This
# will remove the Files entry from the Quick Index and from the Folder Tree View
# (if specified).
# The default value is: YES.
SHOW_FILES = YES
# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces
# page. This will remove the Namespaces entry from the Quick Index and from the
# Folder Tree View (if specified).
# The default value is: YES.
SHOW_NAMESPACES = YES
# The FILE_VERSION_FILTER tag can be used to specify a program or script that
# doxygen should invoke to get the current version for each file (typically from
# the version control system). Doxygen will invoke the program by executing (via
# popen()) the command command input-file, where command is the value of the
# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided
# by doxygen. Whatever the program writes to standard output is used as the file
# version. For an example see the documentation.
FILE_VERSION_FILTER =
# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
# by doxygen. The layout file controls the global structure of the generated
# output files in an output format independent way. To create the layout file
# that represents doxygen's defaults, run doxygen with the -l option. You can
# optionally specify a file name after the option, if omitted DoxygenLayout.xml
# will be used as the name of the layout file. See also section "Changing the
# layout of pages" for information.
#
# Note that if you run doxygen from a directory containing a file called
# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE
# tag is left empty.
LAYOUT_FILE = DoxygenLayout.xml
# The CITE_BIB_FILES tag can be used to specify one or more bib files containing
# the reference definitions. This must be a list of .bib files. The .bib
# extension is automatically appended if omitted. This requires the bibtex tool
# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info.
# For LaTeX the style of the bibliography can be controlled using
# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the
# search path. See also \cite for info how to create references.
CITE_BIB_FILES =
#---------------------------------------------------------------------------
# Configuration options related to warning and progress messages
#---------------------------------------------------------------------------
# The QUIET tag can be used to turn on/off the messages that are generated to
# standard output by doxygen. If QUIET is set to YES this implies that the
# messages are off.
# The default value is: NO.
QUIET = NO
# The WARNINGS tag can be used to turn on/off the warning messages that are
# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES
# this implies that the warnings are on.
#
# Tip: Turn warnings on while writing the documentation.
# The default value is: YES.
WARNINGS = YES
# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate
# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag
# will automatically be disabled.
# The default value is: YES.
WARN_IF_UNDOCUMENTED = YES
# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for
# potential errors in the documentation, such as documenting some parameters in
# a documented function twice, or documenting parameters that don't exist or
# using markup commands wrongly.
# The default value is: YES.
WARN_IF_DOC_ERROR = YES
# If WARN_IF_INCOMPLETE_DOC is set to YES, doxygen will warn about incomplete
# function parameter documentation. If set to NO, doxygen will accept that some
# parameters have no documentation without warning.
# The default value is: YES.
WARN_IF_INCOMPLETE_DOC = YES
# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that
# are documented, but have no documentation for their parameters or return
# value. If set to NO, doxygen will only warn about wrong parameter
# documentation, but not about the absence of documentation. If EXTRACT_ALL is
# set to YES then this flag will automatically be disabled. See also
# WARN_IF_INCOMPLETE_DOC
# The default value is: NO.
WARN_NO_PARAMDOC = YES
# If WARN_IF_UNDOC_ENUM_VAL option is set to YES, doxygen will warn about
# undocumented enumeration values. If set to NO, doxygen will accept
# undocumented enumeration values. If EXTRACT_ALL is set to YES then this flag
# will automatically be disabled.
# The default value is: NO.
WARN_IF_UNDOC_ENUM_VAL = NO
# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when
# a warning is encountered. If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS
# then doxygen will continue running as if WARN_AS_ERROR tag is set to NO, but
# at the end of the doxygen process doxygen will return with a non-zero status.
# If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS_PRINT then doxygen behaves
# like FAIL_ON_WARNINGS but in case no WARN_LOGFILE is defined doxygen will not
# write the warning messages in between other messages but write them at the end
# of a run, in case a WARN_LOGFILE is defined the warning messages will be
# besides being in the defined file also be shown at the end of a run, unless
# the WARN_LOGFILE is defined as - i.e. standard output (stdout) in that case
# the behavior will remain as with the setting FAIL_ON_WARNINGS.
# Possible values are: NO, YES, FAIL_ON_WARNINGS and FAIL_ON_WARNINGS_PRINT.
# The default value is: NO.
WARN_AS_ERROR = NO
# The WARN_FORMAT tag determines the format of the warning messages that doxygen
# can produce. The string should contain the $file, $line, and $text tags, which
# will be replaced by the file and line number from which the warning originated
# and the warning text. Optionally the format may contain $version, which will
# be replaced by the version of the file (if it could be obtained via
# FILE_VERSION_FILTER)
# See also: WARN_LINE_FORMAT
# The default value is: $file:$line: $text.
WARN_FORMAT = "$file:$line: $text"
# In the $text part of the WARN_FORMAT command it is possible that a reference
# to a more specific place is given. To make it easier to jump to this place
# (outside of doxygen) the user can define a custom "cut" / "paste" string.
# Example:
# WARN_LINE_FORMAT = "'vi $file +$line'"
# See also: WARN_FORMAT
# The default value is: at line $line of file $file.
WARN_LINE_FORMAT = "at line $line of file $file"
# The WARN_LOGFILE tag can be used to specify a file to which warning and error
# messages should be written. If left blank the output is written to standard
# error (stderr). In case the file specified cannot be opened for writing the
# warning and error messages are written to standard error. When as file - is
# specified the warning and error messages are written to standard output
# (stdout).
WARN_LOGFILE =
#---------------------------------------------------------------------------
# Configuration options related to the input files
#---------------------------------------------------------------------------
# The INPUT tag is used to specify the files and/or directories that contain
# documented source files. You may enter file names like myfile.cpp or
# directories like /usr/src/myproject. Separate the files or directories with
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.
INPUT = main_page.md \
../include
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
# libiconv (or the iconv built into libc) for the transcoding. See the libiconv
# documentation (see:
# https://www.gnu.org/software/libiconv/) for the list of possible encodings.
# See also: INPUT_FILE_ENCODING
# The default value is: UTF-8.
INPUT_ENCODING = UTF-8
# This tag can be used to specify the character encoding of the source files
# that doxygen parses The INPUT_FILE_ENCODING tag can be used to specify
# character encoding on a per file pattern basis. Doxygen will compare the file
# name with each pattern and apply the encoding instead of the default
# INPUT_ENCODING) if there is a match. The character encodings are a list of the
# form: pattern=encoding (like *.php=ISO-8859-1). See cfg_input_encoding
# "INPUT_ENCODING" for further information on supported encodings.
INPUT_FILE_ENCODING =
# If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and
# *.h) to filter out the source-files in the directories.
#
# Note that for custom extensions or not directly supported extensions you also
# need to set EXTENSION_MAPPING for the extension otherwise the files are not
# read by doxygen.
#
# Note the list of default checked file patterns might differ from the list of
# default file extension mappings.
#
# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp,
# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h,
# *.hh, *.hxx, *.hpp, *.h++, *.l, *.cs, *.d, *.php, *.php4, *.php5, *.phtml,
# *.inc, *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C
# comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd,
# *.vhdl, *.ucf, *.qsf and *.ice.
FILE_PATTERNS = *.cpp \
*.hpp \
*.h \
*.c \
*.cu \
*.cuh
# The RECURSIVE tag can be used to specify whether or not subdirectories should
# be searched for input files as well.
# The default value is: NO.
RECURSIVE = YES
# The EXCLUDE tag can be used to specify files and/or directories that should be
# excluded from the INPUT source files. This way you can easily exclude a
# subdirectory from a directory tree whose root is specified with the INPUT tag.
#
# Note that relative paths are relative to the directory from which doxygen is
# run.
EXCLUDE =
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
# directories that are symbolic links (a Unix file system feature) are excluded
# from the input.
# The default value is: NO.
EXCLUDE_SYMLINKS = NO
# If the value of the INPUT tag contains directories, you can use the
# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
# certain files from those directories.
#
# Note that the wildcards are matched against the file with absolute path, so to
# exclude all test directories for example use the pattern */test/*
EXCLUDE_PATTERNS = */detail/* \
*/nvtx/*
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
# (namespaces, classes, functions, etc.) that should be excluded from the
# output. The symbol name can be a fully qualified name, a word, or if the
# wildcard * is used, a substring. Examples: ANamespace, AClass,
# ANamespace::AClass, ANamespace::*Test
EXCLUDE_SYMBOLS = org::apache
# The EXAMPLE_PATH tag can be used to specify one or more files or directories
# that contain example code fragments that are included (see the \include
# command).
EXAMPLE_PATH =
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and
# *.h) to filter out the source-files in the directories. If left blank all
# files are included.
EXAMPLE_PATTERNS =
# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
# searched for input files to be used with the \include or \dontinclude commands
# irrespective of the value of the RECURSIVE tag.
# The default value is: NO.
EXAMPLE_RECURSIVE = NO
# The IMAGE_PATH tag can be used to specify one or more files or directories
# that contain images that are to be included in the documentation (see the
# \image command).
IMAGE_PATH =
# The INPUT_FILTER tag can be used to specify a program that doxygen should
# invoke to filter for each input file. Doxygen will invoke the filter program
# by executing (via popen()) the command:
#
# <filter> <input-file>
#
# where <filter> is the value of the INPUT_FILTER tag, and <input-file> is the
# name of an input file. Doxygen will then use the output that the filter
# program writes to standard output. If FILTER_PATTERNS is specified, this tag
# will be ignored.
#
# Note that the filter must not add or remove lines; it is applied before the
# code is scanned, but not when the output code is generated. If lines are added
# or removed, the anchors will not be placed correctly.
#
# Note that doxygen will use the data processed and written to standard output
# for further processing, therefore nothing else, like debug statements or used
# commands (so in case of a Windows batch file always use @echo OFF), should be
# written to standard output.
#
# Note that for custom extensions or not directly supported extensions you also
# need to set EXTENSION_MAPPING for the extension otherwise the files are not
# properly processed by doxygen.
INPUT_FILTER =
# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
# basis. Doxygen will compare the file name with each pattern and apply the
# filter if there is a match. The filters are a list of the form: pattern=filter
# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how
# filters are used. If the FILTER_PATTERNS tag is empty or if none of the
# patterns match the file name, INPUT_FILTER is applied.
#
# Note that for custom extensions or not directly supported extensions you also
# need to set EXTENSION_MAPPING for the extension otherwise the files are not
# properly processed by doxygen.
FILTER_PATTERNS = *.md=./modify_fences.sh
# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
# INPUT_FILTER) will also be used to filter the input files that are used for
# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES).
# The default value is: NO.
FILTER_SOURCE_FILES = NO
# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file
# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and
# it is also possible to disable source filtering for a specific pattern using
# *.ext= (so without naming a filter).
# This tag requires that the tag FILTER_SOURCE_FILES is set to YES.
FILTER_SOURCE_PATTERNS =
# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that
# is part of the input, its contents will be placed on the main page
# (index.html). This can be useful if you have a project on for instance GitHub
# and want to reuse the introduction page also for the doxygen output.
USE_MDFILE_AS_MAINPAGE = main_page.md
# The Fortran standard specifies that for fixed formatted Fortran code all
# characters from position 72 are to be considered as comment. A common
# extension is to allow longer lines before the automatic comment starts. The
# setting FORTRAN_COMMENT_AFTER will also make it possible that longer lines can
# be processed before the automatic comment starts.
# Minimum value: 7, maximum value: 10000, default value: 72.
FORTRAN_COMMENT_AFTER = 72
#---------------------------------------------------------------------------
# Configuration options related to source browsing
#---------------------------------------------------------------------------
# If the SOURCE_BROWSER tag is set to YES then a list of source files will be
# generated. Documented entities will be cross-referenced with these sources.
#
# Note: To get rid of all source code in the generated output, make sure that
# also VERBATIM_HEADERS is set to NO.
# The default value is: NO.
SOURCE_BROWSER = YES
# Setting the INLINE_SOURCES tag to YES will include the body of functions,
# classes and enums directly into the documentation.
# The default value is: NO.
INLINE_SOURCES = NO
# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any
# special comment blocks from generated source code fragments. Normal C, C++ and
# Fortran comments will always remain visible.
# The default value is: YES.
STRIP_CODE_COMMENTS = YES
# If the REFERENCED_BY_RELATION tag is set to YES then for each documented
# entity all documented functions referencing it will be listed.
# The default value is: NO.
REFERENCED_BY_RELATION = NO
# If the REFERENCES_RELATION tag is set to YES then for each documented function
# all documented entities called/used by that function will be listed.
# The default value is: NO.
REFERENCES_RELATION = NO
# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set
# to YES then the hyperlinks from functions in REFERENCES_RELATION and
# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will
# link to the documentation.
# The default value is: YES.
REFERENCES_LINK_SOURCE = YES
# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the
# source code will show a tooltip with additional information such as prototype,
# brief description and links to the definition and documentation. Since this
# will make the HTML file larger and loading of large files a bit slower, you
# can opt to disable this feature.
# The default value is: YES.
# This tag requires that the tag SOURCE_BROWSER is set to YES.
SOURCE_TOOLTIPS = YES
# If the USE_HTAGS tag is set to YES then the references to source code will
# point to the HTML generated by the htags(1) tool instead of doxygen built-in
# source browser. The htags tool is part of GNU's global source tagging system
# (see https://www.gnu.org/software/global/global.html). You will need version
# 4.8.6 or higher.
#
# To use it do the following:
# - Install the latest version of global
# - Enable SOURCE_BROWSER and USE_HTAGS in the configuration file
# - Make sure the INPUT points to the root of the source tree
# - Run doxygen as normal
#
# Doxygen will invoke htags (and that will in turn invoke gtags), so these
# tools must be available from the command line (i.e. in the search path).
#
# The result: instead of the source browser generated by doxygen, the links to
# source code will now point to the output of htags.
# The default value is: NO.
# This tag requires that the tag SOURCE_BROWSER is set to YES.
USE_HTAGS = NO
# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a
# verbatim copy of the header file for each class for which an include is
# specified. Set to NO to disable this.
# See also: Section \class.
# The default value is: YES.
VERBATIM_HEADERS = YES
#---------------------------------------------------------------------------
# Configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all
# compounds will be generated. Enable this if the project contains a lot of
# classes, structs, unions or interfaces.
# The default value is: YES.
ALPHABETICAL_INDEX = YES
# The IGNORE_PREFIX tag can be used to specify a prefix (or a list of prefixes)
# that should be ignored while generating the index headers. The IGNORE_PREFIX
# tag works for classes, function and member names. The entity will be placed in
# the alphabetical list under the first letter of the entity name that remains
# after removing the prefix.
# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the HTML output
#---------------------------------------------------------------------------
# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output
# The default value is: YES.
GENERATE_HTML = YES
# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a
# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
# it.
# The default directory is: html.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_OUTPUT = html
# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each
# generated HTML page (for example: .htm, .php, .asp).
# The default value is: .html.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_FILE_EXTENSION = .html
# The HTML_HEADER tag can be used to specify a user-defined HTML header file for
# each generated HTML page. If the tag is left blank doxygen will generate a
# standard header.
#
# To get valid HTML the header file that includes any scripts and style sheets
# that doxygen needs, which is dependent on the configuration options used (e.g.
# the setting GENERATE_TREEVIEW). It is highly recommended to start with a
# default header using
# doxygen -w html new_header.html new_footer.html new_stylesheet.css
# YourConfigFile
# and then modify the file new_header.html. See also section "Doxygen usage"
# for information on how to generate the default header that doxygen normally
# uses.
# Note: The header is subject to change so you typically have to regenerate the
# default header when upgrading to a newer version of doxygen. For a description
# of the possible markers and block names see the documentation.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_HEADER = header.html
# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each
# generated HTML page. If the tag is left blank doxygen will generate a standard
# footer. See HTML_HEADER for more information on how to generate a default
# footer and what special commands can be used inside the footer. See also
# section "Doxygen usage" for information on how to generate the default footer
# that doxygen normally uses.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_FOOTER =
# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style
# sheet that is used by each HTML page. It can be used to fine-tune the look of
# the HTML output. If left blank doxygen will generate a default style sheet.
# See also section "Doxygen usage" for information on how to generate the style
# sheet that doxygen normally uses.
# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as
# it is more robust and this tag (HTML_STYLESHEET) will in the future become
# obsolete.
# This tag requires that the tag GENERATE_HTML is set to YES.
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
# created by doxygen. Using this option one can overrule certain style aspects.
# This is preferred over using HTML_STYLESHEET since it does not replace the
# standard style sheet and is therefore more robust against future updates.
# Doxygen will copy the style sheet files to the output directory.
# Note: The order of the extra style sheet files is of importance (e.g. the last
# style sheet in the list overrules the setting of the previous ones in the
# list).
# Note: Since the styling of scrollbars can currently not be overruled in
# Webkit/Chromium, the styling will be left out of the default doxygen.css if
# one or more extra stylesheets have been specified. So if scrollbar
# customization is desired it has to be added explicitly. For an example see the
# documentation.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_EXTRA_STYLESHEET =
# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
# other source files which should be copied to the HTML output directory. Note
# that these files will be copied to the base HTML output directory. Use the
# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these
# files. In the HTML_STYLESHEET file, use the file name only. Also note that the
# files will be copied as-is; there are no commands or markers available.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_EXTRA_FILES =
# The HTML_COLORSTYLE tag can be used to specify if the generated HTML output
# should be rendered with a dark or light theme.
# Possible values are: LIGHT always generate light mode output, DARK always
# generate dark mode output, AUTO_LIGHT automatically set the mode according to
# the user preference, use light mode if no preference is set (the default),
# AUTO_DARK automatically set the mode according to the user preference, use
# dark mode if no preference is set and TOGGLE allow to user to switch between
# light and dark mode via a button.
# The default value is: AUTO_LIGHT.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_COLORSTYLE = AUTO_LIGHT
# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
# will adjust the colors in the style sheet and background images according to
# this color. Hue is specified as an angle on a color-wheel, see
# https://en.wikipedia.org/wiki/Hue for more information. For instance the value
# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300
# purple, and 360 is red again.
# Minimum value: 0, maximum value: 359, default value: 220.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_COLORSTYLE_HUE = 266
# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors
# in the HTML output. For a value of 0 the output will use gray-scales only. A
# value of 255 will produce the most vivid colors.
# Minimum value: 0, maximum value: 255, default value: 100.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_COLORSTYLE_SAT = 255
# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the
# luminance component of the colors in the HTML output. Values below 100
# gradually make the output lighter, whereas values above 100 make the output
# darker. The value divided by 100 is the actual gamma applied, so 80 represents
# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not
# change the gamma.
# Minimum value: 40, maximum value: 240, default value: 80.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_COLORSTYLE_GAMMA = 52
# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML
# documentation will contain a main index with vertical navigation menus that
# are dynamically created via JavaScript. If disabled, the navigation index will
# consists of multiple levels of tabs that are statically embedded in every HTML
# page. Disable this option to support browsers that do not have JavaScript,
# like the Qt help browser.
# The default value is: YES.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_DYNAMIC_MENUS = YES
# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
# documentation will contain sections that can be hidden and shown after the
# page has loaded.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_DYNAMIC_SECTIONS = NO
# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries
# shown in the various tree structured indices initially; the user can expand
# and collapse entries dynamically later on. Doxygen will expand the tree to
# such a level that at most the specified number of entries are visible (unless
# a fully collapsed tree already exceeds this amount). So setting the number of
# entries 1 will produce a full collapsed tree by default. 0 is a special value
# representing an infinite number of entries and will result in a full expanded
# tree by default.
# Minimum value: 0, maximum value: 9999, default value: 100.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_INDEX_NUM_ENTRIES = 100
# If the GENERATE_DOCSET tag is set to YES, additional index files will be
# generated that can be used as input for Apple's Xcode 3 integrated development
# environment (see:
# https://developer.apple.com/xcode/), introduced with OSX 10.5 (Leopard). To
# create a documentation set, doxygen will generate a Makefile in the HTML
# output directory. Running make will produce the docset in that directory and
# running make install will install the docset in
# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at
# startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy
# genXcode/_index.html for more information.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
GENERATE_DOCSET = NO
# This tag determines the name of the docset feed. A documentation feed provides
# an umbrella under which multiple documentation sets from a single provider
# (such as a company or product suite) can be grouped.
# The default value is: Doxygen generated docs.
# This tag requires that the tag GENERATE_DOCSET is set to YES.
DOCSET_FEEDNAME = "Doxygen generated docs"
# This tag determines the URL of the docset feed. A documentation feed provides
# an umbrella under which multiple documentation sets from a single provider
# (such as a company or product suite) can be grouped.
# This tag requires that the tag GENERATE_DOCSET is set to YES.
DOCSET_FEEDURL =
# This tag specifies a string that should uniquely identify the documentation
# set bundle. This should be a reverse domain-name style string, e.g.
# com.mycompany.MyDocSet. Doxygen will append .docset to the name.
# The default value is: org.doxygen.Project.
# This tag requires that the tag GENERATE_DOCSET is set to YES.
DOCSET_BUNDLE_ID = org.doxygen.Project
# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify
# the documentation publisher. This should be a reverse domain-name style
# string, e.g. com.mycompany.MyDocSet.documentation.
# The default value is: org.doxygen.Publisher.
# This tag requires that the tag GENERATE_DOCSET is set to YES.
DOCSET_PUBLISHER_ID = org.doxygen.Publisher
# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher.
# The default value is: Publisher.
# This tag requires that the tag GENERATE_DOCSET is set to YES.
DOCSET_PUBLISHER_NAME = Publisher
# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three
# additional HTML index files: index.hhp, index.hhc, and index.hhk. The
# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop
# on Windows. In the beginning of 2021 Microsoft took the original page, with
# a.o. the download links, offline the HTML help workshop was already many years
# in maintenance mode). You can download the HTML help workshop from the web
# archives at Installation executable (see:
# http://web.archive.org/web/20160201063255/http://download.microsoft.com/downlo
# ad/0/A/9/0A939EF6-E31C-430F-A3DF-DFAE7960D564/htmlhelp.exe).
#
# The HTML Help Workshop contains a compiler that can convert all HTML output
# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML
# files are now used as the Windows 98 help format, and will replace the old
# Windows help format (.hlp) on all Windows platforms in the future. Compressed
# HTML files also contain an index, a table of contents, and you can search for
# words in the documentation. The HTML workshop also contains a viewer for
# compressed HTML files.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
GENERATE_HTMLHELP = NO
# The CHM_FILE tag can be used to specify the file name of the resulting .chm
# file. You can add a path in front of the file if the result should not be
# written to the html output directory.
# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
CHM_FILE =
# The HHC_LOCATION tag can be used to specify the location (absolute path
# including file name) of the HTML help compiler (hhc.exe). If non-empty,
# doxygen will try to run the HTML help compiler on the generated index.hhp.
# The file has to be specified with full path.
# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
HHC_LOCATION =
# The GENERATE_CHI flag controls if a separate .chi index file is generated
# (YES) or that it should be included in the main .chm file (NO).
# The default value is: NO.
# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
GENERATE_CHI = NO
# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc)
# and project file content.
# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
CHM_INDEX_ENCODING =
# The BINARY_TOC flag controls whether a binary table of contents is generated
# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it
# enables the Previous and Next buttons.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
BINARY_TOC = NO
# The TOC_EXPAND flag can be set to YES to add extra items for group members to
# the table of contents of the HTML help documentation and to the tree view.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
TOC_EXPAND = NO
# The SITEMAP_URL tag is used to specify the full URL of the place where the
# generated documentation will be placed on the server by the user during the
# deployment of the documentation. The generated sitemap is called sitemap.xml
# and placed on the directory specified by HTML_OUTPUT. In case no SITEMAP_URL
# is specified no sitemap is generated. For information about the sitemap
# protocol see https://www.sitemaps.org
# This tag requires that the tag GENERATE_HTML is set to YES.
SITEMAP_URL =
# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that
# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help
# (.qch) of the generated HTML documentation.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
GENERATE_QHP = NO
# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify
# the file name of the resulting .qch file. The path specified is relative to
# the HTML output folder.
# This tag requires that the tag GENERATE_QHP is set to YES.
QCH_FILE =
# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help
# Project output. For more information please see Qt Help Project / Namespace
# (see:
# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace).
# The default value is: org.doxygen.Project.
# This tag requires that the tag GENERATE_QHP is set to YES.
QHP_NAMESPACE = org.doxygen.Project
# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt
# Help Project output. For more information please see Qt Help Project / Virtual
# Folders (see:
# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-folders).
# The default value is: doc.
# This tag requires that the tag GENERATE_QHP is set to YES.
QHP_VIRTUAL_FOLDER = doc
# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom
# filter to add. For more information please see Qt Help Project / Custom
# Filters (see:
# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters).
# This tag requires that the tag GENERATE_QHP is set to YES.
QHP_CUST_FILTER_NAME =
# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the
# custom filter to add. For more information please see Qt Help Project / Custom
# Filters (see:
# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters).
# This tag requires that the tag GENERATE_QHP is set to YES.
QHP_CUST_FILTER_ATTRS =
# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
# project's filter section matches. Qt Help Project / Filter Attributes (see:
# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes).
# This tag requires that the tag GENERATE_QHP is set to YES.
QHP_SECT_FILTER_ATTRS =
# The QHG_LOCATION tag can be used to specify the location (absolute path
# including file name) of Qt's qhelpgenerator. If non-empty doxygen will try to
# run qhelpgenerator on the generated .qhp file.
# This tag requires that the tag GENERATE_QHP is set to YES.
QHG_LOCATION =
# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be
# generated, together with the HTML files, they form an Eclipse help plugin. To
# install this plugin and make it available under the help contents menu in
# Eclipse, the contents of the directory containing the HTML and XML files needs
# to be copied into the plugins directory of eclipse. The name of the directory
# within the plugins directory should be the same as the ECLIPSE_DOC_ID value.
# After copying Eclipse needs to be restarted before the help appears.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
GENERATE_ECLIPSEHELP = NO
# A unique identifier for the Eclipse help plugin. When installing the plugin
# the directory name containing the HTML and XML files should also have this
# name. Each documentation set should have its own identifier.
# The default value is: org.doxygen.Project.
# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES.
ECLIPSE_DOC_ID = org.doxygen.Project
# If you want full control over the layout of the generated HTML pages it might
# be necessary to disable the index and replace it with your own. The
# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top
# of each HTML page. A value of NO enables the index and the value YES disables
# it. Since the tabs in the index contain the same information as the navigation
# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
DISABLE_INDEX = NO
# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
# structure should be generated to display hierarchical information. If the tag
# value is set to YES, a side panel will be generated containing a tree-like
# index structure (just like the one that is generated for HTML Help). For this
# to work a browser that supports JavaScript, DHTML, CSS and frames is required
# (i.e. any modern browser). Windows users are probably better off using the
# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can
# further fine tune the look of the index (see "Fine-tuning the output"). As an
# example, the default style sheet generated by doxygen has an example that
# shows how to put an image at the root of the tree instead of the PROJECT_NAME.
# Since the tree basically has the same information as the tab index, you could
# consider setting DISABLE_INDEX to YES when enabling this option.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
GENERATE_TREEVIEW = NO
# When both GENERATE_TREEVIEW and DISABLE_INDEX are set to YES, then the
# FULL_SIDEBAR option determines if the side bar is limited to only the treeview
# area (value NO) or if it should extend to the full height of the window (value
# YES). Setting this to YES gives a layout similar to
# https://docs.readthedocs.io with more room for contents, but less room for the
# project logo, title, and description. If either GENERATE_TREEVIEW or
# DISABLE_INDEX is set to NO, this option has no effect.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
FULL_SIDEBAR = NO
# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that
# doxygen will group on one line in the generated HTML documentation.
#
# Note that a value of 0 will completely suppress the enum values from appearing
# in the overview section.
# Minimum value: 0, maximum value: 20, default value: 4.
# This tag requires that the tag GENERATE_HTML is set to YES.
ENUM_VALUES_PER_LINE = 4
# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used
# to set the initial width (in pixels) of the frame in which the tree is shown.
# Minimum value: 0, maximum value: 1500, default value: 250.
# This tag requires that the tag GENERATE_HTML is set to YES.
TREEVIEW_WIDTH = 250
# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to
# external symbols imported via tag files in a separate window.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
EXT_LINKS_IN_WINDOW = NO
# If the OBFUSCATE_EMAILS tag is set to YES, doxygen will obfuscate email
# addresses.
# The default value is: YES.
# This tag requires that the tag GENERATE_HTML is set to YES.
OBFUSCATE_EMAILS = YES
# If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg
# tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see
# https://inkscape.org) to generate formulas as SVG images instead of PNGs for
# the HTML output. These images will generally look nicer at scaled resolutions.
# Possible values are: png (the default) and svg (looks nicer but requires the
# pdf2svg or inkscape tool).
# The default value is: png.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_FORMULA_FORMAT = png
# Use this tag to change the font size of LaTeX formulas included as images in
# the HTML documentation. When you change the font size after a successful
# doxygen run you need to manually remove any form_*.png images from the HTML
# output directory to force them to be regenerated.
# Minimum value: 8, maximum value: 50, default value: 10.
# This tag requires that the tag GENERATE_HTML is set to YES.
FORMULA_FONTSIZE = 10
# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands
# to create new LaTeX commands to be used in formulas as building blocks. See
# the section "Including formulas" for details.
FORMULA_MACROFILE =
# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
# https://www.mathjax.org) which uses client side JavaScript for the rendering
# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX
# installed or if you want to formulas look prettier in the HTML output. When
# enabled you may also need to install MathJax separately and configure the path
# to it using the MATHJAX_RELPATH option.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
USE_MATHJAX = NO
# With MATHJAX_VERSION it is possible to specify the MathJax version to be used.
# Note that the different versions of MathJax have different requirements with
# regards to the different settings, so it is possible that also other MathJax
# settings have to be changed when switching between the different MathJax
# versions.
# Possible values are: MathJax_2 and MathJax_3.
# The default value is: MathJax_2.
# This tag requires that the tag USE_MATHJAX is set to YES.
MATHJAX_VERSION = MathJax_2
# When MathJax is enabled you can set the default output format to be used for
# the MathJax output. For more details about the output format see MathJax
# version 2 (see:
# http://docs.mathjax.org/en/v2.7-latest/output.html) and MathJax version 3
# (see:
# http://docs.mathjax.org/en/latest/web/components/output.html).
# Possible values are: HTML-CSS (which is slower, but has the best
# compatibility. This is the name for Mathjax version 2, for MathJax version 3
# this will be translated into chtml), NativeMML (i.e. MathML. Only supported
# for NathJax 2. For MathJax version 3 chtml will be used instead.), chtml (This
# is the name for Mathjax version 3, for MathJax version 2 this will be
# translated into HTML-CSS) and SVG.
# The default value is: HTML-CSS.
# This tag requires that the tag USE_MATHJAX is set to YES.
MATHJAX_FORMAT = HTML-CSS
# When MathJax is enabled you need to specify the location relative to the HTML
# output directory using the MATHJAX_RELPATH option. The destination directory
# should contain the MathJax.js script. For instance, if the mathjax directory
# is located at the same level as the HTML output directory, then
# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax
# Content Delivery Network so you can quickly see the result without installing
# MathJax. However, it is strongly recommended to install a local copy of
# MathJax from https://www.mathjax.org before deployment. The default value is:
# - in case of MathJax version 2: https://cdn.jsdelivr.net/npm/mathjax@2
# - in case of MathJax version 3: https://cdn.jsdelivr.net/npm/mathjax@3
# This tag requires that the tag USE_MATHJAX is set to YES.
MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax
# extension names that should be enabled during MathJax rendering. For example
# for MathJax version 2 (see
# https://docs.mathjax.org/en/v2.7-latest/tex.html#tex-and-latex-extensions):
# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols
# For example for MathJax version 3 (see
# http://docs.mathjax.org/en/latest/input/tex/extensions/index.html):
# MATHJAX_EXTENSIONS = ams
# This tag requires that the tag USE_MATHJAX is set to YES.
MATHJAX_EXTENSIONS =
# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces
# of code that will be used on startup of the MathJax code. See the MathJax site
# (see:
# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. For an
# example see the documentation.
# This tag requires that the tag USE_MATHJAX is set to YES.
MATHJAX_CODEFILE =
# When the SEARCHENGINE tag is enabled doxygen will generate a search box for
# the HTML output. The underlying search engine uses javascript and DHTML and
# should work on any modern browser. Note that when using HTML help
# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET)
# there is already a search function so this one should typically be disabled.
# For large projects the javascript based search engine can be slow, then
# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to
# search using the keyboard; to jump to the search box use <access key> + S
# (what the <access key> is depends on the OS and browser, but it is typically
# <CTRL>, <ALT>/<option>, or both). Inside the search box use the <cursor down
# key> to jump into the search results window, the results can be navigated
# using the <cursor keys>. Press <Enter> to select an item or <escape> to cancel
# the search. The filter options can be selected when the cursor is inside the
# search box by pressing <Shift>+<cursor down>. Also here use the <cursor keys>
# to select a filter and <Enter> or <escape> to activate or cancel the filter
# option.
# The default value is: YES.
# This tag requires that the tag GENERATE_HTML is set to YES.
SEARCHENGINE = YES
# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
# implemented using a web server instead of a web client using JavaScript. There
# are two flavors of web server based searching depending on the EXTERNAL_SEARCH
# setting. When disabled, doxygen will generate a PHP script for searching and
# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing
# and searching needs to be provided by external tools. See the section
# "External Indexing and Searching" for details.
# The default value is: NO.
# This tag requires that the tag SEARCHENGINE is set to YES.
SERVER_BASED_SEARCH = NO
# When EXTERNAL_SEARCH tag is enabled doxygen will no longer generate the PHP
# script for searching. Instead the search results are written to an XML file
# which needs to be processed by an external indexer. Doxygen will invoke an
# external search engine pointed to by the SEARCHENGINE_URL option to obtain the
# search results.
#
# Doxygen ships with an example indexer (doxyindexer) and search engine
# (doxysearch.cgi) which are based on the open source search engine library
# Xapian (see:
# https://xapian.org/).
#
# See the section "External Indexing and Searching" for details.
# The default value is: NO.
# This tag requires that the tag SEARCHENGINE is set to YES.
EXTERNAL_SEARCH = NO
# The SEARCHENGINE_URL should point to a search engine hosted by a web server
# which will return the search results when EXTERNAL_SEARCH is enabled.
#
# Doxygen ships with an example indexer (doxyindexer) and search engine
# (doxysearch.cgi) which are based on the open source search engine library
# Xapian (see:
# https://xapian.org/). See the section "External Indexing and Searching" for
# details.
# This tag requires that the tag SEARCHENGINE is set to YES.
SEARCHENGINE_URL =
# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed
# search data is written to a file for indexing by an external tool. With the
# SEARCHDATA_FILE tag the name of this file can be specified.
# The default file is: searchdata.xml.
# This tag requires that the tag SEARCHENGINE is set to YES.
SEARCHDATA_FILE = searchdata.xml
# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the
# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is
# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple
# projects and redirect the results back to the right project.
# This tag requires that the tag SEARCHENGINE is set to YES.
EXTERNAL_SEARCH_ID =
# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen
# projects other than the one defined by this configuration file, but that are
# all added to the same external search index. Each project needs to have a
# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id of
# to a relative location where the documentation can be found. The format is:
# EXTRA_SEARCH_MAPPINGS = tagname1=loc1 tagname2=loc2 ...
# This tag requires that the tag SEARCHENGINE is set to YES.
EXTRA_SEARCH_MAPPINGS =
#---------------------------------------------------------------------------
# Configuration options related to the LaTeX output
#---------------------------------------------------------------------------
# If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output.
# The default value is: YES.
GENERATE_LATEX = NO
# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a
# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
# it.
# The default directory is: latex.
# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_OUTPUT = latex
# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
# invoked.
#
# Note that when not enabling USE_PDFLATEX the default is latex when enabling
# USE_PDFLATEX the default is pdflatex and when in the later case latex is
# chosen this is overwritten by pdflatex. For specific output languages the
# default can have been set differently, this depends on the implementation of
# the output language.
# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_CMD_NAME = latex
# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate
# index for LaTeX.
# Note: This tag is used in the Makefile / make.bat.
# See also: LATEX_MAKEINDEX_CMD for the part in the generated output file
# (.tex).
# The default file is: makeindex.
# This tag requires that the tag GENERATE_LATEX is set to YES.
MAKEINDEX_CMD_NAME = makeindex
# The LATEX_MAKEINDEX_CMD tag can be used to specify the command name to
# generate index for LaTeX. In case there is no backslash (\) as first character
# it will be automatically added in the LaTeX code.
# Note: This tag is used in the generated output file (.tex).
# See also: MAKEINDEX_CMD_NAME for the part in the Makefile / make.bat.
# The default value is: makeindex.
# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_MAKEINDEX_CMD = makeindex
# If the COMPACT_LATEX tag is set to YES, doxygen generates more compact LaTeX
# documents. This may be useful for small projects and may help to save some
# trees in general.
# The default value is: NO.
# This tag requires that the tag GENERATE_LATEX is set to YES.
COMPACT_LATEX = NO
# The PAPER_TYPE tag can be used to set the paper type that is used by the
# printer.
# Possible values are: a4 (210 x 297 mm), letter (8.5 x 11 inches), legal (8.5 x
# 14 inches) and executive (7.25 x 10.5 inches).
# The default value is: a4.
# This tag requires that the tag GENERATE_LATEX is set to YES.
PAPER_TYPE = a4
# The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names
# that should be included in the LaTeX output. The package can be specified just
# by its name or with the correct syntax as to be used with the LaTeX
# \usepackage command. To get the times font for instance you can specify :
# EXTRA_PACKAGES=times or EXTRA_PACKAGES={times}
# To use the option intlimits with the amsmath package you can specify:
# EXTRA_PACKAGES=[intlimits]{amsmath}
# If left blank no extra packages will be included.
# This tag requires that the tag GENERATE_LATEX is set to YES.
EXTRA_PACKAGES =
# The LATEX_HEADER tag can be used to specify a user-defined LaTeX header for
# the generated LaTeX document. The header should contain everything until the
# first chapter. If it is left blank doxygen will generate a standard header. It
# is highly recommended to start with a default header using
# doxygen -w latex new_header.tex new_footer.tex new_stylesheet.sty
# and then modify the file new_header.tex. See also section "Doxygen usage" for
# information on how to generate the default header that doxygen normally uses.
#
# Note: Only use a user-defined header if you know what you are doing!
# Note: The header is subject to change so you typically have to regenerate the
# default header when upgrading to a newer version of doxygen. The following
# commands have a special meaning inside the header (and footer): For a
# description of the possible markers and block names see the documentation.
# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_HEADER =
# The LATEX_FOOTER tag can be used to specify a user-defined LaTeX footer for
# the generated LaTeX document. The footer should contain everything after the
# last chapter. If it is left blank doxygen will generate a standard footer. See
# LATEX_HEADER for more information on how to generate a default footer and what
# special commands can be used inside the footer. See also section "Doxygen
# usage" for information on how to generate the default footer that doxygen
# normally uses. Note: Only use a user-defined footer if you know what you are
# doing!
# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_FOOTER =
# The LATEX_EXTRA_STYLESHEET tag can be used to specify additional user-defined
# LaTeX style sheets that are included after the standard style sheets created
# by doxygen. Using this option one can overrule certain style aspects. Doxygen
# will copy the style sheet files to the output directory.
# Note: The order of the extra style sheet files is of importance (e.g. the last
# style sheet in the list overrules the setting of the previous ones in the
# list).
# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_EXTRA_STYLESHEET =
# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or
# other source files which should be copied to the LATEX_OUTPUT output
# directory. Note that the files will be copied as-is; there are no commands or
# markers available.
# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_EXTRA_FILES =
# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated is
# prepared for conversion to PDF (using ps2pdf or pdflatex). The PDF file will
# contain links (just like the HTML output) instead of page references. This
# makes the output suitable for online browsing using a PDF viewer.
# The default value is: YES.
# This tag requires that the tag GENERATE_LATEX is set to YES.
PDF_HYPERLINKS = YES
# If the USE_PDFLATEX tag is set to YES, doxygen will use the engine as
# specified with LATEX_CMD_NAME to generate the PDF file directly from the LaTeX
# files. Set this option to YES, to get a higher quality PDF documentation.
#
# See also section LATEX_CMD_NAME for selecting the engine.
# The default value is: YES.
# This tag requires that the tag GENERATE_LATEX is set to YES.
USE_PDFLATEX = YES
# The LATEX_BATCHMODE tag ignals the behavior of LaTeX in case of an error.
# Possible values are: NO same as ERROR_STOP, YES same as BATCH, BATCH In batch
# mode nothing is printed on the terminal, errors are scrolled as if <return> is
# hit at every error; missing files that TeX tries to input or request from
# keyboard input (\read on a not open input stream) cause the job to abort,
# NON_STOP In nonstop mode the diagnostic message will appear on the terminal,
# but there is no possibility of user interaction just like in batch mode,
# SCROLL In scroll mode, TeX will stop only for missing files to input or if
# keyboard input is necessary and ERROR_STOP In errorstop mode, TeX will stop at
# each error, asking for user intervention.
# The default value is: NO.
# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_BATCHMODE = NO
# If the LATEX_HIDE_INDICES tag is set to YES then doxygen will not include the
# index chapters (such as File Index, Compound Index, etc.) in the output.
# The default value is: NO.
# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_HIDE_INDICES = NO
# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
# bibliography, e.g. plainnat, or ieeetr. See
# https://en.wikipedia.org/wiki/BibTeX and \cite for more info.
# The default value is: plain.
# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_BIB_STYLE = plain
# The LATEX_EMOJI_DIRECTORY tag is used to specify the (relative or absolute)
# path from which the emoji images will be read. If a relative path is entered,
# it will be relative to the LATEX_OUTPUT directory. If left blank the
# LATEX_OUTPUT directory will be used.
# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_EMOJI_DIRECTORY =
#---------------------------------------------------------------------------
# Configuration options related to the RTF output
#---------------------------------------------------------------------------
# If the GENERATE_RTF tag is set to YES, doxygen will generate RTF output. The
# RTF output is optimized for Word 97 and may not look too pretty with other RTF
# readers/editors.
# The default value is: NO.
GENERATE_RTF = NO
# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. If a
# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
# it.
# The default directory is: rtf.
# This tag requires that the tag GENERATE_RTF is set to YES.
RTF_OUTPUT = rtf
# If the COMPACT_RTF tag is set to YES, doxygen generates more compact RTF
# documents. This may be useful for small projects and may help to save some
# trees in general.
# The default value is: NO.
# This tag requires that the tag GENERATE_RTF is set to YES.
COMPACT_RTF = NO
# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated will
# contain hyperlink fields. The RTF file will contain links (just like the HTML
# output) instead of page references. This makes the output suitable for online
# browsing using Word or some other Word compatible readers that support those
# fields.
#
# Note: WordPad (write) and others do not support links.
# The default value is: NO.
# This tag requires that the tag GENERATE_RTF is set to YES.
RTF_HYPERLINKS = NO
# Load stylesheet definitions from file. Syntax is similar to doxygen's
# configuration file, i.e. a series of assignments. You only have to provide
# replacements, missing definitions are set to their default value.
#
# See also section "Doxygen usage" for information on how to generate the
# default style sheet that doxygen normally uses.
# This tag requires that the tag GENERATE_RTF is set to YES.
RTF_STYLESHEET_FILE =
# Set optional variables used in the generation of an RTF document. Syntax is
# similar to doxygen's configuration file. A template extensions file can be
# generated using doxygen -e rtf extensionFile.
# This tag requires that the tag GENERATE_RTF is set to YES.
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# Configuration options related to the man page output
#---------------------------------------------------------------------------
# If the GENERATE_MAN tag is set to YES, doxygen will generate man pages for
# classes and files.
# The default value is: NO.
GENERATE_MAN = NO
# The MAN_OUTPUT tag is used to specify where the man pages will be put. If a
# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
# it. A directory man3 will be created inside the directory specified by
# MAN_OUTPUT.
# The default directory is: man.
# This tag requires that the tag GENERATE_MAN is set to YES.
MAN_OUTPUT = man
# The MAN_EXTENSION tag determines the extension that is added to the generated
# man pages. In case the manual section does not start with a number, the number
# 3 is prepended. The dot (.) at the beginning of the MAN_EXTENSION tag is
# optional.
# The default value is: .3.
# This tag requires that the tag GENERATE_MAN is set to YES.
MAN_EXTENSION = .3
# The MAN_SUBDIR tag determines the name of the directory created within
# MAN_OUTPUT in which the man pages are placed. If defaults to man followed by
# MAN_EXTENSION with the initial . removed.
# This tag requires that the tag GENERATE_MAN is set to YES.
MAN_SUBDIR =
# If the MAN_LINKS tag is set to YES and doxygen generates man output, then it
# will generate one additional man file for each entity documented in the real
# man page(s). These additional files only source the real man page, but without
# them the man command would be unable to find the correct page.
# The default value is: NO.
# This tag requires that the tag GENERATE_MAN is set to YES.
MAN_LINKS = NO
#---------------------------------------------------------------------------
# Configuration options related to the XML output
#---------------------------------------------------------------------------
# If the GENERATE_XML tag is set to YES, doxygen will generate an XML file that
# captures the structure of the code including all documentation.
# The default value is: NO.
GENERATE_XML = NO
# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a
# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
# it.
# The default directory is: xml.
# This tag requires that the tag GENERATE_XML is set to YES.
XML_OUTPUT = xml
# If the XML_PROGRAMLISTING tag is set to YES, doxygen will dump the program
# listings (including syntax highlighting and cross-referencing information) to
# the XML output. Note that enabling this will significantly increase the size
# of the XML output.
# The default value is: YES.
# This tag requires that the tag GENERATE_XML is set to YES.
XML_PROGRAMLISTING = YES
# If the XML_NS_MEMB_FILE_SCOPE tag is set to YES, doxygen will include
# namespace members in file scope as well, matching the HTML output.
# The default value is: NO.
# This tag requires that the tag GENERATE_XML is set to YES.
XML_NS_MEMB_FILE_SCOPE = NO
#---------------------------------------------------------------------------
# Configuration options related to the DOCBOOK output
#---------------------------------------------------------------------------
# If the GENERATE_DOCBOOK tag is set to YES, doxygen will generate Docbook files
# that can be used to generate PDF.
# The default value is: NO.
GENERATE_DOCBOOK = NO
# The DOCBOOK_OUTPUT tag is used to specify where the Docbook pages will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be put in
# front of it.
# The default directory is: docbook.
# This tag requires that the tag GENERATE_DOCBOOK is set to YES.
DOCBOOK_OUTPUT = docbook
#---------------------------------------------------------------------------
# Configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
# If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an
# AutoGen Definitions (see https://autogen.sourceforge.net/) file that captures
# the structure of the code including all documentation. Note that this feature
# is still experimental and incomplete at the moment.
# The default value is: NO.
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# Configuration options related to the Perl module output
#---------------------------------------------------------------------------
# If the GENERATE_PERLMOD tag is set to YES, doxygen will generate a Perl module
# file that captures the structure of the code including all documentation.
#
# Note that this feature is still experimental and incomplete at the moment.
# The default value is: NO.
GENERATE_PERLMOD = NO
# If the PERLMOD_LATEX tag is set to YES, doxygen will generate the necessary
# Makefile rules, Perl scripts and LaTeX code to be able to generate PDF and DVI
# output from the Perl module output.
# The default value is: NO.
# This tag requires that the tag GENERATE_PERLMOD is set to YES.
PERLMOD_LATEX = NO
# If the PERLMOD_PRETTY tag is set to YES, the Perl module output will be nicely
# formatted so it can be parsed by a human reader. This is useful if you want to
# understand what is going on. On the other hand, if this tag is set to NO, the
# size of the Perl module output will be much smaller and Perl will parse it
# just the same.
# The default value is: YES.
# This tag requires that the tag GENERATE_PERLMOD is set to YES.
PERLMOD_PRETTY = YES
# The names of the make variables in the generated doxyrules.make file are
# prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. This is useful
# so different doxyrules.make files included by the same Makefile don't
# overwrite each other's variables.
# This tag requires that the tag GENERATE_PERLMOD is set to YES.
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
# If the ENABLE_PREPROCESSING tag is set to YES, doxygen will evaluate all
# C-preprocessor directives found in the sources and include files.
# The default value is: YES.
ENABLE_PREPROCESSING = YES
# If the MACRO_EXPANSION tag is set to YES, doxygen will expand all macro names
# in the source code. If set to NO, only conditional compilation will be
# performed. Macro expansion can be done in a controlled way by setting
# EXPAND_ONLY_PREDEF to YES.
# The default value is: NO.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
MACRO_EXPANSION = YES
# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then
# the macro expansion is limited to the macros specified with the PREDEFINED and
# EXPAND_AS_DEFINED tags.
# The default value is: NO.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
EXPAND_ONLY_PREDEF = YES
# If the SEARCH_INCLUDES tag is set to YES, the include files in the
# INCLUDE_PATH will be searched if a #include is found.
# The default value is: YES.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
SEARCH_INCLUDES = YES
# The INCLUDE_PATH tag can be used to specify one or more directories that
# contain include files that are not input files but should be processed by the
# preprocessor. Note that the INCLUDE_PATH is not recursive, so the setting of
# RECURSIVE has no effect here.
# This tag requires that the tag SEARCH_INCLUDES is set to YES.
INCLUDE_PATH =
# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
# patterns (like *.h and *.hpp) to filter out the header-files in the
# directories. If left blank, the patterns specified with FILE_PATTERNS will be
# used.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
INCLUDE_FILE_PATTERNS =
# The PREDEFINED tag can be used to specify one or more macro names that are
# defined before the preprocessor is started (similar to the -D option of e.g.
# gcc). The argument of the tag is a list of macros of the form: name or
# name=definition (no spaces). If the definition and the "=" are omitted, "=1"
# is assumed. To prevent a macro definition from being undefined via #undef or
# recursively expanded use the := operator instead of the = operator.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
PREDEFINED = __device__= \
__host__=
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
# tag can be used to specify a list of macro names that should be expanded. The
# macro definition that is found in the sources will be used. Use the PREDEFINED
# tag if you want to use a different macro definition that overrules the
# definition found in the source code.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
EXPAND_AS_DEFINED =
# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will
# remove all references to function-like macros that are alone on a line, have
# an all uppercase name, and do not end with a semicolon. Such function macros
# are typically used for boiler-plate code, and will confuse the parser if not
# removed.
# The default value is: YES.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration options related to external references
#---------------------------------------------------------------------------
# The TAGFILES tag can be used to specify one or more tag files. For each tag
# file the location of the external documentation should be added. The format of
# a tag file without this location is as follows:
# TAGFILES = file1 file2 ...
# Adding location for the tag files is done as follows:
# TAGFILES = file1=loc1 "file2 = loc2" ...
# where loc1 and loc2 can be relative or absolute paths or URLs. See the
# section "Linking to external documentation" for more information about the use
# of tag files.
# Note: Each tag file must have a unique name (where the name does NOT include
# the path). If a tag file is not located in the directory in which doxygen is
# run, you must also specify the path to the tagfile here.
TAGFILES = rmm.tag=https://docs.rapids.ai/api/librmm/23.12 "libcudf.tag=https://docs.rapids.ai/api/libcudf/23.12"
# When a file name is specified after GENERATE_TAGFILE, doxygen will create a
# tag file that is based on the input files it reads. See section "Linking to
# external documentation" for more information about the usage of tag files.
GENERATE_TAGFILE =
# If the ALLEXTERNALS tag is set to YES, all external class will be listed in
# the class index. If set to NO, only the inherited external classes will be
# listed.
# The default value is: NO.
ALLEXTERNALS = NO
# If the EXTERNAL_GROUPS tag is set to YES, all external groups will be listed
# in the modules index. If set to NO, only the current project's groups will be
# listed.
# The default value is: YES.
EXTERNAL_GROUPS = YES
# If the EXTERNAL_PAGES tag is set to YES, all external pages will be listed in
# the related pages index. If set to NO, only the current project's pages will
# be listed.
# The default value is: YES.
EXTERNAL_PAGES = YES
#---------------------------------------------------------------------------
# Configuration options related to diagram generator tools
#---------------------------------------------------------------------------
# If set to YES the inheritance and collaboration graphs will hide inheritance
# and usage relations if the target is undocumented or is not a class.
# The default value is: YES.
HIDE_UNDOC_RELATIONS = YES
# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
# available from the path. This tool is part of Graphviz (see:
# https://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent
# Bell Labs. The other options in this section have no effect if this option is
# set to NO
# The default value is: NO.
HAVE_DOT = NO
# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed
# to run in parallel. When set to 0 doxygen will base this on the number of
# processors available in the system. You can set it explicitly to a value
# larger than 0 to get control over the balance between CPU load and processing
# speed.
# Minimum value: 0, maximum value: 32, default value: 0.
# This tag requires that the tag HAVE_DOT is set to YES.
DOT_NUM_THREADS = 0
# DOT_COMMON_ATTR is common attributes for nodes, edges and labels of
# subgraphs. When you want a differently looking font in the dot files that
# doxygen generates you can specify fontname, fontcolor and fontsize attributes.
# For details please see <a href=https://graphviz.org/doc/info/attrs.html>Node,
# Edge and Graph Attributes specification</a> You need to make sure dot is able
# to find the font, which can be done by putting it in a standard location or by
# setting the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the
# directory containing the font. Default graphviz fontsize is 14.
# The default value is: fontname=Helvetica,fontsize=10.
# This tag requires that the tag HAVE_DOT is set to YES.
DOT_COMMON_ATTR = "fontname=Helvetica,fontsize=10"
# DOT_EDGE_ATTR is concatenated with DOT_COMMON_ATTR. For elegant style you can
# add 'arrowhead=open, arrowtail=open, arrowsize=0.5'. <a
# href=https://graphviz.org/doc/info/arrows.html>Complete documentation about
# arrows shapes.</a>
# The default value is: labelfontname=Helvetica,labelfontsize=10.
# This tag requires that the tag HAVE_DOT is set to YES.
DOT_EDGE_ATTR = "labelfontname=Helvetica,labelfontsize=10"
# DOT_NODE_ATTR is concatenated with DOT_COMMON_ATTR. For view without boxes
# around nodes set 'shape=plain' or 'shape=plaintext' <a
# href=https://www.graphviz.org/doc/info/shapes.html>Shapes specification</a>
# The default value is: shape=box,height=0.2,width=0.4.
# This tag requires that the tag HAVE_DOT is set to YES.
DOT_NODE_ATTR = "shape=box,height=0.2,width=0.4"
# You can set the path where dot can find font specified with fontname in
# DOT_COMMON_ATTR and others dot attributes.
# This tag requires that the tag HAVE_DOT is set to YES.
DOT_FONTPATH =
# If the CLASS_GRAPH tag is set to YES or GRAPH or BUILTIN then doxygen will
# generate a graph for each documented class showing the direct and indirect
# inheritance relations. In case the CLASS_GRAPH tag is set to YES or GRAPH and
# HAVE_DOT is enabled as well, then dot will be used to draw the graph. In case
# the CLASS_GRAPH tag is set to YES and HAVE_DOT is disabled or if the
# CLASS_GRAPH tag is set to BUILTIN, then the built-in generator will be used.
# If the CLASS_GRAPH tag is set to TEXT the direct and indirect inheritance
# relations will be shown as texts / links.
# Possible values are: NO, YES, TEXT, GRAPH and BUILTIN.
# The default value is: YES.
CLASS_GRAPH = YES
# If the COLLABORATION_GRAPH tag is set to YES then doxygen will generate a
# graph for each documented class showing the direct and indirect implementation
# dependencies (inheritance, containment, and class references variables) of the
# class with other documented classes.
# The default value is: YES.
# This tag requires that the tag HAVE_DOT is set to YES.
COLLABORATION_GRAPH = YES
# If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for
# groups, showing the direct groups dependencies. See also the chapter Grouping
# in the manual.
# The default value is: YES.
# This tag requires that the tag HAVE_DOT is set to YES.
GROUP_GRAPHS = YES
# If the UML_LOOK tag is set to YES, doxygen will generate inheritance and
# collaboration diagrams in a style similar to the OMG's Unified Modeling
# Language.
# The default value is: NO.
# This tag requires that the tag HAVE_DOT is set to YES.
UML_LOOK = NO
# If the UML_LOOK tag is enabled, the fields and methods are shown inside the
# class node. If there are many fields or methods and many nodes the graph may
# become too big to be useful. The UML_LIMIT_NUM_FIELDS threshold limits the
# number of items for each type to make the size more manageable. Set this to 0
# for no limit. Note that the threshold may be exceeded by 50% before the limit
# is enforced. So when you set the threshold to 10, up to 15 fields may appear,
# but if the number exceeds 15, the total amount of fields shown is limited to
# 10.
# Minimum value: 0, maximum value: 100, default value: 10.
# This tag requires that the tag UML_LOOK is set to YES.
UML_LIMIT_NUM_FIELDS = 10
# If the DOT_UML_DETAILS tag is set to NO, doxygen will show attributes and
# methods without types and arguments in the UML graphs. If the DOT_UML_DETAILS
# tag is set to YES, doxygen will add type and arguments for attributes and
# methods in the UML graphs. If the DOT_UML_DETAILS tag is set to NONE, doxygen
# will not generate fields with class member information in the UML graphs. The
# class diagrams will look similar to the default class diagrams but using UML
# notation for the relationships.
# Possible values are: NO, YES and NONE.
# The default value is: NO.
# This tag requires that the tag UML_LOOK is set to YES.
DOT_UML_DETAILS = NO
# The DOT_WRAP_THRESHOLD tag can be used to set the maximum number of characters
# to display on a single line. If the actual line length exceeds this threshold
# significantly it will wrapped across multiple lines. Some heuristics are apply
# to avoid ugly line breaks.
# Minimum value: 0, maximum value: 1000, default value: 17.
# This tag requires that the tag HAVE_DOT is set to YES.
DOT_WRAP_THRESHOLD = 17
# If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and
# collaboration graphs will show the relations between templates and their
# instances.
# The default value is: NO.
# This tag requires that the tag HAVE_DOT is set to YES.
TEMPLATE_RELATIONS = NO
# If the INCLUDE_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are set to
# YES then doxygen will generate a graph for each documented file showing the
# direct and indirect include dependencies of the file with other documented
# files.
# The default value is: YES.
# This tag requires that the tag HAVE_DOT is set to YES.
INCLUDE_GRAPH = YES
# If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are
# set to YES then doxygen will generate a graph for each documented file showing
# the direct and indirect include dependencies of the file with other documented
# files.
# The default value is: YES.
# This tag requires that the tag HAVE_DOT is set to YES.
INCLUDED_BY_GRAPH = YES
# If the CALL_GRAPH tag is set to YES then doxygen will generate a call
# dependency graph for every global function or class method.
#
# Note that enabling this option will significantly increase the time of a run.
# So in most cases it will be better to enable call graphs for selected
# functions only using the \callgraph command. Disabling a call graph can be
# accomplished by means of the command \hidecallgraph.
# The default value is: NO.
# This tag requires that the tag HAVE_DOT is set to YES.
CALL_GRAPH = NO
# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller
# dependency graph for every global function or class method.
#
# Note that enabling this option will significantly increase the time of a run.
# So in most cases it will be better to enable caller graphs for selected
# functions only using the \callergraph command. Disabling a caller graph can be
# accomplished by means of the command \hidecallergraph.
# The default value is: NO.
# This tag requires that the tag HAVE_DOT is set to YES.
CALLER_GRAPH = NO
# If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical
# hierarchy of all classes instead of a textual one.
# The default value is: YES.
# This tag requires that the tag HAVE_DOT is set to YES.
GRAPHICAL_HIERARCHY = YES
# If the DIRECTORY_GRAPH tag is set to YES then doxygen will show the
# dependencies a directory has on other directories in a graphical way. The
# dependency relations are determined by the #include relations between the
# files in the directories.
# The default value is: YES.
# This tag requires that the tag HAVE_DOT is set to YES.
DIRECTORY_GRAPH = YES
# The DIR_GRAPH_MAX_DEPTH tag can be used to limit the maximum number of levels
# of child directories generated in directory dependency graphs by dot.
# Minimum value: 1, maximum value: 25, default value: 1.
# This tag requires that the tag DIRECTORY_GRAPH is set to YES.
DIR_GRAPH_MAX_DEPTH = 1
# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
# generated by dot. For an explanation of the image formats see the section
# output formats in the documentation of the dot tool (Graphviz (see:
# https://www.graphviz.org/)).
# Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order
# to make the SVG files visible in IE 9+ (other browsers do not have this
# requirement).
# Possible values are: png, jpg, gif, svg, png:gd, png:gd:gd, png:cairo,
# png:cairo:gd, png:cairo:cairo, png:cairo:gdiplus, png:gdiplus and
# png:gdiplus:gdiplus.
# The default value is: png.
# This tag requires that the tag HAVE_DOT is set to YES.
DOT_IMAGE_FORMAT = png
# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
# enable generation of interactive SVG images that allow zooming and panning.
#
# Note that this requires a modern browser other than Internet Explorer. Tested
# and working are Firefox, Chrome, Safari, and Opera.
# Note: For IE 9+ you need to set HTML_FILE_EXTENSION to xhtml in order to make
# the SVG files visible. Older versions of IE do not have SVG support.
# The default value is: NO.
# This tag requires that the tag HAVE_DOT is set to YES.
INTERACTIVE_SVG = NO
# The DOT_PATH tag can be used to specify the path where the dot tool can be
# found. If left blank, it is assumed the dot tool can be found in the path.
# This tag requires that the tag HAVE_DOT is set to YES.
DOT_PATH =
# The DOTFILE_DIRS tag can be used to specify one or more directories that
# contain dot files that are included in the documentation (see the \dotfile
# command).
# This tag requires that the tag HAVE_DOT is set to YES.
DOTFILE_DIRS =
# You can include diagrams made with dia in doxygen documentation. Doxygen will
# then run dia to produce the diagram and insert it in the documentation. The
# DIA_PATH tag allows you to specify the directory where the dia binary resides.
# If left empty dia is assumed to be found in the default search path.
DIA_PATH =
# The DIAFILE_DIRS tag can be used to specify one or more directories that
# contain dia files that are included in the documentation (see the \diafile
# command).
DIAFILE_DIRS =
# When using plantuml, the PLANTUML_JAR_PATH tag should be used to specify the
# path where java can find the plantuml.jar file or to the filename of jar file
# to be used. If left blank, it is assumed PlantUML is not used or called during
# a preprocessing step. Doxygen will generate a warning when it encounters a
# \startuml command in this case and will not generate output for the diagram.
PLANTUML_JAR_PATH =
# When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a
# configuration file for plantuml.
PLANTUML_CFG_FILE =
# When using plantuml, the specified paths are searched for files specified by
# the !include statement in a plantuml block.
PLANTUML_INCLUDE_PATH =
# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes
# that will be shown in the graph. If the number of nodes in a graph becomes
# larger than this value, doxygen will truncate the graph, which is visualized
# by representing a node as a red box. Note that doxygen if the number of direct
# children of the root node in a graph is already larger than
# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note that
# the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
# Minimum value: 0, maximum value: 10000, default value: 50.
# This tag requires that the tag HAVE_DOT is set to YES.
DOT_GRAPH_MAX_NODES = 50
# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the graphs
# generated by dot. A depth value of 3 means that only nodes reachable from the
# root by following a path via at most 3 edges will be shown. Nodes that lay
# further from the root node will be omitted. Note that setting this option to 1
# or 2 may greatly reduce the computation time needed for large code bases. Also
# note that the size of a graph can be further restricted by
# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
# Minimum value: 0, maximum value: 1000, default value: 0.
# This tag requires that the tag HAVE_DOT is set to YES.
MAX_DOT_GRAPH_DEPTH = 0
# Set the DOT_MULTI_TARGETS tag to YES to allow dot to generate multiple output
# files in one run (i.e. multiple -o and -T options on the command line). This
# makes dot run faster, but since only newer versions of dot (>1.8.10) support
# this, this feature is disabled by default.
# The default value is: NO.
# This tag requires that the tag HAVE_DOT is set to YES.
DOT_MULTI_TARGETS = NO
# If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page
# explaining the meaning of the various boxes and arrows in the dot generated
# graphs.
# Note: This tag requires that UML_LOOK isn't set, i.e. the doxygen internal
# graphical representation for inheritance and collaboration diagrams is used.
# The default value is: YES.
# This tag requires that the tag HAVE_DOT is set to YES.
GENERATE_LEGEND = YES
# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate
# files that are used to generate the various graphs.
#
# Note: This setting is not only used for dot files but also for msc temporary
# files.
# The default value is: YES.
DOT_CLEANUP = YES
# You can define message sequence charts within doxygen comments using the \msc
# command. If the MSCGEN_TOOL tag is left empty (the default), then doxygen will
# use a built-in version of mscgen tool to produce the charts. Alternatively,
# the MSCGEN_TOOL tag can also specify the name an external tool. For instance,
# specifying prog as the value, doxygen will call the tool as prog -T
# <outfile_format> -o <outputfile> <inputfile>. The external tool should support
# output file formats "png", "eps", "svg", and "ismap".
MSCGEN_TOOL =
# The MSCFILE_DIRS tag can be used to specify one or more directories that
# contain msc files that are included in the documentation (see the \mscfile
# command).
MSCFILE_DIRS =
| 0 |
rapidsai_public_repos/cuspatial/cpp/cuproj | rapidsai_public_repos/cuspatial/cpp/cuproj/doxygen/header.html | <!-- HTML header for doxygen 1.8.20-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen $doxygenversion"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<!--BEGIN PROJECT_NAME--><title>$projectname: $title</title><!--END PROJECT_NAME-->
<!--BEGIN !PROJECT_NAME--><title>$title</title><!--END !PROJECT_NAME-->
<link href="$relpath^tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="$relpath^jquery.js"></script>
<script type="text/javascript" src="$relpath^dynsections.js"></script>
$treeview
$search
$mathjax
<link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" />
$extrastylesheet
<!-- RAPIDS CUSTOM JS & CSS: START, Please add these two lines back after every version upgrade -->
<script defer src="https://docs.rapids.ai/assets/js/custom.js"></script>
<link rel="stylesheet" href="https://docs.rapids.ai/assets/css/custom.css">
<!-- RAPIDS CUSTOM JS & CSS: END -->
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<!--BEGIN TITLEAREA-->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<!--BEGIN PROJECT_LOGO-->
<td id="projectlogo"><img alt="Logo" src="$relpath^$projectlogo"/></td>
<!--END PROJECT_LOGO-->
<!--BEGIN PROJECT_NAME-->
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">$projectname
<!--BEGIN PROJECT_NUMBER--> <span id="projectnumber">$projectnumber</span><!--END PROJECT_NUMBER-->
</div>
<!--BEGIN PROJECT_BRIEF--><div id="projectbrief">$projectbrief</div><!--END PROJECT_BRIEF-->
</td>
<!--END PROJECT_NAME-->
<!--BEGIN !PROJECT_NAME-->
<!--BEGIN PROJECT_BRIEF-->
<td style="padding-left: 0.5em;">
<div id="projectbrief">$projectbrief</div>
</td>
<!--END PROJECT_BRIEF-->
<!--END !PROJECT_NAME-->
<!--BEGIN DISABLE_INDEX-->
<!--BEGIN SEARCHENGINE-->
<td>$searchbox</td>
<!--END SEARCHENGINE-->
<!--END DISABLE_INDEX-->
</tr>
</tbody>
</table>
</div>
<!--END TITLEAREA-->
<!-- end header part -->
| 0 |
rapidsai_public_repos/cuspatial/cpp | rapidsai_public_repos/cuspatial/cpp/tests/CMakeLists.txt | #=============================================================================
# Copyright (c) 2019-2023, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# 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.
#=============================================================================
###################################################################################################
# - compiler function -----------------------------------------------------------------------------
function(ConfigureTest CMAKE_TEST_NAME)
add_executable(${CMAKE_TEST_NAME} ${ARGN})
target_compile_options(${CMAKE_TEST_NAME}
PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${CUSPATIAL_CXX_FLAGS}>"
"$<$<COMPILE_LANGUAGE:CUDA>:${CUSPATIAL_CUDA_FLAGS}>")
target_include_directories(${CMAKE_TEST_NAME}
PRIVATE "$<BUILD_INTERFACE:${CUSPATIAL_SOURCE_DIR}>"
"$<BUILD_INTERFACE:${CUSPATIAL_SOURCE_DIR}/src>")
set_target_properties(
${CMAKE_TEST_NAME}
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "$<BUILD_INTERFACE:${CUSPATIAL_BINARY_DIR}/gtests>"
INSTALL_RPATH "\$ORIGIN/../../../lib"
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
CUDA_STANDARD 17
CUDA_STANDARD_REQUIRED ON
)
target_link_libraries(${CMAKE_TEST_NAME} GTest::gtest_main GTest::gmock_main ranger::ranger cudf::cudftestutil cuspatial)
add_test(NAME ${CMAKE_TEST_NAME} COMMAND ${CMAKE_TEST_NAME})
install(
TARGETS ${CMAKE_TEST_NAME}
COMPONENT testing
DESTINATION bin/gtests/libcuspatial
EXCLUDE_FROM_ALL
)
endfunction(ConfigureTest)
###################################################################################################
### test sources ##################################################################################
###################################################################################################
# index
ConfigureTest(POINT_QUADTREE_TEST
index/point_quadtree_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)
ConfigureTest(JOIN_POINT_IN_POLYGON_TEST
join/quadtree_point_in_polygon_test.cpp)
# projection
ConfigureTest(SINUSOIDAL_PROJECTION_TEST
projection/sinusoidal_projection_test.cpp)
# bounding boxes
ConfigureTest(LINESTRING_BOUNDING_BOXES_TEST
bounding_boxes/linestring_bounding_boxes_test.cpp)
ConfigureTest(POLYGON_BOUNDING_BOXES_TEST
bounding_boxes/polygon_bounding_boxes_test.cpp)
# distance
ConfigureTest(HAVERSINE_TEST
distance/haversine_test.cpp)
ConfigureTest(HAUSDORFF_TEST
distance/hausdorff_test.cpp)
ConfigureTest(POINT_DISTANCE_TEST
distance/point_distance_test.cpp)
ConfigureTest(POINT_LINESTRING_DISTANCE_TEST
distance/point_linestring_distance_test.cpp)
ConfigureTest(LINESTRING_DISTANCE_TEST
distance/linestring_distance_test.cpp)
ConfigureTest(POINT_POLYGON_DISTANCE_TEST
distance/point_polygon_distance_test.cpp)
ConfigureTest(LINESTRING_POLYGON_DISTANCE_TEST
distance/linestring_polygon_distance_test.cpp)
ConfigureTest(POLYGON_DISTANCE_TEST
distance/polygon_distance_test.cpp)
# equality
ConfigureTest(PAIRWISE_MULTIPOINT_EQUALS_COUNT_TEST
equality/pairwise_multipoint_equals_count_test.cpp)
# intersection
ConfigureTest(LINESTRING_INTERSECTION_TEST
intersection/linestring_intersection_test.cpp)
# nearest points
ConfigureTest(POINT_LINESTRING_NEAREST_POINT_TEST
nearest_points/point_linestring_nearest_points_test.cpp)
# point in polygon
ConfigureTest(POINT_IN_POLYGON_TEST
point_in_polygon/point_in_polygon_test.cpp)
ConfigureTest(PAIRWISE_POINT_IN_POLYGON_TEST
point_in_polygon/pairwise_point_in_polygon_test.cpp)
# points in range
ConfigureTest(POINTS_IN_RANGE_TEST
points_in_range/points_in_range_test.cpp)
# trajectory
ConfigureTest(TRAJECTORY_DISTANCES_AND_SPEEDS_TEST
trajectory/test_trajectory_distances_and_speeds.cu)
ConfigureTest(DERIVE_TRAJECTORIES_TEST
trajectory/test_derive_trajectories.cpp)
ConfigureTest(TRAJECTORY_BOUNDING_BOXES_TEST
trajectory/test_trajectory_bounding_boxes.cu)
# utility
ConfigureTest(UTILITY_TEST
utility_test/test_float_equivalent.cu
utility_test/test_multipoint_factory.cu
utility_test/test_geometry_generators.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)
# index
ConfigureTest(POINT_QUADTREE_TEST_EXP
index/point_quadtree_test.cu)
# join
ConfigureTest(JOIN_QUADTREE_AND_BOUNDING_BOXES_TEST_EXP
join/join_quadtree_and_bounding_boxes_test.cu)
ConfigureTest(JOIN_POINT_IN_POLYGON_SMALL_TEST_EXP
join/quadtree_point_in_polygon_test_small.cu)
ConfigureTest(JOIN_POINT_IN_POLYGON_LARGE_TEST_EXP
join/quadtree_point_in_polygon_test_large.cu)
ConfigureTest(JOIN_POINT_TO_LINESTRING_SMALL_TEST_EXP
join/quadtree_point_to_nearest_linestring_test_small.cu)
# operators
ConfigureTest(OPERATOR_TEST_EXP
operators/linestrings_test.cu)
# projection
ConfigureTest(SINUSOIDAL_PROJECTION_TEST_EXP
projection/sinusoidal_projection_test.cu)
# range
ConfigureTest(RANGE_TEST_EXP
range/multipoint_range_test.cu
range/multilinestring_range_test.cu
range/multipolygon_range_test.cu)
# bounding boxes
ConfigureTest(POINT_BOUNDING_BOXES_TEST_EXP
bounding_boxes/point_bounding_boxes_test.cu)
ConfigureTest(POLYGON_BOUNDING_BOXES_TEST_EXP
bounding_boxes/polygon_bounding_boxes_test.cu)
ConfigureTest(LINESTRING_BOUNDING_BOXES_TEST_EXP
bounding_boxes/linestring_bounding_boxes_test.cu)
# distance
ConfigureTest(HAUSDORFF_TEST_EXP
distance/hausdorff_test.cu)
ConfigureTest(HAVERSINE_TEST_EXP
distance/haversine_test.cu)
ConfigureTest(POINT_DISTANCE_TEST_EXP
distance/point_distance_test.cu)
ConfigureTest(POINT_LINESTRING_DISTANCE_TEST_EXP
distance/point_linestring_distance_test.cu)
ConfigureTest(POINT_POLYGON_DISTANCE_TEST_EXP
distance/point_polygon_distance_test.cu)
ConfigureTest(LINESTRING_POLYGON_DISTANCE_TEST_EXP
distance/linestring_polygon_distance_test.cu)
ConfigureTest(LINESTRING_DISTANCE_TEST_EXP
distance/linestring_distance_test.cu
distance/linestring_distance_test_medium.cu)
ConfigureTest(POLYGON_DISTANCE_TEST_EXP
distance/polygon_distance_test.cu)
# equality
ConfigureTest(PAIRWISE_MULTIPOINT_EQUALS_COUNT_TEST_EXP
equality/pairwise_multipoint_equals_count_test.cu)
# intersection
ConfigureTest(LINESTRING_INTERSECTION_TEST_EXP
intersection/linestring_intersection_count_test.cu
intersection/linestring_intersection_intermediates_remove_if_test.cu
intersection/linestring_intersection_with_duplicates_test.cu
intersection/linestring_intersection_test.cu
intersection/linestring_intersection_large_test.cu)
# nearest points
ConfigureTest(POINT_LINESTRING_NEAREST_POINT_TEST_EXP
nearest_points/point_linestring_nearest_points_test.cu)
# point in polygon
ConfigureTest(POINT_IN_POLYGON_TEST_EXP
point_in_polygon/point_in_polygon_test.cu)
ConfigureTest(PAIRWISE_POINT_IN_POLYGON_TEST_EXP
point_in_polygon/pairwise_point_in_polygon_test.cu)
# points in range
ConfigureTest(POINTS_IN_RANGE_TEST_EXP
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)
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/operators/linestrings_test.cu | /*
* 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 <cuspatial_test/base_fixture.hpp>
#include <cuspatial_test/vector_equality.hpp>
#include <cuspatial/cuda_utils.hpp>
#include <cuspatial/detail/utility/linestring.cuh>
#include <cuspatial/error.hpp>
#include <cuspatial/geometry/vec_2d.hpp>
#include <rmm/device_vector.hpp>
#include <thrust/execution_policy.h>
#include <thrust/optional.h>
#include <thrust/pair.h>
#include <gtest/gtest.h>
#include <iostream>
#include <optional>
using namespace cuspatial;
using namespace cuspatial::detail;
using namespace cuspatial::test;
template <typename T>
using optional_vec2d = thrust::optional<vec_2d<T>>;
namespace cuspatial {
// Required by gtest test suite to compile
// Need to be defined within cuspatial namespace for ADL.
template <typename T>
std::ostream& operator<<(std::ostream& os, thrust::optional<vec_2d<T>> const& opt)
{
if (opt.has_value())
return os << opt.value();
else
return os << "null";
}
} // namespace cuspatial
template <typename T>
struct SegmentIntersectionTest : public BaseFixture {};
using TestTypes = ::testing::Types<float, double>;
TYPED_TEST_CASE(SegmentIntersectionTest, TestTypes);
template <typename T>
segment<T> __device__ order_end_points(segment<T> const& seg)
{
auto [a, b] = seg;
return a < b ? segment<T>{a, b} : segment<T>{b, a};
}
template <typename T, typename Point, typename Segment>
__global__ void compute_intersection(segment<T> ab,
segment<T> cd,
Point point_out,
Segment segment_out)
{
auto [p, s] = detail::segment_intersection(ab, cd);
point_out[0] = p;
segment_out[0] = s.has_value() ? thrust::optional(order_end_points(s.value())) : s;
}
template <typename T>
struct unpack_optional_segment {
thrust::tuple<optional_vec2d<T>, optional_vec2d<T>> CUSPATIAL_HOST_DEVICE
operator()(thrust::optional<segment<T>> segment)
{
if (segment.has_value())
return thrust::make_tuple(segment.value().v1, segment.value().v2);
else
return thrust::tuple<optional_vec2d<T>, optional_vec2d<T>>{thrust::nullopt, thrust::nullopt};
}
};
template <typename T>
void run_single_intersection_test(
segment<T> const& ab,
segment<T> const& cd,
std::vector<thrust::optional<vec_2d<T>>> const& points_expected,
std::vector<thrust::optional<segment<T>>> const& segments_expected)
{
rmm::device_vector<thrust::optional<vec_2d<T>>> points_got(points_expected.size());
rmm::device_vector<thrust::optional<segment<T>>> segments_got(segments_expected.size());
compute_intersection<<<1, 1>>>(ab, cd, points_got.data(), segments_got.data());
// Unpack the segment into two separate optional vec_2d column.
rmm::device_vector<thrust::optional<vec_2d<T>>> first(segments_got.size());
rmm::device_vector<thrust::optional<vec_2d<T>>> second(segments_got.size());
auto outit = thrust::make_zip_iterator(first.begin(), second.begin());
thrust::transform(segments_got.begin(), segments_got.end(), outit, unpack_optional_segment<T>{});
std::vector<thrust::optional<vec_2d<T>>> expected_first(segments_expected.size());
std::vector<thrust::optional<vec_2d<T>>> expected_second(segments_expected.size());
auto h_outit = thrust::make_zip_iterator(expected_first.begin(), expected_second.begin());
thrust::transform(thrust::host,
segments_expected.begin(),
segments_expected.end(),
h_outit,
unpack_optional_segment<T>{});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(points_got, points_expected);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(first, expected_first);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(second, expected_second);
}
TYPED_TEST(SegmentIntersectionTest, SimpleIntersect)
{
using T = TypeParam;
segment<T> ab{{0.0, 0.0}, {1.0, 1.0}};
segment<T> cd{{0.0, 1.0}, {1.0, 0.0}};
std::vector<thrust::optional<vec_2d<T>>> points_expected{vec_2d<T>{0.5, 0.5}};
std::vector<thrust::optional<segment<T>>> segments_expected{thrust::nullopt};
run_single_intersection_test(ab, cd, points_expected, segments_expected);
}
TYPED_TEST(SegmentIntersectionTest, IntersectAtEndPoint)
{
using T = TypeParam;
segment<T> ab{{0.0, 0.0}, {1.0, 1.0}};
segment<T> cd{{1.0, 1.0}, {1.0, 0.0}};
std::vector<thrust::optional<vec_2d<T>>> points_expected{vec_2d<T>{1.0, 1.0}};
std::vector<thrust::optional<segment<T>>> segments_expected{thrust::nullopt};
run_single_intersection_test(ab, cd, points_expected, segments_expected);
}
TYPED_TEST(SegmentIntersectionTest, IntersectAtEndPoint2)
{
using T = TypeParam;
segment<T> ab{{-1.0, 0.0}, {0.0, 0.0}};
segment<T> cd{{0.0, 0.0}, {0.0, 1.0}};
std::vector<thrust::optional<vec_2d<T>>> points_expected{vec_2d<T>{0.0, 0.0}};
std::vector<thrust::optional<segment<T>>> segments_expected{thrust::nullopt};
run_single_intersection_test(ab, cd, points_expected, segments_expected);
}
TYPED_TEST(SegmentIntersectionTest, IntersectAtEndPoint3)
{
using T = TypeParam;
segment<T> ab{{-1.0, 0.0}, {0.0, 0.0}};
segment<T> cd{{1.0, 0.0}, {0.0, 0.0}};
std::vector<thrust::optional<vec_2d<T>>> points_expected{vec_2d<T>{0.0, 0.0}};
std::vector<thrust::optional<segment<T>>> segments_expected{thrust::nullopt};
run_single_intersection_test(ab, cd, points_expected, segments_expected);
}
TYPED_TEST(SegmentIntersectionTest, UnparallelDisjoint1)
{
using T = TypeParam;
segment<T> ab{{0.0, 0.0}, {0.4, 1.0}};
segment<T> cd{{1.0, 0.0}, {0.6, 1.0}};
std::vector<thrust::optional<vec_2d<T>>> points_expected{thrust::nullopt};
std::vector<thrust::optional<segment<T>>> segments_expected{thrust::nullopt};
run_single_intersection_test(ab, cd, points_expected, segments_expected);
}
TYPED_TEST(SegmentIntersectionTest, UnparallelDisjoint2)
{
using T = TypeParam;
segment<T> ab{{0.0, 0.0}, {1.0, 0.0}};
segment<T> cd{{2.0, 0.0}, {2.0, 1.0}};
std::vector<thrust::optional<vec_2d<T>>> points_expected{thrust::nullopt};
std::vector<thrust::optional<segment<T>>> segments_expected{thrust::nullopt};
run_single_intersection_test(ab, cd, points_expected, segments_expected);
}
TYPED_TEST(SegmentIntersectionTest, ParallelDisjoint1)
{
using T = TypeParam;
segment<T> ab{{0.0, 0.0}, {0.0, 1.0}};
segment<T> cd{{1.0, 0.0}, {1.0, 1.0}};
std::vector<thrust::optional<vec_2d<T>>> points_expected{thrust::nullopt};
std::vector<thrust::optional<segment<T>>> segments_expected{thrust::nullopt};
run_single_intersection_test(ab, cd, points_expected, segments_expected);
}
TYPED_TEST(SegmentIntersectionTest, ParallelDisjoint2)
{
using T = TypeParam;
segment<T> ab{{0.0, 0.0}, {1.0, 0.0}};
segment<T> cd{{0.0, 1.0}, {1.0, 1.0}};
std::vector<thrust::optional<vec_2d<T>>> points_expected{thrust::nullopt};
std::vector<thrust::optional<segment<T>>> segments_expected{thrust::nullopt};
run_single_intersection_test(ab, cd, points_expected, segments_expected);
}
TYPED_TEST(SegmentIntersectionTest, ParallelDisjoint3)
{
using T = TypeParam;
segment<T> ab{{0.0, 0.0}, {1.0, 1.0}};
segment<T> cd{{1.0, 0.0}, {2.0, 1.0}};
std::vector<thrust::optional<vec_2d<T>>> points_expected{thrust::nullopt};
std::vector<thrust::optional<segment<T>>> segments_expected{thrust::nullopt};
run_single_intersection_test(ab, cd, points_expected, segments_expected);
}
TYPED_TEST(SegmentIntersectionTest, ParallelDisjoint4)
{
using T = TypeParam;
segment<T> ab{{0.0, 0.0}, {0.0, -1.0}};
segment<T> cd{{1.0, 0.0}, {1.0, 1.0}};
std::vector<thrust::optional<vec_2d<T>>> points_expected{thrust::nullopt};
std::vector<thrust::optional<segment<T>>> segments_expected{thrust::nullopt};
run_single_intersection_test(ab, cd, points_expected, segments_expected);
}
TYPED_TEST(SegmentIntersectionTest, CollinearDisjoint1)
{
using T = TypeParam;
segment<T> ab{{0.0, 0.0}, {1.0, 0.0}};
segment<T> cd{{2.0, 0.0}, {3.0, 0.0}};
std::vector<thrust::optional<vec_2d<T>>> points_expected{thrust::nullopt};
std::vector<thrust::optional<segment<T>>> segments_expected{thrust::nullopt};
run_single_intersection_test(ab, cd, points_expected, segments_expected);
}
TYPED_TEST(SegmentIntersectionTest, CollinearDisjoint2)
{
using T = TypeParam;
segment<T> ab{{0.0, 0.0}, {1.0, 0.0}};
segment<T> cd{{-1.0, 0.0}, {-2.0, 0.0}};
std::vector<thrust::optional<vec_2d<T>>> points_expected{thrust::nullopt};
std::vector<thrust::optional<segment<T>>> segments_expected{thrust::nullopt};
run_single_intersection_test(ab, cd, points_expected, segments_expected);
}
TYPED_TEST(SegmentIntersectionTest, CollinearDisjoint3)
{
using T = TypeParam;
segment<T> ab{{0.0, 0.0}, {0.0, 1.0}};
segment<T> cd{{0.0, 2.0}, {0.0, 3.0}};
std::vector<thrust::optional<vec_2d<T>>> points_expected{thrust::nullopt};
std::vector<thrust::optional<segment<T>>> segments_expected{thrust::nullopt};
run_single_intersection_test(ab, cd, points_expected, segments_expected);
}
TYPED_TEST(SegmentIntersectionTest, CollinearDisjoint4)
{
using T = TypeParam;
segment<T> ab{{0.0, 0.0}, {0.0, 1.0}};
segment<T> cd{{0.0, -1.0}, {0.0, -2.0}};
std::vector<thrust::optional<vec_2d<T>>> points_expected{thrust::nullopt};
std::vector<thrust::optional<segment<T>>> segments_expected{thrust::nullopt};
run_single_intersection_test(ab, cd, points_expected, segments_expected);
}
TYPED_TEST(SegmentIntersectionTest, CollinearDisjoint5)
{
using T = TypeParam;
segment<T> ab{{0.0, 0.0}, {1.0, 1.0}};
segment<T> cd{{2.0, 2.0}, {3.0, 3.0}};
std::vector<thrust::optional<vec_2d<T>>> points_expected{thrust::nullopt};
std::vector<thrust::optional<segment<T>>> segments_expected{thrust::nullopt};
run_single_intersection_test(ab, cd, points_expected, segments_expected);
}
TYPED_TEST(SegmentIntersectionTest, CollinearDisjoint6)
{
using T = TypeParam;
segment<T> ab{{0.0, 0.0}, {1.0, 1.0}};
segment<T> cd{{-1.0, -1.0}, {-2.0, -2.0}};
std::vector<thrust::optional<vec_2d<T>>> points_expected{thrust::nullopt};
std::vector<thrust::optional<segment<T>>> segments_expected{thrust::nullopt};
run_single_intersection_test(ab, cd, points_expected, segments_expected);
}
TYPED_TEST(SegmentIntersectionTest, Overlap1)
{
using T = TypeParam;
segment<T> ab{{0.0, 0.0}, {1.0, 1.0}};
segment<T> cd{{0.5, 0.5}, {1.5, 1.5}};
std::vector<thrust::optional<vec_2d<T>>> points_expected{thrust::nullopt};
std::vector<thrust::optional<segment<T>>> segments_expected{segment<T>{{0.5, 0.5}, {1.0, 1.0}}};
run_single_intersection_test(ab, cd, points_expected, segments_expected);
}
TYPED_TEST(SegmentIntersectionTest, Overlap2)
{
using T = TypeParam;
segment<T> ab{{0.0, 0.0}, {1.0, 1.0}};
segment<T> cd{{0.5, 0.5}, {-1.5, -1.5}};
std::vector<thrust::optional<vec_2d<T>>> points_expected{thrust::nullopt};
std::vector<thrust::optional<segment<T>>> segments_expected{segment<T>{{0.0, 0.0}, {0.5, 0.5}}};
run_single_intersection_test(ab, cd, points_expected, segments_expected);
}
TYPED_TEST(SegmentIntersectionTest, Overlap3)
{
using T = TypeParam;
segment<T> ab{{0.0, 0.0}, {1.0, 0.0}};
segment<T> cd{{0.5, 0.0}, {2.0, 0.0}};
std::vector<thrust::optional<vec_2d<T>>> points_expected{thrust::nullopt};
std::vector<thrust::optional<segment<T>>> segments_expected{segment<T>{{0.5, 0.0}, {1.0, 0.0}}};
run_single_intersection_test(ab, cd, points_expected, segments_expected);
}
TYPED_TEST(SegmentIntersectionTest, Overlap4)
{
using T = TypeParam;
segment<T> ab{{0.0, 0.0}, {1.0, 0.0}};
segment<T> cd{{0.5, 0.0}, {-1.0, 0.0}};
std::vector<thrust::optional<vec_2d<T>>> points_expected{thrust::nullopt};
std::vector<thrust::optional<segment<T>>> segments_expected{segment<T>{{0.0, 0.0}, {0.5, 0.0}}};
run_single_intersection_test(ab, cd, points_expected, segments_expected);
}
TYPED_TEST(SegmentIntersectionTest, Overlap5)
{
using T = TypeParam;
segment<T> ab{{0.0, 0.0}, {0.0, 1.0}};
segment<T> cd{{0.0, 0.5}, {0.0, 2.0}};
std::vector<thrust::optional<vec_2d<T>>> points_expected{thrust::nullopt};
std::vector<thrust::optional<segment<T>>> segments_expected{segment<T>{{0.0, 0.5}, {0.0, 1.0}}};
run_single_intersection_test(ab, cd, points_expected, segments_expected);
}
TYPED_TEST(SegmentIntersectionTest, Overlap6)
{
using T = TypeParam;
segment<T> ab{{0.0, 0.0}, {0.0, 1.0}};
segment<T> cd{{0.0, 0.5}, {0.0, -2.0}};
std::vector<thrust::optional<vec_2d<T>>> points_expected{thrust::nullopt};
std::vector<thrust::optional<segment<T>>> segments_expected{segment<T>{{0.0, 0.0}, {0.0, 0.5}}};
run_single_intersection_test(ab, cd, points_expected, segments_expected);
}
TYPED_TEST(SegmentIntersectionTest, Overlap7)
{
using T = TypeParam;
segment<T> ab{{0.0, 0.0}, {0.0, 1.0}};
segment<T> cd{{0.0, 0.0}, {0.0, 0.5}};
std::vector<thrust::optional<vec_2d<T>>> points_expected{thrust::nullopt};
std::vector<thrust::optional<segment<T>>> segments_expected{segment<T>{{0.0, 0.0}, {0.0, 0.5}}};
run_single_intersection_test(ab, cd, points_expected, segments_expected);
}
TYPED_TEST(SegmentIntersectionTest, Overlap8)
{
using T = TypeParam;
segment<T> ab{{0.0, 0.0}, {0.0, 1.0}};
segment<T> cd{{0.0, 0.5}, {0.0, 1.0}};
std::vector<thrust::optional<vec_2d<T>>> points_expected{thrust::nullopt};
std::vector<thrust::optional<segment<T>>> segments_expected{segment<T>{{0.0, 0.5}, {0.0, 1.0}}};
run_single_intersection_test(ab, cd, points_expected, segments_expected);
}
TYPED_TEST(SegmentIntersectionTest, Overlap9)
{
using T = TypeParam;
segment<T> ab{{0.0, 0.0}, {0.0, 1.0}};
segment<T> cd{{0.0, 0.25}, {0.0, 0.75}};
std::vector<thrust::optional<vec_2d<T>>> points_expected{thrust::nullopt};
std::vector<thrust::optional<segment<T>>> segments_expected{cd};
run_single_intersection_test(ab, cd, points_expected, segments_expected);
}
TYPED_TEST(SegmentIntersectionTest, Overlap10)
{
using T = TypeParam;
segment<T> ab{{0.0, 0.25}, {0.0, 0.75}};
segment<T> cd{{0.0, 0.0}, {0.0, 1.0}};
std::vector<thrust::optional<vec_2d<T>>> points_expected{thrust::nullopt};
std::vector<thrust::optional<segment<T>>> segments_expected{ab};
run_single_intersection_test(ab, cd, points_expected, segments_expected);
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/bounding_boxes/polygon_bounding_boxes_test.cu | /*
* 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 <cuspatial_test/vector_equality.hpp>
#include <cuspatial_test/vector_factories.cuh>
#include <cuspatial/bounding_boxes.cuh>
#include <cuspatial/error.hpp>
#include <cuspatial/geometry/box.hpp>
#include <cuspatial/geometry/vec_2d.hpp>
#include <gtest/gtest.h>
template <typename T>
struct PolygonBoundingBoxTest : public ::testing::Test {};
using cuspatial::vec_2d;
using cuspatial::test::make_device_vector;
using TestTypes = ::testing::Types<float, double>;
TYPED_TEST_CASE(PolygonBoundingBoxTest, TestTypes);
TYPED_TEST(PolygonBoundingBoxTest, test_empty)
{
using T = TypeParam;
{
auto poly_offsets = make_device_vector<int32_t>({});
auto ring_offsets = make_device_vector<int32_t>({});
auto vertices = make_device_vector<vec_2d<T>>({});
auto bboxes = rmm::device_vector<cuspatial::box<T>>(0);
auto bboxes_end = cuspatial::polygon_bounding_boxes(poly_offsets.begin(),
poly_offsets.end(),
ring_offsets.begin(),
ring_offsets.end(),
vertices.begin(),
vertices.end(),
bboxes.begin());
EXPECT_EQ(std::distance(bboxes.begin(), bboxes_end), 0);
}
{
auto poly_offsets = make_device_vector<int32_t>({0});
auto ring_offsets = make_device_vector<int32_t>({});
auto vertices = make_device_vector<vec_2d<T>>({});
auto bboxes = rmm::device_vector<cuspatial::box<T>>(0);
auto bboxes_end = cuspatial::polygon_bounding_boxes(poly_offsets.begin(),
poly_offsets.end(),
ring_offsets.begin(),
ring_offsets.end(),
vertices.begin(),
vertices.end(),
bboxes.begin());
EXPECT_EQ(std::distance(bboxes.begin(), bboxes_end), 0);
}
}
TYPED_TEST(PolygonBoundingBoxTest, test_one)
{
using T = TypeParam;
// GeoArrow: Final offset points to the end of the data. The number of offsets is number of
// geometries / parts plus one.
auto poly_offsets = make_device_vector<int32_t>({0, 1});
auto ring_offsets = make_device_vector<int32_t>({0, 4});
auto vertices = make_device_vector<vec_2d<T>>(
{{2.488450, 5.856625}, {1.333584, 5.008840}, {3.460720, 4.586599}, {2.488450, 5.856625}});
// GeoArrow: Number of linestrings is number of offsets minus one.
auto bboxes = rmm::device_vector<cuspatial::box<T>>(poly_offsets.size() - 1);
auto bboxes_end = cuspatial::polygon_bounding_boxes(poly_offsets.begin(),
poly_offsets.end(),
ring_offsets.begin(),
ring_offsets.end(),
vertices.begin(),
vertices.end(),
bboxes.begin());
EXPECT_EQ(std::distance(bboxes.begin(), bboxes_end), 1);
auto bboxes_expected =
make_device_vector<cuspatial::box<T>>({{{1.333584, 4.586599}, {3.460720, 5.856625}}});
CUSPATIAL_EXPECT_VEC2D_PAIRS_EQUIVALENT(bboxes, bboxes_expected);
}
TYPED_TEST(PolygonBoundingBoxTest, test_small)
{
using T = TypeParam;
// GeoArrow: Final offset points to the end of the data. The number of offsets is number of
// geometries / parts plus one.
auto poly_offsets = make_device_vector<int32_t>({0, 1, 2, 3, 4});
auto ring_offsets = make_device_vector<int32_t>({0, 4, 9, 13, 17});
auto vertices = make_device_vector<vec_2d<T>>({// ring 1 (closed)
{2.488450, 5.856625},
{1.333584, 5.008840},
{3.460720, 4.586599},
{2.488450, 5.856625},
// ring 2 (open)
{5.039823, 4.229242},
{5.561707, 1.825073},
{7.103516, 1.503906},
{7.190674, 4.025879},
{5.998939, 5.653384},
// ring 3 (closed)
{5.998939, 1.235638},
{5.573720, 0.197808},
{6.703534, 0.086693},
{5.998939, 1.235638},
// ring 4 (open)
{2.088115, 4.541529},
{1.034892, 3.530299},
{2.415080, 2.896937},
{3.208660, 3.745936}});
// GeoArrow: Number of linestrings is number of offsets minus one.
auto bboxes = rmm::device_vector<cuspatial::box<T>>(poly_offsets.size() - 1);
auto bboxes_end = cuspatial::polygon_bounding_boxes(poly_offsets.begin(),
poly_offsets.end(),
ring_offsets.begin(),
ring_offsets.end(),
vertices.begin(),
vertices.end(),
bboxes.begin());
EXPECT_EQ(std::distance(bboxes.begin(), bboxes_end), 4);
auto bboxes_expected = make_device_vector<cuspatial::box<T>>(
{{{1.3335840000000001, 4.5865989999999996}, {3.4607199999999998, 5.8566250000000002}},
{{5.0398230000000002, 1.503906}, {7.1906739999999996, 5.653384}},
{{5.5737199999999998, 0.086693000000000006}, {6.7035340000000003, 1.235638}},
{{1.0348919999999999, 2.8969369999999999}, {3.2086600000000001, 4.5415289999999997}}});
CUSPATIAL_EXPECT_VEC2D_PAIRS_EQUIVALENT(bboxes, bboxes_expected);
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/bounding_boxes/linestring_bounding_boxes_test.cpp | /*
* 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.
*/
#include <cuspatial/bounding_boxes.hpp>
#include <cuspatial/error.hpp>
#include <cudf/table/table.hpp>
#include <cudf/table/table_view.hpp>
#include <cudf_test/column_wrapper.hpp>
struct LinestringBoundingBoxErrorTest : public ::testing::Test {};
using T = float;
TEST_F(LinestringBoundingBoxErrorTest, test_empty)
{
using namespace cudf::test;
fixed_width_column_wrapper<int32_t> linestring_offsets({});
fixed_width_column_wrapper<T> x({});
fixed_width_column_wrapper<T> y({});
auto bboxes = cuspatial::linestring_bounding_boxes(linestring_offsets, x, y, 0.0);
EXPECT_EQ(bboxes->num_rows(), 0);
}
TEST_F(LinestringBoundingBoxErrorTest, type_mismatch)
{
using namespace cudf::test;
fixed_width_column_wrapper<int32_t> linestring_offsets({0, 4});
fixed_width_column_wrapper<T> x({2.488450, 1.333584, 3.460720, 2.488450});
fixed_width_column_wrapper<double> y({5.856625, 5.008840, 4.586599, 5.856625});
EXPECT_THROW(cuspatial::linestring_bounding_boxes(linestring_offsets, x, y, 0.0),
cuspatial::logic_error);
}
TEST_F(LinestringBoundingBoxErrorTest, not_enough_offsets)
{
using namespace cudf::test;
fixed_width_column_wrapper<int32_t> linestring_offsets({0});
fixed_width_column_wrapper<T> x({2.488450, 1.333584, 3.460720, 2.488450});
fixed_width_column_wrapper<T> y({5.856625, 5.008840, 4.586599, 5.856625});
auto bboxes = cuspatial::linestring_bounding_boxes(linestring_offsets, x, y, 0.0);
EXPECT_EQ(bboxes->num_rows(), 0);
}
TEST_F(LinestringBoundingBoxErrorTest, offset_type_error)
{
using namespace cudf::test;
{
fixed_width_column_wrapper<float> linestring_offsets({0, 4});
fixed_width_column_wrapper<T> x({2.488450, 1.333584, 3.460720, 2.488450});
fixed_width_column_wrapper<T> y({5.856625, 5.008840, 4.586599, 5.856625});
EXPECT_THROW(cuspatial::linestring_bounding_boxes(linestring_offsets, x, y, 0.0),
cuspatial::logic_error);
}
}
TEST_F(LinestringBoundingBoxErrorTest, vertex_size_mismatch)
{
using namespace cudf::test;
fixed_width_column_wrapper<int32_t> linestring_offsets({0, 4});
fixed_width_column_wrapper<T> x({2.488450, 1.333584, 3.460720, 2.488450});
fixed_width_column_wrapper<T> y({5.856625, 5.008840});
EXPECT_THROW(cuspatial::linestring_bounding_boxes(linestring_offsets, x, y, 0.0),
cuspatial::logic_error);
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/bounding_boxes/point_bounding_boxes_test.cu | /*
* 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 "../trajectory/trajectory_test_utils.cuh"
#include <cuspatial_test/vector_equality.hpp>
#include <cuspatial/bounding_boxes.cuh>
#include <cuspatial/geometry/box.hpp>
#include <cuspatial/geometry/vec_2d.hpp>
#include <cuspatial/iterator_factory.cuh>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <rmm/mr/device/per_device_resource.hpp>
#include <thrust/binary_search.h>
#include <thrust/gather.h>
#include <thrust/random.h>
#include <thrust/random/uniform_int_distribution.h>
#include <thrust/scan.h>
#include <thrust/shuffle.h>
#include <gtest/gtest.h>
#include <cstdint>
template <typename T>
struct PointBoundingBoxesTest : public ::testing::Test {
void run_test(int num_trajectories, int points_per_trajectory, T expansion_radius = T{})
{
auto data = cuspatial::test::trajectory_test_data<T>(num_trajectories, points_per_trajectory);
auto bounding_boxes = rmm::device_vector<cuspatial::box<T>>(data.num_trajectories);
auto boxes_end = cuspatial::point_bounding_boxes(data.ids_sorted.begin(),
data.ids_sorted.end(),
data.points_sorted.begin(),
bounding_boxes.begin());
EXPECT_EQ(std::distance(bounding_boxes.begin(), boxes_end), data.num_trajectories);
CUSPATIAL_EXPECT_VEC2D_PAIRS_EQUIVALENT(bounding_boxes, data.bounding_boxes());
}
};
using TestTypes = ::testing::Types<float, double>;
TYPED_TEST_CASE(PointBoundingBoxesTest, TestTypes);
TYPED_TEST(PointBoundingBoxesTest, TenThousandSmallTrajectories) { this->run_test(10'000, 50); }
TYPED_TEST(PointBoundingBoxesTest, OneHundredLargeTrajectories) { this->run_test(100, 10'000); }
TYPED_TEST(PointBoundingBoxesTest, OneVeryLargeTrajectory) { this->run_test(1, 1'000'000); }
TYPED_TEST(PointBoundingBoxesTest, TrajectoriesWithExpansion)
{
this->run_test(10'000, 50, TypeParam{0.5});
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/bounding_boxes/linestring_bounding_boxes_test.cu | /*
* 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 <cuspatial_test/vector_equality.hpp>
#include <cuspatial_test/vector_factories.cuh>
#include <cuspatial/bounding_boxes.cuh>
#include <cuspatial/error.hpp>
#include <cuspatial/geometry/box.hpp>
#include <cuspatial/geometry/vec_2d.hpp>
#include <gtest/gtest.h>
template <typename T>
struct LinestringBoundingBoxTest : public ::testing::Test {};
using cuspatial::vec_2d;
using cuspatial::test::make_device_vector;
using TestTypes = ::testing::Types<float, double>;
TYPED_TEST_CASE(LinestringBoundingBoxTest, TestTypes);
TYPED_TEST(LinestringBoundingBoxTest, test_empty)
{
using T = TypeParam;
auto offsets = make_device_vector<int32_t>({});
auto vertices = make_device_vector<vec_2d<T>>({});
auto bboxes = rmm::device_vector<cuspatial::box<T>>(offsets.size());
auto bboxes_end = cuspatial::linestring_bounding_boxes(
offsets.begin(), offsets.end(), vertices.begin(), vertices.end(), bboxes.begin());
EXPECT_EQ(std::distance(bboxes.begin(), bboxes_end), 0);
}
TYPED_TEST(LinestringBoundingBoxTest, test_one)
{
using T = TypeParam;
// GeoArrow: Final offset points to the end of the data. The number of offsets is number of
// geometries / parts plus one.
auto offsets = make_device_vector<int32_t>({0, 4});
auto vertices = make_device_vector<vec_2d<T>>(
{{2.488450, 5.856625}, {1.333584, 5.008840}, {3.460720, 4.586599}, {2.488450, 5.856625}});
// GeoArrow: Number of linestrings is number of offsets minus one.
auto bboxes = rmm::device_vector<cuspatial::box<T>>(offsets.size() - 1);
auto bboxes_end = cuspatial::linestring_bounding_boxes(
offsets.begin(), offsets.end(), vertices.begin(), vertices.end(), bboxes.begin());
EXPECT_EQ(std::distance(bboxes.begin(), bboxes_end), 1);
auto bboxes_expected =
make_device_vector<cuspatial::box<T>>({{{1.333584, 4.586599}, {3.460720, 5.856625}}});
CUSPATIAL_EXPECT_VEC2D_PAIRS_EQUIVALENT(bboxes, bboxes_expected);
}
TYPED_TEST(LinestringBoundingBoxTest, test_small)
{
using T = TypeParam;
// GeoArrow: Final offset points to the end of the data. The number of offsets is number of
// geometries / parts plus one.
auto offsets = make_device_vector<int32_t>({0, 4, 9, 13, 17});
auto vertices = make_device_vector<vec_2d<T>>({// 1
{2.488450, 5.856625},
{1.333584, 5.008840},
{3.460720, 4.586599},
{2.488450, 5.856625},
// 2
{5.039823, 4.229242},
{5.561707, 1.825073},
{7.103516, 1.503906},
{7.190674, 4.025879},
{5.998939, 5.653384},
// 3
{5.998939, 1.235638},
{5.573720, 0.197808},
{6.703534, 0.086693},
{5.998939, 1.235638},
// 4
{2.088115, 4.541529},
{1.034892, 3.530299},
{2.415080, 2.896937},
{3.208660, 3.745936}});
// GeoArrow: Number of linestrings is number of offsets minus one.
auto bboxes = rmm::device_vector<cuspatial::box<T>>(offsets.size() - 1);
auto bboxes_end = cuspatial::linestring_bounding_boxes(
offsets.begin(), offsets.end(), vertices.begin(), vertices.end(), bboxes.begin());
EXPECT_EQ(std::distance(bboxes.begin(), bboxes_end), 4);
auto bboxes_expected = make_device_vector<cuspatial::box<T>>(
{{{1.3335840000000001, 4.5865989999999996}, {3.4607199999999998, 5.8566250000000002}},
{{5.0398230000000002, 1.503906}, {7.1906739999999996, 5.653384}},
{{5.5737199999999998, 0.086693000000000006}, {6.7035340000000003, 1.235638}},
{{1.0348919999999999, 2.8969369999999999}, {3.2086600000000001, 4.5415289999999997}}});
CUSPATIAL_EXPECT_VEC2D_PAIRS_EQUIVALENT(bboxes, bboxes_expected);
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/bounding_boxes/polygon_bounding_boxes_test.cpp | /*
* Copyright (c) 2020-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cuspatial/bounding_boxes.hpp>
#include <cuspatial/error.hpp>
#include <cudf/table/table.hpp>
#include <cudf/table/table_view.hpp>
#include <cudf/utilities/error.hpp>
#include <cudf_test/column_utilities.hpp>
#include <cudf_test/column_wrapper.hpp>
struct PolygonBoundingBoxErrorTest : public ::testing::Test {};
using T = float;
TEST_F(PolygonBoundingBoxErrorTest, test_empty)
{
using namespace cudf::test;
{
fixed_width_column_wrapper<int32_t> poly_offsets({});
fixed_width_column_wrapper<int32_t> ring_offsets({});
fixed_width_column_wrapper<T> x({});
fixed_width_column_wrapper<T> y({});
auto bboxes = cuspatial::polygon_bounding_boxes(poly_offsets, ring_offsets, x, y, 0.0);
EXPECT_EQ(bboxes->num_rows(), 0);
}
{
fixed_width_column_wrapper<int32_t> poly_offsets({0});
fixed_width_column_wrapper<int32_t> ring_offsets({});
fixed_width_column_wrapper<T> x({});
fixed_width_column_wrapper<T> y({});
auto bboxes = cuspatial::polygon_bounding_boxes(poly_offsets, ring_offsets, x, y, 0.0);
EXPECT_EQ(bboxes->num_rows(), 0);
}
}
TEST_F(PolygonBoundingBoxErrorTest, type_mismatch)
{
using namespace cudf::test;
fixed_width_column_wrapper<int32_t> poly_offsets({0, 1});
fixed_width_column_wrapper<int32_t> ring_offsets({0, 4});
fixed_width_column_wrapper<T> x({2.488450, 1.333584, 3.460720, 2.488450});
fixed_width_column_wrapper<double> y({5.856625, 5.008840, 4.586599, 5.856625});
EXPECT_THROW(cuspatial::polygon_bounding_boxes(poly_offsets, ring_offsets, x, y, 0.0),
cuspatial::logic_error);
}
TEST_F(PolygonBoundingBoxErrorTest, not_enough_ring_offsets)
{
using namespace cudf::test;
fixed_width_column_wrapper<int32_t> poly_offsets({0, 1});
fixed_width_column_wrapper<int32_t> ring_offsets({});
fixed_width_column_wrapper<T> x({2.488450, 1.333584, 3.460720, 2.488450});
fixed_width_column_wrapper<T> y({5.856625, 5.008840, 4.586599, 5.856625});
EXPECT_THROW(cuspatial::polygon_bounding_boxes(poly_offsets, ring_offsets, x, y, 0.0),
cuspatial::logic_error);
}
TEST_F(PolygonBoundingBoxErrorTest, offset_type_error)
{
using namespace cudf::test;
{
fixed_width_column_wrapper<float> poly_offsets({0, 1});
fixed_width_column_wrapper<int32_t> ring_offsets({0, 4});
fixed_width_column_wrapper<T> x({2.488450, 1.333584, 3.460720, 2.488450});
fixed_width_column_wrapper<T> y({5.856625, 5.008840, 4.586599, 5.856625});
EXPECT_THROW(cuspatial::polygon_bounding_boxes(poly_offsets, ring_offsets, x, y, 0.0),
cuspatial::logic_error);
}
{
fixed_width_column_wrapper<int32_t> poly_offsets({0, 1});
fixed_width_column_wrapper<float> ring_offsets({0, 4});
fixed_width_column_wrapper<T> x({2.488450, 1.333584, 3.460720, 2.488450});
fixed_width_column_wrapper<T> y({5.856625, 5.008840, 4.586599, 5.856625});
EXPECT_THROW(cuspatial::polygon_bounding_boxes(poly_offsets, ring_offsets, x, y, 0.0),
cuspatial::logic_error);
}
}
TEST_F(PolygonBoundingBoxErrorTest, vertex_size_mismatch)
{
using namespace cudf::test;
fixed_width_column_wrapper<int32_t> poly_offsets({0, 1});
fixed_width_column_wrapper<int32_t> ring_offsets({0, 4});
fixed_width_column_wrapper<T> x({2.488450, 1.333584, 3.460720, 2.488450});
fixed_width_column_wrapper<T> y({5.856625, 5.008840});
EXPECT_THROW(cuspatial::polygon_bounding_boxes(poly_offsets, ring_offsets, x, y, 0.0),
cuspatial::logic_error);
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/projection/sinusoidal_projection_test.cu | /*
* 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 <cuspatial/constants.hpp>
#include <cuspatial/error.hpp>
#include <cuspatial/projection.cuh>
#include <cuspatial_test/vector_equality.hpp>
#include <rmm/device_vector.hpp>
#include <gtest/gtest.h>
#include <thrust/iterator/transform_iterator.h>
template <typename T>
inline T midpoint(T a, T b)
{
return (a + b) / 2;
}
template <typename T>
inline T lon_to_x(T lon, T lat)
{
return lon * cuspatial::EARTH_CIRCUMFERENCE_KM_PER_DEGREE *
cos(lat * cuspatial::DEGREE_TO_RADIAN);
};
template <typename T>
inline T lat_to_y(T lat)
{
return lat * cuspatial::EARTH_CIRCUMFERENCE_KM_PER_DEGREE;
};
template <typename T>
struct sinusoidal_projection_functor {
using vec_2d = cuspatial::vec_2d<T>;
sinusoidal_projection_functor(vec_2d origin) : _origin(origin) {}
vec_2d operator()(vec_2d loc)
{
return vec_2d{lon_to_x(_origin.x - loc.x, midpoint(loc.y, _origin.y)),
lat_to_y(_origin.y - loc.y)};
}
private:
vec_2d _origin{};
};
template <typename T>
struct SinusoidalProjectionTest : public ::testing::Test {
using Vec = cuspatial::vec_2d<T>;
void run_test(std::vector<Vec> const& h_lonlats, Vec const& origin)
{
auto h_expected = std::vector<Vec>(h_lonlats.size());
std::transform(h_lonlats.begin(),
h_lonlats.end(),
h_expected.begin(),
sinusoidal_projection_functor(origin));
auto lonlats = rmm::device_vector<Vec>{h_lonlats};
auto xy_output = rmm::device_vector<Vec>(lonlats.size(), Vec{-1, -1});
auto xy_end =
cuspatial::sinusoidal_projection(lonlats.begin(), lonlats.end(), xy_output.begin(), origin);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(h_expected, xy_output);
EXPECT_EQ(h_expected.size(), std::distance(xy_output.begin(), xy_end));
}
};
// float and double are logically the same but would require separate tests due to precision.
using TestTypes = ::testing::Types<float, double>;
TYPED_TEST_CASE(SinusoidalProjectionTest, TestTypes);
TYPED_TEST(SinusoidalProjectionTest, Empty)
{
using T = TypeParam;
using Loc = cuspatial::vec_2d<T>;
using Cart = cuspatial::vec_2d<T>;
auto origin = Loc{-90.66511046, 42.49197018};
auto h_point_lonlat = std::vector<Loc>{};
CUSPATIAL_RUN_TEST(this->run_test, h_point_lonlat, origin);
}
TYPED_TEST(SinusoidalProjectionTest, Single)
{
using T = TypeParam;
using Loc = cuspatial::vec_2d<T>;
using Cart = cuspatial::vec_2d<T>;
auto origin = Loc{-90.66511046, 42.49197018};
auto h_point_lonlat = std::vector<Loc>({{-90.664973, 42.493894}});
CUSPATIAL_RUN_TEST(this->run_test, h_point_lonlat, origin);
}
TYPED_TEST(SinusoidalProjectionTest, Extremes)
{
using T = TypeParam;
using Loc = cuspatial::vec_2d<T>;
using Cart = cuspatial::vec_2d<T>;
auto origin = Loc{0, 0};
auto h_points_lonlat = std::vector<Loc>(
{{0.0, -90.0}, {0.0, 90.0}, {-180.0, 0.0}, {180.0, 0.0}, {45.0, 0.0}, {-180.0, -90.0}});
CUSPATIAL_RUN_TEST(this->run_test, h_points_lonlat, origin);
}
TYPED_TEST(SinusoidalProjectionTest, Multiple)
{
using T = TypeParam;
using Loc = cuspatial::vec_2d<T>;
using Cart = cuspatial::vec_2d<T>;
auto origin = Loc{-90.66511046, 42.49197018};
auto h_points_lonlat = std::vector<Loc>({{-90.664973, 42.493894},
{-90.665393, 42.491520},
{-90.664976, 42.491420},
{-90.664537, 42.493823}});
CUSPATIAL_RUN_TEST(this->run_test, h_points_lonlat, origin);
}
TYPED_TEST(SinusoidalProjectionTest, OriginOutOfBounds)
{
using T = TypeParam;
using Loc = cuspatial::vec_2d<T>;
using Cart = cuspatial::vec_2d<T>;
auto origin = Loc{-181, -91};
auto h_point_lonlat = std::vector<Loc>{};
auto h_expected = std::vector<Cart>{};
auto point_lonlat = rmm::device_vector<Loc>{};
auto expected = rmm::device_vector<Cart>{};
auto xy_output = rmm::device_vector<Cart>{};
EXPECT_THROW(cuspatial::sinusoidal_projection(
point_lonlat.begin(), point_lonlat.end(), xy_output.begin(), origin),
cuspatial::logic_error);
}
template <typename T>
struct identity_xform {
using Location = cuspatial::vec_2d<T>;
__device__ Location operator()(Location const& loc) { return loc; };
};
// This test verifies that fancy iterators can be passed by using a pass-through transform_iterator
TYPED_TEST(SinusoidalProjectionTest, TransformIterator)
{
using T = TypeParam;
using Loc = cuspatial::vec_2d<T>;
using Cart = cuspatial::vec_2d<T>;
auto origin = Loc{-90.66511046, 42.49197018};
auto h_points_lonlat = std::vector<Loc>({{-90.664973, 42.493894},
{-90.665393, 42.491520},
{-90.664976, 42.491420},
{-90.664537, 42.493823}});
auto h_expected = std::vector<Cart>(h_points_lonlat.size());
std::transform(h_points_lonlat.begin(),
h_points_lonlat.end(),
h_expected.begin(),
sinusoidal_projection_functor(origin));
auto points_lonlat = rmm::device_vector<Loc>{h_points_lonlat};
auto expected = rmm::device_vector<Cart>{h_expected};
auto xy_output = rmm::device_vector<Cart>(4, Cart{-1, -1});
auto xform_begin = thrust::make_transform_iterator(points_lonlat.begin(), identity_xform<T>{});
auto xform_end = thrust::make_transform_iterator(points_lonlat.end(), identity_xform<T>{});
auto xy_end = cuspatial::sinusoidal_projection(xform_begin, xform_end, xy_output.begin(), origin);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected, xy_output);
EXPECT_EQ(4, std::distance(xy_output.begin(), xy_end));
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/projection/sinusoidal_projection_test.cpp | /*
* Copyright (c) 2019-2020, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cuspatial/error.hpp>
#include <cuspatial/projection.hpp>
#include <cudf_test/base_fixture.hpp>
#include <cudf_test/column_utilities.hpp>
#include <cudf_test/column_wrapper.hpp>
#include <cudf_test/cudf_gtest.hpp>
#include <cudf_test/type_lists.hpp>
#include <type_traits>
using namespace cudf::test;
constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::ALL_ERRORS};
template <typename T>
struct SinusoidalProjectionTest : public BaseFixture {};
// float and double are logically the same but would require separate tests due to precision.
using TestTypes = Types<double>;
TYPED_TEST_CASE(SinusoidalProjectionTest, TestTypes);
TYPED_TEST(SinusoidalProjectionTest, Single)
{
using T = TypeParam;
auto camera_lon = -90.66511046;
auto camera_lat = 42.49197018;
auto point_lon = fixed_width_column_wrapper<T>({-90.664973});
auto point_lat = fixed_width_column_wrapper<T>({42.493894});
auto res_pair = cuspatial::sinusoidal_projection(camera_lon, camera_lat, point_lon, point_lat);
auto expected_lon = fixed_width_column_wrapper<T>({-0.01126195531216838});
auto expected_lat = fixed_width_column_wrapper<T>({-0.21375777777718794});
expect_columns_equivalent(expected_lon, res_pair.first->view(), verbosity);
expect_columns_equivalent(expected_lat, res_pair.second->view(), verbosity);
}
TYPED_TEST(SinusoidalProjectionTest, Extremes)
{
using T = TypeParam;
auto camera_lon = 0;
auto camera_lat = 0;
auto point_lon = fixed_width_column_wrapper<T>({0.0, 0.0, -180.0, 180.0, 45.0, -180.0});
auto point_lat = fixed_width_column_wrapper<T>({-90.0, 90.0, 0.0, 0.0, 0.0, -90.0});
auto res_pair = cuspatial::sinusoidal_projection(camera_lon, camera_lat, point_lon, point_lat);
auto expected_lon =
fixed_width_column_wrapper<T>({0.0, 0.0, 20000.0, -20000.0, -5000.0, 14142.13562373095192015});
auto expected_lat = fixed_width_column_wrapper<T>({10000.0, -10000.0, 0.0, 0.0, 0.0, 10000.0});
expect_columns_equivalent(expected_lon, res_pair.first->view(), verbosity);
expect_columns_equivalent(expected_lat, res_pair.second->view(), verbosity);
}
TYPED_TEST(SinusoidalProjectionTest, Multiple)
{
using T = TypeParam;
auto camera_lon = -90.66511046;
auto camera_lat = 42.49197018;
auto point_lon = fixed_width_column_wrapper<T>({-90.664973, -90.665393, -90.664976, -90.664537});
auto point_lat = fixed_width_column_wrapper<T>({42.493894, 42.491520, 42.491420, 42.493823});
auto res_pair = cuspatial::sinusoidal_projection(camera_lon, camera_lat, point_lon, point_lat);
auto expected_lon = fixed_width_column_wrapper<T>(
{-0.01126195531216838, 0.02314864865181343, -0.01101638630252916, -0.04698301003584082});
auto expected_lat = fixed_width_column_wrapper<T>(
{-0.21375777777718794, 0.05002000000015667, 0.06113111111163663, -0.20586888888847929});
expect_columns_equivalent(expected_lon, res_pair.first->view(), verbosity);
expect_columns_equivalent(expected_lat, res_pair.second->view(), verbosity);
}
TYPED_TEST(SinusoidalProjectionTest, Empty)
{
using T = TypeParam;
auto camera_lon = -90.66511046;
auto camera_lat = 42.49197018;
auto point_lon = fixed_width_column_wrapper<T>({});
auto point_lat = fixed_width_column_wrapper<T>({});
auto res_pair = cuspatial::sinusoidal_projection(camera_lon, camera_lat, point_lon, point_lat);
auto expected_lon = fixed_width_column_wrapper<T>({});
auto expected_lat = fixed_width_column_wrapper<T>({});
expect_columns_equivalent(expected_lon, res_pair.first->view(), verbosity);
expect_columns_equivalent(expected_lat, res_pair.second->view(), verbosity);
}
TYPED_TEST(SinusoidalProjectionTest, NullableNoNulls)
{
using T = TypeParam;
auto camera_lon = -90.66511046;
auto camera_lat = 42.49197018;
auto point_lon = fixed_width_column_wrapper<T>({-90.664973}, {1});
auto point_lat = fixed_width_column_wrapper<T>({42.493894}, {1});
auto res_pair = cuspatial::sinusoidal_projection(camera_lon, camera_lat, point_lon, point_lat);
auto expected_lon = fixed_width_column_wrapper<T>({-0.01126195531216838});
auto expected_lat = fixed_width_column_wrapper<T>({-0.21375777777718794});
expect_columns_equivalent(expected_lon, res_pair.first->view(), verbosity);
expect_columns_equivalent(expected_lat, res_pair.second->view(), verbosity);
}
TYPED_TEST(SinusoidalProjectionTest, NullabilityMixedNoNulls)
{
using T = TypeParam;
auto camera_lon = -90.66511046;
auto camera_lat = 42.49197018;
auto point_lon = fixed_width_column_wrapper<T>({-90.664973});
auto point_lat = fixed_width_column_wrapper<T>({42.493894}, {1});
auto res_pair = cuspatial::sinusoidal_projection(camera_lon, camera_lat, point_lon, point_lat);
auto expected_lon = fixed_width_column_wrapper<T>({-0.01126195531216838});
auto expected_lat = fixed_width_column_wrapper<T>({-0.21375777777718794});
expect_columns_equivalent(expected_lon, res_pair.first->view(), verbosity);
expect_columns_equivalent(expected_lat, res_pair.second->view(), verbosity);
}
TYPED_TEST(SinusoidalProjectionTest, NullableWithNulls)
{
using T = TypeParam;
auto camera_lon = 0;
auto camera_lat = 0;
auto point_lon = fixed_width_column_wrapper<T>({0}, {0});
auto point_lat = fixed_width_column_wrapper<T>({0}, {1});
EXPECT_THROW(cuspatial::sinusoidal_projection(camera_lon, camera_lat, point_lon, point_lat),
cuspatial::logic_error);
}
TYPED_TEST(SinusoidalProjectionTest, OriginOutOfBounds)
{
using T = TypeParam;
auto camera_lon = -181;
auto camera_lat = -91;
auto point_lon = fixed_width_column_wrapper<T>({0});
auto point_lat = fixed_width_column_wrapper<T>({0});
EXPECT_THROW(cuspatial::sinusoidal_projection(camera_lon, camera_lat, point_lon, point_lat),
cuspatial::logic_error);
}
TYPED_TEST(SinusoidalProjectionTest, MismatchType)
{
auto camera_lon = 0;
auto camera_lat = 0;
auto point_lon = fixed_width_column_wrapper<double>({0});
auto point_lat = fixed_width_column_wrapper<float>({0});
EXPECT_THROW(cuspatial::sinusoidal_projection(camera_lon, camera_lat, point_lon, point_lat),
cuspatial::logic_error);
}
TYPED_TEST(SinusoidalProjectionTest, MismatchSize)
{
using T = TypeParam;
auto camera_lon = 0;
auto camera_lat = 0;
auto point_lon = fixed_width_column_wrapper<T>({0, 0});
auto point_lat = fixed_width_column_wrapper<T>({0});
EXPECT_THROW(cuspatial::sinusoidal_projection(camera_lon, camera_lat, point_lon, point_lat),
cuspatial::logic_error);
}
template <typename T>
struct LatLonToCartesianUnsupportedTypesTest : public BaseFixture {};
using UnsupportedTestTypes = RemoveIf<ContainedIn<Types<float, double>>, NumericTypes>;
TYPED_TEST_CASE(LatLonToCartesianUnsupportedTypesTest, UnsupportedTestTypes);
TYPED_TEST(LatLonToCartesianUnsupportedTypesTest, MismatchSize)
{
using T = TypeParam;
auto camera_lon = 0;
auto camera_lat = 0;
auto point_lon = fixed_width_column_wrapper<T>({0});
auto point_lat = fixed_width_column_wrapper<T>({0});
EXPECT_THROW(cuspatial::sinusoidal_projection(camera_lon, camera_lat, point_lon, point_lat),
cuspatial::logic_error);
}
template <typename T>
struct LatLonToCartesianUnsupportedChronoTypesTest : public BaseFixture {};
TYPED_TEST_CASE(LatLonToCartesianUnsupportedChronoTypesTest, ChronoTypes);
TYPED_TEST(LatLonToCartesianUnsupportedChronoTypesTest, MismatchSize)
{
using T = TypeParam;
using R = typename T::rep;
auto camera_lon = 0;
auto camera_lat = 0;
auto point_lon = fixed_width_column_wrapper<T, R>({R{0}});
auto point_lat = fixed_width_column_wrapper<T, R>({R{0}});
EXPECT_THROW(cuspatial::sinusoidal_projection(camera_lon, camera_lat, point_lon, point_lat),
cuspatial::logic_error);
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/intersection/intersection_test_utils.cuh | /*
* 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 <cuspatial_test/vector_factories.cuh>
#include <cuspatial/cuda_utils.hpp>
#include <cuspatial/geometry/segment.cuh>
#include <cuspatial/intersection.cuh>
#include <thrust/copy.h>
#include <thrust/iterator/zip_iterator.h>
#include <thrust/scatter.h>
#include <thrust/sort.h>
#include <thrust/tuple.h>
namespace cuspatial {
namespace test {
// Custom order for two segments
template <typename T>
bool CUSPATIAL_HOST_DEVICE operator<(segment<T> lhs, segment<T> rhs)
{
return lhs.v1 < rhs.v1 || (lhs.v1 == rhs.v1 && lhs.v2 < rhs.v2);
}
/**
* @brief Functor for segmented sorting a geometry array
*
* Using a label array and a geometry array as keys, this functor defines that
* all keys with smaller labels should precede keys with larger labels; and that
* the order with the same label should be determined by the natural order of the
* geometries.
*
* Example:
* Labels: {0, 0, 0, 1}
* Points: {(0, 0), (5, 5), (1, 1), (3, 3)}
* Result: {(0, 0), (1, 1), (5, 5), (3, 3)}
*/
template <typename KeyType, typename GeomType>
struct order_key_value_pairs {
using key_value_t = thrust::tuple<KeyType, GeomType>;
bool CUSPATIAL_HOST_DEVICE operator()(key_value_t lhs, key_value_t rhs)
{
return thrust::get<0>(lhs) < thrust::get<0>(rhs) ||
(thrust::get<0>(lhs) == thrust::get<0>(rhs) &&
thrust::get<1>(lhs) < thrust::get<1>(rhs));
}
};
/**
* @brief Perform sorting to the intersection result
*
* The result of intersection result is non-determinisitc. This algorithm sorts
* the geometries of the same types and the same list and makes the result deterministic.
*
* The example below contains 2 rows and 4 geometries. The order of the first
* and second point is non-deterministic.
* [
* [Point(1.0, 1.5), Point(0.0, -0.3), Segment((0.0, 0.0), (1.0, 1.0))]
* ^ ^
* [Point(-3, -5)]
* ]
*
* After sorting, the result is deterministic:
* [
* [Point(0.0, -0.3), Point(1.0, 1.5), Segment((0.0, 0.0), (1.0, 1.0))]
* ^ ^
* [Point(-3, -5)]
* ]
*
* This function invalidates the input @p result and return a copy of sorted results.
*/
template <typename T, typename IndexType, typename type_t>
linestring_intersection_result<T, IndexType> segment_sort_intersection_result(
linestring_intersection_result<T, IndexType>& result,
rmm::mr::device_memory_resource* mr,
rmm::cuda_stream_view stream)
{
auto const num_points = result.points_coords->size();
auto const num_segments = result.segments_coords->size();
auto const num_geoms = num_points + num_segments;
rmm::device_uvector<IndexType> scatter_map(num_geoms, stream);
thrust::sequence(rmm::exec_policy(stream), scatter_map.begin(), scatter_map.end());
// Compute keys for each row in the union column. Rows of the same list
// are assigned the same label.
rmm::device_uvector<IndexType> geometry_collection_keys(num_geoms, stream);
auto geometry_collection_keys_begin = make_geometry_id_iterator<IndexType>(
result.geometry_collection_offset->begin(), result.geometry_collection_offset->end());
thrust::copy(rmm::exec_policy(stream),
geometry_collection_keys_begin,
geometry_collection_keys_begin + num_geoms,
geometry_collection_keys.begin());
// Perform "group-by" based on the list label and type of the row -
// This makes the geometry of the same type and of the same list neighbor.
// Make a copy of types buffer so that the sorting does not affect the original.
auto types_buffer = rmm::device_uvector<type_t>(*result.types_buffer, stream);
auto keys_begin =
thrust::make_zip_iterator(types_buffer.begin(), geometry_collection_keys.begin());
auto value_begin = thrust::make_zip_iterator(scatter_map.begin(),
result.lhs_linestring_id->begin(),
result.lhs_segment_id->begin(),
result.rhs_linestring_id->begin(),
result.rhs_segment_id->begin());
thrust::sort_by_key(rmm::exec_policy(stream), keys_begin, keys_begin + num_geoms, value_begin);
// Segment-sort the point array
auto keys_points_begin = thrust::make_zip_iterator(keys_begin, result.points_coords->begin());
thrust::sort_by_key(rmm::exec_policy(stream),
keys_points_begin,
keys_points_begin + num_points,
scatter_map.begin(),
order_key_value_pairs<thrust::tuple<IndexType, IndexType>, vec_2d<T>>{});
// Segment-sort the segment array
auto keys_segment_begin =
thrust::make_zip_iterator(keys_begin + num_points, result.segments_coords->begin());
thrust::sort_by_key(rmm::exec_policy(stream),
keys_segment_begin,
keys_segment_begin + num_segments,
scatter_map.begin() + num_points,
order_key_value_pairs<thrust::tuple<IndexType, IndexType>, segment<T>>{});
// Restore the order of indices
auto lhs_linestring_id = std::make_unique<rmm::device_uvector<IndexType>>(num_geoms, stream, mr);
auto lhs_segment_id = std::make_unique<rmm::device_uvector<IndexType>>(num_geoms, stream, mr);
auto rhs_linestring_id = std::make_unique<rmm::device_uvector<IndexType>>(num_geoms, stream, mr);
auto rhs_segment_id = std::make_unique<rmm::device_uvector<IndexType>>(num_geoms, stream, mr);
auto input_it = thrust::make_zip_iterator(result.lhs_linestring_id->begin(),
result.lhs_segment_id->begin(),
result.rhs_linestring_id->begin(),
result.rhs_segment_id->begin());
auto output_it = thrust::make_zip_iterator(lhs_linestring_id->begin(),
lhs_segment_id->begin(),
rhs_linestring_id->begin(),
rhs_segment_id->begin());
thrust::scatter(
rmm::exec_policy(stream), input_it, input_it + num_geoms, scatter_map.begin(), output_it);
return {std::move(result.geometry_collection_offset),
std::move(result.types_buffer),
std::move(result.offset_buffer),
std::move(result.points_coords),
std::move(result.segments_coords),
std::move(lhs_linestring_id),
std::move(lhs_segment_id),
std::move(rhs_linestring_id),
std::move(rhs_segment_id)};
}
template <typename T,
typename IndexType,
typename types_t,
typename point_t = vec_2d<T>,
typename segment_t = segment<T>>
auto make_linestring_intersection_result(
std::initializer_list<IndexType> geometry_collection_offset,
std::initializer_list<types_t> types_buffer,
std::initializer_list<IndexType> offset_buffer,
std::initializer_list<point_t> points_coords,
std::initializer_list<segment_t> segments_coords,
std::initializer_list<IndexType> lhs_linestring_ids,
std::initializer_list<IndexType> lhs_segment_ids,
std::initializer_list<IndexType> rhs_linestring_ids,
std::initializer_list<IndexType> rhs_segment_ids,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto d_geometry_collection_offset =
make_device_uvector<IndexType>(geometry_collection_offset, stream, mr);
auto d_types_buffer = make_device_uvector<types_t>(types_buffer, stream, mr);
auto d_offset_buffer = make_device_uvector<IndexType>(offset_buffer, stream, mr);
auto d_points_coords = make_device_uvector<point_t>(points_coords, stream, mr);
auto d_segments_coords = make_device_uvector<segment_t>(segments_coords, stream, mr);
auto d_lhs_linestring_ids = make_device_uvector<IndexType>(lhs_linestring_ids, stream, mr);
auto d_lhs_segment_ids = make_device_uvector<IndexType>(lhs_segment_ids, stream, mr);
auto d_rhs_linestring_ids = make_device_uvector<IndexType>(rhs_linestring_ids, stream, mr);
auto d_rhs_segment_ids = make_device_uvector<IndexType>(rhs_segment_ids, stream, mr);
return linestring_intersection_result<T, IndexType>{
std::make_unique<rmm::device_uvector<IndexType>>(d_geometry_collection_offset, stream),
std::make_unique<rmm::device_uvector<types_t>>(d_types_buffer, stream),
std::make_unique<rmm::device_uvector<IndexType>>(d_offset_buffer, stream),
std::make_unique<rmm::device_uvector<point_t>>(d_points_coords, stream),
std::make_unique<rmm::device_uvector<segment_t>>(d_segments_coords, stream),
std::make_unique<rmm::device_uvector<IndexType>>(d_lhs_linestring_ids, stream),
std::make_unique<rmm::device_uvector<IndexType>>(d_lhs_segment_ids, stream),
std::make_unique<rmm::device_uvector<IndexType>>(d_rhs_linestring_ids, stream),
std::make_unique<rmm::device_uvector<IndexType>>(d_rhs_segment_ids, stream)};
}
} // namespace test
} // namespace cuspatial
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/intersection/linestring_intersection_test.cpp | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf_test/cudf_gtest.hpp>
#include <cuspatial_test/base_fixture.hpp>
#include <cuspatial_test/test_util.cuh>
#include <cuspatial_test/vector_equality.hpp>
#include <cuspatial_test/vector_factories.cuh>
#include <cuspatial/column/geometry_column_view.hpp>
#include <cuspatial/error.hpp>
#include <cuspatial/geometry/vec_2d.hpp>
#include <cuspatial/intersection.hpp>
#include <cuspatial/types.hpp>
#include <cudf/column/column_factories.hpp>
#include <cudf/filling.hpp>
#include <cudf/scalar/scalar_factories.hpp>
#include <cudf/types.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf_test/column_utilities.hpp>
#include <cudf_test/column_wrapper.hpp>
#include <cudf_test/type_lists.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/mr/device/device_memory_resource.hpp>
#include <initializer_list>
#include <memory>
#include <optional>
#include <utility>
using namespace cuspatial;
using namespace cuspatial::test;
using namespace cudf;
using namespace cudf::test;
template <typename T>
using wrapper = cudf::test::fixed_width_column_wrapper<T>;
constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::ALL_ERRORS};
// helper function to make a linestring column
template <typename T>
std::pair<collection_type_id, std::unique_ptr<cudf::column>> make_linestring_column(
std::initializer_list<cudf::size_type>&& linestring_offsets,
std::initializer_list<T>&& linestring_coords,
rmm::cuda_stream_view stream)
{
auto num_points = linestring_coords.size() / 2;
auto size = linestring_offsets.size() - 1;
auto zero = make_fixed_width_scalar<size_type>(0, stream);
auto two = make_fixed_width_scalar<size_type>(2, stream);
auto offsets_column = wrapper<cudf::size_type>(linestring_offsets).release();
auto coords_offset = cudf::sequence(num_points + 1, *zero, *two);
auto coords_column = wrapper<T>(linestring_coords).release();
return {collection_type_id::SINGLE,
cudf::make_lists_column(
size,
std::move(offsets_column),
cudf::make_lists_column(
num_points, std::move(coords_offset), std::move(coords_column), 0, {}),
0,
{})};
}
// helper function to make a multilinestring column
template <typename T>
std::pair<collection_type_id, std::unique_ptr<cudf::column>> make_linestring_column(
std::initializer_list<cudf::size_type>&& multilinestring_offsets,
std::initializer_list<cudf::size_type>&& linestring_offsets,
std::initializer_list<T> linestring_coords,
rmm::cuda_stream_view stream)
{
auto geometry_size = multilinestring_offsets.size() - 1;
auto part_size = linestring_offsets.size() - 1;
auto num_points = linestring_coords.size() / 2;
auto zero = make_fixed_width_scalar<size_type>(0, stream);
auto two = make_fixed_width_scalar<size_type>(2, stream);
auto geometry_column = wrapper<cudf::size_type>(multilinestring_offsets).release();
auto part_column = wrapper<cudf::size_type>(linestring_offsets).release();
auto coords_offset = cudf::sequence(num_points + 1, *zero, *two);
auto coord_column = wrapper<T>(linestring_coords).release();
return {collection_type_id::MULTI,
cudf::make_lists_column(
geometry_size,
std::move(geometry_column),
cudf::make_lists_column(
part_size,
std::move(part_column),
cudf::make_lists_column(
num_points, std::move(coords_offset), std::move(coord_column), 0, {}),
0,
{}),
0,
{})};
}
struct LinestringIntersectionTestBase : public BaseFixture {
rmm::cuda_stream_view stream{rmm::cuda_stream_default};
rmm::mr::device_memory_resource* mr{rmm::mr::get_current_device_resource()};
};
template <typename T>
struct LinestringIntersectionTest : public LinestringIntersectionTestBase {
void run_single(geometry_column_view lhs,
geometry_column_view rhs,
linestring_intersection_column_result const& expected)
{
auto result = pairwise_linestring_intersection(lhs, rhs);
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(result.geometry_collection_offset->view(),
expected.geometry_collection_offset->view(),
verbosity);
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(
result.types_buffer->view(), expected.types_buffer->view(), verbosity);
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(
result.offset_buffer->view(), expected.offset_buffer->view(), verbosity);
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(result.points->view(), expected.points->view(), verbosity);
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(
result.segments->view(), expected.segments->view(), verbosity);
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(
result.lhs_linestring_id->view(), expected.lhs_linestring_id->view(), verbosity);
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(
result.lhs_segment_id->view(), expected.lhs_segment_id->view(), verbosity);
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(
result.rhs_linestring_id->view(), expected.rhs_linestring_id->view(), verbosity);
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(
result.rhs_segment_id->view(), expected.rhs_segment_id->view(), verbosity);
}
// helper function to make a linestring_intersection_column_result
auto make_linestring_intersection_result(
std::initializer_list<cudf::size_type> geometry_collection_offset,
std::initializer_list<uint8_t> types_buffer,
std::initializer_list<cudf::size_type> offset_buffer,
std::initializer_list<cudf::size_type> points_offsets,
std::initializer_list<T> points_xy,
std::initializer_list<cudf::size_type> segments_offsets,
std::initializer_list<cudf::size_type> segments_coords_offsets,
std::initializer_list<T> segments_xy,
std::initializer_list<cudf::size_type> lhs_linestring_ids,
std::initializer_list<cudf::size_type> lhs_segment_ids,
std::initializer_list<cudf::size_type> rhs_linestring_ids,
std::initializer_list<cudf::size_type> rhs_segment_ids)
{
auto d_geometry_collection_offset =
wrapper<cudf::size_type>(geometry_collection_offset).release();
auto d_types_buffer = wrapper<uint8_t>(types_buffer).release();
auto d_offset_buffer = wrapper<cudf::size_type>(offset_buffer).release();
auto num_points = points_offsets.size() - 1;
auto d_points_offsets = wrapper<cudf::size_type>(points_offsets).release();
auto d_points_xy = wrapper<T>(points_xy).release();
auto d_points =
make_lists_column(num_points, std::move(d_points_offsets), std::move(d_points_xy), 0, {});
auto d_segments_offsets = wrapper<size_type>(segments_offsets).release();
auto d_segments_coords_offsets = wrapper<size_type>(segments_coords_offsets).release();
auto d_segments_xy = wrapper<T>(segments_xy).release();
auto num_segments = d_segments_offsets->size() - 1;
auto num_segment_points = d_segments_coords_offsets->size() - 1;
auto d_segments = make_lists_column(
num_segments,
std::move(d_segments_offsets),
make_lists_column(
num_segment_points, std::move(d_segments_coords_offsets), std::move(d_segments_xy), 0, {}),
0,
{});
auto d_lhs_linestring_ids = wrapper<cudf::size_type>(lhs_linestring_ids).release();
auto d_lhs_segment_ids = wrapper<cudf::size_type>(lhs_segment_ids).release();
auto d_rhs_linestring_ids = wrapper<cudf::size_type>(rhs_linestring_ids).release();
auto d_rhs_segment_ids = wrapper<cudf::size_type>(rhs_segment_ids).release();
return linestring_intersection_column_result{std::move(d_geometry_collection_offset),
std::move(d_types_buffer),
std::move(d_offset_buffer),
std::move(d_points),
std::move(d_segments),
std::move(d_lhs_linestring_ids),
std::move(d_lhs_segment_ids),
std::move(d_rhs_linestring_ids),
std::move(d_rhs_segment_ids)};
}
};
struct LinestringIntersectionTestUntyped : public LinestringIntersectionTestBase {};
// float and double are logically the same but would require separate tests due to precision.
using TestTypes = FloatingPointTypes;
TYPED_TEST_CASE(LinestringIntersectionTest, TestTypes);
TYPED_TEST(LinestringIntersectionTest, SingleToSingleEmpty)
{
using T = TypeParam;
auto [ltype, lhs] = make_linestring_column<T>({0}, std::initializer_list<T>{}, this->stream);
auto [rtype, rhs] = make_linestring_column<T>({0}, std::initializer_list<T>{}, this->stream);
auto expected =
this->make_linestring_intersection_result({0},
{},
std::initializer_list<size_type>{},
{0},
std::initializer_list<T>{},
{0},
{0},
std::initializer_list<T>{},
std::initializer_list<cudf::size_type>{},
std::initializer_list<cudf::size_type>{},
std::initializer_list<cudf::size_type>{},
std::initializer_list<cudf::size_type>{});
CUSPATIAL_RUN_TEST(this->run_single,
geometry_column_view(lhs->view(), ltype, geometry_type_id::LINESTRING),
geometry_column_view(rhs->view(), rtype, geometry_type_id::LINESTRING),
expected);
}
TYPED_TEST(LinestringIntersectionTest, SingleToSingleOnePair)
{
using T = TypeParam;
auto [ltype, lhs] = make_linestring_column<T>({0, 2}, {0, 0, 1, 1}, this->stream);
auto [rtype, rhs] = make_linestring_column<T>({0, 2}, {0, 1, 1, 0}, this->stream);
auto expected = this->make_linestring_intersection_result(
{0, 1}, {0}, {0}, {0, 2}, {0.5, 0.5}, {0}, {0}, {}, {0}, {0}, {0}, {0});
CUSPATIAL_RUN_TEST(this->run_single,
geometry_column_view(lhs->view(), ltype, geometry_type_id::LINESTRING),
geometry_column_view(rhs->view(), rtype, geometry_type_id::LINESTRING),
expected);
}
TYPED_TEST(LinestringIntersectionTest, MultiToSingleEmpty)
{
using T = TypeParam;
auto [ltype, lhs] = make_linestring_column<T>({0}, {0}, std::initializer_list<T>{}, this->stream);
auto [rtype, rhs] = make_linestring_column<T>({0}, std::initializer_list<T>{}, this->stream);
auto expected =
this->make_linestring_intersection_result({0},
{},
std::initializer_list<cudf::size_type>{},
{0},
std::initializer_list<T>{},
{0},
{0},
std::initializer_list<T>{},
std::initializer_list<cudf::size_type>{},
std::initializer_list<cudf::size_type>{},
std::initializer_list<cudf::size_type>{},
std::initializer_list<cudf::size_type>{});
CUSPATIAL_RUN_TEST(this->run_single,
geometry_column_view(lhs->view(), ltype, geometry_type_id::LINESTRING),
geometry_column_view(rhs->view(), rtype, geometry_type_id::LINESTRING),
expected);
}
TYPED_TEST(LinestringIntersectionTest, MultiToSingleOnePair)
{
using T = TypeParam;
auto [ltype, lhs] = make_linestring_column<T>({0, 1}, {0, 2}, {0, 2, 2, 2}, this->stream);
auto [rtype, rhs] = make_linestring_column<T>({0, 2}, {1, 3, 1, 0}, this->stream);
auto expected = this->make_linestring_intersection_result(
{0, 1}, {0}, {0}, {0, 2}, {1, 2}, {0}, {0}, std::initializer_list<T>{}, {0}, {0}, {0}, {0});
CUSPATIAL_RUN_TEST(this->run_single,
geometry_column_view(lhs->view(), ltype, geometry_type_id::LINESTRING),
geometry_column_view(rhs->view(), rtype, geometry_type_id::LINESTRING),
expected);
}
TYPED_TEST(LinestringIntersectionTest, SingleToMultiEmpty)
{
using T = TypeParam;
auto [ltype, lhs] = make_linestring_column<T>({0}, std::initializer_list<T>{}, this->stream);
auto [rtype, rhs] = make_linestring_column<T>({0}, {0}, std::initializer_list<T>{}, this->stream);
auto expected =
this->make_linestring_intersection_result({0},
{},
std::initializer_list<cudf::size_type>{},
{0},
std::initializer_list<T>{},
{0},
{0},
std::initializer_list<T>{},
std::initializer_list<cudf::size_type>{},
std::initializer_list<cudf::size_type>{},
std::initializer_list<cudf::size_type>{},
std::initializer_list<cudf::size_type>{});
CUSPATIAL_RUN_TEST(this->run_single,
geometry_column_view(lhs->view(), ltype, geometry_type_id::LINESTRING),
geometry_column_view(rhs->view(), rtype, geometry_type_id::LINESTRING),
expected);
}
TYPED_TEST(LinestringIntersectionTest, SingleToMultiOnePair)
{
using T = TypeParam;
auto [ltype, lhs] = make_linestring_column<T>({0, 2}, {0, 2, 2, 2}, this->stream);
auto [rtype, rhs] = make_linestring_column<T>({0, 1}, {0, 2}, {1, 3, 1, 0}, this->stream);
auto expected = this->make_linestring_intersection_result(
{0, 1}, {0}, {0}, {0, 2}, {1, 2}, {0}, {0}, {}, {0}, {0}, {0}, {0});
CUSPATIAL_RUN_TEST(this->run_single,
geometry_column_view(lhs->view(), ltype, geometry_type_id::LINESTRING),
geometry_column_view(rhs->view(), rtype, geometry_type_id::LINESTRING),
expected);
}
TYPED_TEST(LinestringIntersectionTest, MultiToMultiEmpty)
{
using T = TypeParam;
auto [ltype, lhs] = make_linestring_column<T>({0}, {0}, std::initializer_list<T>{}, this->stream);
auto [rtype, rhs] = make_linestring_column<T>({0}, {0}, std::initializer_list<T>{}, this->stream);
auto expected =
this->make_linestring_intersection_result({0},
{},
std::initializer_list<cudf::size_type>{},
{0},
std::initializer_list<T>{},
{0},
{0},
std::initializer_list<T>{},
std::initializer_list<cudf::size_type>{},
std::initializer_list<cudf::size_type>{},
std::initializer_list<cudf::size_type>{},
std::initializer_list<cudf::size_type>{});
CUSPATIAL_RUN_TEST(this->run_single,
geometry_column_view(lhs->view(), ltype, geometry_type_id::LINESTRING),
geometry_column_view(rhs->view(), rtype, geometry_type_id::LINESTRING),
expected);
}
TYPED_TEST(LinestringIntersectionTest, MultiToMultiOnePair)
{
using T = TypeParam;
auto [ltype, lhs] = make_linestring_column<T>({0, 1}, {0, 2}, {0, 2, 2, 2}, this->stream);
auto [rtype, rhs] = make_linestring_column<T>({0, 1}, {0, 2}, {1, 3, 1, 0}, this->stream);
auto expected = this->make_linestring_intersection_result(
{0, 1}, {0}, {0}, {0, 2}, {1, 2}, {0}, {0}, std::initializer_list<T>{}, {0}, {0}, {0}, {0});
CUSPATIAL_RUN_TEST(this->run_single,
geometry_column_view(lhs->view(), ltype, geometry_type_id::LINESTRING),
geometry_column_view(rhs->view(), rtype, geometry_type_id::LINESTRING),
expected);
}
TEST_F(LinestringIntersectionTestUntyped, MismatchCoordinateType)
{
auto lhs_geom = fixed_width_column_wrapper<cudf::size_type>{0, 2};
auto lhs_coords = fixed_width_column_wrapper<float>{0, 1, 1, 0};
auto lhs = cudf::make_lists_column(1, lhs_geom.release(), lhs_coords.release(), 0, {});
auto lhs_view =
geometry_column_view(lhs->view(), collection_type_id::SINGLE, geometry_type_id::LINESTRING);
auto rhs_geom = fixed_width_column_wrapper<cudf::size_type>{0, 2};
auto rhs_coords = fixed_width_column_wrapper<double>{0, 1, 1, 0};
auto rhs = cudf::make_lists_column(1, rhs_geom.release(), rhs_coords.release(), 0, {});
auto rhs_view =
geometry_column_view(rhs->view(), collection_type_id::SINGLE, geometry_type_id::LINESTRING);
EXPECT_THROW(cuspatial::pairwise_linestring_intersection(lhs_view, rhs_view),
cuspatial::logic_error);
}
TEST_F(LinestringIntersectionTestUntyped, MismatchSizeSingleToSingle)
{
auto lhs_geom = fixed_width_column_wrapper<cudf::size_type>{0, 2, 4};
auto lhs_coords = fixed_width_column_wrapper<double>{0, 1, 1, 0, 1, 1, 2, 2};
auto lhs = cudf::make_lists_column(2, lhs_geom.release(), lhs_coords.release(), 0, {});
auto lhs_view =
geometry_column_view(lhs->view(), collection_type_id::SINGLE, geometry_type_id::LINESTRING);
auto rhs_geom = fixed_width_column_wrapper<cudf::size_type>{0, 2};
auto rhs_coords = fixed_width_column_wrapper<double>{0, 1, 1, 0};
auto rhs = cudf::make_lists_column(1, rhs_geom.release(), rhs_coords.release(), 0, {});
auto rhs_view =
geometry_column_view(rhs->view(), collection_type_id::SINGLE, geometry_type_id::LINESTRING);
EXPECT_THROW(cuspatial::pairwise_linestring_intersection(lhs_view, rhs_view),
cuspatial::logic_error);
}
TEST_F(LinestringIntersectionTestUntyped, MismatchSizeSingleToMulti)
{
auto lhs_geom = fixed_width_column_wrapper<cudf::size_type>{0, 2};
auto lhs_coords = fixed_width_column_wrapper<double>{0, 1, 1, 0};
auto lhs = cudf::make_lists_column(1, lhs_geom.release(), lhs_coords.release(), 0, {});
auto lhs_view =
geometry_column_view(lhs->view(), collection_type_id::SINGLE, geometry_type_id::LINESTRING);
auto rhs_geom = fixed_width_column_wrapper<cudf::size_type>{0, 1, 2};
auto rhs_part = fixed_width_column_wrapper<cudf::size_type>{0, 2, 4};
auto rhs_coords = fixed_width_column_wrapper<double>{0, 1, 1, 0, 0, 2, 2, 0};
auto rhs = cudf::make_lists_column(2, rhs_geom.release(), rhs_coords.release(), 0, {});
auto rhs_view =
geometry_column_view(rhs->view(), collection_type_id::MULTI, geometry_type_id::LINESTRING);
EXPECT_THROW(cuspatial::pairwise_linestring_intersection(lhs_view, rhs_view),
cuspatial::logic_error);
}
TEST_F(LinestringIntersectionTestUntyped, MismatchSizeMultiToSingle)
{
auto lhs_geom = fixed_width_column_wrapper<cudf::size_type>{0, 2};
auto lhs_coords = fixed_width_column_wrapper<double>{0, 1, 1, 0};
auto lhs = cudf::make_lists_column(1, lhs_geom.release(), lhs_coords.release(), 0, {});
auto lhs_view =
geometry_column_view(lhs->view(), collection_type_id::SINGLE, geometry_type_id::LINESTRING);
auto rhs_geom = fixed_width_column_wrapper<cudf::size_type>{0, 1, 2};
auto rhs_part = fixed_width_column_wrapper<cudf::size_type>{0, 2, 4};
auto rhs_coords = fixed_width_column_wrapper<double>{0, 1, 1, 0, 0, 2, 2, 0};
auto rhs = cudf::make_lists_column(2, rhs_geom.release(), rhs_coords.release(), 0, {});
auto rhs_view =
geometry_column_view(rhs->view(), collection_type_id::MULTI, geometry_type_id::LINESTRING);
EXPECT_THROW(cuspatial::pairwise_linestring_intersection(lhs_view, rhs_view),
cuspatial::logic_error);
}
TEST_F(LinestringIntersectionTestUntyped, MismatchSizeMultiToMulti)
{
auto lhs_geom = fixed_width_column_wrapper<cudf::size_type>{0, 1, 2};
auto lhs_part = fixed_width_column_wrapper<cudf::size_type>{0, 2, 4};
auto lhs_coords = fixed_width_column_wrapper<double>{0, 1, 1, 0, 0, 2, 2, 2};
auto lhs = cudf::make_lists_column(2, lhs_geom.release(), lhs_coords.release(), 0, {});
auto lhs_view =
geometry_column_view(lhs->view(), collection_type_id::MULTI, geometry_type_id::LINESTRING);
auto rhs_geom = fixed_width_column_wrapper<cudf::size_type>{0, 1};
auto rhs_part = fixed_width_column_wrapper<cudf::size_type>{0, 2};
auto rhs_coords = fixed_width_column_wrapper<double>{0, 1, 1, 0};
auto rhs = cudf::make_lists_column(1, rhs_geom.release(), rhs_coords.release(), 0, {});
auto rhs_view =
geometry_column_view(rhs->view(), collection_type_id::MULTI, geometry_type_id::LINESTRING);
EXPECT_THROW(cuspatial::pairwise_linestring_intersection(lhs_view, rhs_view),
cuspatial::logic_error);
}
TEST_F(LinestringIntersectionTestUntyped, NotLineString)
{
auto lhs_offsets = fixed_width_column_wrapper<cudf::size_type>{0, 2, 4};
auto lhs_coords = fixed_width_column_wrapper<double>{0, 1, 1, 2};
auto lhs = cudf::make_lists_column(2, lhs_offsets.release(), lhs_coords.release(), 0, {});
auto lhs_view =
geometry_column_view(lhs->view(), collection_type_id::SINGLE, geometry_type_id::POINT);
auto [rhs_type, rhs] = make_linestring_column<double>({0, 2}, {0, 1, 1, 0}, this->stream);
auto rhs_view = geometry_column_view(rhs->view(), rhs_type, geometry_type_id::LINESTRING);
EXPECT_THROW(cuspatial::pairwise_linestring_intersection(lhs_view, rhs_view),
cuspatial::logic_error);
}
TEST_F(LinestringIntersectionTestUntyped, NotLinestring2)
{
auto lhs_geom = fixed_width_column_wrapper<cudf::size_type>{0, 2};
auto lhs_coords = fixed_width_column_wrapper<double>{0, 1, 1, 0};
auto lhs = cudf::make_lists_column(1, lhs_geom.release(), lhs_coords.release(), 0, {});
auto lhs_view =
geometry_column_view(lhs->view(), collection_type_id::SINGLE, geometry_type_id::LINESTRING);
auto rhs_geom = fixed_width_column_wrapper<cudf::size_type>{0, 1};
auto rhs_part = fixed_width_column_wrapper<cudf::size_type>{0, 1};
auto rhs_ring = fixed_width_column_wrapper<cudf::size_type>{0, 5};
auto rhs_coord = fixed_width_column_wrapper<double>{0, 1, 1, 1, 1, 0, 0, 0, 0, 1};
auto rhs = cudf::make_lists_column(
1,
rhs_geom.release(),
cudf::make_lists_column(
1,
rhs_part.release(),
cudf::make_lists_column(1, rhs_ring.release(), rhs_coord.release(), 0, {}),
0,
{}),
0,
{});
auto rhs_view =
geometry_column_view(rhs->view(), collection_type_id::MULTI, geometry_type_id::POLYGON);
EXPECT_THROW(cuspatial::pairwise_linestring_intersection(lhs_view, rhs_view),
cuspatial::logic_error);
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/intersection/linestring_intersection_test.cu | /*
* 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 "intersection_test_utils.cuh"
#include <cuspatial_test/vector_equality.hpp>
#include <cuspatial_test/vector_factories.cuh>
#include <cuspatial/error.hpp>
#include <cuspatial/geometry/vec_2d.hpp>
#include <cuspatial/intersection.cuh>
#include <cuspatial/iterator_factory.cuh>
#include <cuspatial/traits.hpp>
#include <cudf/column/column.hpp>
#include <cudf_test/column_utilities.hpp>
#include <rmm/device_vector.hpp>
#include <rmm/exec_policy.hpp>
#include <rmm/mr/device/pool_memory_resource.hpp>
#include <thrust/binary_search.h>
#include <thrust/sort.h>
#include <initializer_list>
#include <type_traits>
using namespace cuspatial;
using namespace cuspatial::test;
template <typename T>
struct LinestringIntersectionTest : public ::testing::Test {
rmm::cuda_stream_view stream() { return rmm::cuda_stream_default; }
rmm::mr::device_memory_resource* mr() { return rmm::mr::get_current_device_resource(); }
template <typename IndexType, typename MultiLinestringRange, typename IntersectionResult>
void run_single_test(MultiLinestringRange lhs,
MultiLinestringRange rhs,
IntersectionResult const& expected)
{
using types_t = typename IntersectionResult::types_t;
auto unsorted =
pairwise_linestring_intersection<T, IndexType>(lhs, rhs, this->mr(), this->stream());
auto got =
segment_sort_intersection_result<T, IndexType, types_t>(unsorted, this->mr(), this->stream());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(*std::move(expected.geometry_collection_offset),
*std::move(got.geometry_collection_offset));
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(*std::move(expected.types_buffer),
*std::move(got.types_buffer));
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(*std::move(expected.offset_buffer),
*std::move(got.offset_buffer));
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(*std::move(expected.points_coords),
*std::move(got.points_coords));
expect_vec_2d_pair_equivalent(*std::move(expected.segments_coords),
*std::move(got.segments_coords));
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(*std::move(expected.lhs_linestring_id),
*std::move(got.lhs_linestring_id));
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(*std::move(expected.lhs_segment_id),
*std::move(got.lhs_segment_id));
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(*std::move(expected.rhs_linestring_id),
*std::move(got.rhs_linestring_id));
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(*std::move(expected.rhs_segment_id),
*std::move(got.rhs_segment_id));
}
};
// float and double are logically the same but would require separate tests due to precision.
using TestTypes = ::testing::Types<float, double>;
TYPED_TEST_CASE(LinestringIntersectionTest, TestTypes);
// // TODO: sort the points in the intersection result since the result order is arbitrary.
TYPED_TEST(LinestringIntersectionTest, Empty)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = typename linestring_intersection_result<T, std::size_t>::index_t;
using types_t = typename linestring_intersection_result<T, std::size_t>::types_t;
auto multilinestrings1 = make_multilinestring_array({0}, {0}, std::initializer_list<P>{});
auto multilinestrings2 = make_multilinestring_array({0}, {0}, std::initializer_list<P>{});
auto expected = make_linestring_intersection_result<T, index_t, types_t>(
{0}, {}, {}, {}, {}, {}, {}, {}, {}, this->stream(), this->mr());
CUSPATIAL_RUN_TEST(this->template run_single_test<index_t>,
multilinestrings1.range(),
multilinestrings2.range(),
expected);
}
TYPED_TEST(LinestringIntersectionTest, SingletoSingleOnePair)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = typename linestring_intersection_result<T, std::size_t>::index_t;
using types_t = typename linestring_intersection_result<T, std::size_t>::types_t;
auto multilinestrings1 = make_multilinestring_array({0, 1}, {0, 2}, {P{0.0, 0.0}, P{1.0, 1.0}});
auto multilinestrings2 = make_multilinestring_array({0, 1}, {0, 2}, {P{0.0, 1.0}, P{1.0, 0.0}});
auto expected = make_linestring_intersection_result<T, index_t, types_t>(
{0, 1}, {0}, {0}, {P{0.5, 0.5}}, {}, {0}, {0}, {0}, {0}, this->stream(), this->mr());
CUSPATIAL_RUN_TEST(this->template run_single_test<index_t>,
multilinestrings1.range(),
multilinestrings2.range(),
expected);
}
TYPED_TEST(LinestringIntersectionTest, OnePairWithRings)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = typename linestring_intersection_result<T, std::size_t>::index_t;
using types_t = typename linestring_intersection_result<T, std::size_t>::types_t;
auto multilinestrings1 = make_multilinestring_array<T>({0, 1}, {0, 2}, {{-1, 0}, {0, 0}});
auto multilinestrings2 =
make_multilinestring_array<T>({0, 1}, {0, 5}, {{0, 0}, {0, 1}, {1, 1}, {1, 0}, {0, 0}});
auto expected = make_linestring_intersection_result<T, index_t, types_t>(
{0, 1}, {0}, {0}, {P{0.0, 0.0}}, {}, {0}, {0}, {0}, {0}, this->stream(), this->mr());
CUSPATIAL_RUN_TEST(this->template run_single_test<index_t>,
multilinestrings1.range(),
multilinestrings2.range(),
expected);
}
TYPED_TEST(LinestringIntersectionTest, SingletoSingleOnePairWithDuplicatePoint)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = typename linestring_intersection_result<T, std::size_t>::index_t;
using types_t = typename linestring_intersection_result<T, std::size_t>::types_t;
auto multilinestrings1 = make_multilinestring_array({0, 1}, {0, 2}, {P{0.0, 0.0}, P{1.0, 1.0}});
auto multilinestrings2 =
make_multilinestring_array({0, 1}, {0, 4}, {P{0.0, 1.0}, P{1.0, 0.0}, P{0.5, 0.0}, P{0.5, 1}});
auto expected = make_linestring_intersection_result<T, index_t, types_t>(
{0, 1}, {0}, {0}, {P{0.5, 0.5}}, {}, {0}, {0}, {0}, {0}, this->stream(), this->mr());
CUSPATIAL_RUN_TEST(this->template run_single_test<index_t>,
multilinestrings1.range(),
multilinestrings2.range(),
expected);
}
TYPED_TEST(LinestringIntersectionTest, SingletoSingleOnePairWithMergeableSegment)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = typename linestring_intersection_result<T, std::size_t>::index_t;
using types_t = typename linestring_intersection_result<T, std::size_t>::types_t;
auto multilinestrings1 = make_multilinestring_array({0, 1}, {0, 2}, {P{0.0, 0.0}, P{3.0, 3.0}});
auto multilinestrings2 = make_multilinestring_array(
{0, 1}, {0, 4}, {P{0.0, 0.0}, P{1.0, 1.0}, P{0.5, 0.5}, P{1.5, 1.5}});
auto expected =
make_linestring_intersection_result<T, index_t, types_t>({0, 1},
{1},
{0},
{},
{segment<T>{P{0.0, 0.0}, P{1.5, 1.5}}},
{0},
{0},
{0},
{0},
this->stream(),
this->mr());
CUSPATIAL_RUN_TEST(this->template run_single_test<index_t>,
multilinestrings1.range(),
multilinestrings2.range(),
expected);
}
TYPED_TEST(LinestringIntersectionTest, SingletoSingleOnePairWithMergeablePoint)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = typename linestring_intersection_result<T, std::size_t>::index_t;
using types_t = typename linestring_intersection_result<T, std::size_t>::types_t;
auto multilinestrings1 = make_multilinestring_array({0, 1}, {0, 2}, {P{0.0, 0.0}, P{3.0, 3.0}});
auto multilinestrings2 = make_multilinestring_array(
{0, 1}, {0, 4}, {P{0.0, 1.0}, P{1.0, 0.0}, P{2.0, 2.0}, P{0.0, 0.0}});
auto expected =
make_linestring_intersection_result<T, index_t, types_t>({0, 1},
{1},
{0},
{},
{segment<T>{P{0.0, 0.0}, P{2.0, 2.0}}},
{0},
{0},
{0},
{2},
this->stream(),
this->mr());
CUSPATIAL_RUN_TEST(this->template run_single_test<index_t>,
multilinestrings1.range(),
multilinestrings2.range(),
expected);
}
TYPED_TEST(LinestringIntersectionTest, TwoPairsSingleToSingle)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = typename linestring_intersection_result<T, std::size_t>::index_t;
using types_t = typename linestring_intersection_result<T, std::size_t>::types_t;
auto multilinestrings1 = make_multilinestring_array(
{0, 1, 2}, {0, 2, 4}, {P{0.0, 0.0}, P{1.0, 1.0}, P{0.5, 0}, P{0.5, 1}});
auto multilinestrings2 = make_multilinestring_array(
{0, 1, 2}, {0, 2, 4}, {P{0.0, 1.0}, P{1.0, 0.0}, P{0, 0.5}, P{1, 0.5}});
auto expected =
make_linestring_intersection_result<T, index_t, types_t>({0, 1, 2},
{0, 0},
{0, 1},
{P{0.5, 0.5}, P{0.5, 0.5}},
{},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
this->stream(),
this->mr());
CUSPATIAL_RUN_TEST(this->template run_single_test<index_t>,
multilinestrings1.range(),
multilinestrings2.range(),
expected);
}
TYPED_TEST(LinestringIntersectionTest, TwoPairMultiWithMergeablePoints)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = typename linestring_intersection_result<T, std::size_t>::index_t;
using types_t = typename linestring_intersection_result<T, std::size_t>::types_t;
auto multilinestrings1 = make_multilinestring_array(
{0, 2, 3},
{0, 2, 4, 6},
{P{0.25, 0.25}, P{0.75, 0.75}, P{0.0, 1.0}, P{1.0, 0.0}, P{0.0, 3.0}, P{3.0, 3.0}});
auto multilinestrings2 = make_multilinestring_array(
{0, 1, 2}, {0, 2, 5}, {P{0.0, 0.0}, P{1.0, 1.0}, P{0.0, 2.0}, P{2.0, 4.0}, P{3.0, 2.0}});
auto expected = make_linestring_intersection_result<T, index_t, types_t>(
{0, 1, 3},
{1, 0, 0},
{0, 0, 1},
{P{1.0, 3.0}, P{2.5, 3.0}},
{segment<T>{P{0.25, 0.25}, P{0.75, 0.75}}},
{0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{0, 0, 1},
this->stream(),
this->mr());
CUSPATIAL_RUN_TEST(this->template run_single_test<index_t>,
multilinestrings1.range(),
multilinestrings2.range(),
expected);
}
TYPED_TEST(LinestringIntersectionTest, TwoPairMultiWithDuplicatePoints)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = typename linestring_intersection_result<T, std::size_t>::index_t;
using types_t = typename linestring_intersection_result<T, std::size_t>::types_t;
auto multilinestrings1 = make_multilinestring_array(
{0, 2, 3},
{0, 2, 4, 6},
{P{0.0, 1.0}, P{1.0, 0.0}, P{0.5, 0.0}, P{0.5, 1.0}, P{0.0, 3.0}, P{3.0, 3.0}});
auto multilinestrings2 = make_multilinestring_array(
{0, 1, 2}, {0, 2, 4}, {P{0.0, 0.0}, P{1.0, 1.0}, P{0.0, 2.0}, P{2.0, 2.0}});
auto expected = make_linestring_intersection_result<T, index_t, types_t>(
{0, 1, 1}, {0}, {0}, {P{0.5, 0.5}}, {}, {0}, {0}, {0}, {0}, this->stream(), this->mr());
CUSPATIAL_RUN_TEST(this->template run_single_test<index_t>,
multilinestrings1.range(),
multilinestrings2.range(),
expected);
}
TYPED_TEST(LinestringIntersectionTest, ThreePairIdenticalInputsNoRing)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = typename linestring_intersection_result<T, std::size_t>::index_t;
using types_t = typename linestring_intersection_result<T, std::size_t>::types_t;
auto multilinestrings1 = make_multilinestring_array(
{0, 1, 2, 3},
{0, 2, 4, 6},
{P{0.0, 0.0}, P{1.0, 1.0}, P{0.0, 0.0}, P{1.0, 1.0}, P{0.0, 0.0}, P{1.0, 1.0}});
auto multilinestrings2 = make_multilinestring_array<T>({0, 1, 2, 3},
{0, 4, 8, 12},
{{0, 0},
{0, 1},
{1, 1},
{1, 0},
{0, 0},
{0, 1},
{1, 1},
{1, 0},
{0, 0},
{0, 1},
{1, 1},
{1, 0}});
auto expected = make_linestring_intersection_result<T, index_t, types_t>({0, 2, 4, 6},
{0, 0, 0, 0, 0, 0},
{0, 1, 2, 3, 4, 5},
{
{0.0, 0.0},
{1.0, 1.0},
{0.0, 0.0},
{1.0, 1.0},
{0.0, 0.0},
{1.0, 1.0},
},
{},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 1, 0, 1, 0, 1},
this->stream(),
this->mr());
CUSPATIAL_RUN_TEST(this->template run_single_test<index_t>,
multilinestrings1.range(),
multilinestrings2.range(),
expected);
}
TYPED_TEST(LinestringIntersectionTest, ThreePairIdenticalInputsHasRing)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = typename linestring_intersection_result<T, std::size_t>::index_t;
using types_t = typename linestring_intersection_result<T, std::size_t>::types_t;
auto multilinestrings1 = make_multilinestring_array(
{0, 1, 2, 3},
{0, 2, 4, 6},
{P{0.0, 0.0}, P{1.0, 1.0}, P{0.0, 0.0}, P{1.0, 1.0}, P{0.0, 0.0}, P{1.0, 1.0}});
auto multilinestrings2 = make_multilinestring_array<T>({0, 1, 2, 3},
{0, 5, 10, 15},
{{0, 0},
{0, 1},
{1, 1},
{1, 0},
{0, 0},
{0, 0},
{0, 1},
{1, 1},
{1, 0},
{0, 0},
{0, 0},
{0, 1},
{1, 1},
{1, 0},
{0, 0}});
auto expected = make_linestring_intersection_result<T, index_t, types_t>({0, 2, 4, 6},
{0, 0, 0, 0, 0, 0},
{0, 1, 2, 3, 4, 5},
{
{0.0, 0.0},
{1.0, 1.0},
{0.0, 0.0},
{1.0, 1.0},
{0.0, 0.0},
{1.0, 1.0},
},
{},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 1, 0, 1, 0, 1},
this->stream(),
this->mr());
CUSPATIAL_RUN_TEST(this->template run_single_test<index_t>,
multilinestrings1.range(),
multilinestrings2.range(),
expected);
}
TYPED_TEST(LinestringIntersectionTest, ManyPairsIntegrated)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = typename linestring_intersection_result<T, std::size_t>::index_t;
using types_t = typename linestring_intersection_result<T, std::size_t>::types_t;
auto multilinestrings1 = make_multilinestring_array({0, 1, 2, 3, 4, 5, 6, 7},
{0, 2, 4, 6, 8, 10, 12, 14},
{P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1}});
auto multilinestrings2 = make_multilinestring_array(
{0, 1, 2, 3, 4, 5, 6, 7},
{0, 2, 5, 7, 12, 16, 18, 20},
{P{1, 0}, P{0, 1}, P{0.5, 0}, P{0, 0.5}, P{1, 0.5},
P{0.5, 0.5}, P{1.5, 1.5}, P{-1, -1}, P{0.25, 0.25}, P{0.25, 0.0},
P{0.75, 0.75}, P{1.5, 1.5}, P{0.25, 0.0}, P{0.25, 0.5}, P{0.75, 0.75},
P{1.5, 1.5}, P{2, 2}, P{3, 3}, P{1, 0}, P{2, 0}});
auto expected = make_linestring_intersection_result<T, index_t, types_t>(
{0, 1, 3, 4, 6, 8, 8, 8},
{0, 0, 0, 1, 1, 1, 0, 1},
{0, 1, 2, 0, 1, 2, 3, 3},
{P{0.5, 0.5}, P{0.25, 0.25}, P{0.5, 0.5}, P{0.25, 0.25}},
{segment<T>{P{0.5, 0.5}, P{1, 1}},
segment<T>{P{0, 0}, P{0.25, 0.25}},
segment<T>{P{0.75, 0.75}, P{1, 1}},
segment<T>{P{0.75, 0.75}, P{1, 1}}},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 0, 0, 3, 0, 2},
this->stream(),
this->mr());
CUSPATIAL_RUN_TEST(this->template run_single_test<index_t>,
multilinestrings1.range(),
multilinestrings2.range(),
expected);
}
TYPED_TEST(LinestringIntersectionTest, SignedIntegerInput)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = typename linestring_intersection_result<T, int32_t>::index_t;
using types_t = typename linestring_intersection_result<T, int32_t>::types_t;
auto multilinestrings1 = make_multilinestring_array({0, 1, 2, 3, 4, 5, 6, 7},
{0, 2, 4, 6, 8, 10, 12, 14},
{P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1}});
auto multilinestrings2 = make_multilinestring_array(
{0, 1, 2, 3, 4, 5, 6, 7},
{0, 2, 5, 7, 12, 16, 18, 20},
{P{1, 0}, P{0, 1}, P{0.5, 0}, P{0, 0.5}, P{1, 0.5},
P{0.5, 0.5}, P{1.5, 1.5}, P{-1, -1}, P{0.25, 0.25}, P{0.25, 0.0},
P{0.75, 0.75}, P{1.5, 1.5}, P{0.25, 0.0}, P{0.25, 0.5}, P{0.75, 0.75},
P{1.5, 1.5}, P{2, 2}, P{3, 3}, P{1, 0}, P{2, 0}});
auto expected = make_linestring_intersection_result<T, index_t, types_t>(
{0, 1, 3, 4, 6, 8, 8, 8},
{0, 0, 0, 1, 1, 1, 0, 1},
{0, 1, 2, 0, 1, 2, 3, 3},
{P{0.5, 0.5}, P{0.25, 0.25}, P{0.5, 0.5}, P{0.25, 0.25}},
{segment<T>{P{0.5, 0.5}, P{1, 1}},
segment<T>{P{0, 0}, P{0.25, 0.25}},
segment<T>{P{0.75, 0.75}, P{1, 1}},
segment<T>{P{0.75, 0.75}, P{1, 1}}},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 0, 0, 3, 0, 2},
this->stream(),
this->mr());
CUSPATIAL_RUN_TEST(this->template run_single_test<index_t>,
multilinestrings1.range(),
multilinestrings2.range(),
expected);
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/intersection/linestring_intersection_intermediates_remove_if_test.cu | /*
* 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 <cuspatial_test/vector_equality.hpp>
#include <cuspatial_test/vector_factories.cuh>
#include <cuspatial/detail/intersection/linestring_intersection_with_duplicates.cuh>
#include <cuspatial/error.hpp>
#include <cuspatial/geometry/vec_2d.hpp>
#include <cuspatial/iterator_factory.cuh>
#include <cuspatial/range/range.cuh>
#include <cuspatial/traits.hpp>
#include <rmm/device_vector.hpp>
#include <rmm/exec_policy.hpp>
#include <rmm/mr/device/per_device_resource.hpp>
#include <thrust/iterator/zip_iterator.h>
#include <initializer_list>
#include <type_traits>
using namespace cuspatial;
using namespace cuspatial::test;
template <typename IndexType, typename Geom>
auto make_linestring_intersection_intermediates(std::initializer_list<IndexType> offsets,
std::initializer_list<Geom> geoms,
std::initializer_list<IndexType> lhs_linestring_ids,
std::initializer_list<IndexType> lhs_segment_ids,
std::initializer_list<IndexType> rhs_linestring_ids,
std::initializer_list<IndexType> rhs_segment_ids,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto d_offset = make_device_uvector<IndexType>(offsets, stream, mr);
auto d_geoms = make_device_uvector<Geom>(geoms, stream, mr);
auto d_lhs_linestring_ids = make_device_uvector<IndexType>(lhs_linestring_ids, stream, mr);
auto d_lhs_segment_ids = make_device_uvector<IndexType>(lhs_segment_ids, stream, mr);
auto d_rhs_linestring_ids = make_device_uvector<IndexType>(rhs_linestring_ids, stream, mr);
auto d_rhs_segment_ids = make_device_uvector<IndexType>(rhs_segment_ids, stream, mr);
return linestring_intersection_intermediates<Geom, IndexType>{
std::make_unique<rmm::device_uvector<IndexType>>(d_offset, stream),
std::make_unique<rmm::device_uvector<Geom>>(d_geoms, stream),
std::make_unique<rmm::device_uvector<IndexType>>(d_lhs_linestring_ids, stream),
std::make_unique<rmm::device_uvector<IndexType>>(d_lhs_segment_ids, stream),
std::make_unique<rmm::device_uvector<IndexType>>(d_rhs_linestring_ids, stream),
std::make_unique<rmm::device_uvector<IndexType>>(d_rhs_segment_ids, stream),
};
}
template <typename T>
struct LinestringIntersectionIntermediatesRemoveIfTest : public ::testing::Test {
rmm::cuda_stream_view stream() { return rmm::cuda_stream_default; }
rmm::mr::device_memory_resource* mr() { return rmm::mr::get_current_device_resource(); }
template <typename FlagType, typename IntermediateType>
void run_single(IntermediateType& intermediates,
std::initializer_list<FlagType> flags,
IntermediateType const& expected)
{
using GeomType = typename IntermediateType::geometry_t;
auto d_flags = make_device_uvector<FlagType>(flags, this->stream(), this->mr());
intermediates.remove_if(range(d_flags.begin(), d_flags.end()), this->stream());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(*intermediates.offsets, *expected.offsets);
if constexpr (cuspatial::is_vec_2d<GeomType>)
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(*intermediates.geoms, *expected.geoms);
else
CUSPATIAL_EXPECT_VEC2D_PAIRS_EQUIVALENT(*intermediates.geoms, *expected.geoms);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(*intermediates.lhs_linestring_ids,
*expected.lhs_linestring_ids);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(*intermediates.lhs_segment_ids, *expected.lhs_segment_ids);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(*intermediates.rhs_linestring_ids,
*expected.rhs_linestring_ids);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(*intermediates.rhs_segment_ids, *expected.rhs_segment_ids);
}
};
// float and double are logically the same but would require separate tests due to precision.
using TestTypes = ::testing::Types<float, double>;
TYPED_TEST_CASE(LinestringIntersectionIntermediatesRemoveIfTest, TestTypes);
TYPED_TEST(LinestringIntersectionIntermediatesRemoveIfTest, EmptyInput)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = std::size_t;
using flag_t = uint8_t;
auto intermediates = make_linestring_intersection_intermediates<index_t, P>(
{0}, {}, {}, {}, {}, {}, this->stream(), this->mr());
auto expected = make_linestring_intersection_intermediates<index_t, P>(
{0}, {}, {}, {}, {}, {}, this->stream(), this->mr());
CUSPATIAL_RUN_TEST(this->template run_single<flag_t>, intermediates, {}, expected);
}
TYPED_TEST(LinestringIntersectionIntermediatesRemoveIfTest, OnePairOnePointNotRemoved)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = std::size_t;
using flag_t = uint8_t;
auto intermediates = make_linestring_intersection_intermediates<index_t, P>(
{0, 1}, {{0.5, 0.5}}, {0}, {0}, {0}, {0}, this->stream(), this->mr());
auto expected = make_linestring_intersection_intermediates<index_t, P>(
{0, 1}, {{0.5, 0.5}}, {0}, {0}, {0}, {0}, this->stream(), this->mr());
CUSPATIAL_RUN_TEST(this->template run_single<flag_t>, intermediates, {0}, expected);
}
TYPED_TEST(LinestringIntersectionIntermediatesRemoveIfTest, OnePairOnePointRemoved)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = std::size_t;
using flag_t = uint8_t;
auto intermediates = make_linestring_intersection_intermediates<index_t, P>(
{0, 1}, {{0.5, 0.5}}, {0}, {0}, {0}, {0}, this->stream(), this->mr());
auto expected = make_linestring_intersection_intermediates<index_t, P>(
{0, 0}, {}, {}, {}, {}, {}, this->stream(), this->mr());
CUSPATIAL_RUN_TEST(this->template run_single<flag_t>, intermediates, {1}, expected);
}
TYPED_TEST(LinestringIntersectionIntermediatesRemoveIfTest, SimplePoint)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = std::size_t;
using flag_t = uint8_t;
auto intermediates = make_linestring_intersection_intermediates<index_t, P>(
{0, 2, 4},
{{0.0, 0.0}, {1.0, 1.0}, {2.0, 2.0}, {3.0, 3.0}},
{0, 1, 2, 3},
{0, 1, 2, 3},
{0, 1, 2, 3},
{0, 1, 2, 3},
this->stream(),
this->mr());
auto expected = make_linestring_intersection_intermediates<index_t, P>({0, 1, 2},
{{0.0, 0.0}, {2.0, 2.0}},
{0, 2},
{0, 2},
{0, 2},
{0, 2},
this->stream(),
this->mr());
CUSPATIAL_RUN_TEST(this->template run_single<flag_t>, intermediates, {0, 1, 0, 1}, expected);
}
TYPED_TEST(LinestringIntersectionIntermediatesRemoveIfTest, SimplePoint2)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = std::size_t;
using flag_t = uint8_t;
auto intermediates = make_linestring_intersection_intermediates<index_t, P>(
{0, 2}, {{0.0, 0.5}, {0.5, 0.5}}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, this->stream(), this->mr());
auto expected = make_linestring_intersection_intermediates<index_t, P>(
{0, 1}, {{0.0, 0.5}}, {0}, {0}, {0}, {0}, this->stream(), this->mr());
CUSPATIAL_RUN_TEST(this->template run_single<flag_t>, intermediates, {0, 1}, expected);
}
TYPED_TEST(LinestringIntersectionIntermediatesRemoveIfTest, SimpleSegment1)
{
using T = TypeParam;
using S = segment<T>;
using index_t = std::size_t;
using flag_t = uint8_t;
auto intermediates = make_linestring_intersection_intermediates<index_t, S>(
{0, 2},
{S{{0.0, 0.5}, {0.5, 0.5}}, S{{0.0, 0.0}, {1.0, 1.0}}},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
this->stream(),
this->mr());
auto expected = make_linestring_intersection_intermediates<index_t, S>(
{0, 1}, {S{{0.0, 0.5}, {0.5, 0.5}}}, {0}, {0}, {0}, {0}, this->stream(), this->mr());
CUSPATIAL_RUN_TEST(this->template run_single<flag_t>, intermediates, {0, 1}, expected);
}
TYPED_TEST(LinestringIntersectionIntermediatesRemoveIfTest, SimpleSegment2)
{
using T = TypeParam;
using S = segment<T>;
using index_t = std::size_t;
using flag_t = uint8_t;
auto intermediates = make_linestring_intersection_intermediates<index_t, S>(
{0, 2},
{S{{0.0, 0.5}, {0.5, 0.5}}, S{{0.0, 0.0}, {1.0, 1.0}}},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
this->stream(),
this->mr());
auto expected = make_linestring_intersection_intermediates<index_t, S>(
{0, 0}, {}, {}, {}, {}, {}, this->stream(), this->mr());
CUSPATIAL_RUN_TEST(this->template run_single<flag_t>, intermediates, {1, 1}, expected);
}
TYPED_TEST(LinestringIntersectionIntermediatesRemoveIfTest, FourSegmentsKeep)
{
using T = TypeParam;
using S = segment<T>;
using index_t = std::size_t;
using flag_t = uint8_t;
auto intermediates =
make_linestring_intersection_intermediates<index_t, S>({0, 0, 0, 1, 3, 4, 4, 4},
{S{{0.5, 0.5}, {1, 1}},
S{{0, 0}, {0.25, 0.25}},
S{{0.75, 0.75}, {1, 1}},
S{{0.75, 0.75}, {1, 1}}},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 3, 2},
this->stream(),
this->mr());
auto expected = make_linestring_intersection_intermediates<index_t, S>({0, 0, 0, 1, 3, 4, 4, 4},
{S{{0.5, 0.5}, {1, 1}},
S{{0, 0}, {0.25, 0.25}},
S{{0.75, 0.75}, {1, 1}},
S{{0.75, 0.75}, {1, 1}}},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 3, 2},
this->stream(),
this->mr());
CUSPATIAL_RUN_TEST(this->template run_single<flag_t>, intermediates, {0, 0, 0, 0}, expected);
}
TYPED_TEST(LinestringIntersectionIntermediatesRemoveIfTest, FourSegmentsRemoveOne1)
{
using T = TypeParam;
using S = segment<T>;
using index_t = std::size_t;
using flag_t = uint8_t;
auto intermediates =
make_linestring_intersection_intermediates<index_t, S>({0, 0, 0, 1, 3, 4, 4, 4},
{S{{0.5, 0.5}, {1, 1}},
S{{0, 0}, {0.25, 0.25}},
S{{0.75, 0.75}, {1, 1}},
S{{0.75, 0.75}, {1, 1}}},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 3, 2},
this->stream(),
this->mr());
auto expected = make_linestring_intersection_intermediates<index_t, S>(
{0, 0, 0, 1, 2, 3, 3, 3},
{S{{0.5, 0.5}, {1, 1}}, S{{0.75, 0.75}, {1, 1}}, S{{0.75, 0.75}, {1, 1}}},
{0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{0, 3, 2},
this->stream(),
this->mr());
CUSPATIAL_RUN_TEST(this->template run_single<flag_t>, intermediates, {0, 1, 0, 0}, expected);
}
TYPED_TEST(LinestringIntersectionIntermediatesRemoveIfTest, FourSegmentsRemoveOne2)
{
using T = TypeParam;
using S = segment<T>;
using index_t = std::size_t;
using flag_t = uint8_t;
auto intermediates =
make_linestring_intersection_intermediates<index_t, S>({0, 0, 0, 1, 3, 4, 4, 4},
{S{{0.5, 0.5}, {1, 1}},
S{{0, 0}, {0.25, 0.25}},
S{{0.75, 0.75}, {1, 1}},
S{{0.75, 0.75}, {1, 1}}},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 3, 2},
this->stream(),
this->mr());
auto expected = make_linestring_intersection_intermediates<index_t, S>(
{0, 0, 0, 0, 2, 3, 3, 3},
{S{{0, 0}, {0.25, 0.25}}, S{{0.75, 0.75}, {1, 1}}, S{{0.75, 0.75}, {1, 1}}},
{0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{0, 3, 2},
this->stream(),
this->mr());
CUSPATIAL_RUN_TEST(this->template run_single<flag_t>, intermediates, {1, 0, 0, 0}, expected);
}
TYPED_TEST(LinestringIntersectionIntermediatesRemoveIfTest, FourSegmentsRemoveOne3)
{
using T = TypeParam;
using S = segment<T>;
using index_t = std::size_t;
using flag_t = uint8_t;
auto intermediates =
make_linestring_intersection_intermediates<index_t, S>({0, 0, 0, 1, 3, 4, 4, 4},
{S{{0.5, 0.5}, {1, 1}},
S{{0, 0}, {0.25, 0.25}},
S{{0.75, 0.75}, {1, 1}},
S{{0.75, 0.75}, {1, 1}}},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 3, 2},
this->stream(),
this->mr());
auto expected = make_linestring_intersection_intermediates<index_t, S>(
{0, 0, 0, 1, 3, 3, 3, 3},
{S{{0.5, 0.5}, {1, 1}}, S{{0, 0}, {0.25, 0.25}}, S{{0.75, 0.75}, {1, 1}}},
{0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{0, 0, 3},
this->stream(),
this->mr());
CUSPATIAL_RUN_TEST(this->template run_single<flag_t>, intermediates, {0, 0, 0, 1}, expected);
}
TYPED_TEST(LinestringIntersectionIntermediatesRemoveIfTest, FourSegmentsRemoveOne4)
{
using T = TypeParam;
using S = segment<T>;
using index_t = std::size_t;
using flag_t = uint8_t;
auto intermediates =
make_linestring_intersection_intermediates<index_t, S>({0, 0, 0, 1, 3, 4, 4, 4},
{S{{0.5, 0.5}, {1, 1}},
S{{0, 0}, {0.25, 0.25}},
S{{0.75, 0.75}, {1, 1}},
S{{0.75, 0.75}, {1, 1}}},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 3, 2},
this->stream(),
this->mr());
auto expected = make_linestring_intersection_intermediates<index_t, S>(
{0, 0, 0, 1, 2, 3, 3, 3},
{S{{0.5, 0.5}, {1, 1}}, S{{0, 0}, {0.25, 0.25}}, S{{0.75, 0.75}, {1, 1}}},
{0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{0, 0, 2},
this->stream(),
this->mr());
CUSPATIAL_RUN_TEST(this->template run_single<flag_t>, intermediates, {0, 0, 1, 0}, expected);
}
TYPED_TEST(LinestringIntersectionIntermediatesRemoveIfTest, FourSegmentsRemoveTwo1)
{
using T = TypeParam;
using S = segment<T>;
using index_t = std::size_t;
using flag_t = uint8_t;
auto intermediates =
make_linestring_intersection_intermediates<index_t, S>({0, 0, 0, 1, 3, 4, 4, 4},
{S{{0.5, 0.5}, {1, 1}},
S{{0, 0}, {0.25, 0.25}},
S{{0.75, 0.75}, {1, 1}},
S{{0.75, 0.75}, {1, 1}}},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 3, 2},
this->stream(),
this->mr());
auto expected = make_linestring_intersection_intermediates<index_t, S>(
{0, 0, 0, 1, 1, 2, 2, 2},
{S{{0.5, 0.5}, {1, 1}}, S{{0.75, 0.75}, {1, 1}}},
{0, 0},
{0, 0},
{0, 0},
{0, 2},
this->stream(),
this->mr());
CUSPATIAL_RUN_TEST(this->template run_single<flag_t>, intermediates, {0, 1, 1, 0}, expected);
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/intersection/linestring_intersection_large_test.cu | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/// Regression case found on V100-32GB machine.
#include "intersection_test_utils.cuh"
#include <cuspatial_test/base_fixture.hpp>
#include <cuspatial_test/test_util.cuh>
#include <cuspatial_test/vector_equality.hpp>
#include <cuspatial_test/vector_factories.cuh>
#include <cuspatial/geometry/segment.cuh>
#include <cuspatial/geometry/vec_2d.hpp>
#include <cuspatial/intersection.cuh>
#include <rmm/exec_policy.hpp>
#include <thrust/host_vector.h>
template <typename T>
struct LinestringIntersectionLargeTest : public cuspatial::test::BaseFixture {
using I = typename cuspatial::linestring_intersection_result<T, std::size_t>;
using index_t = typename I::index_t;
using types_t = typename I::types_t;
template <typename MultiLinestringRange>
void verify_legal_result(MultiLinestringRange lhs, MultiLinestringRange rhs)
{
auto unsorted =
cuspatial::pairwise_linestring_intersection<T, index_t>(lhs, rhs, this->mr(), this->stream());
// auto got = cuspatial::test::segment_sort_intersection_result<T, IndexType, types_t>(
// unsorted, this->mr(), this->stream());
// auto [points, segments] = cuspatial::pairwise_linestring_intersection_with_duplicates(lhs,
// rhs, this->mr(), this->stream);
auto num_points = unsorted.points_coords->size();
auto num_segments = unsorted.segments_coords->size();
auto h_types_buffer = cuspatial::test::to_host<types_t>(std::move(*unsorted.types_buffer));
auto h_offset_buffer = cuspatial::test::to_host<index_t>(std::move(*unsorted.offset_buffer));
for (std::size_t i = 0; i < h_types_buffer.size(); ++i) {
switch (h_types_buffer[i]) {
case static_cast<types_t>(cuspatial::IntersectionTypeCode::POINT):
// EXPECT_LT(h_offset_buffer[i], num_points);
if (h_offset_buffer[i] >= num_points) {
std::cout << "offset: " << h_offset_buffer[i] << " numpoints: " << num_points
<< " idx: " << i << std::endl;
FAIL();
}
break;
case static_cast<types_t>(cuspatial::IntersectionTypeCode::LINESTRING):
if (h_offset_buffer[i] >= num_segments) {
std::cout << "offset: " << h_offset_buffer[i] << " numsegments: " << num_segments
<< " idx: " << i << std::endl;
FAIL();
}
// EXPECT_LT(h_offset_buffer[i], num_segments);
break;
default:
FAIL() << "Unknown intersection type. idx: " << i
<< " type: " << static_cast<int>(h_types_buffer[i]);
}
}
}
};
// float and double are logically the same but would require separate tests due to precision.
using TestTypes = ::testing::Types<float, double>;
TYPED_TEST_CASE(LinestringIntersectionLargeTest, TestTypes);
TYPED_TEST(LinestringIntersectionLargeTest, LongInput)
{
using T = TypeParam;
using P = cuspatial::vec_2d<T>;
auto multilinestrings1 = cuspatial::test::make_multilinestring_array<T>(
{
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224,
225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254,
255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269,
270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299,
300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329,
330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359,
360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389,
390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419,
420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434,
435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449,
450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464,
465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479,
480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494,
495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509,
510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524,
525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539,
540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554,
555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569,
570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584,
585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599,
600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614,
615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629,
630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644,
645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659,
660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674,
675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 687, 688, 689,
690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704,
705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719,
720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734,
735, 736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749,
750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764,
765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779,
780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794,
795, 796, 797, 798, 799, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809,
810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824,
825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, 837, 838, 839,
840, 841, 842, 843, 844, 845, 846, 847, 848, 849, 850, 851, 852, 853, 854,
855, 856, 857, 858, 859, 860, 861, 862, 863, 864, 865, 866, 867, 868, 869,
870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 884,
885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 897, 898, 899,
900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914,
915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929,
930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944,
945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959,
960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974,
975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989,
990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004,
1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019,
1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034,
1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049,
1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064,
1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079,
1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094,
1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109,
1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124,
1125, 1126, 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1138, 1139,
1140, 1141, 1142, 1143, 1144, 1145, 1146, 1147, 1148, 1149, 1150, 1151, 1152, 1153, 1154,
1155, 1156, 1157, 1158, 1159, 1160, 1161, 1162, 1163, 1164, 1165, 1166, 1167, 1168, 1169,
1170, 1171, 1172, 1173, 1174, 1175, 1176, 1177, 1178, 1179, 1180, 1181, 1182, 1183, 1184,
1185, 1186, 1187, 1188, 1189, 1190, 1191, 1192, 1193, 1194, 1195, 1196, 1197, 1198, 1199,
1200, 1201, 1202, 1203, 1204, 1205, 1206, 1207, 1208, 1209, 1210, 1211, 1212, 1213, 1214,
1215, 1216, 1217, 1218, 1219, 1220, 1221, 1222, 1223, 1224, 1225, 1226, 1227, 1228, 1229,
1230, 1231, 1232, 1233, 1234, 1235, 1236, 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244,
1245, 1246, 1247, 1248, 1249, 1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258, 1259,
1260, 1261, 1262, 1263, 1264, 1265, 1266, 1267, 1268, 1269, 1270, 1271, 1272, 1273, 1274,
1275, 1276, 1277, 1278, 1279, 1280, 1281, 1282, 1283, 1284, 1285, 1286, 1287, 1288, 1289,
1290, 1291, 1292, 1293, 1294, 1295, 1296, 1297, 1298, 1299, 1300, 1301, 1302, 1303, 1304,
1305, 1306, 1307, 1308, 1309, 1310, 1311, 1312, 1313, 1314, 1315, 1316, 1317, 1318, 1319,
1320, 1321, 1322, 1323, 1324, 1325, 1326, 1327, 1328, 1329, 1330, 1331, 1332, 1333, 1334,
1335, 1336, 1337, 1338, 1339, 1340, 1341, 1342, 1343, 1344, 1345, 1346, 1347, 1348, 1349,
1350, 1351, 1352, 1353, 1354, 1355, 1356, 1357, 1358, 1359, 1360, 1361, 1362, 1363, 1364,
1365, 1366, 1367, 1368, 1369, 1370, 1371, 1372, 1373, 1374, 1375, 1376, 1377, 1378, 1379,
1380, 1381, 1382, 1383, 1384, 1385, 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394,
1395, 1396, 1397, 1398, 1399, 1400, 1401, 1402, 1403, 1404, 1405, 1406, 1407, 1408, 1409,
1410, 1411, 1412, 1413, 1414, 1415, 1416, 1417, 1418, 1419, 1420, 1421, 1422, 1423, 1424,
1425, 1426, 1427, 1428, 1429, 1430, 1431, 1432, 1433, 1434, 1435, 1436, 1437, 1438, 1439,
1440, 1441, 1442, 1443, 1444, 1445, 1446, 1447, 1448, 1449, 1450, 1451, 1452, 1453, 1454,
1455, 1456, 1457, 1458, 1459, 1460, 1461, 1462, 1463, 1464, 1465, 1466, 1467, 1468, 1469,
1470, 1471, 1472, 1473, 1474, 1475, 1476, 1477, 1478, 1479, 1480, 1481, 1482, 1483, 1484,
1485, 1486, 1487, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, 1497, 1498, 1499,
1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514,
1515, 1516, 1517, 1518, 1519, 1520, 1521, 1522, 1523, 1524, 1525, 1526, 1527, 1528, 1529,
1530, 1531, 1532, 1533, 1534, 1535, 1536, 1537, 1538, 1539, 1540, 1541, 1542, 1543, 1544,
1545, 1546, 1547, 1548, 1549, 1550, 1551, 1552, 1553, 1554, 1555, 1556, 1557, 1558, 1559,
1560, 1561, 1562, 1563, 1564, 1565, 1566, 1567, 1568, 1569, 1570, 1571, 1572, 1573, 1574,
1575, 1576, 1577, 1578, 1579, 1580, 1581, 1582, 1583, 1584, 1585, 1586, 1587, 1588, 1589,
1590, 1591, 1592, 1593, 1594, 1595, 1596, 1597, 1598, 1599, 1600, 1601, 1602, 1603, 1604,
1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1614, 1615, 1616, 1617, 1618, 1619,
1620, 1621, 1622, 1623, 1624, 1625, 1626, 1627, 1628, 1629, 1630, 1631, 1632, 1633, 1634,
1635, 1636, 1637, 1638, 1639, 1640, 1641, 1642, 1643, 1644, 1645, 1646, 1647, 1648, 1649,
1650, 1651, 1652, 1653, 1654, 1655, 1656, 1657, 1658, 1659, 1660, 1661, 1662, 1663, 1664,
1665, 1666, 1667, 1668, 1669, 1670, 1671, 1672, 1673, 1674, 1675, 1676, 1677, 1678, 1679,
1680, 1681, 1682, 1683, 1684, 1685, 1686, 1687, 1688, 1689, 1690, 1691, 1692, 1693, 1694,
1695, 1696, 1697, 1698, 1699, 1700, 1701, 1702, 1703, 1704, 1705, 1706, 1707, 1708, 1709,
1710, 1711, 1712, 1713, 1714, 1715, 1716, 1717, 1718, 1719, 1720, 1721, 1722, 1723, 1724,
1725, 1726, 1727, 1728, 1729, 1730, 1731, 1732, 1733, 1734, 1735, 1736, 1737, 1738, 1739,
1740, 1741, 1742, 1743, 1744, 1745, 1746, 1747, 1748, 1749, 1750, 1751, 1752, 1753, 1754,
1755, 1756, 1757, 1758, 1759, 1760, 1761, 1762, 1763, 1764, 1765, 1766, 1767, 1768, 1769,
1770, 1771, 1772, 1773, 1774, 1775, 1776, 1777, 1778, 1779, 1780, 1781, 1782, 1783, 1784,
1785, 1786, 1787, 1788, 1789, 1790, 1791, 1792, 1793, 1794, 1795, 1796, 1797, 1798, 1799,
1800, 1801, 1802, 1803, 1804, 1805, 1806, 1807, 1808, 1809, 1810, 1811, 1812, 1813, 1814,
1815, 1816, 1817, 1818, 1819, 1820, 1821, 1822, 1823, 1824, 1825, 1826, 1827, 1828, 1829,
1830, 1831, 1832, 1833, 1834, 1835, 1836, 1837, 1838, 1839, 1840, 1841, 1842, 1843, 1844,
1845, 1846, 1847, 1848, 1849, 1850, 1851, 1852, 1853, 1854, 1855, 1856, 1857, 1858, 1859,
1860, 1861, 1862, 1863, 1864, 1865, 1866, 1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874,
1875, 1876, 1877, 1878, 1879, 1880, 1881, 1882, 1883, 1884, 1885, 1886, 1887, 1888, 1889,
1890, 1891, 1892, 1893, 1894, 1895, 1896, 1897, 1898, 1899, 1900, 1901, 1902, 1903, 1904,
1905, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 1913, 1914, 1915, 1916, 1917, 1918, 1919,
1920, 1921, 1922, 1923, 1924, 1925, 1926, 1927, 1928, 1929, 1930, 1931, 1932, 1933, 1934,
1935, 1936, 1937, 1938, 1939, 1940, 1941, 1942, 1943, 1944, 1945, 1946, 1947, 1948, 1949,
1950, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964,
1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979,
1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024,
2025, 2026, 2027, 2028, 2029, 2030, 2031, 2032, 2033, 2034, 2035, 2036, 2037, 2038, 2039,
2040, 2041, 2042, 2043, 2044, 2045, 2046, 2047, 2048, 2049, 2050, 2051, 2052, 2053, 2054,
2055, 2056, 2057, 2058, 2059, 2060, 2061, 2062, 2063, 2064, 2065, 2066, 2067, 2068, 2069,
2070, 2071, 2072, 2073, 2074, 2075, 2076, 2077, 2078, 2079, 2080, 2081, 2082, 2083, 2084,
2085, 2086, 2087, 2088, 2089, 2090, 2091, 2092, 2093, 2094, 2095, 2096, 2097, 2098, 2099,
2100, 2101, 2102, 2103, 2104, 2105, 2106, 2107, 2108, 2109, 2110, 2111, 2112, 2113, 2114,
2115, 2116, 2117, 2118, 2119, 2120, 2121, 2122, 2123, 2124, 2125, 2126, 2127, 2128, 2129,
2130, 2131, 2132, 2133, 2134, 2135, 2136, 2137, 2138, 2139, 2140, 2141, 2142, 2143, 2144,
2145, 2146, 2147, 2148, 2149, 2150, 2151, 2152, 2153, 2154, 2155, 2156, 2157, 2158, 2159,
2160, 2161, 2162, 2163, 2164, 2165, 2166, 2167, 2168, 2169, 2170, 2171, 2172, 2173, 2174,
2175, 2176, 2177, 2178, 2179, 2180, 2181, 2182, 2183, 2184, 2185, 2186, 2187, 2188, 2189,
2190, 2191, 2192, 2193, 2194, 2195, 2196, 2197, 2198, 2199, 2200, 2201, 2202, 2203, 2204,
2205, 2206, 2207, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2216, 2217, 2218, 2219,
2220, 2221, 2222, 2223, 2224, 2225, 2226, 2227, 2228, 2229, 2230, 2231, 2232, 2233, 2234,
2235, 2236, 2237, 2238, 2239, 2240, 2241, 2242, 2243, 2244, 2245, 2246, 2247, 2248, 2249,
2250, 2251, 2252, 2253, 2254, 2255, 2256, 2257, 2258, 2259, 2260, 2261, 2262, 2263, 2264,
2265, 2266, 2267, 2268, 2269, 2270, 2271, 2272, 2273, 2274, 2275, 2276, 2277, 2278, 2279,
2280, 2281, 2282, 2283, 2284, 2285, 2286, 2287, 2288, 2289, 2290, 2291, 2292, 2293, 2294,
2295, 2296, 2297, 2298, 2299, 2300, 2301, 2302, 2303, 2304, 2305, 2306, 2307, 2308, 2309,
2310, 2311, 2312, 2313, 2314, 2315, 2316, 2317, 2318, 2319, 2320, 2321, 2322, 2323, 2324,
2325, 2326, 2327, 2328, 2329, 2330, 2331, 2332, 2333, 2334, 2335, 2336, 2337, 2338, 2339,
2340, 2341, 2342, 2343, 2344, 2345, 2346, 2347, 2348, 2349, 2350, 2351, 2352, 2353, 2354,
2355, 2356, 2357, 2358, 2359, 2360, 2361, 2362, 2363, 2364, 2365, 2366, 2367, 2368, 2369,
2370, 2371, 2372, 2373, 2374, 2375, 2376, 2377, 2378, 2379, 2380, 2381, 2382, 2383, 2384,
2385, 2386, 2387, 2388, 2389, 2390,
},
{
0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28,
30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88,
90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118,
120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148,
150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178,
180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208,
210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238,
240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268,
270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298,
300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328,
330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358,
360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388,
390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418,
420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 444, 446, 448,
450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478,
480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508,
510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538,
540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568,
570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598,
600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628,
630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658,
660, 662, 664, 666, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688,
690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718,
720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748,
750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778,
780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808,
810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838,
840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868,
870, 872, 874, 876, 878, 880, 882, 884, 886, 888, 890, 892, 894, 896, 898,
900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928,
930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958,
960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988,
990, 992, 994, 996, 998, 1000, 1002, 1004, 1006, 1008, 1010, 1012, 1014, 1016, 1018,
1020, 1022, 1024, 1026, 1028, 1030, 1032, 1034, 1036, 1038, 1040, 1042, 1044, 1046, 1048,
1050, 1052, 1054, 1056, 1058, 1060, 1062, 1064, 1066, 1068, 1070, 1072, 1074, 1076, 1078,
1080, 1082, 1084, 1086, 1088, 1090, 1092, 1094, 1096, 1098, 1100, 1102, 1104, 1106, 1108,
1110, 1112, 1114, 1116, 1118, 1120, 1122, 1124, 1126, 1128, 1130, 1132, 1134, 1136, 1138,
1140, 1142, 1144, 1146, 1148, 1150, 1152, 1154, 1156, 1158, 1160, 1162, 1164, 1166, 1168,
1170, 1172, 1174, 1176, 1178, 1180, 1182, 1184, 1186, 1188, 1190, 1192, 1194, 1196, 1198,
1200, 1202, 1204, 1206, 1208, 1210, 1212, 1214, 1216, 1218, 1220, 1222, 1224, 1226, 1228,
1230, 1232, 1234, 1236, 1238, 1240, 1242, 1244, 1246, 1248, 1250, 1252, 1254, 1256, 1258,
1260, 1262, 1264, 1266, 1268, 1270, 1272, 1274, 1276, 1278, 1280, 1282, 1284, 1286, 1288,
1290, 1292, 1294, 1296, 1298, 1300, 1302, 1304, 1306, 1308, 1310, 1312, 1314, 1316, 1318,
1320, 1322, 1324, 1326, 1328, 1330, 1332, 1334, 1336, 1338, 1340, 1342, 1344, 1346, 1348,
1350, 1352, 1354, 1356, 1358, 1360, 1362, 1364, 1366, 1368, 1370, 1372, 1374, 1376, 1378,
1380, 1382, 1384, 1386, 1388, 1390, 1392, 1394, 1396, 1398, 1400, 1402, 1404, 1406, 1408,
1410, 1412, 1414, 1416, 1418, 1420, 1422, 1424, 1426, 1428, 1430, 1432, 1434, 1436, 1438,
1440, 1442, 1444, 1446, 1448, 1450, 1452, 1454, 1456, 1458, 1460, 1462, 1464, 1466, 1468,
1470, 1472, 1474, 1476, 1478, 1480, 1482, 1484, 1486, 1488, 1490, 1492, 1494, 1496, 1498,
1500, 1502, 1504, 1506, 1508, 1510, 1512, 1514, 1516, 1518, 1520, 1522, 1524, 1526, 1528,
1530, 1532, 1534, 1536, 1538, 1540, 1542, 1544, 1546, 1548, 1550, 1552, 1554, 1556, 1558,
1560, 1562, 1564, 1566, 1568, 1570, 1572, 1574, 1576, 1578, 1580, 1582, 1584, 1586, 1588,
1590, 1592, 1594, 1596, 1598, 1600, 1602, 1604, 1606, 1608, 1610, 1612, 1614, 1616, 1618,
1620, 1622, 1624, 1626, 1628, 1630, 1632, 1634, 1636, 1638, 1640, 1642, 1644, 1646, 1648,
1650, 1652, 1654, 1656, 1658, 1660, 1662, 1664, 1666, 1668, 1670, 1672, 1674, 1676, 1678,
1680, 1682, 1684, 1686, 1688, 1690, 1692, 1694, 1696, 1698, 1700, 1702, 1704, 1706, 1708,
1710, 1712, 1714, 1716, 1718, 1720, 1722, 1724, 1726, 1728, 1730, 1732, 1734, 1736, 1738,
1740, 1742, 1744, 1746, 1748, 1750, 1752, 1754, 1756, 1758, 1760, 1762, 1764, 1766, 1768,
1770, 1772, 1774, 1776, 1778, 1780, 1782, 1784, 1786, 1788, 1790, 1792, 1794, 1796, 1798,
1800, 1802, 1804, 1806, 1808, 1810, 1812, 1814, 1816, 1818, 1820, 1822, 1824, 1826, 1828,
1830, 1832, 1834, 1836, 1838, 1840, 1842, 1844, 1846, 1848, 1850, 1852, 1854, 1856, 1858,
1860, 1862, 1864, 1866, 1868, 1870, 1872, 1874, 1876, 1878, 1880, 1882, 1884, 1886, 1888,
1890, 1892, 1894, 1896, 1898, 1900, 1902, 1904, 1906, 1908, 1910, 1912, 1914, 1916, 1918,
1920, 1922, 1924, 1926, 1928, 1930, 1932, 1934, 1936, 1938, 1940, 1942, 1944, 1946, 1948,
1950, 1952, 1954, 1956, 1958, 1960, 1962, 1964, 1966, 1968, 1970, 1972, 1974, 1976, 1978,
1980, 1982, 1984, 1986, 1988, 1990, 1992, 1994, 1996, 1998, 2000, 2002, 2004, 2006, 2008,
2010, 2012, 2014, 2016, 2018, 2020, 2022, 2024, 2026, 2028, 2030, 2032, 2034, 2036, 2038,
2040, 2042, 2044, 2046, 2048, 2050, 2052, 2054, 2056, 2058, 2060, 2062, 2064, 2066, 2068,
2070, 2072, 2074, 2076, 2078, 2080, 2082, 2084, 2086, 2088, 2090, 2092, 2094, 2096, 2098,
2100, 2102, 2104, 2106, 2108, 2110, 2112, 2114, 2116, 2118, 2120, 2122, 2124, 2126, 2128,
2130, 2132, 2134, 2136, 2138, 2140, 2142, 2144, 2146, 2148, 2150, 2152, 2154, 2156, 2158,
2160, 2162, 2164, 2166, 2168, 2170, 2172, 2174, 2176, 2178, 2180, 2182, 2184, 2186, 2188,
2190, 2192, 2194, 2196, 2198, 2200, 2202, 2204, 2206, 2208, 2210, 2212, 2214, 2216, 2218,
2220, 2222, 2224, 2226, 2228, 2230, 2232, 2234, 2236, 2238, 2240, 2242, 2244, 2246, 2248,
2250, 2252, 2254, 2256, 2258, 2260, 2262, 2264, 2266, 2268, 2270, 2272, 2274, 2276, 2278,
2280, 2282, 2284, 2286, 2288, 2290, 2292, 2294, 2296, 2298, 2300, 2302, 2304, 2306, 2308,
2310, 2312, 2314, 2316, 2318, 2320, 2322, 2324, 2326, 2328, 2330, 2332, 2334, 2336, 2338,
2340, 2342, 2344, 2346, 2348, 2350, 2352, 2354, 2356, 2358, 2360, 2362, 2364, 2366, 2368,
2370, 2372, 2374, 2376, 2378, 2380, 2382, 2384, 2386, 2388, 2390, 2392, 2394, 2396, 2398,
2400, 2402, 2404, 2406, 2408, 2410, 2412, 2414, 2416, 2418, 2420, 2422, 2424, 2426, 2428,
2430, 2432, 2434, 2436, 2438, 2440, 2442, 2444, 2446, 2448, 2450, 2452, 2454, 2456, 2458,
2460, 2462, 2464, 2466, 2468, 2470, 2472, 2474, 2476, 2478, 2480, 2482, 2484, 2486, 2488,
2490, 2492, 2494, 2496, 2498, 2500, 2502, 2504, 2506, 2508, 2510, 2512, 2514, 2516, 2518,
2520, 2522, 2524, 2526, 2528, 2530, 2532, 2534, 2536, 2538, 2540, 2542, 2544, 2546, 2548,
2550, 2552, 2554, 2556, 2558, 2560, 2562, 2564, 2566, 2568, 2570, 2572, 2574, 2576, 2578,
2580, 2582, 2584, 2586, 2588, 2590, 2592, 2594, 2596, 2598, 2600, 2602, 2604, 2606, 2608,
2610, 2612, 2614, 2616, 2618, 2620, 2622, 2624, 2626, 2628, 2630, 2632, 2634, 2636, 2638,
2640, 2642, 2644, 2646, 2648, 2650, 2652, 2654, 2656, 2658, 2660, 2662, 2664, 2666, 2668,
2670, 2672, 2674, 2676, 2678, 2680, 2682, 2684, 2686, 2688, 2690, 2692, 2694, 2696, 2698,
2700, 2702, 2704, 2706, 2708, 2710, 2712, 2714, 2716, 2718, 2720, 2722, 2724, 2726, 2728,
2730, 2732, 2734, 2736, 2738, 2740, 2742, 2744, 2746, 2748, 2750, 2752, 2754, 2756, 2758,
2760, 2762, 2764, 2766, 2768, 2770, 2772, 2774, 2776, 2778, 2780, 2782, 2784, 2786, 2788,
2790, 2792, 2794, 2796, 2798, 2800, 2802, 2804, 2806, 2808, 2810, 2812, 2814, 2816, 2818,
2820, 2822, 2824, 2826, 2828, 2830, 2832, 2834, 2836, 2838, 2840, 2842, 2844, 2846, 2848,
2850, 2852, 2854, 2856, 2858, 2860, 2862, 2864, 2866, 2868, 2870, 2872, 2874, 2876, 2878,
2880, 2882, 2884, 2886, 2888, 2890, 2892, 2894, 2896, 2898, 2900, 2902, 2904, 2906, 2908,
2910, 2912, 2914, 2916, 2918, 2920, 2922, 2924, 2926, 2928, 2930, 2932, 2934, 2936, 2938,
2940, 2942, 2944, 2946, 2948, 2950, 2952, 2954, 2956, 2958, 2960, 2962, 2964, 2966, 2968,
2970, 2972, 2974, 2976, 2978, 2980, 2982, 2984, 2986, 2988, 2990, 2992, 2994, 2996, 2998,
3000, 3002, 3004, 3006, 3008, 3010, 3012, 3014, 3016, 3018, 3020, 3022, 3024, 3026, 3028,
3030, 3032, 3034, 3036, 3038, 3040, 3042, 3044, 3046, 3048, 3050, 3052, 3054, 3056, 3058,
3060, 3062, 3064, 3066, 3068, 3070, 3072, 3074, 3076, 3078, 3080, 3082, 3084, 3086, 3088,
3090, 3092, 3094, 3096, 3098, 3100, 3102, 3104, 3106, 3108, 3110, 3112, 3114, 3116, 3118,
3120, 3122, 3124, 3126, 3128, 3130, 3132, 3134, 3136, 3138, 3140, 3142, 3144, 3146, 3148,
3150, 3152, 3154, 3156, 3158, 3160, 3162, 3164, 3166, 3168, 3170, 3172, 3174, 3176, 3178,
3180, 3182, 3184, 3186, 3188, 3190, 3192, 3194, 3196, 3198, 3200, 3202, 3204, 3206, 3208,
3210, 3212, 3214, 3216, 3218, 3220, 3222, 3224, 3226, 3228, 3230, 3232, 3234, 3236, 3238,
3240, 3242, 3244, 3246, 3248, 3250, 3252, 3254, 3256, 3258, 3260, 3262, 3264, 3266, 3268,
3270, 3272, 3274, 3276, 3278, 3280, 3282, 3284, 3286, 3288, 3290, 3292, 3294, 3296, 3298,
3300, 3302, 3304, 3306, 3308, 3310, 3312, 3314, 3316, 3318, 3320, 3322, 3324, 3326, 3328,
3330, 3332, 3334, 3336, 3338, 3340, 3342, 3344, 3346, 3348, 3350, 3352, 3354, 3356, 3358,
3360, 3362, 3364, 3366, 3368, 3370, 3372, 3374, 3376, 3378, 3380, 3382, 3384, 3386, 3388,
3390, 3392, 3394, 3396, 3398, 3400, 3402, 3404, 3406, 3408, 3410, 3412, 3414, 3416, 3418,
3420, 3422, 3424, 3426, 3428, 3430, 3432, 3434, 3436, 3438, 3440, 3442, 3444, 3446, 3448,
3450, 3452, 3454, 3456, 3458, 3460, 3462, 3464, 3466, 3468, 3470, 3472, 3474, 3476, 3478,
3480, 3482, 3484, 3486, 3488, 3490, 3492, 3494, 3496, 3498, 3500, 3502, 3504, 3506, 3508,
3510, 3512, 3514, 3516, 3518, 3520, 3522, 3524, 3526, 3528, 3530, 3532, 3534, 3536, 3538,
3540, 3542, 3544, 3546, 3548, 3550, 3552, 3554, 3556, 3558, 3560, 3562, 3564, 3566, 3568,
3570, 3572, 3574, 3576, 3578, 3580, 3582, 3584, 3586, 3588, 3590, 3592, 3594, 3596, 3598,
3600, 3602, 3604, 3606, 3608, 3610, 3612, 3614, 3616, 3618, 3620, 3622, 3624, 3626, 3628,
3630, 3632, 3634, 3636, 3638, 3640, 3642, 3644, 3646, 3648, 3650, 3652, 3654, 3656, 3658,
3660, 3662, 3664, 3666, 3668, 3670, 3672, 3674, 3676, 3678, 3680, 3682, 3684, 3686, 3688,
3690, 3692, 3694, 3696, 3698, 3700, 3702, 3704, 3706, 3708, 3710, 3712, 3714, 3716, 3718,
3720, 3722, 3724, 3726, 3728, 3730, 3732, 3734, 3736, 3738, 3740, 3742, 3744, 3746, 3748,
3750, 3752, 3754, 3756, 3758, 3760, 3762, 3764, 3766, 3768, 3770, 3772, 3774, 3776, 3778,
3780, 3782, 3784, 3786, 3788, 3790, 3792, 3794, 3796, 3798, 3800, 3802, 3804, 3806, 3808,
3810, 3812, 3814, 3816, 3818, 3820, 3822, 3824, 3826, 3828, 3830, 3832, 3834, 3836, 3838,
3840, 3842, 3844, 3846, 3848, 3850, 3852, 3854, 3856, 3858, 3860, 3862, 3864, 3866, 3868,
3870, 3872, 3874, 3876, 3878, 3880, 3882, 3884, 3886, 3888, 3890, 3892, 3894, 3896, 3898,
3900, 3902, 3904, 3906, 3908, 3910, 3912, 3914, 3916, 3918, 3920, 3922, 3924, 3926, 3928,
3930, 3932, 3934, 3936, 3938, 3940, 3942, 3944, 3946, 3948, 3950, 3952, 3954, 3956, 3958,
3960, 3962, 3964, 3966, 3968, 3970, 3972, 3974, 3976, 3978, 3980, 3982, 3984, 3986, 3988,
3990, 3992, 3994, 3996, 3998, 4000, 4002, 4004, 4006, 4008, 4010, 4012, 4014, 4016, 4018,
4020, 4022, 4024, 4026, 4028, 4030, 4032, 4034, 4036, 4038, 4040, 4042, 4044, 4046, 4048,
4050, 4052, 4054, 4056, 4058, 4060, 4062, 4064, 4066, 4068, 4070, 4072, 4074, 4076, 4078,
4080, 4082, 4084, 4086, 4088, 4090, 4092, 4094, 4096, 4098, 4100, 4102, 4104, 4106, 4108,
4110, 4112, 4114, 4116, 4118, 4120, 4122, 4124, 4126, 4128, 4130, 4132, 4134, 4136, 4138,
4140, 4142, 4144, 4146, 4148, 4150, 4152, 4154, 4156, 4158, 4160, 4162, 4164, 4166, 4168,
4170, 4172, 4174, 4176, 4178, 4180, 4182, 4184, 4186, 4188, 4190, 4192, 4194, 4196, 4198,
4200, 4202, 4204, 4206, 4208, 4210, 4212, 4214, 4216, 4218, 4220, 4222, 4224, 4226, 4228,
4230, 4232, 4234, 4236, 4238, 4240, 4242, 4244, 4246, 4248, 4250, 4252, 4254, 4256, 4258,
4260, 4262, 4264, 4266, 4268, 4270, 4272, 4274, 4276, 4278, 4280, 4282, 4284, 4286, 4288,
4290, 4292, 4294, 4296, 4298, 4300, 4302, 4304, 4306, 4308, 4310, 4312, 4314, 4316, 4318,
4320, 4322, 4324, 4326, 4328, 4330, 4332, 4334, 4336, 4338, 4340, 4342, 4344, 4346, 4348,
4350, 4352, 4354, 4356, 4358, 4360, 4362, 4364, 4366, 4368, 4370, 4372, 4374, 4376, 4378,
4380, 4382, 4384, 4386, 4388, 4390, 4392, 4394, 4396, 4398, 4400, 4402, 4404, 4406, 4408,
4410, 4412, 4414, 4416, 4418, 4420, 4422, 4424, 4426, 4428, 4430, 4432, 4434, 4436, 4438,
4440, 4442, 4444, 4446, 4448, 4450, 4452, 4454, 4456, 4458, 4460, 4462, 4464, 4466, 4468,
4470, 4472, 4474, 4476, 4478, 4480, 4482, 4484, 4486, 4488, 4490, 4492, 4494, 4496, 4498,
4500, 4502, 4504, 4506, 4508, 4510, 4512, 4514, 4516, 4518, 4520, 4522, 4524, 4526, 4528,
4530, 4532, 4534, 4536, 4538, 4540, 4542, 4544, 4546, 4548, 4550, 4552, 4554, 4556, 4558,
4560, 4562, 4564, 4566, 4568, 4570, 4572, 4574, 4576, 4578, 4580, 4582, 4584, 4586, 4588,
4590, 4592, 4594, 4596, 4598, 4600, 4602, 4604, 4606, 4608, 4610, 4612, 4614, 4616, 4618,
4620, 4622, 4624, 4626, 4628, 4630, 4632, 4634, 4636, 4638, 4640, 4642, 4644, 4646, 4648,
4650, 4652, 4654, 4656, 4658, 4660, 4662, 4664, 4666, 4668, 4670, 4672, 4674, 4676, 4678,
4680, 4682, 4684, 4686, 4688, 4690, 4692, 4694, 4696, 4698, 4700, 4702, 4704, 4706, 4708,
4710, 4712, 4714, 4716, 4718, 4720, 4722, 4724, 4726, 4728, 4730, 4732, 4734, 4736, 4738,
4740, 4742, 4744, 4746, 4748, 4750, 4752, 4754, 4756, 4758, 4760, 4762, 4764, 4766, 4768,
4770, 4772, 4774, 4776, 4778, 4780,
},
{
{0.0, 0.0}, {0.0, 1.0}, {0.5, 0.0}, {0.5, 1.0}, {0.0, 0.0}, {1.0, 0.0}, {0.0, 0.0},
{1.0, 0.0}, {0.0, 0.0}, {0.0, 1.0}, {0.5, 0.0}, {0.5, 1.0}, {0.0, 0.0}, {1.0, 0.0},
{0.0, 0.0}, {0.0, 1.0}, {0.0, 0.0}, {1.0, 0.0}, {0.0, 0.0}, {1.0, 0.0}, {0.5, 0.0},
{0.5, 1.0}, {0.0, 0.0}, {1.0, 0.0}, {0.0, 0.0}, {1.0, 0.0}, {0.0, 0.0}, {1.0, 0.0},
{0.0, 0.0}, {1.0, 0.0}, {0.0, 0.0}, {1.0, 0.0}, {0.5, 0.0}, {0.5, 1.0}, {0.0, 0.0},
{1.0, 0.0}, {0.0, 0.0}, {1.0, 0.0}, {0.0, 0.0}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 0.0}, {0.5, 0.0}, {0.5, 1.0}, {0.5, 0.0},
{0.5, 1.0}, {0.5, 0.0}, {0.5, 1.0}, {0.5, 0.0}, {0.5, 1.0}, {0.0, 0.0}, {1.0, 0.0},
{0.5, 0.0}, {0.5, 1.0}, {0.0, 0.0}, {0.0, 1.0}, {0.5, 0.0}, {0.5, 1.0}, {0.0, 0.0},
{1.0, 0.0}, {0.0, 0.0}, {0.0, 1.0}, {0.0, 0.0}, {1.0, 0.0}, {0.0, 0.0}, {0.0, 1.0},
{0.0, 0.0}, {0.0, 1.0}, {0.5, 0.0}, {0.5, 1.0}, {0.0, 0.0}, {1.0, 0.0}, {0.5, 0.0},
{0.5, 1.0}, {0.0, 0.0}, {0.0, 1.0}, {0.5, 0.0}, {0.5, 1.0}, {0.0, 0.0}, {1.0, 0.0},
{0.0, 0.0}, {1.0, 0.0}, {0.0, 0.0}, {1.0, 0.0}, {0.0, 0.0}, {1.0, 0.0}, {0.5, 0.0},
{0.5, 1.0}, {0.0, 0.0}, {1.0, 0.0}, {0.5, 0.0}, {0.5, 1.0}, {0.0, 0.0}, {1.0, 0.0},
{0.0, 0.0}, {1.0, 0.0}, {0.0, 0.0}, {1.0, 0.0}, {0.5, 0.0}, {0.5, 1.0}, {0.0, 0.0},
{0.0, 1.0}, {0.0, 0.0}, {1.0, 0.0}, {0.5, 0.0}, {0.5, 1.0}, {0.0, 0.0}, {0.0, 1.0},
{0.5, 0.0}, {0.5, 1.0}, {0.0, 0.0}, {1.0, 0.0}, {0.0, 0.0}, {1.0, 0.0}, {0.5, 0.0},
{0.5, 1.0}, {0.0, 0.0}, {1.0, 0.0}, {0.0, 0.0}, {1.0, 0.0}, {0.5, 0.0}, {0.5, 1.0},
{0.0, 0.0}, {1.0, 0.0}, {0.0, 0.0}, {0.0, 1.0}, {0.0, 0.0}, {1.0, 0.0},
});
auto multilinestrings2 = cuspatial::test::make_multilinestring_array<T>(
{
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224,
225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254,
255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269,
270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299,
300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329,
330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359,
360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389,
390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419,
420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434,
435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449,
450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464,
465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479,
480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494,
495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509,
510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524,
525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539,
540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554,
555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569,
570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584,
585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599,
600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614,
615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629,
630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644,
645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659,
660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674,
675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 687, 688, 689,
690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704,
705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719,
720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734,
735, 736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749,
750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764,
765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779,
780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794,
795, 796, 797, 798, 799, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809,
810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824,
825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, 837, 838, 839,
840, 841, 842, 843, 844, 845, 846, 847, 848, 849, 850, 851, 852, 853, 854,
855, 856, 857, 858, 859, 860, 861, 862, 863, 864, 865, 866, 867, 868, 869,
870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 884,
885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 897, 898, 899,
900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914,
915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929,
930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944,
945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959,
960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974,
975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989,
990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004,
1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019,
1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034,
1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049,
1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064,
1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079,
1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094,
1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109,
1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124,
1125, 1126, 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1138, 1139,
1140, 1141, 1142, 1143, 1144, 1145, 1146, 1147, 1148, 1149, 1150, 1151, 1152, 1153, 1154,
1155, 1156, 1157, 1158, 1159, 1160, 1161, 1162, 1163, 1164, 1165, 1166, 1167, 1168, 1169,
1170, 1171, 1172, 1173, 1174, 1175, 1176, 1177, 1178, 1179, 1180, 1181, 1182, 1183, 1184,
1185, 1186, 1187, 1188, 1189, 1190, 1191, 1192, 1193, 1194, 1195, 1196, 1197, 1198, 1199,
1200, 1201, 1202, 1203, 1204, 1205, 1206, 1207, 1208, 1209, 1210, 1211, 1212, 1213, 1214,
1215, 1216, 1217, 1218, 1219, 1220, 1221, 1222, 1223, 1224, 1225, 1226, 1227, 1228, 1229,
1230, 1231, 1232, 1233, 1234, 1235, 1236, 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244,
1245, 1246, 1247, 1248, 1249, 1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258, 1259,
1260, 1261, 1262, 1263, 1264, 1265, 1266, 1267, 1268, 1269, 1270, 1271, 1272, 1273, 1274,
1275, 1276, 1277, 1278, 1279, 1280, 1281, 1282, 1283, 1284, 1285, 1286, 1287, 1288, 1289,
1290, 1291, 1292, 1293, 1294, 1295, 1296, 1297, 1298, 1299, 1300, 1301, 1302, 1303, 1304,
1305, 1306, 1307, 1308, 1309, 1310, 1311, 1312, 1313, 1314, 1315, 1316, 1317, 1318, 1319,
1320, 1321, 1322, 1323, 1324, 1325, 1326, 1327, 1328, 1329, 1330, 1331, 1332, 1333, 1334,
1335, 1336, 1337, 1338, 1339, 1340, 1341, 1342, 1343, 1344, 1345, 1346, 1347, 1348, 1349,
1350, 1351, 1352, 1353, 1354, 1355, 1356, 1357, 1358, 1359, 1360, 1361, 1362, 1363, 1364,
1365, 1366, 1367, 1368, 1369, 1370, 1371, 1372, 1373, 1374, 1375, 1376, 1377, 1378, 1379,
1380, 1381, 1382, 1383, 1384, 1385, 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394,
1395, 1396, 1397, 1398, 1399, 1400, 1401, 1402, 1403, 1404, 1405, 1406, 1407, 1408, 1409,
1410, 1411, 1412, 1413, 1414, 1415, 1416, 1417, 1418, 1419, 1420, 1421, 1422, 1423, 1424,
1425, 1426, 1427, 1428, 1429, 1430, 1431, 1432, 1433, 1434, 1435, 1436, 1437, 1438, 1439,
1440, 1441, 1442, 1443, 1444, 1445, 1446, 1447, 1448, 1449, 1450, 1451, 1452, 1453, 1454,
1455, 1456, 1457, 1458, 1459, 1460, 1461, 1462, 1463, 1464, 1465, 1466, 1467, 1468, 1469,
1470, 1471, 1472, 1473, 1474, 1475, 1476, 1477, 1478, 1479, 1480, 1481, 1482, 1483, 1484,
1485, 1486, 1487, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, 1497, 1498, 1499,
1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514,
1515, 1516, 1517, 1518, 1519, 1520, 1521, 1522, 1523, 1524, 1525, 1526, 1527, 1528, 1529,
1530, 1531, 1532, 1533, 1534, 1535, 1536, 1537, 1538, 1539, 1540, 1541, 1542, 1543, 1544,
1545, 1546, 1547, 1548, 1549, 1550, 1551, 1552, 1553, 1554, 1555, 1556, 1557, 1558, 1559,
1560, 1561, 1562, 1563, 1564, 1565, 1566, 1567, 1568, 1569, 1570, 1571, 1572, 1573, 1574,
1575, 1576, 1577, 1578, 1579, 1580, 1581, 1582, 1583, 1584, 1585, 1586, 1587, 1588, 1589,
1590, 1591, 1592, 1593, 1594, 1595, 1596, 1597, 1598, 1599, 1600, 1601, 1602, 1603, 1604,
1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1614, 1615, 1616, 1617, 1618, 1619,
1620, 1621, 1622, 1623, 1624, 1625, 1626, 1627, 1628, 1629, 1630, 1631, 1632, 1633, 1634,
1635, 1636, 1637, 1638, 1639, 1640, 1641, 1642, 1643, 1644, 1645, 1646, 1647, 1648, 1649,
1650, 1651, 1652, 1653, 1654, 1655, 1656, 1657, 1658, 1659, 1660, 1661, 1662, 1663, 1664,
1665, 1666, 1667, 1668, 1669, 1670, 1671, 1672, 1673, 1674, 1675, 1676, 1677, 1678, 1679,
1680, 1681, 1682, 1683, 1684, 1685, 1686, 1687, 1688, 1689, 1690, 1691, 1692, 1693, 1694,
1695, 1696, 1697, 1698, 1699, 1700, 1701, 1702, 1703, 1704, 1705, 1706, 1707, 1708, 1709,
1710, 1711, 1712, 1713, 1714, 1715, 1716, 1717, 1718, 1719, 1720, 1721, 1722, 1723, 1724,
1725, 1726, 1727, 1728, 1729, 1730, 1731, 1732, 1733, 1734, 1735, 1736, 1737, 1738, 1739,
1740, 1741, 1742, 1743, 1744, 1745, 1746, 1747, 1748, 1749, 1750, 1751, 1752, 1753, 1754,
1755, 1756, 1757, 1758, 1759, 1760, 1761, 1762, 1763, 1764, 1765, 1766, 1767, 1768, 1769,
1770, 1771, 1772, 1773, 1774, 1775, 1776, 1777, 1778, 1779, 1780, 1781, 1782, 1783, 1784,
1785, 1786, 1787, 1788, 1789, 1790, 1791, 1792, 1793, 1794, 1795, 1796, 1797, 1798, 1799,
1800, 1801, 1802, 1803, 1804, 1805, 1806, 1807, 1808, 1809, 1810, 1811, 1812, 1813, 1814,
1815, 1816, 1817, 1818, 1819, 1820, 1821, 1822, 1823, 1824, 1825, 1826, 1827, 1828, 1829,
1830, 1831, 1832, 1833, 1834, 1835, 1836, 1837, 1838, 1839, 1840, 1841, 1842, 1843, 1844,
1845, 1846, 1847, 1848, 1849, 1850, 1851, 1852, 1853, 1854, 1855, 1856, 1857, 1858, 1859,
1860, 1861, 1862, 1863, 1864, 1865, 1866, 1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874,
1875, 1876, 1877, 1878, 1879, 1880, 1881, 1882, 1883, 1884, 1885, 1886, 1887, 1888, 1889,
1890, 1891, 1892, 1893, 1894, 1895, 1896, 1897, 1898, 1899, 1900, 1901, 1902, 1903, 1904,
1905, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 1913, 1914, 1915, 1916, 1917, 1918, 1919,
1920, 1921, 1922, 1923, 1924, 1925, 1926, 1927, 1928, 1929, 1930, 1931, 1932, 1933, 1934,
1935, 1936, 1937, 1938, 1939, 1940, 1941, 1942, 1943, 1944, 1945, 1946, 1947, 1948, 1949,
1950, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964,
1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979,
1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024,
2025, 2026, 2027, 2028, 2029, 2030, 2031, 2032, 2033, 2034, 2035, 2036, 2037, 2038, 2039,
2040, 2041, 2042, 2043, 2044, 2045, 2046, 2047, 2048, 2049, 2050, 2051, 2052, 2053, 2054,
2055, 2056, 2057, 2058, 2059, 2060, 2061, 2062, 2063, 2064, 2065, 2066, 2067, 2068, 2069,
2070, 2071, 2072, 2073, 2074, 2075, 2076, 2077, 2078, 2079, 2080, 2081, 2082, 2083, 2084,
2085, 2086, 2087, 2088, 2089, 2090, 2091, 2092, 2093, 2094, 2095, 2096, 2097, 2098, 2099,
2100, 2101, 2102, 2103, 2104, 2105, 2106, 2107, 2108, 2109, 2110, 2111, 2112, 2113, 2114,
2115, 2116, 2117, 2118, 2119, 2120, 2121, 2122, 2123, 2124, 2125, 2126, 2127, 2128, 2129,
2130, 2131, 2132, 2133, 2134, 2135, 2136, 2137, 2138, 2139, 2140, 2141, 2142, 2143, 2144,
2145, 2146, 2147, 2148, 2149, 2150, 2151, 2152, 2153, 2154, 2155, 2156, 2157, 2158, 2159,
2160, 2161, 2162, 2163, 2164, 2165, 2166, 2167, 2168, 2169, 2170, 2171, 2172, 2173, 2174,
2175, 2176, 2177, 2178, 2179, 2180, 2181, 2182, 2183, 2184, 2185, 2186, 2187, 2188, 2189,
2190, 2191, 2192, 2193, 2194, 2195, 2196, 2197, 2198, 2199, 2200, 2201, 2202, 2203, 2204,
2205, 2206, 2207, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2216, 2217, 2218, 2219,
2220, 2221, 2222, 2223, 2224, 2225, 2226, 2227, 2228, 2229, 2230, 2231, 2232, 2233, 2234,
2235, 2236, 2237, 2238, 2239, 2240, 2241, 2242, 2243, 2244, 2245, 2246, 2247, 2248, 2249,
2250, 2251, 2252, 2253, 2254, 2255, 2256, 2257, 2258, 2259, 2260, 2261, 2262, 2263, 2264,
2265, 2266, 2267, 2268, 2269, 2270, 2271, 2272, 2273, 2274, 2275, 2276, 2277, 2278, 2279,
2280, 2281, 2282, 2283, 2284, 2285, 2286, 2287, 2288, 2289, 2290, 2291, 2292, 2293, 2294,
2295, 2296, 2297, 2298, 2299, 2300, 2301, 2302, 2303, 2304, 2305, 2306, 2307, 2308, 2309,
2310, 2311, 2312, 2313, 2314, 2315, 2316, 2317, 2318, 2319, 2320, 2321, 2322, 2323, 2324,
2325, 2326, 2327, 2328, 2329, 2330, 2331, 2332, 2333, 2334, 2335, 2336, 2337, 2338, 2339,
2340, 2341, 2342, 2343, 2344, 2345, 2346, 2347, 2348, 2349, 2350, 2351, 2352, 2353, 2354,
2355, 2356, 2357, 2358, 2359, 2360, 2361, 2362, 2363, 2364, 2365, 2366, 2367, 2368, 2369,
2370, 2371, 2372, 2373, 2374, 2375, 2376, 2377, 2378, 2379, 2380, 2381, 2382, 2383, 2384,
2385, 2386, 2387, 2388, 2389, 2390,
},
{
0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28,
30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88,
90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118,
120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148,
150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178,
180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208,
210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238,
240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268,
270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298,
300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328,
330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358,
360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388,
390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418,
420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 444, 446, 448,
450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478,
480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508,
510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538,
540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568,
570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598,
600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628,
630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658,
660, 662, 664, 666, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688,
690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718,
720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748,
750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778,
780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808,
810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838,
840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868,
870, 872, 874, 876, 878, 880, 882, 884, 886, 888, 890, 892, 894, 896, 898,
900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928,
930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958,
960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988,
990, 992, 994, 996, 998, 1000, 1002, 1004, 1006, 1008, 1010, 1012, 1014, 1016, 1018,
1020, 1022, 1024, 1026, 1028, 1030, 1032, 1034, 1036, 1038, 1040, 1042, 1044, 1046, 1048,
1050, 1052, 1054, 1056, 1058, 1060, 1062, 1064, 1066, 1068, 1070, 1072, 1074, 1076, 1078,
1080, 1082, 1084, 1086, 1088, 1090, 1092, 1094, 1096, 1098, 1100, 1102, 1104, 1106, 1108,
1110, 1112, 1114, 1116, 1118, 1120, 1122, 1124, 1126, 1128, 1130, 1132, 1134, 1136, 1138,
1140, 1142, 1144, 1146, 1148, 1150, 1152, 1154, 1156, 1158, 1160, 1162, 1164, 1166, 1168,
1170, 1172, 1174, 1176, 1178, 1180, 1182, 1184, 1186, 1188, 1190, 1192, 1194, 1196, 1198,
1200, 1202, 1204, 1206, 1208, 1210, 1212, 1214, 1216, 1218, 1220, 1222, 1224, 1226, 1228,
1230, 1232, 1234, 1236, 1238, 1240, 1242, 1244, 1246, 1248, 1250, 1252, 1254, 1256, 1258,
1260, 1262, 1264, 1266, 1268, 1270, 1272, 1274, 1276, 1278, 1280, 1282, 1284, 1286, 1288,
1290, 1292, 1294, 1296, 1298, 1300, 1302, 1304, 1306, 1308, 1310, 1312, 1314, 1316, 1318,
1320, 1322, 1324, 1326, 1328, 1330, 1332, 1334, 1336, 1338, 1340, 1342, 1344, 1346, 1348,
1350, 1352, 1354, 1356, 1358, 1360, 1362, 1364, 1366, 1368, 1370, 1372, 1374, 1376, 1378,
1380, 1382, 1384, 1386, 1388, 1390, 1392, 1394, 1396, 1398, 1400, 1402, 1404, 1406, 1408,
1410, 1412, 1414, 1416, 1418, 1420, 1422, 1424, 1426, 1428, 1430, 1432, 1434, 1436, 1438,
1440, 1442, 1444, 1446, 1448, 1450, 1452, 1454, 1456, 1458, 1460, 1462, 1464, 1466, 1468,
1470, 1472, 1474, 1476, 1478, 1480, 1482, 1484, 1486, 1488, 1490, 1492, 1494, 1496, 1498,
1500, 1502, 1504, 1506, 1508, 1510, 1512, 1514, 1516, 1518, 1520, 1522, 1524, 1526, 1528,
1530, 1532, 1534, 1536, 1538, 1540, 1542, 1544, 1546, 1548, 1550, 1552, 1554, 1556, 1558,
1560, 1562, 1564, 1566, 1568, 1570, 1572, 1574, 1576, 1578, 1580, 1582, 1584, 1586, 1588,
1590, 1592, 1594, 1596, 1598, 1600, 1602, 1604, 1606, 1608, 1610, 1612, 1614, 1616, 1618,
1620, 1622, 1624, 1626, 1628, 1630, 1632, 1634, 1636, 1638, 1640, 1642, 1644, 1646, 1648,
1650, 1652, 1654, 1656, 1658, 1660, 1662, 1664, 1666, 1668, 1670, 1672, 1674, 1676, 1678,
1680, 1682, 1684, 1686, 1688, 1690, 1692, 1694, 1696, 1698, 1700, 1702, 1704, 1706, 1708,
1710, 1712, 1714, 1716, 1718, 1720, 1722, 1724, 1726, 1728, 1730, 1732, 1734, 1736, 1738,
1740, 1742, 1744, 1746, 1748, 1750, 1752, 1754, 1756, 1758, 1760, 1762, 1764, 1766, 1768,
1770, 1772, 1774, 1776, 1778, 1780, 1782, 1784, 1786, 1788, 1790, 1792, 1794, 1796, 1798,
1800, 1802, 1804, 1806, 1808, 1810, 1812, 1814, 1816, 1818, 1820, 1822, 1824, 1826, 1828,
1830, 1832, 1834, 1836, 1838, 1840, 1842, 1844, 1846, 1848, 1850, 1852, 1854, 1856, 1858,
1860, 1862, 1864, 1866, 1868, 1870, 1872, 1874, 1876, 1878, 1880, 1882, 1884, 1886, 1888,
1890, 1892, 1894, 1896, 1898, 1900, 1902, 1904, 1906, 1908, 1910, 1912, 1914, 1916, 1918,
1920, 1922, 1924, 1926, 1928, 1930, 1932, 1934, 1936, 1938, 1940, 1942, 1944, 1946, 1948,
1950, 1952, 1954, 1956, 1958, 1960, 1962, 1964, 1966, 1968, 1970, 1972, 1974, 1976, 1978,
1980, 1982, 1984, 1986, 1988, 1990, 1992, 1994, 1996, 1998, 2000, 2002, 2004, 2006, 2008,
2010, 2012, 2014, 2016, 2018, 2020, 2022, 2024, 2026, 2028, 2030, 2032, 2034, 2036, 2038,
2040, 2042, 2044, 2046, 2048, 2050, 2052, 2054, 2056, 2058, 2060, 2062, 2064, 2066, 2068,
2070, 2072, 2074, 2076, 2078, 2080, 2082, 2084, 2086, 2088, 2090, 2092, 2094, 2096, 2098,
2100, 2102, 2104, 2106, 2108, 2110, 2112, 2114, 2116, 2118, 2120, 2122, 2124, 2126, 2128,
2130, 2132, 2134, 2136, 2138, 2140, 2142, 2144, 2146, 2148, 2150, 2152, 2154, 2156, 2158,
2160, 2162, 2164, 2166, 2168, 2170, 2172, 2174, 2176, 2178, 2180, 2182, 2184, 2186, 2188,
2190, 2192, 2194, 2196, 2198, 2200, 2202, 2204, 2206, 2208, 2210, 2212, 2214, 2216, 2218,
2220, 2222, 2224, 2226, 2228, 2230, 2232, 2234, 2236, 2238, 2240, 2242, 2244, 2246, 2248,
2250, 2252, 2254, 2256, 2258, 2260, 2262, 2264, 2266, 2268, 2270, 2272, 2274, 2276, 2278,
2280, 2282, 2284, 2286, 2288, 2290, 2292, 2294, 2296, 2298, 2300, 2302, 2304, 2306, 2308,
2310, 2312, 2314, 2316, 2318, 2320, 2322, 2324, 2326, 2328, 2330, 2332, 2334, 2336, 2338,
2340, 2342, 2344, 2346, 2348, 2350, 2352, 2354, 2356, 2358, 2360, 2362, 2364, 2366, 2368,
2370, 2372, 2374, 2376, 2378, 2380, 2382, 2384, 2386, 2388, 2390, 2392, 2394, 2396, 2398,
2400, 2402, 2404, 2406, 2408, 2410, 2412, 2414, 2416, 2418, 2420, 2422, 2424, 2426, 2428,
2430, 2432, 2434, 2436, 2438, 2440, 2442, 2444, 2446, 2448, 2450, 2452, 2454, 2456, 2458,
2460, 2462, 2464, 2466, 2468, 2470, 2472, 2474, 2476, 2478, 2480, 2482, 2484, 2486, 2488,
2490, 2492, 2494, 2496, 2498, 2500, 2502, 2504, 2506, 2508, 2510, 2512, 2514, 2516, 2518,
2520, 2522, 2524, 2526, 2528, 2530, 2532, 2534, 2536, 2538, 2540, 2542, 2544, 2546, 2548,
2550, 2552, 2554, 2556, 2558, 2560, 2562, 2564, 2566, 2568, 2570, 2572, 2574, 2576, 2578,
2580, 2582, 2584, 2586, 2588, 2590, 2592, 2594, 2596, 2598, 2600, 2602, 2604, 2606, 2608,
2610, 2612, 2614, 2616, 2618, 2620, 2622, 2624, 2626, 2628, 2630, 2632, 2634, 2636, 2638,
2640, 2642, 2644, 2646, 2648, 2650, 2652, 2654, 2656, 2658, 2660, 2662, 2664, 2666, 2668,
2670, 2672, 2674, 2676, 2678, 2680, 2682, 2684, 2686, 2688, 2690, 2692, 2694, 2696, 2698,
2700, 2702, 2704, 2706, 2708, 2710, 2712, 2714, 2716, 2718, 2720, 2722, 2724, 2726, 2728,
2730, 2732, 2734, 2736, 2738, 2740, 2742, 2744, 2746, 2748, 2750, 2752, 2754, 2756, 2758,
2760, 2762, 2764, 2766, 2768, 2770, 2772, 2774, 2776, 2778, 2780, 2782, 2784, 2786, 2788,
2790, 2792, 2794, 2796, 2798, 2800, 2802, 2804, 2806, 2808, 2810, 2812, 2814, 2816, 2818,
2820, 2822, 2824, 2826, 2828, 2830, 2832, 2834, 2836, 2838, 2840, 2842, 2844, 2846, 2848,
2850, 2852, 2854, 2856, 2858, 2860, 2862, 2864, 2866, 2868, 2870, 2872, 2874, 2876, 2878,
2880, 2882, 2884, 2886, 2888, 2890, 2892, 2894, 2896, 2898, 2900, 2902, 2904, 2906, 2908,
2910, 2912, 2914, 2916, 2918, 2920, 2922, 2924, 2926, 2928, 2930, 2932, 2934, 2936, 2938,
2940, 2942, 2944, 2946, 2948, 2950, 2952, 2954, 2956, 2958, 2960, 2962, 2964, 2966, 2968,
2970, 2972, 2974, 2976, 2978, 2980, 2982, 2984, 2986, 2988, 2990, 2992, 2994, 2996, 2998,
3000, 3002, 3004, 3006, 3008, 3010, 3012, 3014, 3016, 3018, 3020, 3022, 3024, 3026, 3028,
3030, 3032, 3034, 3036, 3038, 3040, 3042, 3044, 3046, 3048, 3050, 3052, 3054, 3056, 3058,
3060, 3062, 3064, 3066, 3068, 3070, 3072, 3074, 3076, 3078, 3080, 3082, 3084, 3086, 3088,
3090, 3092, 3094, 3096, 3098, 3100, 3102, 3104, 3106, 3108, 3110, 3112, 3114, 3116, 3118,
3120, 3122, 3124, 3126, 3128, 3130, 3132, 3134, 3136, 3138, 3140, 3142, 3144, 3146, 3148,
3150, 3152, 3154, 3156, 3158, 3160, 3162, 3164, 3166, 3168, 3170, 3172, 3174, 3176, 3178,
3180, 3182, 3184, 3186, 3188, 3190, 3192, 3194, 3196, 3198, 3200, 3202, 3204, 3206, 3208,
3210, 3212, 3214, 3216, 3218, 3220, 3222, 3224, 3226, 3228, 3230, 3232, 3234, 3236, 3238,
3240, 3242, 3244, 3246, 3248, 3250, 3252, 3254, 3256, 3258, 3260, 3262, 3264, 3266, 3268,
3270, 3272, 3274, 3276, 3278, 3280, 3282, 3284, 3286, 3288, 3290, 3292, 3294, 3296, 3298,
3300, 3302, 3304, 3306, 3308, 3310, 3312, 3314, 3316, 3318, 3320, 3322, 3324, 3326, 3328,
3330, 3332, 3334, 3336, 3338, 3340, 3342, 3344, 3346, 3348, 3350, 3352, 3354, 3356, 3358,
3360, 3362, 3364, 3366, 3368, 3370, 3372, 3374, 3376, 3378, 3380, 3382, 3384, 3386, 3388,
3390, 3392, 3394, 3396, 3398, 3400, 3402, 3404, 3406, 3408, 3410, 3412, 3414, 3416, 3418,
3420, 3422, 3424, 3426, 3428, 3430, 3432, 3434, 3436, 3438, 3440, 3442, 3444, 3446, 3448,
3450, 3452, 3454, 3456, 3458, 3460, 3462, 3464, 3466, 3468, 3470, 3472, 3474, 3476, 3478,
3480, 3482, 3484, 3486, 3488, 3490, 3492, 3494, 3496, 3498, 3500, 3502, 3504, 3506, 3508,
3510, 3512, 3514, 3516, 3518, 3520, 3522, 3524, 3526, 3528, 3530, 3532, 3534, 3536, 3538,
3540, 3542, 3544, 3546, 3548, 3550, 3552, 3554, 3556, 3558, 3560, 3562, 3564, 3566, 3568,
3570, 3572, 3574, 3576, 3578, 3580, 3582, 3584, 3586, 3588, 3590, 3592, 3594, 3596, 3598,
3600, 3602, 3604, 3606, 3608, 3610, 3612, 3614, 3616, 3618, 3620, 3622, 3624, 3626, 3628,
3630, 3632, 3634, 3636, 3638, 3640, 3642, 3644, 3646, 3648, 3650, 3652, 3654, 3656, 3658,
3660, 3662, 3664, 3666, 3668, 3670, 3672, 3674, 3676, 3678, 3680, 3682, 3684, 3686, 3688,
3690, 3692, 3694, 3696, 3698, 3700, 3702, 3704, 3706, 3708, 3710, 3712, 3714, 3716, 3718,
3720, 3722, 3724, 3726, 3728, 3730, 3732, 3734, 3736, 3738, 3740, 3742, 3744, 3746, 3748,
3750, 3752, 3754, 3756, 3758, 3760, 3762, 3764, 3766, 3768, 3770, 3772, 3774, 3776, 3778,
3780, 3782, 3784, 3786, 3788, 3790, 3792, 3794, 3796, 3798, 3800, 3802, 3804, 3806, 3808,
3810, 3812, 3814, 3816, 3818, 3820, 3822, 3824, 3826, 3828, 3830, 3832, 3834, 3836, 3838,
3840, 3842, 3844, 3846, 3848, 3850, 3852, 3854, 3856, 3858, 3860, 3862, 3864, 3866, 3868,
3870, 3872, 3874, 3876, 3878, 3880, 3882, 3884, 3886, 3888, 3890, 3892, 3894, 3896, 3898,
3900, 3902, 3904, 3906, 3908, 3910, 3912, 3914, 3916, 3918, 3920, 3922, 3924, 3926, 3928,
3930, 3932, 3934, 3936, 3938, 3940, 3942, 3944, 3946, 3948, 3950, 3952, 3954, 3956, 3958,
3960, 3962, 3964, 3966, 3968, 3970, 3972, 3974, 3976, 3978, 3980, 3982, 3984, 3986, 3988,
3990, 3992, 3994, 3996, 3998, 4000, 4002, 4004, 4006, 4008, 4010, 4012, 4014, 4016, 4018,
4020, 4022, 4024, 4026, 4028, 4030, 4032, 4034, 4036, 4038, 4040, 4042, 4044, 4046, 4048,
4050, 4052, 4054, 4056, 4058, 4060, 4062, 4064, 4066, 4068, 4070, 4072, 4074, 4076, 4078,
4080, 4082, 4084, 4086, 4088, 4090, 4092, 4094, 4096, 4098, 4100, 4102, 4104, 4106, 4108,
4110, 4112, 4114, 4116, 4118, 4120, 4122, 4124, 4126, 4128, 4130, 4132, 4134, 4136, 4138,
4140, 4142, 4144, 4146, 4148, 4150, 4152, 4154, 4156, 4158, 4160, 4162, 4164, 4166, 4168,
4170, 4172, 4174, 4176, 4178, 4180, 4182, 4184, 4186, 4188, 4190, 4192, 4194, 4196, 4198,
4200, 4202, 4204, 4206, 4208, 4210, 4212, 4214, 4216, 4218, 4220, 4222, 4224, 4226, 4228,
4230, 4232, 4234, 4236, 4238, 4240, 4242, 4244, 4246, 4248, 4250, 4252, 4254, 4256, 4258,
4260, 4262, 4264, 4266, 4268, 4270, 4272, 4274, 4276, 4278, 4280, 4282, 4284, 4286, 4288,
4290, 4292, 4294, 4296, 4298, 4300, 4302, 4304, 4306, 4308, 4310, 4312, 4314, 4316, 4318,
4320, 4322, 4324, 4326, 4328, 4330, 4332, 4334, 4336, 4338, 4340, 4342, 4344, 4346, 4348,
4350, 4352, 4354, 4356, 4358, 4360, 4362, 4364, 4366, 4368, 4370, 4372, 4374, 4376, 4378,
4380, 4382, 4384, 4386, 4388, 4390, 4392, 4394, 4396, 4398, 4400, 4402, 4404, 4406, 4408,
4410, 4412, 4414, 4416, 4418, 4420, 4422, 4424, 4426, 4428, 4430, 4432, 4434, 4436, 4438,
4440, 4442, 4444, 4446, 4448, 4450, 4452, 4454, 4456, 4458, 4460, 4462, 4464, 4466, 4468,
4470, 4472, 4474, 4476, 4478, 4480, 4482, 4484, 4486, 4488, 4490, 4492, 4494, 4496, 4498,
4500, 4502, 4504, 4506, 4508, 4510, 4512, 4514, 4516, 4518, 4520, 4522, 4524, 4526, 4528,
4530, 4532, 4534, 4536, 4538, 4540, 4542, 4544, 4546, 4548, 4550, 4552, 4554, 4556, 4558,
4560, 4562, 4564, 4566, 4568, 4570, 4572, 4574, 4576, 4578, 4580, 4582, 4584, 4586, 4588,
4590, 4592, 4594, 4596, 4598, 4600, 4602, 4604, 4606, 4608, 4610, 4612, 4614, 4616, 4618,
4620, 4622, 4624, 4626, 4628, 4630, 4632, 4634, 4636, 4638, 4640, 4642, 4644, 4646, 4648,
4650, 4652, 4654, 4656, 4658, 4660, 4662, 4664, 4666, 4668, 4670, 4672, 4674, 4676, 4678,
4680, 4682, 4684, 4686, 4688, 4690, 4692, 4694, 4696, 4698, 4700, 4702, 4704, 4706, 4708,
4710, 4712, 4714, 4716, 4718, 4720, 4722, 4724, 4726, 4728, 4730, 4732, 4734, 4736, 4738,
4740, 4742, 4744, 4746, 4748, 4750, 4752, 4754, 4756, 4758, 4760, 4762, 4764, 4766, 4768,
4770, 4772, 4774, 4776, 4778, 4780,
},
{{0.0, 0.0}, {1.0, 0.0}, {0.0, 0.0}, {1.0, 0.0}, {0.0, 1.0}, {1.0, 1.0}, {0.0, 0.5}, {1.0, 0.5},
{0.0, 0.5}, {1.0, 0.5}, {0.0, 1.0}, {1.0, 1.0}, {0.0, 1.0}, {1.0, 1.0}, {0.0, 0.0}, {1.0, 0.0},
{0.0, 1.0}, {1.0, 1.0}, {0.0, 0.0}, {1.0, 0.0}, {0.0, 1.0}, {1.0, 1.0}, {0.0, 1.0}, {1.0, 1.0},
{0.0, 0.0}, {1.0, 0.0}, {0.0, 1.0}, {1.0, 1.0}, {0.0, 0.5}, {1.0, 0.5}, {0.0, 0.0}, {1.0, 0.0},
{0.0, 0.5}, {1.0, 0.5}, {0.0, 0.5}, {1.0, 0.5}, {0.0, 0.0}, {1.0, 0.0}, {0.0, 0.0}, {1.0, 0.0},
{0.0, 1.0}, {1.0, 1.0}, {0.0, 0.5}, {1.0, 0.5}, {0.0, 0.0}, {1.0, 0.0}, {0.0, 0.0}, {1.0, 0.0},
{0.0, 0.0}, {1.0, 0.0}, {0.0, 0.5}, {1.0, 0.5}, {0.0, 0.0}, {1.0, 0.0}, {0.0, 0.0}, {1.0, 0.0},
{0.0, 0.0}, {1.0, 0.0}, {0.0, 1.0}, {1.0, 1.0}, {0.0, 0.5}, {1.0, 0.5}, {0.0, 0.0}, {1.0, 0.0},
{0.0, 0.5}, {1.0, 0.5}, {0.0, 1.0}, {1.0, 1.0}, {0.0, 0.0}, {1.0, 0.0}, {0.0, 0.0}, {1.0, 0.0},
{0.0, 0.0}, {1.0, 0.0}, {0.0, 0.0}, {1.0, 0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.0, 0.5}, {1.0, 0.5}, {0.0, 0.0}, {1.0, 0.0}, {0.0, 0.0}, {1.0, 0.0},
{0.0, 1.0}, {1.0, 1.0}, {0.0, 0.0}, {1.0, 0.0}, {0.0, 0.0}, {1.0, 0.0}, {0.0, 0.0}, {1.0, 0.0},
{0.0, 0.0}, {1.0, 0.0}, {0.0, 0.5}, {1.0, 0.5}, {0.0, 0.0}, {1.0, 0.0}, {0.0, 0.0}, {1.0, 0.0},
{0.0, 0.0}, {1.0, 0.0}, {0.0, 0.0}, {1.0, 0.0}, {0.0, 0.5}, {1.0, 0.5}, {0.0, 1.0}, {1.0, 1.0},
{0.0, 0.0}, {1.0, 0.0}, {0.0, 0.0}, {1.0, 0.0}, {0.0, 0.0}, {1.0, 0.0}, {0.0, 0.0}, {1.0, 0.0},
{0.0, 0.0}, {1.0, 0.0}, {0.0, 0.5}, {1.0, 0.5}, {0.0, 0.0}, {1.0, 0.0}, {0.0, 0.5}, {1.0, 0.5},
{0.0, 0.5}, {1.0, 0.5}, {0.0, 0.0}, {1.0, 0.0}});
CUSPATIAL_RUN_TEST(
this->template verify_legal_result, multilinestrings1.range(), multilinestrings2.range());
}
template <typename T>
struct coordinate_functor {
cuspatial::vec_2d<T> __device__ operator()(std::size_t i)
{
return cuspatial::vec_2d<T>{static_cast<T>(i), static_cast<T>(i)};
}
};
TYPED_TEST(LinestringIntersectionLargeTest, LongInput_2)
{
using P = cuspatial::vec_2d<TypeParam>;
auto geometry_offset = cuspatial::test::make_device_vector({0, 1});
auto part_offset = cuspatial::test::make_device_vector({0, 130});
auto coordinates = rmm::device_uvector<P>(260, this->stream());
thrust::tabulate(rmm::exec_policy(this->stream()),
coordinates.begin(),
thrust::next(coordinates.begin(), 128),
coordinate_functor<TypeParam>{});
coordinates.set_element(128, P{127.0, 0.0}, this->stream());
coordinates.set_element(129, P{0.0, 0.0}, this->stream());
auto rng = cuspatial::make_multilinestring_range(
1, geometry_offset.begin(), 1, part_offset.begin(), 130, coordinates.begin());
CUSPATIAL_RUN_TEST(this->template verify_legal_result, rng, rng);
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/intersection/linestring_intersection_with_duplicates_test.cu | /*
* 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 "intersection_test_utils.cuh"
#include <cuspatial_test/vector_equality.hpp>
#include <cuspatial_test/vector_factories.cuh>
#include <cuspatial/detail/intersection/linestring_intersection_with_duplicates.cuh>
#include <cuspatial/error.hpp>
#include <cuspatial/geometry/vec_2d.hpp>
#include <cuspatial/iterator_factory.cuh>
#include <cuspatial/traits.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_uvector.hpp>
#include <rmm/device_vector.hpp>
#include <rmm/exec_policy.hpp>
#include <rmm/mr/device/device_memory_resource.hpp>
#include <rmm/mr/device/per_device_resource.hpp>
#include <thrust/gather.h>
#include <thrust/iterator/zip_iterator.h>
#include <thrust/sequence.h>
#include <thrust/sort.h>
#include <cub/device/device_segmented_sort.cuh>
#include <initializer_list>
#include <type_traits>
using namespace cuspatial;
using namespace cuspatial::test;
/**
* @brief Sort geometries in `intersection_intermediates` by segments
*
* The order of results from `linestring_intersection_with_duplicates` is non-deterministic.
* Specifically, while each result is written to the dedicated location for the pair, if there
* are multiple results in the same pair (e.g. 2 intersection point of the pair), the order
* between these pairs are non-deterministic. This doesn't affect the semantic of the intersection
* result, but will make tests flaky since the expected results are hard-coded.
*
* This function sorts the intersection results so that the comparison is deterministic.
*
* Example:
* offsets: {0, 1, 3, 4}
* points: {{0, 0}, {2, 1}, {0, 1}, {5, 5}}
* ^ ^
* The order of points[1] and points[2] are non-deterministic.
* Sort Result (deterministic):
* points: {{0, 0}, {0, 1}, {2, 1}, {5, 5}}
*
* @tparam Intermediate Type of intersection_intermediate
* @param intermediate Intermediate result from `intersection_with_duplicates`
* @param stream The CUDA stream to use for device memory operations and kernel launches.
* @param mr The optional resource to use for output device memory allocations.
* @return A copy of the intermediate result containing sorted geometries
*/
template <typename Intermediate>
Intermediate segmented_sort_intersection_intermediates(Intermediate& intermediate,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
using GeomType = typename Intermediate::geometry_t;
using IndexType = typename Intermediate::index_t;
auto const num_geoms = intermediate.geoms->size();
if (num_geoms == 0) return std::move(intermediate);
auto keys = rmm::device_uvector<IndexType>(num_geoms, stream);
auto gather_map = rmm::device_uvector<IndexType>(num_geoms, stream);
auto keys_it = intermediate.keys_begin();
thrust::copy(rmm::exec_policy(stream), keys_it, keys_it + keys.size(), keys.begin());
thrust::sequence(rmm::exec_policy(stream), gather_map.begin(), gather_map.end());
auto sort_keys_it = thrust::make_zip_iterator(keys.begin(), intermediate.geoms->begin());
thrust::sort_by_key(rmm::exec_policy(stream),
sort_keys_it,
sort_keys_it + keys.size(),
gather_map.begin(),
order_key_value_pairs<IndexType, GeomType>{});
// Update intermediate indices
auto lhs_linestring_ids = std::make_unique<rmm::device_uvector<IndexType>>(num_geoms, stream, mr);
auto lhs_segment_ids = std::make_unique<rmm::device_uvector<IndexType>>(num_geoms, stream, mr);
auto rhs_linestring_ids = std::make_unique<rmm::device_uvector<IndexType>>(num_geoms, stream, mr);
auto rhs_segment_ids = std::make_unique<rmm::device_uvector<IndexType>>(num_geoms, stream, mr);
auto input_it = thrust::make_zip_iterator(intermediate.lhs_linestring_ids->begin(),
intermediate.lhs_segment_ids->begin(),
intermediate.rhs_linestring_ids->begin(),
intermediate.rhs_segment_ids->begin());
auto output_it = thrust::make_zip_iterator(lhs_linestring_ids->begin(),
lhs_segment_ids->begin(),
rhs_linestring_ids->begin(),
rhs_segment_ids->begin());
thrust::gather(
rmm::exec_policy(stream), gather_map.begin(), gather_map.end(), input_it, output_it);
return Intermediate{std::move(intermediate.offsets),
std::move(intermediate.geoms),
std::move(lhs_linestring_ids),
std::move(lhs_segment_ids),
std::move(rhs_linestring_ids),
std::move(rhs_segment_ids)};
}
template <typename T>
struct LinestringIntersectionDuplicatesTest : public ::testing::Test {
rmm::cuda_stream_view stream() { return rmm::cuda_stream_default; }
rmm::mr::device_memory_resource* mr() { return rmm::mr::get_current_device_resource(); }
template <typename IndexType, typename MultilinestringRange1, typename MultilinestringRange2>
void run_single(MultilinestringRange1 lhs,
MultilinestringRange2 rhs,
std::initializer_list<IndexType> expected_points_offsets,
std::initializer_list<vec_2d<T>> expected_points_coords,
std::initializer_list<IndexType> expected_segments_offsets,
std::initializer_list<segment<T>> expected_segments_coords,
std::initializer_list<IndexType> expected_point_lhs_linestring_ids,
std::initializer_list<IndexType> expected_point_lhs_segment_ids,
std::initializer_list<IndexType> expected_point_rhs_linestring_ids,
std::initializer_list<IndexType> expected_point_rhs_segment_ids,
std::initializer_list<IndexType> expected_segment_lhs_linestring_ids,
std::initializer_list<IndexType> expected_segment_lhs_segment_ids,
std::initializer_list<IndexType> expected_segment_rhs_linestring_ids,
std::initializer_list<IndexType> expected_segment_rhs_segment_ids
)
{
auto d_expected_points_offsets = make_device_vector(expected_points_offsets);
auto d_expected_points_coords = make_device_vector(expected_points_coords);
auto d_expected_segments_offsets = make_device_vector(expected_segments_offsets);
auto d_expected_segments_coords = make_device_vector(expected_segments_coords);
auto d_expected_point_lhs_linestring_ids =
make_device_vector(expected_point_lhs_linestring_ids);
auto d_expected_point_lhs_segment_ids = make_device_vector(expected_point_lhs_segment_ids);
auto d_expected_point_rhs_linestring_ids =
make_device_vector(expected_point_rhs_linestring_ids);
auto d_expected_point_rhs_segment_ids = make_device_vector(expected_point_rhs_segment_ids);
auto d_expected_segment_lhs_linestring_ids =
make_device_vector(expected_segment_lhs_linestring_ids);
auto d_expected_segment_lhs_segment_ids = make_device_vector(expected_segment_lhs_segment_ids);
auto d_expected_segment_rhs_linestring_ids =
make_device_vector(expected_segment_rhs_linestring_ids);
auto d_expected_segment_rhs_segment_ids = make_device_vector(expected_segment_rhs_segment_ids);
auto [points, segments] = [&lhs, &rhs, this]() {
auto [points, segments] =
detail::pairwise_linestring_intersection_with_duplicates<IndexType, T>(
lhs, rhs, this->mr(), this->stream());
auto sorted_points =
segmented_sort_intersection_intermediates(points, this->stream(), this->mr());
auto sorted_segments =
segmented_sort_intersection_intermediates(segments, this->stream(), this->mr());
return std::pair{std::move(sorted_points), std::move(sorted_segments)};
}();
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_expected_points_offsets, *std::move(points.offsets));
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_expected_points_coords, *std::move(points.geoms));
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_expected_segments_offsets, *std::move(segments.offsets));
CUSPATIAL_EXPECT_VEC2D_PAIRS_EQUIVALENT(d_expected_segments_coords, *std::move(segments.geoms));
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_expected_point_lhs_linestring_ids,
*std::move(points.lhs_linestring_ids));
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_expected_point_lhs_segment_ids,
*std::move(points.lhs_segment_ids));
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_expected_point_rhs_linestring_ids,
*std::move(points.rhs_linestring_ids));
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_expected_point_rhs_segment_ids,
*std::move(points.rhs_segment_ids));
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_expected_segment_lhs_linestring_ids,
*std::move(segments.lhs_linestring_ids));
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_expected_segment_lhs_segment_ids,
*std::move(segments.lhs_segment_ids));
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_expected_segment_rhs_linestring_ids,
*std::move(segments.rhs_linestring_ids));
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_expected_segment_rhs_segment_ids,
*std::move(segments.rhs_segment_ids));
}
};
// float and double are logically the same but would require separate tests due to precision.
using TestTypes = ::testing::Types<float, double>;
TYPED_TEST_CASE(LinestringIntersectionDuplicatesTest, TestTypes);
// TODO: sort the points in the intersection result since the result order is arbitrary.
TYPED_TEST(LinestringIntersectionDuplicatesTest, Example)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = std::size_t;
auto multilinestrings1 = make_multilinestring_array({0, 1, 2, 3, 4, 5, 6, 7},
{0, 2, 4, 6, 8, 10, 12, 14},
{P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1}});
auto multilinestrings2 = make_multilinestring_array(
{0, 1, 2, 3, 4, 5, 6, 7},
{0, 2, 5, 7, 12, 16, 18, 20},
{P{1, 0}, P{0, 1}, P{0.5, 0}, P{0, 0.5}, P{1, 0.5},
P{0.5, 0.5}, P{1.5, 1.5}, P{-1, -1}, P{0.25, 0.25}, P{0.25, 0.0},
P{0.75, 0.75}, P{1.5, 1.5}, P{0.25, 0.0}, P{0.25, 0.5}, P{0.75, 0.75},
P{1.5, 1.5}, P{2, 2}, P{3, 3}, P{1, 0}, P{2, 0}});
CUSPATIAL_RUN_TEST(this->template run_single<index_t>,
multilinestrings1.range(),
multilinestrings2.range(),
// Point offsets
{0, 1, 3, 3, 5, 7, 7, 7},
// Expected points
{P{0.5, 0.5},
P{0.25, 0.25},
P{0.5, 0.5},
P{0.25, 0.25},
P{0.75, 0.75},
P{0.25, 0.25},
P{0.75, 0.75}},
// Segment offsets
{0, 0, 0, 1, 3, 4, 4, 4},
// Expected segments
{segment<T>{P{0.5, 0.5}, P{1, 1}},
segment<T>{P{0, 0}, P{0.25, 0.25}},
segment<T>{P{0.75, 0.75}, P{1, 1}},
segment<T>{P{0.75, 0.75}, P{1, 1}}},
// Expected look-back id for points
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 2, 0, 1},
// Expected look-back id for segments
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 3, 2});
}
// Same Test Case as above, reversing the order of multilinestrings1 and multilinestrings2
TYPED_TEST(LinestringIntersectionDuplicatesTest, ExampleReversed)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = std::size_t;
auto multilinestrings1 = make_multilinestring_array({0, 1, 2, 3, 4, 5, 6, 7},
{0, 2, 4, 6, 8, 10, 12, 14},
{P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1}});
auto multilinestrings2 = make_multilinestring_array(
{0, 1, 2, 3, 4, 5, 6, 7},
{0, 2, 5, 7, 12, 16, 18, 20},
{P{1, 0}, P{0, 1}, P{0.5, 0}, P{0, 0.5}, P{1, 0.5},
P{0.5, 0.5}, P{1.5, 1.5}, P{-1, -1}, P{0.25, 0.25}, P{0.25, 0.0},
P{0.75, 0.75}, P{1.5, 1.5}, P{0.25, 0.0}, P{0.25, 0.5}, P{0.75, 0.75},
P{1.5, 1.5}, P{2, 2}, P{3, 3}, P{1, 0}, P{2, 0}});
CUSPATIAL_RUN_TEST(this->template run_single<index_t>,
multilinestrings2.range(),
multilinestrings1.range(),
// Point Offsets
{0, 1, 3, 3, 5, 7, 7, 7},
// Expected points
{P{0.5, 0.5},
P{0.25, 0.25},
P{0.5, 0.5},
P{0.25, 0.25},
P{0.75, 0.75},
P{0.25, 0.25},
P{0.75, 0.75}},
// Segment Offsets
{0, 0, 0, 1, 3, 4, 4, 4},
// Expected Segments
{segment<T>{P{0.5, 0.5}, P{1, 1}},
segment<T>{P{0, 0}, P{0.25, 0.25}},
segment<T>{P{0.75, 0.75}, P{1, 1}},
segment<T>{P{0.75, 0.75}, P{1, 1}}},
// Point look-back ids
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 2, 0, 1},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
// Segment look-back ids
{0, 0, 0, 0},
{0, 0, 3, 2},
{0, 0, 0, 0},
{0, 0, 0, 0});
}
TYPED_TEST(LinestringIntersectionDuplicatesTest, MultilinestringsIntersectionWithDuplicates)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = std::size_t;
auto multilinestrings1 = make_multilinestring_array(
{0, 2, 5},
{0, 2, 4, 6, 8, 10},
{P{0, 0}, P{1, 1}, P{1, 0}, P{2, 1}, P{0, 2}, P{1, 2}, P{0, 3}, P{0, 2}, P{0, 3}, P{1, 2}});
auto multilinestrings2 =
make_multilinestring_array({0, 1, 2}, {0, 2, 4}, {P{0, 1}, P{2, 0}, P{0, 2.5}, P{1, 2.5}});
CUSPATIAL_RUN_TEST(this->template run_single<index_t>,
multilinestrings1.range(),
multilinestrings2.range(),
// Points offsets
{0, 2, 4},
// Expected Points
{P{2 / 3., 2 / 3.}, P{4 / 3., 1 / 3.}, P{0, 2.5}, P{0.5, 2.5}},
// Segment offsets
{0, 0, 0},
// Expected Segments
{},
// Point look-back ids
{0, 1, 1, 2},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0},
// Segment look-back ids
{},
{},
{},
{});
}
TYPED_TEST(LinestringIntersectionDuplicatesTest, Empty)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = std::size_t;
auto multilinestrings1 = make_multilinestring_array({0}, {0}, std::initializer_list<P>{});
auto multilinestrings2 = make_multilinestring_array({0}, {0}, std::initializer_list<P>{});
CUSPATIAL_RUN_TEST(this->template run_single<index_t>,
multilinestrings1.range(),
multilinestrings2.range(),
// Point offsets
{0},
// Expected Points
{},
// Segment offsets
{0},
// Expected segments
{},
// Point look-back ids
{},
{},
{},
{},
// segment look-back ids
{},
{},
{},
{});
}
TYPED_TEST(LinestringIntersectionDuplicatesTest, OnePairSingleToSingleOneSegment)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = std::size_t;
auto multilinestrings1 = make_multilinestring_array({0, 1}, {0, 2}, {P{0, 0}, P{1, 1}});
auto multilinestrings2 = make_multilinestring_array({0, 1}, {0, 2}, {P{0, 1}, P{1, 0}});
CUSPATIAL_RUN_TEST(this->template run_single<index_t>,
multilinestrings1.range(),
multilinestrings2.range(),
// Point offsets
{0, 1},
// Expected Points
{P{0.5, 0.5}},
// Segment offsets
{0, 0},
// Expected segments
{},
// Point look-back ids
{0},
{0},
{0},
{0},
// segment look-back ids
{},
{},
{},
{});
}
TYPED_TEST(LinestringIntersectionDuplicatesTest, OnePairSingleToSingleTwoSegments)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = std::size_t;
auto multilinestrings1 = make_multilinestring_array({0, 1}, {0, 3}, {P{-1, 0}, P{0, 0}, P{1, 1}});
auto multilinestrings2 = make_multilinestring_array({0, 1}, {0, 3}, {P{0, 2}, P{0, 1}, P{1, 0}});
CUSPATIAL_RUN_TEST(this->template run_single<index_t>,
multilinestrings1.range(),
multilinestrings2.range(),
// Point offsets
{0, 1},
// Expected Points
{P{0.5, 0.5}},
// Segment offsets
{0, 0},
// Expected segments
{},
// Point look-back ids
{0},
{1},
{0},
{1},
// segment look-back ids
{},
{},
{},
{});
}
TYPED_TEST(LinestringIntersectionDuplicatesTest, OnePairSingletoSingleOverlap)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = std::size_t;
auto multilinestrings1 = make_multilinestring_array({0, 1}, {0, 2}, {P{0, 0}, P{1, 1}});
auto multilinestrings2 =
make_multilinestring_array({0, 1}, {0, 2}, {P{0.75, 0.75}, P{0.25, 0.25}});
CUSPATIAL_RUN_TEST(this->template run_single<index_t>,
multilinestrings1.range(),
multilinestrings2.range(),
// Point offsets
{0, 0},
// Expected Points
{},
// Segment offsets
{0, 1},
// Expected segments
{segment<T>{P{0.25, 0.25}, P{0.75, 0.75}}},
// Point look-back ids
{},
{},
{},
{},
// segment look-back ids
{0},
{0},
{0},
{0});
}
TYPED_TEST(LinestringIntersectionDuplicatesTest, OnePairSingletoSingleOverlapTwoSegments)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = std::size_t;
auto multilinestrings1 = make_multilinestring_array({0, 1}, {0, 3}, {P{0, 0}, P{1, 1}, P{2, 2}});
auto multilinestrings2 =
make_multilinestring_array({0, 1}, {0, 3}, {P{1.25, 1.25}, P{0.75, 0.75}, P{0.25, 0.25}});
CUSPATIAL_RUN_TEST(this->template run_single<index_t>,
multilinestrings1.range(),
multilinestrings2.range(),
// Point offsets
{0, 0},
// Expected Points
{},
// Segment offsets
{0, 3},
// Expected segments
{segment<T>{P{0.25, 0.25}, P{0.75, 0.75}},
segment<T>{P{0.75, 0.75}, P{1.0, 1.0}},
segment<T>{P{1.0, 1.0}, P{1.25, 1.25}}},
// Point look-back ids
{},
{},
{},
{},
// segment look-back ids
{0, 0, 0},
{0, 0, 1},
{0, 0, 0},
{1, 0, 0});
}
TYPED_TEST(LinestringIntersectionDuplicatesTest, OnePairMultiSingle)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = std::size_t;
auto multilinestrings1 =
make_multilinestring_array({0, 2}, {0, 2, 4}, {P{0, 0}, P{1, 1}, P{0, 0}, P{-1, 1}});
auto multilinestrings2 = make_multilinestring_array({0, 1}, {0, 2}, {P{-2, 0.5}, P{2, 0.5}});
CUSPATIAL_RUN_TEST(this->template run_single<index_t>,
multilinestrings1.range(),
multilinestrings2.range(),
// Point offsets
{0, 2},
// Expected Points
{P{-0.5, 0.5}, P{0.5, 0.5}},
// Segment offsets
{0, 0},
// Expected segments
{},
// Point look-back ids
{1, 0},
{0, 0},
{0, 0},
{0, 0},
// segment look-back ids
{},
{},
{},
{});
}
TYPED_TEST(LinestringIntersectionDuplicatesTest, TwoPairsSingletoSingle)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = std::size_t;
auto multilinestrings1 =
make_multilinestring_array({0, 1, 2}, {0, 2, 4}, {P{0, 0}, P{1, 1}, P{0, 0}, P{-1, 1}});
auto multilinestrings2 =
make_multilinestring_array({0, 1, 2}, {0, 2, 4}, {P{0, 1}, P{1, 0}, P{0, 1}, P{-1, 0}});
CUSPATIAL_RUN_TEST(this->template run_single<index_t>,
multilinestrings1.range(),
multilinestrings2.range(),
// Point offsets
{0, 1, 2},
// Expected Points
{P{0.5, 0.5}, P{-0.5, 0.5}},
// Segment offsets
{0, 0, 0},
// Expected segments
{},
// Point look-back ids
{0, 0},
{0, 0},
{0, 0},
{0, 0},
// segment look-back ids
{},
{},
{},
{});
}
TYPED_TEST(LinestringIntersectionDuplicatesTest, TwoPairsMultitoMulti)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = std::size_t;
auto multilinestrings1 = make_multilinestring_array(
{0, 2, 4},
{0, 2, 4, 6, 8},
{P{0, 0}, P{1, 1}, P{2, 0}, P{3, 1}, P{1, 0}, P{1, 1}, P{0, 0}, P{1, 0}});
auto multilinestrings2 = make_multilinestring_array(
{0, 2, 4},
{0, 2, 4, 6, 8},
{P{0, 1}, P{1, 0}, P{2, 1}, P{3, 0}, P{-1, 0}, P{-2, 1}, P{-3, -2}, P{-4, 3}});
CUSPATIAL_RUN_TEST(this->template run_single<index_t>,
multilinestrings1.range(),
multilinestrings2.range(),
// Point offsets
{0, 2, 2},
// Expected Points
{P{0.5, 0.5}, P{2.5, 0.5}},
// Segment offsets
{0, 0, 0},
// Expected segments
{},
// Point look-back ids
{0, 1},
{0, 0},
{0, 1},
{0, 0},
// segment look-back ids
{},
{},
{},
{});
}
TYPED_TEST(LinestringIntersectionDuplicatesTest, ThreePairIdenticalInputsNoRings)
{
using T = TypeParam;
using P = vec_2d<T>;
using index_t = std::size_t;
auto multilinestrings1 = make_multilinestring_array(
{0, 1, 2, 3},
{0, 2, 4, 6},
{P{0.0, 0.0}, P{1.0, 1.0}, P{0.0, 0.0}, P{1.0, 1.0}, P{0.0, 0.0}, P{1.0, 1.0}});
auto multilinestrings2 = make_multilinestring_array<T>({0, 1, 2, 3},
{0, 4, 8, 12},
{{0, 0},
{0, 1},
{1, 1},
{1, 0},
{0, 0},
{0, 1},
{1, 1},
{1, 0},
{0, 0},
{0, 1},
{1, 1},
{1, 0}});
CUSPATIAL_RUN_TEST(
this->template run_single<index_t>,
multilinestrings1.range(),
multilinestrings2.range(),
// Point offsets
{0, 3, 6, 9},
// Expected Points
{P{0, 0}, P{1, 1}, P{1, 1}, P{0, 0}, P{1, 1}, P{1, 1}, P{0, 0}, P{1, 1}, P{1, 1}},
// Segment offsets
{0, 0, 0, 0},
// Expected segments
{},
// Point look-back ids
{0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 1, 2, 0, 1, 2, 0, 1, 2},
// segment look-back ids
{},
{},
{},
{});
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/intersection/linestring_intersection_count_test.cu | /*
* 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 <cuspatial_test/vector_equality.hpp>
#include <cuspatial_test/vector_factories.cuh>
#include <cuspatial/detail/intersection/linestring_intersection_count.cuh>
#include <cuspatial/error.hpp>
#include <cuspatial/geometry/vec_2d.hpp>
#include <cuspatial/iterator_factory.cuh>
#include <cuspatial/traits.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_uvector.hpp>
#include <rmm/device_vector.hpp>
#include <thrust/uninitialized_fill.h>
#include <rmm/exec_policy.hpp>
#include <thrust/iterator/zip_iterator.h>
#include <initializer_list>
#include <type_traits>
using namespace cuspatial;
using namespace cuspatial::test;
template <typename T>
struct LinestringIntersectionCountTest : public ::testing::Test {
rmm::cuda_stream_view default_stream() { return rmm::cuda_stream_default; }
};
// float and double are logically the same but would require separate tests due to precision.
using TestTypes = ::testing::Types<float, double>;
TYPED_TEST_CASE(LinestringIntersectionCountTest, TestTypes);
TYPED_TEST(LinestringIntersectionCountTest, SingleToSingleSimpleIntersectSinglePoint)
{
using T = TypeParam;
using P = vec_2d<T>;
using count_type = unsigned;
auto multilinestrings1 = make_multilinestring_array({0, 1}, {0, 2}, {P{0, 0}, P{1, 1}});
auto multilinestrings2 = make_multilinestring_array({0, 1}, {0, 2}, {P{0, 1}, P{1, 0}});
rmm::device_vector<count_type> num_intersecting_points(multilinestrings1.size());
rmm::device_vector<count_type> num_overlapping_segments(multilinestrings1.size());
std::vector<count_type> expected_intersecting_points_count{1};
std::vector<count_type> expected_overlapping_segment_count{0};
pairwise_linestring_intersection_upper_bound_count(multilinestrings1.range(),
multilinestrings2.range(),
num_intersecting_points.begin(),
num_overlapping_segments.begin(),
this->default_stream());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(num_intersecting_points, expected_intersecting_points_count);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(num_overlapping_segments, expected_overlapping_segment_count);
}
TYPED_TEST(LinestringIntersectionCountTest, SingleToSingleIntersectMultipoint)
{
using T = TypeParam;
using P = vec_2d<T>;
using count_type = unsigned;
auto multilinestrings1 = make_multilinestring_array({0, 1}, {0, 2}, {P{0, 0}, P{1, 1}});
auto multilinestrings2 =
make_multilinestring_array({0, 1}, {0, 3}, {P{0.5, 0.0}, P{0.0, 0.5}, P{1.0, 0.5}});
rmm::device_vector<count_type> num_intersecting_points(multilinestrings1.size());
rmm::device_vector<count_type> num_overlapping_segments(multilinestrings1.size());
std::vector<count_type> expected_intersecting_points_count{2};
std::vector<count_type> expected_overlapping_segment_count{0};
pairwise_linestring_intersection_upper_bound_count(multilinestrings1.range(),
multilinestrings2.range(),
num_intersecting_points.begin(),
num_overlapping_segments.begin(),
this->default_stream());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(num_intersecting_points, expected_intersecting_points_count);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(num_overlapping_segments, expected_overlapping_segment_count);
}
TYPED_TEST(LinestringIntersectionCountTest, SingleToSingleOverlapSingleSegment)
{
using T = TypeParam;
using P = vec_2d<T>;
using count_type = unsigned;
auto multilinestrings1 = make_multilinestring_array({0, 1}, {0, 2}, {P{0, 0}, P{1, 1}});
auto multilinestrings2 = make_multilinestring_array({0, 1}, {0, 2}, {P{0.5, 0.5}, P{1.5, 1.5}});
rmm::device_vector<count_type> num_intersecting_points(multilinestrings1.size());
rmm::device_vector<count_type> num_overlapping_segments(multilinestrings1.size());
std::vector<count_type> expected_intersecting_points_count{0};
std::vector<count_type> expected_overlapping_segment_count{1};
pairwise_linestring_intersection_upper_bound_count(multilinestrings1.range(),
multilinestrings2.range(),
num_intersecting_points.begin(),
num_overlapping_segments.begin(),
this->default_stream());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(num_intersecting_points, expected_intersecting_points_count);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(num_overlapping_segments, expected_overlapping_segment_count);
}
TYPED_TEST(LinestringIntersectionCountTest, SingleToSingleOverlapSingleSegment2)
{
using T = TypeParam;
using P = vec_2d<T>;
using count_type = unsigned;
// The "upper bound intersection count" between
// (0, 0) -> (1, 1) and (-1, -1) -> (0.25, 0.25) -> (0.25, 0.0) is
// 1 intersection point(s) (0.25, 0.25) and
// 1 overlapping segment(s) (0.0, 0.0) -> (0.25, 0.25)
auto multilinestrings1 = make_multilinestring_array({0, 1}, {0, 2}, {P{0, 0}, P{1, 1}});
auto multilinestrings2 =
make_multilinestring_array({0, 1}, {0, 3}, {P{-1, -1}, P{0.25, 0.25}, P{0.25, 0.0}});
rmm::device_vector<count_type> num_intersecting_points(multilinestrings1.size());
rmm::device_vector<count_type> num_overlapping_segments(multilinestrings1.size());
std::vector<count_type> expected_intersecting_points_count{1};
std::vector<count_type> expected_overlapping_segment_count{1};
pairwise_linestring_intersection_upper_bound_count(multilinestrings1.range(),
multilinestrings2.range(),
num_intersecting_points.begin(),
num_overlapping_segments.begin(),
this->default_stream());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(num_intersecting_points, expected_intersecting_points_count);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(num_overlapping_segments, expected_overlapping_segment_count);
}
TYPED_TEST(LinestringIntersectionCountTest, SingleToSingleOverlapMultipleSegment)
{
using T = TypeParam;
using P = vec_2d<T>;
using count_type = unsigned;
// The "upper bound intersection count" between
// (0, 0) -> (1, 1) and (-1, -1) -> (0.25, 0.25) -> (0.25, 0.0) is
// 2 intersection point(s) (0.25, 0.25) and (0.75, 0.75)
// 2 overlapping segment(s) (0.0, 0.0) -> (0.25, 0.25), (0.75, 0.75) -> (1.0, 1.0)
auto multilinestrings1 = make_multilinestring_array({0, 1}, {0, 2}, {P{0, 0}, P{1, 1}});
auto multilinestrings2 = make_multilinestring_array(
{0, 1}, {0, 5}, {P{-1, -1}, P{0.25, 0.25}, P{0.25, 0.0}, P{0.75, 0.75}, P{1.5, 1.5}});
rmm::device_vector<count_type> num_intersecting_points(multilinestrings1.size());
rmm::device_vector<count_type> num_overlapping_segments(multilinestrings1.size());
std::vector<count_type> expected_intersecting_points_count{2};
std::vector<count_type> expected_overlapping_segment_count{2};
pairwise_linestring_intersection_upper_bound_count(multilinestrings1.range(),
multilinestrings2.range(),
num_intersecting_points.begin(),
num_overlapping_segments.begin(),
this->default_stream());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(num_intersecting_points, expected_intersecting_points_count);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(num_overlapping_segments, expected_overlapping_segment_count);
}
TYPED_TEST(LinestringIntersectionCountTest, SingleToSingleSimpleIntersectAndOverlap)
{
using T = TypeParam;
using P = vec_2d<T>;
using count_type = unsigned;
// The "upper bound intersection count" between
// (0.25, 0) -> (0.25, 0.5) -> (0.75, 0.75) -> (1.5, 1.5) and (0, 0) -> (1, 1)
// 2 intersection point(s) (0.25, 0.25) and (0.75, 0.75)
// 1 overlapping segment(s) (0.75, 0.75) -> (1.0, 1.0)
auto multilinestrings1 = make_multilinestring_array({0, 1}, {0, 2}, {P{0, 0}, P{1, 1}});
auto multilinestrings2 = make_multilinestring_array(
{0, 1}, {0, 4}, {P{0.25, 0.0}, P{0.25, 0.5}, P{0.75, 0.75}, P{1.5, 1.5}});
rmm::device_vector<count_type> num_intersecting_points(multilinestrings1.size());
rmm::device_vector<count_type> num_overlapping_segments(multilinestrings1.size());
std::vector<count_type> expected_intersecting_points_count{2};
std::vector<count_type> expected_overlapping_segment_count{1};
pairwise_linestring_intersection_upper_bound_count(multilinestrings1.range(),
multilinestrings2.range(),
num_intersecting_points.begin(),
num_overlapping_segments.begin(),
this->default_stream());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(num_intersecting_points, expected_intersecting_points_count);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(num_overlapping_segments, expected_overlapping_segment_count);
}
TYPED_TEST(LinestringIntersectionCountTest, SingleToSingleSimpleDisjoint)
{
using T = TypeParam;
using P = vec_2d<T>;
using count_type = unsigned;
auto multilinestrings1 = make_multilinestring_array({0, 1}, {0, 2}, {P{0, 0}, P{1, 1}});
auto multilinestrings2 = make_multilinestring_array({0, 1}, {0, 2}, {P{2, 2}, P{3, 3}});
rmm::device_vector<count_type> num_intersecting_points(multilinestrings1.size());
rmm::device_vector<count_type> num_overlapping_segments(multilinestrings1.size());
std::vector<count_type> expected_intersecting_points_count{0};
std::vector<count_type> expected_overlapping_segment_count{0};
pairwise_linestring_intersection_upper_bound_count(multilinestrings1.range(),
multilinestrings2.range(),
num_intersecting_points.begin(),
num_overlapping_segments.begin(),
this->default_stream());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(num_intersecting_points, expected_intersecting_points_count);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(num_overlapping_segments, expected_overlapping_segment_count);
}
TYPED_TEST(LinestringIntersectionCountTest, SingleToSingleSimpleDisjoint2)
{
using T = TypeParam;
using P = vec_2d<T>;
using count_type = unsigned;
auto multilinestrings1 = make_multilinestring_array({0, 1}, {0, 2}, {P{0, 0}, P{1, 1}});
auto multilinestrings2 = make_multilinestring_array({0, 1}, {0, 2}, {P{1, 0}, P{2, 0}});
rmm::device_vector<count_type> num_intersecting_points(multilinestrings1.size());
rmm::device_vector<count_type> num_overlapping_segments(multilinestrings1.size());
std::vector<count_type> expected_intersecting_points_count{0};
std::vector<count_type> expected_overlapping_segment_count{0};
pairwise_linestring_intersection_upper_bound_count(multilinestrings1.range(),
multilinestrings2.range(),
num_intersecting_points.begin(),
num_overlapping_segments.begin(),
this->default_stream());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(num_intersecting_points, expected_intersecting_points_count);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(num_overlapping_segments, expected_overlapping_segment_count);
}
// FIXME
TYPED_TEST(LinestringIntersectionCountTest, SingleToSingleIntersectOverlapSameVertex)
{
using T = TypeParam;
using P = vec_2d<T>;
using count_type = unsigned;
// The "upper bound intersection count" between
// (0, 1) -> (1, 0) -> (1, 1) -> (2, 1.5) and (0, 0) -> (1, 1) -> (2, 1)
// 5 intersection point(s) (1, 1) (4 times), (0.5, 0.5)
// 0 overlapping segment(s)
auto stream = this->default_stream();
auto multilinestrings1 = make_multilinestring_array({0, 1}, {0, 3}, {P{0, 0}, P{1, 1}, P{2, 1}});
auto multilinestrings2 =
make_multilinestring_array({0, 1}, {0, 4}, {P{0, 1}, P{1, 0}, P{1, 1}, P{2, 1.5}});
rmm::device_uvector<count_type> num_intersecting_points(multilinestrings1.size(), stream);
rmm::device_uvector<count_type> num_overlapping_segments(multilinestrings1.size(), stream);
thrust::uninitialized_fill_n(
rmm::exec_policy(stream), num_intersecting_points.begin(), multilinestrings1.size(), 0);
thrust::uninitialized_fill_n(
rmm::exec_policy(stream), num_overlapping_segments.begin(), multilinestrings1.size(), 0);
std::vector<count_type> expected_intersecting_points_count{5};
std::vector<count_type> expected_overlapping_segment_count{0};
pairwise_linestring_intersection_upper_bound_count(multilinestrings1.range(),
multilinestrings2.range(),
num_intersecting_points.begin(),
num_overlapping_segments.begin(),
this->default_stream());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(num_intersecting_points, expected_intersecting_points_count);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(num_overlapping_segments, expected_overlapping_segment_count);
}
TYPED_TEST(LinestringIntersectionCountTest, SingleToSingleExample)
{
using T = TypeParam;
using P = vec_2d<T>;
// First pair:
// (0, 0), (1, 1)
// Second pair:
// (1, 0), (0,1)
// (0.5, 0), (0, 0.5), (1, 0.5)
// (0.5, 0.5), (1.5, 1.5)
// (-1, -1), (0.25, 0.25), (0.25, 0.0), (0.75, 0.75), (1.5, 1.5)
// (0.25, 0.0), (0.25, 0.5), (0.75, 0.75), (1.5, 1.5)
// (2,2), (3,3)
// (1, 0), (2, 0)
// Result:
// intersecting points (upper bound):
// 1, 2, 0, 2, 2, 0, 0
// ^ ^
// row[3] points: (0.25, 0.25) and (0.75, 0.75)
// row[4] points: (0.25, 0.25) and (0.75, 0.75)
// overlapping segments (upper bound):
// 0, 0, 1, 2, 1, 0, 0
auto multilinestrings1 = make_multilinestring_array({0, 1, 2, 3, 4, 5, 6, 7},
{0, 2, 4, 6, 8, 10, 12, 14},
{P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1},
P{0, 0},
P{1, 1}});
auto multilinestrings2 = make_multilinestring_array(
{0, 1, 2, 3, 4, 5, 6, 7},
{0, 2, 5, 7, 12, 16, 18, 20},
{P{1, 0}, P{0, 1}, P{0.5, 0}, P{0, 0.5}, P{1, 0.5},
P{0.5, 0.5}, P{1.5, 1.5}, P{-1, -1}, P{0.25, 0.25}, P{0.25, 0.0},
P{0.75, 0.75}, P{1.5, 1.5}, P{0.25, 0.0}, P{0.25, 0.5}, P{0.75, 0.75},
P{1.5, 1.5}, P{2, 2}, P{3, 3}, P{1, 0}, P{2, 0}});
rmm::device_vector<unsigned> num_intersecting_points(multilinestrings1.size(), 0);
rmm::device_vector<unsigned> num_overlapping_segments(multilinestrings1.size(), 0);
std::vector<unsigned> expected_intersecting_points_count{1, 2, 0, 2, 2, 0, 0};
std::vector<unsigned> expected_overlapping_segment_count{0, 0, 1, 2, 1, 0, 0};
pairwise_linestring_intersection_upper_bound_count(multilinestrings1.range(),
multilinestrings2.range(),
num_intersecting_points.begin(),
num_overlapping_segments.begin(),
this->default_stream());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(num_intersecting_points, expected_intersecting_points_count);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(num_overlapping_segments, expected_overlapping_segment_count);
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/nearest_points/point_linestring_nearest_points_test.cpp | /*
* 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 <cuspatial/error.hpp>
#include <cuspatial/geometry/vec_2d.hpp>
#include <cuspatial/nearest_points.hpp>
#include <cudf_test/column_utilities.hpp>
#include <cudf_test/column_wrapper.hpp>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
namespace cuspatial {
using namespace cudf;
using namespace cudf::test;
template <typename T>
struct PairwisePointLinestringNearestPointsTest : public ::testing::Test {};
using TestTypes = ::testing::Types<float, double>;
TYPED_TEST_CASE(PairwisePointLinestringNearestPointsTest, TestTypes);
TYPED_TEST(PairwisePointLinestringNearestPointsTest, Empty)
{
using T = TypeParam;
auto xy = fixed_width_column_wrapper<T>{};
auto offset = fixed_width_column_wrapper<size_type>{0};
auto line_xy = fixed_width_column_wrapper<T>{};
auto [point_idx, linestring_idx, segment_idx, nearest_points] =
pairwise_point_linestring_nearest_points(
std::nullopt, xy, std::nullopt, column_view(offset), line_xy);
auto expect_segment_idx = fixed_width_column_wrapper<size_type>{};
auto expect_nearest_points = fixed_width_column_wrapper<T>{};
EXPECT_EQ(point_idx, std::nullopt);
EXPECT_EQ(linestring_idx, std::nullopt);
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expect_segment_idx, *segment_idx);
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expect_nearest_points, *nearest_points);
}
TYPED_TEST(PairwisePointLinestringNearestPointsTest, SinglePointMultiLineString)
{
using T = TypeParam;
auto xy = fixed_width_column_wrapper<T>{0.0, 0.5};
auto line_geometry = fixed_width_column_wrapper<size_type>{0, 2};
auto line_offset = fixed_width_column_wrapper<size_type>{0, 3, 5};
auto line_xy = fixed_width_column_wrapper<T>{1.0, 1.0, 2.0, 2.0, 2.5, 1.3, -1.0, -3.6, -0.8, 1.0};
auto [point_idx, linestring_idx, segment_idx, nearest_points] =
pairwise_point_linestring_nearest_points(
std::nullopt, xy, column_view(line_geometry), column_view(line_offset), line_xy);
auto expect_linestring_idx = fixed_width_column_wrapper<size_type>{1};
auto expect_segment_idx = fixed_width_column_wrapper<size_type>{0};
auto expect_nearest_points =
fixed_width_column_wrapper<T>{-0.820188679245283, 0.5356603773584898};
EXPECT_EQ(point_idx, std::nullopt);
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expect_linestring_idx, *(linestring_idx.value()));
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expect_segment_idx, *segment_idx);
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expect_nearest_points, *nearest_points);
}
TYPED_TEST(PairwisePointLinestringNearestPointsTest, MultiPointSingleLineString)
{
using T = TypeParam;
auto point_geometry = fixed_width_column_wrapper<size_type>{0, 2};
auto xy = fixed_width_column_wrapper<T>{0.5, 0.5, 0.5, 0.0};
auto line_offset = fixed_width_column_wrapper<size_type>{0, 4};
auto line_xy = fixed_width_column_wrapper<T>{0.0, 2.0, 2.0, 0.0, 0.0, -2.0, -2.0, 0.0};
auto [point_idx, linestring_idx, segment_idx, nearest_points] =
pairwise_point_linestring_nearest_points(
column_view(point_geometry), xy, std::nullopt, column_view(line_offset), line_xy);
auto expect_point_idx = fixed_width_column_wrapper<size_type>{0};
auto expect_segment_idx = fixed_width_column_wrapper<size_type>{0};
auto expect_nearest_points = fixed_width_column_wrapper<T>{1.0, 1.0};
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expect_point_idx, *(point_idx.value()));
EXPECT_EQ(linestring_idx, std::nullopt);
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expect_segment_idx, *segment_idx);
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expect_nearest_points, *nearest_points);
}
TYPED_TEST(PairwisePointLinestringNearestPointsTest, MultiPointMultiLineString)
{
using T = TypeParam;
auto point_geometry = fixed_width_column_wrapper<size_type>{0, 2};
auto xy = fixed_width_column_wrapper<T>{-0.5, 0.0, 0.0, 1.0};
auto line_geometry = fixed_width_column_wrapper<size_type>{0, 2};
auto line_offset = fixed_width_column_wrapper<size_type>{0, 3, 6};
auto line_xy =
fixed_width_column_wrapper<T>{2.0, 2.0, 0.0, 0.0, 2.0, -2.0, -2.0, 2.0, 0.0, 0.0, -2.0, -2.0};
auto [point_idx, linestring_idx, segment_idx, nearest_points] =
pairwise_point_linestring_nearest_points(column_view(point_geometry),
xy,
column_view(line_geometry),
column_view(line_offset),
line_xy);
auto expect_point_idx = fixed_width_column_wrapper<size_type>{0};
auto expect_linestring_idx = fixed_width_column_wrapper<size_type>{1};
auto expect_segment_idx = fixed_width_column_wrapper<size_type>{0};
auto expect_nearest_points = fixed_width_column_wrapper<T>{-0.25, 0.25};
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expect_point_idx, *(point_idx.value()));
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expect_linestring_idx, *(linestring_idx.value()));
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expect_segment_idx, *segment_idx);
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(expect_nearest_points, *nearest_points);
}
struct PairwisePointLinestringNearestPointsThrowTest : public ::testing::Test {};
TEST_F(PairwisePointLinestringNearestPointsThrowTest, OddNumberOfCoordinates)
{
auto xy = fixed_width_column_wrapper<float>{1, 1, 2};
auto offset = fixed_width_column_wrapper<size_type>{0, 3};
auto line_xy = fixed_width_column_wrapper<float>{1, 1, 2, 2, 3, 3};
EXPECT_THROW(pairwise_point_linestring_nearest_points(
std::nullopt, xy, std::nullopt, column_view(offset), line_xy),
cuspatial::logic_error);
}
TEST_F(PairwisePointLinestringNearestPointsThrowTest, NumPairsMismatchSinglePointSingleLinestring)
{
auto xy = fixed_width_column_wrapper<float>{1, 1, 2, 2};
auto offset = fixed_width_column_wrapper<size_type>{0, 3};
auto line_xy = fixed_width_column_wrapper<float>{1, 1, 2, 2, 3, 3};
EXPECT_THROW(pairwise_point_linestring_nearest_points(
std::nullopt, xy, std::nullopt, column_view(offset), line_xy),
cuspatial::logic_error);
}
TEST_F(PairwisePointLinestringNearestPointsThrowTest, NumPairsMismatchSinglePointMultiLinestring)
{
auto xy = fixed_width_column_wrapper<float>{1, 1, 2, 2};
auto line_geometry = fixed_width_column_wrapper<size_type>{0, 2};
auto offset = fixed_width_column_wrapper<size_type>{0, 3, 5};
auto line_xy = fixed_width_column_wrapper<float>{1, 1, 2, 2, 3, 3, 4, 4, 5, 5};
EXPECT_THROW(pairwise_point_linestring_nearest_points(
std::nullopt, xy, column_view(line_geometry), column_view(offset), line_xy),
cuspatial::logic_error);
}
TEST_F(PairwisePointLinestringNearestPointsThrowTest, NumPairsMismatchMultiPointSingleLinestring)
{
auto point_geometry = fixed_width_column_wrapper<size_type>{0, 2, 4};
auto xy = fixed_width_column_wrapper<float>{1, 1, 2, 2, 3, 3, 4, 4};
auto offset = fixed_width_column_wrapper<size_type>{0, 3};
auto line_xy = fixed_width_column_wrapper<float>{1, 1, 2, 2, 3, 3};
EXPECT_THROW(pairwise_point_linestring_nearest_points(
column_view(point_geometry), xy, std::nullopt, column_view(offset), line_xy),
cuspatial::logic_error);
}
TEST_F(PairwisePointLinestringNearestPointsThrowTest, NumPairsMismatchMultiPointMultiLinestring)
{
auto point_geometry = fixed_width_column_wrapper<size_type>{0, 2, 4};
auto xy = fixed_width_column_wrapper<float>{1, 1, 2, 2, 3, 3, 4, 4};
auto linestring_geometry = fixed_width_column_wrapper<size_type>{0, 2, 4, 6};
auto offset = fixed_width_column_wrapper<size_type>{0, 2, 4, 6, 8, 10};
auto line_xy =
fixed_width_column_wrapper<float>{1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10};
EXPECT_THROW(pairwise_point_linestring_nearest_points(
column_view(point_geometry), xy, std::nullopt, column_view(offset), line_xy),
cuspatial::logic_error);
}
TEST_F(PairwisePointLinestringNearestPointsThrowTest, MismatchType)
{
auto point_geometry = fixed_width_column_wrapper<size_type>{0, 2, 4};
auto xy = fixed_width_column_wrapper<float>{1, 1, 2, 2, 3, 3, 4, 4};
auto linestring_geometry = fixed_width_column_wrapper<size_type>{0, 2, 4};
auto offset = fixed_width_column_wrapper<size_type>{0, 2, 4, 6};
auto line_xy = fixed_width_column_wrapper<double>{1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6};
EXPECT_THROW(pairwise_point_linestring_nearest_points(
column_view(point_geometry), xy, std::nullopt, column_view(offset), line_xy),
cuspatial::logic_error);
}
TEST_F(PairwisePointLinestringNearestPointsThrowTest, ContainsNull)
{
auto point_geometry = fixed_width_column_wrapper<size_type>{0, 2, 4};
auto xy = fixed_width_column_wrapper<float>{{1, 1, 2, 2, 3, 3, 4, 4}, {1, 0, 1, 1, 1, 1, 1, 1}};
auto linestring_geometry = fixed_width_column_wrapper<size_type>{0, 2, 4};
auto offset = fixed_width_column_wrapper<size_type>{0, 2, 4, 6};
auto line_xy = fixed_width_column_wrapper<float>{1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6};
EXPECT_THROW(pairwise_point_linestring_nearest_points(
column_view(point_geometry), xy, std::nullopt, column_view(offset), line_xy),
cuspatial::logic_error);
}
} // namespace cuspatial
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/nearest_points/point_linestring_nearest_points_test.cu | /*
* 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 <cuspatial_test/vector_equality.hpp>
#include <cuspatial/error.hpp>
#include <cuspatial/geometry/vec_2d.hpp>
#include <cuspatial/iterator_factory.cuh>
#include <cuspatial/nearest_points.cuh>
#include <rmm/device_vector.hpp>
#include <thrust/host_vector.h>
#include <thrust/iterator/constant_iterator.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/iterator/discard_iterator.h>
#include <type_traits>
using namespace cuspatial;
using namespace cuspatial::test;
template <typename T>
struct PairwisePointLinestringNearestPointsTest : public ::testing::Test {};
// float and double are logically the same but would require separate tests due to precision.
using TestTypes = ::testing::Types<float, double>;
TYPED_TEST_CASE(PairwisePointLinestringNearestPointsTest, TestTypes);
TYPED_TEST(PairwisePointLinestringNearestPointsTest, Empty)
{
using T = TypeParam;
using CartVec = std::vector<vec_2d<T>>;
auto num_pairs = 0;
auto points_geometry_it = thrust::make_counting_iterator(0);
auto points_it = rmm::device_vector<vec_2d<T>>(CartVec{});
auto linestring_geometry_it = thrust::make_counting_iterator(0);
auto linestring_part_offsets = rmm::device_vector<int32_t>(std::vector<int32_t>{0});
auto linestring_points_it = rmm::device_vector<vec_2d<T>>(CartVec{});
auto nearest_point_id = rmm::device_vector<int32_t>(num_pairs);
auto nearest_linestring_parts_id = rmm::device_vector<int32_t>(num_pairs);
auto nearest_linestring_segment_id = rmm::device_vector<int32_t>(0);
auto neartest_point_coordinate = rmm::device_vector<vec_2d<T>>(0);
auto output_it =
thrust::make_zip_iterator(thrust::make_tuple(nearest_point_id.begin(),
nearest_linestring_parts_id.begin(),
nearest_linestring_segment_id.begin(),
neartest_point_coordinate.begin()));
auto ret = pairwise_point_linestring_nearest_points(points_geometry_it,
points_geometry_it + num_pairs + 1,
points_it.begin(),
points_it.end(),
linestring_geometry_it,
linestring_part_offsets.begin(),
linestring_part_offsets.end(),
linestring_points_it.begin(),
linestring_points_it.end(),
output_it);
EXPECT_EQ(nearest_point_id, std::vector<int32_t>{});
EXPECT_EQ(nearest_linestring_parts_id, std::vector<int32_t>{});
EXPECT_EQ(nearest_linestring_segment_id, std::vector<int32_t>{});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(neartest_point_coordinate, std::vector<vec_2d<T>>{});
EXPECT_EQ(std::distance(output_it, ret), num_pairs);
}
TYPED_TEST(PairwisePointLinestringNearestPointsTest, OnePairSingleComponent)
{
using T = TypeParam;
using CartVec = std::vector<vec_2d<T>>;
auto num_pairs = 1;
auto points_geometry_it = thrust::make_counting_iterator(0);
auto points_it = rmm::device_vector<vec_2d<T>>(CartVec{{0, 0}});
auto linestring_geometry_it = thrust::make_counting_iterator(0);
auto linestring_part_offsets = rmm::device_vector<int32_t>(std::vector<int32_t>{0, 3});
auto linestring_points_it = rmm::device_vector<vec_2d<T>>(CartVec{{1, -1}, {1, 0}, {0, 1}});
auto nearest_linestring_segment_id = rmm::device_vector<int32_t>(num_pairs);
auto neartest_point_coordinate = rmm::device_vector<vec_2d<T>>(num_pairs);
auto output_it =
thrust::make_zip_iterator(thrust::make_tuple(thrust::make_discard_iterator(),
thrust::make_discard_iterator(),
nearest_linestring_segment_id.begin(),
neartest_point_coordinate.begin()));
auto ret = pairwise_point_linestring_nearest_points(points_geometry_it,
points_geometry_it + num_pairs + 1,
points_it.begin(),
points_it.end(),
linestring_geometry_it,
linestring_part_offsets.begin(),
linestring_part_offsets.end(),
linestring_points_it.begin(),
linestring_points_it.end(),
output_it);
EXPECT_EQ(nearest_linestring_segment_id, std::vector<int32_t>{1});
auto expected_coordinate = CartVec{{0.5, 0.5}};
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(neartest_point_coordinate, expected_coordinate);
EXPECT_EQ(std::distance(output_it, ret), num_pairs);
}
TYPED_TEST(PairwisePointLinestringNearestPointsTest, NearestAtLeftEndPoint)
{
using T = TypeParam;
using CartVec = std::vector<vec_2d<T>>;
auto num_pairs = 1;
auto points_geometry_it = thrust::make_counting_iterator(0);
auto points_it = rmm::device_vector<vec_2d<T>>(CartVec{{0, 0}});
auto linestring_geometry_it = thrust::make_counting_iterator(0);
auto linestring_part_offsets = rmm::device_vector<int32_t>(std::vector<int32_t>{0, 2});
auto linestring_points_it = rmm::device_vector<vec_2d<T>>(CartVec{{1, 1}, {2, 2}});
auto nearest_linestring_segment_id = rmm::device_vector<int32_t>(num_pairs);
auto neartest_point_coordinate = rmm::device_vector<vec_2d<T>>(num_pairs);
auto output_it =
thrust::make_zip_iterator(thrust::make_tuple(thrust::make_discard_iterator(),
thrust::make_discard_iterator(),
nearest_linestring_segment_id.begin(),
neartest_point_coordinate.begin()));
auto ret = pairwise_point_linestring_nearest_points(points_geometry_it,
points_geometry_it + num_pairs + 1,
points_it.begin(),
points_it.end(),
linestring_geometry_it,
linestring_part_offsets.begin(),
linestring_part_offsets.end(),
linestring_points_it.begin(),
linestring_points_it.end(),
output_it);
EXPECT_EQ(nearest_linestring_segment_id, std::vector<int32_t>{0});
auto expected_coordinate = CartVec{{1, 1}};
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(neartest_point_coordinate, expected_coordinate);
EXPECT_EQ(std::distance(output_it, ret), num_pairs);
}
TYPED_TEST(PairwisePointLinestringNearestPointsTest, NearestAtRightEndPoint)
{
using T = TypeParam;
using CartVec = std::vector<vec_2d<T>>;
auto num_pairs = 1;
auto points_geometry_it = thrust::make_counting_iterator(0);
auto points_it = rmm::device_vector<vec_2d<T>>(CartVec{{3, 3}});
auto linestring_geometry_it = thrust::make_counting_iterator(0);
auto linestring_part_offsets = rmm::device_vector<int32_t>(std::vector<int32_t>{0, 2});
auto linestring_points_it = rmm::device_vector<vec_2d<T>>(CartVec{{1, 1}, {2, 2}});
auto nearest_linestring_segment_id = rmm::device_vector<int32_t>(num_pairs);
auto neartest_point_coordinate = rmm::device_vector<vec_2d<T>>(num_pairs);
auto output_it =
thrust::make_zip_iterator(thrust::make_tuple(thrust::make_discard_iterator(),
thrust::make_discard_iterator(),
nearest_linestring_segment_id.begin(),
neartest_point_coordinate.begin()));
auto ret = pairwise_point_linestring_nearest_points(points_geometry_it,
points_geometry_it + num_pairs + 1,
points_it.begin(),
points_it.end(),
linestring_geometry_it,
linestring_part_offsets.begin(),
linestring_part_offsets.end(),
linestring_points_it.begin(),
linestring_points_it.end(),
output_it);
EXPECT_EQ(nearest_linestring_segment_id, std::vector<int32_t>{0});
auto expected_coordinate = CartVec{{2, 2}};
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(neartest_point_coordinate, expected_coordinate);
EXPECT_EQ(std::distance(output_it, ret), num_pairs);
}
TYPED_TEST(PairwisePointLinestringNearestPointsTest, PointAtEndPoints)
{
using T = TypeParam;
using CartVec = std::vector<vec_2d<T>>;
auto num_pairs = 3;
auto points_geometry_it = thrust::make_counting_iterator(0);
auto points_it = rmm::device_vector<vec_2d<T>>(CartVec{{0, 0}, {1, 1}, {2, 2}});
auto linestring_geometry_it = thrust::make_counting_iterator(0);
auto linestring_part_offsets = rmm::device_vector<int32_t>(std::vector<int32_t>{0, 3, 6, 9});
auto linestring_points_it = rmm::device_vector<vec_2d<T>>(
CartVec{{0, 0}, {1, 1}, {2, 2}, {0, 0}, {1, 1}, {2, 2}, {0, 0}, {1, 1}, {2, 2}});
auto nearest_linestring_segment_id = rmm::device_vector<int32_t>(num_pairs);
auto neartest_point_coordinate = rmm::device_vector<vec_2d<T>>(num_pairs);
auto output_it =
thrust::make_zip_iterator(thrust::make_tuple(thrust::make_discard_iterator(),
thrust::make_discard_iterator(),
nearest_linestring_segment_id.begin(),
neartest_point_coordinate.begin()));
auto ret = pairwise_point_linestring_nearest_points(points_geometry_it,
points_geometry_it + num_pairs + 1,
points_it.begin(),
points_it.end(),
linestring_geometry_it,
linestring_part_offsets.begin(),
linestring_part_offsets.end(),
linestring_points_it.begin(),
linestring_points_it.end(),
output_it);
EXPECT_EQ(nearest_linestring_segment_id, std::vector<int32_t>({0, 0, 1}));
auto expected_coordinate = CartVec{{0, 0}, {1, 1}, {2, 2}};
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(neartest_point_coordinate, expected_coordinate);
EXPECT_EQ(std::distance(output_it, ret), num_pairs);
}
TYPED_TEST(PairwisePointLinestringNearestPointsTest, PointOnLineString)
{
using T = TypeParam;
using CartVec = std::vector<vec_2d<T>>;
auto num_pairs = 2;
auto points_geometry_it = thrust::make_counting_iterator(0);
auto points_it = rmm::device_vector<vec_2d<T>>(CartVec{{0.5, 0.5}, {1.5, 1.5}});
auto linestring_geometry_it = thrust::make_counting_iterator(0);
auto linestring_part_offsets = rmm::device_vector<int32_t>(std::vector<int32_t>{0, 3, 6});
auto linestring_points_it =
rmm::device_vector<vec_2d<T>>(CartVec{{0, 0}, {1, 1}, {2, 2}, {0, 0}, {1, 1}, {2, 2}});
auto nearest_linestring_segment_id = rmm::device_vector<int32_t>(num_pairs);
auto neartest_point_coordinate = rmm::device_vector<vec_2d<T>>(num_pairs);
auto output_it =
thrust::make_zip_iterator(thrust::make_tuple(thrust::make_discard_iterator(),
thrust::make_discard_iterator(),
nearest_linestring_segment_id.begin(),
neartest_point_coordinate.begin()));
auto ret = pairwise_point_linestring_nearest_points(points_geometry_it,
points_geometry_it + num_pairs + 1,
points_it.begin(),
points_it.end(),
linestring_geometry_it,
linestring_part_offsets.begin(),
linestring_part_offsets.end(),
linestring_points_it.begin(),
linestring_points_it.end(),
output_it);
EXPECT_EQ(nearest_linestring_segment_id, std::vector<int32_t>({0, 1}));
auto expected_coordinate = CartVec{{0.5, 0.5}, {1.5, 1.5}};
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(neartest_point_coordinate, expected_coordinate);
EXPECT_EQ(std::distance(output_it, ret), num_pairs);
}
TYPED_TEST(PairwisePointLinestringNearestPointsTest, TwoPairsSingleComponent)
{
using T = TypeParam;
using CartVec = std::vector<vec_2d<T>>;
auto num_pairs = 2;
auto points_geometry_it = thrust::make_counting_iterator(0);
auto points_it = rmm::device_vector<vec_2d<T>>(CartVec{{0, 0}, {1, 2}});
auto linestring_geometry_it = thrust::make_counting_iterator(0);
auto linestring_part_offsets = rmm::device_vector<int32_t>(std::vector<int32_t>{0, 3, 7});
auto linestring_points_it = rmm::device_vector<vec_2d<T>>(
CartVec{{1, -1}, {1, 0}, {0, 1}, {0, 0}, {3, 1}, {3.9, 4}, {5.5, 1.2}});
auto nearest_linestring_segment_id = rmm::device_vector<int32_t>(num_pairs);
auto neartest_point_coordinate = rmm::device_vector<vec_2d<T>>(num_pairs);
auto output_it =
thrust::make_zip_iterator(thrust::make_tuple(thrust::make_discard_iterator(),
thrust::make_discard_iterator(),
nearest_linestring_segment_id.begin(),
neartest_point_coordinate.begin()));
auto ret = pairwise_point_linestring_nearest_points(points_geometry_it,
points_geometry_it + num_pairs + 1,
points_it.begin(),
points_it.end(),
linestring_geometry_it,
linestring_part_offsets.begin(),
linestring_part_offsets.end(),
linestring_points_it.begin(),
linestring_points_it.end(),
output_it);
EXPECT_EQ(nearest_linestring_segment_id, std::vector<int32_t>({1, 0}));
auto expected_coordinate = CartVec{{0.5, 0.5}, {1.5, 0.5}};
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(neartest_point_coordinate, expected_coordinate);
EXPECT_EQ(std::distance(output_it, ret), num_pairs);
}
TYPED_TEST(PairwisePointLinestringNearestPointsTest, OnePairMultiComponent)
{
using T = TypeParam;
using CartVec = std::vector<vec_2d<T>>;
auto num_pairs = 1;
auto points_geometry_offsets = rmm::device_vector<int32_t>(std::vector<int>{0, 4});
auto points_it = rmm::device_vector<vec_2d<T>>(CartVec{{0, 0}, {1, 2}, {3, 4}, {5, 6}});
auto linestring_geometry_offsets = rmm::device_vector<int32_t>(std::vector<int>{0, 2});
auto linestring_part_offsets = rmm::device_vector<int32_t>(std::vector<int32_t>{0, 3, 5});
auto linestring_points = rmm::device_vector<vec_2d<T>>(
CartVec{{1.0, 1.5}, {2.3, 3.7}, {-5, 4.0}, {0.0, 1.0}, {-2.0, 0.5}});
auto nearest_point_id = rmm::device_vector<int32_t>(num_pairs);
auto nearest_linestring_linestring_id = rmm::device_vector<int32_t>(num_pairs);
auto nearest_linestring_segment_id = rmm::device_vector<int32_t>(num_pairs);
auto neartest_point_coordinate = rmm::device_vector<vec_2d<T>>(num_pairs);
auto output_it =
thrust::make_zip_iterator(thrust::make_tuple(nearest_point_id.begin(),
nearest_linestring_linestring_id.begin(),
nearest_linestring_segment_id.begin(),
neartest_point_coordinate.begin()));
auto ret = pairwise_point_linestring_nearest_points(points_geometry_offsets.begin(),
points_geometry_offsets.end(),
points_it.begin(),
points_it.end(),
linestring_geometry_offsets.begin(),
linestring_part_offsets.begin(),
linestring_part_offsets.end(),
linestring_points.begin(),
linestring_points.end(),
output_it);
EXPECT_EQ(nearest_point_id, std::vector<int32_t>({1}));
EXPECT_EQ(nearest_linestring_linestring_id, std::vector<int32_t>({0}));
EXPECT_EQ(nearest_linestring_segment_id, std::vector<int32_t>({0}));
auto expected_coordinate = CartVec{{1.2189892802450228, 1.8705972434915774}};
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(neartest_point_coordinate, expected_coordinate);
EXPECT_EQ(std::distance(output_it, ret), num_pairs);
}
TYPED_TEST(PairwisePointLinestringNearestPointsTest, ThreePairMultiComponent)
{
using T = TypeParam;
using CartVec = std::vector<vec_2d<T>>;
auto num_pairs = 3;
auto points_geometry_offsets = rmm::device_vector<int32_t>(std::vector<int>{0, 2, 3, 6});
auto points = rmm::device_vector<vec_2d<T>>(
CartVec{{1.1, 3.0}, {3.6, 2.4}, {10.0, 15.0}, {-5.0, -8.7}, {-6.28, -7.0}, {-10.0, -10.0}});
auto linestring_geometry_offsets = rmm::device_vector<int32_t>(std::vector<int>{0, 2, 4, 5});
auto linestring_part_offsets =
rmm::device_vector<int32_t>(std::vector<int32_t>{0, 3, 5, 7, 9, 13});
auto linestring_points_it = rmm::device_vector<vec_2d<T>>(CartVec{{2.1, 3.14},
{8.4, -0.5},
{6.0, 1.4},
{-1.0, 0.0},
{-1.7, 0.83},
{20.14, 13.5},
{18.3, 14.3},
{8.34, 9.1},
{9.9, 9.4},
{-20.0, 0.0},
{-15.0, -15.0},
{0.0, -18.0},
{0.0, 0.0}});
auto nearest_point_id = rmm::device_vector<int32_t>(num_pairs);
auto nearest_linestring_id = rmm::device_vector<int32_t>(num_pairs);
auto nearest_segment_id = rmm::device_vector<int32_t>(num_pairs);
auto neartest_point_coordinate = rmm::device_vector<vec_2d<T>>(num_pairs);
auto output_it = thrust::make_zip_iterator(thrust::make_tuple(nearest_point_id.begin(),
nearest_linestring_id.begin(),
nearest_segment_id.begin(),
neartest_point_coordinate.begin()));
auto ret = pairwise_point_linestring_nearest_points(points_geometry_offsets.begin(),
points_geometry_offsets.end(),
points.begin(),
points.end(),
linestring_geometry_offsets.begin(),
linestring_part_offsets.begin(),
linestring_part_offsets.end(),
linestring_points_it.begin(),
linestring_points_it.end(),
output_it);
EXPECT_EQ(thrust::host_vector<int32_t>(nearest_point_id), std::vector<int32_t>({1, 0, 0}));
EXPECT_EQ(thrust::host_vector<int32_t>(nearest_linestring_id), std::vector<int32_t>({0, 1, 0}));
EXPECT_EQ(thrust::host_vector<int32_t>(nearest_segment_id), std::vector<int32_t>({0, 0, 2}));
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(
neartest_point_coordinate,
CartVec{{3.545131432802666, 2.30503517215846}, {9.9, 9.4}, {0.0, -8.7}});
EXPECT_EQ(std::distance(output_it, ret), num_pairs);
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/point_in_polygon/point_in_polygon_test.cpp | /*
* Copyright (c) 2019-2020, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cuspatial/error.hpp>
#include <cuspatial/point_in_polygon.hpp>
#include <cudf_test/base_fixture.hpp>
#include <cudf_test/column_utilities.hpp>
#include <cudf_test/column_wrapper.hpp>
#include <cudf_test/cudf_gtest.hpp>
#include <cudf_test/type_lists.hpp>
#include <type_traits>
using namespace cudf::test;
template <typename T, typename R = T>
using wrapper = fixed_width_column_wrapper<T, R>;
template <typename T>
struct PointInPolygonTest : public BaseFixture {};
// float and double are logically the same but would require separate tests due to precision.
using TestTypes = FloatingPointTypes;
TYPED_TEST_CASE(PointInPolygonTest, TestTypes);
constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::ALL_ERRORS};
TYPED_TEST(PointInPolygonTest, Empty)
{
using T = TypeParam;
auto test_point_xs = wrapper<T>({0});
auto test_point_ys = wrapper<T>({0});
auto poly_offsets = wrapper<cudf::size_type>({0});
auto poly_ring_offsets = wrapper<cudf::size_type>({0});
auto poly_point_xs = wrapper<T>({});
auto poly_point_ys = wrapper<T>({});
auto expected = wrapper<int32_t>({0b0});
auto actual = cuspatial::point_in_polygon(
test_point_xs, test_point_ys, poly_offsets, poly_ring_offsets, poly_point_xs, poly_point_ys);
CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, actual->view(), verbosity);
}
template <typename T>
struct PointInPolygonUnsupportedTypesTest : public BaseFixture {};
using UnsupportedTestTypes = RemoveIf<ContainedIn<TestTypes>, NumericTypes>;
TYPED_TEST_CASE(PointInPolygonUnsupportedTypesTest, UnsupportedTestTypes);
TYPED_TEST(PointInPolygonUnsupportedTypesTest, UnsupportedPointType)
{
using T = TypeParam;
auto test_point_xs = wrapper<T>({0.0, 0.0});
auto test_point_ys = wrapper<T>({0.0});
auto poly_offsets = wrapper<cudf::size_type>({0});
auto poly_ring_offsets = wrapper<cudf::size_type>({0});
auto poly_point_xs = wrapper<T>({0.0, 1.0, 0.0, -1.0});
auto poly_point_ys = wrapper<T>({1.0, 0.0, -1.0, 0.0});
EXPECT_THROW(
cuspatial::point_in_polygon(
test_point_xs, test_point_ys, poly_offsets, poly_ring_offsets, poly_point_xs, poly_point_ys),
cuspatial::logic_error);
}
template <typename T>
struct PointInPolygonUnsupportedChronoTypesTest : public BaseFixture {};
TYPED_TEST_CASE(PointInPolygonUnsupportedChronoTypesTest, ChronoTypes);
TYPED_TEST(PointInPolygonUnsupportedChronoTypesTest, UnsupportedPointChronoType)
{
using T = TypeParam;
using R = typename T::rep;
auto test_point_xs = wrapper<T, R>({R{0}, R{0}});
auto test_point_ys = wrapper<T, R>({R{0}});
auto poly_offsets = wrapper<cudf::size_type>({0});
auto poly_ring_offsets = wrapper<cudf::size_type>({0});
auto poly_point_xs = wrapper<T, R>({R{0}, R{1}, R{0}, R{-1}});
auto poly_point_ys = wrapper<T, R>({R{1}, R{0}, R{-1}, R{0}});
EXPECT_THROW(
cuspatial::point_in_polygon(
test_point_xs, test_point_ys, poly_offsets, poly_ring_offsets, poly_point_xs, poly_point_ys),
cuspatial::logic_error);
}
struct PointInPolygonErrorTest : public BaseFixture {};
TEST_F(PointInPolygonErrorTest, EmptyPolygonOffsets)
{
using T = double;
auto test_point_xs = wrapper<T>({0});
auto test_point_ys = wrapper<T>({0});
auto poly_offsets = wrapper<cudf::size_type>({}); // empty lists have a single offset
auto poly_ring_offsets = wrapper<cudf::size_type>({});
auto poly_point_xs = wrapper<T>({});
auto poly_point_ys = wrapper<T>({});
EXPECT_THROW(
cuspatial::point_in_polygon(
test_point_xs, test_point_ys, poly_offsets, poly_ring_offsets, poly_point_xs, poly_point_ys),
cuspatial::logic_error);
}
TEST_F(PointInPolygonErrorTest, EmptyTestPointsReturnsEmpty)
{
using T = double;
auto test_point_xs = wrapper<T>({});
auto test_point_ys = wrapper<T>({});
auto poly_offsets = wrapper<cudf::size_type>({}); // empty lists have a single offset
auto poly_ring_offsets = wrapper<cudf::size_type>({});
auto poly_point_xs = wrapper<T>({});
auto poly_point_ys = wrapper<T>({});
auto expected = wrapper<int32_t>({});
auto actual = cuspatial::point_in_polygon(
test_point_xs, test_point_ys, poly_offsets, poly_ring_offsets, poly_point_xs, poly_point_ys);
CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, actual->view(), verbosity);
}
TEST_F(PointInPolygonErrorTest, MismatchTestPointXYLength)
{
using T = double;
auto test_point_xs = wrapper<T>({0.0, 0.0});
auto test_point_ys = wrapper<T>({0.0});
auto poly_offsets = wrapper<cudf::size_type>({0});
auto poly_ring_offsets = wrapper<cudf::size_type>({0});
auto poly_point_xs = wrapper<T>({0.0, 1.0, 0.0, -1.0});
auto poly_point_ys = wrapper<T>({1.0, 0.0, -1.0, 0.0});
EXPECT_THROW(
cuspatial::point_in_polygon(
test_point_xs, test_point_ys, poly_offsets, poly_ring_offsets, poly_point_xs, poly_point_ys),
cuspatial::logic_error);
}
TEST_F(PointInPolygonErrorTest, MismatchTestPointType)
{
using T = double;
auto test_point_xs = wrapper<T>({0.0, 0.0});
auto test_point_ys = wrapper<float>({0.0, 0.0});
auto poly_offsets = wrapper<cudf::size_type>({0});
auto poly_ring_offsets = wrapper<cudf::size_type>({0});
auto poly_point_xs = wrapper<T>({0.0, 1.0, 0.0});
auto poly_point_ys = wrapper<T>({1.0, 0.0, -1.0, 0.0});
EXPECT_THROW(
cuspatial::point_in_polygon(
test_point_xs, test_point_ys, poly_offsets, poly_ring_offsets, poly_point_xs, poly_point_ys),
cuspatial::logic_error);
}
TEST_F(PointInPolygonErrorTest, MismatchPolyPointXYLength)
{
using T = double;
auto test_point_xs = wrapper<T>({0.0, 0.0});
auto test_point_ys = wrapper<T>({0.0, 0.0});
auto poly_offsets = wrapper<cudf::size_type>({0});
auto poly_ring_offsets = wrapper<cudf::size_type>({0});
auto poly_point_xs = wrapper<T>({0.0, 1.0, 0.0});
auto poly_point_ys = wrapper<T>({1.0, 0.0, -1.0, 0.0});
EXPECT_THROW(
cuspatial::point_in_polygon(
test_point_xs, test_point_ys, poly_offsets, poly_ring_offsets, poly_point_xs, poly_point_ys),
cuspatial::logic_error);
}
TEST_F(PointInPolygonErrorTest, MismatchPolyPointType)
{
using T = double;
auto test_point_xs = wrapper<T>({0.0, 0.0});
auto test_point_ys = wrapper<T>({0.0, 0.0});
auto poly_offsets = wrapper<cudf::size_type>({0});
auto poly_ring_offsets = wrapper<cudf::size_type>({0});
auto poly_point_xs = wrapper<T>({0.0, 1.0, 0.0});
auto poly_point_ys = wrapper<float>({1.0, 0.0, -1.0, 0.0});
EXPECT_THROW(
cuspatial::point_in_polygon(
test_point_xs, test_point_ys, poly_offsets, poly_ring_offsets, poly_point_xs, poly_point_ys),
cuspatial::logic_error);
}
TEST_F(PointInPolygonErrorTest, MismatchPointTypes)
{
auto test_point_xs = wrapper<float>({0.0, 0.0});
auto test_point_ys = wrapper<float>({0.0, 0.0});
auto poly_offsets = wrapper<cudf::size_type>({0});
auto poly_ring_offsets = wrapper<cudf::size_type>({0});
auto poly_point_xs = wrapper<double>({0.0, 1.0, 0.0, -1.0});
auto poly_point_ys = wrapper<double>({1.0, 0.0, -1.0, 0.0});
EXPECT_THROW(
cuspatial::point_in_polygon(
test_point_xs, test_point_ys, poly_offsets, poly_ring_offsets, poly_point_xs, poly_point_ys),
cuspatial::logic_error);
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/point_in_polygon/point_in_polygon_test.cu | /*
* 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 <cuspatial_test/base_fixture.hpp>
#include <cuspatial_test/vector_equality.hpp>
#include <cuspatial_test/vector_factories.cuh>
#include <cuspatial/error.hpp>
#include <cuspatial/geometry/vec_2d.hpp>
#include <cuspatial/iterator_factory.cuh>
#include <cuspatial/point_in_polygon.cuh>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_vector.hpp>
#include <thrust/host_vector.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/iterator/transform_iterator.h>
#include <gtest/gtest.h>
using namespace cuspatial;
using namespace cuspatial::test;
template <typename T>
struct PointInPolygonTest : public BaseFixture {
public:
void run_test(std::initializer_list<vec_2d<T>> points,
std::initializer_list<int> polygon_offsets,
std::initializer_list<int> ring_offsets,
std::initializer_list<vec_2d<T>> polygon_points,
std::initializer_list<int32_t> expected)
{
auto d_points = make_device_vector<vec_2d<T>>(points);
auto d_polygon_offsets = make_device_vector<int>(polygon_offsets);
auto d_ring_offsets = make_device_vector<int>(ring_offsets);
auto d_polygon_points = make_device_vector<vec_2d<T>>(polygon_points);
auto mpoints = make_multipoint_range(
d_points.size(), thrust::make_counting_iterator(0), d_points.size(), d_points.begin());
auto mpolys = make_multipolygon_range(polygon_offsets.size() - 1,
thrust::make_counting_iterator(0),
d_polygon_offsets.size() - 1,
d_polygon_offsets.begin(),
d_ring_offsets.size() - 1,
d_ring_offsets.begin(),
d_polygon_points.size(),
d_polygon_points.begin());
auto d_expected = make_device_vector(expected);
auto got = rmm::device_uvector<int32_t>(points.size(), stream());
auto ret = point_in_polygon(mpoints, mpolys, got.begin(), stream());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_expected, got);
EXPECT_EQ(ret, got.end());
}
void run_spherical_test(std::initializer_list<vec_3d<T>> points,
std::initializer_list<int> polygon_offsets,
std::initializer_list<int> ring_offsets,
std::initializer_list<vec_3d<T>> polygon_points,
std::initializer_list<int32_t> expected)
{
auto d_points = make_device_vector<vec_3d<T>>(points);
auto d_polygon_offsets = make_device_vector<int>(polygon_offsets);
auto d_ring_offsets = make_device_vector<int>(ring_offsets);
auto d_polygon_points = make_device_vector<vec_3d<T>>(polygon_points);
auto mpoints = make_multipoint_range(
d_points.size(), thrust::make_counting_iterator(0), d_points.size(), d_points.begin());
auto mpolys = make_multipolygon_range(polygon_offsets.size() - 1,
thrust::make_counting_iterator(0),
d_polygon_offsets.size() - 1,
d_polygon_offsets.begin(),
d_ring_offsets.size() - 1,
d_ring_offsets.begin(),
d_polygon_points.size(),
d_polygon_points.begin());
auto d_expected = make_device_vector(expected);
auto got = rmm::device_uvector<int32_t>(points.size(), stream());
auto ret = point_in_polygon(mpoints, mpolys, got.begin(), stream());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_expected, got);
EXPECT_EQ(ret, got.end());
}
};
TYPED_TEST_CASE(PointInPolygonTest, FloatingPointTypes);
TYPED_TEST(PointInPolygonTest, OnePolygonOneRing)
{
CUSPATIAL_RUN_TEST(this->run_test,
{{-2.0, 0.0},
{2.0, 0.0},
{0.0, -2.0},
{0.0, 2.0},
{-0.5, 0.0},
{0.5, 0.0},
{0.0, -0.5},
{0.0, 0.5}},
{0, 1},
{0, 5},
{{-1.0, -1.0}, {1.0, -1.0}, {1.0, 1.0}, {-1.0, 1.0}, {-1.0, -1.0}},
{false, false, false, false, true, true, true, true});
}
TYPED_TEST(PointInPolygonTest, OnePolygonOneRingSpherical)
{
CUSPATIAL_RUN_TEST(this->run_spherical_test,
{{-2503.357, -4660.203, 3551.245},
{-2503.357, -4660.203, 3551.245},
{-2686.757, -4312.736, 3842.237},
{-2684.959, -4312.568, 3843.673},
{519.181, -5283.34, 3523.313}},
{0, 1},
{0, 5},
{{-2681.925, -4311.158, 3847.346}, // San Jose
{-2695.156, -4299.131, 3851.527}, // MTV
{-2691.386, -4313.414, 3838.26}, // Los Gatos
{-2673.88, -4319.257, 3843.883}, // East San Jose
{-2681.925, -4311.158, 3847.346}}, // San Jose
{false, false, true, true, false});
}
// cuspatial expects closed rings, however algorithms may work OK with unclosed rings
// in the future if we change to an algorithm that requires closed rings we may change or remove
// this test.
// Note that we don't introspect the values of offset arrays to validate closedness. So this test
// uses a polygon ring with 4 vertices so it doesn't fail polygon validation.
TYPED_TEST(PointInPolygonTest, OnePolygonOneRingUnclosed)
{
CUSPATIAL_RUN_TEST(this->run_test,
{{-2.0, 0.0},
{2.0, 0.0},
{0.0, -2.0},
{0.0, 2.0},
{-0.5, 0.0},
{0.5, 0.0},
{0.0, -0.5},
{0.0, 0.5}},
{0, 1},
{0, 4},
{{-1.0, -1.0}, {1.0, -1.0}, {1.0, 0.0}, {1.0, 1.0}},
{false, false, false, false, false, true, true, false});
}
TYPED_TEST(PointInPolygonTest, OnePolygonOneRingUnclosedSpherical)
{
CUSPATIAL_RUN_TEST(this->run_spherical_test,
{{-2503.357, -4660.203, 3551.245},
{-2503.357, -4660.203, 3551.245},
{-2686.757, -4312.736, 3842.237},
{-2684.959, -4312.568, 3843.673},
{519.181, -5283.34, 3523.313}},
{0, 1},
{0, 4},
{{-2681.925, -4311.158, 3847.346}, // San Jose
{-2695.156, -4299.131, 3851.527}, // MTV
{-2691.386, -4313.414, 3838.26}, // Los Gatos
{-2673.88, -4319.257, 3843.883}}, // East San Jose
{false, false, true, true, false});
}
TYPED_TEST(PointInPolygonTest, TwoPolygonsOneRingEach)
{
CUSPATIAL_RUN_TEST(this->run_test,
{{-2.0, 0.0},
{2.0, 0.0},
{0.0, -2.0},
{0.0, 2.0},
{-0.5, 0.0},
{0.5, 0.0},
{0.0, -0.5},
{0.0, 0.5}},
{0, 1, 2},
{0, 5, 10},
{{-1.0, -1.0},
{-1.0, 1.0},
{1.0, 1.0},
{1.0, -1.0},
{-1.0, -1.0},
{0.0, 1.0},
{1.0, 0.0},
{0.0, -1.0},
{-1.0, 0.0},
{0.0, 1.0}},
{0b00, 0b00, 0b00, 0b00, 0b11, 0b11, 0b11, 0b11});
}
TYPED_TEST(PointInPolygonTest, TwoPolygonsOneRingEachSpherical)
{
CUSPATIAL_RUN_TEST(this->run_spherical_test,
{{-2503.357, -4660.203, 3551.245},
{-2503.357, -4660.203, 3551.245},
{-2686.757, -4312.736, 3842.237},
{-2684.959, -4312.568, 3843.673},
{519.181, -5283.34, 3523.313}},
{0, 1, 2},
{0, 5, 10},
{{-2681.925, -4311.158, 3847.346}, // San Jose
{-2695.156, -4299.131, 3851.527}, // MTV
{-2691.386, -4313.414, 3838.26}, // Los Gatos
{-2673.88, -4319.257, 3843.883}, // East San Jose
{-2681.925, -4311.158, 3847.346}, // San Jose
{-2691.386, -4313.414, 3838.26}, // Los Gatos
{-2673.88, -4319.257, 3843.883}, // East San Jose
{-2681.925, -4311.158, 3847.346}, // San Jose
{-2695.156, -4299.131, 3851.527}, // MTV
{-2691.386, -4313.414, 3838.26}}, // Los Gatos
{0b00, 0b00, 0b11, 0b11, 0b00});
}
TYPED_TEST(PointInPolygonTest, OnePolygonTwoRings)
{
CUSPATIAL_RUN_TEST(this->run_test,
{{0.0, 0.0}, {-0.4, 0.0}, {-0.6, 0.0}, {0.0, 0.4}, {0.0, -0.6}},
{0, 2},
{0, 5, 10},
{{-1.0, -1.0},
{1.0, -1.0},
{1.0, 1.0},
{-1.0, 1.0},
{-1.0, -1.0},
{-0.5, -0.5},
{-0.5, 0.5},
{0.5, 0.5},
{0.5, -0.5},
{-0.5, -0.5}},
{0b0, 0b0, 0b1, 0b0, 0b1});
}
TYPED_TEST(PointInPolygonTest, OnePolygonTwoRingsSpherical)
{
CUSPATIAL_RUN_TEST(this->run_spherical_test,
{{-2503.357, -4660.203, 3551.245},
{-2503.357, -4660.203, 3551.245},
{-2686.757, -4312.736, 3842.237},
{-2684.959, -4312.568, 3843.673},
{519.181, -5283.34, 3523.313}},
{0, 2},
{0, 5, 10},
{
{-2867.9, -3750.684, 4273.764},
{-3346.365, -4376.427, 3203.156},
{-2010.426, -5129.275, 3203.156},
{-1722.974, -4395.889, 4273.764},
{-2867.9, -3750.684, 4273.764},
{-2681.925, -4311.158, 3847.346}, // San Jose
{-2673.88, -4319.257, 3843.883}, // East San Jose
{-2691.386, -4313.414, 3838.26}, // Los Gatos
{-2695.156, -4299.131, 3851.527}, // MTV
{-2681.925, -4311.158, 3847.346}, // San Jose
},
{0b1, 0b1, 0b0, 0b0, 0b0});
}
TYPED_TEST(PointInPolygonTest, EdgesOfSquare)
{
CUSPATIAL_RUN_TEST(
this->run_test,
{{0.0, 0.0}},
{0, 1, 2, 3, 4},
{0, 5, 10, 15, 20},
// 0: rect on min x side
// 1: rect on max x side
// 2: rect on min y side
// 3: rect on max y side
{{-1.0, -1.0}, {0.0, -1.0}, {0.0, 1.0}, {-1.0, 1.0}, {-1.0, -1.0}, {0.0, -1.0}, {1.0, -1.0},
{1.0, 1.0}, {0.0, 1.0}, {0.0, -1.0}, {-1.0, -1.0}, {-1.0, 0.0}, {1.0, 0.0}, {1.0, -1.0},
{-1.0, 1.0}, {-1.0, 0.0}, {-1.0, 1.0}, {1.0, 1.0}, {1.0, 0.0}, {-1.0, 0.0}},
{0b0000});
}
TYPED_TEST(PointInPolygonTest, CornersOfSquare)
{
CUSPATIAL_RUN_TEST(
this->run_test,
{{0.0, 0.0}},
{0, 1, 2, 3, 4},
{0, 5, 10, 15, 20},
// 0: min x min y corner
// 1: min x max y corner
// 2: max x min y corner
// 3: max x max y corner
{{-1.0, -1.0}, {-1.0, 0.0}, {0.0, 0.0}, {0.0, -1.0}, {-1.0, -1.0}, {-1.0, 0.0}, {-1.0, 1.0},
{0.0, 1.0}, {-1.0, 0.0}, {-1.0, 0.0}, {0.0, -1.0}, {0.0, 0.0}, {1.0, 0.0}, {1.0, -1.0},
{0.0, -1.0}, {0.0, 0.0}, {0.0, 1.0}, {1.0, 1.0}, {1.0, 0.0}, {0.0, 0.0}},
{0b0000});
}
TYPED_TEST(PointInPolygonTest, OnePolygonOneRingDifferentHemisphereSpherical)
{
CUSPATIAL_RUN_TEST(this->run_spherical_test,
{{0, 1.0, 0},
{0.5773502, -0.5773502, -0.5773502},
{-0.5773502, -0.5773502, -0.5773502},
{-0.5773502, -0.5773502, 0.5773502}},
{0, 1},
{0, 5},
{{-0.5773502, 0.5773502, 0.5773502},
{0.5773502, 0.5773502, 0.5773502},
{0.5773502, 0.5773502, -0.5773502},
{-0.5773502, 0.5773502, -0.5773502},
{-0.5773502, 0.5773502, 0.5773502}},
{true, false, false, false});
}
struct OffsetIteratorFunctor {
std::size_t __device__ operator()(std::size_t idx) { return idx * 5; }
};
template <typename T>
struct PolyPointIteratorFunctorA {
T __device__ operator()(std::size_t idx)
{
switch (idx % 5) {
case 0:
case 1: return -1.0;
case 2:
case 3: return 1.0;
case 4:
default: return -1.0;
}
}
};
template <typename T>
struct PolyPointIteratorFunctorB {
T __device__ operator()(std::size_t idx)
{
switch (idx % 5) {
case 0: return -1.0;
case 1:
case 2: return 1.0;
case 3:
case 4:
default: return -1.0;
}
}
};
TYPED_TEST(PointInPolygonTest, 31PolygonSupport)
{
using T = TypeParam;
auto constexpr num_polys = 31;
auto constexpr num_poly_points = num_polys * 5;
auto test_point = make_device_vector<vec_2d<T>>({{0.0, 0.0}, {2.0, 0.0}});
auto offsets_iter = thrust::make_counting_iterator<std::size_t>(0);
auto poly_ring_offsets_iter =
thrust::make_transform_iterator(offsets_iter, OffsetIteratorFunctor{});
auto poly_point_xs_iter =
thrust::make_transform_iterator(offsets_iter, PolyPointIteratorFunctorA<T>{});
auto poly_point_ys_iter =
thrust::make_transform_iterator(offsets_iter, PolyPointIteratorFunctorB<T>{});
auto poly_point_iter = make_vec_2d_iterator(poly_point_xs_iter, poly_point_ys_iter);
auto points_range = make_multipoint_range(
test_point.size(), thrust::make_counting_iterator(0), test_point.size(), test_point.begin());
auto polygons_range = make_multipolygon_range(num_polys,
thrust::make_counting_iterator(0),
num_polys,
offsets_iter,
num_polys,
poly_ring_offsets_iter,
num_poly_points,
poly_point_iter);
auto expected =
std::vector<int32_t>({0b1111111111111111111111111111111, 0b0000000000000000000000000000000});
auto got = rmm::device_vector<int32_t>(test_point.size());
auto ret = point_in_polygon(points_range, polygons_range, got.begin());
EXPECT_EQ(got, expected);
EXPECT_EQ(ret, got.end());
}
TYPED_TEST(PointInPolygonTest, SelfClosingLoopLeftEdgeMissing)
{
CUSPATIAL_RUN_TEST(this->run_test,
{{-2.0, 0.0}, {0.0, 0.0}, {2.0, 0.0}},
{0, 1},
{0, 4},
// "left" edge missing
{{-1, 1}, {1, 1}, {1, -1}, {-1, -1}},
{0b0, 0b1, 0b0});
}
TYPED_TEST(PointInPolygonTest, SelfClosingLoopRightEdgeMissing)
{
using T = TypeParam;
CUSPATIAL_RUN_TEST(this->run_test,
{{-2.0, 0.0}, {0.0, 0.0}, {2.0, 0.0}},
{0, 1},
{0, 4},
// "right" edge missing
{{1, -1}, {-1, -1}, {-1, 1}, {1, 1}},
{0b0, 0b1, 0b0});
}
TYPED_TEST(PointInPolygonTest, ContainsButCollinearWithBoundary)
{
using T = TypeParam;
CUSPATIAL_RUN_TEST(
this->run_test,
{{0.5, 0.5}},
{0, 1},
{0, 9},
{{0, 0}, {0, 1}, {1, 1}, {1, 0.5}, {1.5, 0.5}, {1.5, 1}, {2, 1}, {2, 0}, {0, 0}},
{0b1});
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/point_in_polygon/pairwise_point_in_polygon_test.cu | /*
* 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 <cuspatial_test/base_fixture.hpp>
#include <cuspatial_test/vector_equality.hpp>
#include <cuspatial_test/vector_factories.cuh>
#include <cuspatial/error.hpp>
#include <cuspatial/geometry/vec_2d.hpp>
#include <cuspatial/iterator_factory.cuh>
#include <cuspatial/point_in_polygon.cuh>
#include <rmm/device_vector.hpp>
#include <thrust/host_vector.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/iterator/transform_iterator.h>
#include <initializer_list>
using namespace cuspatial;
using namespace cuspatial::test;
template <typename T>
struct PairwisePointInPolygonTest : public BaseFixture {
void run_test(std::initializer_list<vec_2d<T>> points,
std::initializer_list<int> polygon_offsets,
std::initializer_list<int> ring_offsets,
std::initializer_list<vec_2d<T>> polygon_points,
std::initializer_list<uint8_t> expected)
{
auto d_points = make_device_vector<vec_2d<T>>(points);
auto d_polygon_offsets = make_device_vector<int>(polygon_offsets);
auto d_ring_offsets = make_device_vector<int>(ring_offsets);
auto d_polygon_points = make_device_vector<vec_2d<T>>(polygon_points);
auto mpoints = make_multipoint_range(
d_points.size(), thrust::make_counting_iterator(0), d_points.size(), d_points.begin());
auto mpolys = make_multipolygon_range(polygon_offsets.size() - 1,
thrust::make_counting_iterator(0),
d_polygon_offsets.size() - 1,
d_polygon_offsets.begin(),
d_ring_offsets.size() - 1,
d_ring_offsets.begin(),
d_polygon_points.size(),
d_polygon_points.begin());
auto d_expected = make_device_vector(expected);
auto got = rmm::device_uvector<uint8_t>(points.size(), stream());
auto ret = pairwise_point_in_polygon(mpoints, mpolys, got.begin(), stream());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_expected, got);
EXPECT_EQ(ret, got.end());
}
};
// float and double are logically the same but would require separate tests due to precision.
TYPED_TEST_CASE(PairwisePointInPolygonTest, FloatingPointTypes);
TYPED_TEST(PairwisePointInPolygonTest, OnePolygonOneRing)
{
using T = TypeParam;
auto point_list = std::vector<vec_2d<T>>{{-2.0, 0.0},
{2.0, 0.0},
{0.0, -2.0},
{0.0, 2.0},
{-0.5, 0.0},
{0.5, 0.0},
{0.0, -0.5},
{0.0, 0.5}};
auto poly_offsets = make_device_vector({0, 1});
auto poly_ring_offsets = make_device_vector({0, 5});
auto poly_point = make_device_vector<vec_2d<T>>(
{{-1.0, -1.0}, {1.0, -1.0}, {1.0, 1.0}, {-1.0, 1.0}, {-1.0, -1.0}});
auto polygon_range = make_multipolygon_range(poly_offsets.size() - 1,
thrust::make_counting_iterator(0),
poly_offsets.size() - 1,
poly_offsets.begin(),
poly_ring_offsets.size() - 1,
poly_ring_offsets.begin(),
poly_point.size(),
poly_point.begin());
auto got = rmm::device_vector<uint8_t>(1);
auto expected =
cuspatial::test::make_host_vector({false, false, false, false, true, true, true, true});
for (size_t i = 0; i < point_list.size(); ++i) {
auto p = point_list[i];
auto d_point = make_device_vector<vec_2d<T>>({{p.x, p.y}});
auto point_range = make_multipoint_range(
d_point.size(), thrust::make_counting_iterator(0), d_point.size(), d_point.begin());
auto ret = pairwise_point_in_polygon(point_range, polygon_range, got.begin(), this->stream());
EXPECT_EQ(got, std::vector<uint8_t>({expected[i]}));
EXPECT_EQ(ret, got.end());
}
}
TYPED_TEST(PairwisePointInPolygonTest, TwoPolygonsOneRingEach)
{
using T = TypeParam;
auto point_list = std::vector<vec_2d<T>>{{-2.0, 0.0},
{2.0, 0.0},
{0.0, -2.0},
{0.0, 2.0},
{-0.5, 0.0},
{0.5, 0.0},
{0.0, -0.5},
{0.0, 0.5}};
auto poly_offsets = make_device_vector({0, 1, 2});
auto poly_ring_offsets = make_device_vector({0, 5, 10});
auto poly_point = make_device_vector<vec_2d<T>>({{-1.0, -1.0},
{-1.0, 1.0},
{1.0, 1.0},
{1.0, -1.0},
{-1.0, -1.0},
{0.0, 1.0},
{1.0, 0.0},
{0.0, -1.0},
{-1.0, 0.0},
{0.0, 1.0}});
auto polygon_range = make_multipolygon_range(poly_offsets.size() - 1,
thrust::make_counting_iterator(0),
poly_offsets.size() - 1,
poly_offsets.begin(),
poly_ring_offsets.size() - 1,
poly_ring_offsets.begin(),
poly_point.size(),
poly_point.begin());
auto got = rmm::device_vector<uint8_t>(2);
auto expected = std::vector<uint8_t>({false, false, false, false, true, true, true, true});
for (size_t i = 0; i < point_list.size() / 2; i = i + 2) {
auto points = make_device_vector<vec_2d<T>>(
{{point_list[i].x, point_list[i].y}, {point_list[i + 1].x, point_list[i + 1].y}});
auto points_range = make_multipoint_range(
points.size(), thrust::make_counting_iterator(0), points.size(), points.begin());
auto ret = pairwise_point_in_polygon(points_range, polygon_range, got.begin(), this->stream());
EXPECT_EQ(got, std::vector<uint8_t>({expected[i], expected[i + 1]}));
EXPECT_EQ(ret, got.end());
}
}
TYPED_TEST(PairwisePointInPolygonTest, OnePolygonTwoRings)
{
using T = TypeParam;
auto point_list =
std::vector<std::vector<T>>{{0.0, 0.0}, {-0.4, 0.0}, {-0.6, 0.0}, {0.0, 0.4}, {0.0, -0.6}};
auto poly_offsets = make_device_vector({0, 2});
auto num_polys = poly_offsets.size() - 1;
auto poly_ring_offsets = make_device_vector({0, 5, 10});
auto poly_point = make_device_vector<vec_2d<T>>({{-1.0, -1.0},
{1.0, -1.0},
{1.0, 1.0},
{-1.0, 1.0},
{-1.0, -1.0},
{-0.5, -0.5},
{-0.5, 0.5},
{0.5, 0.5},
{0.5, -0.5},
{-0.5, -0.5}});
auto polygon_range = make_multipolygon_range(num_polys,
thrust::make_counting_iterator(0),
num_polys,
poly_offsets.begin(),
poly_ring_offsets.size() - 1,
poly_ring_offsets.begin(),
poly_point.size(),
poly_point.begin());
auto expected = std::vector<uint8_t>{0b0, 0b0, 0b1, 0b0, 0b1};
for (size_t i = 0; i < point_list.size(); ++i) {
auto got = rmm::device_vector<uint8_t>(1);
auto point = make_device_vector<vec_2d<T>>({{point_list[i][0], point_list[i][1]}});
auto points_range = make_multipoint_range(
point.size(), thrust::make_counting_iterator(0), point.size(), point.begin());
auto ret = pairwise_point_in_polygon(points_range, polygon_range, got.begin(), this->stream());
EXPECT_EQ(got, std::vector<uint8_t>{expected[i]});
EXPECT_EQ(ret, got.end());
}
}
TYPED_TEST(PairwisePointInPolygonTest, EdgesOfSquare)
{
// 0: rect on min x side
// 1: rect on max x side
// 2: rect on min y side
// 3: rect on max y side
CUSPATIAL_RUN_TEST(
this->run_test,
{{0.0, 0.0}, {0.0, 0.0}, {0.0, 0.0}, {0.0, 0.0}},
{0, 1, 2, 3, 4},
{0, 5, 10, 15, 20},
{{-1.0, -1.0}, {0.0, -1.0}, {0.0, 1.0}, {-1.0, 1.0}, {-1.0, -1.0}, {0.0, -1.0}, {1.0, -1.0},
{1.0, 1.0}, {0.0, 1.0}, {0.0, -1.0}, {-1.0, -1.0}, {-1.0, 0.0}, {1.0, 0.0}, {1.0, -1.0},
{-1.0, 1.0}, {-1.0, 0.0}, {-1.0, 1.0}, {1.0, 1.0}, {1.0, 0.0}, {-1.0, 0.0}},
{0b0, 0b0, 0b0, 0b0});
}
TYPED_TEST(PairwisePointInPolygonTest, CornersOfSquare)
{
// 0: min x min y corner
// 1: min x max y corner
// 2: max x min y corner
// 3: max x max y corner
CUSPATIAL_RUN_TEST(
this->run_test,
{{0.0, 0.0}, {0.0, 0.0}, {0.0, 0.0}, {0.0, 0.0}},
{0, 1, 2, 3, 4},
{0, 5, 10, 15, 20},
{{-1.0, -1.0}, {-1.0, 0.0}, {0.0, 0.0}, {0.0, -1.0}, {-1.0, -1.0}, {-1.0, 0.0}, {-1.0, 1.0},
{0.0, 1.0}, {-1.0, 0.0}, {-1.0, 0.0}, {0.0, -1.0}, {0.0, 0.0}, {1.0, 0.0}, {1.0, -1.0},
{0.0, -1.0}, {0.0, 0.0}, {0.0, 1.0}, {1.0, 1.0}, {1.0, 0.0}, {0.0, 0.0}},
{0b0, 0b0, 0b0, 0b0});
}
struct OffsetIteratorFunctor {
std::size_t __device__ operator()(std::size_t idx) { return idx * 5; }
};
template <typename T>
struct PolyPointIteratorFunctorA {
T __device__ operator()(std::size_t idx)
{
switch (idx % 5) {
case 0:
case 1: return -1.0;
case 2:
case 3: return 1.0;
case 4:
default: return -1.0;
}
}
};
template <typename T>
struct PolyPointIteratorFunctorB {
T __device__ operator()(std::size_t idx)
{
switch (idx % 5) {
case 0: return -1.0;
case 1:
case 2: return 1.0;
case 3:
case 4:
default: return -1.0;
}
}
};
TYPED_TEST(PairwisePointInPolygonTest, 32PolygonSupport)
{
using T = TypeParam;
auto constexpr num_polys = 32;
auto constexpr num_poly_points = num_polys * 5;
auto test_point = make_device_vector<vec_2d<T>>(
{{0.0, 0.0}, {2.0, 0.0}, {0.0, 0.0}, {2.0, 0.0}, {0.0, 0.0}, {2.0, 0.0}, {0.0, 0.0},
{2.0, 0.0}, {0.0, 0.0}, {2.0, 0.0}, {0.0, 0.0}, {2.0, 0.0}, {0.0, 0.0}, {2.0, 0.0},
{0.0, 0.0}, {2.0, 0.0}, {0.0, 0.0}, {2.0, 0.0}, {0.0, 0.0}, {2.0, 0.0}, {0.0, 0.0},
{2.0, 0.0}, {0.0, 0.0}, {2.0, 0.0}, {0.0, 0.0}, {2.0, 0.0}, {0.0, 0.0}, {2.0, 0.0},
{0.0, 0.0}, {2.0, 0.0}, {0.0, 0.0}, {2.0, 0.0}});
auto points_range = make_multipoint_range(
test_point.size(), thrust::make_counting_iterator(0), test_point.size(), test_point.begin());
auto offsets_iter = thrust::make_counting_iterator<std::size_t>(0);
auto poly_ring_offsets_iter =
thrust::make_transform_iterator(offsets_iter, OffsetIteratorFunctor{});
auto poly_point_xs_iter =
thrust::make_transform_iterator(offsets_iter, PolyPointIteratorFunctorA<T>{});
auto poly_point_ys_iter =
thrust::make_transform_iterator(offsets_iter, PolyPointIteratorFunctorB<T>{});
auto poly_point_iter = make_vec_2d_iterator(poly_point_xs_iter, poly_point_ys_iter);
auto polygons_range = make_multipolygon_range(num_polys,
thrust::make_counting_iterator(0),
num_polys,
offsets_iter,
num_polys,
poly_ring_offsets_iter,
num_poly_points,
poly_point_iter);
auto expected = std::vector<uint8_t>({1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0});
auto got = rmm::device_vector<uint8_t>(test_point.size());
auto ret = pairwise_point_in_polygon(points_range, polygons_range, got.begin(), this->stream());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(got, expected);
EXPECT_EQ(ret, got.end());
}
struct PairwisePointInPolygonErrorTest : public PairwisePointInPolygonTest<double> {};
TEST_F(PairwisePointInPolygonErrorTest, InsufficientPoints)
{
using T = double;
auto test_point = make_device_vector<vec_2d<T>>({{0.0, 0.0}, {0.0, 0.0}});
auto points_range = make_multipoint_range(
test_point.size(), thrust::make_counting_iterator(0), test_point.size(), test_point.begin());
auto poly_offsets = make_device_vector({0, 1});
auto num_polys = poly_offsets.size() - 1;
auto poly_ring_offsets = make_device_vector({0, 3});
auto poly_point = make_device_vector<vec_2d<T>>({{0.0, 1.0}, {1.0, 0.0}, {0.0, -1.0}});
auto polygons_range = make_multipolygon_range(num_polys,
thrust::make_counting_iterator(0),
num_polys,
poly_offsets.begin(),
num_polys,
poly_ring_offsets.begin(),
poly_point.size(),
poly_point.begin());
auto got = rmm::device_vector<uint8_t>(test_point.size());
EXPECT_THROW(pairwise_point_in_polygon(points_range, polygons_range, got.begin(), this->stream()),
cuspatial::logic_error);
}
TEST_F(PairwisePointInPolygonErrorTest, InsufficientPolyOffsets)
{
using T = double;
auto test_point = make_device_vector<vec_2d<T>>({{0.0, 0.0}, {0.0, 0.0}});
auto points_range = make_multipoint_range(
test_point.size(), thrust::make_counting_iterator(0), test_point.size(), test_point.begin());
auto poly_offsets = make_device_vector({0});
auto num_polys = poly_offsets.size() - 1;
auto poly_ring_offsets = make_device_vector({0, 4});
auto poly_point =
make_device_vector<vec_2d<T>>({{0.0, 1.0}, {1.0, 0.0}, {0.0, -1.0}, {0.0, 1.0}});
auto polygons_range = make_multipolygon_range(num_polys,
thrust::make_counting_iterator(0),
num_polys,
poly_offsets.begin(),
num_polys,
poly_ring_offsets.begin(),
poly_point.size(),
poly_point.begin());
auto got = rmm::device_vector<uint8_t>(test_point.size());
EXPECT_THROW(pairwise_point_in_polygon(points_range, polygons_range, got.begin(), this->stream()),
cuspatial::logic_error);
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/point_in_polygon/pairwise_point_in_polygon_test.cpp | /*
* 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 <cuspatial/error.hpp>
#include <cuspatial/point_in_polygon.hpp>
#include <cudf_test/base_fixture.hpp>
#include <cudf_test/column_utilities.hpp>
#include <cudf_test/column_wrapper.hpp>
#include <cudf_test/cudf_gtest.hpp>
#include <cudf_test/type_lists.hpp>
#include <type_traits>
using namespace cudf::test;
template <typename T, typename R = T>
using wrapper = fixed_width_column_wrapper<T, R>;
template <typename T>
struct PairwisePointInPolygonTest : public BaseFixture {};
// float and double are logically the same but would require separate tests due to precision.
using TestTypes = FloatingPointTypes;
TYPED_TEST_CASE(PairwisePointInPolygonTest, TestTypes);
constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::ALL_ERRORS};
TYPED_TEST(PairwisePointInPolygonTest, Empty)
{
using T = TypeParam;
auto test_point_xs = wrapper<T>({});
auto test_point_ys = wrapper<T>({});
auto poly_offsets = wrapper<cudf::size_type>({});
auto poly_ring_offsets = wrapper<cudf::size_type>({});
auto poly_point_xs = wrapper<T>({});
auto poly_point_ys = wrapper<T>({});
auto expected = wrapper<uint8_t>({});
auto actual = cuspatial::pairwise_point_in_polygon(
test_point_xs, test_point_ys, poly_offsets, poly_ring_offsets, poly_point_xs, poly_point_ys);
CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, actual->view(), verbosity);
}
template <typename T>
struct PairwisePointInPolygonUnsupportedTypesTest : public BaseFixture {};
using UnsupportedTestTypes = RemoveIf<ContainedIn<TestTypes>, NumericTypes>;
TYPED_TEST_CASE(PairwisePointInPolygonUnsupportedTypesTest, UnsupportedTestTypes);
TYPED_TEST(PairwisePointInPolygonUnsupportedTypesTest, UnsupportedPointType)
{
using T = TypeParam;
auto test_point_xs = wrapper<T>({0.0});
auto test_point_ys = wrapper<T>({0.0});
auto poly_offsets = wrapper<cudf::size_type>({0, 1});
auto poly_ring_offsets = wrapper<cudf::size_type>({0, 4});
auto poly_point_xs = wrapper<T>({0.0, 1.0, 0.0, -1.0});
auto poly_point_ys = wrapper<T>({1.0, 0.0, -1.0, 0.0});
EXPECT_THROW(
cuspatial::pairwise_point_in_polygon(
test_point_xs, test_point_ys, poly_offsets, poly_ring_offsets, poly_point_xs, poly_point_ys),
cuspatial::logic_error);
}
template <typename T>
struct PairwisePointInPolygonUnsupportedChronoTypesTest : public BaseFixture {};
TYPED_TEST_CASE(PairwisePointInPolygonUnsupportedChronoTypesTest, ChronoTypes);
TYPED_TEST(PairwisePointInPolygonUnsupportedChronoTypesTest, UnsupportedPointChronoType)
{
using T = TypeParam;
using R = typename T::rep;
auto test_point_xs = wrapper<T, R>({R{0}, R{0}});
auto test_point_ys = wrapper<T, R>({R{0}});
auto poly_offsets = wrapper<cudf::size_type>({0});
auto poly_ring_offsets = wrapper<cudf::size_type>({0});
auto poly_point_xs = wrapper<T, R>({R{0}, R{1}, R{0}, R{-1}});
auto poly_point_ys = wrapper<T, R>({R{1}, R{0}, R{-1}, R{0}});
EXPECT_THROW(
cuspatial::pairwise_point_in_polygon(
test_point_xs, test_point_ys, poly_offsets, poly_ring_offsets, poly_point_xs, poly_point_ys),
cuspatial::logic_error);
}
struct PairwisePointInPolygonErrorTest : public BaseFixture {};
TEST_F(PairwisePointInPolygonErrorTest, MismatchTestPointXYLength)
{
using T = double;
auto test_point_xs = wrapper<T>({0.0, 0.0});
auto test_point_ys = wrapper<T>({0.0});
auto poly_offsets = wrapper<cudf::size_type>({0, 1});
auto poly_ring_offsets = wrapper<cudf::size_type>({0, 4});
auto poly_point_xs = wrapper<T>({0.0, 1.0, 0.0, -1.0});
auto poly_point_ys = wrapper<T>({1.0, 0.0, -1.0, 0.0});
EXPECT_THROW(
cuspatial::pairwise_point_in_polygon(
test_point_xs, test_point_ys, poly_offsets, poly_ring_offsets, poly_point_xs, poly_point_ys),
cuspatial::logic_error);
}
TEST_F(PairwisePointInPolygonErrorTest, MismatchTestPointType)
{
using T = double;
auto test_point_xs = wrapper<T>({0.0});
auto test_point_ys = wrapper<float>({0.0});
auto poly_offsets = wrapper<cudf::size_type>({0, 1});
auto poly_ring_offsets = wrapper<cudf::size_type>({0, 4});
auto poly_point_xs = wrapper<T>({0.0, 1.0, 0.0, -1.0});
auto poly_point_ys = wrapper<T>({1.0, 0.0, -1.0, 0.0});
EXPECT_THROW(
cuspatial::pairwise_point_in_polygon(
test_point_xs, test_point_ys, poly_offsets, poly_ring_offsets, poly_point_xs, poly_point_ys),
cuspatial::logic_error);
}
TEST_F(PairwisePointInPolygonErrorTest, MismatchPolyPointXYLength)
{
using T = double;
auto test_point_xs = wrapper<T>({0.0});
auto test_point_ys = wrapper<T>({0.0});
auto poly_offsets = wrapper<cudf::size_type>({0, 1});
auto poly_ring_offsets = wrapper<cudf::size_type>({0, 4});
auto poly_point_xs = wrapper<T>({0.0, 1.0, 0.0});
auto poly_point_ys = wrapper<T>({1.0, 0.0, -1.0, 0.0});
EXPECT_THROW(
cuspatial::pairwise_point_in_polygon(
test_point_xs, test_point_ys, poly_offsets, poly_ring_offsets, poly_point_xs, poly_point_ys),
cuspatial::logic_error);
}
TEST_F(PairwisePointInPolygonErrorTest, MismatchPolyPointType)
{
using T = double;
auto test_point_xs = wrapper<T>({0.0});
auto test_point_ys = wrapper<T>({0.0});
auto poly_offsets = wrapper<cudf::size_type>({0, 1});
auto poly_ring_offsets = wrapper<cudf::size_type>({0, 4});
auto poly_point_xs = wrapper<T>({0.0, 1.0, 0.0});
auto poly_point_ys = wrapper<float>({1.0, 0.0, -1.0, 0.0});
EXPECT_THROW(
cuspatial::pairwise_point_in_polygon(
test_point_xs, test_point_ys, poly_offsets, poly_ring_offsets, poly_point_xs, poly_point_ys),
cuspatial::logic_error);
}
TEST_F(PairwisePointInPolygonErrorTest, MismatchPointTypes)
{
auto test_point_xs = wrapper<float>({0.0});
auto test_point_ys = wrapper<float>({0.0});
auto poly_offsets = wrapper<cudf::size_type>({0, 1});
auto poly_ring_offsets = wrapper<cudf::size_type>({0, 4});
auto poly_point_xs = wrapper<double>({0.0, 1.0, 0.0, -1.0});
auto poly_point_ys = wrapper<double>({1.0, 0.0, -1.0, 0.0});
EXPECT_THROW(
cuspatial::pairwise_point_in_polygon(
test_point_xs, test_point_ys, poly_offsets, poly_ring_offsets, poly_point_xs, poly_point_ys),
cuspatial::logic_error);
}
TEST_F(PairwisePointInPolygonErrorTest, MorePointsThanPolygons)
{
auto test_point_xs = wrapper<float>({0.0, 0.0});
auto test_point_ys = wrapper<float>({0.0, 0.0});
auto poly_offsets = wrapper<cudf::size_type>({0, 1});
auto poly_ring_offsets = wrapper<cudf::size_type>({0, 4});
auto poly_point_xs = wrapper<float>({0.0, 1.0, 0.0, -1.0});
auto poly_point_ys = wrapper<float>({1.0, 0.0, -1.0, 0.0});
EXPECT_THROW(
cuspatial::pairwise_point_in_polygon(
test_point_xs, test_point_ys, poly_offsets, poly_ring_offsets, poly_point_xs, poly_point_ys),
cuspatial::logic_error);
}
TEST_F(PairwisePointInPolygonErrorTest, MorePolygonsThanPoints)
{
auto test_point_xs = wrapper<float>({0.0});
auto test_point_ys = wrapper<float>({0.0});
auto poly_offsets = wrapper<cudf::size_type>({0, 1, 2});
auto poly_ring_offsets = wrapper<cudf::size_type>({0, 4, 8});
auto poly_point_xs = wrapper<float>({0.0, 1.0, 0.0, -1.0, 0.0, 1.0, 0.0, -1.0});
auto poly_point_ys = wrapper<float>({1.0, 0.0, -1.0, 0.0, 1.0, 0.0, -1.0, 0.0});
EXPECT_THROW(
cuspatial::pairwise_point_in_polygon(
test_point_xs, test_point_ys, poly_offsets, poly_ring_offsets, poly_point_xs, poly_point_ys),
cuspatial::logic_error);
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/utility_test/test_multipoint_factory.cu | /*
* 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 <cuspatial_test/base_fixture.hpp>
#include <cuspatial_test/vector_equality.hpp>
#include <cuspatial_test/vector_factories.cuh>
using namespace cuspatial;
using namespace cuspatial::detail;
using namespace cuspatial::test;
template <typename T>
struct MultiPointFactoryTest : public BaseFixture {};
using TestTypes = ::testing::Types<float, double>;
TYPED_TEST_CASE(MultiPointFactoryTest, TestTypes);
TYPED_TEST(MultiPointFactoryTest, simple)
{
using T = TypeParam;
using P = vec_2d<T>;
auto multipoints =
make_multipoint_array({{P{0.0, 0.0}, P{1.0, 0.0}}, {P{2.0, 0.0}, P{2.0, 2.0}}});
auto [offsets, coords] = multipoints.release();
auto expected_offsets = make_device_vector<std::size_t>({0, 2, 4});
auto expected_coords =
make_device_vector<vec_2d<T>>({P{0.0, 0.0}, P{1.0, 0.0}, P{2.0, 0.0}, P{2.0, 2.0}});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(offsets, expected_offsets);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(coords, expected_coords);
}
TYPED_TEST(MultiPointFactoryTest, empty)
{
using T = TypeParam;
using P = vec_2d<T>;
auto multipoints = make_multipoint_array<T>({});
auto [offsets, coords] = multipoints.release();
auto expected_offsets = make_device_vector<std::size_t>({0});
auto expected_coords = make_device_vector<vec_2d<T>>({});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(offsets, expected_offsets);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(coords, expected_coords);
}
TYPED_TEST(MultiPointFactoryTest, mixed_empty_multipoint)
{
using T = TypeParam;
using P = vec_2d<T>;
auto multipoints = make_multipoint_array({{P{1.0, 0.0}}, {}, {P{2.0, 3.0}, P{4.0, 5.0}}});
auto [offsets, coords] = multipoints.release();
auto expected_offsets = make_device_vector<std::size_t>({0, 1, 1, 3});
auto expected_coords = make_device_vector<vec_2d<T>>({P{1.0, 0.0}, P{2.0, 3.0}, P{4.0, 5.0}});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(offsets, expected_offsets);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(coords, expected_coords);
}
TYPED_TEST(MultiPointFactoryTest, mixed_empty_multipoint2)
{
using T = TypeParam;
using P = vec_2d<T>;
auto multipoints = make_multipoint_array({{}, {P{1.0, 0.0}}, {P{2.0, 3.0}, P{4.0, 5.0}}});
auto [offsets, coords] = multipoints.release();
auto expected_offsets = make_device_vector<std::size_t>({0, 0, 1, 3});
auto expected_coords = make_device_vector<vec_2d<T>>({P{1.0, 0.0}, P{2.0, 3.0}, P{4.0, 5.0}});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(offsets, expected_offsets);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(coords, expected_coords);
}
TYPED_TEST(MultiPointFactoryTest, mixed_empty_multipoint3)
{
using T = TypeParam;
using P = vec_2d<T>;
auto multipoints = make_multipoint_array({{P{1.0, 0.0}}, {P{2.0, 3.0}, P{4.0, 5.0}}, {}});
auto [offsets, coords] = multipoints.release();
auto expected_offsets = make_device_vector<std::size_t>({0, 1, 3, 3});
auto expected_coords = make_device_vector<vec_2d<T>>({P{1.0, 0.0}, P{2.0, 3.0}, P{4.0, 5.0}});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(offsets, expected_offsets);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(coords, expected_coords);
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/utility_test/test_geometry_generators.cu | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cuspatial_test/base_fixture.hpp>
#include <cuspatial_test/geometry_generator.cuh>
#include <cuspatial_test/vector_equality.hpp>
#include <cuspatial/geometry/vec_2d.hpp>
#include <gtest/gtest-param-test.h>
#include <type_traits>
using namespace cuspatial;
using namespace cuspatial::test;
template <typename T>
auto constexpr abs_error(T radius)
{
return radius * (std::is_same_v<T, float> ? 1e-7 : 1e-15);
};
template <typename T>
struct GeometryFactoryTest : public BaseFixture {
template <typename MultipolygonArray>
void run(multipolygon_generator_parameter<T> params,
MultipolygonArray expected,
T abs_error = 0.0)
{
auto got = generate_multipolygon_array(params, stream());
auto [got_geometry_offsets, got_part_offsets, got_ring_offsets, got_coordinates] =
got.to_host();
auto [expected_geometry_offsets,
expected_part_offsets,
expected_ring_offsets,
expected_coordinates] = expected.to_host();
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected_geometry_offsets, got_geometry_offsets);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected_part_offsets, got_part_offsets);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected_ring_offsets, got_ring_offsets);
if (abs_error == 0.0)
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected_coordinates, got_coordinates);
else
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected_coordinates, got_coordinates, abs_error);
}
};
using TestTypes = ::testing::Types<float, double>;
TYPED_TEST_CASE(GeometryFactoryTest, TestTypes);
TYPED_TEST(GeometryFactoryTest, multipolygonarray_basic)
{
using T = TypeParam;
using P = vec_2d<T>;
auto params = multipolygon_generator_parameter<T>{1, 1, 0, 3, {0.0, 0.0}, 1.0};
auto expected = make_multipolygon_array(
{0, 1},
{0, 1},
{0, 4},
{P{1.0, 0.0}, P{-0.5, 0.8660254037844386}, P{-0.5, -0.8660254037844386}, P{1.0, 0.0}});
CUSPATIAL_RUN_TEST(this->run, params, std::move(expected));
}
TYPED_TEST(GeometryFactoryTest, multipolygonarray_basic2)
{
using T = TypeParam;
using P = vec_2d<T>;
auto params = multipolygon_generator_parameter<T>{1, 1, 0, 4, {0.0, 0.0}, 1.0};
auto expected = make_multipolygon_array(
{0, 1}, {0, 1}, {0, 5}, {P{1.0, 0.0}, P{0.0, 1.0}, P{-1.0, 0.0}, P{0.0, -1.0}, P{1.0, 0.0}});
CUSPATIAL_RUN_TEST(this->run, params, std::move(expected), abs_error<T>(params.radius));
}
TYPED_TEST(GeometryFactoryTest, multipolygonarray_1poly1hole)
{
using T = TypeParam;
using P = vec_2d<T>;
auto params = multipolygon_generator_parameter<T>{1, 1, 1, 4, {0.0, 0.0}, 1.0};
auto expected = make_multipolygon_array({0, 1},
{0, 2},
{0, 5, 10},
{P{1.0, 0.0},
P{0.0, 1.0},
P{-1.0, 0.0},
P{0.0, -1.0},
P{1.0, 0.0},
P{0.0, 0.0},
P{-0.5, 0.5},
P{-1.0, 0.0},
P{-0.5, -0.5},
P{0.0, 0.0}});
CUSPATIAL_RUN_TEST(this->run, params, std::move(expected), abs_error<T>(params.radius));
}
TYPED_TEST(GeometryFactoryTest, multipolygonarray_1poly2holes)
{
using T = TypeParam;
using P = vec_2d<T>;
auto params = multipolygon_generator_parameter<T>{1, 1, 2, 4, {0.0, 0.0}, 1.0};
auto expected = make_multipolygon_array({0, 1},
{0, 3},
{0, 5, 10, 15},
{
P{1.0, 0.0},
P{0.0, 1.0},
P{-1.0, 0.0},
P{0.0, -1.0},
P{1.0, 0.0},
P{-0.3333333333333333, 0.0},
P{-0.6666666666666666, 0.3333333333333333},
P{-1.0, 0.0},
P{-0.6666666666666666, -0.3333333333333333},
P{-0.3333333333333333, 0.0},
P{0.3333333333333333, 0.0},
P{0.0, 0.3333333333333333},
P{-0.3333333333333333, 0.0},
P{0.0, -0.3333333333333333},
P{0.3333333333333333, 0.0},
});
CUSPATIAL_RUN_TEST(this->run, params, std::move(expected), abs_error<T>(params.radius));
}
TYPED_TEST(GeometryFactoryTest, multipolygonarray_2poly0hole)
{
using T = TypeParam;
using P = vec_2d<T>;
auto params = multipolygon_generator_parameter<T>{1, 2, 0, 4, {0.0, 0.0}, 1.0};
auto expected = make_multipolygon_array({0, 2},
{0, 1, 2},
{0, 5, 10},
{
P{1.0, 0.0},
P{0.0, 1.0},
P{-1.0, 0.0},
P{0.0, -1.0},
P{1.0, 0.0},
P{4.0, 0.0},
P{3.0, 1.0},
P{2.0, 0.0},
P{3.0, -1.0},
P{4.0, 0.0},
});
CUSPATIAL_RUN_TEST(this->run, params, std::move(expected), abs_error<T>(params.radius));
}
TYPED_TEST(GeometryFactoryTest, multipolygonarray_2poly1hole)
{
using T = TypeParam;
using P = vec_2d<T>;
auto params = multipolygon_generator_parameter<T>{1, 2, 1, 4, {0.0, 0.0}, 1.0};
auto expected =
make_multipolygon_array({0, 2},
{0, 2, 4},
{0, 5, 10, 15, 20},
{
P{1.0, 0.0}, P{0.0, 1.0}, P{-1.0, 0.0}, P{0.0, -1.0}, P{1.0, 0.0},
P{0.0, 0.0}, P{-0.5, 0.5}, P{-1.0, 0.0}, P{-0.5, -0.5}, P{0.0, 0.0},
P{4.0, 0.0}, P{3.0, 1.0}, P{2.0, 0.0}, P{3.0, -1.0}, P{4.0, 0.0},
P{3.0, 0.0}, P{2.5, 0.5}, P{2.0, 0.0}, P{2.5, -0.5}, P{3.0, 0.0},
});
CUSPATIAL_RUN_TEST(this->run, params, std::move(expected), abs_error<T>(params.radius));
}
TYPED_TEST(GeometryFactoryTest, multipolygonarray_2multipolygon1poly0hole)
{
using T = TypeParam;
using P = vec_2d<T>;
auto params = multipolygon_generator_parameter<T>{2, 1, 0, 4, {0.0, 0.0}, 1.0};
auto expected = make_multipolygon_array({0, 1, 2},
{0, 1, 2},
{0, 5, 10},
{
P{1.0, 0.0},
P{0.0, 1.0},
P{-1.0, 0.0},
P{0.0, -1.0},
P{1.0, 0.0},
P{1.0, 0.0},
P{0.0, 1.0},
P{-1.0, 0.0},
P{0.0, -1.0},
P{1.0, 0.0},
});
CUSPATIAL_RUN_TEST(this->run, params, std::move(expected), abs_error<T>(params.radius));
}
TYPED_TEST(GeometryFactoryTest, multipolygonarray_2multipolygon1poly1hole)
{
using T = TypeParam;
using P = vec_2d<T>;
auto params = multipolygon_generator_parameter<T>{2, 1, 1, 4, {0.0, 0.0}, 1.0};
auto expected =
make_multipolygon_array({0, 1, 2},
{0, 2, 4},
{0, 5, 10, 15, 20},
{
P{1.0, 0.0}, P{0.0, 1.0}, P{-1.0, 0.0}, P{0.0, -1.0}, P{1.0, 0.0},
P{0.0, 0.0}, P{-0.5, 0.5}, P{-1.0, 0.0}, P{-0.5, -0.5}, P{0.0, 0.0},
P{1.0, 0.0}, P{0.0, 1.0}, P{-1.0, 0.0}, P{0.0, -1.0}, P{1.0, 0.0},
P{0.0, 0.0}, P{-0.5, 0.5}, P{-1.0, 0.0}, P{-0.5, -0.5}, P{0.0, 0.0},
});
CUSPATIAL_RUN_TEST(this->run, params, std::move(expected), abs_error<T>(params.radius));
}
TYPED_TEST(GeometryFactoryTest, multipolygonarray_2multipolygon2poly1hole)
{
using T = TypeParam;
using P = vec_2d<T>;
auto params = multipolygon_generator_parameter<T>{2, 2, 1, 4, {0.0, 0.0}, 1.0};
auto expected = make_multipolygon_array(
{0, 2, 4},
{0, 2, 4, 6, 8},
{0, 5, 10, 15, 20, 25, 30, 35, 40},
{
P{1.0, 0.0}, P{0.0, 1.0}, P{-1.0, 0.0}, P{0.0, -1.0}, P{1.0, 0.0}, P{0.0, 0.0},
P{-0.5, 0.5}, P{-1.0, 0.0}, P{-0.5, -0.5}, P{0.0, 0.0}, P{4.0, 0.0}, P{3.0, 1.0},
P{2.0, 0.0}, P{3.0, -1.0}, P{4.0, 0.0}, P{3.0, 0.0}, P{2.5, 0.5}, P{2.0, 0.0},
P{2.5, -0.5}, P{3.0, 0.0}, P{1.0, 0.0}, P{0.0, 1.0}, P{-1.0, 0.0}, P{0.0, -1.0},
P{1.0, 0.0}, P{0.0, 0.0}, P{-0.5, 0.5}, P{-1.0, 0.0}, P{-0.5, -0.5}, P{0.0, 0.0},
P{4.0, 0.0}, P{3.0, 1.0}, P{2.0, 0.0}, P{3.0, -1.0}, P{4.0, 0.0}, P{3.0, 0.0},
P{2.5, 0.5}, P{2.0, 0.0}, P{2.5, -0.5}, P{3.0, 0.0},
});
CUSPATIAL_RUN_TEST(this->run, params, std::move(expected), abs_error<T>(params.radius));
}
TYPED_TEST(GeometryFactoryTest, multipolygonarray_basic_centroid)
{
using T = TypeParam;
using P = vec_2d<T>;
auto params = multipolygon_generator_parameter<T>{1, 1, 0, 4, {2.0, 3.0}, 1.0};
auto expected = make_multipolygon_array(
{0, 1}, {0, 1}, {0, 5}, {P{3.0, 3.0}, P{2.0, 4.0}, P{1.0, 3.0}, P{2.0, 2.0}, P{3.0, 3.0}});
CUSPATIAL_RUN_TEST(this->run, params, std::move(expected), abs_error<T>(params.radius));
}
TYPED_TEST(GeometryFactoryTest, multipolygonarray_basic_radius)
{
using T = TypeParam;
using P = vec_2d<T>;
auto params = multipolygon_generator_parameter<T>{1, 1, 0, 4, {0.0, 0.0}, 6.0};
auto expected = make_multipolygon_array(
{0, 1}, {0, 1}, {0, 5}, {P{6.0, 0.0}, P{0.0, 6.0}, P{-6.0, 0.0}, P{0.0, -6.0}, P{6.0, 0.0}});
CUSPATIAL_RUN_TEST(this->run, params, std::move(expected), abs_error<T>(params.radius));
}
struct GeometryFactoryCountVerificationTest
: public BaseFixtureWithParam<std::size_t, std::size_t, std::size_t, std::size_t> {
void run(multipolygon_generator_parameter<float> params)
{
auto got = generate_multipolygon_array(params, stream());
auto [got_geometry_offsets, got_part_offsets, got_ring_offsets, got_coordinates] =
got.to_host();
EXPECT_EQ(got_geometry_offsets.size(), params.num_multipolygons + 1);
EXPECT_EQ(got_part_offsets.size(), params.num_polygons() + 1);
EXPECT_EQ(got_ring_offsets.size(), params.num_rings() + 1);
EXPECT_EQ(got_coordinates.size(), params.num_coords());
}
};
TEST_P(GeometryFactoryCountVerificationTest, CountsVerification)
{
// Structured binding unsupported by Gtest
std::size_t num_multipolygons = std::get<0>(GetParam());
std::size_t num_polygons_per_multipolygon = std::get<1>(GetParam());
std::size_t num_holes_per_polygon = std::get<2>(GetParam());
std::size_t num_sides_per_ring = std::get<3>(GetParam());
auto params = multipolygon_generator_parameter<float>{num_multipolygons,
num_polygons_per_multipolygon,
num_holes_per_polygon,
num_sides_per_ring,
vec_2d<float>{0.0, 0.0},
1.0};
CUSPATIAL_RUN_TEST(this->run, params);
}
INSTANTIATE_TEST_SUITE_P(
GeometryFactoryCountVerificationTests,
GeometryFactoryCountVerificationTest,
::testing::Combine(::testing::Values<std::size_t>(1, 100), // num_multipolygons
::testing::Values<std::size_t>(1, 30), // num_polygons_per_multipolygon
::testing::Values<std::size_t>(0, 100), // num_holes_per_polygon
::testing::Values<std::size_t>(3, 100) // num_sides_per_ring
));
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/utility_test/test_float_equivalent.cu | /*
* 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 <cuspatial/detail/utility/floating_point.cuh>
#include <cuspatial_test/vector_factories.cuh>
#include <limits>
#include <rmm/device_vector.hpp>
#include <gtest/gtest.h>
using namespace cuspatial;
using namespace cuspatial::test;
template <typename T>
struct ULPFloatingPointEquivalenceTest : public ::testing::Test {};
using TestTypes = ::testing::Types<float, double>;
TYPED_TEST_CASE(ULPFloatingPointEquivalenceTest, TestTypes);
template <typename Float>
struct float_eq_comp {
bool __device__ operator()(Float lhs, Float rhs) { return detail::float_equal(lhs, rhs); }
};
template <typename T>
T increment(T f, unsigned step)
{
if (!step) return f;
return increment(std::nextafter(f, std::numeric_limits<T>::max()), step - 1);
}
template <typename T>
T decrement(T f, unsigned step)
{
if (!step) return f;
return decrement(std::nextafter(f, std::numeric_limits<T>::min()), step - 1);
}
template <typename T>
void run_test(T base)
{
T FourULPGreater = increment(base, 4);
T FiveULPGreater = increment(base, 5);
T FourULPLess = decrement(base, 4);
T FiveULPLess = decrement(base, 5);
std::vector<T> first{base, base, base, base};
std::vector<T> second{FourULPGreater, FiveULPGreater, FourULPLess, FiveULPLess};
rmm::device_vector<T> d_first(first);
rmm::device_vector<T> d_second(second);
auto expected = make_host_vector({true, false, true, false});
rmm::device_vector<bool> got(4);
thrust::transform(
d_first.begin(), d_first.end(), d_second.begin(), got.begin(), float_eq_comp<T>{});
EXPECT_EQ(expected, got);
}
TYPED_TEST(ULPFloatingPointEquivalenceTest, BiasedFromPositiveZero)
{
using T = TypeParam;
run_test(T{0.0});
}
TYPED_TEST(ULPFloatingPointEquivalenceTest, BiasedFromNegativeZero)
{
using T = TypeParam;
run_test(T{-0.0});
}
TYPED_TEST(ULPFloatingPointEquivalenceTest, TestVeryNearZeroPositive)
{
using T = TypeParam;
T very_small_positive_float = increment(T{0.0}, 1);
run_test(very_small_positive_float);
}
TYPED_TEST(ULPFloatingPointEquivalenceTest, TestVeryNearZeroNegative)
{
using T = TypeParam;
T very_small_negative_float = decrement(T{0.0}, 1);
run_test(very_small_negative_float);
}
TYPED_TEST(ULPFloatingPointEquivalenceTest, BiasedFromSmallPostiveFloat)
{
using T = TypeParam;
run_test(T{0.1});
}
TYPED_TEST(ULPFloatingPointEquivalenceTest, BiasedFromSmallNegativeFloat)
{
using T = TypeParam;
run_test(T{-0.1});
}
TYPED_TEST(ULPFloatingPointEquivalenceTest, BiasedFromPostiveFloat)
{
using T = TypeParam;
run_test(T{1234.0});
}
TYPED_TEST(ULPFloatingPointEquivalenceTest, BiasedFromNegativeFloat)
{
using T = TypeParam;
run_test(T{-5678.0});
}
TYPED_TEST(ULPFloatingPointEquivalenceTest, BiasedFromVeryLargePositiveFloat)
{
using T = TypeParam;
T very_large_positive_float = decrement(std::numeric_limits<T>::max(), 10);
run_test(very_large_positive_float);
}
TYPED_TEST(ULPFloatingPointEquivalenceTest, BiasedFromVeryLargeNegativeFloat)
{
using T = TypeParam;
T very_large_negative_float = increment(std::numeric_limits<T>::min(), 10);
run_test(very_large_negative_float);
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/trajectory/test_trajectory_distances_and_speeds.cu | /*
* Copyright (c) 2020, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cuspatial_test/base_fixture.hpp>
#include <cuspatial/error.hpp>
#include <cuspatial/trajectory.hpp>
#include <cudf_test/column_utilities.hpp>
#include <rmm/device_uvector.hpp>
struct TrajectoryDistanceSpeedErrorTest : public cuspatial::test::BaseFixture {};
TEST_F(TrajectoryDistanceSpeedErrorTest, SizeMismatch)
{
auto const size = 1000;
{
auto id = cudf::column(rmm::device_uvector<cudf::size_type>(size, rmm::cuda_stream_default),
rmm::device_buffer{},
0);
auto xs = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ys = cudf::column(
rmm::device_uvector<float>(size / 2, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ts = cudf::column(rmm::device_uvector<cudf::timestamp_ms>(size, rmm::cuda_stream_default),
rmm::device_buffer{},
0);
EXPECT_THROW(cuspatial::trajectory_distances_and_speeds(1, id, xs, ys, ts, this->mr()),
cuspatial::logic_error);
}
{
auto id = cudf::column(
rmm::device_uvector<int>(size / 2, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto xs = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ys = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ts = cudf::column(rmm::device_uvector<cudf::timestamp_ms>(size, rmm::cuda_stream_default),
rmm::device_buffer{},
0);
EXPECT_THROW(cuspatial::trajectory_distances_and_speeds(1, id, xs, ys, ts, this->mr()),
cuspatial::logic_error);
}
{
auto id = cudf::column(
rmm::device_uvector<int>(size / 2, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto xs = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ys = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ts =
cudf::column(rmm::device_uvector<cudf::timestamp_ms>(size / 2, rmm::cuda_stream_default),
rmm::device_buffer{},
0);
EXPECT_THROW(cuspatial::trajectory_distances_and_speeds(1, id, xs, ys, ts, this->mr()),
cuspatial::logic_error);
}
}
TEST_F(TrajectoryDistanceSpeedErrorTest, TypeError)
{
auto const size = 1000;
{
auto id = cudf::column(rmm::device_uvector<float>(size, rmm::cuda_stream_default),
rmm::device_buffer{},
0); // not integer
auto xs = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ys = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ts = cudf::column(rmm::device_uvector<cudf::timestamp_ms>(size, rmm::cuda_stream_default),
rmm::device_buffer{},
0);
EXPECT_THROW(cuspatial::trajectory_distances_and_speeds(1, id, xs, ys, ts, this->mr()),
cuspatial::logic_error);
}
{
auto id = cudf::column(
rmm::device_uvector<int>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto xs = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ys = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ts = cudf::column(rmm::device_uvector<float>(size, rmm::cuda_stream_default),
rmm::device_buffer{},
0); // not timestamp
EXPECT_THROW(cuspatial::trajectory_distances_and_speeds(1, id, xs, ys, ts, this->mr()),
cuspatial::logic_error);
}
{
// x-y type mismatch
auto id = cudf::column(rmm::device_uvector<cudf::size_type>(size, rmm::cuda_stream_default),
rmm::device_buffer{},
0);
auto xs = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ys = cudf::column(
rmm::device_uvector<double>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ts = cudf::column(rmm::device_uvector<cudf::timestamp_ms>(size, rmm::cuda_stream_default),
rmm::device_buffer{},
0);
EXPECT_THROW(cuspatial::trajectory_distances_and_speeds(1, id, xs, ys, ts, this->mr()),
cuspatial::logic_error);
}
}
TEST_F(TrajectoryDistanceSpeedErrorTest, Nulls)
{
auto const size = 1000;
{
auto id = cudf::column(rmm::device_uvector<cudf::size_type>(size, rmm::cuda_stream_default),
rmm::device_buffer{},
0);
auto xs = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ys = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ts = cudf::column(rmm::device_uvector<cudf::timestamp_ms>(size, rmm::cuda_stream_default),
rmm::device_buffer{},
0);
auto nulls = rmm::device_uvector<int>(1000, rmm::cuda_stream_default);
cudaMemsetAsync(nulls.data(), 0xcccc, nulls.size(), rmm::cuda_stream_default.value());
auto nulls_buffer = nulls.release();
id.set_null_mask(nulls_buffer, 4000);
EXPECT_THROW(cuspatial::trajectory_distances_and_speeds(1, id, xs, ys, ts, this->mr()),
cuspatial::logic_error);
}
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/trajectory/test_trajectory_bounding_boxes.cu | /*
* Copyright (c) 2020, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cuspatial_test/base_fixture.hpp>
#include <cuspatial/error.hpp>
#include <cuspatial/trajectory.hpp>
struct TrajectoryBoundingBoxesErrorTest : public cuspatial::test::BaseFixture {};
TEST_F(TrajectoryBoundingBoxesErrorTest, SizeMismatch)
{
auto const size = 1000;
{
auto id = cudf::column(rmm::device_uvector<cudf::size_type>(size, rmm::cuda_stream_default),
rmm::device_buffer{},
0);
auto xs = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ys = cudf::column(
rmm::device_uvector<float>(size / 2, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
EXPECT_THROW(cuspatial::trajectory_bounding_boxes(1, id, xs, ys, this->mr()),
cuspatial::logic_error);
}
{
auto id = cudf::column(
rmm::device_uvector<int>(size / 2, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto xs = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ys = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
EXPECT_THROW(cuspatial::trajectory_bounding_boxes(1, id, xs, ys, this->mr()),
cuspatial::logic_error);
}
}
TEST_F(TrajectoryBoundingBoxesErrorTest, TypeError)
{
auto const size = 1000;
{
auto id = cudf::column(rmm::device_uvector<float>(size, rmm::cuda_stream_default),
rmm::device_buffer{},
0); // not integer
auto xs = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ys = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
EXPECT_THROW(cuspatial::trajectory_bounding_boxes(1, id, xs, ys, this->mr()),
cuspatial::logic_error);
}
{
// x-y type mismatch
auto id = cudf::column(rmm::device_uvector<cudf::size_type>(size, rmm::cuda_stream_default),
rmm::device_buffer{},
0);
auto xs = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ys = cudf::column(
rmm::device_uvector<double>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
EXPECT_THROW(cuspatial::trajectory_bounding_boxes(1, id, xs, ys, this->mr()),
cuspatial::logic_error);
}
}
TEST_F(TrajectoryBoundingBoxesErrorTest, Nulls)
{
auto const size = 1000;
{
auto id = cudf::column(rmm::device_uvector<cudf::size_type>(size, rmm::cuda_stream_default),
rmm::device_buffer{},
0);
auto xs = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ys = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto nulls = rmm::device_uvector<int>(1000, rmm::cuda_stream_default);
cudaMemsetAsync(nulls.data(), 0xcccc, nulls.size(), rmm::cuda_stream_default.value());
auto nulls_buffer = nulls.release();
id.set_null_mask(nulls_buffer, 4000);
EXPECT_THROW(cuspatial::trajectory_bounding_boxes(1, id, xs, ys, this->mr()),
cuspatial::logic_error);
}
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/trajectory/derive_trajectories_test.cu | /*
* 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 "cuspatial_test/vector_equality.hpp"
#include "trajectory_test_utils.cuh"
#include <cuspatial/geometry/vec_2d.hpp>
#include <cuspatial/iterator_factory.cuh>
#include <cuspatial/trajectory.cuh>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <rmm/mr/device/per_device_resource.hpp>
#include <thrust/binary_search.h>
#include <thrust/gather.h>
#include <thrust/random.h>
#include <thrust/random/uniform_int_distribution.h>
#include <thrust/scan.h>
#include <thrust/shuffle.h>
#include <gtest/gtest.h>
#include <cstdint>
#include <iostream>
namespace std {
// Required by gtest EXPECT_EQ test suite to compile.
// Since `time_point` is an alias on
// std::chrono::time_point<std::chrono::system_clock, std::chrono::milliseconds>,
// according to ADL rules for templates, only the inner most enclosing namespaces,
// and associated namespaces of the template arguments are added to search. In this
// case, only `std` namespace is searched.
//
// [1]: https://en.cppreference.com/w/cpp/language/adl
std::ostream& operator<<(std::ostream& os, cuspatial::test::time_point const& tp)
{
// Output the time point in the desired format
os << tp.time_since_epoch().count() << "ms";
return os;
}
} // namespace std
template <typename T>
struct DeriveTrajectoriesTest : public ::testing::Test {};
using TestTypes = ::testing::Types<float, double>;
TYPED_TEST_CASE(DeriveTrajectoriesTest, TestTypes);
TYPED_TEST(DeriveTrajectoriesTest, TenThousandSmallTrajectories)
{
auto data = cuspatial::test::trajectory_test_data<TypeParam>(10'000, 50);
auto traj_ids = rmm::device_vector<std::int32_t>(data.ids.size());
auto traj_points = rmm::device_vector<cuspatial::vec_2d<TypeParam>>(data.points.size());
auto traj_times = rmm::device_vector<cuspatial::test::time_point>(data.times.size());
auto traj_offsets = cuspatial::derive_trajectories(data.ids.begin(),
data.ids.end(),
data.points.begin(),
data.times.begin(),
traj_ids.begin(),
traj_points.begin(),
traj_times.begin());
EXPECT_EQ(traj_ids, data.ids_sorted);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(traj_points, data.points_sorted);
EXPECT_EQ(traj_times, data.times_sorted);
}
TYPED_TEST(DeriveTrajectoriesTest, OneHundredLargeTrajectories)
{
auto data = cuspatial::test::trajectory_test_data<TypeParam>(100, 10'000);
auto traj_ids = rmm::device_vector<std::int32_t>(data.ids.size());
auto traj_points = rmm::device_vector<cuspatial::vec_2d<TypeParam>>(data.points.size());
auto traj_times = rmm::device_vector<cuspatial::test::time_point>(data.times.size());
auto traj_offsets = cuspatial::derive_trajectories(data.ids.begin(),
data.ids.end(),
data.points.begin(),
data.times.begin(),
traj_ids.begin(),
traj_points.begin(),
traj_times.begin());
EXPECT_EQ(traj_ids, data.ids_sorted);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(traj_points, data.points_sorted);
EXPECT_EQ(traj_times, data.times_sorted);
}
TYPED_TEST(DeriveTrajectoriesTest, OneVeryLargeTrajectory)
{
auto data = cuspatial::test::trajectory_test_data<TypeParam>(1, 1'000'000);
auto traj_ids = rmm::device_vector<std::int32_t>(data.ids.size());
auto traj_points = rmm::device_vector<cuspatial::vec_2d<TypeParam>>(data.points.size());
auto traj_times = rmm::device_vector<cuspatial::test::time_point>(data.times.size());
auto traj_offsets = cuspatial::derive_trajectories(data.ids.begin(),
data.ids.end(),
data.points.begin(),
data.times.begin(),
traj_ids.begin(),
traj_points.begin(),
traj_times.begin());
EXPECT_EQ(traj_ids, data.ids_sorted);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(traj_points, data.points_sorted);
EXPECT_EQ(traj_times, data.times_sorted);
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/trajectory/trajectory_test_utils.cuh | /*
* 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 <cuspatial/geometry/vec_2d.hpp>
#include <cuspatial/iterator_factory.cuh>
#include <cuspatial_test/test_util.cuh>
#include <rmm/device_vector.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/binary_search.h>
#include <thrust/gather.h>
#include <thrust/iterator/constant_iterator.h>
#include <thrust/iterator/discard_iterator.h>
#include <thrust/random.h>
#include <thrust/sequence.h>
#include <thrust/shuffle.h>
#include <thrust/tabulate.h>
#include <thrust/transform.h>
#include <cuda/std/chrono>
#include <cstdint>
namespace cuspatial {
namespace test {
using time_point = std::chrono::time_point<std::chrono::system_clock, std::chrono::milliseconds>;
/* Test data generation for trajectory APIs. Generates num_trajectories trajectories of random
size between 1 and max_trajectory_size samples. Creates both a reference (sorted) set of
trajectory IDs, timestamps, and points, and a shuffled (unsorted) set of the same for test
input. The sorted data can be input directly into `trajectory_distance_and_speed`, while
the shuffled data can be input to `derive_trajectories`.
The times are not random, but do vary somewhat between trajectories and trajectory lengths.
Each trajectory has a distinct starting time point and trajectory timestamps increase
monotonically at each sample. The interval between samples varies within a small range.
Likewise, the positions are not random, but follow a sinusoid pattern based on the time stamps.
*/
template <typename T>
struct trajectory_test_data {
std::size_t num_trajectories;
rmm::device_vector<std::int32_t> offsets;
rmm::device_vector<std::int32_t> ids;
rmm::device_vector<time_point> times;
rmm::device_vector<cuspatial::vec_2d<T>> points;
rmm::device_vector<std::int32_t> ids_sorted;
rmm::device_vector<time_point> times_sorted;
rmm::device_vector<cuspatial::vec_2d<T>> points_sorted;
trajectory_test_data(std::size_t num_trajectories, std::size_t max_trajectory_size)
: num_trajectories(num_trajectories)
{
thrust::minstd_rand gen{0};
thrust::uniform_int_distribution<std::int32_t> size_rand(1, max_trajectory_size);
// random trajectory sizes
rmm::device_vector<std::int32_t> sizes(num_trajectories, max_trajectory_size);
thrust::tabulate(
rmm::exec_policy(), sizes.begin(), sizes.end(), size_rand_functor(gen, size_rand));
// offset to each trajectory
// GeoArrow: offsets size is one more than number of points. Last offset points past the end of
// the data array
offsets.resize(num_trajectories + 1);
thrust::exclusive_scan(rmm::exec_policy(), sizes.begin(), sizes.end(), offsets.begin(), 0);
auto total_points = sizes[num_trajectories - 1] + offsets[num_trajectories - 1];
offsets[num_trajectories] = total_points;
ids.resize(total_points);
ids_sorted.resize(ids.size());
times.resize(total_points);
times_sorted.resize(times.size());
points.resize(total_points);
points_sorted.resize(points.size());
using namespace std::chrono_literals;
thrust::tabulate(rmm::exec_policy(),
ids_sorted.begin(),
ids_sorted.end(),
id_functor(offsets.data().get(), offsets.data().get() + offsets.size()));
thrust::transform(
rmm::exec_policy(),
thrust::make_counting_iterator(0),
thrust::make_counting_iterator(total_points),
ids_sorted.begin(),
times_sorted.begin(),
timestamp_functor(offsets.data().get(), offsets.data().get() + offsets.size()));
thrust::transform(rmm::exec_policy(),
times_sorted.begin(),
times_sorted.end(),
ids_sorted.begin(),
points_sorted.begin(),
point_functor());
// shuffle input data to create randomized order
rmm::device_vector<std::int32_t> map(total_points);
thrust::sequence(rmm::exec_policy(), map.begin(), map.end(), 0);
thrust::shuffle(rmm::exec_policy(), map.begin(), map.end(), gen);
thrust::gather(rmm::exec_policy(), map.begin(), map.end(), ids_sorted.begin(), ids.begin());
thrust::gather(rmm::exec_policy(), map.begin(), map.end(), times_sorted.begin(), times.begin());
thrust::gather(
rmm::exec_policy(), map.begin(), map.end(), points_sorted.begin(), points.begin());
}
struct id_functor {
std::int32_t* offsets_begin{};
std::int32_t* offsets_end{};
id_functor(std::int32_t* offsets_begin, std::int32_t* offsets_end)
: offsets_begin(offsets_begin), offsets_end(offsets_end)
{
}
__device__ std::int32_t operator()(int i)
{
// Find the index within the current trajectory
return thrust::distance(
offsets_begin,
thrust::prev(thrust::upper_bound(thrust::seq, offsets_begin, offsets_end, i)));
}
};
struct timestamp_functor {
std::int32_t* offsets_begin{};
std::int32_t* offsets_end{};
timestamp_functor(std::int32_t* offsets_begin, std::int32_t* offsets_end)
: offsets_begin(offsets_begin), offsets_end(offsets_end)
{
}
__device__ time_point operator()(int i, int id)
{
auto offset = thrust::prev(thrust::upper_bound(thrust::seq, offsets_begin, offsets_end, i));
auto time_step = i - *offset;
// The arithmetic here just adds some variance to the time step but keeps it monotonically
// increasing with `i`
auto duration = (id % 10) * std::chrono::milliseconds(1000) +
time_step * std::chrono::milliseconds(100) +
std::chrono::milliseconds(int(10 * cos(time_step)));
return time_point{duration};
}
};
struct point_functor {
__device__ cuspatial::vec_2d<T> operator()(time_point const& time, std::int32_t id)
{
// X is time in seconds, Y is cosine(time), offset by ID
T duration = (time - time_point{std::chrono::milliseconds(0)}).count();
return cuspatial::vec_2d<T>{duration / 1000, id + cos(duration)};
}
};
struct size_rand_functor {
thrust::minstd_rand gen;
thrust::uniform_int_distribution<std::int32_t> size_rand;
size_rand_functor(thrust::minstd_rand gen,
thrust::uniform_int_distribution<std::int32_t> size_rand)
: gen(gen), size_rand(size_rand)
{
}
__device__ std::int32_t operator()(int i)
{
gen.discard(i);
return size_rand(gen);
}
};
struct box_minmax {
__host__ __device__ box<T> operator()(box<T> const& a, box<T> const& b)
{
return {box_min(box_min(a.v1, a.v2), b.v1), box_max(box_max(a.v1, a.v2), b.v2)};
}
};
struct point_bbox_functor {
T expansion_radius{};
__host__ __device__ box<T> operator()(cuspatial::vec_2d<T> const& p)
{
auto expansion = cuspatial::vec_2d<T>{expansion_radius, expansion_radius};
return {p - expansion, p + expansion};
}
};
auto bounding_boxes(T expansion_radius = T{})
{
auto bounding_boxes = rmm::device_vector<box<T>>(num_trajectories);
auto point_tuples =
thrust::make_transform_iterator(points_sorted.begin(), point_bbox_functor{expansion_radius});
thrust::reduce_by_key(ids_sorted.begin(),
ids_sorted.end(),
point_tuples,
thrust::discard_iterator{},
bounding_boxes.begin(),
thrust::equal_to<std::int32_t>(),
box_minmax{});
return bounding_boxes;
}
struct duration_functor {
using id_and_timestamp = thrust::tuple<std::int32_t, time_point>;
__host__ __device__ time_point::rep operator()(id_and_timestamp const& p0,
id_and_timestamp const& p1)
{
auto const id0 = thrust::get<0>(p0);
auto const id1 = thrust::get<0>(p1);
auto const t0 = thrust::get<1>(p0);
auto const t1 = thrust::get<1>(p1);
if (id0 == id1) { return (t1 - t0).count(); }
return 0;
}
};
struct distance_functor {
using id_and_position = thrust::tuple<std::int32_t, cuspatial::vec_2d<T>>;
__host__ __device__ T operator()(id_and_position const& p0, id_and_position const& p1)
{
auto const id0 = thrust::get<0>(p0);
auto const id1 = thrust::get<0>(p1);
if (id0 == id1) {
auto const pos0 = thrust::get<1>(p0);
auto const pos1 = thrust::get<1>(p1);
auto const vec = pos1 - pos0;
return sqrt(dot(vec, vec));
}
return 0;
}
};
struct average_distance_speed_functor {
using duration_distance = thrust::tuple<time_point::rep, T, T, T>;
using Sec = typename cuda::std::chrono::seconds;
using Period =
typename cuda::std::ratio_divide<typename time_point::period, typename Sec::period>::type;
__host__ __device__ duration_distance operator()(duration_distance const& a,
duration_distance const& b)
{
auto time_d =
time_point::duration(thrust::get<0>(a)) + time_point::duration(thrust::get<0>(b));
auto time_s =
static_cast<T>(time_d.count()) * static_cast<T>(Period::num) / static_cast<T>(Period::den);
T dist_km = thrust::get<1>(a) + thrust::get<1>(b);
T dist_m = dist_km * T{1000.0}; // km to m
T speed_m_s = dist_m / time_s; // m/ms to m/s
return {time_d.count(), dist_km, dist_m, speed_m_s};
}
};
std::pair<rmm::device_vector<T>, rmm::device_vector<T>> distance_and_speed()
{
using Rep = typename time_point::rep;
auto id_and_timestamp = thrust::make_zip_iterator(ids_sorted.begin(), times_sorted.begin());
auto duration_per_step = rmm::device_vector<Rep>(points.size());
thrust::transform(rmm::exec_policy(),
id_and_timestamp,
id_and_timestamp + points.size() - 1,
id_and_timestamp + 1,
duration_per_step.begin() + 1,
duration_functor{});
auto id_and_position = thrust::make_zip_iterator(ids_sorted.begin(), points_sorted.begin());
auto distance_per_step = rmm::device_vector<T>{points.size()};
thrust::transform(rmm::exec_policy(),
id_and_position,
id_and_position + points.size() - 1,
id_and_position + 1,
distance_per_step.begin() + 1,
distance_functor{});
rmm::device_vector<Rep> durations_tmp(num_trajectories);
rmm::device_vector<T> distances_tmp(num_trajectories);
rmm::device_vector<T> distances(num_trajectories);
rmm::device_vector<T> speeds(num_trajectories);
auto duration_distance_and_speed = thrust::make_zip_iterator(
durations_tmp.begin(), distances_tmp.begin(), distances.begin(), speeds.begin());
auto duration_and_distance_init =
thrust::make_zip_iterator(duration_per_step.begin(),
distance_per_step.begin(),
thrust::make_constant_iterator<T>(0),
thrust::make_constant_iterator<T>(0));
thrust::reduce_by_key(rmm::exec_policy(),
ids_sorted.begin(),
ids_sorted.end(),
duration_and_distance_init,
thrust::discard_iterator{},
duration_distance_and_speed,
thrust::equal_to<int32_t>(), // binary_pred
average_distance_speed_functor{}); // binary_op
CUSPATIAL_CHECK_CUDA(rmm::cuda_stream_default);
return std::pair{distances, speeds};
}
};
} // namespace test
} // namespace cuspatial
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/trajectory/test_derive_trajectories.cpp | /*
* 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.
*/
#include <cuspatial_test/base_fixture.hpp>
#include <cuspatial/error.hpp>
#include <cuspatial/trajectory.hpp>
#include <cudf/column/column.hpp>
#include <cudf/types.hpp>
#include <cudf/wrappers/timestamps.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_uvector.hpp>
#include <gtest/gtest.h>
struct DeriveTrajectoriesErrorTest : public cuspatial::test::BaseFixture {};
TEST_F(DeriveTrajectoriesErrorTest, SizeMismatch)
{
auto const size = 1000;
{
auto id = cudf::column(
rmm::device_uvector<int>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto xs = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ys = cudf::column(
rmm::device_uvector<float>(size / 2, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ts = cudf::column(rmm::device_uvector<cudf::timestamp_ms>(size, rmm::cuda_stream_default),
rmm::device_buffer{},
0);
EXPECT_THROW(cuspatial::derive_trajectories(id, xs, ys, ts, this->mr()),
cuspatial::logic_error);
}
{
auto id = cudf::column(
rmm::device_uvector<int>(size / 2, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto xs = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ys = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ts = cudf::column(rmm::device_uvector<cudf::timestamp_ms>(size, rmm::cuda_stream_default),
rmm::device_buffer{},
0);
EXPECT_THROW(cuspatial::derive_trajectories(id, xs, ys, ts, this->mr()),
cuspatial::logic_error);
}
{
auto id = cudf::column(
rmm::device_uvector<int>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto xs = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ys = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ts =
cudf::column(rmm::device_uvector<cudf::timestamp_ms>(size / 2, rmm::cuda_stream_default),
rmm::device_buffer{},
0);
EXPECT_THROW(cuspatial::derive_trajectories(id, xs, ys, ts, this->mr()),
cuspatial::logic_error);
}
}
TEST_F(DeriveTrajectoriesErrorTest, TypeError)
{
auto const size = 1000;
{
auto id = cudf::column(rmm::device_uvector<float>(size, rmm::cuda_stream_default),
rmm::device_buffer{},
0); // not integer
auto xs = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ys = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ts = cudf::column(rmm::device_uvector<cudf::timestamp_ms>(size, rmm::cuda_stream_default),
rmm::device_buffer{},
0);
EXPECT_THROW(cuspatial::derive_trajectories(id, xs, ys, ts, this->mr()),
cuspatial::logic_error);
}
{
auto id = cudf::column(
rmm::device_uvector<int>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto xs = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ys = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ts = cudf::column(rmm::device_uvector<float>(size, rmm::cuda_stream_default),
rmm::device_buffer{},
0); // not timestamp
EXPECT_THROW(cuspatial::derive_trajectories(id, xs, ys, ts, this->mr()),
cuspatial::logic_error);
}
{
// x-y type mismatch
auto id = cudf::column(rmm::device_uvector<cudf::size_type>(size, rmm::cuda_stream_default),
rmm::device_buffer{},
0);
auto xs = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ys = cudf::column(
rmm::device_uvector<double>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ts = cudf::column(rmm::device_uvector<cudf::timestamp_ms>(size, rmm::cuda_stream_default),
rmm::device_buffer{},
0);
EXPECT_THROW(cuspatial::derive_trajectories(id, xs, ys, ts, this->mr()),
cuspatial::logic_error);
}
}
TEST_F(DeriveTrajectoriesErrorTest, Nulls)
{
auto const size = 1000;
{
auto id = cudf::column(
rmm::device_uvector<int>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto xs = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ys = cudf::column(
rmm::device_uvector<float>(size, rmm::cuda_stream_default), rmm::device_buffer{}, 0);
auto ts = cudf::column(rmm::device_uvector<cudf::timestamp_ms>(size, rmm::cuda_stream_default),
rmm::device_buffer{},
0);
auto nulls = rmm::device_uvector<int>(1000, rmm::cuda_stream_default);
cudaMemsetAsync(nulls.data(), 0xcccc, nulls.size(), rmm::cuda_stream_default.value());
auto nulls_buffer = nulls.release();
id.set_null_mask(nulls_buffer, 4000);
EXPECT_THROW(cuspatial::derive_trajectories(id, xs, ys, ts, this->mr()),
cuspatial::logic_error);
}
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/trajectory/trajectory_distances_and_speeds_test.cu |
/*
* 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 "trajectory_test_utils.cuh"
#include <cuspatial_test/vector_equality.hpp>
#include <cuspatial/geometry/vec_2d.hpp>
#include <cuspatial/iterator_factory.cuh>
#include <cuspatial/trajectory.cuh>
#include <cuspatial/trajectory.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/iterator/zip_iterator.h>
#include <thrust/reduce.h>
#include <gtest/gtest.h>
#include <limits>
template <typename T>
struct TrajectoryDistancesAndSpeedsTest : public ::testing::Test {
void run_test(int num_trajectories, int points_per_trajectory)
{
auto data = cuspatial::test::trajectory_test_data<T>(num_trajectories, points_per_trajectory);
auto distances = rmm::device_vector<T>(data.num_trajectories);
auto speeds = rmm::device_vector<T>(data.num_trajectories);
auto distance_and_speed_begin = thrust::make_zip_iterator(distances.begin(), speeds.begin());
auto distance_and_speed_end =
cuspatial::trajectory_distances_and_speeds(data.num_trajectories,
data.ids_sorted.begin(),
data.ids_sorted.end(),
data.points_sorted.begin(),
data.times_sorted.begin(),
distance_and_speed_begin);
EXPECT_EQ(std::distance(distance_and_speed_begin, distance_and_speed_end),
data.num_trajectories);
auto [expected_distances, expected_speeds] = data.distance_and_speed();
T max_expected_distance = thrust::reduce(expected_distances.begin(),
expected_distances.end(),
std::numeric_limits<T>::lowest(),
thrust::maximum<T>{});
T max_expected_speed =
thrust::reduce(expected_speeds.begin(),
expected_speeds.end(),
std::numeric_limits<T>::lowest(),
[] __device__(T const& a, T const& b) { return max(abs(a), abs(b)); });
// We expect the floating point error (in ulps) due to be proportional to the number of
// operations to compute the relevant quantity. For distance, this computation is
// m_per_km * sqrt(dot(vec, vec)), where vec = (p1 - p0).
// For speed, there is an additional division. There is also accumulated error in the reductions
// and we find k_ulps == 10 reliably results in the expected computation matching the actual
// computation for large trajectories with disparate positions and increasing timestamps.
// This value and the magnitude of the values involved (e.g. max distance) are used to scale
// the machine epsilon to come up with an absolute error tolerance.
int k_ulps = 10;
T abs_error_distance = k_ulps * std::numeric_limits<T>::epsilon() * max_expected_distance;
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(distances, expected_distances, abs_error_distance);
T abs_error_speed = k_ulps * std::numeric_limits<T>::epsilon() * max_expected_speed;
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(speeds, expected_speeds, abs_error_speed);
}
};
using TestTypes = ::testing::Types<float, double>;
TYPED_TEST_CASE(TrajectoryDistancesAndSpeedsTest, TestTypes);
TYPED_TEST(TrajectoryDistancesAndSpeedsTest, TenThousandSmallTrajectories)
{
CUSPATIAL_RUN_TEST(this->run_test, 10'000, 50);
}
TYPED_TEST(TrajectoryDistancesAndSpeedsTest, OneHundredLargeTrajectories)
{
CUSPATIAL_RUN_TEST(this->run_test, 100, 10'000);
}
TYPED_TEST(TrajectoryDistancesAndSpeedsTest, OneVeryLargeTrajectory)
{
CUSPATIAL_RUN_TEST(this->run_test, 1, 1'000'000);
}
struct time_point_generator {
using time_point = cuspatial::test::time_point;
int init;
time_point __device__ operator()(int const i)
{
return time_point{time_point::duration{i + init}};
}
};
// Simple standalone test with hard-coded results
TYPED_TEST(TrajectoryDistancesAndSpeedsTest, ComputeDistanceAndSpeed3Simple)
{
using T = TypeParam;
using time_point = cuspatial::test::time_point;
std::int32_t num_trajectories = 3;
auto offsets = rmm::device_vector<int32_t>{std::vector<std::int32_t>{0, 5, 9}};
auto id =
rmm::device_vector<int32_t>{std::vector<std::int32_t>{0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2}};
auto points =
rmm::device_vector<cuspatial::vec_2d<T>>(std::vector<cuspatial::vec_2d<T>>{{1.0, 0.0},
{2.0, 1.0},
{3.0, 2.0},
{5.0, 3.0},
{7.0, 1.0},
{1.0, 3.0},
{2.0, 5.0},
{3.0, 6.0},
{6.0, 5.0},
{0.0, 4.0},
{3.0, 7.0},
{6.0, 4.0}});
auto ts = rmm::device_vector<time_point>{12};
thrust::tabulate(ts.begin(), ts.end(), time_point_generator{1}); // 1 through 12
auto distances = rmm::device_vector<T>(num_trajectories);
auto speeds = rmm::device_vector<T>(num_trajectories);
auto distance_and_speed_begin = thrust::make_zip_iterator(distances.begin(), speeds.begin());
auto distance_and_speed_end = cuspatial::trajectory_distances_and_speeds(
3, id.begin(), id.end(), points.begin(), ts.begin(), distance_and_speed_begin);
ASSERT_EQ(std::distance(distance_and_speed_begin, distance_and_speed_end), num_trajectories);
// expected distance and speed
std::vector<T> speeds_expected({1973230.5567480423, 2270853.0666804211, 4242640.6871192846});
std::vector<T> distances_expected({7892.9222269921693, 6812.5592000412635, 8485.2813742385697});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(distances, distances_expected);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(speeds, speeds_expected);
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/join/quadtree_point_to_nearest_linestring_test_small.cu | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cuspatial_test/base_fixture.hpp>
#include <cuspatial_test/vector_equality.hpp>
#include <cuspatial_test/vector_factories.cuh>
#include <cuspatial/bounding_boxes.cuh>
#include <cuspatial/error.hpp>
#include <cuspatial/point_quadtree.cuh>
#include <cuspatial/range/multilinestring_range.cuh>
#include <cuspatial/spatial_join.cuh>
#include <type_traits>
template <typename T>
struct QuadtreePointToLinestringTestSmall : public cuspatial::test::BaseFixture {};
using TestTypes = ::testing::Types<float, double>;
TYPED_TEST_CASE(QuadtreePointToLinestringTestSmall, TestTypes);
TYPED_TEST(QuadtreePointToLinestringTestSmall, TestSmall)
{
using T = TypeParam;
using cuspatial::vec_2d;
using cuspatial::test::make_device_vector;
vec_2d<T> v_min{0.0, 0.0};
vec_2d<T> v_max{8.0, 8.0};
T const scale{1.0};
uint8_t const max_depth{3};
uint32_t const max_size{12};
auto points = make_device_vector<vec_2d<T>>(
{{1.9804558865545805, 1.3472225743317712}, {0.1895259128530169, 0.5431061133894604},
{1.2591725716781235, 0.1448705855995005}, {0.8178039499335275, 0.8138440641113271},
{0.48171647380517046, 1.9022922214961997}, {1.3890664414691907, 1.5177694304735412},
{0.2536015260915061, 1.8762161698642947}, {3.1907684812039956, 0.2621847215928189},
{3.028362149164369, 0.027638405909631958}, {3.918090468102582, 0.3338651960183463},
{3.710910700915217, 0.9937713340192049}, {3.0706987088385853, 0.9376313558467103},
{3.572744183805594, 0.33184908855075124}, {3.7080407833612004, 0.09804238103130436},
{3.70669993057843, 0.7485845679979923}, {3.3588457228653024, 0.2346381514128677},
{2.0697434332621234, 1.1809465376402173}, {2.5322042870739683, 1.419555755682142},
{2.175448214220591, 1.2372448404986038}, {2.113652420701984, 1.2774712415624014},
{2.520755151373394, 1.902015274420646}, {2.9909779614491687, 1.2420487904041893},
{2.4613232527836137, 1.0484414482621331}, {4.975578758530645, 0.9606291981013242},
{4.07037627210835, 1.9486902798139454}, {4.300706849071861, 0.021365525588281198},
{4.5584381091040616, 1.8996548860019926}, {4.822583857757069, 0.3234041700489503},
{4.849847745942472, 1.9531893897409585}, {4.75489831780737, 0.7800065259479418},
{4.529792124514895, 1.942673409259531}, {4.732546857961497, 0.5659923375279095},
{3.7622247877537456, 2.8709552313924487}, {3.2648444465931474, 2.693039435509084},
{3.01954722322135, 2.57810040095543}, {3.7164018490892348, 2.4612194182614333},
{3.7002781846945347, 2.3345952955903906}, {2.493975723955388, 3.3999020934055837},
{2.1807636574967466, 3.2296461832828114}, {2.566986568683904, 3.6607732238530897},
{2.2006520196663066, 3.7672478678985257}, {2.5104987015171574, 3.0668114607133137},
{2.8222482218882474, 3.8159308233351266}, {2.241538022180476, 3.8812819070357545},
{2.3007438625108882, 3.6045900851589048}, {6.0821276168848994, 2.5470532680258002},
{6.291790729917634, 2.983311357415729}, {6.109985464455084, 2.2235950639628523},
{6.101327777646798, 2.5239201807166616}, {6.325158445513714, 2.8765450351723674},
{6.6793884701899, 2.5605928243991434}, {6.4274219368674315, 2.9754616970668213},
{6.444584786789386, 2.174562817047202}, {7.897735998643542, 3.380784914178574},
{7.079453687660189, 3.063690547962938}, {7.430677191305505, 3.380489849365283},
{7.5085184104988, 3.623862886287816}, {7.886010001346151, 3.538128217886674},
{7.250745898479374, 3.4154469467473447}, {7.769497359206111, 3.253257011908445},
{1.8703303641352362, 4.209727933188015}, {1.7015273093278767, 7.478882372510933},
{2.7456295127617385, 7.474216636277054}, {2.2065031771469, 6.896038613284851},
{3.86008672302403, 7.513564222799629}, {1.9143371250907073, 6.885401350515916},
{3.7176098065039747, 6.194330707468438}, {0.059011873032214, 5.823535317960799},
{3.1162712022943757, 6.789029097334483}, {2.4264509160270813, 5.188939408363776},
{3.154282922203257, 5.788316610960881}});
// build a quadtree on the points
auto [point_indices, quadtree] = cuspatial::quadtree_on_points(
points.begin(), points.end(), v_min, v_max, scale, max_depth, max_size, this->stream());
T const expansion_radius{2.0};
auto multilinestring_array =
cuspatial::test::make_multilinestring_array<T>({0, 1, 2, 3, 4},
{0, 4, 10, 14, 19},
{// ring 1
{2.488450, 5.856625},
{1.333584, 5.008840},
{3.460720, 4.586599},
{2.488450, 5.856625},
// ring 2
{5.039823, 4.229242},
{5.561707, 1.825073},
{7.103516, 1.503906},
{7.190674, 4.025879},
{5.998939, 5.653384},
{5.039823, 4.229242},
// ring 3
{5.998939, 1.235638},
{5.573720, 0.197808},
{6.703534, 0.086693},
{5.998939, 1.235638},
// ring 4
{2.088115, 4.541529},
{1.034892, 3.530299},
{2.415080, 2.896937},
{3.208660, 3.745936},
{2.088115, 4.541529}});
auto multilinestrings = multilinestring_array.range();
auto bboxes =
rmm::device_uvector<cuspatial::box<T>>(multilinestrings.num_linestrings(), this->stream());
cuspatial::linestring_bounding_boxes(multilinestrings.part_offset_begin(),
multilinestrings.part_offset_end(),
multilinestrings.point_begin(),
multilinestrings.point_end(),
bboxes.begin(),
expansion_radius,
this->stream());
auto [linestring_indices, quad_indices] = cuspatial::join_quadtree_and_bounding_boxes(
quadtree, bboxes.begin(), bboxes.end(), v_min, scale, max_depth, this->stream(), this->mr());
// This tests the output of `join_quadtree_and_bounding_boxes` for correctness, rather than
// repeating this test standalone.
{
auto expected_linestring_indices =
make_device_vector<uint32_t>({3, 1, 2, 3, 3, 0, 1, 2, 3, 0, 3, 1, 2, 3, 1, 2, 1, 2, 0, 1, 3});
auto expected_quad_indices = make_device_vector<uint32_t>(
{3, 8, 8, 8, 9, 10, 10, 10, 10, 11, 11, 6, 6, 6, 12, 12, 13, 13, 2, 2, 2});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(linestring_indices, expected_linestring_indices);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(quad_indices, expected_quad_indices);
}
auto [point_idx, linestring_idx, distance] =
cuspatial::quadtree_point_to_nearest_linestring(linestring_indices.begin(),
linestring_indices.end(),
quad_indices.begin(),
quadtree,
point_indices.begin(),
point_indices.end(),
points.begin(),
multilinestrings,
this->stream());
auto expected_distances = []() {
if constexpr (std::is_same_v<T, float>) {
return make_device_vector<T>(
{3.06755614, 2.55945015, 2.98496079, 1.71036518, 1.82931805, 1.60950696,
1.68141198, 2.38382101, 2.55103993, 1.66121042, 2.02551198, 2.06608653,
2.0054605, 1.86834478, 1.94656599, 2.2151804, 1.75039434, 1.48201656,
1.67690217, 1.6472789, 1.00051796, 1.75223088, 1.84907377, 1.00189602,
0.760027468, 0.65931344, 1.24821293, 1.32290053, 0.285818338, 0.204662085,
0.41061914, 0.566183507, 0.0462928228, 0.166630849, 0.449532568, 0.566757083,
0.842694938, 1.2851826, 0.761564255, 0.978420198, 0.917963803, 1.43116546,
0.964613676, 0.668479323, 0.983481824, 0.661732435, 0.862337708, 0.50195682,
0.675588429, 0.825302362, 0.460371286, 0.726516545, 0.5221892, 0.728920817,
0.0779202655, 0.262149751, 0.331539005, 0.711767673, 0.0811179057, 0.605163872,
0.0885084718, 1.51270044, 0.389437437, 0.487170845, 1.17812812, 1.8030436,
1.07697463, 1.1812768, 1.12407148, 1.63790822, 2.15100765});
} else {
return make_device_vector<T>(
{3.0675562686570932, 2.5594501016565698, 2.9849608928964071, 1.7103652150920774,
1.8293181280383963, 1.6095070428899729, 1.681412227243898, 2.3838209461314879,
2.5510398428020409, 1.6612106150272572, 2.0255119347250292, 2.0660867596957564,
2.005460353737949, 1.8683447535522375, 1.9465658908648766, 2.215180472008103,
1.7503944159063249, 1.4820166799617225, 1.6769023397521503, 1.6472789467219351,
1.0005181046076022, 1.7522309916961678, 1.8490738879835735, 1.0018961233717569,
0.76002760100291122, 0.65931355999132091, 1.2482129257770731, 1.3229005055827028,
0.28581819228716798, 0.20466187296772376, 0.41061901127492934, 0.56618357460517321,
0.046292709584059538, 0.16663093663041179, 0.44953247369220306, 0.56675685520587671,
0.8426949387264755, 1.2851826443010033, 0.7615641155638555, 0.97842040913621187,
0.91796378078050755, 1.4311654461101424, 0.96461369875795078, 0.66847988653443491,
0.98348202146010699, 0.66173276971965733, 0.86233789031448094, 0.50195678903916696,
0.6755886291567379, 0.82530249944765133, 0.46037120394920633, 0.72651648874084795,
0.52218906793095576, 0.72892093000338909, 0.077921089704128393, 0.26215098141130333,
0.33153993710577778, 0.71176747526132511, 0.081119666144327182, 0.60516346789266895,
0.088508309264124049, 1.5127004224070386, 0.38943741327066272, 0.48717099143018805,
1.1781283344854494, 1.8030436222567465, 1.0769747770485747, 1.181276832710481,
1.1240715558969043, 1.6379084234284416, 2.1510078772519496});
}
}();
auto expected_point_indices = make_device_vector<std::uint32_t>(
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70});
auto expected_linestring_indices = make_device_vector<std::uint32_t>(
{3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 3, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected_point_indices, point_idx);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected_linestring_indices, linestring_idx);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected_distances, distance);
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/join/quadtree_point_in_polygon_test.cpp | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column.hpp>
#include <cuspatial/bounding_boxes.hpp>
#include <cuspatial/error.hpp>
#include <cuspatial/geometry/vec_2d.hpp>
#include <cuspatial/point_quadtree.hpp>
#include <cuspatial/spatial_join.hpp>
#include <cudf/table/table.hpp>
#include <cudf/table/table_view.hpp>
#include <cudf/utilities/error.hpp>
#include <cudf_test/column_utilities.hpp>
#include <cudf_test/column_wrapper.hpp>
#include <cudf_test/table_utilities.hpp>
#include <memory>
using T = float;
template <typename T>
using wrapper = cudf::test::fixed_width_column_wrapper<T>;
struct QuadtreePointInPolygonErrorTest : public ::testing::Test {
auto prepare_test(cudf::column_view const& x,
cudf::column_view const& y,
cudf::column_view const& polygon_offsets,
cudf::column_view const& ring_offsets,
cudf::column_view const& polygon_x,
cudf::column_view const& polygon_y,
cuspatial::vec_2d<T> v_min,
cuspatial::vec_2d<T> v_max,
T scale,
uint32_t max_depth,
uint32_t min_size,
T expansion_radius)
{
using namespace cudf::test;
auto quadtree_pair = cuspatial::quadtree_on_points(
x, y, v_min.x, v_max.x, v_min.y, v_max.y, scale, max_depth, min_size);
auto& quadtree = std::get<1>(quadtree_pair);
auto& point_indices = std::get<0>(quadtree_pair);
auto polygon_bboxes = cuspatial::polygon_bounding_boxes(
polygon_offsets, ring_offsets, polygon_x, polygon_y, expansion_radius);
auto polygon_quadrant_pairs = cuspatial::join_quadtree_and_bounding_boxes(
*quadtree, *polygon_bboxes, v_min.x, v_max.x, v_min.y, v_max.y, scale, max_depth);
return std::make_tuple(std::move(quadtree),
std::move(point_indices),
std::move(polygon_bboxes),
std::move(polygon_quadrant_pairs));
}
void SetUp() override
{
using namespace cudf::test;
cuspatial::vec_2d<T> v_min{0.0, 0.0};
cuspatial::vec_2d<T> v_max{8.0, 8.0};
double const scale{1.0};
uint32_t const max_depth{3};
uint32_t const min_size{12};
double const expansion_radius{0.0};
auto x_col =
wrapper<T>({1.9804558865545805, 0.1895259128530169, 1.2591725716781235, 0.8178039499335275});
auto y_col =
wrapper<T>({1.3472225743317712, 0.5431061133894604, 0.1448705855995005, 0.8138440641113271});
auto polygon_offsets_col = wrapper<std::int32_t>({0, 4, 10});
auto ring_offsets_col = wrapper<std::int32_t>({0, 4, 10});
auto polygon_x_col = wrapper<T>({// ring 1
2.488450,
1.333584,
3.460720,
2.488450,
// ring 2
5.039823,
5.561707,
7.103516,
7.190674,
5.998939,
5.039823});
auto polygon_y_col = wrapper<T>({// ring 1
2.488450,
1.333584,
3.460720,
2.488450,
// ring 2
5.039823,
5.561707,
7.103516,
7.190674,
5.998939,
5.039823});
std::tie(quadtree, point_indices, polygon_bboxes, polygon_quadrant_pairs) =
prepare_test(x_col,
y_col,
polygon_offsets_col,
ring_offsets_col,
polygon_x_col,
polygon_y_col,
v_min,
v_max,
scale,
max_depth,
min_size,
expansion_radius);
x = x_col.release();
y = y_col.release();
polygon_offsets = polygon_offsets_col.release();
ring_offsets = ring_offsets_col.release();
polygon_x = polygon_x_col.release();
polygon_y = polygon_y_col.release();
}
void TearDown() override {}
std::unique_ptr<cudf::column> x;
std::unique_ptr<cudf::column> y;
std::unique_ptr<cudf::column> polygon_offsets;
std::unique_ptr<cudf::column> ring_offsets;
std::unique_ptr<cudf::column> polygon_x;
std::unique_ptr<cudf::column> polygon_y;
std::unique_ptr<cudf::column> point_indices;
std::unique_ptr<cudf::table> quadtree;
std::unique_ptr<cudf::table> polygon_bboxes;
std::unique_ptr<cudf::table> polygon_quadrant_pairs;
};
// test cudf::quadtree_point_in_polygon with empty inputs
TEST_F(QuadtreePointInPolygonErrorTest, test_empty)
{
// empty point data
{
auto empty_point_indices = wrapper<std::uint32_t>({});
auto empty_x = wrapper<T>({});
auto empty_y = wrapper<T>({});
auto results = cuspatial::quadtree_point_in_polygon(*polygon_quadrant_pairs,
*quadtree,
empty_point_indices,
empty_x,
empty_y,
*polygon_offsets,
*ring_offsets,
*polygon_x,
*polygon_y);
auto expected_poly_offset = wrapper<std::uint32_t>({});
auto expected_point_offset = wrapper<std::uint32_t>({});
auto expected = cudf::table_view{
{cudf::column_view(expected_poly_offset), cudf::column_view(expected_point_offset)}};
CUDF_TEST_EXPECT_TABLES_EQUIVALENT(expected, *results);
}
// empty polygon data
{
auto empty_polygon_offsets = wrapper<std::uint32_t>({});
auto empty_ring_offsets = wrapper<std::uint32_t>({});
auto empty_polygon_x = wrapper<T>({});
auto empty_polygon_y = wrapper<T>({});
auto results = cuspatial::quadtree_point_in_polygon(*polygon_quadrant_pairs,
*quadtree,
*point_indices,
*x,
*y,
empty_polygon_offsets,
empty_ring_offsets,
empty_polygon_x,
empty_polygon_y);
auto expected_poly_offset = wrapper<std::uint32_t>({});
auto expected_point_offset = wrapper<std::uint32_t>({});
auto expected = cudf::table_view{
{cudf::column_view(expected_poly_offset), cudf::column_view(expected_point_offset)}};
CUDF_TEST_EXPECT_TABLES_EQUIVALENT(expected, *results);
}
}
TEST_F(QuadtreePointInPolygonErrorTest, type_mismatch)
{
// x/y type mismatch
{
auto x_col = wrapper<int32_t>({1, 2, 3, 4});
auto y_col = wrapper<float>({1, 2, 3, 4});
EXPECT_THROW(cuspatial::quadtree_point_in_polygon(*polygon_quadrant_pairs,
*quadtree,
*point_indices,
x_col,
y_col,
*polygon_offsets,
*ring_offsets,
*polygon_x,
*polygon_y),
cuspatial::logic_error);
}
// polygon_x/polygon_y type mismatch
{
auto polygon_x_col = wrapper<int32_t>({1, 2, 3, 4});
auto polygon_y_col = wrapper<float>({1, 2, 3, 4});
EXPECT_THROW(cuspatial::quadtree_point_in_polygon(*polygon_quadrant_pairs,
*quadtree,
*point_indices,
*x,
*y,
*polygon_offsets,
*ring_offsets,
polygon_x_col,
polygon_y_col),
cuspatial::logic_error);
}
// x / polygon_x type mismatch
{
auto x_col = wrapper<int32_t>({1, 2, 3, 4});
auto polygon_x_col = wrapper<float>({1, 2, 3, 4});
EXPECT_THROW(cuspatial::quadtree_point_in_polygon(*polygon_quadrant_pairs,
*quadtree,
*point_indices,
x_col,
*y,
*polygon_offsets,
*ring_offsets,
polygon_x_col,
*polygon_y),
cuspatial::logic_error);
}
}
TEST_F(QuadtreePointInPolygonErrorTest, offset_type_error)
{
{
auto polygon_offsets_col = wrapper<float>({0, 4, 10});
auto ring_offsets_col = wrapper<std::int32_t>({0, 4, 10});
EXPECT_THROW(cuspatial::quadtree_point_in_polygon(*polygon_quadrant_pairs,
*quadtree,
*point_indices,
*x,
*y,
polygon_offsets_col,
ring_offsets_col,
*polygon_x,
*polygon_y),
cuspatial::logic_error);
}
}
TEST_F(QuadtreePointInPolygonErrorTest, size_mismatch)
{
{
auto polygon_offsets_col = wrapper<int32_t>({0, 4, 10});
auto ring_offsets_col = wrapper<int32_t>({0, 4, 10});
auto poly_x = wrapper<float>({1, 2, 3, 4, 5, 6, 7, 8, 9, 10});
auto poly_y = wrapper<float>({1, 2, 3, 4, 5, 6});
EXPECT_THROW(cuspatial::quadtree_point_in_polygon(*polygon_quadrant_pairs,
*quadtree,
*point_indices,
*x,
*y,
polygon_offsets_col,
ring_offsets_col,
poly_x,
poly_y),
cuspatial::logic_error);
}
{
auto point_indices = wrapper<int32_t>({0, 1, 2, 3, 4});
auto x = wrapper<float>({1, 2, 3, 4, 5, 6, 7, 8, 9, 10});
auto y = wrapper<float>({1, 2, 3, 4, 5, 6, 7, 8, 9, 10});
EXPECT_THROW(cuspatial::quadtree_point_in_polygon(*polygon_quadrant_pairs,
*quadtree,
point_indices,
x,
y,
*polygon_offsets,
*ring_offsets,
*polygon_x,
*polygon_y),
cuspatial::logic_error);
}
{
auto point_indices = wrapper<int32_t>({0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10});
auto x = wrapper<float>({1, 2, 3, 4, 5});
auto y = wrapper<float>({1, 2, 3, 4, 5, 6, 7, 8, 9, 10});
EXPECT_THROW(cuspatial::quadtree_point_in_polygon(*polygon_quadrant_pairs,
*quadtree,
point_indices,
x,
y,
*polygon_offsets,
*ring_offsets,
*polygon_x,
*polygon_y),
cuspatial::logic_error);
}
{
auto point_indices = wrapper<int32_t>({0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10});
auto x = wrapper<float>({1, 2, 3, 4, 5, 6, 7, 8, 9, 10});
auto y = wrapper<float>({1, 2, 3, 4, 5});
EXPECT_THROW(cuspatial::quadtree_point_in_polygon(*polygon_quadrant_pairs,
*quadtree,
point_indices,
x,
y,
*polygon_offsets,
*ring_offsets,
*polygon_x,
*polygon_y),
cuspatial::logic_error);
}
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/join/quadtree_point_in_polygon_test_large.cu | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cuspatial_test/base_fixture.hpp>
#include <cuspatial_test/random.cuh>
#include <cuspatial_test/test_util.cuh>
#include <cuspatial_test/vector_equality.hpp>
#include <cuspatial_test/vector_factories.cuh>
#include <cuspatial/bounding_boxes.cuh>
#include <cuspatial/error.hpp>
#include <cuspatial/geometry/box.hpp>
#include <cuspatial/point_in_polygon.cuh>
#include <cuspatial/spatial_join.cuh>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_uvector.hpp>
#include <rmm/exec_policy.hpp>
#include <rmm/mr/device/device_memory_resource.hpp>
#include <rmm/mr/device/per_device_resource.hpp>
#include <thrust/gather.h>
#include <thrust/sort.h>
/*
* The test uses the same quadtree structure as in pip_refine_test_small. However, the number of
* randomly generated points under all quadrants (min_size) are increased to be more than the
* number of threads per-block.
*/
template <typename T>
struct PIPRefineTestLarge : public cuspatial::test::BaseFixture {};
using TestTypes = ::testing::Types<float, double>;
TYPED_TEST_CASE(PIPRefineTestLarge, TestTypes);
template <typename T>
inline auto generate_points(
std::vector<std::vector<T>> const& quads,
uint32_t points_per_quad,
std::size_t seed,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource())
{
auto engine = cuspatial::test::deterministic_engine(0);
auto uniform = cuspatial::test::make_normal_dist<T>(0.0, 1.0);
auto pgen = cuspatial::test::point_generator(cuspatial::vec_2d<T>{0.0, 0.0},
cuspatial::vec_2d<T>{1.0, 1.0},
engine,
engine,
uniform,
uniform);
auto num_points = quads.size() * points_per_quad;
rmm::device_uvector<cuspatial::vec_2d<T>> points(num_points, stream, mr);
auto counting_iter = thrust::make_counting_iterator(seed);
thrust::transform(
rmm::exec_policy(stream), counting_iter, counting_iter + num_points, points.begin(), pgen);
return points;
}
TYPED_TEST(PIPRefineTestLarge, TestLarge)
{
using T = TypeParam;
using cuspatial::vec_2d;
using cuspatial::test::make_device_vector;
vec_2d<T> v_min{0.0, 0.0};
vec_2d<T> v_max{8.0, 8.0};
T const scale{1.0};
uint8_t const max_depth{3};
uint32_t const min_size{400};
std::vector<std::vector<T>> quads{{0, 2, 0, 2},
{3, 4, 0, 1},
{2, 3, 1, 2},
{4, 6, 0, 2},
{3, 4, 2, 3},
{2, 3, 3, 4},
{6, 7, 2, 3},
{7, 8, 3, 4},
{0, 4, 4, 8}};
auto points_in = generate_points<T>(quads, min_size, 0, this->stream());
auto [point_indices, quadtree] = quadtree_on_points(
points_in.begin(), points_in.end(), v_min, v_max, scale, max_depth, min_size, this->stream());
auto points = rmm::device_uvector<vec_2d<T>>(quads.size() * min_size, this->stream());
thrust::gather(rmm::exec_policy(this->stream()),
point_indices.begin(),
point_indices.end(),
points_in.begin(),
points.begin());
auto multipoly_array = cuspatial::test::make_multipolygon_array<T>({0, 1, 2, 3, 4},
{0, 1, 2, 3, 4},
{0, 4, 10, 14, 19},
{// ring 1
{2.488450, 5.856625},
{1.333584, 5.008840},
{3.460720, 4.586599},
{2.488450, 5.856625},
// ring 2
{5.039823, 4.229242},
{5.561707, 1.825073},
{7.103516, 1.503906},
{7.190674, 4.025879},
{5.998939, 5.653384},
{5.039823, 4.229242},
// ring 3
{5.998939, 1.235638},
{5.573720, 0.197808},
{6.703534, 0.086693},
{5.998939, 1.235638},
// ring 4
{2.088115, 4.541529},
{1.034892, 3.530299},
{2.415080, 2.896937},
{3.208660, 3.745936},
{2.088115, 4.541529}});
auto multipolygons = multipoly_array.range();
auto bboxes =
rmm::device_uvector<cuspatial::box<T>>(multipolygons.num_polygons(), this->stream());
cuspatial::polygon_bounding_boxes(multipolygons.part_offset_begin(),
multipolygons.part_offset_end(),
multipolygons.ring_offset_begin(),
multipolygons.ring_offset_end(),
multipolygons.point_begin(),
multipolygons.point_end(),
bboxes.begin(),
T{0},
this->stream());
auto [poly_indices, quad_indices] = cuspatial::join_quadtree_and_bounding_boxes(
quadtree, bboxes.begin(), bboxes.end(), v_min, scale, max_depth, this->stream());
auto [actual_poly_indices, actual_point_indices] =
cuspatial::quadtree_point_in_polygon(poly_indices.begin(),
poly_indices.end(),
quad_indices.begin(),
quadtree,
point_indices.begin(),
point_indices.end(),
points.begin(),
multipolygons,
this->stream());
thrust::stable_sort_by_key(rmm::exec_policy(this->stream()),
actual_point_indices.begin(),
actual_point_indices.end(),
actual_poly_indices.begin());
{ // verify
rmm::device_uvector<int32_t> hits(points.size(), this->stream());
auto points_range = make_multipoint_range(
points.size(), thrust::make_counting_iterator(0), points.size(), points.begin());
auto polygons_range = make_multipolygon_range(multipolygons.size(),
thrust::make_counting_iterator(0),
multipolygons.size(),
multipolygons.part_offset_begin(),
multipolygons.num_rings(),
multipolygons.ring_offset_begin(),
multipolygons.num_points(),
multipolygons.point_begin());
auto hits_end =
cuspatial::point_in_polygon(points_range, polygons_range, hits.begin(), this->stream());
auto hits_host = cuspatial::test::to_host<int32_t>(hits);
std::vector<uint32_t> expected_poly_indices;
std::vector<uint32_t> expected_point_indices;
for (std::size_t point_index = 0; point_index < hits_host.size(); point_index++) {
// iterate over set bits
std::uint32_t bits = hits_host[point_index];
while (bits != 0) {
std::uint32_t t = bits & -bits; // get only LSB
std::uint32_t poly_index = __builtin_ctz(bits); // get index of LSB
expected_poly_indices.push_back(poly_index);
expected_point_indices.push_back(point_index);
bits ^= t; // reset LSB to zero to advance to next set bit
}
}
// TODO: shouldn't have to copy to device here, but I get Thrust compilation errors if I use
// host vectors and a host stable_sort_by_key.
auto d_expected_poly_indices = rmm::device_vector<std::uint32_t>(expected_poly_indices);
auto d_expected_point_indices = rmm::device_vector<std::uint32_t>(expected_point_indices);
thrust::stable_sort_by_key(rmm::exec_policy(this->stream()),
d_expected_point_indices.begin(),
d_expected_point_indices.end(),
d_expected_poly_indices.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_expected_poly_indices, actual_poly_indices);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_expected_point_indices, actual_point_indices);
}
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/join/quadtree_point_to_nearest_linestring_test.cpp | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column.hpp>
#include <cuspatial/bounding_boxes.hpp>
#include <cuspatial/error.hpp>
#include <cuspatial/geometry/vec_2d.hpp>
#include <cuspatial/point_quadtree.hpp>
#include <cuspatial/spatial_join.hpp>
#include <cudf/table/table.hpp>
#include <cudf/table/table_view.hpp>
#include <cudf/utilities/error.hpp>
#include <cudf_test/column_utilities.hpp>
#include <cudf_test/column_wrapper.hpp>
#include <cudf_test/table_utilities.hpp>
#include <memory>
using T = float;
template <typename T>
using wrapper = cudf::test::fixed_width_column_wrapper<T>;
struct QuadtreePointToNearestLinestringErrorTest : public ::testing::Test {
auto prepare_test(cudf::column_view const& x,
cudf::column_view const& y,
cudf::column_view const& linestring_offsets,
cudf::column_view const& polygon_x,
cudf::column_view const& polygon_y,
cuspatial::vec_2d<T> v_min,
cuspatial::vec_2d<T> v_max,
T scale,
uint32_t max_depth,
uint32_t min_size,
T expansion_radius)
{
using namespace cudf::test;
auto quadtree_pair = cuspatial::quadtree_on_points(
x, y, v_min.x, v_max.x, v_min.y, v_max.y, scale, max_depth, min_size);
auto& quadtree = std::get<1>(quadtree_pair);
auto& point_indices = std::get<0>(quadtree_pair);
auto linestring_bboxes = cuspatial::linestring_bounding_boxes(
linestring_offsets, polygon_x, polygon_y, expansion_radius);
auto linestring_quadrant_pairs = cuspatial::join_quadtree_and_bounding_boxes(
*quadtree, *linestring_bboxes, v_min.x, v_max.x, v_min.y, v_max.y, scale, max_depth);
return std::make_tuple(std::move(quadtree),
std::move(point_indices),
std::move(linestring_bboxes),
std::move(linestring_quadrant_pairs));
}
void SetUp() override
{
using namespace cudf::test;
cuspatial::vec_2d<T> v_min{0.0, 0.0};
cuspatial::vec_2d<T> v_max{8.0, 8.0};
double const scale{1.0};
uint32_t const max_depth{3};
uint32_t const min_size{12};
double const expansion_radius{0.0};
auto x_col =
wrapper<T>({1.9804558865545805, 0.1895259128530169, 1.2591725716781235, 0.8178039499335275});
auto y_col =
wrapper<T>({1.3472225743317712, 0.5431061133894604, 0.1448705855995005, 0.8138440641113271});
auto linestring_offsets_col = wrapper<std::int32_t>({0, 4, 10});
auto linestring_x_col = wrapper<T>({// ring 1
2.488450,
1.333584,
3.460720,
2.488450,
// ring 2
5.039823,
5.561707,
7.103516,
7.190674,
5.998939,
5.039823});
auto linestring_y_col = wrapper<T>({// ring 1
2.488450,
1.333584,
3.460720,
2.488450,
// ring 2
5.039823,
5.561707,
7.103516,
7.190674,
5.998939,
5.039823});
std::tie(quadtree, point_indices, linestring_bboxes, linestring_quadrant_pairs) =
prepare_test(x_col,
y_col,
linestring_offsets_col,
linestring_x_col,
linestring_y_col,
v_min,
v_max,
scale,
max_depth,
min_size,
expansion_radius);
x = x_col.release();
y = y_col.release();
linestring_offsets = linestring_offsets_col.release();
linestring_x = linestring_x_col.release();
linestring_y = linestring_y_col.release();
}
void TearDown() override {}
std::unique_ptr<cudf::column> x;
std::unique_ptr<cudf::column> y;
std::unique_ptr<cudf::column> linestring_offsets;
std::unique_ptr<cudf::column> linestring_x;
std::unique_ptr<cudf::column> linestring_y;
std::unique_ptr<cudf::column> point_indices;
std::unique_ptr<cudf::table> quadtree;
std::unique_ptr<cudf::table> linestring_bboxes;
std::unique_ptr<cudf::table> linestring_quadrant_pairs;
};
// test cudf::quadtree_point_in_polygon with empty inputs
TEST_F(QuadtreePointToNearestLinestringErrorTest, test_empty)
{
// empty point data
{
auto empty_point_indices = wrapper<std::uint32_t>({});
auto empty_x = wrapper<T>({});
auto empty_y = wrapper<T>({});
auto results = cuspatial::quadtree_point_to_nearest_linestring(*linestring_quadrant_pairs,
*quadtree,
empty_point_indices,
empty_x,
empty_y,
*linestring_offsets,
*linestring_x,
*linestring_y);
auto expected_linestring_offset = wrapper<std::uint32_t>({});
auto expected_point_offset = wrapper<std::uint32_t>({});
auto expected_distance = wrapper<T>({});
auto expected =
cudf::table_view{{expected_linestring_offset, expected_point_offset, expected_distance}};
CUDF_TEST_EXPECT_TABLES_EQUIVALENT(expected, *results);
}
// empty linestring data
{
auto empty_linestring_offsets = wrapper<std::uint32_t>({});
auto empty_linestring_x = wrapper<T>({});
auto empty_linestring_y = wrapper<T>({});
auto results = cuspatial::quadtree_point_to_nearest_linestring(*linestring_quadrant_pairs,
*quadtree,
*point_indices,
*x,
*y,
empty_linestring_offsets,
empty_linestring_x,
empty_linestring_y);
auto expected_linestring_offset = wrapper<std::uint32_t>({});
auto expected_point_offset = wrapper<std::uint32_t>({});
auto expected_distance = wrapper<T>({});
auto expected =
cudf::table_view{{expected_linestring_offset, expected_point_offset, expected_distance}};
CUDF_TEST_EXPECT_TABLES_EQUIVALENT(expected, *results);
}
}
TEST_F(QuadtreePointToNearestLinestringErrorTest, type_mismatch)
{
// x/y type mismatch
{
auto x_col = wrapper<int32_t>({1, 2, 3, 4});
auto y_col = wrapper<float>({1, 2, 3, 4});
EXPECT_THROW(cuspatial::quadtree_point_to_nearest_linestring(*linestring_quadrant_pairs,
*quadtree,
*point_indices,
x_col,
y_col,
*linestring_offsets,
*linestring_x,
*linestring_y),
cuspatial::logic_error);
}
// linestring_x/linestring_y type mismatch
{
auto linestring_x_col = wrapper<int32_t>({1, 2, 3, 4});
auto linestring_y_col = wrapper<float>({1, 2, 3, 4});
EXPECT_THROW(cuspatial::quadtree_point_to_nearest_linestring(*linestring_quadrant_pairs,
*quadtree,
*point_indices,
*x,
*y,
*linestring_offsets,
linestring_x_col,
linestring_y_col),
cuspatial::logic_error);
}
// x / linestring_x type mismatch
{
auto x_col = wrapper<int32_t>({1, 2, 3, 4});
auto linestring_x_col = wrapper<float>({1, 2, 3, 4});
EXPECT_THROW(cuspatial::quadtree_point_to_nearest_linestring(*linestring_quadrant_pairs,
*quadtree,
*point_indices,
x_col,
*y,
*linestring_offsets,
linestring_x_col,
*linestring_y),
cuspatial::logic_error);
}
}
TEST_F(QuadtreePointToNearestLinestringErrorTest, size_mismatch)
{
{
auto linestring_offsets_col = wrapper<int32_t>({0, 4, 10});
auto linestring_x = wrapper<float>({1, 2, 3, 4, 5, 6, 7, 8, 9, 10});
auto linestring_y = wrapper<float>({1, 2, 3, 4, 5, 6});
EXPECT_THROW(cuspatial::quadtree_point_to_nearest_linestring(*linestring_quadrant_pairs,
*quadtree,
*point_indices,
*x,
*y,
linestring_offsets_col,
linestring_x,
linestring_y),
cuspatial::logic_error);
}
{
auto point_indices = wrapper<int32_t>({0, 1, 2, 3, 4});
auto x = wrapper<float>({1, 2, 3, 4, 5, 6, 7, 8, 9, 10});
auto y = wrapper<float>({1, 2, 3, 4, 5, 6, 7, 8, 9, 10});
EXPECT_THROW(cuspatial::quadtree_point_to_nearest_linestring(*linestring_quadrant_pairs,
*quadtree,
point_indices,
x,
y,
*linestring_offsets,
*linestring_x,
*linestring_y),
cuspatial::logic_error);
}
{
auto point_indices = wrapper<int32_t>({0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10});
auto x = wrapper<float>({1, 2, 3, 4, 5});
auto y = wrapper<float>({1, 2, 3, 4, 5, 6, 7, 8, 9, 10});
EXPECT_THROW(cuspatial::quadtree_point_to_nearest_linestring(*linestring_quadrant_pairs,
*quadtree,
point_indices,
x,
y,
*linestring_offsets,
*linestring_x,
*linestring_y),
cuspatial::logic_error);
}
{
auto point_indices = wrapper<int32_t>({0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10});
auto x = wrapper<float>({1, 2, 3, 4, 5, 6, 7, 8, 9, 10});
auto y = wrapper<float>({1, 2, 3, 4, 5});
EXPECT_THROW(cuspatial::quadtree_point_to_nearest_linestring(*linestring_quadrant_pairs,
*quadtree,
point_indices,
x,
y,
*linestring_offsets,
*linestring_x,
*linestring_y),
cuspatial::logic_error);
}
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/join/join_quadtree_and_bounding_boxes_test.cu | /*
* Copyright (c) 2020-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cuspatial_test/base_fixture.hpp>
#include <cuspatial_test/vector_equality.hpp>
#include <cuspatial_test/vector_factories.cuh>
#include <cuspatial/error.hpp>
#include <cuspatial/point_quadtree.cuh>
#include <cuspatial/spatial_join.cuh>
// Note: the detailed correctness test of the join_quadtree_and_bounding_boxes() function is covered
// by the quadtree_point_in_polygon_test_small.cu test file.
template <typename T>
struct JoinQuadtreeAndBoundingBoxesErrorTest : public cuspatial::test::BaseFixture {};
using TestTypes = ::testing::Types<float, double>;
TYPED_TEST_CASE(JoinQuadtreeAndBoundingBoxesErrorTest, TestTypes);
TYPED_TEST(JoinQuadtreeAndBoundingBoxesErrorTest, test_empty)
{
using T = TypeParam;
using namespace cuspatial;
using cuspatial::vec_2d;
using cuspatial::test::make_device_vector;
vec_2d<T> v_min{0.0, 0.0};
T const scale{1.0};
uint8_t const max_depth{1};
auto empty_quadtree = point_quadtree_ref{nullptr, nullptr, nullptr, nullptr, nullptr, nullptr};
auto empty_bboxes = rmm::device_uvector<box<T>>{0, this->stream()};
auto [polygon_idx, quad_idx] = cuspatial::join_quadtree_and_bounding_boxes(empty_quadtree,
empty_bboxes.begin(),
empty_bboxes.end(),
v_min,
scale,
max_depth,
this->stream());
auto expected_polygon_idx = rmm::device_uvector<std::uint32_t>{0, this->stream()};
auto expected_quad_idx = rmm::device_uvector<std::uint32_t>{0, this->stream()};
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected_polygon_idx, polygon_idx);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected_quad_idx, quad_idx);
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/join/quadtree_point_in_polygon_test_small.cu | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cuspatial_test/base_fixture.hpp>
#include <cuspatial_test/vector_equality.hpp>
#include <cuspatial_test/vector_factories.cuh>
#include <cuspatial/bounding_boxes.cuh>
#include <cuspatial/error.hpp>
#include <cuspatial/point_quadtree.cuh>
#include <cuspatial/range/multipolygon_range.cuh>
#include <cuspatial/spatial_join.cuh>
#include <gtest/gtest.h>
#include <initializer_list>
/*
* A small test that it is suitable for manually visualizing point-polygon pairing results in a GIS
* environment. GPU results are compared with expected values embedded in code. However, the number
* of points in each quadrant is less than 32, the two kernels for point-in-polygon test are not
* fully tested.
*/
template <typename T>
struct PIPRefineTestSmall : public cuspatial::test::BaseFixture {};
using TestTypes = ::testing::Types<float, double>;
TYPED_TEST_CASE(PIPRefineTestSmall, TestTypes);
TYPED_TEST(PIPRefineTestSmall, TestSmall)
{
using T = TypeParam;
using cuspatial::vec_2d;
using cuspatial::test::make_device_vector;
vec_2d<T> v_min{0.0, 0.0};
vec_2d<T> v_max{8.0, 8.0};
T const scale{1.0};
uint8_t const max_depth{3};
uint32_t const max_size{12};
auto points = make_device_vector<vec_2d<T>>(
{{1.9804558865545805, 1.3472225743317712}, {0.1895259128530169, 0.5431061133894604},
{1.2591725716781235, 0.1448705855995005}, {0.8178039499335275, 0.8138440641113271},
{0.48171647380517046, 1.9022922214961997}, {1.3890664414691907, 1.5177694304735412},
{0.2536015260915061, 1.8762161698642947}, {3.1907684812039956, 0.2621847215928189},
{3.028362149164369, 0.027638405909631958}, {3.918090468102582, 0.3338651960183463},
{3.710910700915217, 0.9937713340192049}, {3.0706987088385853, 0.9376313558467103},
{3.572744183805594, 0.33184908855075124}, {3.7080407833612004, 0.09804238103130436},
{3.70669993057843, 0.7485845679979923}, {3.3588457228653024, 0.2346381514128677},
{2.0697434332621234, 1.1809465376402173}, {2.5322042870739683, 1.419555755682142},
{2.175448214220591, 1.2372448404986038}, {2.113652420701984, 1.2774712415624014},
{2.520755151373394, 1.902015274420646}, {2.9909779614491687, 1.2420487904041893},
{2.4613232527836137, 1.0484414482621331}, {4.975578758530645, 0.9606291981013242},
{4.07037627210835, 1.9486902798139454}, {4.300706849071861, 0.021365525588281198},
{4.5584381091040616, 1.8996548860019926}, {4.822583857757069, 0.3234041700489503},
{4.849847745942472, 1.9531893897409585}, {4.75489831780737, 0.7800065259479418},
{4.529792124514895, 1.942673409259531}, {4.732546857961497, 0.5659923375279095},
{3.7622247877537456, 2.8709552313924487}, {3.2648444465931474, 2.693039435509084},
{3.01954722322135, 2.57810040095543}, {3.7164018490892348, 2.4612194182614333},
{3.7002781846945347, 2.3345952955903906}, {2.493975723955388, 3.3999020934055837},
{2.1807636574967466, 3.2296461832828114}, {2.566986568683904, 3.6607732238530897},
{2.2006520196663066, 3.7672478678985257}, {2.5104987015171574, 3.0668114607133137},
{2.8222482218882474, 3.8159308233351266}, {2.241538022180476, 3.8812819070357545},
{2.3007438625108882, 3.6045900851589048}, {6.0821276168848994, 2.5470532680258002},
{6.291790729917634, 2.983311357415729}, {6.109985464455084, 2.2235950639628523},
{6.101327777646798, 2.5239201807166616}, {6.325158445513714, 2.8765450351723674},
{6.6793884701899, 2.5605928243991434}, {6.4274219368674315, 2.9754616970668213},
{6.444584786789386, 2.174562817047202}, {7.897735998643542, 3.380784914178574},
{7.079453687660189, 3.063690547962938}, {7.430677191305505, 3.380489849365283},
{7.5085184104988, 3.623862886287816}, {7.886010001346151, 3.538128217886674},
{7.250745898479374, 3.4154469467473447}, {7.769497359206111, 3.253257011908445},
{1.8703303641352362, 4.209727933188015}, {1.7015273093278767, 7.478882372510933},
{2.7456295127617385, 7.474216636277054}, {2.2065031771469, 6.896038613284851},
{3.86008672302403, 7.513564222799629}, {1.9143371250907073, 6.885401350515916},
{3.7176098065039747, 6.194330707468438}, {0.059011873032214, 5.823535317960799},
{3.1162712022943757, 6.789029097334483}, {2.4264509160270813, 5.188939408363776},
{3.154282922203257, 5.788316610960881}});
// build a quadtree on the points
auto [point_indices, quadtree] = cuspatial::quadtree_on_points(
points.begin(), points.end(), v_min, v_max, scale, max_depth, max_size, this->stream());
auto multipoly_array = cuspatial::test::make_multipolygon_array<T>({0, 1, 2, 3, 4},
{0, 1, 2, 3, 4},
{0, 4, 10, 14, 19},
{// ring 1
{2.488450, 5.856625},
{1.333584, 5.008840},
{3.460720, 4.586599},
{2.488450, 5.856625},
// ring 2
{5.039823, 4.229242},
{5.561707, 1.825073},
{7.103516, 1.503906},
{7.190674, 4.025879},
{5.998939, 5.653384},
{5.039823, 4.229242},
// ring 3
{5.998939, 1.235638},
{5.573720, 0.197808},
{6.703534, 0.086693},
{5.998939, 1.235638},
// ring 4
{2.088115, 4.541529},
{1.034892, 3.530299},
{2.415080, 2.896937},
{3.208660, 3.745936},
{2.088115, 4.541529}});
auto multipolygons = multipoly_array.range();
auto bboxes =
rmm::device_uvector<cuspatial::box<T>>(multipolygons.num_polygons(), this->stream());
cuspatial::polygon_bounding_boxes(multipolygons.part_offset_begin(),
multipolygons.part_offset_end(),
multipolygons.ring_offset_begin(),
multipolygons.ring_offset_end(),
multipolygons.point_begin(),
multipolygons.point_end(),
bboxes.begin(),
T{0},
this->stream());
auto [poly_indices, quad_indices] = cuspatial::join_quadtree_and_bounding_boxes(
quadtree, bboxes.begin(), bboxes.end(), v_min, scale, max_depth, this->stream(), this->mr());
{
auto expected_poly_indices = make_device_vector<uint32_t>({3, 3, 1, 2, 1, 1, 0, 3});
auto expected_quad_indices = make_device_vector<uint32_t>({10, 11, 6, 6, 12, 13, 2, 2});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(poly_indices, expected_poly_indices);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(quad_indices, expected_quad_indices);
}
auto [poly_offset, point_offset] = cuspatial::quadtree_point_in_polygon(poly_indices.begin(),
poly_indices.end(),
quad_indices.begin(),
quadtree,
point_indices.begin(),
point_indices.end(),
points.begin(),
multipolygons,
this->stream());
auto expected_poly_offset =
make_device_vector<uint32_t>({3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 3});
auto expected_point_offset = make_device_vector<uint32_t>(
{28, 29, 30, 31, 32, 33, 34, 35, 45, 46, 47, 48, 49, 50, 51, 52, 54, 62, 60});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(poly_offset, expected_poly_offset);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(point_offset, expected_point_offset);
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/join/join_quadtree_and_bounding_boxes_test.cpp | /*
* Copyright (c) 2020-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cuspatial/bounding_boxes.hpp>
#include <cuspatial/error.hpp>
#include <cuspatial/point_quadtree.hpp>
#include <cuspatial/spatial_join.hpp>
#include <cudf/table/table.hpp>
#include <cudf/table/table_view.hpp>
#include <cudf_test/base_fixture.hpp>
#include <cudf_test/column_utilities.hpp>
#include <cudf_test/column_wrapper.hpp>
#include <cudf_test/table_utilities.hpp>
#include <cudf_test/type_lists.hpp>
template <typename T>
struct JoinQuadtreeAndBoundingBoxesErrorTest : public cudf::test::BaseFixture {};
TYPED_TEST_CASE(JoinQuadtreeAndBoundingBoxesErrorTest, cudf::test::FloatingPointTypes);
TYPED_TEST(JoinQuadtreeAndBoundingBoxesErrorTest, test_errors)
{
using T = TypeParam;
using namespace cudf::test;
// bad table
cudf::table_view bad_quadtree{};
// bad bboxes
cudf::table_view bad_bboxes{};
// empty quadtree
cudf::table_view empty_quadtree{{
fixed_width_column_wrapper<int32_t>({}),
fixed_width_column_wrapper<int8_t>({}),
fixed_width_column_wrapper<bool>({}),
fixed_width_column_wrapper<int32_t>({}),
fixed_width_column_wrapper<int32_t>({}),
}};
// empty bboxes
cudf::table_view empty_bboxes{{fixed_width_column_wrapper<T>({}),
fixed_width_column_wrapper<T>({}),
fixed_width_column_wrapper<T>({}),
fixed_width_column_wrapper<T>({})}};
// Test throws on bad quadtree
EXPECT_THROW(cuspatial::join_quadtree_and_bounding_boxes(
bad_quadtree, empty_bboxes, 0, 1, 0, 1, 1, 1, this->mr()),
cuspatial::logic_error);
// Test throws on bad bboxes
EXPECT_THROW(cuspatial::join_quadtree_and_bounding_boxes(
empty_quadtree, bad_bboxes, 0, 1, 0, 1, 1, 1, this->mr()),
cuspatial::logic_error);
// Test throws on bad scale
EXPECT_THROW(cuspatial::join_quadtree_and_bounding_boxes(
empty_quadtree, empty_bboxes, 0, 1, 0, 1, 0, 1, this->mr()),
cuspatial::logic_error);
// Test throws on bad max_depth <= 0
EXPECT_THROW(cuspatial::join_quadtree_and_bounding_boxes(
empty_quadtree, empty_bboxes, 0, 1, 0, 1, 1, 0, this->mr()),
cuspatial::logic_error);
// Test throws on bad max_depth >= 16
EXPECT_THROW(cuspatial::join_quadtree_and_bounding_boxes(
empty_quadtree, empty_bboxes, 0, 1, 0, 1, 1, 16, this->mr()),
cuspatial::logic_error);
// Test throws on reversed area of interest bbox coordinates
EXPECT_THROW(cuspatial::join_quadtree_and_bounding_boxes(
empty_quadtree, empty_bboxes, 1, 0, 1, 0, 1, 1, this->mr()),
cuspatial::logic_error);
}
TYPED_TEST(JoinQuadtreeAndBoundingBoxesErrorTest, test_empty)
{
using T = TypeParam;
using namespace cudf::test;
double const x_min{0.0};
double const x_max{1.0};
double const y_min{0.0};
double const y_max{1.0};
double const scale{1.0};
uint32_t const max_depth{1};
// empty quadtree
cudf::table_view quadtree{{
fixed_width_column_wrapper<int32_t>({}),
fixed_width_column_wrapper<int8_t>({}),
fixed_width_column_wrapper<bool>({}),
fixed_width_column_wrapper<int32_t>({}),
fixed_width_column_wrapper<int32_t>({}),
}};
// empty bboxes
cudf::table_view bboxes{{fixed_width_column_wrapper<T>({}),
fixed_width_column_wrapper<T>({}),
fixed_width_column_wrapper<T>({}),
fixed_width_column_wrapper<T>({})}};
auto polygon_quadrant_pairs = cuspatial::join_quadtree_and_bounding_boxes(
quadtree, bboxes, x_min, x_max, y_min, y_max, scale, max_depth, this->mr());
auto expect_first = fixed_width_column_wrapper<uint32_t>({});
auto expect_second = fixed_width_column_wrapper<uint32_t>({});
auto expect = cudf::table_view{{expect_first, expect_second}};
CUDF_TEST_EXPECT_TABLES_EQUAL(expect, *polygon_quadrant_pairs);
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/index/point_quadtree_test.cu | /*
* 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 <cuspatial_test/vector_equality.hpp>
#include <cuspatial_test/vector_factories.cuh>
#include <cuspatial/geometry/vec_2d.hpp>
#include <cuspatial/point_quadtree.cuh>
template <typename T>
struct QuadtreeOnPointIndexingTest : public ::testing::Test {
void test(std::vector<cuspatial::vec_2d<T>> const& points,
const cuspatial::vec_2d<T> vertex_1,
const cuspatial::vec_2d<T> vertex_2,
const T scale,
const int8_t max_depth,
const int32_t max_size,
std::vector<uint32_t> const& expected_key,
std::vector<uint8_t> const& expected_level,
thrust::host_vector<bool> const& expected_is_internal_node,
std::vector<uint32_t> const& expected_length,
std::vector<uint32_t> const& expected_offset)
{
thrust::device_vector<cuspatial::vec_2d<T>> d_points{points};
auto [point_indices, tree] = cuspatial::quadtree_on_points(
d_points.begin(), d_points.end(), vertex_1, vertex_2, scale, max_depth, max_size);
EXPECT_EQ(point_indices.size(), points.size());
auto& key_d = tree.key;
auto& level_d = tree.level;
auto& is_internal_node_d = tree.internal_node_flag;
auto& length_d = tree.length;
auto& offset_d = tree.offset;
EXPECT_EQ(key_d.size(), expected_key.size());
EXPECT_EQ(level_d.size(), expected_level.size());
EXPECT_EQ(is_internal_node_d.size(), expected_is_internal_node.size());
EXPECT_EQ(length_d.size(), expected_length.size());
EXPECT_EQ(offset_d.size(), expected_offset.size());
using namespace cuspatial::test;
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected_key, key_d);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected_level, level_d);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected_is_internal_node, is_internal_node_d);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected_length, length_d);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected_offset, offset_d);
}
};
using TestTypes = ::testing::Types<float, double>;
TYPED_TEST_CASE(QuadtreeOnPointIndexingTest, TestTypes);
TYPED_TEST(QuadtreeOnPointIndexingTest, test_empty)
{
using T = TypeParam;
const cuspatial::vec_2d<T> vertex_1{0.0, 0.0};
const cuspatial::vec_2d<T> vertex_2{1.0, 1.0};
const int8_t max_depth = 1;
const int32_t max_size = 1;
const T scale = 1.0;
CUSPATIAL_RUN_TEST(
this->test, {}, vertex_1, vertex_2, scale, max_depth, max_size, {}, {}, {}, {}, {});
}
TYPED_TEST(QuadtreeOnPointIndexingTest, test_single)
{
using T = TypeParam;
const cuspatial::vec_2d<T> vertex_1{0.0, 0.0};
const cuspatial::vec_2d<T> vertex_2{1.0, 1.0};
const int8_t max_depth = 1;
const int32_t max_size = 1;
const T scale = 1.0;
CUSPATIAL_RUN_TEST(this->test,
{{0.45, 0.45}},
vertex_1,
vertex_2,
scale,
max_depth,
max_size,
{0},
{0},
cuspatial::test::make_host_vector({false}),
{1},
{0});
}
TYPED_TEST(QuadtreeOnPointIndexingTest, test_two)
{
using T = TypeParam;
const cuspatial::vec_2d<T> vertex_1{0.0, 0.0};
const cuspatial::vec_2d<T> vertex_2{2.0, 2.0};
const int8_t max_depth = 1;
const int32_t max_size = 1;
const T scale = 1.0;
CUSPATIAL_RUN_TEST(this->test,
{{0.45, 0.45}, {1.45, 1.45}},
vertex_1,
vertex_2,
scale,
max_depth,
max_size,
{0, 3},
{0, 0},
cuspatial::test::make_host_vector({false, false}),
{1, 1},
{0, 1});
}
TYPED_TEST(QuadtreeOnPointIndexingTest, test_all_lowest_level_quads)
{
using T = TypeParam;
const cuspatial::vec_2d<T> vertex_1{-1000.0, -1000.0};
const cuspatial::vec_2d<T> vertex_2{1000.0, 1000.0};
const int8_t max_depth = 2;
const int32_t max_size = 1;
CUSPATIAL_RUN_TEST(this->test,
{{-100.0, -100.0}, {100.0, 100.0}},
vertex_1,
vertex_2,
-1,
max_depth,
max_size,
{3, 12, 15},
{0, 1, 1},
cuspatial::test::make_host_vector({true, false, false}),
{2, 1, 1},
{1, 0, 1});
}
TYPED_TEST(QuadtreeOnPointIndexingTest, test_small)
{
using T = TypeParam;
const cuspatial::vec_2d<T> vertex_1{0.0, 0.0};
const cuspatial::vec_2d<T> vertex_2{8.0, 8.0};
const int8_t max_depth = 3;
const int32_t max_size = 12;
const T scale = 1.0;
CUSPATIAL_RUN_TEST(
this->test,
{
{1.9804558865545805, 1.3472225743317712}, {0.1895259128530169, 0.5431061133894604},
{1.2591725716781235, 0.1448705855995005}, {0.8178039499335275, 0.8138440641113271},
{0.48171647380517046, 1.9022922214961997}, {1.3890664414691907, 1.5177694304735412},
{0.2536015260915061, 1.8762161698642947}, {3.1907684812039956, 0.2621847215928189},
{3.028362149164369, 0.027638405909631958}, {3.918090468102582, 0.3338651960183463},
{3.710910700915217, 0.9937713340192049}, {3.0706987088385853, 0.9376313558467103},
{3.572744183805594, 0.33184908855075124}, {3.7080407833612004, 0.09804238103130436},
{3.70669993057843, 0.7485845679979923}, {3.3588457228653024, 0.2346381514128677},
{2.0697434332621234, 1.1809465376402173}, {2.5322042870739683, 1.419555755682142},
{2.175448214220591, 1.2372448404986038}, {2.113652420701984, 1.2774712415624014},
{2.520755151373394, 1.902015274420646}, {2.9909779614491687, 1.2420487904041893},
{2.4613232527836137, 1.0484414482621331}, {4.975578758530645, 0.9606291981013242},
{4.07037627210835, 1.9486902798139454}, {4.300706849071861, 0.021365525588281198},
{4.5584381091040616, 1.8996548860019926}, {4.822583857757069, 0.3234041700489503},
{4.849847745942472, 1.9531893897409585}, {4.75489831780737, 0.7800065259479418},
{4.529792124514895, 1.942673409259531}, {4.732546857961497, 0.5659923375279095},
{3.7622247877537456, 2.8709552313924487}, {3.2648444465931474, 2.693039435509084},
{3.01954722322135, 2.57810040095543}, {3.7164018490892348, 2.4612194182614333},
{3.7002781846945347, 2.3345952955903906}, {2.493975723955388, 3.3999020934055837},
{2.1807636574967466, 3.2296461832828114}, {2.566986568683904, 3.6607732238530897},
{2.2006520196663066, 3.7672478678985257}, {2.5104987015171574, 3.0668114607133137},
{2.8222482218882474, 3.8159308233351266}, {2.241538022180476, 3.8812819070357545},
{2.3007438625108882, 3.6045900851589048}, {6.0821276168848994, 2.5470532680258002},
{6.291790729917634, 2.983311357415729}, {6.109985464455084, 2.2235950639628523},
{6.101327777646798, 2.5239201807166616}, {6.325158445513714, 2.8765450351723674},
{6.6793884701899, 2.5605928243991434}, {6.4274219368674315, 2.9754616970668213},
{6.444584786789386, 2.174562817047202}, {7.897735998643542, 3.380784914178574},
{7.079453687660189, 3.063690547962938}, {7.430677191305505, 3.380489849365283},
{7.5085184104988, 3.623862886287816}, {7.886010001346151, 3.538128217886674},
{7.250745898479374, 3.4154469467473447}, {7.769497359206111, 3.253257011908445},
{1.8703303641352362, 4.209727933188015}, {1.7015273093278767, 7.478882372510933},
{2.7456295127617385, 7.474216636277054}, {2.2065031771469, 6.896038613284851},
{3.86008672302403, 7.513564222799629}, {1.9143371250907073, 6.885401350515916},
{3.7176098065039747, 6.194330707468438}, {0.059011873032214, 5.823535317960799},
{3.1162712022943757, 6.789029097334483}, {2.4264509160270813, 5.188939408363776},
{3.154282922203257, 5.788316610960881},
},
vertex_1,
vertex_2,
scale,
max_depth,
max_size,
{0, 1, 2, 0, 1, 3, 4, 7, 5, 6, 13, 14, 28, 31},
{0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2},
cuspatial::test::make_host_vector({true,
true,
false,
false,
true,
true,
false,
true,
false,
false,
false,
false,
false,
false}),
{3, 2, 11, 7, 2, 2, 9, 2, 9, 7, 5, 8, 8, 7},
{3, 6, 60, 0, 8, 10, 36, 12, 7, 16, 23, 28, 45, 53});
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/index/point_quadtree_test.cpp | /*
* Copyright (c) 2020-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cuspatial/error.hpp>
#include <cuspatial/point_quadtree.hpp>
#include <cudf/column/column_view.hpp>
#include <cudf/table/table.hpp>
#include <cudf/table/table_view.hpp>
#include <cudf_test/base_fixture.hpp>
#include <cudf_test/column_utilities.hpp>
#include <cudf_test/column_wrapper.hpp>
#include <cudf_test/table_utilities.hpp>
#include <cudf_test/type_lists.hpp>
struct QuadtreeOnPointErrorTest : public cudf::test::BaseFixture {};
TYPED_TEST_CASE(QuadtreeOnPointIndexingTest, cudf::test::FloatingPointTypes);
TEST_F(QuadtreeOnPointErrorTest, test_empty)
{
using T = float;
using namespace cudf::test;
const int8_t max_depth = 1;
uint32_t min_size = 1;
double scale = 1.0;
double x_min = 0, x_max = 1, y_min = 0, y_max = 1;
fixed_width_column_wrapper<T> x({});
fixed_width_column_wrapper<T> y({});
auto quadtree_pair =
cuspatial::quadtree_on_points(x, y, x_min, x_max, y_min, y_max, scale, max_depth, min_size);
auto& quadtree = std::get<1>(quadtree_pair);
CUSPATIAL_EXPECTS(
quadtree->num_columns() == 5,
"a quadtree table must have 5 columns (keys, levels, is_node, lengths, offsets)");
CUSPATIAL_EXPECTS(quadtree->num_rows() == 0,
"the resulting quadtree must have a single quadrant");
}
TEST_F(QuadtreeOnPointErrorTest, test_x_y_size_mismatch)
{
using T = float;
using namespace cudf::test;
const int8_t max_depth = 1;
uint32_t min_size = 1;
double scale = 1.0;
double x_min = 0, x_max = 1, y_min = 0, y_max = 1;
fixed_width_column_wrapper<T> x({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
fixed_width_column_wrapper<T> y({0, 1, 2, 3, 4, 5, 6, 7, 8});
EXPECT_THROW(
cuspatial::quadtree_on_points(x, y, x_min, x_max, y_min, y_max, scale, max_depth, min_size),
cuspatial::logic_error);
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/range/multilinestring_range_test.cu | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cuspatial_test/test_util.cuh>
#include <cuspatial_test/base_fixture.hpp>
#include <cuspatial_test/vector_equality.hpp>
#include <cuspatial_test/vector_factories.cuh>
#include <cuspatial/detail/utility/zero_data.cuh>
#include <cuspatial/geometry/vec_2d.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_scalar.hpp>
#include <rmm/device_uvector.hpp>
#include <rmm/device_vector.hpp>
#include <rmm/exec_policy.hpp>
#include <rmm/mr/device/device_memory_resource.hpp>
#include <thrust/sequence.h>
#include <thrust/tabulate.h>
#include <initializer_list>
#include <limits>
using namespace cuspatial;
using namespace cuspatial::test;
template <typename MultiLineStringRange, typename OutputIt>
void __global__ array_access_tester(MultiLineStringRange mls, std::size_t i, OutputIt output_points)
{
thrust::copy(thrust::seq, mls[i].point_begin(), mls[i].point_end(), output_points);
}
template <typename T>
struct MultilinestringRangeTest : public BaseFixture {
void run_segment_test_single(std::initializer_list<std::size_t> geometry_offset,
std::initializer_list<std::size_t> part_offset,
std::initializer_list<vec_2d<T>> coordinates,
std::initializer_list<segment<T>> expected)
{
auto multilinestring_array =
make_multilinestring_array(geometry_offset, part_offset, coordinates);
auto rng = multilinestring_array.range();
auto segments = rng._segments(stream());
auto segments_range = segments.segment_range();
rmm::device_uvector<segment<T>> got(segments_range.num_segments(), stream());
thrust::copy(
rmm::exec_policy(stream()), segments_range.begin(), segments_range.end(), got.begin());
auto d_expected = thrust::device_vector<segment<T>>(expected.begin(), expected.end());
CUSPATIAL_EXPECT_VEC2D_PAIRS_EQUIVALENT(d_expected, got);
}
void run_multilinestring_point_count_test(std::initializer_list<std::size_t> geometry_offset,
std::initializer_list<std::size_t> part_offset,
std::initializer_list<vec_2d<T>> coordinates,
std::initializer_list<std::size_t> expected)
{
auto multilinestring_array =
make_multilinestring_array(geometry_offset, part_offset, coordinates);
auto d_expected = thrust::device_vector<std::size_t>(expected.begin(), expected.end());
auto rng = multilinestring_array.range();
rmm::device_uvector<std::size_t> got(rng.num_multilinestrings(), stream());
thrust::copy(rmm::exec_policy(stream()),
rng.multilinestring_point_count_begin(),
rng.multilinestring_point_count_end(),
got.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_expected, got);
}
void run_multilinestring_segment_count_test(std::initializer_list<std::size_t> geometry_offset,
std::initializer_list<std::size_t> part_offset,
std::initializer_list<vec_2d<T>> coordinates,
std::initializer_list<std::size_t> expected)
{
auto multilinestring_array =
make_multilinestring_array(geometry_offset, part_offset, coordinates);
auto rng = multilinestring_array.range();
auto segments = rng._segments(stream());
auto segments_range = segments.segment_range();
auto d_expected = thrust::device_vector<std::size_t>(expected.begin(), expected.end());
rmm::device_uvector<std::size_t> got(rng.num_multilinestrings(), stream());
thrust::copy(rmm::exec_policy(stream()),
segments_range.multigeometry_count_begin(),
segments_range.multigeometry_count_end(),
got.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_expected, got);
}
void run_multilinestring_segment_offset_test(std::initializer_list<std::size_t> geometry_offset,
std::initializer_list<std::size_t> part_offset,
std::initializer_list<vec_2d<T>> coordinates,
std::initializer_list<std::size_t> expected)
{
auto multilinestring_array =
make_multilinestring_array(geometry_offset, part_offset, coordinates);
auto rng = multilinestring_array.range();
auto segments = rng._segments(stream());
auto segments_range = segments.segment_range();
auto d_expected = thrust::device_vector<std::size_t>(expected.begin(), expected.end());
rmm::device_uvector<std::size_t> got(rng.num_multilinestrings() + 1, stream());
thrust::copy(rmm::exec_policy(stream()),
segments_range.multigeometry_offset_begin(),
segments_range.multigeometry_offset_end(),
got.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_expected, got);
}
void run_multilinestring_linestring_count_test(std::initializer_list<std::size_t> geometry_offset,
std::initializer_list<std::size_t> part_offset,
std::initializer_list<vec_2d<T>> coordinates,
std::initializer_list<std::size_t> expected)
{
auto multilinestring_array =
make_multilinestring_array(geometry_offset, part_offset, coordinates);
auto d_expected = thrust::device_vector<std::size_t>(expected.begin(), expected.end());
auto rng = multilinestring_array.range();
rmm::device_uvector<std::size_t> got(rng.num_multilinestrings(), stream());
thrust::copy(rmm::exec_policy(stream()),
rng.multilinestring_linestring_count_begin(),
rng.multilinestring_linestring_count_end(),
got.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_expected, got);
}
void run_multilinestring_as_multipoint_test(
std::initializer_list<std::size_t> geometry_offset,
std::initializer_list<std::size_t> part_offset,
std::initializer_list<vec_2d<T>> coordinates,
std::initializer_list<std::initializer_list<vec_2d<T>>> expected)
{
auto multilinestring_array =
make_multilinestring_array(geometry_offset, part_offset, coordinates);
auto multilinestring_range = multilinestring_array.range();
auto multipoint_range = multilinestring_range.as_multipoint_range();
thrust::device_vector<std::size_t> got_geometry_offset(multipoint_range.offsets_begin(),
multipoint_range.offsets_end());
thrust::device_vector<vec_2d<T>> got_coordinates(multipoint_range.point_begin(),
multipoint_range.point_end());
auto expected_multipoint = make_multipoint_array(expected);
auto expected_range = expected_multipoint.range();
thrust::device_vector<std::size_t> expected_geometry_offset(expected_range.offsets_begin(),
expected_range.offsets_end());
thrust::device_vector<vec_2d<T>> expected_coordinates(expected_range.point_begin(),
expected_range.point_end());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected_geometry_offset, got_geometry_offset);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected_coordinates, got_coordinates);
}
};
using TestTypes = ::testing::Types<float, double>;
TYPED_TEST_CASE(MultilinestringRangeTest, TestTypes);
TYPED_TEST(MultilinestringRangeTest, SegmentIteratorOneSegmentTest)
{
using T = TypeParam;
using P = vec_2d<T>;
using S = segment<T>;
CUSPATIAL_RUN_TEST(
this->run_segment_test_single, {0, 1}, {0, 2}, {P{0, 0}, P{1, 1}}, {S{P{0, 0}, P{1, 1}}});
}
TYPED_TEST(MultilinestringRangeTest, SegmentIteratorTwoSegmentTest)
{
using T = TypeParam;
using P = vec_2d<T>;
using S = segment<T>;
CUSPATIAL_RUN_TEST(this->run_segment_test_single,
{0, 2},
{0, 2, 4},
{P{0, 0}, P{1, 1}, P{2, 2}, P{3, 3}},
{S{P{0, 0}, P{1, 1}}, S{P{2, 2}, P{3, 3}}});
}
TYPED_TEST(MultilinestringRangeTest, SegmentIteratorTwoSegmentTest2)
{
using T = TypeParam;
using P = vec_2d<T>;
using S = segment<T>;
CUSPATIAL_RUN_TEST(this->run_segment_test_single,
{0, 1, 2},
{0, 2, 4},
{P{0, 0}, P{1, 1}, P{0, 0}, P{1, 1}},
{S{P{0, 0}, P{1, 1}}, S{P{0, 0}, P{1, 1}}});
}
TYPED_TEST(MultilinestringRangeTest, SegmentIteratorManyPairTest)
{
using T = TypeParam;
using P = vec_2d<T>;
using S = segment<T>;
CUSPATIAL_RUN_TEST(this->run_segment_test_single,
{0, 1, 2, 3},
{0, 6, 11, 14},
{
P{0, 0},
P{1, 1},
P{2, 2},
P{3, 3},
P{4, 4},
P{5, 5},
P{10, 10},
P{11, 11},
P{12, 12},
P{13, 13},
P{14, 14},
P{20, 20},
P{21, 21},
P{22, 22}
},
{S{P{0, 0}, P{1, 1}},
S{P{1, 1}, P{2, 2}},
S{P{2, 2}, P{3, 3}},
S{P{3, 3}, P{4, 4}},
S{P{4, 4}, P{5, 5}},
S{P{10, 10}, P{11, 11}},
S{P{11, 11}, P{12, 12}},
S{P{12, 12}, P{13, 13}},
S{P{13, 13}, P{14, 14}},
S{P{20, 20}, P{21, 21}},
S{P{21, 21}, P{22, 22}}});
}
TYPED_TEST(MultilinestringRangeTest, SegmentIteratorWithEmptyLineTest)
{
using T = TypeParam;
using P = vec_2d<T>;
using S = segment<T>;
CUSPATIAL_RUN_TEST(
this->run_segment_test_single,
{0, 1, 2, 3},
{0, 3, 3, 6},
{P{0, 0}, P{1, 1}, P{2, 2}, P{10, 10}, P{11, 11}, P{12, 12}},
{S{P{0, 0}, P{1, 1}}, S{P{1, 1}, P{2, 2}}, S{P{10, 10}, P{11, 11}}, S{P{11, 11}, P{12, 12}}});
}
TYPED_TEST(MultilinestringRangeTest, SegmentIteratorWithEmptyMultiLineStringTest)
{
using T = TypeParam;
using P = vec_2d<T>;
using S = segment<T>;
CUSPATIAL_RUN_TEST(
this->run_segment_test_single,
{0, 1, 1, 2},
{0, 3, 6},
{P{0, 0}, P{1, 1}, P{2, 2}, P{10, 10}, P{11, 11}, P{12, 12}},
{S{P{0, 0}, P{1, 1}}, S{P{1, 1}, P{2, 2}}, S{P{10, 10}, P{11, 11}}, S{P{11, 11}, P{12, 12}}});
}
TYPED_TEST(MultilinestringRangeTest, SegmentIteratorWithEmptyMultiLineStringTest2)
{
using T = TypeParam;
using P = vec_2d<T>;
using S = segment<T>;
CUSPATIAL_RUN_TEST(this->run_segment_test_single,
{0, 1, 1, 2},
{0, 4, 7},
{P{0, 0}, P{1, 1}, P{2, 2}, P{3, 3}, P{10, 10}, P{11, 11}, P{12, 12}},
{S{P{0, 0}, P{1, 1}},
S{P{1, 1}, P{2, 2}},
S{P{2, 2}, P{3, 3}},
S{P{10, 10}, P{11, 11}},
S{P{11, 11}, P{12, 12}}});
}
TYPED_TEST(MultilinestringRangeTest, PerMultilinestringCountTest)
{
using T = TypeParam;
using P = vec_2d<T>;
using S = segment<T>;
CUSPATIAL_RUN_TEST(this->run_multilinestring_point_count_test,
{0, 1, 2, 3},
{0, 3, 3, 6},
{P{0, 0}, P{1, 1}, P{2, 2}, P{10, 10}, P{11, 11}, P{12, 12}},
{3, 0, 3});
}
TYPED_TEST(MultilinestringRangeTest, PerMultilinestringCountTest2)
{
using T = TypeParam;
using P = vec_2d<T>;
using S = segment<T>;
CUSPATIAL_RUN_TEST(this->run_multilinestring_point_count_test,
{0, 1, 3},
{0, 3, 3, 6},
{P{0, 0}, P{1, 1}, P{2, 2}, P{10, 10}, P{11, 11}, P{12, 12}},
{3, 3});
}
TYPED_TEST(MultilinestringRangeTest, MultilinestringSegmentCountTest)
{
using T = TypeParam;
using P = vec_2d<T>;
using S = segment<T>;
CUSPATIAL_RUN_TEST(
this->run_multilinestring_segment_count_test, {0, 1}, {0, 3}, {P{0, 0}, P{1, 1}, P{2, 2}}, {2});
}
TYPED_TEST(MultilinestringRangeTest, MultilinestringSegmentCountTest2)
{
using T = TypeParam;
using P = vec_2d<T>;
using S = segment<T>;
CUSPATIAL_RUN_TEST(this->run_multilinestring_segment_count_test,
{0, 1, 3},
{0, 3, 3, 6},
{P{0, 0}, P{1, 1}, P{2, 2}, P{10, 10}, P{11, 11}, P{12, 12}},
{2, 2});
}
TYPED_TEST(MultilinestringRangeTest, MultilinestringSegmentCountTest3)
{
using T = TypeParam;
using P = vec_2d<T>;
using S = segment<T>;
CUSPATIAL_RUN_TEST(this->run_multilinestring_segment_count_test,
{0, 1, 2},
{0, 3, 6},
{P{0, 0}, P{1, 1}, P{2, 2}, P{10, 10}, P{11, 11}, P{12, 12}},
{2, 2});
}
TYPED_TEST(MultilinestringRangeTest, MultilinestringSegmentCountTest4)
{
using T = TypeParam;
using P = vec_2d<T>;
using S = segment<T>;
CUSPATIAL_RUN_TEST(this->run_multilinestring_segment_count_test,
{0, 1, 3},
{0, 3, 5, 7},
{P{0, 0}, P{1, 1}, P{2, 2}, P{10, 10}, P{11, 11}, P{20, 20}, P{21, 21}},
{2, 2});
}
// contains empty linestring
TYPED_TEST(MultilinestringRangeTest, MultilinestringSegmentCountTest5)
{
using T = TypeParam;
using P = vec_2d<T>;
using S = segment<T>;
CUSPATIAL_RUN_TEST(this->run_multilinestring_segment_count_test,
{0, 1, 2, 3},
{0, 3, 3, 6},
{P{0, 0}, P{1, 1}, P{2, 2}, P{10, 10}, P{11, 11}, P{12, 12}},
{2, 0, 2});
}
// contains empty multilinestring
TYPED_TEST(MultilinestringRangeTest, MultilinestringSegmentCountTest6)
{
using T = TypeParam;
using P = vec_2d<T>;
using S = segment<T>;
CUSPATIAL_RUN_TEST(this->run_multilinestring_segment_count_test,
{0, 1, 1, 2},
{0, 3, 6},
{P{0, 0}, P{1, 1}, P{2, 2}, P{10, 10}, P{11, 11}, P{12, 12}},
{2, 0, 2});
}
// contains empty multilinestring
TYPED_TEST(MultilinestringRangeTest, MultilinestringSegmentCountTest7)
{
using T = TypeParam;
using P = vec_2d<T>;
using S = segment<T>;
CUSPATIAL_RUN_TEST(this->run_multilinestring_segment_count_test,
{0, 1, 1, 2},
{0, 4, 7},
{P{0, 0}, P{1, 1}, P{2, 2}, P{3, 3}, P{10, 10}, P{11, 11}, P{12, 12}},
{3, 0, 2});
}
// contains empty multilinestring
TYPED_TEST(MultilinestringRangeTest, MultilinestringSegmentOffsetTest)
{
using T = TypeParam;
using P = vec_2d<T>;
using S = segment<T>;
CUSPATIAL_RUN_TEST(this->run_multilinestring_segment_offset_test,
{0, 1, 1, 2},
{0, 4, 7},
{P{0, 0}, P{1, 1}, P{2, 2}, P{3, 3}, P{10, 10}, P{11, 11}, P{12, 12}},
{0, 3, 3, 5});
}
TYPED_TEST(MultilinestringRangeTest, MultilinestringLinestringCountTest)
{
using T = TypeParam;
using P = vec_2d<T>;
using S = segment<T>;
CUSPATIAL_RUN_TEST(
this->run_multilinestring_linestring_count_test,
{0, 1, 2, 3},
{0, 3, 6, 9},
{P{0, 0}, P{1, 1}, P{2, 2}, P{10, 10}, P{11, 11}, P{12, 12}, P{20, 20}, P{21, 21}, P{22, 22}},
{1, 1, 1});
}
TYPED_TEST(MultilinestringRangeTest, MultilinestringLinestringCountTest2)
{
using T = TypeParam;
using P = vec_2d<T>;
using S = segment<T>;
CUSPATIAL_RUN_TEST(
this->run_multilinestring_linestring_count_test,
{0, 1, 3},
{0, 3, 6, 9},
{P{0, 0}, P{1, 1}, P{2, 2}, P{10, 10}, P{11, 11}, P{12, 12}, P{20, 20}, P{21, 21}, P{22, 22}},
{1, 2});
}
TYPED_TEST(MultilinestringRangeTest, MultilinestringAsMultipointTest)
{
using T = TypeParam;
using P = vec_2d<T>;
using S = segment<T>;
CUSPATIAL_RUN_TEST(this->run_multilinestring_as_multipoint_test,
{0, 1},
{0, 3},
{P{0, 0}, P{1, 1}, P{2, 2}},
{{P{0, 0}, P{1, 1}, P{2, 2}}});
}
TYPED_TEST(MultilinestringRangeTest, MultilinestringAsMultipointTest2)
{
using T = TypeParam;
using P = vec_2d<T>;
using S = segment<T>;
CUSPATIAL_RUN_TEST(this->run_multilinestring_as_multipoint_test,
{0, 2},
{0, 3, 5},
{P{0, 0}, P{1, 1}, P{2, 2}, P{3, 3}, P{4, 4}},
{{P{0, 0}, P{1, 1}, P{2, 2}, P{3, 3}, P{4, 4}}});
}
TYPED_TEST(MultilinestringRangeTest, MultilinestringAsMultipointTest3)
{
using T = TypeParam;
using P = vec_2d<T>;
using S = segment<T>;
CUSPATIAL_RUN_TEST(this->run_multilinestring_as_multipoint_test,
{0, 1, 2},
{0, 3, 5},
{P{0, 0}, P{1, 1}, P{2, 2}, P{10, 10}, P{11, 11}},
{{P{0, 0}, P{1, 1}, P{2, 2}}, {P{10, 10}, P{11, 11}}});
}
TYPED_TEST(MultilinestringRangeTest, MultilinestringAsMultipointTest4)
{
using T = TypeParam;
using P = vec_2d<T>;
using S = segment<T>;
CUSPATIAL_RUN_TEST(this->run_multilinestring_as_multipoint_test,
{0, 1, 3},
{0, 3, 5, 7},
{P{0, 0}, P{1, 1}, P{2, 2}, P{10, 10}, P{11, 11}, P{12, 12}, P{13, 13}},
{{P{0, 0}, P{1, 1}, P{2, 2}}, {P{10, 10}, P{11, 11}, P{12, 12}, P{13, 13}}});
}
TYPED_TEST(MultilinestringRangeTest, MultilinestringAsMultipointTest5)
{
using T = TypeParam;
using P = vec_2d<T>;
using S = segment<T>;
CUSPATIAL_RUN_TEST(this->run_multilinestring_as_multipoint_test,
{0, 1},
{0, 4},
{P{0, 0}, P{1, 1}, P{2, 2}, P{2, 3}},
{{P{0, 0}, P{1, 1}, P{2, 2}, P{2, 3}}});
}
TYPED_TEST(MultilinestringRangeTest, MultilinestringAsMultipointTest6)
{
using T = TypeParam;
using P = vec_2d<T>;
using S = segment<T>;
CUSPATIAL_RUN_TEST(this->run_multilinestring_as_multipoint_test,
{0, 2},
{0, 2, 4},
{P{1, 1}, P{0, 0}, P{6, 6}, P{6, 7}},
{{P{1, 1}, P{0, 0}, P{6, 6}, P{6, 7}}});
}
template <typename T>
class MultilinestringRangeTestBase : public BaseFixture {
public:
struct copy_leading_point_per_multilinestring {
template <typename MultiLineStringRef>
vec_2d<T> __device__ operator()(MultiLineStringRef m)
{
return m.size() > 0 ? m[0].point_begin()[0] : vec_2d<T>{-1, -1};
}
};
template <typename MultiLineStringRange>
struct part_idx_from_point_idx_functor {
MultiLineStringRange _rng;
std::size_t __device__ operator()(std::size_t point_idx)
{
return _rng.part_idx_from_point_idx(point_idx);
}
};
template <typename MultiLineStringRange>
struct part_idx_from_segment_idx_functor {
MultiLineStringRange _rng;
std::size_t __device__ operator()(std::size_t segment_idx)
{
auto opt = _rng.part_idx_from_segment_idx(segment_idx);
if (opt.has_value()) {
return opt.value();
} else {
return std::numeric_limits<std::size_t>::max();
}
}
};
template <typename MultiLineStringRange>
struct geometry_idx_from_point_idx_functor {
MultiLineStringRange _rng;
std::size_t __device__ operator()(std::size_t point_idx)
{
return _rng.geometry_idx_from_point_idx(point_idx);
}
};
template <typename MultiLineStringRange>
struct intra_part_idx_functor {
MultiLineStringRange _rng;
std::size_t __device__ operator()(std::size_t i) { return _rng.intra_part_idx(i); }
};
template <typename MultiLineStringRange>
struct intra_point_idx_functor {
MultiLineStringRange _rng;
std::size_t __device__ operator()(std::size_t i) { return _rng.intra_point_idx(i); }
};
template <typename MultiLineStringRange>
struct is_valid_segment_id_functor {
MultiLineStringRange _rng;
bool __device__ operator()(std::size_t i)
{
auto part_idx = _rng.part_idx_from_point_idx(i);
return _rng.is_valid_segment_id(i, part_idx);
}
};
template <typename MultiLineStringRange>
struct segment_functor {
MultiLineStringRange _rng;
segment<T> __device__ operator()(std::size_t i)
{
auto part_idx = _rng.part_idx_from_point_idx(i);
return _rng.is_valid_segment_id(i, part_idx)
? _rng.segment(i)
: segment<T>{vec_2d<T>{-1, -1}, vec_2d<T>{-1, -1}};
}
};
void SetUp() { make_test_multilinestring(); }
virtual void make_test_multilinestring() = 0;
auto range() { return test_multilinestring->range(); }
void run_test()
{
test_size();
test_num_multilinestrings();
test_num_linestrings();
test_num_points();
test_multilinestring_it();
test_begin();
test_end();
test_point_it();
test_part_offset_it();
test_part_idx_from_point_idx();
test_part_idx_from_segment_idx();
test_geometry_idx_from_point_idx();
test_intra_part_idx();
test_intra_point_idx();
test_is_valid_segment_id();
test_segment();
test_multilinestring_point_count_it();
test_multilinestring_linestring_count_it();
test_array_access_operator();
test_geometry_offset_it();
}
void test_size() { EXPECT_EQ(this->range().size(), this->range().num_multilinestrings()); }
virtual void test_num_multilinestrings() = 0;
virtual void test_num_linestrings() = 0;
virtual void test_num_points() = 0;
virtual void test_multilinestring_it() = 0;
void test_begin() { EXPECT_EQ(this->range().begin(), this->range().multilinestring_begin()); }
void test_end() { EXPECT_EQ(this->range().end(), this->range().multilinestring_end()); }
virtual void test_point_it() = 0;
virtual void test_geometry_offset_it() = 0;
virtual void test_part_offset_it() = 0;
virtual void test_part_idx_from_point_idx() = 0;
virtual void test_part_idx_from_segment_idx() = 0;
virtual void test_geometry_idx_from_point_idx() = 0;
virtual void test_intra_part_idx() = 0;
virtual void test_intra_point_idx() = 0;
virtual void test_is_valid_segment_id() = 0;
virtual void test_segment() = 0;
virtual void test_multilinestring_point_count_it() = 0;
virtual void test_multilinestring_linestring_count_it() = 0;
virtual void test_array_access_operator() = 0;
// Helper functions to be used by all subclass (test cases).
rmm::device_uvector<vec_2d<T>> copy_leading_points()
{
auto rng = this->range();
auto d_leading_point = rmm::device_uvector<vec_2d<T>>(rng.num_multilinestrings(), stream());
thrust::transform(rmm::exec_policy(stream()),
rng.begin(),
rng.end(),
d_leading_point.begin(),
copy_leading_point_per_multilinestring());
return d_leading_point;
}
rmm::device_uvector<vec_2d<T>> copy_all_points()
{
auto rng = this->range();
auto d_all_points = rmm::device_uvector<vec_2d<T>>(rng.num_points(), stream());
thrust::copy(
rmm::exec_policy(stream()), rng.point_begin(), rng.point_end(), d_all_points.begin());
return d_all_points;
}
rmm::device_uvector<std::size_t> copy_geometry_offsets()
{
auto rng = this->range();
auto d_geometry_offsets =
rmm::device_uvector<std::size_t>(rng.num_multilinestrings() + 1, stream());
thrust::copy(rmm::exec_policy(stream()),
rng.geometry_offset_begin(),
rng.geometry_offset_end(),
d_geometry_offsets.begin());
return d_geometry_offsets;
}
rmm::device_uvector<std::size_t> copy_part_offset()
{
auto rng = this->range();
auto d_part_offset = rmm::device_uvector<std::size_t>(rng.num_linestrings() + 1, stream());
thrust::copy(rmm::exec_policy(stream()),
rng.part_offset_begin(),
rng.part_offset_end(),
d_part_offset.begin());
return d_part_offset;
}
rmm::device_uvector<std::size_t> copy_part_idx_from_point_idx()
{
auto rng = this->range();
auto d_part_idx = rmm::device_uvector<std::size_t>(rng.num_points(), stream());
auto f = part_idx_from_point_idx_functor<decltype(rng)>{rng};
thrust::tabulate(rmm::exec_policy(stream()), d_part_idx.begin(), d_part_idx.end(), f);
return d_part_idx;
}
rmm::device_uvector<std::size_t> copy_part_idx_from_segment_idx()
{
auto rng = this->range();
auto d_part_idx = rmm::device_uvector<std::size_t>(rng.num_points(), stream());
auto f = part_idx_from_segment_idx_functor<decltype(rng)>{rng};
thrust::tabulate(rmm::exec_policy(stream()), d_part_idx.begin(), d_part_idx.end(), f);
return d_part_idx;
}
rmm::device_uvector<std::size_t> copy_geometry_idx_from_point_idx()
{
auto rng = this->range();
auto d_geometry_idx = rmm::device_uvector<std::size_t>(rng.num_points(), stream());
thrust::tabulate(rmm::exec_policy(stream()),
d_geometry_idx.begin(),
d_geometry_idx.end(),
geometry_idx_from_point_idx_functor<decltype(rng)>{rng});
return d_geometry_idx;
}
rmm::device_uvector<std::size_t> copy_intra_part_idx()
{
auto rng = this->range();
auto d_intra_part_idx = rmm::device_uvector<std::size_t>(rng.num_linestrings(), stream());
thrust::tabulate(rmm::exec_policy(stream()),
d_intra_part_idx.begin(),
d_intra_part_idx.end(),
intra_part_idx_functor<decltype(rng)>{rng});
return d_intra_part_idx;
}
rmm::device_uvector<std::size_t> copy_intra_point_idx()
{
auto rng = this->range();
auto d_intra_point_idx = rmm::device_uvector<std::size_t>(rng.num_points(), stream());
thrust::tabulate(rmm::exec_policy(stream()),
d_intra_point_idx.begin(),
d_intra_point_idx.end(),
intra_point_idx_functor<decltype(rng)>{rng});
return d_intra_point_idx;
}
rmm::device_uvector<uint8_t> copy_is_valid_segment_id()
{
auto rng = this->range();
auto d_is_valid_segment_id = rmm::device_uvector<uint8_t>(rng.num_points(), stream());
thrust::tabulate(rmm::exec_policy(stream()),
d_is_valid_segment_id.begin(),
d_is_valid_segment_id.end(),
is_valid_segment_id_functor<decltype(rng)>{rng});
return d_is_valid_segment_id;
}
rmm::device_uvector<segment<T>> copy_segments()
{
auto rng = this->range();
auto d_segments = rmm::device_uvector<segment<T>>(rng.num_points(), stream());
thrust::tabulate(rmm::exec_policy(stream()),
d_segments.begin(),
d_segments.end(),
segment_functor<decltype(rng)>{rng});
return d_segments;
}
rmm::device_uvector<std::size_t> copy_multilinestring_point_count()
{
auto rng = this->range();
auto d_multilinestring_point_count =
rmm::device_uvector<std::size_t>(rng.num_multilinestrings(), stream());
thrust::copy(rmm::exec_policy(stream()),
rng.multilinestring_point_count_begin(),
rng.multilinestring_point_count_end(),
d_multilinestring_point_count.begin());
return d_multilinestring_point_count;
}
rmm::device_uvector<std::size_t> copy_multilinestring_linestring_count()
{
auto rng = this->range();
auto d_multilinestring_linestring_count =
rmm::device_uvector<std::size_t>(rng.num_multilinestrings(), stream());
thrust::copy(rmm::exec_policy(stream()),
rng.multilinestring_linestring_count_begin(),
rng.multilinestring_linestring_count_end(),
d_multilinestring_linestring_count.begin());
return d_multilinestring_linestring_count;
}
rmm::device_uvector<vec_2d<T>> copy_all_points_of_ith_multilinestring(std::size_t i)
{
auto rng = this->range();
rmm::device_scalar<std::size_t> num_points(stream());
thrust::copy_n(rmm::exec_policy(stream()),
rng.multilinestring_point_count_begin() + i,
1,
num_points.data());
auto d_all_points = rmm::device_uvector<vec_2d<T>>(num_points.value(stream()), stream());
array_access_tester<<<1, 1, 0, stream()>>>(rng, i, d_all_points.data());
return d_all_points;
}
protected:
std::unique_ptr<multilinestring_array<rmm::device_vector<std::size_t>,
rmm::device_vector<std::size_t>,
rmm::device_vector<vec_2d<T>>>>
test_multilinestring;
};
template <typename T>
class MultilinestringRangeEmptyTest : public MultilinestringRangeTestBase<T> {
void make_test_multilinestring()
{
auto array = make_multilinestring_array<T>({0}, {0}, {});
this->test_multilinestring = std::make_unique<decltype(array)>(std::move(array));
}
void test_num_multilinestrings() { EXPECT_EQ(this->range().num_multilinestrings(), 0); }
void test_num_linestrings() { EXPECT_EQ(this->range().num_linestrings(), 0); }
void test_num_points() { EXPECT_EQ(this->range().num_points(), 0); }
void test_multilinestring_it()
{
auto leading_points = this->copy_leading_points();
auto expected = rmm::device_uvector<vec_2d<T>>(0, this->stream());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(leading_points, expected);
}
void test_point_it()
{
auto all_points = this->copy_all_points();
auto expected = rmm::device_uvector<vec_2d<T>>(0, this->stream());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(all_points, expected);
}
void test_part_offset_it()
{
auto part_offset = this->copy_part_offset();
auto expected = make_device_vector<std::size_t>({0});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(part_offset, expected);
}
void test_part_idx_from_point_idx()
{
auto part_idx = this->copy_part_idx_from_point_idx();
auto expected = rmm::device_vector<std::size_t>(0);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(part_idx, expected);
}
void test_part_idx_from_segment_idx()
{
auto part_idx = this->copy_part_idx_from_segment_idx();
auto expected = rmm::device_vector<std::size_t>(0);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(part_idx, expected);
}
void test_geometry_idx_from_point_idx()
{
auto geometry_idx = this->copy_geometry_idx_from_point_idx();
auto expected = rmm::device_vector<std::size_t>(0);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(geometry_idx, expected);
}
void test_intra_part_idx()
{
auto intra_part_idx = this->copy_intra_part_idx();
auto expected = rmm::device_vector<std::size_t>(0);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(intra_part_idx, expected);
}
void test_intra_point_idx()
{
auto intra_point_idx = this->copy_intra_point_idx();
auto expected = rmm::device_vector<std::size_t>(0);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(intra_point_idx, expected);
}
void test_is_valid_segment_id()
{
auto is_valid_segment_id = this->copy_is_valid_segment_id();
auto expected = rmm::device_vector<uint8_t>(0);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(is_valid_segment_id, expected);
}
void test_segment()
{
auto segments = this->copy_segments();
auto expected = rmm::device_vector<segment<T>>(0);
CUSPATIAL_EXPECT_VEC2D_PAIRS_EQUIVALENT(segments, expected);
}
void test_multilinestring_point_count_it()
{
auto multilinestring_point_count = this->copy_multilinestring_point_count();
auto expected = rmm::device_vector<std::size_t>(0);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(multilinestring_point_count, expected);
}
void test_multilinestring_linestring_count_it()
{
auto multilinestring_linestring_count = this->copy_multilinestring_linestring_count();
auto expected = rmm::device_vector<std::size_t>(0);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(multilinestring_linestring_count, expected);
}
void test_array_access_operator()
{
// Nothing to access
SUCCEED();
}
void test_geometry_offset_it()
{
auto geometry_offsets = this->copy_geometry_offsets();
auto expected = make_device_vector<std::size_t>({0});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(geometry_offsets, expected);
}
void test_part_offsets_it()
{
auto part_offsets = this->copy_part_offsets();
auto expected = make_device_vector<std::size_t>({0});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(part_offsets, expected);
}
};
TYPED_TEST_CASE(MultilinestringRangeEmptyTest, FloatingPointTypes);
TYPED_TEST(MultilinestringRangeEmptyTest, EmptyTest) { this->run_test(); }
template <typename T>
class MultilinestringRangeOneTest : public MultilinestringRangeTestBase<T> {
void make_test_multilinestring()
{
auto array = make_multilinestring_array<T>(
{0, 2}, {0, 2, 5}, {{10, 10}, {20, 20}, {100, 100}, {200, 200}, {300, 300}});
this->test_multilinestring = std::make_unique<decltype(array)>(std::move(array));
}
void test_num_multilinestrings() { EXPECT_EQ(this->range().num_multilinestrings(), 1); }
void test_num_linestrings() { EXPECT_EQ(this->range().num_linestrings(), 2); }
void test_num_points() { EXPECT_EQ(this->range().num_points(), 5); }
void test_multilinestring_it()
{
auto leading_points = this->copy_leading_points();
auto expected = make_device_vector<vec_2d<T>>({{10, 10}});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(leading_points, expected);
}
void test_point_it()
{
auto all_points = this->copy_all_points();
auto expected =
make_device_vector<vec_2d<T>>({{10, 10}, {20, 20}, {100, 100}, {200, 200}, {300, 300}});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(all_points, expected);
}
void test_part_offset_it()
{
auto part_offset = this->copy_part_offset();
auto expected = make_device_vector<std::size_t>({0, 2, 5});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(part_offset, expected);
}
void test_part_idx_from_point_idx()
{
auto part_idx = this->copy_part_idx_from_point_idx();
auto expected = make_device_vector<std::size_t>({0, 0, 1, 1, 1});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(part_idx, expected);
}
void test_part_idx_from_segment_idx()
{
auto part_idx = this->copy_part_idx_from_segment_idx();
auto expected = make_device_vector<std::size_t>(
{0, std::numeric_limits<std::size_t>::max(), 1, 1, std::numeric_limits<std::size_t>::max()});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(part_idx, expected);
}
void test_geometry_idx_from_point_idx()
{
auto geometry_idx = this->copy_geometry_idx_from_point_idx();
auto expected = make_device_vector<std::size_t>({0, 0, 0, 0, 0});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(geometry_idx, expected);
}
void test_intra_part_idx()
{
auto intra_part_idx = this->copy_intra_part_idx();
auto expected = make_device_vector<std::size_t>({0, 1});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(intra_part_idx, expected);
}
void test_intra_point_idx()
{
auto intra_point_idx = this->copy_intra_point_idx();
auto expected = make_device_vector<std::size_t>({0, 1, 0, 1, 2});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(intra_point_idx, expected);
}
void test_is_valid_segment_id()
{
auto is_valid_segment_id = this->copy_is_valid_segment_id();
auto expected = make_device_vector<uint8_t>({1, 0, 1, 1, 0});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(is_valid_segment_id, expected);
}
void test_segment()
{
auto segments = this->copy_segments();
auto expected = make_device_vector<segment<T>>({{{10, 10}, {20, 20}},
{{-1, -1}, {-1, -1}},
{{100, 100}, {200, 200}},
{{200, 200}, {300, 300}},
{{-1, -1}, {-1, -1}}});
CUSPATIAL_EXPECT_VEC2D_PAIRS_EQUIVALENT(segments, expected);
}
void test_multilinestring_point_count_it()
{
auto multilinestring_point_count = this->copy_multilinestring_point_count();
auto expected = make_device_vector<std::size_t>({5});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(multilinestring_point_count, expected);
}
void test_multilinestring_linestring_count_it()
{
auto multilinestring_linestring_count = this->copy_multilinestring_linestring_count();
auto expected = make_device_vector<std::size_t>({2});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(multilinestring_linestring_count, expected);
}
void test_array_access_operator()
{
auto all_points = this->copy_all_points_of_ith_multilinestring(0);
auto expected =
make_device_vector<vec_2d<T>>({{10, 10}, {20, 20}, {100, 100}, {200, 200}, {300, 300}});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(all_points, expected);
}
void test_geometry_offset_it()
{
auto geometry_offsets = this->copy_geometry_offsets();
auto expected = make_device_vector<std::size_t>({0, 2});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(geometry_offsets, expected);
}
void test_part_offsets_it()
{
auto part_offsets = this->copy_part_offsets();
auto expected = make_device_vector<std::size_t>({0, 2, 5});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(part_offsets, expected);
}
};
TYPED_TEST_CASE(MultilinestringRangeOneTest, FloatingPointTypes);
TYPED_TEST(MultilinestringRangeOneTest, OneTest) { this->run_test(); }
template <typename T>
class MultilinestringRangeOneThousandTest : public MultilinestringRangeTestBase<T> {
public:
struct make_points_functor {
vec_2d<T> __device__ operator()(std::size_t i)
{
auto part_idx = i / 2;
auto intra_point_idx = i % 2;
return vec_2d<T>{static_cast<T>(part_idx * 10 + intra_point_idx),
static_cast<T>(part_idx * 10 + intra_point_idx)};
}
};
void make_test_multilinestring()
{
rmm::device_vector<std::size_t> geometry_offset(1001);
rmm::device_vector<std::size_t> part_offset(1001);
rmm::device_vector<vec_2d<T>> points(2000);
thrust::sequence(
rmm::exec_policy(this->stream()), geometry_offset.begin(), geometry_offset.end());
thrust::sequence(
rmm::exec_policy(this->stream()), part_offset.begin(), part_offset.end(), 0, 2);
thrust::tabulate(
rmm::exec_policy(this->stream()), points.begin(), points.end(), make_points_functor{});
auto array = make_multilinestring_array(
std::move(geometry_offset), std::move(part_offset), std::move(points));
this->test_multilinestring = std::make_unique<decltype(array)>(std::move(array));
}
void test_num_multilinestrings() { EXPECT_EQ(this->range().num_multilinestrings(), 1000); }
void test_num_linestrings() { EXPECT_EQ(this->range().num_linestrings(), 1000); }
void test_num_points() { EXPECT_EQ(this->range().num_points(), 2000); }
void test_multilinestring_it()
{
auto leading_points = this->copy_leading_points();
auto expected = rmm::device_uvector<vec_2d<T>>(1000, this->stream());
thrust::tabulate(rmm::exec_policy(this->stream()),
expected.begin(),
expected.end(),
[] __device__(std::size_t i) {
return vec_2d<T>{i * T{10.}, i * T{10.}};
});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(leading_points, expected);
}
void test_point_it()
{
auto all_points = this->copy_all_points();
auto expected = rmm::device_uvector<vec_2d<T>>(2000, this->stream());
thrust::tabulate(
rmm::exec_policy(this->stream()), expected.begin(), expected.end(), make_points_functor{});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(all_points, expected);
}
void test_part_offset_it()
{
auto part_offset = this->copy_part_offset();
auto expected = rmm::device_uvector<std::size_t>(1001, this->stream());
thrust::sequence(rmm::exec_policy(this->stream()), expected.begin(), expected.end(), 0, 2);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(part_offset, expected);
}
void test_part_idx_from_point_idx()
{
auto part_idx = this->copy_part_idx_from_point_idx();
auto expected = rmm::device_uvector<std::size_t>(2000, this->stream());
thrust::tabulate(rmm::exec_policy(this->stream()),
expected.begin(),
expected.end(),
[] __device__(std::size_t i) { return i / 2; });
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(part_idx, expected);
}
void test_part_idx_from_segment_idx()
{
auto part_idx = this->copy_part_idx_from_segment_idx();
auto expected = rmm::device_uvector<std::size_t>(2000, this->stream());
thrust::tabulate(rmm::exec_policy(this->stream()),
expected.begin(),
expected.end(),
[] __device__(std::size_t i) {
return i % 2 == 0 ? i / 2 : std::numeric_limits<std::size_t>::max();
});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(part_idx, expected);
}
void test_geometry_idx_from_point_idx()
{
auto geometry_idx = this->copy_geometry_idx_from_point_idx();
auto expected = rmm::device_uvector<std::size_t>(2000, this->stream());
thrust::tabulate(rmm::exec_policy(this->stream()),
expected.begin(),
expected.end(),
[] __device__(std::size_t i) { return i / 2; });
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(geometry_idx, expected);
}
void test_intra_part_idx()
{
auto intra_part_idx = this->copy_intra_part_idx();
auto expected = rmm::device_uvector<std::size_t>(1000, this->stream());
detail::zero_data_async(expected.begin(), expected.end(), this->stream());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(intra_part_idx, expected);
}
void test_intra_point_idx()
{
auto intra_point_idx = this->copy_intra_point_idx();
auto expected = rmm::device_uvector<std::size_t>(2000, this->stream());
thrust::tabulate(rmm::exec_policy(this->stream()),
expected.begin(),
expected.end(),
[] __device__(std::size_t i) { return i % 2; });
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(intra_point_idx, expected);
}
void test_is_valid_segment_id()
{
auto is_valid_segment_id = this->copy_is_valid_segment_id();
auto expected = rmm::device_uvector<uint8_t>(2000, this->stream());
thrust::tabulate(rmm::exec_policy(this->stream()),
expected.begin(),
expected.end(),
[] __device__(std::size_t i) { return (i + 1) % 2; });
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(is_valid_segment_id, expected);
}
void test_segment()
{
auto segments = this->copy_segments();
auto expected = rmm::device_uvector<segment<T>>(2000, this->stream());
thrust::tabulate(
rmm::exec_policy(this->stream()),
expected.begin(),
expected.end(),
[] __device__(std::size_t i) {
auto part_idx = i / 2;
auto intra_point_idx = i % 2;
return i % 2 == 0
? segment<T>{vec_2d<T>{static_cast<T>(part_idx * 10 + intra_point_idx),
static_cast<T>(part_idx * 10 + intra_point_idx)},
vec_2d<T>{static_cast<T>(part_idx * 10 + intra_point_idx + 1),
static_cast<T>(part_idx * 10 + intra_point_idx + 1)}}
: segment<T>{vec_2d<T>{-1, -1}, vec_2d<T>{-1, -1}};
});
CUSPATIAL_EXPECT_VEC2D_PAIRS_EQUIVALENT(segments, expected);
}
void test_multilinestring_point_count_it()
{
auto multilinestring_point_count = this->copy_multilinestring_point_count();
auto expected = rmm::device_uvector<std::size_t>(1000, this->stream());
thrust::fill(rmm::exec_policy(this->stream()), expected.begin(), expected.end(), 2);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(multilinestring_point_count, expected);
}
void test_multilinestring_linestring_count_it()
{
auto multilinestring_linestring_count = this->copy_multilinestring_linestring_count();
auto expected = rmm::device_uvector<std::size_t>(1000, this->stream());
thrust::fill(rmm::exec_policy(this->stream()), expected.begin(), expected.end(), 1);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(multilinestring_linestring_count, expected);
}
void test_array_access_operator()
{
auto all_points = this->copy_all_points_of_ith_multilinestring(513);
auto expected = make_device_vector<vec_2d<T>>({{5130, 5130}, {5131, 5131}});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(all_points, expected);
}
void test_geometry_offset_it()
{
auto geometry_offsets = this->copy_geometry_offsets();
auto expected = rmm::device_uvector<std::size_t>(1001, this->stream());
thrust::sequence(rmm::exec_policy(this->stream()), expected.begin(), expected.end());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(geometry_offsets, expected);
}
void test_part_offsets_it()
{
auto part_offsets = this->copy_part_offsets();
auto expected = rmm::device_uvector<std::size_t>(1001, this->stream());
thrust::sequence(rmm::exec_policy(this->stream()), expected.begin(), expected.end(), 0, 2);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(part_offsets, expected);
}
};
TYPED_TEST_CASE(MultilinestringRangeOneThousandTest, FloatingPointTypes);
TYPED_TEST(MultilinestringRangeOneThousandTest, OneThousandTest) { this->run_test(); }
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/range/multipolygon_range_test.cu | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cuspatial_test/base_fixture.hpp>
#include <cuspatial_test/vector_equality.hpp>
#include <cuspatial_test/vector_factories.cuh>
#include <cuspatial/geometry/segment.cuh>
#include <cuspatial/geometry/vec_2d.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_scalar.hpp>
#include <rmm/device_uvector.hpp>
#include <rmm/exec_policy.hpp>
#include <rmm/mr/device/device_memory_resource.hpp>
#include <thrust/sequence.h>
#include <thrust/tabulate.h>
#include <initializer_list>
using namespace cuspatial;
using namespace cuspatial::test;
template <typename T>
struct MultipolygonRangeTest : public BaseFixture {
void run_multipolygon_segment_method_iterator_single(
std::initializer_list<std::size_t> geometry_offset,
std::initializer_list<std::size_t> part_offset,
std::initializer_list<std::size_t> ring_offset,
std::initializer_list<vec_2d<T>> coordinates,
std::initializer_list<segment<T>> expected)
{
auto multipolygon_array =
make_multipolygon_array(geometry_offset, part_offset, ring_offset, coordinates);
auto rng = multipolygon_array.range();
auto segments = rng._segments(stream());
auto segment_range = segments.segment_range();
auto got = rmm::device_uvector<segment<T>>(segment_range.num_segments(), stream());
thrust::copy(
rmm::exec_policy(stream()), segment_range.begin(), segment_range.end(), got.begin());
auto d_expected = thrust::device_vector<segment<T>>(expected.begin(), expected.end());
CUSPATIAL_EXPECT_VEC2D_PAIRS_EQUIVALENT(got, d_expected);
}
void run_multipolygon_point_count_iterator_single(
std::initializer_list<std::size_t> geometry_offset,
std::initializer_list<std::size_t> part_offset,
std::initializer_list<std::size_t> ring_offset,
std::initializer_list<vec_2d<T>> coordinates,
std::initializer_list<std::size_t> expected_point_counts)
{
auto multipolygon_array =
make_multipolygon_array(geometry_offset, part_offset, ring_offset, coordinates);
auto rng = multipolygon_array.range();
auto got = rmm::device_uvector<std::size_t>(rng.num_multipolygons(), stream());
thrust::copy(rmm::exec_policy(stream()),
rng.multipolygon_point_count_begin(),
rng.multipolygon_point_count_end(),
got.begin());
auto d_expected = thrust::device_vector<std::size_t>(expected_point_counts.begin(),
expected_point_counts.end());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(got, d_expected);
}
void run_multipolygon_segment_method_count_single(
std::initializer_list<std::size_t> geometry_offset,
std::initializer_list<std::size_t> part_offset,
std::initializer_list<std::size_t> ring_offset,
std::initializer_list<vec_2d<T>> coordinates,
std::initializer_list<std::size_t> expected_segment_counts)
{
auto multipolygon_array =
make_multipolygon_array(geometry_offset, part_offset, ring_offset, coordinates);
auto rng = multipolygon_array.range();
auto segments = rng._segments(stream());
auto segment_range = segments.segment_range();
auto got = rmm::device_uvector<std::size_t>(rng.num_multipolygons(), stream());
thrust::copy(rmm::exec_policy(stream()),
segment_range.multigeometry_count_begin(),
segment_range.multigeometry_count_end(),
got.begin());
auto d_expected = thrust::device_vector<std::size_t>(expected_segment_counts.begin(),
expected_segment_counts.end());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(got, d_expected);
}
void test_multipolygon_as_multilinestring(
std::initializer_list<std::size_t> multipolygon_geometry_offset,
std::initializer_list<std::size_t> multipolygon_part_offset,
std::initializer_list<std::size_t> ring_offset,
std::initializer_list<vec_2d<T>> multipolygon_coordinates,
std::initializer_list<std::size_t> multilinestring_geometry_offset,
std::initializer_list<std::size_t> multilinestring_part_offset,
std::initializer_list<vec_2d<T>> multilinestring_coordinates)
{
auto multipolygon_array = make_multipolygon_array(multipolygon_geometry_offset,
multipolygon_part_offset,
ring_offset,
multipolygon_coordinates);
auto rng = multipolygon_array.range().as_multilinestring_range();
auto geometry_offsets =
rmm::device_vector<std::size_t>(rng.geometry_offset_begin(), rng.geometry_offset_end());
auto part_offsets =
rmm::device_vector<std::size_t>(rng.part_offset_begin(), rng.part_offset_end());
auto points = rmm::device_vector<vec_2d<T>>(rng.point_begin(), rng.point_end());
auto got = make_multilinestring_array(
std::move(geometry_offsets), std::move(part_offsets), std::move(points));
auto expected = make_multilinestring_array(
multilinestring_geometry_offset, multilinestring_part_offset, multilinestring_coordinates);
CUSPATIAL_EXPECT_MULTILINESTRING_ARRAY_EQUIVALENT(expected, got);
}
void test_multipolygon_as_multipoint(
std::initializer_list<std::size_t> multipolygon_geometry_offset,
std::initializer_list<std::size_t> multipolygon_part_offset,
std::initializer_list<std::size_t> ring_offset,
std::initializer_list<vec_2d<T>> multipolygon_coordinates,
std::initializer_list<std::size_t> multipoint_geometry_offset,
std::initializer_list<vec_2d<T>> multipoint_coordinates)
{
auto multipolygon_array = make_multipolygon_array(multipolygon_geometry_offset,
multipolygon_part_offset,
ring_offset,
multipolygon_coordinates);
auto rng = multipolygon_array.range().as_multipoint_range();
auto got = make_multipoint_array(range(rng.offsets_begin(), rng.offsets_end()),
range(rng.point_begin(), rng.point_end()));
auto expected = make_multipoint_array(
range(multipoint_geometry_offset.begin(), multipoint_geometry_offset.end()),
range(multipoint_coordinates.begin(), multipoint_coordinates.end()));
CUSPATIAL_EXPECT_MULTIPOINT_ARRAY_EQUIVALENT(expected, got);
}
};
TYPED_TEST_CASE(MultipolygonRangeTest, FloatingPointTypes);
TYPED_TEST(MultipolygonRangeTest, SegmentIterators)
{
using T = TypeParam;
using P = vec_2d<T>;
using S = segment<T>;
CUSPATIAL_RUN_TEST(this->run_multipolygon_segment_method_iterator_single,
{0, 1},
{0, 1},
{0, 4},
{{0, 0}, {1, 0}, {1, 1}, {0, 0}},
{S{{0, 0}, P{1, 0}}, S{P{1, 0}, P{1, 1}}, S{P{1, 1}, P{0, 0}}});
}
TYPED_TEST(MultipolygonRangeTest, SegmentIterators2)
{
CUSPATIAL_RUN_TEST(this->run_multipolygon_segment_method_iterator_single,
{0, 1},
{0, 2},
{0, 4, 8},
{{0, 0}, {1, 0}, {1, 1}, {0, 0}, {10, 10}, {11, 10}, {11, 11}, {10, 10}},
{{{0, 0}, {1, 0}},
{{1, 0}, {1, 1}},
{{1, 1}, {0, 0}},
{{10, 10}, {11, 10}},
{{11, 10}, {11, 11}},
{{11, 11}, {10, 10}}});
}
TYPED_TEST(MultipolygonRangeTest, SegmentIterators3)
{
CUSPATIAL_RUN_TEST(this->run_multipolygon_segment_method_iterator_single,
{0, 2},
{0, 1, 2},
{0, 4, 8},
{{0, 0}, {1, 0}, {1, 1}, {0, 0}, {10, 10}, {11, 10}, {11, 11}, {10, 10}},
{{{0, 0}, {1, 0}},
{{1, 0}, {1, 1}},
{{1, 1}, {0, 0}},
{{10, 10}, {11, 10}},
{{11, 10}, {11, 11}},
{{11, 11}, {10, 10}}});
}
TYPED_TEST(MultipolygonRangeTest, SegmentIterators4)
{
CUSPATIAL_RUN_TEST(this->run_multipolygon_segment_method_iterator_single,
{0, 1, 2},
{0, 1, 2},
{0, 4, 8},
{{0, 0}, {1, 0}, {1, 1}, {0, 0}, {10, 10}, {11, 10}, {11, 11}, {10, 10}},
{{{0, 0}, {1, 0}},
{{1, 0}, {1, 1}},
{{1, 1}, {0, 0}},
{{10, 10}, {11, 10}},
{{11, 10}, {11, 11}},
{{11, 11}, {10, 10}}});
}
TYPED_TEST(MultipolygonRangeTest, SegmentIterators5)
{
CUSPATIAL_RUN_TEST(this->run_multipolygon_segment_method_iterator_single,
{0, 1, 2, 3},
{0, 1, 2, 3},
{0, 4, 9, 14},
{{-1, -1},
{-2, -2},
{-2, -1},
{-1, -1},
{-20, -20},
{-20, -21},
{-21, -21},
{-21, -20},
{-20, -20},
{-10, -10},
{-10, -11},
{-11, -11},
{-11, -10},
{-10, -10}},
{{{-1, -1}, {-2, -2}},
{{-2, -2}, {-2, -1}},
{{-2, -1}, {-1, -1}},
{{-20, -20}, {-20, -21}},
{{-20, -21}, {-21, -21}},
{{-21, -21}, {-21, -20}},
{{-21, -20}, {-20, -20}},
{{-10, -10}, {-10, -11}},
{{-10, -11}, {-11, -11}},
{{-11, -11}, {-11, -10}},
{{-11, -10}, {-10, -10}}});
}
TYPED_TEST(MultipolygonRangeTest, SegmentIterators5EmptyRing)
{
CUSPATIAL_RUN_TEST(this->run_multipolygon_segment_method_iterator_single,
{0, 1, 2},
{0, 1, 3},
{0, 4, 4, 8},
{{0, 0}, {1, 0}, {1, 1}, {0, 0}, {10, 10}, {11, 10}, {11, 11}, {10, 10}},
{{{0, 0}, {1, 0}},
{{1, 0}, {1, 1}},
{{1, 1}, {0, 0}},
{{10, 10}, {11, 10}},
{{11, 10}, {11, 11}},
{{11, 11}, {10, 10}}});
}
TYPED_TEST(MultipolygonRangeTest, SegmentIterators6EmptyPolygon)
{
CUSPATIAL_RUN_TEST(this->run_multipolygon_segment_method_iterator_single,
{0, 1, 3},
{0, 1, 1, 2},
{0, 4, 8},
{{0, 0}, {1, 0}, {1, 1}, {0, 0}, {10, 10}, {11, 10}, {11, 11}, {10, 10}},
{{{0, 0}, {1, 0}},
{{1, 0}, {1, 1}},
{{1, 1}, {0, 0}},
{{10, 10}, {11, 10}},
{{11, 10}, {11, 11}},
{{11, 11}, {10, 10}}});
}
TYPED_TEST(MultipolygonRangeTest, SegmentIterators7EmptyMultiPolygon)
{
CUSPATIAL_RUN_TEST(this->run_multipolygon_segment_method_iterator_single,
{0, 1, 1, 2},
{0, 1, 2},
{0, 4, 8},
{{0, 0}, {1, 0}, {1, 1}, {0, 0}, {10, 10}, {11, 10}, {11, 11}, {10, 10}},
{{{0, 0}, {1, 0}},
{{1, 0}, {1, 1}},
{{1, 1}, {0, 0}},
{{10, 10}, {11, 10}},
{{11, 10}, {11, 11}},
{{11, 11}, {10, 10}}});
}
TYPED_TEST(MultipolygonRangeTest, MultipolygonCountIterator)
{
CUSPATIAL_RUN_TEST(this->run_multipolygon_point_count_iterator_single,
{0, 1},
{0, 1},
{0, 4},
{{0, 0}, {1, 0}, {1, 1}, {0, 0}},
{4});
}
TYPED_TEST(MultipolygonRangeTest, MultipolygonCountIterator2)
{
CUSPATIAL_RUN_TEST(
this->run_multipolygon_point_count_iterator_single,
{0, 1},
{0, 2},
{0, 4, 8},
{{0, 0}, {1, 0}, {1, 1}, {0, 0}, {0.2, 0.2}, {0.2, 0.3}, {0.3, 0.3}, {0.3, 0.2}},
{8});
}
TYPED_TEST(MultipolygonRangeTest, MultipolygonCountIterator3)
{
CUSPATIAL_RUN_TEST(this->run_multipolygon_point_count_iterator_single,
{0, 2},
{0, 2, 3},
{0, 4, 8, 12},
{{0, 0},
{1, 0},
{1, 1},
{0, 0},
{0.2, 0.2},
{0.2, 0.3},
{0.3, 0.3},
{0.3, 0.2},
{0, 0},
{1, 0},
{1, 1},
{0, 1}},
{12});
}
TYPED_TEST(MultipolygonRangeTest, MultipolygonCountIterator4)
{
CUSPATIAL_RUN_TEST(this->run_multipolygon_point_count_iterator_single,
{0, 2, 3},
{0, 2, 3, 4},
{0, 4, 8, 12, 16},
{{0, 0},
{1, 0},
{1, 1},
{0, 0},
{0.2, 0.2},
{0.2, 0.3},
{0.3, 0.3},
{0.2, 0.2},
{0, 0},
{1, 0},
{1, 1},
{0, 0},
{0, 0},
{1, 0},
{1, 1},
{0, 0}},
{12, 4});
}
TYPED_TEST(MultipolygonRangeTest, MultipolygonSegmentCount)
{
CUSPATIAL_RUN_TEST(this->run_multipolygon_segment_method_count_single,
{0, 1},
{0, 1},
{0, 4},
{{0, 0}, {1, 0}, {1, 1}, {0, 0}},
{3});
}
TYPED_TEST(MultipolygonRangeTest, MultipolygonSegmentCount2)
{
CUSPATIAL_RUN_TEST(
this->run_multipolygon_segment_method_count_single,
{0, 1},
{0, 2},
{0, 4, 8},
{{0, 0}, {1, 0}, {1, 1}, {0, 0}, {0.2, 0.2}, {0.2, 0.3}, {0.3, 0.3}, {0.2, 0.2}},
{6});
}
TYPED_TEST(MultipolygonRangeTest, MultipolygonSegmentCount3)
{
CUSPATIAL_RUN_TEST(this->run_multipolygon_segment_method_count_single,
{0, 2},
{0, 2, 3},
{0, 4, 8, 12},
{{0, 0},
{1, 0},
{1, 1},
{0, 0},
{0.2, 0.2},
{0.2, 0.3},
{0.3, 0.3},
{0.2, 0.2},
{0, 0},
{1, 0},
{1, 1},
{0, 0}},
{9});
}
TYPED_TEST(MultipolygonRangeTest, MultipolygonSegmentCount4)
{
CUSPATIAL_RUN_TEST(this->run_multipolygon_segment_method_count_single,
{0, 2, 3},
{0, 2, 3, 4},
{0, 4, 8, 12, 16},
{{0, 0},
{1, 0},
{1, 1},
{0, 0},
{0.2, 0.2},
{0.2, 0.3},
{0.3, 0.3},
{0.2, 0.2},
{0, 0},
{1, 0},
{1, 1},
{0, 0},
{0, 0},
{1, 0},
{1, 1},
{0, 0}},
{9, 3});
}
// FIXME: multipolygon constructor doesn't allow empty rings, should it?
TYPED_TEST(MultipolygonRangeTest, MultipolygonSegmentCount_ContainsEmptyRing)
{
CUSPATIAL_RUN_TEST(this->run_multipolygon_segment_method_count_single,
{0, 2, 3},
{0, 2, 3, 4},
{0, 7, 7, 11, 18},
{{0, 0},
{1, 0},
{1, 1},
{0.5, 1.5},
{0, 1.0},
{0.5, 0.5},
{0, 0},
{0.2, 0.2},
{0.2, 0.3},
{0.3, 0.3},
{0.2, 0.2},
{0, 0},
{1, 0},
{1, 1},
{0.5, 1.5},
{0, 1.0},
{0.5, 0.5},
{0, 0}},
{9, 6});
}
// FIXME: multipolygon constructor doesn't allow empty rings, should it?
TYPED_TEST(MultipolygonRangeTest, MultipolygonSegmentCount_ContainsEmptyPart)
{
CUSPATIAL_RUN_TEST(this->run_multipolygon_segment_method_count_single,
{0, 3, 4},
{0, 1, 1, 2, 3},
{0, 4, 8, 12},
{{0, 0},
{1, 0},
{1, 1},
{0, 0},
{0.2, 0.2},
{0.2, 0.3},
{0.3, 0.3},
{0.2, 0.2},
{0, 0},
{1, 0},
{1, 1},
{0, 0}},
{6, 3});
}
TYPED_TEST(MultipolygonRangeTest, MultipolygonAsMultipolygon1)
{
CUSPATIAL_RUN_TEST(this->test_multipolygon_as_multilinestring,
{0, 1, 2},
{0, 1, 2},
{0, 4, 8},
{{0, 0}, {1, 0}, {1, 1}, {0, 0}, {10, 10}, {11, 10}, {11, 11}, {10, 10}},
{0, 1, 2},
{0, 4, 8},
{{0, 0}, {1, 0}, {1, 1}, {0, 0}, {10, 10}, {11, 10}, {11, 11}, {10, 10}});
}
TYPED_TEST(MultipolygonRangeTest, MultipolygonAsMultipolygon2)
{
CUSPATIAL_RUN_TEST(this->test_multipolygon_as_multilinestring,
{0, 1, 2},
{0, 1, 3},
{0, 4, 8, 12},
{{0, 0},
{1, 0},
{1, 1},
{0, 0},
{10, 10},
{11, 10},
{11, 11},
{10, 10},
{20, 20},
{21, 20},
{21, 21},
{20, 20}},
{0, 1, 3},
{0, 4, 8, 12},
{{0, 0},
{1, 0},
{1, 1},
{0, 0},
{10, 10},
{11, 10},
{11, 11},
{10, 10},
{20, 20},
{21, 20},
{21, 21},
{20, 20}});
}
TYPED_TEST(MultipolygonRangeTest, MultipolygonAsMultipolygon3)
{
CUSPATIAL_RUN_TEST(this->test_multipolygon_as_multilinestring,
{0, 1, 2},
{0, 2, 3},
{0, 4, 8, 12},
{{0, 0},
{1, 0},
{1, 1},
{0, 0},
{10, 10},
{11, 10},
{11, 11},
{10, 10},
{20, 20},
{21, 20},
{21, 21},
{20, 20}},
{0, 2, 3},
{0, 4, 8, 12},
{{0, 0},
{1, 0},
{1, 1},
{0, 0},
{10, 10},
{11, 10},
{11, 11},
{10, 10},
{20, 20},
{21, 20},
{21, 21},
{20, 20}});
}
TYPED_TEST(MultipolygonRangeTest, MultipolygonAsMultiPoint1)
{
CUSPATIAL_RUN_TEST(this->test_multipolygon_as_multipoint,
{0, 1, 2},
{0, 1, 2},
{0, 4, 8},
{{0, 0}, {1, 0}, {1, 1}, {0, 0}, {10, 10}, {11, 10}, {11, 11}, {10, 10}},
{0, 4, 8},
{{0, 0}, {1, 0}, {1, 1}, {0, 0}, {10, 10}, {11, 10}, {11, 11}, {10, 10}});
}
TYPED_TEST(MultipolygonRangeTest, MultipolygonAsMultiPoint2)
{
CUSPATIAL_RUN_TEST(this->test_multipolygon_as_multipoint,
{0, 1, 2},
{0, 1, 3},
{0, 4, 8, 12},
{{0, 0},
{1, 0},
{1, 1},
{0, 0},
{10, 10},
{11, 10},
{11, 11},
{10, 10},
{20, 20},
{21, 20},
{21, 21},
{20, 20}},
{0, 4, 12},
{{0, 0},
{1, 0},
{1, 1},
{0, 0},
{10, 10},
{11, 10},
{11, 11},
{10, 10},
{20, 20},
{21, 20},
{21, 21},
{20, 20}});
}
TYPED_TEST(MultipolygonRangeTest, MultipolygonAsMultiPoint3)
{
CUSPATIAL_RUN_TEST(this->test_multipolygon_as_multipoint,
{0, 1, 2},
{0, 2, 3},
{0, 4, 8, 12},
{{0, 0},
{1, 0},
{1, 1},
{0, 0},
{10, 10},
{11, 10},
{11, 11},
{10, 10},
{20, 20},
{21, 20},
{21, 21},
{20, 20}},
{0, 8, 12},
{{0, 0},
{1, 0},
{1, 1},
{0, 0},
{10, 10},
{11, 10},
{11, 11},
{10, 10},
{20, 20},
{21, 20},
{21, 21},
{20, 20}});
}
template <typename MultiPolygonRange, typename PointOutputIt>
__global__ void array_access_tester(MultiPolygonRange rng, std::size_t i, PointOutputIt output)
{
thrust::copy(thrust::seq, rng[i].point_begin(), rng[i].point_end(), output);
}
template <typename T>
class MultipolygonRangeTestBase : public BaseFixture {
public:
struct copy_leading_point_functor {
template <typename MultiPolygonRef>
__device__ vec_2d<T> operator()(MultiPolygonRef mpolygon)
{
return mpolygon.size() > 0 ? mpolygon.point_begin()[0] : vec_2d<T>{-1, -1};
}
};
template <typename MultiPolygonRange>
struct ring_idx_from_point_idx_functor {
MultiPolygonRange mpolygons;
__device__ std::size_t operator()(std::size_t point_idx)
{
return mpolygons.ring_idx_from_point_idx(point_idx);
}
};
template <typename MultiPolygonRange>
struct part_idx_from_ring_idx_functor {
MultiPolygonRange mpolygons;
__device__ std::size_t operator()(std::size_t ring_idx)
{
return mpolygons.part_idx_from_ring_idx(ring_idx);
}
};
template <typename MultiPolygonRange>
struct geometry_idx_from_part_idx_functor {
MultiPolygonRange mpolygons;
__device__ std::size_t operator()(std::size_t part_idx)
{
return mpolygons.geometry_idx_from_part_idx(part_idx);
}
};
void SetUp() { make_test_multipolygon(); }
virtual void make_test_multipolygon() = 0;
auto range() { return test_multipolygon->range(); }
void run_test()
{
test_size();
test_num_multipolygons();
test_num_polygons();
test_num_rings();
test_num_points();
test_multipolygon_it();
test_begin();
test_end();
test_point_it();
test_geometry_offsets_it();
test_part_offset_it();
test_ring_offset_it();
test_ring_idx_from_point_idx();
test_part_idx_from_ring_idx();
test_geometry_idx_from_part_idx();
test_array_access_operator();
test_multipolygon_point_count_it();
test_multipolygon_ring_count_it();
}
void test_size() { EXPECT_EQ(range().size(), range().num_multipolygons()); };
virtual void test_num_multipolygons() = 0;
virtual void test_num_polygons() = 0;
virtual void test_num_rings() = 0;
virtual void test_num_points() = 0;
virtual void test_multipolygon_it() = 0;
void test_begin() { EXPECT_EQ(range().begin(), range().multipolygon_begin()); }
void test_end() { EXPECT_EQ(range().end(), range().multipolygon_end()); }
virtual void test_point_it() = 0;
virtual void test_geometry_offsets_it() = 0;
virtual void test_part_offset_it() = 0;
virtual void test_ring_offset_it() = 0;
virtual void test_ring_idx_from_point_idx() = 0;
virtual void test_part_idx_from_ring_idx() = 0;
virtual void test_geometry_idx_from_part_idx() = 0;
virtual void test_array_access_operator() = 0;
virtual void test_multipolygon_point_count_it() = 0;
virtual void test_multipolygon_ring_count_it() = 0;
// helper method to access multipolygon range
rmm::device_uvector<vec_2d<T>> copy_leading_point_multipolygon()
{
auto rng = range();
auto d_points = rmm::device_uvector<vec_2d<T>>(rng.num_multipolygons(), stream());
thrust::transform(rmm::exec_policy(stream()),
rng.multipolygon_begin(),
rng.multipolygon_end(),
d_points.begin(),
copy_leading_point_functor{});
return d_points;
}
rmm::device_uvector<vec_2d<T>> copy_all_points()
{
auto rng = range();
auto d_points = rmm::device_uvector<vec_2d<T>>(rng.num_points(), stream());
thrust::copy(rmm::exec_policy(stream()), rng.point_begin(), rng.point_end(), d_points.begin());
return d_points;
}
rmm::device_uvector<std::size_t> copy_geometry_offsets()
{
auto rng = range();
auto d_offsets = rmm::device_uvector<std::size_t>(rng.num_multipolygons() + 1, stream());
thrust::copy(rmm::exec_policy(stream()),
rng.geometry_offset_begin(),
rng.geometry_offset_end(),
d_offsets.begin());
return d_offsets;
}
rmm::device_uvector<std::size_t> copy_part_offsets()
{
auto rng = range();
auto d_offsets = rmm::device_uvector<std::size_t>(rng.num_polygons() + 1, stream());
thrust::copy(rmm::exec_policy(stream()),
rng.part_offset_begin(),
rng.part_offset_end(),
d_offsets.begin());
return d_offsets;
}
rmm::device_uvector<std::size_t> copy_ring_offsets()
{
auto rng = range();
auto d_offsets = rmm::device_uvector<std::size_t>(rng.num_rings() + 1, stream());
thrust::copy(rmm::exec_policy(stream()),
rng.ring_offset_begin(),
rng.ring_offset_end(),
d_offsets.begin());
return d_offsets;
}
rmm::device_uvector<std::size_t> copy_ring_idx_from_point_idx()
{
auto rng = range();
auto d_ring_idx = rmm::device_uvector<std::size_t>(rng.num_points(), stream());
thrust::tabulate(rmm::exec_policy(stream()),
d_ring_idx.begin(),
d_ring_idx.end(),
ring_idx_from_point_idx_functor<decltype(rng)>{rng});
return d_ring_idx;
}
rmm::device_uvector<std::size_t> copy_part_idx_from_ring_idx()
{
auto rng = range();
auto d_part_idx = rmm::device_uvector<std::size_t>(rng.num_rings(), stream());
thrust::tabulate(rmm::exec_policy(stream()),
d_part_idx.begin(),
d_part_idx.end(),
part_idx_from_ring_idx_functor<decltype(rng)>{rng});
return d_part_idx;
}
rmm::device_uvector<std::size_t> copy_geometry_idx_from_part_idx()
{
auto rng = range();
auto d_geometry_idx = rmm::device_uvector<std::size_t>(rng.num_polygons(), stream());
thrust::tabulate(rmm::exec_policy(stream()),
d_geometry_idx.begin(),
d_geometry_idx.end(),
geometry_idx_from_part_idx_functor<decltype(rng)>{rng});
return d_geometry_idx;
}
rmm::device_uvector<vec_2d<T>> copy_all_points_of_ith_multipolygon(std::size_t i)
{
auto rng = this->range();
rmm::device_scalar<std::size_t> num_points(stream());
thrust::copy_n(
rmm::exec_policy(stream()), rng.multipolygon_point_count_begin() + i, 1, num_points.data());
auto d_all_points = rmm::device_uvector<vec_2d<T>>(num_points.value(stream()), stream());
array_access_tester<<<1, 1, 0, stream()>>>(rng, i, d_all_points.data());
return d_all_points;
}
rmm::device_uvector<std::size_t> copy_multipolygon_point_count()
{
auto rng = this->range();
auto d_point_count = rmm::device_uvector<std::size_t>(rng.num_multipolygons(), stream());
thrust::copy(rmm::exec_policy(stream()),
rng.multipolygon_point_count_begin(),
rng.multipolygon_point_count_end(),
d_point_count.begin());
return d_point_count;
}
rmm::device_uvector<std::size_t> copy_multipolygon_ring_count()
{
auto rng = this->range();
auto d_ring_count = rmm::device_uvector<std::size_t>(rng.num_multipolygons(), stream());
thrust::copy(rmm::exec_policy(stream()),
rng.multipolygon_ring_count_begin(),
rng.multipolygon_ring_count_end(),
d_ring_count.begin());
return d_ring_count;
}
protected:
std::unique_ptr<multipolygon_array<rmm::device_vector<std::size_t>,
rmm::device_vector<std::size_t>,
rmm::device_vector<std::size_t>,
rmm::device_vector<vec_2d<T>>>>
test_multipolygon;
};
template <typename T>
class MultipolygonRangeEmptyTest : public MultipolygonRangeTestBase<T> {
void make_test_multipolygon()
{
auto geometry_offsets = make_device_vector<std::size_t>({0});
auto part_offsets = make_device_vector<std::size_t>({0});
auto ring_offsets = make_device_vector<std::size_t>({0});
auto coordinates = make_device_vector<vec_2d<T>>({});
this->test_multipolygon = std::make_unique<multipolygon_array<rmm::device_vector<std::size_t>,
rmm::device_vector<std::size_t>,
rmm::device_vector<std::size_t>,
rmm::device_vector<vec_2d<T>>>>(
std::move(geometry_offsets),
std::move(part_offsets),
std::move(ring_offsets),
std::move(coordinates));
}
void test_num_multipolygons() { EXPECT_EQ(this->range().num_multipolygons(), 0); }
void test_num_polygons() { EXPECT_EQ(this->range().num_polygons(), 0); }
void test_num_rings() { EXPECT_EQ(this->range().num_rings(), 0); }
void test_num_points() { EXPECT_EQ(this->range().num_points(), 0); }
void test_multipolygon_it()
{
rmm::device_uvector<vec_2d<T>> d_points = this->copy_leading_point_multipolygon();
rmm::device_uvector<vec_2d<T>> expected(0, this->stream());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_points, expected);
}
void test_point_it()
{
rmm::device_uvector<vec_2d<T>> d_points = this->copy_all_points();
rmm::device_uvector<vec_2d<T>> expected(0, this->stream());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_points, expected);
}
void test_geometry_offsets_it()
{
rmm::device_uvector<std::size_t> d_offsets = this->copy_geometry_offsets();
auto expected = make_device_vector<std::size_t>({0});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_offsets, expected);
}
void test_part_offset_it()
{
rmm::device_uvector<std::size_t> d_offsets = this->copy_part_offsets();
auto expected = make_device_vector<std::size_t>({0});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_offsets, expected);
}
void test_ring_offset_it()
{
rmm::device_uvector<std::size_t> d_offsets = this->copy_ring_offsets();
auto expected = make_device_vector<std::size_t>({0});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_offsets, expected);
}
void test_ring_idx_from_point_idx()
{
rmm::device_uvector<std::size_t> d_ring_idx = this->copy_ring_idx_from_point_idx();
auto expected = make_device_vector<std::size_t>({});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_ring_idx, expected);
}
void test_part_idx_from_ring_idx()
{
rmm::device_uvector<std::size_t> d_part_idx = this->copy_part_idx_from_ring_idx();
auto expected = make_device_vector<std::size_t>({});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_part_idx, expected);
}
void test_geometry_idx_from_part_idx()
{
rmm::device_uvector<std::size_t> d_geometry_idx = this->copy_geometry_idx_from_part_idx();
auto expected = make_device_vector<std::size_t>({});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_geometry_idx, expected);
}
void test_array_access_operator()
{
// Nothing to access
SUCCEED();
}
void test_multipolygon_point_count_it()
{
rmm::device_uvector<std::size_t> d_point_count = this->copy_multipolygon_point_count();
rmm::device_uvector<std::size_t> expected(0, this->stream());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_point_count, expected);
}
void test_multipolygon_ring_count_it()
{
rmm::device_uvector<std::size_t> d_ring_count = this->copy_multipolygon_ring_count();
rmm::device_uvector<std::size_t> expected(0, this->stream());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_ring_count, expected);
}
};
TYPED_TEST_CASE(MultipolygonRangeEmptyTest, FloatingPointTypes);
TYPED_TEST(MultipolygonRangeEmptyTest, EmptyMultipolygonRange) { this->run_test(); }
template <typename T>
class MultipolygonRangeOneTest : public MultipolygonRangeTestBase<T> {
void make_test_multipolygon()
{
auto geometry_offsets = make_device_vector<std::size_t>({0, 2});
auto part_offsets = make_device_vector<std::size_t>({0, 1, 2});
auto ring_offsets = make_device_vector<std::size_t>({0, 4, 8});
auto coordinates = make_device_vector<vec_2d<T>>(
{{0, 0}, {1, 0}, {1, 1}, {0, 0}, {10, 10}, {11, 10}, {11, 11}, {10, 10}});
this->test_multipolygon = std::make_unique<multipolygon_array<rmm::device_vector<std::size_t>,
rmm::device_vector<std::size_t>,
rmm::device_vector<std::size_t>,
rmm::device_vector<vec_2d<T>>>>(
std::move(geometry_offsets),
std::move(part_offsets),
std::move(ring_offsets),
std::move(coordinates));
}
void test_num_multipolygons() { EXPECT_EQ(this->range().num_multipolygons(), 1); }
void test_num_polygons() { EXPECT_EQ(this->range().num_polygons(), 2); }
void test_num_rings() { EXPECT_EQ(this->range().num_rings(), 2); }
void test_num_points() { EXPECT_EQ(this->range().num_points(), 8); }
void test_multipolygon_it()
{
rmm::device_uvector<vec_2d<T>> d_points = this->copy_leading_point_multipolygon();
auto expected = make_device_vector<vec_2d<T>>({{0, 0}});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_points, expected);
}
void test_point_it()
{
rmm::device_uvector<vec_2d<T>> d_points = this->copy_all_points();
auto expected = make_device_vector<vec_2d<T>>(
{{0, 0}, {1, 0}, {1, 1}, {0, 0}, {10, 10}, {11, 10}, {11, 11}, {10, 10}});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_points, expected);
}
void test_geometry_offsets_it()
{
rmm::device_uvector<std::size_t> d_offsets = this->copy_geometry_offsets();
auto expected = make_device_vector<std::size_t>({0, 1});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_offsets, expected);
}
void test_part_offset_it()
{
rmm::device_uvector<std::size_t> d_offsets = this->copy_part_offsets();
auto expected = make_device_vector<std::size_t>({0, 1, 2});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_offsets, expected);
}
void test_ring_offset_it()
{
rmm::device_uvector<std::size_t> d_offsets = this->copy_ring_offsets();
auto expected = make_device_vector<std::size_t>({0, 4, 8});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_offsets, expected);
}
void test_ring_idx_from_point_idx()
{
rmm::device_uvector<std::size_t> d_ring_idx = this->copy_ring_idx_from_point_idx();
auto expected = make_device_vector<std::size_t>({0, 0, 0, 0, 1, 1, 1, 1});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_ring_idx, expected);
}
void test_part_idx_from_ring_idx()
{
rmm::device_uvector<std::size_t> d_part_idx = this->copy_part_idx_from_ring_idx();
auto expected = make_device_vector<std::size_t>({0, 1});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_part_idx, expected);
}
void test_geometry_idx_from_part_idx()
{
rmm::device_uvector<std::size_t> d_geometry_idx = this->copy_geometry_idx_from_part_idx();
auto expected = make_device_vector<std::size_t>({0, 0});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_geometry_idx, expected);
}
void test_array_access_operator()
{
auto all_points = this->copy_all_points_of_ith_multipolygon(0);
auto expected = make_device_vector<vec_2d<T>>(
{{0, 0}, {1, 0}, {1, 1}, {0, 0}, {10, 10}, {11, 10}, {11, 11}, {10, 10}});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(all_points, expected);
}
void test_multipolygon_point_count_it()
{
rmm::device_uvector<std::size_t> d_point_count = this->copy_multipolygon_point_count();
auto expected = make_device_vector<std::size_t>({8});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_point_count, expected);
}
void test_multipolygon_ring_count_it()
{
rmm::device_uvector<std::size_t> d_ring_count = this->copy_multipolygon_ring_count();
auto expected = make_device_vector<std::size_t>({2});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_ring_count, expected);
}
};
TYPED_TEST_CASE(MultipolygonRangeOneTest, FloatingPointTypes);
TYPED_TEST(MultipolygonRangeOneTest, OneMultipolygonRange) { this->run_test(); }
template <typename T>
class MultipolygonRangeOneThousandTest : public MultipolygonRangeTestBase<T> {
public:
struct make_points_functor {
__device__ auto operator()(std::size_t i)
{
auto geometry_idx = i / 4;
auto intra_point_idx = i % 4;
return vec_2d<T>{geometry_idx * T{10.} + intra_point_idx,
geometry_idx * T{10.} + intra_point_idx};
}
};
void make_test_multipolygon()
{
auto geometry_offsets = rmm::device_vector<std::size_t>(1001);
auto part_offsets = rmm::device_vector<std::size_t>(1001);
auto ring_offsets = rmm::device_vector<std::size_t>(1001);
auto coordinates = rmm::device_vector<vec_2d<T>>(4000);
thrust::sequence(
rmm::exec_policy(this->stream()), geometry_offsets.begin(), geometry_offsets.end());
thrust::sequence(rmm::exec_policy(this->stream()), part_offsets.begin(), part_offsets.end());
thrust::sequence(
rmm::exec_policy(this->stream()), ring_offsets.begin(), ring_offsets.end(), 0, 4);
thrust::tabulate(rmm::exec_policy(this->stream()),
coordinates.begin(),
coordinates.end(),
make_points_functor{});
this->test_multipolygon = std::make_unique<multipolygon_array<rmm::device_vector<std::size_t>,
rmm::device_vector<std::size_t>,
rmm::device_vector<std::size_t>,
rmm::device_vector<vec_2d<T>>>>(
std::move(geometry_offsets),
std::move(part_offsets),
std::move(ring_offsets),
std::move(coordinates));
}
void test_num_multipolygons() { EXPECT_EQ(this->range().num_multipolygons(), 1000); }
void test_num_polygons() { EXPECT_EQ(this->range().num_polygons(), 1000); }
void test_num_rings() { EXPECT_EQ(this->range().num_rings(), 1000); }
void test_num_points() { EXPECT_EQ(this->range().num_points(), 4000); }
void test_multipolygon_it()
{
rmm::device_uvector<vec_2d<T>> d_points = this->copy_leading_point_multipolygon();
rmm::device_uvector<vec_2d<T>> expected(1000, this->stream());
thrust::tabulate(rmm::exec_policy(this->stream()),
expected.begin(),
expected.end(),
[] __device__(std::size_t i) {
return vec_2d<T>{i * T{10.}, i * T{10.}};
});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_points, expected);
}
void test_point_it()
{
rmm::device_uvector<vec_2d<T>> d_points = this->copy_all_points();
rmm::device_uvector<vec_2d<T>> expected(4000, this->stream());
thrust::tabulate(
rmm::exec_policy(this->stream()), expected.begin(), expected.end(), make_points_functor{});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_points, expected);
}
void test_geometry_offsets_it()
{
rmm::device_uvector<std::size_t> d_offsets = this->copy_geometry_offsets();
auto expected = rmm::device_uvector<std::size_t>(1001, this->stream());
thrust::sequence(rmm::exec_policy(this->stream()), expected.begin(), expected.end());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_offsets, expected);
}
void test_part_offset_it()
{
rmm::device_uvector<std::size_t> d_offsets = this->copy_part_offsets();
auto expected = rmm::device_uvector<std::size_t>(1001, this->stream());
thrust::sequence(rmm::exec_policy(this->stream()), expected.begin(), expected.end());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_offsets, expected);
}
void test_ring_offset_it()
{
rmm::device_uvector<std::size_t> d_offsets = this->copy_ring_offsets();
auto expected = rmm::device_uvector<std::size_t>(1001, this->stream());
thrust::sequence(rmm::exec_policy(this->stream()), expected.begin(), expected.end(), 0, 4);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_offsets, expected);
}
void test_ring_idx_from_point_idx()
{
rmm::device_uvector<std::size_t> d_ring_idx = this->copy_ring_idx_from_point_idx();
auto expected = rmm::device_uvector<std::size_t>(4000, this->stream());
thrust::tabulate(rmm::exec_policy(this->stream()),
expected.begin(),
expected.end(),
[] __device__(std::size_t i) { return i / 4; });
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_ring_idx, expected);
}
void test_part_idx_from_ring_idx()
{
rmm::device_uvector<std::size_t> d_part_idx = this->copy_part_idx_from_ring_idx();
auto expected = rmm::device_uvector<std::size_t>(1000, this->stream());
thrust::sequence(rmm::exec_policy(this->stream()), expected.begin(), expected.end());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_part_idx, expected);
}
void test_geometry_idx_from_part_idx()
{
rmm::device_uvector<std::size_t> d_geometry_idx = this->copy_geometry_idx_from_part_idx();
auto expected = rmm::device_uvector<std::size_t>(1000, this->stream());
thrust::sequence(rmm::exec_policy(this->stream()), expected.begin(), expected.end());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_geometry_idx, expected);
}
void test_array_access_operator()
{
auto all_points = this->copy_all_points_of_ith_multipolygon(777);
auto expected = make_device_vector<vec_2d<T>>({
{7770, 7770},
{7771, 7771},
{7772, 7772},
{7773, 7773},
});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(all_points, expected);
}
void test_multipolygon_point_count_it()
{
rmm::device_uvector<std::size_t> d_point_count = this->copy_multipolygon_point_count();
auto expected = rmm::device_uvector<std::size_t>(1000, this->stream());
thrust::fill(rmm::exec_policy(this->stream()), expected.begin(), expected.end(), 4);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_point_count, expected);
}
void test_multipolygon_ring_count_it()
{
rmm::device_uvector<std::size_t> d_ring_count = this->copy_multipolygon_ring_count();
auto expected = rmm::device_uvector<std::size_t>(1000, this->stream());
thrust::fill(rmm::exec_policy(this->stream()), expected.begin(), expected.end(), 1);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(d_ring_count, expected);
}
};
TYPED_TEST_CASE(MultipolygonRangeOneThousandTest, FloatingPointTypes);
TYPED_TEST(MultipolygonRangeOneThousandTest, OneThousandMultipolygonRange) { this->run_test(); }
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/range/multipoint_range_test.cu | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cuspatial_test/base_fixture.hpp>
#include <cuspatial_test/vector_equality.hpp>
#include <cuspatial_test/vector_factories.cuh>
#include <cuspatial/detail/functors.cuh>
#include <cuspatial/error.hpp>
#include <cuspatial/geometry/segment.cuh>
#include <cuspatial/geometry/vec_2d.hpp>
#include <cuspatial/iterator_factory.cuh>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_scalar.hpp>
#include <rmm/device_uvector.hpp>
#include <rmm/exec_policy.hpp>
#include <rmm/mr/device/device_memory_resource.hpp>
#include <thrust/iterator/constant_iterator.h>
#include <thrust/sequence.h>
#include <initializer_list>
using namespace cuspatial;
using namespace cuspatial::test;
template <typename MultiPointRange, typename OutputIt>
void __global__ array_access_tester(MultiPointRange multipoints,
std::size_t i,
OutputIt output_points)
{
using T = typename MultiPointRange::element_t;
thrust::copy(thrust::seq, multipoints[i].begin(), multipoints[i].end(), output_points);
}
template <typename MultiPointRange, typename OutputIt>
void __global__ point_accessor_tester(MultiPointRange multipoints, std::size_t i, OutputIt point)
{
using T = typename MultiPointRange::element_t;
point[0] = multipoints.point(i);
}
template <typename T>
class MultipointRangeTest : public BaseFixture {
public:
struct copy_leading_point_per_multipoint {
template <typename MultiPointRef>
vec_2d<T> __device__ operator()(MultiPointRef multipoint)
{
return multipoint.size() > 0 ? multipoint[0] : vec_2d<T>{-1, -1};
}
};
template <typename MultiPointRange>
struct point_idx_to_geometry_idx {
MultiPointRange rng;
point_idx_to_geometry_idx(MultiPointRange r) : rng(r) {}
std::size_t __device__ operator()(std::size_t pidx)
{
return rng.geometry_idx_from_point_idx(pidx);
}
};
void SetUp() { make_test_multipoints(); }
auto range() { return test_multipoints->range(); }
virtual void make_test_multipoints() = 0;
void run_test()
{
test_num_multipoints();
test_num_points();
test_size();
test_multipoint_it();
test_begin();
test_end();
test_point_it();
test_offsets_it();
test_geometry_idx_from_point_idx();
test_subscript_operator();
test_point_accessor();
test_is_single_point_range();
}
virtual void test_num_multipoints() = 0;
virtual void test_num_points() = 0;
void test_size() { EXPECT_EQ(this->range().size(), this->range().num_multipoints()); }
virtual void test_multipoint_it() = 0;
void test_begin() { EXPECT_EQ(this->range().begin(), this->range().multipoint_begin()); }
void test_end() { EXPECT_EQ(this->range().end(), this->range().multipoint_end()); }
virtual void test_point_it() = 0;
virtual void test_offsets_it() = 0;
virtual void test_geometry_idx_from_point_idx() = 0;
virtual void test_subscript_operator() = 0;
virtual void test_point_accessor() = 0;
virtual void test_is_single_point_range() = 0;
protected:
rmm::device_uvector<vec_2d<T>> copy_leading_points()
{
auto rng = this->range();
rmm::device_uvector<vec_2d<T>> leading_points(rng.num_multipoints(), this->stream());
thrust::transform(rmm::exec_policy(this->stream()),
rng.multipoint_begin(),
rng.multipoint_end(),
leading_points.begin(),
copy_leading_point_per_multipoint{});
return leading_points;
}
rmm::device_uvector<vec_2d<T>> copy_all_points()
{
auto rng = this->range();
rmm::device_uvector<vec_2d<T>> points(rng.num_points(), this->stream());
thrust::copy(
rmm::exec_policy(this->stream()), rng.point_begin(), rng.point_end(), points.begin());
return points;
};
rmm::device_uvector<std::size_t> copy_offsets()
{
auto rng = this->range();
rmm::device_uvector<std::size_t> offsets(rng.num_multipoints() + 1, this->stream());
thrust::copy(
rmm::exec_policy(this->stream()), rng.offsets_begin(), rng.offsets_end(), offsets.begin());
return offsets;
};
rmm::device_uvector<std::size_t> copy_geometry_idx()
{
auto rng = this->range();
rmm::device_uvector<std::size_t> idx(rng.num_points(), this->stream());
thrust::tabulate(
rmm::exec_policy(this->stream()), idx.begin(), idx.end(), point_idx_to_geometry_idx{rng});
return idx;
}
rmm::device_scalar<vec_2d<T>> copy_ith_point(std::size_t i)
{
auto rng = this->range();
rmm::device_scalar<vec_2d<T>> point(this->stream());
point_accessor_tester<<<1, 1, 0, this->stream()>>>(rng, i, point.data());
CUSPATIAL_CHECK_CUDA(this->stream());
return point;
}
rmm::device_uvector<vec_2d<T>> copy_ith_multipoint(std::size_t i)
{
auto rng = this->range();
rmm::device_scalar<std::size_t> num_points(this->stream());
auto count_iterator = make_count_iterator_from_offset_iterator(this->range().offsets_begin());
thrust::copy_n(rmm::exec_policy(this->stream()), count_iterator, 1, num_points.data());
rmm::device_uvector<vec_2d<T>> multipoint(num_points.value(this->stream()), this->stream());
array_access_tester<<<1, 1, 0, this->stream()>>>(rng, i, multipoint.begin());
CUSPATIAL_CHECK_CUDA(this->stream());
return multipoint;
}
std::unique_ptr<multipoint_array<rmm::device_vector<std::size_t>, rmm::device_vector<vec_2d<T>>>>
test_multipoints;
};
template <typename T>
class EmptyMultiPointRangeTest : public MultipointRangeTest<T> {
public:
void make_test_multipoints()
{
auto array = make_multipoint_array<T>({});
this->test_multipoints = std::make_unique<decltype(array)>(std::move(array));
}
void test_num_multipoints() { EXPECT_EQ(this->range().num_multipoints(), 0); }
void test_num_points() { EXPECT_EQ(this->range().num_points(), 0); }
void test_multipoint_it()
{
auto leading_points = this->copy_leading_points();
auto expected = rmm::device_uvector<vec_2d<T>>(0, this->stream());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(leading_points, expected);
}
void test_point_it()
{
auto points = this->copy_all_points();
auto expected = rmm::device_uvector<vec_2d<T>>(0, this->stream());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(points, expected);
}
void test_offsets_it()
{
auto offsets = this->copy_offsets();
auto expected = make_device_vector<std::size_t>({0});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(offsets, expected);
}
void test_geometry_idx_from_point_idx()
{
auto geometry_indices = this->copy_geometry_idx();
auto expected = rmm::device_uvector<std::size_t>(0, this->stream());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(geometry_indices, expected);
}
void test_subscript_operator()
{
// Range is empty, nothing to test.
SUCCEED();
}
void test_point_accessor()
{
// Range is empty, nothing to test.
SUCCEED();
}
void test_is_single_point_range()
{
// Range is empty, undefined behavior.
SUCCEED();
}
};
TYPED_TEST_CASE(EmptyMultiPointRangeTest, FloatingPointTypes);
TYPED_TEST(EmptyMultiPointRangeTest, Test) { this->run_test(); }
template <typename T>
class LengthOneMultiPointRangeTest : public MultipointRangeTest<T> {
public:
void make_test_multipoints()
{
auto array = make_multipoint_array<T>({{{1.0, 1.0}, {10.0, 10.0}}});
this->test_multipoints = std::make_unique<decltype(array)>(std::move(array));
}
void test_num_multipoints() { EXPECT_EQ(this->range().num_multipoints(), 1); }
void test_num_points() { EXPECT_EQ(this->range().num_points(), 2); }
void test_multipoint_it()
{
auto leading_points = this->copy_leading_points();
auto expected = make_device_vector<vec_2d<T>>({{1.0, 1.0}});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(leading_points, expected);
}
void test_point_it()
{
auto points = this->copy_all_points();
auto expected = make_device_vector<vec_2d<T>>({{1.0, 1.0}, {10.0, 10.0}});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(points, expected);
}
void test_offsets_it()
{
auto offsets = this->copy_offsets();
auto expected = make_device_vector<std::size_t>({0, 2});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(offsets, expected);
}
void test_geometry_idx_from_point_idx()
{
auto geometry_indices = this->copy_geometry_idx();
auto expected = make_device_vector<std::size_t>({0, 0});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(geometry_indices, expected);
}
void test_subscript_operator()
{
auto multipoint = this->copy_ith_multipoint(0);
auto expected = make_device_vector<vec_2d<T>>({{1.0, 1.0}, {10.0, 10.0}});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(multipoint, expected);
}
void test_point_accessor()
{
auto point = this->copy_ith_point(1);
auto expected = vec_2d<T>{10.0, 10.0};
EXPECT_EQ(point.value(this->stream()), expected);
}
void test_is_single_point_range() { EXPECT_FALSE(this->range().is_single_point_range()); }
};
TYPED_TEST_CASE(LengthOneMultiPointRangeTest, FloatingPointTypes);
TYPED_TEST(LengthOneMultiPointRangeTest, Test) { this->run_test(); }
template <typename T>
class LengthFiveMultiPointRangeTest : public MultipointRangeTest<T> {
public:
void make_test_multipoints()
{
auto array = make_multipoint_array<T>({{{0.0, 0.0}, {1.0, 1.0}},
{{10.0, 10.0}},
{{20.0, 21.0}, {22.0, 23.0}},
{{30.0, 31.0}, {32.0, 33.0}, {34.0, 35.0}},
{}});
this->test_multipoints = std::make_unique<decltype(array)>(std::move(array));
}
void test_num_multipoints() { EXPECT_EQ(this->range().num_multipoints(), 5); }
void test_num_points() { EXPECT_EQ(this->range().num_points(), 8); }
void test_multipoint_it()
{
auto leading_points = this->copy_leading_points();
auto expected = make_device_vector<vec_2d<T>>(
{{0.0, 0.0}, {10.0, 10.0}, {20.0, 21.0}, {30.0, 31.0}, {-1, -1}});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(leading_points, expected);
}
void test_point_it()
{
auto points = this->copy_all_points();
auto expected = make_device_vector<vec_2d<T>>({{0.0, 0.0},
{1.0, 1.0},
{10.0, 10.0},
{20.0, 21.0},
{22.0, 23.0},
{30.0, 31.0},
{32.0, 33.0},
{34.0, 35.0}});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(points, expected);
}
void test_offsets_it()
{
auto offsets = this->copy_offsets();
auto expected = make_device_vector<std::size_t>({0, 2, 3, 5, 8, 8});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(offsets, expected);
}
void test_geometry_idx_from_point_idx()
{
auto geometry_indices = this->copy_geometry_idx();
auto expected = make_device_vector<std::size_t>({0, 0, 1, 2, 2, 3, 3, 3});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(geometry_indices, expected);
}
void test_subscript_operator()
{
auto second_multipoint = this->copy_ith_multipoint(2);
auto expected = make_device_vector<vec_2d<T>>({{20.0, 21.0}, {22.0, 23.0}});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(second_multipoint, expected);
}
void test_point_accessor()
{
auto third_point = this->copy_ith_point(3);
auto expected = vec_2d<T>{20.0, 21.0};
EXPECT_EQ(third_point.value(this->stream()), expected);
}
void test_is_single_point_range() { EXPECT_FALSE(this->range().is_single_point_range()); }
};
TYPED_TEST_CASE(LengthFiveMultiPointRangeTest, FloatingPointTypes);
TYPED_TEST(LengthFiveMultiPointRangeTest, Test) { this->run_test(); }
template <typename T>
class LengthOneThousandRangeTest : public MultipointRangeTest<T> {
public:
std::size_t static constexpr num_multipoints = 1000;
std::size_t static constexpr num_point_per_multipoint = 3;
std::size_t static constexpr num_points = num_multipoints * num_point_per_multipoint;
void make_test_multipoints()
{
rmm::device_vector<std::size_t> geometry_offsets(num_multipoints + 1);
rmm::device_vector<vec_2d<T>> coordinates(num_points);
thrust::sequence(rmm::exec_policy(this->stream()),
geometry_offsets.begin(),
geometry_offsets.end(),
0ul,
num_point_per_multipoint);
thrust::tabulate(rmm::exec_policy(this->stream()),
coordinates.begin(),
coordinates.end(),
[] __device__(auto i) {
return vec_2d<T>{static_cast<T>(i), 10.0};
});
auto array =
make_multipoint_array<std::size_t, T>(std::move(geometry_offsets), std::move(coordinates));
this->test_multipoints = std::make_unique<decltype(array)>(std::move(array));
}
void test_num_multipoints() { EXPECT_EQ(this->range().num_multipoints(), num_multipoints); }
void test_num_points() { EXPECT_EQ(this->range().num_points(), num_points); }
void test_multipoint_it()
{
auto leading_points = this->copy_leading_points();
auto expect = rmm::device_uvector<vec_2d<T>>(num_multipoints, this->stream());
thrust::tabulate(
rmm::exec_policy(this->stream()), expect.begin(), expect.end(), [] __device__(auto i) {
return vec_2d<T>{static_cast<T>(i) * num_point_per_multipoint, 10.0};
});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(leading_points, expect);
}
void test_point_it()
{
auto all_points = this->copy_all_points();
auto expect = rmm::device_uvector<vec_2d<T>>(num_points, this->stream());
thrust::tabulate(
rmm::exec_policy(this->stream()), expect.begin(), expect.end(), [] __device__(auto i) {
return vec_2d<T>{static_cast<T>(i), 10.0};
});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(all_points, expect);
}
void test_offsets_it()
{
auto offsets = this->copy_offsets();
auto expect = rmm::device_uvector<std::size_t>(num_multipoints + 1, this->stream());
thrust::sequence(rmm::exec_policy(this->stream()),
expect.begin(),
expect.end(),
0ul,
num_point_per_multipoint);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(offsets, expect);
}
void test_geometry_idx_from_point_idx()
{
auto indices = this->copy_geometry_idx();
auto expect = rmm::device_uvector<std::size_t>(3000, this->stream());
thrust::tabulate(
rmm::exec_policy(this->stream()), expect.begin(), expect.end(), [] __device__(auto i) {
return i / num_point_per_multipoint;
});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(indices, expect);
}
void test_subscript_operator()
{
auto multipoint_five_hundred_thirty_third = this->copy_ith_multipoint(533);
auto expect = make_device_vector<vec_2d<T>>({{533 * num_point_per_multipoint, 10.0},
{533 * num_point_per_multipoint + 1, 10.0},
{533 * num_point_per_multipoint + 2, 10.0}});
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(multipoint_five_hundred_thirty_third, expect);
}
void test_point_accessor()
{
auto point_seventeen_hundred_seventy_six = this->copy_ith_point(1776);
auto expect = vec_2d<T>{1776, 10.0};
EXPECT_EQ(point_seventeen_hundred_seventy_six.value(this->stream()), expect);
}
void test_is_single_point_range() { EXPECT_FALSE(this->range().is_single_point_range()); }
};
TYPED_TEST_CASE(LengthOneThousandRangeTest, FloatingPointTypes);
TYPED_TEST(LengthOneThousandRangeTest, Test) { this->run_test(); }
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/distance/linestring_distance_test.cu | /*
* 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 <cuspatial_test/vector_equality.hpp>
#include <cuspatial_test/vector_factories.cuh>
#include <cuspatial/distance.cuh>
#include <cuspatial/error.hpp>
#include <cuspatial/geometry/vec_2d.hpp>
#include <cuspatial/iterator_factory.cuh>
#include <cuspatial/range/multilinestring_range.cuh>
#include <thrust/iterator/constant_iterator.h>
#include <thrust/iterator/counting_iterator.h>
using namespace cuspatial;
using namespace cuspatial::test;
template <typename T>
struct PairwiseLinestringDistanceTest : public ::testing::Test {};
struct PairwiseLinestringDistanceTestUntyped : public ::testing::Test {};
// float and double are logically the same but would require separate tests due to precision.
using TestTypes = ::testing::Types<float, double>;
TYPED_TEST_CASE(PairwiseLinestringDistanceTest, TestTypes);
TYPED_TEST(PairwiseLinestringDistanceTest, FromSeparateArrayInputs)
{
using T = TypeParam;
using CartVec = std::vector<vec_2d<T>>;
auto constexpr num_pairs = 1;
auto a_cart2d = rmm::device_vector<vec_2d<T>>{
CartVec({{0.0f, 0.0f}, {1.0f, 0.0f}, {2.0f, 0.0f}, {3.0f, 0.0f}, {4.0f, 0.0f}})};
auto b_cart2d = rmm::device_vector<vec_2d<T>>{
CartVec({{0.0f, 1.0f}, {1.0f, 1.0f}, {2.0f, 1.0f}, {3.0f, 1.0f}, {4.0f, 1.0f}})};
auto offset = make_device_vector<int32_t>({0, 5});
auto mlinestrings1 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
offset.size() - 1,
offset.begin(),
a_cart2d.size(),
a_cart2d.begin());
auto mlinestrings2 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
offset.size() - 1,
offset.begin(),
b_cart2d.size(),
b_cart2d.begin());
auto got = rmm::device_vector<T>(num_pairs);
auto expected = rmm::device_vector<T>{std::vector<T>{1.0}};
auto ret = pairwise_linestring_distance(mlinestrings1, mlinestrings2, got.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected, got);
EXPECT_EQ(num_pairs, std::distance(got.begin(), ret));
}
TYPED_TEST(PairwiseLinestringDistanceTest, FromSamePointArrayInput)
{
using T = TypeParam;
using CartVec = std::vector<vec_2d<T>>;
auto constexpr num_pairs = 1;
auto cart2ds = make_device_vector<vec_2d<T>>(
{{0.0f, 0.0f}, {1.0f, 0.0f}, {2.0f, 0.0f}, {3.0f, 0.0f}, {4.0f, 0.0f}});
auto offset_a = make_device_vector<int32_t>({0, 3});
auto offset_b = make_device_vector<int32_t>({0, 4});
auto got = rmm::device_vector<T>(1);
auto expected = make_device_vector<T>({0.0});
auto mlinestrings1 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
offset_a.size() - 1,
offset_a.begin(),
3,
cart2ds.begin());
auto mlinestrings2 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
offset_b.size() - 1,
offset_b.begin(),
4,
thrust::next(cart2ds.begin()));
auto ret = pairwise_linestring_distance(mlinestrings1, mlinestrings2, got.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected, got);
EXPECT_EQ(num_pairs, std::distance(got.begin(), ret));
}
TYPED_TEST(PairwiseLinestringDistanceTest, FromTransformIterator)
{
using T = TypeParam;
using CartVec = std::vector<vec_2d<T>>;
auto constexpr num_pairs = 1;
auto a_cart2d_x = rmm::device_vector<T>{std::vector<T>{0.0, 1.0, 2.0, 3.0, 4.0}};
auto a_cart2d_y = rmm::device_vector<T>(5, 0.0);
auto a_begin = make_vec_2d_iterator(a_cart2d_x.begin(), a_cart2d_y.begin());
auto b_cart2d_x = rmm::device_vector<T>{std::vector<T>{0.0, 1.0, 2.0, 3.0, 4.0}};
auto b_cart2d_y = rmm::device_vector<T>(5, 1.0);
auto b_begin = make_vec_2d_iterator(b_cart2d_x.begin(), b_cart2d_y.begin());
auto offset = rmm::device_vector<int32_t>{std::vector<int32_t>{0, 5}};
auto got = rmm::device_vector<T>{1};
auto expected = rmm::device_vector<T>{std::vector<T>{1.0}};
auto mlinestrings1 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
offset.size() - 1,
offset.begin(),
a_cart2d_x.size(),
a_begin);
auto mlinestrings2 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
offset.size() - 1,
offset.begin(),
b_cart2d_x.size(),
b_begin);
auto ret = pairwise_linestring_distance(mlinestrings1, mlinestrings2, got.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected, got);
EXPECT_EQ(num_pairs, std::distance(got.begin(), ret));
}
TYPED_TEST(PairwiseLinestringDistanceTest, FromMixedIterator)
{
using T = TypeParam;
using CartVec = std::vector<vec_2d<T>>;
auto constexpr num_pairs = 1;
auto a_cart2d = rmm::device_vector<vec_2d<T>>{
CartVec({{0.0f, 0.0f}, {1.0f, 0.0f}, {2.0f, 0.0f}, {3.0f, 0.0f}, {4.0f, 0.0f}})};
auto b_cart2d_x = rmm::device_vector<T>{std::vector<T>{0.0, 1.0, 2.0, 3.0, 4.0}};
auto b_cart2d_y = rmm::device_vector<T>(5, 1.0);
auto b_begin = make_vec_2d_iterator(b_cart2d_x.begin(), b_cart2d_y.begin());
auto offset_a = rmm::device_vector<int32_t>{std::vector<int32_t>{0, 5}};
auto offset_b = rmm::device_vector<int32_t>{std::vector<int32_t>{0, 5}};
auto got = rmm::device_vector<T>{1};
auto expected = rmm::device_vector<T>{std::vector<T>{1.0}};
auto mlinestrings1 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
offset_a.size() - 1,
offset_a.begin(),
a_cart2d.size(),
a_cart2d.begin());
auto mlinestrings2 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
offset_b.size() - 1,
offset_b.begin(),
b_cart2d_x.size(),
b_begin);
auto ret = pairwise_linestring_distance(mlinestrings1, mlinestrings2, got.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected, got);
EXPECT_EQ(num_pairs, std::distance(got.begin(), ret));
}
TYPED_TEST(PairwiseLinestringDistanceTest, FromLongInputs)
{
using T = TypeParam;
using CartVec = std::vector<vec_2d<T>>;
auto constexpr num_pairs = 5;
auto constexpr num_points = 1000;
auto a_cart2d_x_begin = thrust::make_constant_iterator(T{0.0});
auto a_cart2d_y_begin = thrust::make_counting_iterator(T{0.0});
auto a_cart2d_begin = make_vec_2d_iterator(a_cart2d_x_begin, a_cart2d_y_begin);
auto b_cart2d_x_begin = thrust::make_constant_iterator(T{42.0});
auto b_cart2d_y_begin = thrust::make_counting_iterator(T{0.0});
auto b_cart2d_begin = make_vec_2d_iterator(b_cart2d_x_begin, b_cart2d_y_begin);
auto offset =
rmm::device_vector<int32_t>{std::vector<int32_t>{0, 100, 200, 300, 400, num_points}};
auto got = rmm::device_vector<T>{num_pairs};
auto expected = rmm::device_vector<T>{std::vector<T>{42.0, 42.0, 42.0, 42.0, 42.0}};
auto mlinestrings1 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
offset.size() - 1,
offset.begin(),
num_points,
a_cart2d_begin);
auto mlinestrings2 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
offset.size() - 1,
offset.begin(),
num_points,
b_cart2d_begin);
auto ret = pairwise_linestring_distance(mlinestrings1, mlinestrings2, got.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected, got);
EXPECT_EQ(num_pairs, std::distance(got.begin(), ret));
}
TYPED_TEST(PairwiseLinestringDistanceTest, OnePairLinestringParallel)
{
using T = TypeParam;
// Linestring 1: (0.0, 0.0), (1.0, 1.0)
// Linestring 2: (1.0, 0.0), (2.0, 1.0)
int32_t constexpr num_pairs = 1;
auto linestring1_offsets = make_device_vector<int32_t>({0, 2});
auto linestring1_points_xy = make_device_vector<T>({0.0, 0.0, 1.0, 1.0});
auto linestring2_offsets = make_device_vector<int32_t>({0, 2});
auto linestring2_points_xy = make_device_vector<T>({1.0, 0.0, 2.0, 1.0});
auto linestring1_points_it = make_vec_2d_iterator(linestring1_points_xy.begin());
auto linestring2_points_it = make_vec_2d_iterator(linestring2_points_xy.begin());
auto expected = make_device_vector<T>({0.7071067811865476});
auto got = rmm::device_vector<T>(expected.size());
auto mlinestrings1 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring1_offsets.size() - 1,
linestring1_offsets.begin(),
linestring1_points_xy.size() / 2,
linestring1_points_it);
auto mlinestrings2 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring2_offsets.size() - 1,
linestring2_offsets.begin(),
linestring2_points_xy.size() / 2,
linestring2_points_it);
auto ret = pairwise_linestring_distance(mlinestrings1, mlinestrings2, got.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected, got);
EXPECT_EQ(num_pairs, std::distance(got.begin(), ret));
}
TYPED_TEST(PairwiseLinestringDistanceTest, OnePairLinestringEndpointsDistance)
{
using T = TypeParam;
// Linestring 1: (0.0, 0.0), (1.0, 1.0), (2.0, 2.0)
// Linestring 2: (2.0, 0.0), (1.0, -1.0), (0.0, -1.0)
auto constexpr num_pairs = 1;
auto linestring1_offsets = make_device_vector<int32_t>({0, 3});
auto linestring1_points_xy = make_device_vector<T>({0.0, 0.0, 1.0, 1.0, 2.0, 2.0});
auto linestring2_offsets = make_device_vector<T>({0, 3});
auto linestring2_points_xy = make_device_vector<T>({2.0, 0.0, 1.0, -1.0, 0.0, -1.0});
auto linestring1_points_it = make_vec_2d_iterator(linestring1_points_xy.begin());
auto linestring2_points_it = make_vec_2d_iterator(linestring2_points_xy.begin());
auto expected = make_device_vector<T>({1.0});
auto got = rmm::device_vector<T>(expected.size());
auto mlinestrings1 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring1_offsets.size() - 1,
linestring1_offsets.begin(),
linestring1_points_xy.size() / 2,
linestring1_points_it);
auto mlinestrings2 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring2_offsets.size() - 1,
linestring2_offsets.begin(),
linestring2_points_xy.size() / 2,
linestring2_points_it);
auto ret = pairwise_linestring_distance(mlinestrings1, mlinestrings2, got.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected, got);
EXPECT_EQ(num_pairs, std::distance(got.begin(), ret));
}
TYPED_TEST(PairwiseLinestringDistanceTest, OnePairLinestringProjectionNotOnLine)
{
using T = TypeParam;
auto constexpr num_pairs = 1;
// Linestring 1: (0.0, 0.0), (1.0, 1.0)
// Linestring 2: (3.0, 1.5), (3.0, 2.0)
auto linestring1_offsets = make_device_vector<int32_t>({0, 2});
auto linestring1_points_xy = make_device_vector<T>({0.0, 0.0, 1.0, 1.0});
auto linestring2_offsets = make_device_vector<int32_t>({0, 2});
auto linestring2_points_xy = make_device_vector<T>({3.0, 1.5, 3.0, 2.0});
auto linestring1_points_it = make_vec_2d_iterator(linestring1_points_xy.begin());
auto linestring2_points_it = make_vec_2d_iterator(linestring2_points_xy.begin());
auto expected = make_device_vector<T>({2.0615528128088303});
auto got = rmm::device_vector<T>(expected.size());
auto mlinestrings1 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring1_offsets.size() - 1,
linestring1_offsets.begin(),
linestring1_points_xy.size() / 2,
linestring1_points_it);
auto mlinestrings2 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring2_offsets.size() - 1,
linestring2_offsets.begin(),
linestring2_points_xy.size() / 2,
linestring2_points_it);
auto ret = pairwise_linestring_distance(mlinestrings1, mlinestrings2, got.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected, got);
EXPECT_EQ(num_pairs, std::distance(got.begin(), ret));
}
TYPED_TEST(PairwiseLinestringDistanceTest, OnePairLinestringPerpendicular)
{
using T = TypeParam;
auto constexpr num_pairs = 1;
// Linestring 1: (0.0, 0.0), (2.0, 0.0)
// Linestring 2: (1.0, 1.0), (1.0, 2.0)
auto linestring1_offsets = make_device_vector<int32_t>({0, 2});
auto linestring1_points_xy = make_device_vector<T>({0.0, 0.0, 2.0, 0.0});
auto linestring2_offsets = make_device_vector<int32_t>({0, 2});
auto linestring2_points_xy = make_device_vector<T>({1.0, 1.0, 1.0, 2.0});
auto linestring1_points_it = make_vec_2d_iterator(linestring1_points_xy.begin());
auto linestring2_points_it = make_vec_2d_iterator(linestring2_points_xy.begin());
auto expected = make_device_vector<T>({1.0});
auto got = rmm::device_vector<T>(expected.size());
auto mlinestrings1 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring1_offsets.size() - 1,
linestring1_offsets.begin(),
linestring1_points_xy.size() / 2,
linestring1_points_it);
auto mlinestrings2 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring2_offsets.size() - 1,
linestring2_offsets.begin(),
linestring2_points_xy.size() / 2,
linestring2_points_it);
auto ret = pairwise_linestring_distance(mlinestrings1, mlinestrings2, got.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected, got);
EXPECT_EQ(num_pairs, std::distance(got.begin(), ret));
}
TYPED_TEST(PairwiseLinestringDistanceTest, OnePairLinestringIntersects)
{
using T = TypeParam;
auto constexpr num_pairs = 1;
// Linestring 1: (0.0, 0.0), (1.0, 1.0)
// Linestring 2: (0.0, 1.0), (1.0, 0.0)
auto linestring1_offsets = make_device_vector<int32_t>({0, 2});
auto linestring1_points_xy = make_device_vector<T>({0.0, 0.0, 1.0, 1.0});
auto linestring2_offsets = make_device_vector<int32_t>({0, 2});
auto linestring2_points_xy = make_device_vector<T>({0.0, 1.0, 1.0, 0.0});
auto linestring1_points_it = make_vec_2d_iterator(linestring1_points_xy.begin());
auto linestring2_points_it = make_vec_2d_iterator(linestring2_points_xy.begin());
auto expected = make_device_vector<T>({0.0});
auto got = rmm::device_vector<T>(expected.size());
auto mlinestrings1 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring1_offsets.size() - 1,
linestring1_offsets.begin(),
linestring1_points_xy.size() / 2,
linestring1_points_it);
auto mlinestrings2 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring2_offsets.size() - 1,
linestring2_offsets.begin(),
linestring2_points_xy.size() / 2,
linestring2_points_it);
auto ret = pairwise_linestring_distance(mlinestrings1, mlinestrings2, got.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected, got);
EXPECT_EQ(num_pairs, std::distance(got.begin(), ret));
}
TYPED_TEST(PairwiseLinestringDistanceTest, OnePairLinestringSharedVertex)
{
using T = TypeParam;
auto constexpr num_pairs = 1;
// Linestring 1: (0.0, 0.0), (0.0, 2.0), (2.0, 2.0)
// Linestring 2: (2.0, 2.0), (2.0, 1.0), (1.0, 1.0), (2.5, 0.0)
auto linestring1_offsets = make_device_vector<int32_t>({0, 3});
auto linestring1_points_xy = make_device_vector<T>({0.0, 0.0, 0.0, 2.0, 2.0, 2.0});
auto linestring2_offsets = make_device_vector<int32_t>({0, 4});
auto linestring2_points_xy = make_device_vector<T>({2.0, 2.0, 2.0, 1.0, 1.0, 1.0, 2.5, 0.0});
auto linestring1_points_it = make_vec_2d_iterator(linestring1_points_xy.begin());
auto linestring2_points_it = make_vec_2d_iterator(linestring2_points_xy.begin());
auto expected = make_device_vector<T>({0.0});
auto got = rmm::device_vector<T>(expected.size());
auto mlinestrings1 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring1_offsets.size() - 1,
linestring1_offsets.begin(),
linestring1_points_xy.size() / 2,
linestring1_points_it);
auto mlinestrings2 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring2_offsets.size() - 1,
linestring2_offsets.begin(),
linestring2_points_xy.size() / 2,
linestring2_points_it);
auto ret = pairwise_linestring_distance(mlinestrings1, mlinestrings2, got.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected, got);
EXPECT_EQ(num_pairs, std::distance(got.begin(), ret));
}
TYPED_TEST(PairwiseLinestringDistanceTest, OnePairLinestringCoincide)
{
using T = TypeParam;
auto constexpr num_pairs = 1;
// Linestring 1: (0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 1.0)
// Linestring 2: (2.0, 1.0), (1.0, 1.0), (1.0, 0.0), (2.0, 0.0), (2.0, 0.5)
auto linestring1_offsets = make_device_vector<int32_t>({0, 4});
auto linestring1_points_xy = make_device_vector<T>({0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0});
auto linestring2_offsets = make_device_vector<int32_t>({0, 5});
auto linestring2_points_xy =
make_device_vector<T>({2.0, 1.0, 1.0, 1.0, 1.0, 0.0, 2.0, 0.0, 2.0, 0.5});
auto linestring1_points_it = make_vec_2d_iterator(linestring1_points_xy.begin());
auto linestring2_points_it = make_vec_2d_iterator(linestring2_points_xy.begin());
auto expected = make_device_vector<T>({0.0});
auto got = rmm::device_vector<T>(expected.size());
auto mlinestrings1 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring1_offsets.size() - 1,
linestring1_offsets.begin(),
linestring1_points_xy.size() / 2,
linestring1_points_it);
auto mlinestrings2 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring2_offsets.size() - 1,
linestring2_offsets.begin(),
linestring2_points_xy.size() / 2,
linestring2_points_it);
auto ret = pairwise_linestring_distance(mlinestrings1, mlinestrings2, got.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected, got);
EXPECT_EQ(num_pairs, std::distance(got.begin(), ret));
}
TYPED_TEST(PairwiseLinestringDistanceTest, OnePairDegenerateCollinearNoIntersect)
{
using T = TypeParam;
auto constexpr num_pairs = 1;
// Linestring1: (0.0, 0.0) -> (0.0, 1.0)
// Linestring2: (0.0, 2.0) -> (0.0, 3.0)
auto linestring1_offsets = make_device_vector<int32_t>({0, 2});
auto linestring1_points_xy = make_device_vector<T>({0.0, 0.0, 0.0, 1.0});
auto linestring2_offsets = make_device_vector<int32_t>({0, 2});
auto linestring2_points_xy = make_device_vector<T>({0.0, 2.0, 0.0, 3.0});
auto linestring1_points_it = make_vec_2d_iterator(linestring1_points_xy.begin());
auto linestring2_points_it = make_vec_2d_iterator(linestring2_points_xy.begin());
auto expected = make_device_vector<T>({1.0});
auto got = rmm::device_vector<T>(expected.size());
auto mlinestrings1 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring1_offsets.size() - 1,
linestring1_offsets.begin(),
linestring1_points_xy.size() / 2,
linestring1_points_it);
auto mlinestrings2 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring2_offsets.size() - 1,
linestring2_offsets.begin(),
linestring2_points_xy.size() / 2,
linestring2_points_it);
auto ret = pairwise_linestring_distance(mlinestrings1, mlinestrings2, got.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected, got);
EXPECT_EQ(num_pairs, std::distance(got.begin(), ret));
}
TYPED_TEST(PairwiseLinestringDistanceTest, OnePairCollinearNoIntersect)
{
using T = TypeParam;
auto constexpr num_pairs = 1;
// Linestring1: (0.0, 0.0) -> (1.0, 1.0)
// Linestring2: (2.0, 2.0) -> (3.0, 3.0)
auto linestring1_offsets = make_device_vector<int32_t>({0, 2});
auto linestring1_points_xy = make_device_vector<T>({0.0, 0.0, 1.0, 1.0});
auto linestring2_offsets = make_device_vector<int32_t>({0, 2});
auto linestring2_points_xy = make_device_vector<T>({2.0, 2.0, 3.0, 3.0});
auto linestring1_points_it = make_vec_2d_iterator(linestring1_points_xy.begin());
auto linestring2_points_it = make_vec_2d_iterator(linestring2_points_xy.begin());
auto expected = make_device_vector<T>({1.4142135623730951});
auto got = rmm::device_vector<T>(expected.size());
auto mlinestrings1 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring1_offsets.size() - 1,
linestring1_offsets.begin(),
linestring1_points_xy.size() / 2,
linestring1_points_it);
auto mlinestrings2 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring2_offsets.size() - 1,
linestring2_offsets.begin(),
linestring2_points_xy.size() / 2,
linestring2_points_it);
auto ret = pairwise_linestring_distance(mlinestrings1, mlinestrings2, got.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected, got);
EXPECT_EQ(num_pairs, std::distance(got.begin(), ret));
}
TYPED_TEST(PairwiseLinestringDistanceTest, OnePairDegenerateCollinearIntersect)
{
using T = TypeParam;
auto constexpr num_pairs = 1;
auto linestring1_offsets = make_device_vector<int32_t>({0, 2});
auto linestring1_points_xy = make_device_vector<T>({0.0, 0.0, 2.0, 2.0});
auto linestring2_offsets = make_device_vector<int32_t>({0, 2});
auto linestring2_points_xy = make_device_vector<T>({1.0, 1.0, 3.0, 3.0});
auto linestring1_points_it = make_vec_2d_iterator(linestring1_points_xy.begin());
auto linestring2_points_it = make_vec_2d_iterator(linestring2_points_xy.begin());
auto expected = make_device_vector<T>({0.0});
auto got = rmm::device_vector<T>(expected.size());
auto mlinestrings1 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring1_offsets.size() - 1,
linestring1_offsets.begin(),
linestring1_points_xy.size() / 2,
linestring1_points_it);
auto mlinestrings2 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring2_offsets.size() - 1,
linestring2_offsets.begin(),
linestring2_points_xy.size() / 2,
linestring2_points_it);
auto ret = pairwise_linestring_distance(mlinestrings1, mlinestrings2, got.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected, got);
EXPECT_EQ(num_pairs, std::distance(got.begin(), ret));
}
TEST_F(PairwiseLinestringDistanceTestUntyped, OnePairDeterminantDoublePrecisionDenormalized)
{
// Vector ab: (1e-155, 2e-155)
// Vector cd: (2e-155, 1e-155)
// determinant of matrix [a, b] = -3e-310, a denormalized number
auto constexpr num_pairs = 1;
auto linestring1_offsets = make_device_vector<int32_t>({0, 2});
auto linestring1_points_xy = make_device_vector<double>({0.0, 0.0, 1e-155, 2e-155});
auto linestring2_offsets = make_device_vector<int32_t>({0, 2});
auto linestring2_points_xy = make_device_vector<double>({4e-155, 5e-155, 6e-155, 6e-155});
auto linestring1_points_it = make_vec_2d_iterator(linestring1_points_xy.begin());
auto linestring2_points_it = make_vec_2d_iterator(linestring2_points_xy.begin());
auto expected = make_device_vector<double>({4.24264068711929e-155});
auto got = rmm::device_vector<double>(expected.size());
auto mlinestrings1 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring1_offsets.size() - 1,
linestring1_offsets.begin(),
linestring1_points_xy.size() / 2,
linestring1_points_it);
auto mlinestrings2 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring2_offsets.size() - 1,
linestring2_offsets.begin(),
linestring2_points_xy.size() / 2,
linestring2_points_it);
auto ret = pairwise_linestring_distance(mlinestrings1, mlinestrings2, got.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected, got);
EXPECT_EQ(num_pairs, std::distance(got.begin(), ret));
}
TEST_F(PairwiseLinestringDistanceTestUntyped, OnePairDeterminantSinglePrecisionDenormalized)
{
// Vector ab: (1e-20, 2e-20)
// Vector cd: (2e-20, 1e-20)
// determinant of matrix [ab, cd] = -3e-40, a denormalized number
auto constexpr num_pairs = 1;
auto linestring1_offsets = make_device_vector<int32_t>({0, 2});
auto linestring1_points_xy = make_device_vector<float>({0.0, 0.0, 1e-20, 2e-20});
auto linestring2_offsets = make_device_vector<int32_t>({0, 2});
auto linestring2_points_xy = make_device_vector<float>({4e-20, 5e-20, 6e-20, 6e-20});
auto linestring1_points_it = make_vec_2d_iterator(linestring1_points_xy.begin());
auto linestring2_points_it = make_vec_2d_iterator(linestring2_points_xy.begin());
auto expected = make_device_vector<float>({4.2426405524813e-20});
auto got = rmm::device_vector<float>(expected.size());
auto mlinestrings1 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring1_offsets.size() - 1,
linestring1_offsets.begin(),
linestring1_points_xy.size() / 2,
linestring1_points_it);
auto mlinestrings2 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring2_offsets.size() - 1,
linestring2_offsets.begin(),
linestring2_points_xy.size() / 2,
linestring2_points_it);
auto ret = pairwise_linestring_distance(mlinestrings1, mlinestrings2, got.begin());
// Expect a slightly greater floating point error compared to 4 ULP
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected, got, 1e-25f);
EXPECT_EQ(num_pairs, std::distance(got.begin(), ret));
}
TYPED_TEST(PairwiseLinestringDistanceTest, OnePairRandom1)
{
using T = TypeParam;
auto constexpr num_pairs = 1;
auto linestring1_offsets = make_device_vector<int32_t>({0, 3});
auto linestring1_points_xy = make_device_vector<T>({-22556.235212018168,
41094.0501840996,
-16375.655690574613,
42992.319790050366,
-20082.724633593425,
33759.13529113619});
auto linestring2_offsets = make_device_vector<int32_t>({0, 2});
auto linestring2_points_xy = make_device_vector<T>(
{4365.496374409238, -59857.47177852941, 1671.0269165650761, -54931.9723439855});
auto linestring1_points_it = make_vec_2d_iterator(linestring1_points_xy.begin());
auto linestring2_points_it = make_vec_2d_iterator(linestring2_points_xy.begin());
auto expected = make_device_vector<T>({91319.97744223749});
auto got = rmm::device_vector<T>(expected.size());
auto mlinestrings1 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring1_offsets.size() - 1,
linestring1_offsets.begin(),
linestring1_points_xy.size() / 2,
linestring1_points_it);
auto mlinestrings2 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring2_offsets.size() - 1,
linestring2_offsets.begin(),
linestring2_points_xy.size() / 2,
linestring2_points_it);
auto ret = pairwise_linestring_distance(mlinestrings1, mlinestrings2, got.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected, got);
EXPECT_EQ(num_pairs, std::distance(got.begin(), ret));
}
TYPED_TEST(PairwiseLinestringDistanceTest, OnePairIntersectFromRealData1)
{
// Example extracted from a pair of trajectry in geolife dataset
using T = TypeParam;
auto constexpr num_pairs = 1;
auto linestring1_offsets = make_device_vector<int32_t>({0, 5});
auto linestring1_points_xy = make_device_vector<T>({39.97551667,
116.33028333,
39.97585,
116.3304,
39.97598333,
116.33046667,
39.9761,
116.3305,
39.97623333,
116.33056667});
auto linestring2_offsets = make_device_vector<int32_t>({0, 55});
auto linestring2_points_xy = make_device_vector<T>(
{39.97381667, 116.34211667, 39.97341667, 116.34215, 39.9731, 116.34218333,
39.97293333, 116.34221667, 39.97233333, 116.34225, 39.97218333, 116.34243333,
39.97218333, 116.34296667, 39.97215, 116.34478333, 39.97168333, 116.34486667,
39.97093333, 116.34485, 39.97073333, 116.34468333, 39.9705, 116.34461667,
39.96991667, 116.34465, 39.96961667, 116.34465, 39.96918333, 116.34466667,
39.96891667, 116.34465, 39.97531667, 116.33036667, 39.97533333, 116.32961667,
39.97535, 116.3292, 39.97515, 116.32903333, 39.97506667, 116.32985,
39.97508333, 116.33128333, 39.9751, 116.33195, 39.97513333, 116.33618333,
39.97511667, 116.33668333, 39.97503333, 116.33818333, 39.97513333, 116.34,
39.97523333, 116.34045, 39.97521667, 116.34183333, 39.97503333, 116.342,
39.97463333, 116.34203333, 39.97443333, 116.3422, 39.96838333, 116.3445,
39.96808333, 116.34451667, 39.96771667, 116.3445, 39.96745, 116.34453333,
39.96735, 116.34493333, 39.9673, 116.34506667, 39.96718333, 116.3451,
39.96751667, 116.34483333, 39.9678, 116.3448, 39.9676, 116.3449,
39.96741667, 116.345, 39.9672, 116.34506667, 39.97646667, 116.33006667,
39.9764, 116.33015, 39.97625, 116.33026667, 39.9762, 116.33038333,
39.97603333, 116.33036667, 39.97581667, 116.3303, 39.9757, 116.33033333,
39.97551667, 116.33035, 39.97535, 116.3304, 39.97543333, 116.33078333,
39.97538333, 116.33066667});
auto linestring1_points_it = make_vec_2d_iterator(linestring1_points_xy.begin());
auto linestring2_points_it = make_vec_2d_iterator(linestring2_points_xy.begin());
auto expected = make_device_vector<T>({0.0});
auto got = rmm::device_vector<T>(expected.size());
auto mlinestrings1 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring1_offsets.size() - 1,
linestring1_offsets.begin(),
linestring1_points_xy.size() / 2,
linestring1_points_it);
auto mlinestrings2 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring2_offsets.size() - 1,
linestring2_offsets.begin(),
linestring2_points_xy.size() / 2,
linestring2_points_it);
auto ret = pairwise_linestring_distance(mlinestrings1, mlinestrings2, got.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected, got);
EXPECT_EQ(num_pairs, std::distance(got.begin(), ret));
}
TYPED_TEST(PairwiseLinestringDistanceTest, OnePairFromRealData)
{
// Example extracted from a pair of trajectry in geolife dataset
using T = TypeParam;
auto constexpr num_pairs = 1;
auto linestring1_offsets = make_device_vector<int32_t>({0, 2});
auto linestring1_points_xy =
make_device_vector<T>({39.9752666666667, 116.334316666667, 39.9752666666667, 116.334533333333});
auto linestring2_offsets = make_device_vector<int32_t>({0, 2});
auto linestring2_points_xy =
make_device_vector<T>({39.9752666666667, 116.323966666667, 39.9752666666667, 116.3236});
auto linestring1_points_it = make_vec_2d_iterator(linestring1_points_xy.begin());
auto linestring2_points_it = make_vec_2d_iterator(linestring2_points_xy.begin());
// Steps to reproduce:
// Create a float32/float64 numpy array with the literal inputs as above.
// Construct a shapely.geometry.LineString object and compute the result.
// Cast the result to np.float32/np.float64.
auto expected =
make_device_vector<T>({std::is_same_v<T, float> ? 0.010353088f : 0.010349999999988313});
auto got = rmm::device_vector<T>(expected.size());
auto mlinestrings1 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring1_offsets.size() - 1,
linestring1_offsets.begin(),
linestring1_points_xy.size() / 2,
linestring1_points_it);
auto mlinestrings2 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring2_offsets.size() - 1,
linestring2_offsets.begin(),
linestring2_points_xy.size() / 2,
linestring2_points_it);
auto ret = pairwise_linestring_distance(mlinestrings1, mlinestrings2, got.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected, got);
EXPECT_EQ(num_pairs, std::distance(got.begin(), ret));
}
TYPED_TEST(PairwiseLinestringDistanceTest, TwoPairsSingleLineString)
{
using T = TypeParam;
auto constexpr num_pairs = 2;
// First pair lhs:
// (41658.902315589876, 14694.11814724456)->(46600.70359801489, 8771.431887804214)->
// (47079.510547637154, 10199.68027155776)->(51498.48049880379, 17049.62665643919)
// First pair rhs:
// (24046.170375947084, 27878.56737867571)->(20614.007047185743, 26489.74880629428)
// Second pair lhs:
// (-27429.917796286478, -33240.8339287343)->(-21764.269974046114, -37974.45515744517)->
// (-14460.71813363161, -31333.481529957502)->(-18226.13032712476, -30181.03842467982)
// Second pair rhs:
// (48381.39607717942, -8366.313156569413)->(53346.77764665915, -2066.3869793077383)
auto linestring1_offsets = make_device_vector<int32_t>({0, 4, 8});
auto linestring1_points_xy = make_device_vector<T>({41658.902315589876,
14694.11814724456,
46600.70359801489,
8771.431887804214,
47079.510547637154,
10199.68027155776,
51498.48049880379,
17049.62665643919,
-27429.917796286478,
-33240.8339287343,
-21764.269974046114,
-37974.45515744517,
-14460.71813363161,
-31333.481529957502,
-18226.13032712476,
-30181.03842467982});
auto linestring2_offsets = make_device_vector<int32_t>({0, 2, 4});
auto linestring2_points_xy = make_device_vector<T>({
24046.170375947084,
27878.56737867571,
20614.007047185743,
26489.74880629428,
48381.39607717942,
-8366.313156569413,
53346.77764665915,
-2066.3869793077383,
});
auto linestring1_points_it = make_vec_2d_iterator(linestring1_points_xy.begin());
auto linestring2_points_it = make_vec_2d_iterator(linestring2_points_xy.begin());
auto expected = make_device_vector<T>({22000.86425379464, 66907.56415814416});
auto got = rmm::device_vector<T>(expected.size());
auto mlinestrings1 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring1_offsets.size() - 1,
linestring1_offsets.begin(),
linestring1_points_xy.size() / 2,
linestring1_points_it);
auto mlinestrings2 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring2_offsets.size() - 1,
linestring2_offsets.begin(),
linestring2_points_xy.size() / 2,
linestring2_points_it);
auto ret = pairwise_linestring_distance(mlinestrings1, mlinestrings2, got.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected, got);
EXPECT_EQ(num_pairs, std::distance(got.begin(), ret));
}
TYPED_TEST(PairwiseLinestringDistanceTest, FourPairsSingleLineString)
{
using T = TypeParam;
auto constexpr num_pairs = 4;
auto linestring1_offsets = make_device_vector<int32_t>({0, 3, 5, 8, 10});
auto linestring1_points_xy =
make_device_vector<T>({0, 1, 1, 0, -1, 0, 0, 0, 0, 1, 0, 0, 2, 2, -2, 0, 2, 2, -2, -2});
auto linestring2_offsets = make_device_vector<int32_t>({0, 4, 7, 9, 12});
auto linestring2_points_xy = make_device_vector<T>(
{1, 1, 2, 1, 2, 0, 3, 0, 1, 0, 1, 1, 1, 2, 2, 0, 0, 2, 1, 1, 5, 5, 10, 0});
auto linestring1_points_it = make_vec_2d_iterator(linestring1_points_xy.begin());
auto linestring2_points_it = make_vec_2d_iterator(linestring2_points_xy.begin());
auto expected = make_device_vector<T>({static_cast<T>(std::sqrt(2.0) * 0.5), 1.0, 0.0, 0.0});
auto got = rmm::device_vector<T>(expected.size());
auto mlinestrings1 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring1_offsets.size() - 1,
linestring1_offsets.begin(),
linestring1_points_xy.size() / 2,
linestring1_points_it);
auto mlinestrings2 = make_multilinestring_range(num_pairs,
thrust::make_counting_iterator(0),
linestring2_offsets.size() - 1,
linestring2_offsets.begin(),
linestring2_points_xy.size() / 2,
linestring2_points_it);
auto ret = pairwise_linestring_distance(mlinestrings1, mlinestrings2, got.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected, got);
EXPECT_EQ(num_pairs, std::distance(got.begin(), ret));
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/distance/haversine_test.cu | /*
* 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 <cuspatial_test/vector_equality.hpp>
#include <cuspatial/distance.cuh>
#include <cuspatial/error.hpp>
#include <rmm/device_vector.hpp>
#include <thrust/iterator/transform_iterator.h>
#include <gtest/gtest.h>
template <typename T>
struct HaversineTest : public ::testing::Test {};
// float and double are logically the same but would require separate tests due to precision.
using TestTypes = ::testing::Types<float, double>;
TYPED_TEST_CASE(HaversineTest, TestTypes);
TYPED_TEST(HaversineTest, Empty)
{
using T = TypeParam;
using Location = cuspatial::vec_2d<T>;
auto a_lonlat = rmm::device_vector<Location>{};
auto b_lonlat = rmm::device_vector<Location>{};
auto distance = rmm::device_vector<T>{};
auto expected = rmm::device_vector<T>{};
auto distance_end = cuspatial::haversine_distance(
a_lonlat.begin(), a_lonlat.end(), b_lonlat.begin(), distance.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected, distance);
EXPECT_EQ(0, std::distance(distance.begin(), distance_end));
}
TYPED_TEST(HaversineTest, Zero)
{
using T = TypeParam;
using Location = cuspatial::vec_2d<T>;
using LocVec = std::vector<Location>;
auto a_lonlat = rmm::device_vector<Location>(1, Location{0, 0});
auto b_lonlat = rmm::device_vector<Location>(1, Location{0, 0});
auto distance = rmm::device_vector<T>{1, -1};
auto expected = rmm::device_vector<T>{1, 0};
auto distance_end = cuspatial::haversine_distance(
a_lonlat.begin(), a_lonlat.end(), b_lonlat.begin(), distance.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected, distance);
EXPECT_EQ(1, std::distance(distance.begin(), distance_end));
}
TYPED_TEST(HaversineTest, NegativeRadius)
{
using T = TypeParam;
using Location = cuspatial::vec_2d<T>;
using LocVec = std::vector<Location>;
auto a_lonlat = rmm::device_vector<Location>(LocVec({Location{1, 1}, Location{0, 0}}));
auto b_lonlat = rmm::device_vector<Location>(LocVec({Location{1, 1}, Location{0, 0}}));
auto distance = rmm::device_vector<T>{1, -1};
auto expected = rmm::device_vector<T>{1, 0};
EXPECT_THROW(cuspatial::haversine_distance(
a_lonlat.begin(), a_lonlat.end(), b_lonlat.begin(), distance.begin(), T{-10}),
cuspatial::logic_error);
}
TYPED_TEST(HaversineTest, EquivalentPoints)
{
using T = TypeParam;
using Location = cuspatial::vec_2d<T>;
auto h_a_lonlat = std::vector<Location>({{-180, 0}, {180, 30}});
auto h_b_lonlat = std::vector<Location>({{180, 0}, {-180, 30}});
auto h_expected = std::vector<T>({1.5604449514735574e-12, 1.3513849691832763e-12});
auto a_lonlat = rmm::device_vector<Location>{h_a_lonlat};
auto b_lonlat = rmm::device_vector<Location>{h_b_lonlat};
auto distance = rmm::device_vector<T>{2, -1};
auto expected = rmm::device_vector<T>{h_expected};
auto distance_end = cuspatial::haversine_distance(
a_lonlat.begin(), a_lonlat.end(), b_lonlat.begin(), distance.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected, distance);
EXPECT_EQ(2, std::distance(distance.begin(), distance_end));
}
template <typename T>
struct identity_xform {
using Location = cuspatial::vec_2d<T>;
__device__ Location operator()(Location const& loc) { return loc; };
};
// This test verifies that fancy iterators can be passed by using a pass-through transform_iterator
TYPED_TEST(HaversineTest, TransformIterator)
{
using T = TypeParam;
using Location = cuspatial::vec_2d<T>;
auto h_a_lonlat = std::vector<Location>({{-180, 0}, {180, 30}});
auto h_b_lonlat = std::vector<Location>({{180, 0}, {-180, 30}});
auto h_expected = std::vector<T>({1.5604449514735574e-12, 1.3513849691832763e-12});
auto a_lonlat = rmm::device_vector<Location>{h_a_lonlat};
auto b_lonlat = rmm::device_vector<Location>{h_b_lonlat};
auto distance = rmm::device_vector<T>{2, -1};
auto expected = rmm::device_vector<T>{h_expected};
auto xform_begin = thrust::make_transform_iterator(a_lonlat.begin(), identity_xform<T>{});
auto xform_end = thrust::make_transform_iterator(a_lonlat.end(), identity_xform<T>{});
auto distance_end =
cuspatial::haversine_distance(xform_begin, xform_end, b_lonlat.begin(), distance.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected, distance);
EXPECT_EQ(2, std::distance(distance.begin(), distance_end));
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/distance/polygon_distance_test.cpp | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cuspatial_test/column_factories.hpp>
#include <cuspatial_test/vector_equality.hpp>
#include <cuspatial/column/geometry_column_view.hpp>
#include <cuspatial/distance.hpp>
#include <cuspatial/error.hpp>
#include <cuspatial/geometry/vec_2d.hpp>
#include <cuspatial/types.hpp>
#include <cudf_test/column_utilities.hpp>
#include <cudf_test/column_wrapper.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <initializer_list>
#include <memory>
using namespace cuspatial;
using namespace cuspatial::test;
using namespace cudf;
using namespace cudf::test;
template <typename T>
struct PairwisePolygonDistanceTestBase : ::testing::Test {
void run_single(geometry_column_view lhs,
geometry_column_view rhs,
std::initializer_list<T> expected)
{
auto got = pairwise_polygon_distance(lhs, rhs);
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*got, fixed_width_column_wrapper<T>(expected));
}
rmm::cuda_stream_view stream() { return cudf::get_default_stream(); }
};
template <typename T>
struct PairwisePolygonDistanceTestEmpty : PairwisePolygonDistanceTestBase<T> {
void SetUp()
{
[[maybe_unused]] collection_type_id _;
std::tie(_, empty_polygon_column) = make_polygon_column<T>({0}, {0}, {}, this->stream());
std::tie(_, empty_multipolygon_column) =
make_polygon_column<T>({0}, {0}, {0}, {}, this->stream());
}
geometry_column_view empty_polygon()
{
return geometry_column_view(
empty_polygon_column->view(), collection_type_id::SINGLE, geometry_type_id::POLYGON);
}
geometry_column_view empty_multipolygon()
{
return geometry_column_view(
empty_multipolygon_column->view(), collection_type_id::MULTI, geometry_type_id::POLYGON);
}
std::unique_ptr<cudf::column> empty_polygon_column;
std::unique_ptr<cudf::column> empty_multipolygon_column;
};
using TestTypes = ::testing::Types<float, double>;
TYPED_TEST_CASE(PairwisePolygonDistanceTestEmpty, TestTypes);
struct PairwisePolygonDistanceTestUntyped : testing::Test {
rmm::cuda_stream_view stream() { return cudf::get_default_stream(); }
};
TYPED_TEST(PairwisePolygonDistanceTestEmpty, SingleToSingleEmpty)
{
CUSPATIAL_RUN_TEST(this->run_single, this->empty_polygon(), this->empty_polygon(), {});
};
TYPED_TEST(PairwisePolygonDistanceTestEmpty, SingleToMultiEmpty)
{
CUSPATIAL_RUN_TEST(this->run_single, this->empty_polygon(), this->empty_multipolygon(), {});
};
TYPED_TEST(PairwisePolygonDistanceTestEmpty, MultiToSingleEmpty)
{
CUSPATIAL_RUN_TEST(this->run_single, this->empty_multipolygon(), this->empty_polygon(), {});
};
TYPED_TEST(PairwisePolygonDistanceTestEmpty, MultiToMultiEmpty)
{
CUSPATIAL_RUN_TEST(this->run_single, this->empty_multipolygon(), this->empty_multipolygon(), {});
};
TEST_F(PairwisePolygonDistanceTestUntyped, SizeMismatch)
{
auto [ptype, polygons1] = make_polygon_column<float>(
{0, 1, 2}, {0, 4, 8}, {0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0}, this->stream());
auto [polytype, polygons2] =
make_polygon_column<float>({0, 1}, {0, 1}, {0, 4}, {1, 1, 1, 2, 2, 2, 1, 1}, this->stream());
auto polygons1_view =
geometry_column_view(polygons1->view(), ptype, geometry_type_id::LINESTRING);
auto polygons2_view =
geometry_column_view(polygons1->view(), polytype, geometry_type_id::POLYGON);
EXPECT_THROW(pairwise_polygon_distance(polygons1_view, polygons2_view), cuspatial::logic_error);
};
TEST_F(PairwisePolygonDistanceTestUntyped, TypeMismatch)
{
auto [ptype, polygons1] = make_polygon_column<double>(
{0, 1, 2}, {0, 4, 8}, {0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0}, this->stream());
auto [polytype, polygons2] =
make_polygon_column<float>({0, 1}, {0, 1}, {0, 4}, {1, 1, 1, 2, 2, 2, 1, 1}, this->stream());
auto polygons1_view =
geometry_column_view(polygons1->view(), ptype, geometry_type_id::LINESTRING);
auto polygons2_view =
geometry_column_view(polygons2->view(), polytype, geometry_type_id::POLYGON);
EXPECT_THROW(pairwise_polygon_distance(polygons1_view, polygons2_view), cuspatial::logic_error);
};
TEST_F(PairwisePolygonDistanceTestUntyped, WrongGeometryType)
{
auto [ptype, points] = make_point_column<float>({0, 1}, {0.0, 0.0}, this->stream());
auto [polytype, polygons] =
make_polygon_column<float>({0, 1}, {0, 1}, {0, 4}, {1, 1, 1, 2, 2, 2, 1, 1}, this->stream());
auto points_view = geometry_column_view(points->view(), ptype, geometry_type_id::POINT);
auto polygons_view = geometry_column_view(polygons->view(), polytype, geometry_type_id::POLYGON);
EXPECT_THROW(pairwise_polygon_distance(points_view, polygons_view), cuspatial::logic_error);
};
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/distance/hausdorff_test.cu | /*
* 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 <cuspatial_test/vector_equality.hpp>
#include <cuspatial/distance.cuh>
#include <cuspatial/error.hpp>
#include <cuspatial/geometry/vec_2d.hpp>
#include <rmm/device_vector.hpp>
#include <thrust/host_vector.h>
#include <thrust/iterator/constant_iterator.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/iterator/transform_iterator.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <iterator>
template <typename T>
struct HausdorffTest : public ::testing::Test {
template <typename Point, typename Index>
void test(std::vector<Point> const& points,
std::vector<Index> const& space_offsets,
std::vector<T> const& expected)
{
auto const d_points = rmm::device_vector<Point>{points};
auto const d_space_offsets = rmm::device_vector<Index>{space_offsets};
auto const num_distances = space_offsets.size() * space_offsets.size();
auto distances = rmm::device_vector<T>{num_distances};
auto const distances_end = cuspatial::directed_hausdorff_distance(d_points.begin(),
d_points.end(),
d_space_offsets.begin(),
d_space_offsets.end(),
distances.begin());
thrust::host_vector<T> h_distances(distances);
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(distances, expected);
EXPECT_EQ(num_distances, std::distance(distances.begin(), distances_end));
}
};
using TestTypes = ::testing::Types<float, double>;
TYPED_TEST_CASE(HausdorffTest, TestTypes);
TYPED_TEST(HausdorffTest, Empty)
{
CUSPATIAL_RUN_TEST((this->template test<cuspatial::vec_2d<TypeParam>, uint32_t>), {}, {}, {});
}
TYPED_TEST(HausdorffTest, Simple)
{
this->template test<cuspatial::vec_2d<TypeParam>, uint32_t>(
{{0, 0}, {1, 0}, {0, 1}, {0, 2}},
{{0, 2}},
{{0.0, 2.0, static_cast<TypeParam>(std::sqrt(2.0)), 0.0}});
}
TYPED_TEST(HausdorffTest, SingleTrajectorySinglePoint)
{
CUSPATIAL_RUN_TEST((this->template test<cuspatial::vec_2d<TypeParam>, uint32_t>),
{{152.2, 2351.0}},
{{0}},
{{0.0}});
}
TYPED_TEST(HausdorffTest, TwoShortSpaces)
{
this->template test<cuspatial::vec_2d<TypeParam>, uint32_t>(
{{0, 0}, {5, 12}, {4, 3}}, {{0, 1}}, {{0.0, 13.0, 5.0, 0.0}});
}
TYPED_TEST(HausdorffTest, TwoShortSpaces2)
{
CUSPATIAL_RUN_TEST((this->template test<cuspatial::vec_2d<TypeParam>, uint32_t>),
{{1, 1}, {5, 12}, {4, 3}, {2, 8}, {3, 4}, {7, 7}},
{{0, 3, 4}},
{{0.0,
5.0000000000000000,
5.0,
7.0710678118654755,
0.0,
5.0990195135927854,
5.3851648071345037,
4.1231056256176606,
0.0}});
}
TYPED_TEST(HausdorffTest, ThreeSpacesLengths543)
{
CUSPATIAL_RUN_TEST((this->template test<cuspatial::vec_2d<TypeParam>, uint32_t>),
{{0.0, 1.0},
{1.0, 2.0},
{2.0, 3.0},
{3.0, 5.0},
{1.0, 7.0},
{3.0, 0.0},
{5.0, 2.0},
{6.0, 3.0},
{5.0, 6.0},
{4.0, 1.0},
{7.0, 3.0},
{4.0, 6.0}},
{{0, 5, 9}},
{{0.0000000000000000,
3.6055512754639896,
4.4721359549995796,
4.1231056256176606,
0.0000000000000000,
1.4142135623730951,
4.0000000000000000,
1.4142135623730951,
0.0000000000000000}});
}
TYPED_TEST(HausdorffTest, MoreSpacesThanPoints)
{
EXPECT_THROW(
(this->template test<cuspatial::vec_2d<TypeParam>, uint32_t>({{0, 0}}, {{0, 1}}, {{0.0}})),
cuspatial::logic_error);
}
template <typename T, uint32_t num_spaces, uint32_t elements_per_space>
void generic_hausdorff_test()
{
constexpr uint64_t num_points =
static_cast<uint64_t>(elements_per_space) * static_cast<uint64_t>(num_spaces);
constexpr auto num_distances = num_spaces * num_spaces;
using vec_2d = cuspatial::vec_2d<T>;
auto zero_iter = thrust::make_constant_iterator<vec_2d>({0, 0});
auto counting_iter = thrust::make_counting_iterator<uint32_t>(0);
auto space_offset_iter = thrust::make_transform_iterator(
counting_iter, [] __device__(auto idx) { return idx * elements_per_space; });
auto distances = rmm::device_vector<T>{num_distances};
auto expected = rmm::device_vector<T>{num_distances, 0};
auto distances_end = cuspatial::directed_hausdorff_distance(zero_iter,
zero_iter + num_points,
space_offset_iter,
space_offset_iter + num_spaces,
distances.begin());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(distances, expected);
EXPECT_EQ(num_distances, std::distance(distances.begin(), distances_end));
}
TYPED_TEST(HausdorffTest, 500Spaces100Points) { generic_hausdorff_test<TypeParam, 500, 100>(); }
TYPED_TEST(HausdorffTest, 1000Spaces10Points) { generic_hausdorff_test<TypeParam, 1000, 10>(); }
TYPED_TEST(HausdorffTest, 10Spaces10000Points) { generic_hausdorff_test<TypeParam, 10, 10000>(); }
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/distance/point_polygon_distance_test.cpp | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cuspatial/column/geometry_column_view.hpp>
#include <cuspatial/distance.hpp>
#include <cuspatial/error.hpp>
#include <cuspatial/geometry/vec_2d.hpp>
#include <cuspatial/types.hpp>
#include <cuspatial_test/column_factories.hpp>
#include <cuspatial_test/vector_equality.hpp>
#include <cudf_test/column_utilities.hpp>
#include <cudf_test/column_wrapper.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <initializer_list>
using namespace cuspatial;
using namespace cuspatial::test;
using namespace cudf;
using namespace cudf::test;
template <typename T>
struct PairwisePointPolygonDistanceTest : public ::testing::Test {
rmm::cuda_stream_view stream() { return rmm::cuda_stream_default; }
void run_single(geometry_column_view points,
geometry_column_view polygons,
std::initializer_list<T> expected)
{
auto got = pairwise_point_polygon_distance(points, polygons);
CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(*got, fixed_width_column_wrapper<T>(expected));
}
};
struct PairwisePointPolygonDistanceTestUntyped : public ::testing::Test {
rmm::cuda_stream_view stream() { return rmm::cuda_stream_default; }
};
using TestTypes = ::testing::Types<float, double>;
TYPED_TEST_CASE(PairwisePointPolygonDistanceTest, TestTypes);
TYPED_TEST(PairwisePointPolygonDistanceTest, SingleToSingleEmpty)
{
using T = TypeParam;
auto [ptype, points] = make_point_column<T>(std::initializer_list<T>{}, this->stream());
auto [polytype, polygons] =
make_polygon_column<T>({0}, {0}, std::initializer_list<T>{}, this->stream());
CUSPATIAL_RUN_TEST(this->run_single,
geometry_column_view(points->view(), ptype, geometry_type_id::POINT),
geometry_column_view(polygons->view(), polytype, geometry_type_id::POLYGON),
{});
};
TYPED_TEST(PairwisePointPolygonDistanceTest, SingleToMultiEmpty)
{
using T = TypeParam;
auto [ptype, points] = make_point_column<T>(std::initializer_list<T>{}, this->stream());
auto [polytype, polygons] =
make_polygon_column<T>({0}, {0}, {0}, std::initializer_list<T>{}, this->stream());
CUSPATIAL_RUN_TEST(this->run_single,
geometry_column_view(points->view(), ptype, geometry_type_id::POINT),
geometry_column_view(polygons->view(), polytype, geometry_type_id::POLYGON),
{});
};
TYPED_TEST(PairwisePointPolygonDistanceTest, MultiToSingleEmpty)
{
using T = TypeParam;
auto [ptype, points] = make_point_column<T>({0}, std::initializer_list<T>{}, this->stream());
auto [polytype, polygons] =
make_polygon_column<T>({0}, {0}, std::initializer_list<T>{}, this->stream());
CUSPATIAL_RUN_TEST(this->run_single,
geometry_column_view(points->view(), ptype, geometry_type_id::POINT),
geometry_column_view(polygons->view(), polytype, geometry_type_id::POLYGON),
{});
};
TYPED_TEST(PairwisePointPolygonDistanceTest, MultiToMultiEmpty)
{
using T = TypeParam;
auto [ptype, points] = make_point_column<T>({0}, std::initializer_list<T>{}, this->stream());
auto [polytype, polygons] =
make_polygon_column<T>({0}, {0}, {0}, std::initializer_list<T>{}, this->stream());
CUSPATIAL_RUN_TEST(this->run_single,
geometry_column_view(points->view(), ptype, geometry_type_id::POINT),
geometry_column_view(polygons->view(), polytype, geometry_type_id::POLYGON),
{});
};
TYPED_TEST(PairwisePointPolygonDistanceTest, SingleToSingleOnePair)
{
using T = TypeParam;
auto [ptype, points] = make_point_column<T>({0.0, 0.0}, this->stream());
auto [polytype, polygons] =
make_polygon_column<T>({0, 1}, {0, 4}, {1, 1, 1, 2, 2, 2, 1, 1}, this->stream());
CUSPATIAL_RUN_TEST(this->run_single,
geometry_column_view(points->view(), ptype, geometry_type_id::POINT),
geometry_column_view(polygons->view(), polytype, geometry_type_id::POLYGON),
{1.4142135623730951});
};
TYPED_TEST(PairwisePointPolygonDistanceTest, SingleToMultiOnePair)
{
using T = TypeParam;
auto [ptype, points] = make_point_column<T>({0.0, 0.0}, this->stream());
auto [polytype, polygons] =
make_polygon_column<T>({0, 1}, {0, 1}, {0, 4}, {1, 1, 1, 2, 2, 2, 1, 1}, this->stream());
CUSPATIAL_RUN_TEST(this->run_single,
geometry_column_view(points->view(), ptype, geometry_type_id::POINT),
geometry_column_view(polygons->view(), polytype, geometry_type_id::POLYGON),
{1.4142135623730951});
};
TYPED_TEST(PairwisePointPolygonDistanceTest, MultiToSingleOnePair)
{
using T = TypeParam;
auto [ptype, points] = make_point_column<T>({0, 1}, {0.0, 0.0}, this->stream());
auto [polytype, polygons] =
make_polygon_column<T>({0, 1}, {0, 4}, {1, 1, 1, 2, 2, 2, 1, 1}, this->stream());
CUSPATIAL_RUN_TEST(this->run_single,
geometry_column_view(points->view(), ptype, geometry_type_id::POINT),
geometry_column_view(polygons->view(), polytype, geometry_type_id::POLYGON),
{1.4142135623730951});
};
TYPED_TEST(PairwisePointPolygonDistanceTest, MultiToMultiOnePair)
{
using T = TypeParam;
auto [ptype, points] = make_point_column<T>({0, 1}, {0.0, 0.0}, this->stream());
auto [polytype, polygons] =
make_polygon_column<T>({0, 1}, {0, 1}, {0, 4}, {1, 1, 1, 2, 2, 2, 1, 1}, this->stream());
CUSPATIAL_RUN_TEST(this->run_single,
geometry_column_view(points->view(), ptype, geometry_type_id::POINT),
geometry_column_view(polygons->view(), polytype, geometry_type_id::POLYGON),
{1.4142135623730951});
};
TEST_F(PairwisePointPolygonDistanceTestUntyped, SizeMismatch)
{
auto [ptype, points] = make_point_column<float>({0, 1, 2}, {0.0, 0.0, 1.0, 1.0}, this->stream());
auto [polytype, polygons] =
make_polygon_column<float>({0, 1}, {0, 1}, {0, 4}, {1, 1, 1, 2, 2, 2, 1, 1}, this->stream());
auto points_view = geometry_column_view(points->view(), ptype, geometry_type_id::POINT);
auto polygons_view = geometry_column_view(polygons->view(), polytype, geometry_type_id::POLYGON);
EXPECT_THROW(pairwise_point_polygon_distance(points_view, polygons_view), cuspatial::logic_error);
};
TEST_F(PairwisePointPolygonDistanceTestUntyped, TypeMismatch)
{
auto [ptype, points] = make_point_column<double>({0, 1}, {0.0, 0.0}, this->stream());
auto [polytype, polygons] =
make_polygon_column<float>({0, 1}, {0, 1}, {0, 4}, {1, 1, 1, 2, 2, 2, 1, 1}, this->stream());
auto points_view = geometry_column_view(points->view(), ptype, geometry_type_id::POINT);
auto polygons_view = geometry_column_view(polygons->view(), polytype, geometry_type_id::POLYGON);
EXPECT_THROW(pairwise_point_polygon_distance(points_view, polygons_view), cuspatial::logic_error);
};
TEST_F(PairwisePointPolygonDistanceTestUntyped, WrongGeometryType)
{
auto [ltype, lines] = make_linestring_column<double>({0, 1}, {0, 1}, {0.0, 0.0}, this->stream());
auto [polytype, polygons] =
make_polygon_column<float>({0, 1}, {0, 1}, {0, 4}, {1, 1, 1, 2, 2, 2, 1, 1}, this->stream());
auto lines_view = geometry_column_view(lines->view(), ltype, geometry_type_id::LINESTRING);
auto polygons_view = geometry_column_view(polygons->view(), polytype, geometry_type_id::POLYGON);
EXPECT_THROW(pairwise_point_polygon_distance(lines_view, polygons_view), cuspatial::logic_error);
};
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/distance/polygon_distance_test.cu | /*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cuspatial_test/base_fixture.hpp>
#include <cuspatial_test/vector_equality.hpp>
#include <cuspatial_test/vector_factories.cuh>
#include <cuspatial/distance.cuh>
#include <cuspatial/geometry/vec_2d.hpp>
#include <cuspatial/iterator_factory.cuh>
#include <cuspatial/range/range.cuh>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <rmm/mr/device/device_memory_resource.hpp>
#include <thrust/iterator/zip_iterator.h>
#include <initializer_list>
using namespace cuspatial;
using namespace cuspatial::test;
template <typename T>
struct PairwisePolygonDistanceTest : BaseFixture {
template <typename MultipolygonRangeA, typename MultipolygonRangeB>
void run_test(MultipolygonRangeA lhs,
MultipolygonRangeB rhs,
rmm::device_uvector<T> const& expected)
{
auto got = rmm::device_uvector<T>(lhs.size(), stream());
auto ret = pairwise_polygon_distance(lhs, rhs, got.begin(), stream());
CUSPATIAL_EXPECT_VECTORS_EQUIVALENT(expected, got);
EXPECT_EQ(thrust::distance(got.begin(), ret), expected.size());
}
void run(std::initializer_list<std::size_t> lhs_multipolygon_geometry_offsets,
std::initializer_list<std::size_t> lhs_multipolygon_part_offsets,
std::initializer_list<std::size_t> lhs_multipolygon_ring_offsets,
std::initializer_list<vec_2d<T>> lhs_multipolygon_coordinates,
std::initializer_list<std::size_t> rhs_multipolygon_geometry_offsets,
std::initializer_list<std::size_t> rhs_multipolygon_part_offsets,
std::initializer_list<std::size_t> rhs_multipolygon_ring_offsets,
std::initializer_list<vec_2d<T>> rhs_multipolygon_coordinates,
std::initializer_list<T> expected)
{
auto lhs = make_multipolygon_array(lhs_multipolygon_geometry_offsets,
lhs_multipolygon_part_offsets,
lhs_multipolygon_ring_offsets,
lhs_multipolygon_coordinates);
auto rhs = make_multipolygon_array(rhs_multipolygon_geometry_offsets,
rhs_multipolygon_part_offsets,
rhs_multipolygon_ring_offsets,
rhs_multipolygon_coordinates);
auto lhs_range = lhs.range();
auto rhs_range = rhs.range();
auto d_expected = make_device_uvector(expected, stream(), mr());
// Euclidean distance is symmetric
run_test(lhs_range, rhs_range, d_expected);
run_test(rhs_range, lhs_range, d_expected);
}
};
TYPED_TEST_CASE(PairwisePolygonDistanceTest, FloatingPointTypes);
TYPED_TEST(PairwisePolygonDistanceTest, Empty)
{
this->run({0}, {0}, {0}, {}, {0}, {0}, {0}, {}, {});
}
// Test Matrix
// One Pair:
// lhs-rhs Relationship: Disjoint, Touching, Overlapping, Contained, Within
// Holes: No, Yes
// Multipolygon: No, Yes
TYPED_TEST(PairwisePolygonDistanceTest, OnePairSinglePolygonDisjointNoHole)
{
this->run({0, 1},
{0, 1},
{0, 4},
{{0, 0}, {0, 1}, {1, 1}, {1, 0}},
{0, 1},
{0, 1},
{0, 4},
{{-1, 0}, {-1, 1}, {-2, 0}, {-1, 0}},
{1});
}
TYPED_TEST(PairwisePolygonDistanceTest, OnePairSinglePolygonTouchingNoHole)
{
this->run({0, 1},
{0, 1},
{0, 4},
{{0, 0}, {0, 1}, {1, 1}, {1, 0}},
{0, 1},
{0, 1},
{0, 4},
{{1, 0}, {2, 0}, {2, 1}, {1, 0}},
{0});
}
TYPED_TEST(PairwisePolygonDistanceTest, OnePairSinglePolygonOverlappingNoHole)
{
this->run({0, 1},
{0, 1},
{0, 4},
{{0, 0}, {0, 1}, {1, 1}, {1, 0}},
{0, 1},
{0, 1},
{0, 4},
{{0.5, 0}, {2, 0}, {2, 1}, {0.5, 0}},
{0});
}
TYPED_TEST(PairwisePolygonDistanceTest, OnePairSinglePolygonContainedNoHole)
{
this->run({0, 1},
{0, 1},
{0, 5},
{{0, 0}, {1, 0}, {1, 1}, {0, 1}, {0, 0}},
{0, 1},
{0, 1},
{0, 5},
{{0.25, 0.25}, {0.75, 0.25}, {0.75, 0.75}, {0.25, 0.75}, {0.25, 0.25}},
{0});
}
TYPED_TEST(PairwisePolygonDistanceTest, OnePairSinglePolygonWithinNoHole)
{
this->run({0, 1},
{0, 1},
{0, 5},
{{0.25, 0.25}, {0.75, 0.25}, {0.75, 0.75}, {0.25, 0.75}, {0.25, 0.25}},
{0, 1},
{0, 1},
{0, 5},
{{0, 0}, {1, 0}, {1, 1}, {0, 1}, {0, 0}},
{0});
}
TYPED_TEST(PairwisePolygonDistanceTest, OnePairSinglePolygonDisjointHasHole)
{
this->run({0, 1},
{0, 2},
{0, 4, 8},
{{0.0, 0.0},
{2.0, 0.0},
{2.0, 2.0},
{0.0, 0.0},
{1.0, 0.75},
{1.5, 0.75},
{1.25, 1.0},
{1.0, 0.75}},
{0, 1},
{0, 2},
{0, 4, 8},
{{-1.0, 0.0},
{-1.0, -1.0},
{-2.0, 0.0},
{-1.0, 0.0},
{-1.25, -0.25},
{-1.25, -0.5},
{-1.5, -0.25},
{-1.25, -0.25}},
{1});
}
TYPED_TEST(PairwisePolygonDistanceTest, OnePairSinglePolygonDisjointHasHole2)
{
this->run({0, 1},
{0, 2},
{0, 5, 10},
{{0.0, 0.0},
{10.0, 0.0},
{10.0, 10.0},
{0.0, 10.0},
{0.0, 0.0},
{2.0, 2.0},
{2.0, 6.0},
{6.0, 6.0},
{6.0, 2.0},
{2.0, 2.0}},
{0, 1},
{0, 1},
{0, 5},
{{3.0, 3.0}, {3.0, 4.0}, {4.0, 4.0}, {4.0, 3.0}, {3.0, 3.0}},
{1});
}
TYPED_TEST(PairwisePolygonDistanceTest, OnePairSinglePolygonTouchingHasHole)
{
this->run({0, 1},
{0, 2},
{0, 4, 8},
{{0.0, 0.0},
{2.0, 0.0},
{2.0, 2.0},
{0.0, 0.0},
{1.0, 0.75},
{1.5, 0.75},
{1.25, 1.0},
{1.0, 0.75}},
{0, 1},
{0, 2},
{0, 4, 8},
{{2.0, 0.0},
{3.0, 0.0},
{3.0, 1.0},
{2.0, 0.0},
{2.5, 0.25},
{2.75, 0.25},
{2.75, 0.5},
{2.5, 0.25}},
{0});
}
TYPED_TEST(PairwisePolygonDistanceTest, OnePairSinglePolygonOverlappingHasHole)
{
this->run({0, 1},
{0, 2},
{0, 5, 10},
{{0, 0}, {4, 0}, {4, 4}, {0, 4}, {0, 0}, {2, 2}, {2, 3}, {3, 3}, {3, 2}, {2, 2}},
{0, 1},
{0, 2},
{0, 4, 8},
{{2, -1}, {5, 4}, {5, -1}, {2, -1}, {3, -0.5}, {4, 0}, {4, -0.5}, {3, -0.5}},
{0});
}
TYPED_TEST(PairwisePolygonDistanceTest, OnePairSinglePolygonContainedHasHole)
{
this->run({0, 1},
{0, 2},
{0, 5, 10},
{{0, 0}, {4, 0}, {4, 4}, {0, 4}, {0, 0}, {1, 3}, {1, 1}, {3, 1}, {1, 3}, {1, 1}},
{0, 1},
{0, 1},
{0, 4},
{{1, 3}, {3, 1}, {3, 3}, {1, 3}},
{0});
}
TYPED_TEST(PairwisePolygonDistanceTest, OnePairSinglePolygonWithinHasHole)
{
this->run({0, 1},
{0, 1},
{0, 4},
{{1, 3}, {3, 1}, {3, 3}, {1, 3}},
{0, 1},
{0, 2},
{0, 5, 9},
{{0, 0}, {4, 0}, {4, 4}, {0, 4}, {0, 0}, {1, 1}, {3, 1}, {1, 3}, {1, 1}},
{0});
}
TYPED_TEST(PairwisePolygonDistanceTest, OnePairMultiPolygonDisjointNoHole)
{
this->run({0, 2},
{0, 1, 2},
{0, 4, 8},
{{0.0, 0.0},
{2.0, 0.0},
{2.0, 2.0},
{0.0, 0.0},
{3.0, 3.0},
{3.0, 4.0},
{4.0, 4.0},
{3.0, 3.0}},
{0, 1},
{0, 1},
{0, 4},
{{-1.0, 0.0}, {-1.0, -1.0}, {-2.0, 0.0}, {-1.0, 0.0}},
{1});
}
TYPED_TEST(PairwisePolygonDistanceTest, OnePairMultiPolygonTouchingNoHole)
{
this->run({0, 2},
{0, 1, 2},
{0, 4, 8},
{{0.0, 0.0},
{2.0, 0.0},
{2.0, 2.0},
{0.0, 0.0},
{3.0, 3.0},
{3.0, 4.0},
{4.0, 4.0},
{3.0, 3.0}},
{0, 1},
{0, 1},
{0, 4},
{{3.0, 3.0}, {2.0, 3.0}, {2.0, 2.0}, {3.0, 3.0}},
{0});
}
TYPED_TEST(PairwisePolygonDistanceTest, OnePairMultiPolygonOverlappingNoHole)
{
this->run({0, 2},
{0, 1, 2},
{0, 4, 8},
{{0.0, 0.0},
{2.0, 0.0},
{2.0, 2.0},
{0.0, 0.0},
{3.0, 3.0},
{3.0, 4.0},
{4.0, 4.0},
{3.0, 3.0}},
{0, 1},
{0, 1},
{0, 4},
{{1.0, 1.0}, {3.0, 1.0}, {3.0, 3.0}, {1.0, 1.0}},
{0});
}
TYPED_TEST(PairwisePolygonDistanceTest, OnePairMultiPolygonContainedNoHole)
{
this->run({0, 2},
{0, 1, 2},
{0, 4, 8},
{{0.0, 0.0},
{2.0, 0.0},
{2.0, 2.0},
{0.0, 0.0},
{1.0, 1.0},
{1.0, 2.0},
{2.0, 2.0},
{1.0, 1.0}},
{0, 1},
{0, 1},
{0, 4},
{{0.5, 0.25}, {1.5, 0.25}, {1.5, 1.25}, {0.5, 0.25}},
{0});
}
// Two Pair Tests
TYPED_TEST(PairwisePolygonDistanceTest, TwoPairSinglePolygonNoHole)
{
this->run({0, 1, 2},
{0, 1, 2},
{0, 4, 8},
{{0.0, 0.0},
{2.0, 0.0},
{2.0, 2.0},
{0.0, 0.0},
{3.0, 3.0},
{3.0, 4.0},
{4.0, 4.0},
{3.0, 3.0}},
{0, 1, 2},
{0, 1, 2},
{0, 4, 8},
{{3.0, 0.0},
{4.0, 0.0},
{4.0, 1.0},
{3.0, 0.0},
{3.0, 3.0},
{3.0, 2.0},
{2.0, 2.0},
{3.0, 3.0}},
{1, 0});
}
TYPED_TEST(PairwisePolygonDistanceTest, TwoPairSinglePolygonHasHole)
{
this->run({0, 1, 2},
{0, 1, 3},
{0, 4, 8, 12},
{{0.0, 0.0},
{2.0, 0.0},
{2.0, 2.0},
{0.0, 0.0},
{3.0, 3.0},
{3.0, 4.0},
{4.0, 4.0},
{3.0, 3.0},
{3.25, 3.5},
{3.5, 3.5},
{3.5, 3.75},
{3.25, 3.5}},
{0, 1, 2},
{0, 1, 2},
{0, 4, 8},
{{3.0, 0.0},
{4.0, 0.0},
{4.0, 1.0},
{3.0, 0.0},
{3.0, 3.0},
{3.0, 2.0},
{2.0, 2.0},
{3.0, 3.0}},
{1, 0});
}
TYPED_TEST(PairwisePolygonDistanceTest, TwoPairMultiPolygonNoHole)
{
this->run({0, 1, 3},
{0, 1, 2, 3},
{0, 4, 8, 12},
{{0.0, 0.0},
{2.0, 0.0},
{2.0, 2.0},
{0.0, 0.0},
{3.0, 3.0},
{3.0, 4.0},
{4.0, 4.0},
{3.0, 3.0},
{3.0, 3.0},
{5.0, 3.0},
{4.0, 2.0},
{3.0, 3.0}},
{0, 1, 2},
{0, 1, 2},
{0, 4, 8},
{{3.0, 0.0},
{4.0, 0.0},
{4.0, 1.0},
{3.0, 0.0},
{3.0, 3.0},
{3.0, 2.0},
{2.0, 2.0},
{3.0, 3.0}},
{1, 0});
}
TYPED_TEST(PairwisePolygonDistanceTest, TwoPairMultiPolygonHasHole)
{
this->run({0, 1, 3},
{0, 1, 2, 4},
{0, 4, 8, 12, 16},
{{0.0, 0.0},
{2.0, 0.0},
{2.0, 2.0},
{0.0, 0.0},
{3.0, 3.0},
{3.0, 4.0},
{4.0, 4.0},
{3.0, 3.0},
{3.0, 3.0},
{5.0, 3.0},
{4.0, 2.0},
{3.0, 3.0},
{3.5, 2.9},
{4.5, 2.9},
{4, 2.4},
{3.5, 2.9}},
{0, 1, 2},
{0, 1, 2},
{0, 4, 8},
{{3.0, 0.0},
{4.0, 0.0},
{4.0, 1.0},
{3.0, 0.0},
{3.0, 3.0},
{3.0, 2.0},
{2.0, 2.0},
{3.0, 3.0}},
{1, 0});
}
| 0 |
rapidsai_public_repos/cuspatial/cpp/tests | rapidsai_public_repos/cuspatial/cpp/tests/distance/hausdorff_test.cpp | /*
* Copyright (c) 2020-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cuspatial/distance.hpp>
#include <cuspatial/error.hpp>
#include <cudf/column/column_view.hpp>
#include <cudf_test/base_fixture.hpp>
#include <cudf_test/column_utilities.hpp>
#include <cudf_test/column_wrapper.hpp>
#include <cudf_test/cudf_gtest.hpp>
#include <cudf_test/table_utilities.hpp>
#include <cudf_test/type_lists.hpp>
#include <thrust/iterator/constant_iterator.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/iterator/transform_iterator.h>
#include <vector>
using namespace cudf;
using namespace test;
constexpr cudf::test::debug_output_level verbosity{cudf::test::debug_output_level::ALL_ERRORS};
template <typename T>
struct HausdorffTest : public BaseFixture {};
TYPED_TEST_CASE(HausdorffTest, cudf::test::FloatingPointTypes);
TYPED_TEST(HausdorffTest, Empty)
{
using T = TypeParam;
auto x = cudf::test::fixed_width_column_wrapper<T>({});
auto y = cudf::test::fixed_width_column_wrapper<T>({});
auto space_offsets = cudf::test::fixed_width_column_wrapper<uint32_t>({});
auto expected_col = cudf::test::fixed_width_column_wrapper<T>({});
auto expected_view = cudf::table_view{};
auto [actual_col, actual_view] =
cuspatial::directed_hausdorff_distance(x, y, space_offsets, this->mr());
expect_columns_equivalent(expected_col, actual_col->view(), verbosity);
CUDF_TEST_EXPECT_TABLES_EQUIVALENT(expected_view, actual_view);
}
TYPED_TEST(HausdorffTest, MoreSpacesThanPoints)
{
using T = TypeParam;
auto x = cudf::test::fixed_width_column_wrapper<T>({0});
auto y = cudf::test::fixed_width_column_wrapper<T>({0});
auto space_offsets = cudf::test::fixed_width_column_wrapper<uint32_t>({0, 1});
EXPECT_THROW(cuspatial::directed_hausdorff_distance(x, y, space_offsets, this->mr()),
cuspatial::logic_error);
}
| 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.