19#include <cuspatial/cuda_utils.hpp>
20#include <cuspatial/detail/range/enumerate_range.cuh>
22#include <cuspatial/traits.hpp>
25#include <rmm/cuda_stream_view.hpp>
27#include <thrust/pair.h>
60template <
typename GeometryIterator,
61 typename PartIterator,
62 typename RingIterator,
64class multipolygon_range {
66 using geometry_it_t = GeometryIterator;
67 using part_it_t = PartIterator;
68 using ring_it_t = RingIterator;
69 using point_it_t = VecIterator;
70 using point_t = iterator_value_type<VecIterator>;
72 using index_t = iterator_value_type<GeometryIterator>;
73 using element_t = iterator_vec_base_type<VecIterator>;
75 multipolygon_range(GeometryIterator geometry_begin,
76 GeometryIterator geometry_end,
77 PartIterator part_begin,
78 PartIterator part_end,
79 RingIterator ring_begin,
80 RingIterator ring_end,
81 VecIterator points_begin,
82 VecIterator points_end);
136 template <
typename IndexType>
140 template <
typename IndexType>
145 template <
typename IndexType>
149 template <
typename IndexType>
150 CUSPATIAL_HOST_DEVICE
auto operator[](IndexType multipolygon_idx);
167 auto _segments(rmm::cuda_stream_view);
179 GeometryIterator _geometry_begin;
180 GeometryIterator _geometry_end;
181 PartIterator _part_begin;
182 PartIterator _part_end;
183 RingIterator _ring_begin;
184 RingIterator _ring_end;
185 VecIterator _point_begin;
186 VecIterator _point_end;
189 template <
typename IndexType1,
typename IndexType2>
190 CUSPATIAL_HOST_DEVICE
bool is_valid_segment_id(IndexType1 segment_idx, IndexType2 ring_idx);
225template <
typename GeometryIteratorDiffType,
226 typename PartIteratorDiffType,
227 typename RingIteratorDiffType,
228 typename VecIteratorDiffType,
229 typename GeometryIterator,
230 typename PartIterator,
231 typename RingIterator,
232 typename VecIterator>
235 GeometryIterator geometry_begin,
236 PartIteratorDiffType num_polygons,
237 PartIterator part_begin,
238 RingIteratorDiffType num_rings,
239 RingIterator ring_begin,
240 VecIteratorDiffType num_points,
241 VecIterator point_begin)
245 thrust::next(geometry_begin, num_multipolygons + 1),
247 thrust::next(part_begin, num_polygons + 1),
249 thrust::next(ring_begin, num_rings + 1),
251 thrust::next(point_begin, num_points),
261template <collection_type_id Type,
264 typename GeometryColumnView,
265 CUSPATIAL_ENABLE_IF(Type == collection_type_id::SINGLE)>
270 auto geometry_iter = thrust::make_counting_iterator(0);
271 auto const& part_offsets = polygons_column.offsets();
272 auto const& ring_offsets = polygons_column.child().child(0);
273 auto const& points_xy =
274 polygons_column.child().child(1).child(1);
279 geometry_iter + part_offsets.size(),
280 part_offsets.template begin<IndexType>(),
281 part_offsets.template end<IndexType>(),
282 ring_offsets.template begin<IndexType>(),
283 ring_offsets.template end<IndexType>(),
285 points_it + points_xy.size() / 2);
294template <collection_type_id Type,
297 CUSPATIAL_ENABLE_IF(Type == collection_type_id::MULTI),
298 typename GeometryColumnView>
303 auto const& geometry_offsets = polygons_column.offsets();
304 auto const& part_offsets = polygons_column.child().child(0);
305 auto const& ring_offsets = polygons_column.child().child(1).child(0);
306 auto const& points_xy =
307 polygons_column.child().child(1).child(1).child(1);
311 return multipolygon_range(geometry_offsets.template begin<IndexType>(),
312 geometry_offsets.template end<IndexType>(),
313 part_offsets.template begin<IndexType>(),
314 part_offsets.template end<IndexType>(),
315 ring_offsets.template begin<IndexType>(),
316 ring_offsets.template end<IndexType>(),
318 points_it + points_xy.size() / 2);
327#include <cuspatial/detail/range/multipolygon_range.cuh>
CUSPATIAL_HOST_DEVICE auto num_points()
返回数组中点的总数。
CUSPATIAL_HOST_DEVICE auto multipolygon_point_count_end()
CUSPATIAL_HOST_DEVICE auto multipolygon_end()
返回范围中最后一个多边形之后一个位置的迭代器。
CUSPATIAL_HOST_DEVICE auto ring_idx_from_point_idx(IndexType point_idx)
给定点的索引,返回包含该点的环的索引。
CUSPATIAL_HOST_DEVICE auto ring_offset_begin()
返回范围中第一个环偏移量的迭代器。
CUSPATIAL_HOST_DEVICE auto geometry_offset_begin()
返回范围中第一个几何偏移量的迭代器。
CUSPATIAL_HOST_DEVICE auto point_end()
返回范围中最后一个点之后一个位置的迭代器。
CUSPATIAL_HOST_DEVICE auto part_offset_end()
返回范围中最后一个部分偏移量之后一个位置的迭代器。
CUSPATIAL_HOST_DEVICE auto multipolygon_begin()
返回范围中第一个多边形的迭代器。
CUSPATIAL_HOST_DEVICE auto operator[](IndexType multipolygon_idx)
返回范围中索引为 multipolygon_idx 的多边形。
CUSPATIAL_HOST_DEVICE auto num_polygons()
返回数组中多边形的总数。
CUSPATIAL_HOST_DEVICE auto num_rings()
返回数组中环的总数。
CUSPATIAL_HOST_DEVICE auto point_begin()
返回范围中第一个点的迭代器。
CUSPATIAL_HOST_DEVICE auto part_idx_from_ring_idx(IndexType ring_idx)
给定环的索引,返回包含该环的部分(多边形)的索引。
CUSPATIAL_HOST_DEVICE auto num_multipolygons()
返回数组中多边形的数量。
CUSPATIAL_HOST_DEVICE auto size()
返回数组中多边形的数量。
CUSPATIAL_HOST_DEVICE auto begin()
返回范围中第一个多边形的迭代器。
CUSPATIAL_HOST_DEVICE auto geometry_offset_end()
返回范围中最后一个几何偏移量之后一个位置的迭代器。
CUSPATIAL_HOST_DEVICE auto end()
返回范围中最后一个多边形之后一个位置的迭代器。
CUSPATIAL_HOST_DEVICE auto multipolygon_point_count_begin()
CUSPATIAL_HOST_DEVICE auto part_offset_begin()
返回范围中第一个部分偏移量的迭代器。
CUSPATIAL_HOST_DEVICE auto ring_offset_end()
返回范围中最后一个环偏移量之后一个位置的迭代器。
CUSPATIAL_HOST_DEVICE auto as_multipoint_range()
范围转换。
CUSPATIAL_HOST_DEVICE auto multipolygon_ring_count_end()
返回指向最后一个多边形环数量之后一个位置的迭代器。
CUSPATIAL_HOST_DEVICE auto as_multilinestring_range()
将多边形范围转换为多线串范围,忽略环的关系。
CUSPATIAL_HOST_DEVICE auto geometry_idx_from_part_idx(IndexType part_idx)
CUSPATIAL_HOST_DEVICE auto multipolygon_ring_count_begin()
返回指向第一个多边形环数量的迭代器。
#define CUSPATIAL_EXPECTS(cond, reason)
用于检查(前置)条件的宏,当条件不满足时抛出异常。
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)
从大小和起始迭代器创建一个 multipolygon_range 对象。
auto make_vec_2d_iterator(FirstIter first, SecondIter second)
从两个输入迭代器创建一个指向 vec_2d 数据的迭代器。