1 // Boost.Geometry (aka GGL, Generic Geometry Library)
4 // Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
6 // Copyright (c) 2014-2017, Oracle and/or its affiliates.
8 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
9 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
11 // Licensed under the Boost Software License version 1.0.
12 // http://www.boost.org/users/license.html
15 #ifndef BOOST_TEST_MODULE
16 #define BOOST_TEST_MODULE test_point_iterator
25 #include <boost/test/included/unit_test.hpp>
27 #include <boost/concept_check.hpp>
28 #include <boost/core/ignore_unused.hpp>
29 #include <boost/iterator/iterator_concepts.hpp>
30 #include <boost/tuple/tuple.hpp>
31 #include <boost/type_traits/is_const.hpp>
32 #include <boost/optional.hpp>
33 #include <boost/type_traits/is_reference.hpp>
35 #include <boost/geometry/core/point_type.hpp>
37 #include <boost/geometry/geometries/geometries.hpp>
38 #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
39 #include <boost/geometry/geometries/register/linestring.hpp>
40 #include <boost/geometry/geometries/register/multi_point.hpp>
42 #include <boost/geometry/algorithms/equals.hpp>
43 #include <boost/geometry/algorithms/make.hpp>
44 #include <boost/geometry/algorithms/num_points.hpp>
46 #include <boost/geometry/policies/compare.hpp>
48 #include <boost/geometry/util/condition.hpp>
50 #include <boost/geometry/io/wkt/wkt.hpp>
51 #include <boost/geometry/io/dsv/write.hpp>
53 #include <boost/geometry/iterators/point_iterator.hpp>
54 #include <boost/geometry/iterators/point_reverse_iterator.hpp>
56 #include <boost/geometry/strategies/strategies.hpp>
58 #include <test_common/with_pointer.hpp>
59 #include <test_geometries/copy_on_dereference_geometries.hpp>
61 // At the end because of conflicts with Boost.QVM
62 #include <boost/assign/list_of.hpp>
65 namespace bg
= ::boost::geometry
;
66 namespace ba
= ::boost::assign
;
68 typedef bg::model::point
<double, 2, bg::cs::cartesian
> point_type
;
69 typedef bg::model::point
<double, 3, bg::cs::cartesian
> point_type_3d
;
70 typedef bg::model::linestring
<point_type
> linestring_type
;
71 typedef bg::model::polygon
<point_type
, false, false> polygon_type
; //ccw, open
74 typedef bg::model::multi_point
<point_type
> multi_point_type
;
75 typedef bg::model::multi_point
<point_type_3d
> multi_point_type_3d
;
76 typedef bg::model::multi_linestring
<linestring_type
> multi_linestring_type
;
77 typedef bg::model::multi_polygon
<polygon_type
> multi_polygon_type
;
79 typedef boost::tuple
<double, double> tuple_point_type
;
80 typedef boost::tuple
<double, double, double> tuple_point_type_3d
;
81 typedef std::vector
<tuple_point_type
> tuple_multi_point_type
;
82 typedef std::vector
<tuple_point_type_3d
> tuple_multi_point_type_3d
;
85 struct vector_as_multipoint
: std::vector
<T
> {};
88 struct vector_as_linestring
: std::vector
<T
> {};
90 BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian
)
91 BOOST_GEOMETRY_REGISTER_MULTI_POINT(tuple_multi_point_type
)
92 BOOST_GEOMETRY_REGISTER_MULTI_POINT(tuple_multi_point_type_3d
)
94 BOOST_GEOMETRY_REGISTER_MULTI_POINT_TEMPLATED(vector_as_multipoint
)
95 BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(vector_as_linestring
)
99 template <typename Geometry
>
100 inline Geometry
from_wkt(std::string
const& wkt
)
103 boost::geometry::read_wkt(wkt
, geometry
);
108 // this function is implemented because std::max_element() requires ForwardIterator
109 // but bg::point_iterator<> is InputIterator since it returns non-true reference
110 template <typename InputIt
, typename Pred
>
111 inline boost::optional
<typename
std::iterator_traits
<InputIt
>::value_type
>
112 max_value(InputIt first
, InputIt last
, Pred pred
)
114 typedef typename
std::iterator_traits
<InputIt
>::value_type value_type
;
117 value_type found
= *first
++;
118 for (; first
!= last
; )
120 value_type current
= *first
++;
121 if (pred(current
, found
))
130 template <typename Iterator
>
131 inline std::ostream
& print_point_range(std::ostream
& os
,
134 std::string
const& header
)
137 for (Iterator it
= first
; it
!= beyond
; ++it
)
139 os
<< " " << bg::dsv(*it
);
150 bool IsConst
= boost::is_const
<Geometry
>::value
152 struct test_iterator_concepts
154 typedef bg::point_iterator
<Geometry
> iterator
;
155 BOOST_CONCEPT_ASSERT((boost::BidirectionalIteratorConcept
<iterator
>));
156 BOOST_CONCEPT_ASSERT((boost_concepts::ReadableIteratorConcept
<iterator
>));
157 BOOST_CONCEPT_ASSERT((boost_concepts::LvalueIteratorConcept
<iterator
>));
159 ((boost_concepts::BidirectionalTraversalConcept
<iterator
>));
162 template <typename Geometry
>
163 struct test_iterator_concepts
<Geometry
, true, false>
164 : test_iterator_concepts
<Geometry
, true, true>
166 typedef bg::point_iterator
<Geometry
> iterator
;
168 ((boost::Mutable_BidirectionalIteratorConcept
<iterator
>));
170 ((boost_concepts::WritableIteratorConcept
<iterator
>));
172 ((boost_concepts::SwappableIteratorConcept
<iterator
>));
175 template <typename Geometry
, bool IsConst
>
176 struct test_iterator_concepts
<Geometry
, false, IsConst
>
183 template <typename Iterator
>
184 static inline std::size_t number_of_elements(Iterator begin
,
187 std::size_t size
= std::distance(begin
, end
);
189 std::size_t num_elems(0);
190 for (Iterator it
= begin
; it
!= end
; ++it
)
194 BOOST_CHECK(size
== num_elems
);
197 for (Iterator it
= end
; it
!= begin
; --it
)
201 BOOST_CHECK(size
== num_elems
);
206 template <typename Iterator1
, typename Iterator2
>
207 static inline bool apply(Iterator1 begin1
, Iterator1 end1
,
208 Iterator2 begin2
, Iterator2 end2
)
210 std::size_t num_points1
= number_of_elements(begin1
, end1
);
211 std::size_t num_points2
= number_of_elements(begin2
, end2
);
213 if (num_points1
!= num_points2
)
218 Iterator1 it1
= begin1
;
219 Iterator2 it2
= begin2
;
220 for (; it1
!= end1
; ++it1
, ++it2
)
222 if (! bg::equals(*it1
, *it2
))
232 template <bool Enable
= true>
233 struct test_assignment
235 template <typename Iterator
, typename ConstIterator
, typename Value
>
236 static inline void apply(Iterator it
, ConstIterator cit
,
237 Value
const& value1
, Value
const& value2
)
239 #ifdef BOOST_GEOMETRY_TEST_DEBUG
240 std::cout
<< "== before assignment ==" << std::endl
;
241 std::cout
<< "value1: " << bg::wkt(value1
) << std::endl
;
242 std::cout
<< "value2: " << bg::wkt(value2
) << std::endl
;
243 std::cout
<< "*it : " << bg::wkt(*it
) << std::endl
;
244 std::cout
<< "*cit : " << bg::wkt(*cit
) << std::endl
;
247 BOOST_CHECK(bg::equals(*it
, value1
));
248 BOOST_CHECK(! bg::equals(*it
, value2
));
249 BOOST_CHECK(bg::equals(*cit
, value1
));
250 BOOST_CHECK(! bg::equals(*cit
, value2
));
253 BOOST_CHECK(bg::equals(*it
, value2
));
254 BOOST_CHECK(! bg::equals(*it
, value1
));
255 BOOST_CHECK(bg::equals(*cit
, value2
));
256 BOOST_CHECK(! bg::equals(*cit
, value1
));
258 #ifdef BOOST_GEOMETRY_TEST_DEBUG
259 std::cout
<< "== after 1st assignment ==" << std::endl
;
260 std::cout
<< "value1: " << bg::wkt(value1
) << std::endl
;
261 std::cout
<< "value2: " << bg::wkt(value2
) << std::endl
;
262 std::cout
<< "*it : " << bg::wkt(*it
) << std::endl
;
263 std::cout
<< "*cit : " << bg::wkt(*cit
) << std::endl
;
267 BOOST_CHECK(bg::equals(*it
, value1
));
268 BOOST_CHECK(! bg::equals(*it
, value2
));
269 BOOST_CHECK(bg::equals(*cit
, value1
));
270 BOOST_CHECK(! bg::equals(*cit
, value2
));
272 #ifdef BOOST_GEOMETRY_TEST_DEBUG
273 std::cout
<< "== after 2nd assignment ==" << std::endl
;
274 std::cout
<< "value1: " << bg::wkt(value1
) << std::endl
;
275 std::cout
<< "value2: " << bg::wkt(value2
) << std::endl
;
276 std::cout
<< "*it : " << bg::wkt(*it
) << std::endl
;
277 std::cout
<< "*cit : " << bg::wkt(*cit
) << std::endl
;
278 std::cout
<< std::endl
;
284 struct test_assignment
<false>
286 template <typename Iterator
, typename ConstIterator
, typename Value
>
287 static inline void apply(Iterator
, ConstIterator
,
288 Value
const&, Value
const&)
298 bool EnableConceptChecks
= true
300 struct test_point_iterator_of_geometry
302 typedef typename
bg::point_type
<Geometry
>::type point_type
;
304 template <typename G
>
305 static inline void base_test(G
& geometry
,
306 PointRange
const& point_range
,
307 std::string
const& header
)
309 typedef bg::point_iterator
<G
> point_iterator
;
311 test_iterator_concepts
<G
, EnableConceptChecks
>();
313 point_iterator begin
= bg::points_begin(geometry
);
314 point_iterator end
= bg::points_end(geometry
);
316 BOOST_CHECK(std::size_t(std::distance(begin
, end
))
318 bg::num_points(geometry
));
320 BOOST_CHECK(equals::apply(begin
, end
,
321 bg::points_begin(point_range
),
322 bg::points_end(point_range
))
325 boost::ignore_unused(header
);
327 #ifdef BOOST_GEOMETRY_TEST_DEBUG
328 std::cout
<< header
<< " geometry: " << bg::wkt(geometry
) << std::endl
;
329 print_point_range(std::cout
, begin
, end
, "point range: ");
330 std::cout
<< std::endl
;
332 typedef bg::point_iterator
<PointRange
const> point_range_iterator
;
334 print_point_range(std::cout
,
335 bg::points_begin(point_range
),
336 bg::points_end(point_range
),
337 "expected point range: ");
338 std::cout
<< std::endl
;
342 template <typename G
, bool Enable
>
345 template <typename Iterator
>
346 static inline void apply(Iterator first
, Iterator last
,
349 boost::ignore_unused(geometry
);
351 std::reverse(first
, last
);
352 #ifdef BOOST_GEOMETRY_TEST_DEBUG
353 print_point_range(std::cout
, first
, last
, "reversed:\n")
355 std::cout
<< bg::wkt(geometry
) << std::endl
;
356 std::cout
<< std::endl
;
359 std::reverse(first
, last
);
360 #ifdef BOOST_GEOMETRY_TEST_DEBUG
361 print_point_range(std::cout
, first
, last
, "re-reversed:\n")
363 std::cout
<< bg::wkt(geometry
) << std::endl
;
364 std::cout
<< std::endl
;
365 std::cout
<< std::endl
;
370 template <typename G
>
371 struct test_reverse
<G
, false>
373 template <typename Iterator
>
374 static inline void apply(Iterator
, Iterator
, G
const&)
379 static inline void apply(Geometry geometry
,
380 PointRange
const& point_range
,
381 point_type
const& zero_point
)
383 base_test
<Geometry
>(geometry
, point_range
, "non-const");
385 #ifdef BOOST_GEOMETRY_TEST_DEBUG
386 std::cout
<< std::endl
;
389 base_test
<Geometry
const>(geometry
, point_range
, "const");
391 #ifdef BOOST_GEOMETRY_TEST_DEBUG
392 std::cout
<< std::endl
<< std::endl
;
395 // testing construction of const and non-const iterator
396 typedef bg::point_iterator
<Geometry
> point_iterator
;
397 typedef bg::point_iterator
<Geometry
const> const_point_iterator
;
399 point_iterator begin
= bg::points_begin(geometry
);
400 point_iterator end
= bg::points_end(geometry
);
402 const_point_iterator const_begin
= bg::points_begin(geometry
);
403 const_point_iterator const_end
= bg::points_end(geometry
);
405 // same for reverse iterator
406 typedef bg::point_reverse_iterator
<Geometry
> point_reverse_iterator
;
407 typedef bg::point_reverse_iterator
410 > const_point_reverse_iterator
;
412 point_reverse_iterator rbegin
= bg::points_rbegin(geometry
);
413 point_reverse_iterator rend
= bg::points_rend(geometry
);
415 const_point_reverse_iterator const_rbegin
= bg::points_rbegin(geometry
);
416 const_point_reverse_iterator const_rend
= bg::points_rend(geometry
);
418 // testing assignment of non-const to const iterator
422 // testing assignment of non-const to const reverse_iterator
423 const_rbegin
= rbegin
;
426 // testing equality/inequality comparison
427 BOOST_CHECK(begin
== const_begin
);
428 BOOST_CHECK(end
== const_end
);
431 BOOST_CHECK(begin
!= const_end
);
432 BOOST_CHECK(const_begin
!= end
);
435 // testing equality/inequality comparison for reverse_iterator
436 BOOST_CHECK(rbegin
== const_rbegin
);
437 BOOST_CHECK(rend
== const_rend
);
440 BOOST_CHECK(rbegin
!= const_rend
);
441 BOOST_CHECK(const_rbegin
!= rend
);
446 BOOST_CHECK(rbegin
!= rend
);
448 point_reverse_iterator
rlast(rend
);
450 BOOST_CHECK(bg::equals(*begin
, *rlast
));
452 point_iterator
last(end
);
454 BOOST_CHECK(bg::equals(*rbegin
, *last
));
457 // testing dereferencing/assignment
459 bool const is_reference
= boost::is_reference
461 typename
std::iterator_traits
<point_iterator
>::reference
466 if (BOOST_GEOMETRY_CONDITION(is_reference
))
468 point_type p
= *begin
;
469 point_type q
= zero_point
;
471 test_assignment
<is_reference
>::apply(begin
, const_begin
, p
, q
);
474 test_assignment
<is_reference
>::apply(begin
, const_begin
, q
, p
);
480 // test with algorithms
481 #ifdef BOOST_GEOMETRY_TEST_DEBUG
482 print_point_range(std::cout
, begin
, end
, "original:\n") << std::endl
;
483 print_point_range(std::cout
, rbegin
, rend
, "reverse traversal:\n")
485 std::cout
<< bg::wkt(geometry
) << std::endl
;
486 std::cout
<< std::endl
;
488 test_reverse
<Geometry
, is_reference
>::apply(begin
, end
, geometry
);
490 typedef typename
std::iterator_traits
494 if (const_begin
!= const_end
)
496 boost::optional
<point
>
497 pt_max
= max_value(const_begin
, const_end
, bg::less
<point
>());
499 BOOST_CHECK(bool(pt_max
)); // to avoid warnings
500 #ifdef BOOST_GEOMETRY_TEST_DEBUG
501 std::cout
<< "max point: " << bg::dsv(*pt_max
) << std::endl
;
504 #ifdef BOOST_GEOMETRY_TEST_DEBUG
505 std::cout
<< std::endl
;
506 std::cout
<< std::endl
;
507 std::cout
<< std::endl
;
511 static inline void apply(Geometry geometry
, PointRange
const& point_range
)
513 apply(geometry
, point_range
, bg::make_zero
<point_type
>());
518 //======================================================================
519 //======================================================================
522 BOOST_AUTO_TEST_CASE( test_linestring_point_iterator
)
524 #ifdef BOOST_GEOMETRY_TEST_DEBUG
525 std::cout
<< "*** LINESTRING ***" << std::endl
;
528 typedef tuple_multi_point_type TMP
;
529 typedef linestring_type L
;
531 typedef test_point_iterator_of_geometry
<L
, TMP
> tester
;
533 tester::apply(from_wkt
<L
>("LINESTRING()"),
537 tester::apply(from_wkt
<L
>("LINESTRING(3 3,4 4,5 5)"),
538 ba::tuple_list_of(3,3)(4,4)(5,5)
541 #ifdef BOOST_GEOMETRY_TEST_DEBUG
542 std::cout
<< std::endl
<< std::endl
<< std::endl
;
547 //======================================================================
548 //======================================================================
551 BOOST_AUTO_TEST_CASE( test_polygon_point_iterator
)
553 #ifdef BOOST_GEOMETRY_TEST_DEBUG
554 std::cout
<< "*** POLYGON ***" << std::endl
;
557 typedef tuple_multi_point_type TMP
;
558 typedef polygon_type P
;
560 typedef test_point_iterator_of_geometry
<P
, TMP
> tester
;
562 tester::apply(from_wkt
<P
>("POLYGON()"),
566 tester::apply(from_wkt
<P
>("POLYGON(())"),
570 tester::apply(from_wkt
<P
>("POLYGON((1 1,9 1,9 9,1 9),(5 5,6 5,6 6,5 6))"),
571 ba::tuple_list_of(1,1)(9,1)(9,9)(1,9)(5,5)(6,5)(6,6)(5,6)
574 tester::apply(from_wkt
<P
>("POLYGON((3 3,4 4,5 5),(),(),(),(6 6,7 7,8 8),(),(),(9 9),())"),
575 ba::tuple_list_of(3,3)(4,4)(5,5)(6,6)(7,7)(8,8)(9,9)
578 tester::apply(from_wkt
<P
>("POLYGON((),(3 3,4 4,5 5),(),(),(6 6,7 7,8 8),(),(),(9 9),())"),
579 ba::tuple_list_of(3,3)(4,4)(5,5)(6,6)(7,7)(8,8)(9,9)
582 #ifdef BOOST_GEOMETRY_TEST_DEBUG
583 std::cout
<< std::endl
<< std::endl
;
588 //======================================================================
589 //======================================================================
592 BOOST_AUTO_TEST_CASE( test_multipoint_point_iterator
)
594 #ifdef BOOST_GEOMETRY_TEST_DEBUG
595 std::cout
<< "*** MULTIPOINT ***" << std::endl
;
598 typedef tuple_multi_point_type TMP
;
599 typedef multi_point_type MP
;
601 typedef test_point_iterator_of_geometry
<MP
, TMP
> tester
;
603 tester::apply(from_wkt
<MP
>("MULTIPOINT()"),
607 tester::apply(from_wkt
<MP
>("MULTIPOINT(3 3,4 4,5 5)"),
608 ba::tuple_list_of(3,3)(4,4)(5,5)
611 #ifdef BOOST_GEOMETRY_TEST_DEBUG
612 std::cout
<< std::endl
<< std::endl
<< std::endl
;
617 //======================================================================
618 //======================================================================
621 BOOST_AUTO_TEST_CASE( test_multipoint_3d_point_iterator
)
623 #ifdef BOOST_GEOMETRY_TEST_DEBUG
624 std::cout
<< "*** MULTIPOINT 3D ***" << std::endl
;
627 typedef tuple_multi_point_type_3d TMP
;
628 typedef multi_point_type_3d MP
;
630 typedef test_point_iterator_of_geometry
<MP
, TMP
> tester
;
632 tester::apply(from_wkt
<MP
>("MULTIPOINT()"),
636 tester::apply(from_wkt
<MP
>("MULTIPOINT(3 3 3,4 4 4,5 5 5)"),
637 ba::tuple_list_of(3,3,3)(4,4,4)(5,5,5)
640 #ifdef BOOST_GEOMETRY_TEST_DEBUG
641 std::cout
<< std::endl
<< std::endl
<< std::endl
;
646 //======================================================================
647 //======================================================================
650 BOOST_AUTO_TEST_CASE( test_multilinestring_point_iterator
)
652 #ifdef BOOST_GEOMETRY_TEST_DEBUG
653 std::cout
<< "*** MULTILINESTRING ***" << std::endl
;
656 typedef tuple_multi_point_type TMP
;
657 typedef multi_linestring_type ML
;
659 typedef test_point_iterator_of_geometry
<ML
, TMP
> tester
;
661 tester::apply(from_wkt
<ML
>("MULTILINESTRING()"),
665 tester::apply(from_wkt
<ML
>("MULTILINESTRING(())"),
669 tester::apply(from_wkt
<ML
>("MULTILINESTRING((),(),())"),
673 tester::apply(from_wkt
<ML
>("MULTILINESTRING((1 1,2 2,3 3),(3 3,4 4,5 5),(6 6))"),
674 ba::tuple_list_of(1,1)(2,2)(3,3)(3,3)(4,4)(5,5)(6,6)
677 tester::apply(from_wkt
<ML
>("MULTILINESTRING((),(),(1 1,2 2,3 3),(),(),(3 3,4 4,5 5),(),(6 6),(),(),())"),
678 ba::tuple_list_of(1,1)(2,2)(3,3)(3,3)(4,4)(5,5)(6,6)
681 #ifdef BOOST_GEOMETRY_TEST_DEBUG
682 std::cout
<< std::endl
<< std::endl
;
687 //======================================================================
688 //======================================================================
691 BOOST_AUTO_TEST_CASE( test_multipolygon_point_iterator
)
693 #ifdef BOOST_GEOMETRY_TEST_DEBUG
694 std::cout
<< "*** MULTIPOLYGON ***" << std::endl
;
697 typedef tuple_multi_point_type TMP
;
698 typedef multi_polygon_type MPL
;
700 typedef test_point_iterator_of_geometry
<MPL
, TMP
> tester
;
702 tester::apply(from_wkt
<MPL
>("MULTIPOLYGON()"),
706 tester::apply(from_wkt
<MPL
>("MULTIPOLYGON( () )"),
710 tester::apply(from_wkt
<MPL
>("MULTIPOLYGON( (()) )"),
714 tester::apply(from_wkt
<MPL
>("MULTIPOLYGON( ((),()) )"),
718 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)))"),
719 ba::tuple_list_of(3,3)(4,4)(5,5)(6,6)(7,7)(8,8)(9,9)\
720 (1,1)(2,2)(10,10)(11,11)(12,12)
723 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),()))"),
724 ba::tuple_list_of(3,3)(4,4)(5,5)(6,6)(7,7)(8,8)(9,9)\
725 (1,1)(2,2)(10,10)(11,11)(12,12)(13,13)
728 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),()),((),(),()))"),
729 ba::tuple_list_of(3,3)(4,4)(5,5)(6,6)(7,7)(8,8)(9,9)\
730 (1,1)(2,2)(10,10)(11,11)(12,12)(13,13)
733 #ifdef BOOST_GEOMETRY_TEST_DEBUG
734 std::cout
<< std::endl
<< std::endl
;
739 //======================================================================
740 //======================================================================
743 BOOST_AUTO_TEST_CASE( test_multipoint_of_point_pointers
)
745 #ifdef BOOST_GEOMETRY_TEST_DEBUG
746 std::cout
<< "*** MULTIPOINT OF POINT POINTERS ***" << std::endl
;
749 typedef tuple_multi_point_type TMP
;
750 typedef vector_as_multipoint
<test::test_point_xy
*> MP
;
753 for (int i
= 1; i
< 10; i
++)
755 test::test_point_xy
* p
= new test::test_point_xy
;
758 multipoint
.push_back(p
);
761 test::test_point_xy
* zero
= new test::test_point_xy
;
765 typedef test_point_iterator_of_geometry
<MP
, TMP
> tester
;
767 tester::apply(multipoint
,
768 ba::tuple_list_of(1,-1)(2,-2)(3,-3)(4,-4)(5,-5)(6,-6)\
773 for (unsigned int i
= 0; i
< multipoint
.size(); i
++)
775 delete multipoint
[i
];
781 //======================================================================
782 //======================================================================
785 BOOST_AUTO_TEST_CASE( test_linestring_of_point_pointers
)
787 #ifdef BOOST_GEOMETRY_TEST_DEBUG
788 std::cout
<< "*** LINESTRING OF POINT POINTERS ***" << std::endl
;
791 typedef tuple_multi_point_type TMP
;
792 typedef vector_as_linestring
<test::test_point_xy
*> L
;
795 for (int i
= 1; i
< 10; i
++)
797 test::test_point_xy
* p
= new test::test_point_xy
;
800 linestring
.push_back(p
);
803 test::test_point_xy
* zero
= new test::test_point_xy
;
807 typedef test_point_iterator_of_geometry
<L
, TMP
> tester
;
809 tester::apply(linestring
,
810 ba::tuple_list_of(1,-1)(2,-2)(3,-3)(4,-4)(5,-5)(6,-6)\
815 for (unsigned int i
= 0; i
< linestring
.size(); i
++)
817 delete linestring
[i
];
823 //======================================================================
824 //======================================================================
827 BOOST_AUTO_TEST_CASE( test_multipoint_copy_on_dereference
)
829 #ifdef BOOST_GEOMETRY_TEST_DEBUG
830 std::cout
<< "*** MULTIPOINT WITH COPY-ON-DEREFERENCE ITERATOR ***"
834 typedef tuple_multi_point_type TMP
;
835 typedef multipoint_copy_on_dereference
<point_type
> MP
;
837 typedef test_point_iterator_of_geometry
839 MP
, TMP
, false // no concept checks
842 // bg::read_wkt does not work for this multipoint type so we have
843 // to initialize the multipoint manually
845 for (int i
= 1; i
< 10; ++i
)
847 multipoint
.push_back(point_type(i
, -i
));
850 tester::apply(multipoint
,
851 // from_wkt<MP>("MULTIPOINT(1 -1,2 -2,3 -3,4 -4,5 -5,6 -6, 7 -7,8 -8,9 -9)"),
852 ba::tuple_list_of(1,-1)(2,-2)(3,-3)(4,-4)(5,-5)(6,-6)\
858 //======================================================================
859 //======================================================================
862 BOOST_AUTO_TEST_CASE( test_linestring_copy_on_dereference
)
864 #ifdef BOOST_GEOMETRY_TEST_DEBUG
865 std::cout
<< "*** LINESTRING WITH COPY-ON-DEREFERENCE ITERATOR ***"
869 typedef tuple_multi_point_type TMP
;
870 typedef linestring_copy_on_dereference
<point_type
> L
;
872 typedef test_point_iterator_of_geometry
874 L
, TMP
, false // no concept checks
877 tester::apply(from_wkt
<L
>("LINESTRING(1 -1,2 -2,3 -3,4 -4,5 -5,6 -6, 7 -7,8 -8,9 -9)"),
878 ba::tuple_list_of(1,-1)(2,-2)(3,-3)(4,-4)(5,-5)(6,-6)\