1 // Boost.Geometry (aka GGL, Generic Geometry Library)
4 // Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
6 // Copyright (c) 2014-2021, Oracle and/or its affiliates.
7 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
8 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
10 // Licensed under the Boost Software License version 1.0.
11 // http://www.boost.org/users/license.html
14 #ifndef BOOST_TEST_MODULE
15 #define BOOST_TEST_MODULE test_point_iterator
24 #include <boost/test/included/unit_test.hpp>
26 #include <boost/concept_check.hpp>
27 #include <boost/core/ignore_unused.hpp>
28 #include <boost/iterator/iterator_concepts.hpp>
29 #include <boost/tuple/tuple.hpp>
30 #include <boost/optional.hpp>
32 #include <boost/geometry/algorithms/equals.hpp>
33 #include <boost/geometry/algorithms/make.hpp>
34 #include <boost/geometry/algorithms/num_points.hpp>
36 #include <boost/geometry/core/point_type.hpp>
38 #include <boost/geometry/geometries/geometries.hpp>
39 #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
40 #include <boost/geometry/geometries/register/linestring.hpp>
41 #include <boost/geometry/geometries/register/multi_point.hpp>
43 #include <boost/geometry/io/wkt/wkt.hpp>
44 #include <boost/geometry/io/dsv/write.hpp>
46 #include <boost/geometry/iterators/point_iterator.hpp>
47 #include <boost/geometry/iterators/point_reverse_iterator.hpp>
49 #include <boost/geometry/policies/compare.hpp>
51 #include <boost/geometry/strategies/strategies.hpp>
53 #include <boost/geometry/util/condition.hpp>
55 #include <test_common/with_pointer.hpp>
56 #include <test_geometries/copy_on_dereference_geometries.hpp>
59 namespace bg
= ::boost::geometry
;
61 typedef bg::model::point
<double, 2, bg::cs::cartesian
> point_type
;
62 typedef bg::model::point
<double, 3, bg::cs::cartesian
> point_type_3d
;
63 typedef bg::model::linestring
<point_type
> linestring_type
;
64 typedef bg::model::polygon
<point_type
, false, false> polygon_type
; //ccw, open
67 typedef bg::model::multi_point
<point_type
> multi_point_type
;
68 typedef bg::model::multi_point
<point_type_3d
> multi_point_type_3d
;
69 typedef bg::model::multi_linestring
<linestring_type
> multi_linestring_type
;
70 typedef bg::model::multi_polygon
<polygon_type
> multi_polygon_type
;
72 typedef boost::tuple
<double, double> tuple_point_type
;
73 typedef boost::tuple
<double, double, double> tuple_point_type_3d
;
74 typedef std::vector
<tuple_point_type
> tuple_multi_point_type
;
75 typedef std::vector
<tuple_point_type_3d
> tuple_multi_point_type_3d
;
78 struct vector_as_multipoint
: std::vector
<T
> {};
81 struct vector_as_linestring
: std::vector
<T
> {};
83 BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian
)
84 BOOST_GEOMETRY_REGISTER_MULTI_POINT(tuple_multi_point_type
)
85 BOOST_GEOMETRY_REGISTER_MULTI_POINT(tuple_multi_point_type_3d
)
87 BOOST_GEOMETRY_REGISTER_MULTI_POINT_TEMPLATED(vector_as_multipoint
)
88 BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(vector_as_linestring
)
92 template <typename Geometry
>
93 inline Geometry
from_wkt(std::string
const& wkt
)
96 bg::read_wkt(wkt
, geometry
);
101 // this function is implemented because std::max_element() requires ForwardIterator
102 // but bg::point_iterator<> is InputIterator since it returns non-true reference
103 template <typename InputIt
, typename Pred
>
104 inline boost::optional
<typename
std::iterator_traits
<InputIt
>::value_type
>
105 max_value(InputIt first
, InputIt last
, Pred pred
)
107 typedef typename
std::iterator_traits
<InputIt
>::value_type value_type
;
110 value_type found
= *first
++;
111 for (; first
!= last
; )
113 value_type current
= *first
++;
114 if (pred(current
, found
))
123 template <typename Iterator
>
124 inline std::ostream
& print_point_range(std::ostream
& os
,
127 std::string
const& header
)
130 for (Iterator it
= first
; it
!= beyond
; ++it
)
132 os
<< " " << bg::dsv(*it
);
143 bool IsConst
= std::is_const
<Geometry
>::value
145 struct test_iterator_concepts
147 typedef bg::point_iterator
<Geometry
> iterator
;
148 BOOST_CONCEPT_ASSERT((boost::BidirectionalIteratorConcept
<iterator
>));
149 BOOST_CONCEPT_ASSERT((boost_concepts::ReadableIteratorConcept
<iterator
>));
150 BOOST_CONCEPT_ASSERT((boost_concepts::LvalueIteratorConcept
<iterator
>));
152 ((boost_concepts::BidirectionalTraversalConcept
<iterator
>));
155 template <typename Geometry
>
156 struct test_iterator_concepts
<Geometry
, true, false>
157 : test_iterator_concepts
<Geometry
, true, true>
159 typedef bg::point_iterator
<Geometry
> iterator
;
161 ((boost::Mutable_BidirectionalIteratorConcept
<iterator
>));
163 ((boost_concepts::WritableIteratorConcept
<iterator
>));
165 ((boost_concepts::SwappableIteratorConcept
<iterator
>));
168 template <typename Geometry
, bool IsConst
>
169 struct test_iterator_concepts
<Geometry
, false, IsConst
>
176 template <typename Iterator
>
177 static inline std::size_t number_of_elements(Iterator begin
,
180 std::size_t size
= std::distance(begin
, end
);
182 std::size_t num_elems(0);
183 for (Iterator it
= begin
; it
!= end
; ++it
)
187 BOOST_CHECK(size
== num_elems
);
190 for (Iterator it
= end
; it
!= begin
; --it
)
194 BOOST_CHECK(size
== num_elems
);
199 template <typename Iterator1
, typename Iterator2
>
200 static inline bool apply(Iterator1 begin1
, Iterator1 end1
,
201 Iterator2 begin2
, Iterator2 end2
)
203 std::size_t num_points1
= number_of_elements(begin1
, end1
);
204 std::size_t num_points2
= number_of_elements(begin2
, end2
);
206 if (num_points1
!= num_points2
)
211 Iterator1 it1
= begin1
;
212 Iterator2 it2
= begin2
;
213 for (; it1
!= end1
; ++it1
, ++it2
)
215 if (! bg::equals(*it1
, *it2
))
225 template <bool Enable
= true>
226 struct test_assignment
228 template <typename Iterator
, typename ConstIterator
, typename Value
>
229 static inline void apply(Iterator it
, ConstIterator cit
,
230 Value
const& value1
, Value
const& value2
)
232 #ifdef BOOST_GEOMETRY_TEST_DEBUG
233 std::cout
<< "== before assignment ==" << std::endl
;
234 std::cout
<< "value1: " << bg::wkt(value1
) << std::endl
;
235 std::cout
<< "value2: " << bg::wkt(value2
) << std::endl
;
236 std::cout
<< "*it : " << bg::wkt(*it
) << std::endl
;
237 std::cout
<< "*cit : " << bg::wkt(*cit
) << std::endl
;
240 BOOST_CHECK(bg::equals(*it
, value1
));
241 BOOST_CHECK(! bg::equals(*it
, value2
));
242 BOOST_CHECK(bg::equals(*cit
, value1
));
243 BOOST_CHECK(! bg::equals(*cit
, value2
));
246 BOOST_CHECK(bg::equals(*it
, value2
));
247 BOOST_CHECK(! bg::equals(*it
, value1
));
248 BOOST_CHECK(bg::equals(*cit
, value2
));
249 BOOST_CHECK(! bg::equals(*cit
, value1
));
251 #ifdef BOOST_GEOMETRY_TEST_DEBUG
252 std::cout
<< "== after 1st assignment ==" << std::endl
;
253 std::cout
<< "value1: " << bg::wkt(value1
) << std::endl
;
254 std::cout
<< "value2: " << bg::wkt(value2
) << std::endl
;
255 std::cout
<< "*it : " << bg::wkt(*it
) << std::endl
;
256 std::cout
<< "*cit : " << bg::wkt(*cit
) << std::endl
;
260 BOOST_CHECK(bg::equals(*it
, value1
));
261 BOOST_CHECK(! bg::equals(*it
, value2
));
262 BOOST_CHECK(bg::equals(*cit
, value1
));
263 BOOST_CHECK(! bg::equals(*cit
, value2
));
265 #ifdef BOOST_GEOMETRY_TEST_DEBUG
266 std::cout
<< "== after 2nd assignment ==" << std::endl
;
267 std::cout
<< "value1: " << bg::wkt(value1
) << std::endl
;
268 std::cout
<< "value2: " << bg::wkt(value2
) << std::endl
;
269 std::cout
<< "*it : " << bg::wkt(*it
) << std::endl
;
270 std::cout
<< "*cit : " << bg::wkt(*cit
) << std::endl
;
271 std::cout
<< std::endl
;
277 struct test_assignment
<false>
279 template <typename Iterator
, typename ConstIterator
, typename Value
>
280 static inline void apply(Iterator
, ConstIterator
,
281 Value
const&, Value
const&)
291 bool EnableConceptChecks
= true
293 struct test_point_iterator_of_geometry
295 typedef typename
bg::point_type
<Geometry
>::type point_type
;
297 template <typename G
>
298 static inline void base_test(G
& geometry
,
299 PointRange
const& point_range
,
300 std::string
const& header
)
302 typedef bg::point_iterator
<G
> point_iterator
;
304 test_iterator_concepts
<G
, EnableConceptChecks
>();
306 point_iterator begin
= bg::points_begin(geometry
);
307 point_iterator end
= bg::points_end(geometry
);
309 BOOST_CHECK(std::size_t(std::distance(begin
, end
))
311 bg::num_points(geometry
));
313 BOOST_CHECK(equals::apply(begin
, end
,
314 bg::points_begin(point_range
),
315 bg::points_end(point_range
))
318 boost::ignore_unused(header
);
320 #ifdef BOOST_GEOMETRY_TEST_DEBUG
321 std::cout
<< header
<< " geometry: " << bg::wkt(geometry
) << std::endl
;
322 print_point_range(std::cout
, begin
, end
, "point range: ");
323 std::cout
<< std::endl
;
325 typedef bg::point_iterator
<PointRange
const> point_range_iterator
;
327 print_point_range(std::cout
,
328 bg::points_begin(point_range
),
329 bg::points_end(point_range
),
330 "expected point range: ");
331 std::cout
<< std::endl
;
335 template <typename G
, bool Enable
>
338 template <typename Iterator
>
339 static inline void apply(Iterator first
, Iterator last
,
342 boost::ignore_unused(geometry
);
344 std::reverse(first
, last
);
345 #ifdef BOOST_GEOMETRY_TEST_DEBUG
346 print_point_range(std::cout
, first
, last
, "reversed:\n")
348 std::cout
<< bg::wkt(geometry
) << std::endl
;
349 std::cout
<< std::endl
;
352 std::reverse(first
, last
);
353 #ifdef BOOST_GEOMETRY_TEST_DEBUG
354 print_point_range(std::cout
, first
, last
, "re-reversed:\n")
356 std::cout
<< bg::wkt(geometry
) << std::endl
;
357 std::cout
<< std::endl
;
358 std::cout
<< std::endl
;
363 template <typename G
>
364 struct test_reverse
<G
, false>
366 template <typename Iterator
>
367 static inline void apply(Iterator
, Iterator
, G
const&)
372 static inline void apply(Geometry geometry
,
373 PointRange
const& point_range
,
374 point_type
const& zero_point
)
376 base_test
<Geometry
>(geometry
, point_range
, "non-const");
378 #ifdef BOOST_GEOMETRY_TEST_DEBUG
379 std::cout
<< std::endl
;
382 base_test
<Geometry
const>(geometry
, point_range
, "const");
384 #ifdef BOOST_GEOMETRY_TEST_DEBUG
385 std::cout
<< std::endl
<< std::endl
;
388 // testing construction of const and non-const iterator
389 typedef bg::point_iterator
<Geometry
> point_iterator
;
390 typedef bg::point_iterator
<Geometry
const> const_point_iterator
;
392 point_iterator begin
= bg::points_begin(geometry
);
393 point_iterator end
= bg::points_end(geometry
);
395 const_point_iterator const_begin
= bg::points_begin(geometry
);
396 const_point_iterator const_end
= bg::points_end(geometry
);
398 // same for reverse iterator
399 typedef bg::point_reverse_iterator
<Geometry
> point_reverse_iterator
;
400 typedef bg::point_reverse_iterator
403 > const_point_reverse_iterator
;
405 point_reverse_iterator rbegin
= bg::points_rbegin(geometry
);
406 point_reverse_iterator rend
= bg::points_rend(geometry
);
408 const_point_reverse_iterator const_rbegin
= bg::points_rbegin(geometry
);
409 const_point_reverse_iterator const_rend
= bg::points_rend(geometry
);
411 // testing assignment of non-const to const iterator
415 // testing assignment of non-const to const reverse_iterator
416 const_rbegin
= rbegin
;
419 // testing equality/inequality comparison
420 BOOST_CHECK(begin
== const_begin
);
421 BOOST_CHECK(end
== const_end
);
424 BOOST_CHECK(begin
!= const_end
);
425 BOOST_CHECK(const_begin
!= end
);
428 // testing equality/inequality comparison for reverse_iterator
429 BOOST_CHECK(rbegin
== const_rbegin
);
430 BOOST_CHECK(rend
== const_rend
);
433 BOOST_CHECK(rbegin
!= const_rend
);
434 BOOST_CHECK(const_rbegin
!= rend
);
439 BOOST_CHECK(rbegin
!= rend
);
441 point_reverse_iterator
rlast(rend
);
443 BOOST_CHECK(bg::equals(*begin
, *rlast
));
445 point_iterator
last(end
);
447 BOOST_CHECK(bg::equals(*rbegin
, *last
));
450 // testing dereferencing/assignment
452 bool const is_reference
= std::is_reference
454 typename
std::iterator_traits
<point_iterator
>::reference
459 if (BOOST_GEOMETRY_CONDITION(is_reference
))
461 point_type p
= *begin
;
462 point_type q
= zero_point
;
464 test_assignment
<is_reference
>::apply(begin
, const_begin
, p
, q
);
467 test_assignment
<is_reference
>::apply(begin
, const_begin
, q
, p
);
473 // test with algorithms
474 #ifdef BOOST_GEOMETRY_TEST_DEBUG
475 print_point_range(std::cout
, begin
, end
, "original:\n") << std::endl
;
476 print_point_range(std::cout
, rbegin
, rend
, "reverse traversal:\n")
478 std::cout
<< bg::wkt(geometry
) << std::endl
;
479 std::cout
<< std::endl
;
481 test_reverse
<Geometry
, is_reference
>::apply(begin
, end
, geometry
);
483 typedef typename
std::iterator_traits
487 if (const_begin
!= const_end
)
489 boost::optional
<point
>
490 pt_max
= max_value(const_begin
, const_end
, bg::less
<point
>());
492 BOOST_CHECK(bool(pt_max
)); // to avoid warnings
493 #ifdef BOOST_GEOMETRY_TEST_DEBUG
494 std::cout
<< "max point: " << bg::dsv(*pt_max
) << std::endl
;
497 #ifdef BOOST_GEOMETRY_TEST_DEBUG
498 std::cout
<< std::endl
;
499 std::cout
<< std::endl
;
500 std::cout
<< std::endl
;
504 static inline void apply(Geometry geometry
, PointRange
const& point_range
)
506 apply(geometry
, point_range
, bg::make_zero
<point_type
>());
511 //======================================================================
512 //======================================================================
515 BOOST_AUTO_TEST_CASE( test_linestring_point_iterator
)
517 #ifdef BOOST_GEOMETRY_TEST_DEBUG
518 std::cout
<< "*** LINESTRING ***" << std::endl
;
521 typedef tuple_multi_point_type TMP
;
522 typedef linestring_type L
;
524 typedef test_point_iterator_of_geometry
<L
, TMP
> tester
;
526 tester::apply(from_wkt
<L
>("LINESTRING()"),
530 tester::apply(from_wkt
<L
>("LINESTRING(3 3,4 4,5 5)"),
531 TMP
{{3,3},{4,4},{5,5}}
534 #ifdef BOOST_GEOMETRY_TEST_DEBUG
535 std::cout
<< std::endl
<< std::endl
<< std::endl
;
540 //======================================================================
541 //======================================================================
544 BOOST_AUTO_TEST_CASE( test_polygon_point_iterator
)
546 #ifdef BOOST_GEOMETRY_TEST_DEBUG
547 std::cout
<< "*** POLYGON ***" << std::endl
;
550 typedef tuple_multi_point_type TMP
;
551 typedef polygon_type P
;
553 typedef test_point_iterator_of_geometry
<P
, TMP
> tester
;
555 tester::apply(from_wkt
<P
>("POLYGON()"),
559 tester::apply(from_wkt
<P
>("POLYGON(())"),
563 tester::apply(from_wkt
<P
>("POLYGON((1 1,9 1,9 9,1 9),(5 5,6 5,6 6,5 6))"),
564 TMP
{{1,1},{9,1},{9,9},{1,9},{5,5},{6,5},{6,6},{5,6}}
567 tester::apply(from_wkt
<P
>("POLYGON((3 3,4 4,5 5),(),(),(),(6 6,7 7,8 8),(),(),(9 9),())"),
568 TMP
{{3,3},{4,4},{5,5},{6,6},{7,7},{8,8},{9,9}}
571 tester::apply(from_wkt
<P
>("POLYGON((),(3 3,4 4,5 5),(),(),(6 6,7 7,8 8),(),(),(9 9),())"),
572 TMP
{{3,3},{4,4},{5,5},{6,6},{7,7},{8,8},{9,9}}
575 #ifdef BOOST_GEOMETRY_TEST_DEBUG
576 std::cout
<< std::endl
<< std::endl
;
581 //======================================================================
582 //======================================================================
585 BOOST_AUTO_TEST_CASE( test_multipoint_point_iterator
)
587 #ifdef BOOST_GEOMETRY_TEST_DEBUG
588 std::cout
<< "*** MULTIPOINT ***" << std::endl
;
591 typedef tuple_multi_point_type TMP
;
592 typedef multi_point_type MP
;
594 typedef test_point_iterator_of_geometry
<MP
, TMP
> tester
;
596 tester::apply(from_wkt
<MP
>("MULTIPOINT()"),
600 tester::apply(from_wkt
<MP
>("MULTIPOINT(3 3,4 4,5 5)"),
601 TMP
{{3,3},{4,4},{5,5}}
604 #ifdef BOOST_GEOMETRY_TEST_DEBUG
605 std::cout
<< std::endl
<< std::endl
<< std::endl
;
610 //======================================================================
611 //======================================================================
614 BOOST_AUTO_TEST_CASE( test_multipoint_3d_point_iterator
)
616 #ifdef BOOST_GEOMETRY_TEST_DEBUG
617 std::cout
<< "*** MULTIPOINT 3D ***" << std::endl
;
620 typedef tuple_multi_point_type_3d TMP
;
621 typedef multi_point_type_3d MP
;
623 typedef test_point_iterator_of_geometry
<MP
, TMP
> tester
;
625 tester::apply(from_wkt
<MP
>("MULTIPOINT()"),
629 tester::apply(from_wkt
<MP
>("MULTIPOINT(3 3 3,4 4 4,5 5 5)"),
630 TMP
{{3,3,3},{4,4,4},{5,5,5}}
633 #ifdef BOOST_GEOMETRY_TEST_DEBUG
634 std::cout
<< std::endl
<< std::endl
<< std::endl
;
639 //======================================================================
640 //======================================================================
643 BOOST_AUTO_TEST_CASE( test_multilinestring_point_iterator
)
645 #ifdef BOOST_GEOMETRY_TEST_DEBUG
646 std::cout
<< "*** MULTILINESTRING ***" << std::endl
;
649 typedef tuple_multi_point_type TMP
;
650 typedef multi_linestring_type ML
;
652 typedef test_point_iterator_of_geometry
<ML
, TMP
> tester
;
654 tester::apply(from_wkt
<ML
>("MULTILINESTRING()"),
658 tester::apply(from_wkt
<ML
>("MULTILINESTRING(())"),
662 tester::apply(from_wkt
<ML
>("MULTILINESTRING((),(),())"),
666 tester::apply(from_wkt
<ML
>("MULTILINESTRING((1 1,2 2,3 3),(3 3,4 4,5 5),(6 6))"),
667 TMP
{{1,1},{2,2},{3,3},{3,3},{4,4},{5,5},{6,6}}
670 tester::apply(from_wkt
<ML
>("MULTILINESTRING((),(),(1 1,2 2,3 3),(),(),(3 3,4 4,5 5),(),(6 6),(),(),())"),
671 TMP
{{1,1},{2,2},{3,3},{3,3},{4,4},{5,5},{6,6}}
674 #ifdef BOOST_GEOMETRY_TEST_DEBUG
675 std::cout
<< std::endl
<< std::endl
;
680 //======================================================================
681 //======================================================================
684 BOOST_AUTO_TEST_CASE( test_multipolygon_point_iterator
)
686 #ifdef BOOST_GEOMETRY_TEST_DEBUG
687 std::cout
<< "*** MULTIPOLYGON ***" << std::endl
;
690 typedef tuple_multi_point_type TMP
;
691 typedef multi_polygon_type MPL
;
693 typedef test_point_iterator_of_geometry
<MPL
, TMP
> tester
;
695 tester::apply(from_wkt
<MPL
>("MULTIPOLYGON()"),
699 tester::apply(from_wkt
<MPL
>("MULTIPOLYGON( () )"),
703 tester::apply(from_wkt
<MPL
>("MULTIPOLYGON( (()) )"),
707 tester::apply(from_wkt
<MPL
>("MULTIPOLYGON( ((),()) )"),
711 tester::apply(from_wkt
<MPL
>("MULTIPOLYGON(((3 3,4 4,5 5),(6 6,7 7,8 8),(9 9)),((1 1,2 2,10 10),(11 11,12 12)))"),
712 TMP
{{3,3},{4,4},{5,5},{6,6},{7,7},{8,8},{9,9},
713 {1,1},{2,2},{10,10},{11,11},{12,12}}
716 tester::apply(from_wkt
<MPL
>("MULTIPOLYGON(((3 3,4 4,5 5),(),(),(),(6 6,7 7,8 8),(),(),(9 9),()),((),(1 1,2 2,10 10),(),(),(),(11 11,12 12),(),(),(13 13),()))"),
717 TMP
{{3,3},{4,4},{5,5},{6,6},{7,7},{8,8},{9,9},
718 {1,1},{2,2},{10,10},{11,11},{12,12},{13,13}}
721 tester::apply(from_wkt
<MPL
>("MULTIPOLYGON(((3 3,4 4,5 5),(),(),(),(6 6,7 7,8 8),(),(),(9 9),()),((),(1 1,2 2,10 10),(),(),(),(11 11,12 12),(),(),(13 13),()),((),(),()))"),
722 TMP
{{3,3},{4,4},{5,5},{6,6},{7,7},{8,8},{9,9},
723 {1,1},{2,2},{10,10},{11,11},{12,12},{13,13}}
726 #ifdef BOOST_GEOMETRY_TEST_DEBUG
727 std::cout
<< std::endl
<< std::endl
;
732 //======================================================================
733 //======================================================================
736 BOOST_AUTO_TEST_CASE( test_multipoint_of_point_pointers
)
738 #ifdef BOOST_GEOMETRY_TEST_DEBUG
739 std::cout
<< "*** MULTIPOINT OF POINT POINTERS ***" << std::endl
;
742 typedef tuple_multi_point_type TMP
;
743 typedef vector_as_multipoint
<test::test_point_xy
*> MP
;
746 for (int i
= 1; i
< 10; i
++)
748 test::test_point_xy
* p
= new test::test_point_xy
;
751 multipoint
.push_back(p
);
754 test::test_point_xy
* zero
= new test::test_point_xy
;
758 typedef test_point_iterator_of_geometry
<MP
, TMP
> tester
;
760 tester::apply(multipoint
,
761 TMP
{{1,-1},{2,-2},{3,-3},{4,-4},{5,-5},{6,-6},
762 {7,-7},{8,-8},{9,-9}},
766 for (unsigned int i
= 0; i
< multipoint
.size(); i
++)
768 delete multipoint
[i
];
774 //======================================================================
775 //======================================================================
778 BOOST_AUTO_TEST_CASE( test_linestring_of_point_pointers
)
780 #ifdef BOOST_GEOMETRY_TEST_DEBUG
781 std::cout
<< "*** LINESTRING OF POINT POINTERS ***" << std::endl
;
784 typedef tuple_multi_point_type TMP
;
785 typedef vector_as_linestring
<test::test_point_xy
*> L
;
788 for (int i
= 1; i
< 10; i
++)
790 test::test_point_xy
* p
= new test::test_point_xy
;
793 linestring
.push_back(p
);
796 test::test_point_xy
* zero
= new test::test_point_xy
;
800 typedef test_point_iterator_of_geometry
<L
, TMP
> tester
;
802 tester::apply(linestring
,
803 TMP
{{1,-1},{2,-2},{3,-3},{4,-4},{5,-5},{6,-6},
804 {7,-7},{8,-8},{9,-9}},
808 for (unsigned int i
= 0; i
< linestring
.size(); i
++)
810 delete linestring
[i
];
816 //======================================================================
817 //======================================================================
820 BOOST_AUTO_TEST_CASE( test_multipoint_copy_on_dereference
)
822 #ifdef BOOST_GEOMETRY_TEST_DEBUG
823 std::cout
<< "*** MULTIPOINT WITH COPY-ON-DEREFERENCE ITERATOR ***"
827 typedef tuple_multi_point_type TMP
;
828 typedef multipoint_copy_on_dereference
<point_type
> MP
;
830 typedef test_point_iterator_of_geometry
832 MP
, TMP
, false // no concept checks
835 // bg::read_wkt does not work for this multipoint type so we have
836 // to initialize the multipoint manually
838 for (int i
= 1; i
< 10; ++i
)
840 multipoint
.push_back(point_type(i
, -i
));
843 tester::apply(multipoint
,
844 // from_wkt<MP>("MULTIPOINT(1 -1,2 -2,3 -3,4 -4,5 -5,6 -6, 7 -7,8 -8,9 -9)"),
845 TMP
{{1,-1},{2,-2},{3,-3},{4,-4},{5,-5},{6,-6},
846 {7,-7},{8,-8},{9,-9}}
851 //======================================================================
852 //======================================================================
855 BOOST_AUTO_TEST_CASE( test_linestring_copy_on_dereference
)
857 #ifdef BOOST_GEOMETRY_TEST_DEBUG
858 std::cout
<< "*** LINESTRING WITH COPY-ON-DEREFERENCE ITERATOR ***"
862 typedef tuple_multi_point_type TMP
;
863 typedef linestring_copy_on_dereference
<point_type
> L
;
865 typedef test_point_iterator_of_geometry
867 L
, TMP
, false // no concept checks
870 tester::apply(from_wkt
<L
>("LINESTRING(1 -1,2 -2,3 -3,4 -4,5 -5,6 -6, 7 -7,8 -8,9 -9)"),
871 TMP
{{1,-1},{2,-2},{3,-3},{4,-4},{5,-5},{6,-6},
872 {7,-7},{8,-8},{9,-9}}