1 // Boost.Geometry (aka GGL, Generic Geometry Library)
4 // Copyright (c) 2014-2016, Oracle and/or its affiliates.
6 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
7 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
9 // Licensed under the Boost Software License version 1.0.
10 // http://www.boost.org/users/license.html
13 #ifndef BOOST_TEST_MODULE
14 #define BOOST_TEST_MODULE test_point_iterator
23 #include <boost/test/included/unit_test.hpp>
25 #include <boost/assign/list_of.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/type_traits/is_const.hpp>
31 #include <boost/optional.hpp>
32 #include <boost/type_traits/is_reference.hpp>
34 #include <boost/geometry/core/point_type.hpp>
36 #include <boost/geometry/geometries/geometries.hpp>
37 #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
38 #include <boost/geometry/geometries/register/linestring.hpp>
39 #include <boost/geometry/geometries/register/multi_point.hpp>
41 #include <boost/geometry/algorithms/equals.hpp>
42 #include <boost/geometry/algorithms/make.hpp>
43 #include <boost/geometry/algorithms/num_points.hpp>
45 #include <boost/geometry/policies/compare.hpp>
47 #include <boost/geometry/util/condition.hpp>
49 #include <boost/geometry/io/wkt/wkt.hpp>
50 #include <boost/geometry/io/dsv/write.hpp>
52 #include <boost/geometry/iterators/point_iterator.hpp>
53 #include <boost/geometry/iterators/point_reverse_iterator.hpp>
55 #include <test_common/with_pointer.hpp>
56 #include <test_geometries/copy_on_dereference_geometries.hpp>
58 namespace bg
= ::boost::geometry
;
59 namespace ba
= ::boost::assign
;
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 boost::geometry::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
= boost::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 std::reverse(first
, last
);
343 #ifdef BOOST_GEOMETRY_TEST_DEBUG
344 print_point_range(std::cout
, first
, last
, "reversed:\n")
346 std::cout
<< bg::wkt(geometry
) << std::endl
;
347 std::cout
<< std::endl
;
350 std::reverse(first
, last
);
351 #ifdef BOOST_GEOMETRY_TEST_DEBUG
352 print_point_range(std::cout
, first
, last
, "re-reversed:\n")
354 std::cout
<< bg::wkt(geometry
) << std::endl
;
355 std::cout
<< std::endl
;
356 std::cout
<< std::endl
;
361 template <typename G
>
362 struct test_reverse
<G
, false>
364 template <typename Iterator
>
365 static inline void apply(Iterator
, Iterator
, G
const&)
370 static inline void apply(Geometry geometry
,
371 PointRange
const& point_range
,
372 point_type
const& zero_point
)
374 base_test
<Geometry
>(geometry
, point_range
, "non-const");
376 #ifdef BOOST_GEOMETRY_TEST_DEBUG
377 std::cout
<< std::endl
;
380 base_test
<Geometry
const>(geometry
, point_range
, "const");
382 #ifdef BOOST_GEOMETRY_TEST_DEBUG
383 std::cout
<< std::endl
<< std::endl
;
386 // testing construction of const and non-const iterator
387 typedef bg::point_iterator
<Geometry
> point_iterator
;
388 typedef bg::point_iterator
<Geometry
const> const_point_iterator
;
390 point_iterator begin
= bg::points_begin(geometry
);
391 point_iterator end
= bg::points_end(geometry
);
393 const_point_iterator const_begin
= bg::points_begin(geometry
);
394 const_point_iterator const_end
= bg::points_end(geometry
);
396 // same for reverse iterator
397 typedef bg::point_reverse_iterator
<Geometry
> point_reverse_iterator
;
398 typedef bg::point_reverse_iterator
401 > const_point_reverse_iterator
;
403 point_reverse_iterator rbegin
= bg::points_rbegin(geometry
);
404 point_reverse_iterator rend
= bg::points_rend(geometry
);
406 const_point_reverse_iterator const_rbegin
= bg::points_rbegin(geometry
);
407 const_point_reverse_iterator const_rend
= bg::points_rend(geometry
);
409 // testing assignment of non-const to const iterator
413 // testing assignment of non-const to const reverse_iterator
414 const_rbegin
= rbegin
;
417 // testing equality/inequality comparison
418 BOOST_CHECK(begin
== const_begin
);
419 BOOST_CHECK(end
== const_end
);
422 BOOST_CHECK(begin
!= const_end
);
423 BOOST_CHECK(const_begin
!= end
);
426 // testing equality/inequality comparison for reverse_iterator
427 BOOST_CHECK(rbegin
== const_rbegin
);
428 BOOST_CHECK(rend
== const_rend
);
431 BOOST_CHECK(rbegin
!= const_rend
);
432 BOOST_CHECK(const_rbegin
!= rend
);
437 BOOST_CHECK(rbegin
!= rend
);
439 point_reverse_iterator
rlast(rend
);
441 BOOST_CHECK(bg::equals(*begin
, *rlast
));
443 point_iterator
last(end
);
445 BOOST_CHECK(bg::equals(*rbegin
, *last
));
448 // testing dereferencing/assignment
450 bool const is_reference
= boost::is_reference
452 typename
std::iterator_traits
<point_iterator
>::reference
457 if (BOOST_GEOMETRY_CONDITION(is_reference
))
459 point_type p
= *begin
;
460 point_type q
= zero_point
;
462 test_assignment
<is_reference
>::apply(begin
, const_begin
, p
, q
);
465 test_assignment
<is_reference
>::apply(begin
, const_begin
, q
, p
);
471 // test with algorithms
472 #ifdef BOOST_GEOMETRY_TEST_DEBUG
473 print_point_range(std::cout
, begin
, end
, "original:\n") << std::endl
;
474 print_point_range(std::cout
, rbegin
, rend
, "reverse traversal:\n")
476 std::cout
<< bg::wkt(geometry
) << std::endl
;
477 std::cout
<< std::endl
;
479 test_reverse
<Geometry
, is_reference
>::apply(begin
, end
, geometry
);
481 typedef typename
std::iterator_traits
485 if (const_begin
!= const_end
)
487 boost::optional
<point
>
488 pt_max
= max_value(const_begin
, const_end
, bg::less
<point
>());
490 BOOST_CHECK(bool(pt_max
)); // to avoid warnings
491 #ifdef BOOST_GEOMETRY_TEST_DEBUG
492 std::cout
<< "max point: " << bg::dsv(*pt_max
) << std::endl
;
495 #ifdef BOOST_GEOMETRY_TEST_DEBUG
496 std::cout
<< std::endl
;
497 std::cout
<< std::endl
;
498 std::cout
<< std::endl
;
502 static inline void apply(Geometry geometry
, PointRange
const& point_range
)
504 apply(geometry
, point_range
, bg::make_zero
<point_type
>());
509 //======================================================================
510 //======================================================================
513 BOOST_AUTO_TEST_CASE( test_linestring_point_iterator
)
515 #ifdef BOOST_GEOMETRY_TEST_DEBUG
516 std::cout
<< "*** LINESTRING ***" << std::endl
;
519 typedef tuple_multi_point_type TMP
;
520 typedef linestring_type L
;
522 typedef test_point_iterator_of_geometry
<L
, TMP
> tester
;
524 tester::apply(from_wkt
<L
>("LINESTRING()"),
528 tester::apply(from_wkt
<L
>("LINESTRING(3 3,4 4,5 5)"),
529 ba::tuple_list_of(3,3)(4,4)(5,5)
532 #ifdef BOOST_GEOMETRY_TEST_DEBUG
533 std::cout
<< std::endl
<< std::endl
<< std::endl
;
538 //======================================================================
539 //======================================================================
542 BOOST_AUTO_TEST_CASE( test_polygon_point_iterator
)
544 #ifdef BOOST_GEOMETRY_TEST_DEBUG
545 std::cout
<< "*** POLYGON ***" << std::endl
;
548 typedef tuple_multi_point_type TMP
;
549 typedef polygon_type P
;
551 typedef test_point_iterator_of_geometry
<P
, TMP
> tester
;
553 tester::apply(from_wkt
<P
>("POLYGON()"),
557 tester::apply(from_wkt
<P
>("POLYGON(())"),
561 tester::apply(from_wkt
<P
>("POLYGON((1 1,9 1,9 9,1 9),(5 5,6 5,6 6,5 6))"),
562 ba::tuple_list_of(1,1)(9,1)(9,9)(1,9)(5,5)(6,5)(6,6)(5,6)
565 tester::apply(from_wkt
<P
>("POLYGON((3 3,4 4,5 5),(),(),(),(6 6,7 7,8 8),(),(),(9 9),())"),
566 ba::tuple_list_of(3,3)(4,4)(5,5)(6,6)(7,7)(8,8)(9,9)
569 tester::apply(from_wkt
<P
>("POLYGON((),(3 3,4 4,5 5),(),(),(6 6,7 7,8 8),(),(),(9 9),())"),
570 ba::tuple_list_of(3,3)(4,4)(5,5)(6,6)(7,7)(8,8)(9,9)
573 #ifdef BOOST_GEOMETRY_TEST_DEBUG
574 std::cout
<< std::endl
<< std::endl
;
579 //======================================================================
580 //======================================================================
583 BOOST_AUTO_TEST_CASE( test_multipoint_point_iterator
)
585 #ifdef BOOST_GEOMETRY_TEST_DEBUG
586 std::cout
<< "*** MULTIPOINT ***" << std::endl
;
589 typedef tuple_multi_point_type TMP
;
590 typedef multi_point_type MP
;
592 typedef test_point_iterator_of_geometry
<MP
, TMP
> tester
;
594 tester::apply(from_wkt
<MP
>("MULTIPOINT()"),
598 tester::apply(from_wkt
<MP
>("MULTIPOINT(3 3,4 4,5 5)"),
599 ba::tuple_list_of(3,3)(4,4)(5,5)
602 #ifdef BOOST_GEOMETRY_TEST_DEBUG
603 std::cout
<< std::endl
<< std::endl
<< std::endl
;
608 //======================================================================
609 //======================================================================
612 BOOST_AUTO_TEST_CASE( test_multipoint_3d_point_iterator
)
614 #ifdef BOOST_GEOMETRY_TEST_DEBUG
615 std::cout
<< "*** MULTIPOINT 3D ***" << std::endl
;
618 typedef tuple_multi_point_type_3d TMP
;
619 typedef multi_point_type_3d MP
;
621 typedef test_point_iterator_of_geometry
<MP
, TMP
> tester
;
623 tester::apply(from_wkt
<MP
>("MULTIPOINT()"),
627 tester::apply(from_wkt
<MP
>("MULTIPOINT(3 3 3,4 4 4,5 5 5)"),
628 ba::tuple_list_of(3,3,3)(4,4,4)(5,5,5)
631 #ifdef BOOST_GEOMETRY_TEST_DEBUG
632 std::cout
<< std::endl
<< std::endl
<< std::endl
;
637 //======================================================================
638 //======================================================================
641 BOOST_AUTO_TEST_CASE( test_multilinestring_point_iterator
)
643 #ifdef BOOST_GEOMETRY_TEST_DEBUG
644 std::cout
<< "*** MULTILINESTRING ***" << std::endl
;
647 typedef tuple_multi_point_type TMP
;
648 typedef multi_linestring_type ML
;
650 typedef test_point_iterator_of_geometry
<ML
, TMP
> tester
;
652 tester::apply(from_wkt
<ML
>("MULTILINESTRING()"),
656 tester::apply(from_wkt
<ML
>("MULTILINESTRING(())"),
660 tester::apply(from_wkt
<ML
>("MULTILINESTRING((),(),())"),
664 tester::apply(from_wkt
<ML
>("MULTILINESTRING((1 1,2 2,3 3),(3 3,4 4,5 5),(6 6))"),
665 ba::tuple_list_of(1,1)(2,2)(3,3)(3,3)(4,4)(5,5)(6,6)
668 tester::apply(from_wkt
<ML
>("MULTILINESTRING((),(),(1 1,2 2,3 3),(),(),(3 3,4 4,5 5),(),(6 6),(),(),())"),
669 ba::tuple_list_of(1,1)(2,2)(3,3)(3,3)(4,4)(5,5)(6,6)
672 #ifdef BOOST_GEOMETRY_TEST_DEBUG
673 std::cout
<< std::endl
<< std::endl
;
678 //======================================================================
679 //======================================================================
682 BOOST_AUTO_TEST_CASE( test_multipolygon_point_iterator
)
684 #ifdef BOOST_GEOMETRY_TEST_DEBUG
685 std::cout
<< "*** MULTIPOLYGON ***" << std::endl
;
688 typedef tuple_multi_point_type TMP
;
689 typedef multi_polygon_type MPL
;
691 typedef test_point_iterator_of_geometry
<MPL
, TMP
> tester
;
693 tester::apply(from_wkt
<MPL
>("MULTIPOLYGON()"),
697 tester::apply(from_wkt
<MPL
>("MULTIPOLYGON( () )"),
701 tester::apply(from_wkt
<MPL
>("MULTIPOLYGON( (()) )"),
705 tester::apply(from_wkt
<MPL
>("MULTIPOLYGON( ((),()) )"),
709 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)))"),
710 ba::tuple_list_of(3,3)(4,4)(5,5)(6,6)(7,7)(8,8)(9,9)\
711 (1,1)(2,2)(10,10)(11,11)(12,12)
714 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),()))"),
715 ba::tuple_list_of(3,3)(4,4)(5,5)(6,6)(7,7)(8,8)(9,9)\
716 (1,1)(2,2)(10,10)(11,11)(12,12)(13,13)
719 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),()),((),(),()))"),
720 ba::tuple_list_of(3,3)(4,4)(5,5)(6,6)(7,7)(8,8)(9,9)\
721 (1,1)(2,2)(10,10)(11,11)(12,12)(13,13)
724 #ifdef BOOST_GEOMETRY_TEST_DEBUG
725 std::cout
<< std::endl
<< std::endl
;
730 //======================================================================
731 //======================================================================
734 BOOST_AUTO_TEST_CASE( test_multipoint_of_point_pointers
)
736 #ifdef BOOST_GEOMETRY_TEST_DEBUG
737 std::cout
<< "*** MULTIPOINT OF POINT POINTERS ***" << std::endl
;
740 typedef tuple_multi_point_type TMP
;
741 typedef vector_as_multipoint
<test::test_point_xy
*> MP
;
744 for (int i
= 1; i
< 10; i
++)
746 test::test_point_xy
* p
= new test::test_point_xy
;
749 multipoint
.push_back(p
);
752 test::test_point_xy
* zero
= new test::test_point_xy
;
756 typedef test_point_iterator_of_geometry
<MP
, TMP
> tester
;
758 tester::apply(multipoint
,
759 ba::tuple_list_of(1,-1)(2,-2)(3,-3)(4,-4)(5,-5)(6,-6)\
764 for (unsigned int i
= 0; i
< multipoint
.size(); i
++)
766 delete multipoint
[i
];
772 //======================================================================
773 //======================================================================
776 BOOST_AUTO_TEST_CASE( test_linestring_of_point_pointers
)
778 #ifdef BOOST_GEOMETRY_TEST_DEBUG
779 std::cout
<< "*** LINESTRING OF POINT POINTERS ***" << std::endl
;
782 typedef tuple_multi_point_type TMP
;
783 typedef vector_as_linestring
<test::test_point_xy
*> L
;
786 for (int i
= 1; i
< 10; i
++)
788 test::test_point_xy
* p
= new test::test_point_xy
;
791 linestring
.push_back(p
);
794 test::test_point_xy
* zero
= new test::test_point_xy
;
798 typedef test_point_iterator_of_geometry
<L
, TMP
> tester
;
800 tester::apply(linestring
,
801 ba::tuple_list_of(1,-1)(2,-2)(3,-3)(4,-4)(5,-5)(6,-6)\
806 for (unsigned int i
= 0; i
< linestring
.size(); i
++)
808 delete linestring
[i
];
814 //======================================================================
815 //======================================================================
818 BOOST_AUTO_TEST_CASE( test_multipoint_copy_on_dereference
)
820 #ifdef BOOST_GEOMETRY_TEST_DEBUG
821 std::cout
<< "*** MULTIPOINT WITH COPY-ON-DEREFERENCE ITERATOR ***"
825 typedef tuple_multi_point_type TMP
;
826 typedef multipoint_copy_on_dereference
<point_type
> MP
;
828 typedef test_point_iterator_of_geometry
830 MP
, TMP
, false // no concept checks
833 // bg::read_wkt does not work for this multipoint type so we have
834 // to initialize the multipoint manually
836 for (int i
= 1; i
< 10; ++i
)
838 multipoint
.push_back(point_type(i
, -i
));
841 tester::apply(multipoint
,
842 // from_wkt<MP>("MULTIPOINT(1 -1,2 -2,3 -3,4 -4,5 -5,6 -6, 7 -7,8 -8,9 -9)"),
843 ba::tuple_list_of(1,-1)(2,-2)(3,-3)(4,-4)(5,-5)(6,-6)\
849 //======================================================================
850 //======================================================================
853 BOOST_AUTO_TEST_CASE( test_linestring_copy_on_dereference
)
855 #ifdef BOOST_GEOMETRY_TEST_DEBUG
856 std::cout
<< "*** LINESTRING WITH COPY-ON-DEREFERENCE ITERATOR ***"
860 typedef tuple_multi_point_type TMP
;
861 typedef linestring_copy_on_dereference
<point_type
> L
;
863 typedef test_point_iterator_of_geometry
865 L
, TMP
, false // no concept checks
868 tester::apply(from_wkt
<L
>("LINESTRING(1 -1,2 -2,3 -3,4 -4,5 -5,6 -6, 7 -7,8 -8,9 -9)"),
869 ba::tuple_list_of(1,-1)(2,-2)(3,-3)(4,-4)(5,-5)(6,-6)\