19#include <cuspatial/cuda_utils.hpp>
20#include <cuspatial/detail/range/enumerate_range.cuh>
23#include <cuspatial/traits.hpp>
26#include <rmm/cuda_stream_view.hpp>
28#include <thrust/pair.h>
58template <
typename GeometryIterator,
typename PartIterator,
typename VecIterator>
61 using geometry_it_t = GeometryIterator;
62 using part_it_t = PartIterator;
63 using point_it_t = VecIterator;
64 using point_t = iterator_value_type<VecIterator>;
65 using element_t = iterator_vec_base_type<VecIterator>;
68 GeometryIterator geometry_end,
69 PartIterator part_begin,
70 PartIterator part_end,
71 VecIterator points_begin,
72 VecIterator points_end);
99 CUSPATIAL_HOST_DEVICE
auto point_begin() {
return _point_begin; }
102 CUSPATIAL_HOST_DEVICE
auto point_end() {
return _point_end; }
117 template <
typename IndexType>
122 template <
typename IndexType>
123 CUSPATIAL_HOST_DEVICE
124 thrust::optional<typename thrust::iterator_traits<PartIterator>::difference_type>
129 template <
typename IndexType>
134 template <
typename IndexType>
138 template <
typename IndexType>
139 CUSPATIAL_HOST_DEVICE
auto intra_part_idx(IndexType global_part_idx);
142 template <
typename IndexType>
143 CUSPATIAL_HOST_DEVICE
auto intra_point_idx(IndexType global_point_idx);
148 template <
typename IndexType1,
typename IndexType2>
152 template <
typename IndexType>
153 CUSPATIAL_HOST_DEVICE
auto segment(IndexType segment_idx);
170 auto _segments(rmm::cuda_stream_view);
173 template <
typename IndexType>
174 CUSPATIAL_HOST_DEVICE
auto operator[](IndexType multilinestring_idx);
184 GeometryIterator _geometry_begin;
185 GeometryIterator _geometry_end;
186 PartIterator _part_begin;
187 PartIterator _part_end;
188 VecIterator _point_begin;
189 VecIterator _point_end;
194 template <
typename IndexType>
195 CUSPATIAL_HOST_DEVICE
auto _part_iter_from_point_idx(IndexType point_idx);
198 template <
typename IndexType>
199 CUSPATIAL_HOST_DEVICE
auto _geometry_iter_from_part_idx(IndexType part_idx);
229template <
typename GeometryIteratorDiffType,
230 typename PartIteratorDiffType,
231 typename VecIteratorDiffType,
232 typename GeometryIterator,
233 typename PartIterator,
234 typename VecIterator>
236 GeometryIterator geometry_begin,
237 PartIteratorDiffType num_linestrings,
238 PartIterator part_begin,
239 VecIteratorDiffType num_points,
240 VecIterator point_begin)
243 geometry_begin + num_multilinestrings + 1,
245 part_begin + num_linestrings + 1,
247 point_begin + num_points};
262template <
typename IntegerRange1,
typename IntegerRange2,
typename Po
intRange>
264 IntegerRange2 part_offsets,
268 geometry_offsets.end(),
269 part_offsets.begin(),
281template <collection_type_id Type,
284 typename GeometryColumnView,
285 CUSPATIAL_ENABLE_IF(Type == collection_type_id::SINGLE)>
288 CUSPATIAL_EXPECTS(linestrings_column.geometry_type() == geometry_type_id::LINESTRING,
289 "Must be Linestring geometry type.");
290 auto geometry_iter = thrust::make_counting_iterator(0);
291 auto const& part_offsets = linestrings_column.offsets();
292 auto const& points_xy = linestrings_column.child().child(1);
297 geometry_iter + part_offsets.size(),
298 part_offsets.template begin<IndexType>(),
299 part_offsets.template end<IndexType>(),
301 points_it + points_xy.size() / 2);
310template <collection_type_id Type,
313 CUSPATIAL_ENABLE_IF(Type == collection_type_id::MULTI),
314 typename GeometryColumnView>
315auto make_multilinestring_range(GeometryColumnView
const& linestrings_column)
317 CUSPATIAL_EXPECTS(linestrings_column.geometry_type() == geometry_type_id::LINESTRING,
318 "Must be Linestring geometry type.");
319 auto const& geometry_offsets = linestrings_column.offsets();
320 auto const& parts = linestrings_column.child();
321 auto const& part_offsets = parts.child(0);
322 auto const& points_xy = parts.child(1).child(1);
326 return multilinestring_range(geometry_offsets.template begin<IndexType>(),
327 geometry_offsets.template end<IndexType>(),
328 part_offsets.template begin<IndexType>(),
329 part_offsets.template end<IndexType>(),
331 points_it + points_xy.size() / 2);
340#include <cuspatial/detail/range/multilinestring_range.cuh>
Non-owning range-based interface to multilinestring data.
CUSPATIAL_HOST_DEVICE auto multilinestring_point_count_begin()
Returns an iterator to the counts of points per multilinestring.
CUSPATIAL_HOST_DEVICE auto end()
Return the iterator to the one past the last multilinestring in the range.
CUSPATIAL_HOST_DEVICE auto multilinestring_linestring_count_end()
Returns an iterator to the counts of points per multilinestring.
CUSPATIAL_HOST_DEVICE auto size()
Return the number of multilinestrings in the array.
CUSPATIAL_HOST_DEVICE auto part_offset_end()
Return the iterator to the one past the last part offset in the range.
CUSPATIAL_HOST_DEVICE auto multilinestring_end()
Return the iterator to the one past the last multilinestring in the range.
CUSPATIAL_HOST_DEVICE auto geometry_idx_from_point_idx(IndexType point_idx)
CUSPATIAL_HOST_DEVICE auto part_idx_from_point_idx(IndexType point_idx)
Given the index of a point, return the part (linestring) index where the point locates.
CUSPATIAL_HOST_DEVICE bool is_valid_segment_id(IndexType1 segment_idx, IndexType2 part_idx)
CUSPATIAL_HOST_DEVICE auto geometry_offset_end()
Return the iterator to the one past the last geometry offset in the range.
CUSPATIAL_HOST_DEVICE auto multilinestring_linestring_count_begin()
Returns an iterator to the counts of points per multilinestring.
CUSPATIAL_HOST_DEVICE auto segment(IndexType segment_idx)
Returns the segment given a segment index.
CUSPATIAL_HOST_DEVICE thrust::optional< typename thrust::iterator_traits< PartIterator >::difference_type > part_idx_from_segment_idx(IndexType point_idx)
CUSPATIAL_HOST_DEVICE auto point_end()
Return the iterator to the one past the last point in the range.
CUSPATIAL_HOST_DEVICE auto num_multilinestrings()
Return the number of multilinestrings in the array.
CUSPATIAL_HOST_DEVICE auto multilinestring_point_count_end()
Returns an iterator to the counts of segments per multilinestring.
CUSPATIAL_HOST_DEVICE auto geometry_idx_from_part_idx(IndexType part_idx)
CUSPATIAL_HOST_DEVICE auto geometry_offset_begin()
Return the iterator to the first geometry offset in the range.
CUSPATIAL_HOST_DEVICE auto as_multipoint_range()
Range Casts.
CUSPATIAL_HOST_DEVICE auto point_begin()
Return the iterator to the first point in the range.
CUSPATIAL_HOST_DEVICE auto operator[](IndexType multilinestring_idx)
Returns the multilinestring_idxth multilinestring in the range.
CUSPATIAL_HOST_DEVICE auto num_points()
Return the total number of points in the array.
CUSPATIAL_HOST_DEVICE auto multilinestring_begin()
Return the iterator to the first multilinestring in the range.
CUSPATIAL_HOST_DEVICE auto num_linestrings()
Return the total number of linestrings in the array.
CUSPATIAL_HOST_DEVICE auto begin()
Return the iterator to the first multilinestring in the range.
CUSPATIAL_HOST_DEVICE auto part_offset_begin()
Return the iterator to the first part offset in the range.
#define CUSPATIAL_EXPECTS(cond, reason)
Macro for checking (pre-)conditions that throws an exception when a condition is violated.
auto make_vec_2d_iterator(FirstIter first, SecondIter second)
Create an iterator to vec_2d data from two input iterators.
auto make_multilinestring_range(GeometryIteratorDiffType num_multilinestrings, GeometryIterator geometry_begin, PartIteratorDiffType num_linestrings, PartIterator part_begin, VecIteratorDiffType num_points, VecIterator point_begin)
Create a multilinestring_range object from size and start iterators.