19#include <cuspatial/cuda_utils.hpp>
20#include <cuspatial/traits.hpp>
23#include <thrust/iterator/counting_iterator.h>
52template <
typename GeometryIterator,
typename VecIterator>
55 using geometry_it_t = GeometryIterator;
56 using point_it_t = VecIterator;
57 using index_t = iterator_value_type<geometry_it_t>;
58 using point_t = iterator_value_type<point_it_t>;
59 using element_t = iterator_vec_base_type<point_it_t>;
65 GeometryIterator geometry_end,
66 VecIterator points_begin,
67 VecIterator points_end);
127 template <
typename IndexType>
137 template <
typename IndexType>
147 template <
typename IndexType>
148 CUSPATIAL_HOST_DEVICE
auto point(IndexType idx);
188template <
typename GeometryIteratorDiffType,
189 typename VecIteratorDiffType,
190 typename GeometryIterator,
191 typename VecIterator>
193 GeometryIteratorDiffType num_multipoints,
194 GeometryIterator geometry_begin,
195 VecIteratorDiffType num_points,
196 VecIterator point_begin)
198 return multipoint_range<GeometryIterator, VecIterator>{
199 geometry_begin, geometry_begin + num_multipoints + 1, point_begin, point_begin + num_points};
212template <
typename IntegerRange,
typename Po
intRange>
216 geometry_offsets.begin(), geometry_offsets.end(), points.begin(), points.end());
225template <collection_type_id Type,
228 CUSPATIAL_ENABLE_IF(Type == collection_type_id::SINGLE),
229 typename GeometryColumnView>
233 "Must be POINT geometry type.");
234 auto geometry_iter = thrust::make_counting_iterator(0);
235 auto const& points_xy = points_column.child();
240 thrust::next(geometry_iter, points_column.size() + 1),
242 points_it + points_xy.size() / 2);
251template <collection_type_id Type,
254 CUSPATIAL_ENABLE_IF(Type == collection_type_id::MULTI),
255 typename GeometryColumnView>
259 "Must be POINT geometry type.");
260 auto const& geometry_offsets = points_column.offsets();
261 auto const& points_xy = points_column.child().child(1);
265 return multipoint_range(geometry_offsets.template begin<IndexType>(),
266 geometry_offsets.template end<IndexType>(),
268 points_it + points_xy.size() / 2);
277#include <cuspatial/detail/range/multipoint_range.cuh>
Non-owning range-based interface to multipoint data.
CUSPATIAL_HOST_DEVICE auto point(IndexType idx)
Returns the idxth point in the array.
CUSPATIAL_HOST_DEVICE auto multipoint_end()
Returns the iterator past the last multipoint in the multipoint array.
CUSPATIAL_HOST_DEVICE auto num_multipoints()
Returns the number of multipoints in the array.
CUSPATIAL_HOST_DEVICE auto size()
Returns the number of multipoints in the array.
CUSPATIAL_HOST_DEVICE auto end()
Returns the iterator past the last multipoint in the multipoint array.
GeometryIterator _geometry_begin
Iterator to the start of the index array of start positions to each multipoint.
CUSPATIAL_HOST_DEVICE auto multipoint_begin()
Returns the iterator to the first multipoint in the multipoint array.
CUSPATIAL_HOST_DEVICE auto point_end()
Returns the iterator to the end of the underlying point array.
CUSPATIAL_HOST_DEVICE auto point_begin()
Returns the iterator to the start of the underlying point array.
CUSPATIAL_HOST_DEVICE auto begin()
Returns the iterator to the start of the multipoint array.
VecIterator _points_end
Iterator to the past-the-end position of the point array.
CUSPATIAL_HOST_DEVICE auto geometry_idx_from_point_idx(IndexType point_idx) const
Returns the geometry index of the given point index.
VecIterator _points_begin
Iterator to the start of the point array.
CUSPATIAL_HOST_DEVICE multipoint_range(GeometryIterator geometry_begin, GeometryIterator geometry_end, VecIterator points_begin, VecIterator points_end)
Construct a new multipoint array object.
CUSPATIAL_HOST_DEVICE auto offsets_begin()
Returns the iterator to the start of the underlying offsets array.
CUSPATIAL_HOST_DEVICE bool is_single_point_range()
Returns true if the range contains only single points Undefined behavior if the range is an empty ran...
CUSPATIAL_HOST_DEVICE auto offsets_end()
Returns the iterator to the end of the underlying offsets array.
CUSPATIAL_HOST_DEVICE auto num_points()
Returns the number of points in the array.
GeometryIterator _geometry_end
Iterator to the past-the-end of the index array of start positions to each multipoint.
CUSPATIAL_HOST_DEVICE auto operator[](IndexType idx)
Returns the idxth multipoint in the array.
#define CUSPATIAL_EXPECTS(cond, reason)
Macro for checking (pre-)conditions that throws an exception when a condition is violated.
multipoint_range< GeometryIterator, VecIterator > make_multipoint_range(GeometryIteratorDiffType num_multipoints, GeometryIterator geometry_begin, VecIteratorDiffType num_points, VecIterator point_begin)
Create a multipoint_range object of from size and start iterators.
auto make_vec_2d_iterator(FirstIter first, SecondIter second)
Create an iterator to vec_2d data from two input iterators.