]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/iterators/point_iterator.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / geometry / test / iterators / point_iterator.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3
4 // Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
5
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
9
10 // Licensed under the Boost Software License version 1.0.
11 // http://www.boost.org/users/license.html
12
13
14 #ifndef BOOST_TEST_MODULE
15 #define BOOST_TEST_MODULE test_point_iterator
16 #endif
17
18 #include <cstddef>
19 #include <iostream>
20 #include <string>
21 #include <iterator>
22 #include <algorithm>
23
24 #include <boost/test/included/unit_test.hpp>
25
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>
31
32 #include <boost/geometry/algorithms/equals.hpp>
33 #include <boost/geometry/algorithms/make.hpp>
34 #include <boost/geometry/algorithms/num_points.hpp>
35
36 #include <boost/geometry/core/point_type.hpp>
37
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>
42
43 #include <boost/geometry/io/wkt/wkt.hpp>
44 #include <boost/geometry/io/dsv/write.hpp>
45
46 #include <boost/geometry/iterators/point_iterator.hpp>
47 #include <boost/geometry/iterators/point_reverse_iterator.hpp>
48
49 #include <boost/geometry/policies/compare.hpp>
50
51 #include <boost/geometry/strategies/strategies.hpp>
52
53 #include <boost/geometry/util/condition.hpp>
54
55 #include <test_common/with_pointer.hpp>
56 #include <test_geometries/copy_on_dereference_geometries.hpp>
57
58
59 namespace bg = ::boost::geometry;
60
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
65
66 // multi geometries
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;
71
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;
76
77 template <typename T>
78 struct vector_as_multipoint : std::vector<T> {};
79
80 template <typename T>
81 struct vector_as_linestring : std::vector<T> {};
82
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)
86
87 BOOST_GEOMETRY_REGISTER_MULTI_POINT_TEMPLATED(vector_as_multipoint)
88 BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(vector_as_linestring)
89
90
91
92 template <typename Geometry>
93 inline Geometry from_wkt(std::string const& wkt)
94 {
95 Geometry geometry;
96 bg::read_wkt(wkt, geometry);
97 return geometry;
98 }
99
100
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)
106 {
107 typedef typename std::iterator_traits<InputIt>::value_type value_type;
108 if (first != last)
109 {
110 value_type found = *first++;
111 for (; first != last; )
112 {
113 value_type current = *first++;
114 if (pred(current, found))
115 found = current;
116 }
117 return found;
118 }
119 return boost::none;
120 }
121
122
123 template <typename Iterator>
124 inline std::ostream& print_point_range(std::ostream& os,
125 Iterator first,
126 Iterator beyond,
127 std::string const& header)
128 {
129 os << header << "(";
130 for (Iterator it = first; it != beyond; ++it)
131 {
132 os << " " << bg::dsv(*it);
133 }
134 os << " )";
135 return os;
136 }
137
138
139 template
140 <
141 typename Geometry,
142 bool Enable = true,
143 bool IsConst = std::is_const<Geometry>::value
144 >
145 struct test_iterator_concepts
146 {
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>));
151 BOOST_CONCEPT_ASSERT
152 ((boost_concepts::BidirectionalTraversalConcept<iterator>));
153 };
154
155 template <typename Geometry>
156 struct test_iterator_concepts<Geometry, true, false>
157 : test_iterator_concepts<Geometry, true, true>
158 {
159 typedef bg::point_iterator<Geometry> iterator;
160 BOOST_CONCEPT_ASSERT
161 ((boost::Mutable_BidirectionalIteratorConcept<iterator>));
162 BOOST_CONCEPT_ASSERT
163 ((boost_concepts::WritableIteratorConcept<iterator>));
164 BOOST_CONCEPT_ASSERT
165 ((boost_concepts::SwappableIteratorConcept<iterator>));
166 };
167
168 template <typename Geometry, bool IsConst>
169 struct test_iterator_concepts<Geometry, false, IsConst>
170 {};
171
172
173
174 struct equals
175 {
176 template <typename Iterator>
177 static inline std::size_t number_of_elements(Iterator begin,
178 Iterator end)
179 {
180 std::size_t size = std::distance(begin, end);
181
182 std::size_t num_elems(0);
183 for (Iterator it = begin; it != end; ++it)
184 {
185 ++num_elems;
186 }
187 BOOST_CHECK(size == num_elems);
188
189 num_elems = 0;
190 for (Iterator it = end; it != begin; --it)
191 {
192 ++num_elems;
193 }
194 BOOST_CHECK(size == num_elems);
195
196 return num_elems;
197 }
198
199 template <typename Iterator1, typename Iterator2>
200 static inline bool apply(Iterator1 begin1, Iterator1 end1,
201 Iterator2 begin2, Iterator2 end2)
202 {
203 std::size_t num_points1 = number_of_elements(begin1, end1);
204 std::size_t num_points2 = number_of_elements(begin2, end2);
205
206 if (num_points1 != num_points2)
207 {
208 return false;
209 }
210
211 Iterator1 it1 = begin1;
212 Iterator2 it2 = begin2;
213 for (; it1 != end1; ++it1, ++it2)
214 {
215 if (! bg::equals(*it1, *it2))
216 {
217 return false;
218 }
219 }
220 return true;
221 }
222 };
223
224
225 template <bool Enable = true>
226 struct test_assignment
227 {
228 template <typename Iterator, typename ConstIterator, typename Value>
229 static inline void apply(Iterator it, ConstIterator cit,
230 Value const& value1, Value const& value2)
231 {
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;
238 #endif
239
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));
244
245 *it = 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));
250
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;
257 #endif
258
259 *it = value1;
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));
264
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;
272 #endif
273 }
274 };
275
276 template <>
277 struct test_assignment<false>
278 {
279 template <typename Iterator, typename ConstIterator, typename Value>
280 static inline void apply(Iterator, ConstIterator,
281 Value const&, Value const&)
282 {
283 }
284 };
285
286
287 template
288 <
289 typename Geometry,
290 typename PointRange,
291 bool EnableConceptChecks = true
292 >
293 struct test_point_iterator_of_geometry
294 {
295 typedef typename bg::point_type<Geometry>::type point_type;
296
297 template <typename G>
298 static inline void base_test(G& geometry,
299 PointRange const& point_range,
300 std::string const& header)
301 {
302 typedef bg::point_iterator<G> point_iterator;
303
304 test_iterator_concepts<G, EnableConceptChecks>();
305
306 point_iterator begin = bg::points_begin(geometry);
307 point_iterator end = bg::points_end(geometry);
308
309 BOOST_CHECK(std::size_t(std::distance(begin, end))
310 ==
311 bg::num_points(geometry));
312
313 BOOST_CHECK(equals::apply(begin, end,
314 bg::points_begin(point_range),
315 bg::points_end(point_range))
316 );
317
318 boost::ignore_unused(header);
319
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;
324
325 typedef bg::point_iterator<PointRange const> point_range_iterator;
326
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;
332 #endif
333 }
334
335 template <typename G, bool Enable>
336 struct test_reverse
337 {
338 template <typename Iterator>
339 static inline void apply(Iterator first, Iterator last,
340 G const& geometry)
341 {
342 boost::ignore_unused(geometry);
343
344 std::reverse(first, last);
345 #ifdef BOOST_GEOMETRY_TEST_DEBUG
346 print_point_range(std::cout, first, last, "reversed:\n")
347 << std::endl;
348 std::cout << bg::wkt(geometry) << std::endl;
349 std::cout << std::endl;
350 #endif
351
352 std::reverse(first, last);
353 #ifdef BOOST_GEOMETRY_TEST_DEBUG
354 print_point_range(std::cout, first, last, "re-reversed:\n")
355 << std::endl;
356 std::cout << bg::wkt(geometry) << std::endl;
357 std::cout << std::endl;
358 std::cout << std::endl;
359 #endif
360 }
361 };
362
363 template <typename G>
364 struct test_reverse<G, false>
365 {
366 template <typename Iterator>
367 static inline void apply(Iterator, Iterator, G const&)
368 {
369 }
370 };
371
372 static inline void apply(Geometry geometry,
373 PointRange const& point_range,
374 point_type const& zero_point)
375 {
376 base_test<Geometry>(geometry, point_range, "non-const");
377
378 #ifdef BOOST_GEOMETRY_TEST_DEBUG
379 std::cout << std::endl;
380 #endif
381
382 base_test<Geometry const>(geometry, point_range, "const");
383
384 #ifdef BOOST_GEOMETRY_TEST_DEBUG
385 std::cout << std::endl << std::endl;
386 #endif
387
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;
391
392 point_iterator begin = bg::points_begin(geometry);
393 point_iterator end = bg::points_end(geometry);
394
395 const_point_iterator const_begin = bg::points_begin(geometry);
396 const_point_iterator const_end = bg::points_end(geometry);
397
398 // same for reverse iterator
399 typedef bg::point_reverse_iterator<Geometry> point_reverse_iterator;
400 typedef bg::point_reverse_iterator
401 <
402 Geometry const
403 > const_point_reverse_iterator;
404
405 point_reverse_iterator rbegin = bg::points_rbegin(geometry);
406 point_reverse_iterator rend = bg::points_rend(geometry);
407
408 const_point_reverse_iterator const_rbegin = bg::points_rbegin(geometry);
409 const_point_reverse_iterator const_rend = bg::points_rend(geometry);
410
411 // testing assignment of non-const to const iterator
412 const_begin = begin;
413 const_end = end;
414
415 // testing assignment of non-const to const reverse_iterator
416 const_rbegin = rbegin;
417 const_rend = rend;
418
419 // testing equality/inequality comparison
420 BOOST_CHECK(begin == const_begin);
421 BOOST_CHECK(end == const_end);
422 if (begin != end)
423 {
424 BOOST_CHECK(begin != const_end);
425 BOOST_CHECK(const_begin != end);
426 }
427
428 // testing equality/inequality comparison for reverse_iterator
429 BOOST_CHECK(rbegin == const_rbegin);
430 BOOST_CHECK(rend == const_rend);
431 if (rbegin != rend)
432 {
433 BOOST_CHECK(rbegin != const_rend);
434 BOOST_CHECK(const_rbegin != rend);
435 }
436
437 if (begin != end)
438 {
439 BOOST_CHECK(rbegin != rend);
440
441 point_reverse_iterator rlast(rend);
442 --rlast;
443 BOOST_CHECK(bg::equals(*begin, *rlast));
444
445 point_iterator last(end);
446 --last;
447 BOOST_CHECK(bg::equals(*rbegin, *last));
448 }
449
450 // testing dereferencing/assignment
451
452 bool const is_reference = std::is_reference
453 <
454 typename std::iterator_traits<point_iterator>::reference
455 >::value;
456
457 if (begin != end)
458 {
459 if (BOOST_GEOMETRY_CONDITION(is_reference))
460 {
461 point_type p = *begin;
462 point_type q = zero_point;
463
464 test_assignment<is_reference>::apply(begin, const_begin, p, q);
465
466 *begin = q;
467 test_assignment<is_reference>::apply(begin, const_begin, q, p);
468
469 *begin = p;
470 }
471 }
472
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")
477 << std::endl;
478 std::cout << bg::wkt(geometry) << std::endl;
479 std::cout << std::endl;
480 #endif
481 test_reverse<Geometry, is_reference>::apply(begin, end, geometry);
482
483 typedef typename std::iterator_traits
484 <
485 point_iterator
486 >::value_type point;
487 if (const_begin != const_end)
488 {
489 boost::optional<point>
490 pt_max = max_value(const_begin, const_end, bg::less<point>());
491
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;
495 #endif
496 }
497 #ifdef BOOST_GEOMETRY_TEST_DEBUG
498 std::cout << std::endl;
499 std::cout << std::endl;
500 std::cout << std::endl;
501 #endif
502 }
503
504 static inline void apply(Geometry geometry, PointRange const& point_range)
505 {
506 apply(geometry, point_range, bg::make_zero<point_type>());
507 }
508 };
509
510
511 //======================================================================
512 //======================================================================
513
514
515 BOOST_AUTO_TEST_CASE( test_linestring_point_iterator )
516 {
517 #ifdef BOOST_GEOMETRY_TEST_DEBUG
518 std::cout << "*** LINESTRING ***" << std::endl;
519 #endif
520
521 typedef tuple_multi_point_type TMP;
522 typedef linestring_type L;
523
524 typedef test_point_iterator_of_geometry<L, TMP> tester;
525
526 tester::apply(from_wkt<L>("LINESTRING()"),
527 TMP()
528 );
529
530 tester::apply(from_wkt<L>("LINESTRING(3 3,4 4,5 5)"),
531 TMP{{3,3},{4,4},{5,5}}
532 );
533
534 #ifdef BOOST_GEOMETRY_TEST_DEBUG
535 std::cout << std::endl << std::endl << std::endl;
536 #endif
537 }
538
539
540 //======================================================================
541 //======================================================================
542
543
544 BOOST_AUTO_TEST_CASE( test_polygon_point_iterator )
545 {
546 #ifdef BOOST_GEOMETRY_TEST_DEBUG
547 std::cout << "*** POLYGON ***" << std::endl;
548 #endif
549
550 typedef tuple_multi_point_type TMP;
551 typedef polygon_type P;
552
553 typedef test_point_iterator_of_geometry<P, TMP> tester;
554
555 tester::apply(from_wkt<P>("POLYGON()"),
556 TMP()
557 );
558
559 tester::apply(from_wkt<P>("POLYGON(())"),
560 TMP()
561 );
562
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}}
565 );
566
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}}
569 );
570
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}}
573 );
574
575 #ifdef BOOST_GEOMETRY_TEST_DEBUG
576 std::cout << std::endl << std::endl;
577 #endif
578 }
579
580
581 //======================================================================
582 //======================================================================
583
584
585 BOOST_AUTO_TEST_CASE( test_multipoint_point_iterator )
586 {
587 #ifdef BOOST_GEOMETRY_TEST_DEBUG
588 std::cout << "*** MULTIPOINT ***" << std::endl;
589 #endif
590
591 typedef tuple_multi_point_type TMP;
592 typedef multi_point_type MP;
593
594 typedef test_point_iterator_of_geometry<MP, TMP> tester;
595
596 tester::apply(from_wkt<MP>("MULTIPOINT()"),
597 TMP()
598 );
599
600 tester::apply(from_wkt<MP>("MULTIPOINT(3 3,4 4,5 5)"),
601 TMP{{3,3},{4,4},{5,5}}
602 );
603
604 #ifdef BOOST_GEOMETRY_TEST_DEBUG
605 std::cout << std::endl << std::endl << std::endl;
606 #endif
607 }
608
609
610 //======================================================================
611 //======================================================================
612
613
614 BOOST_AUTO_TEST_CASE( test_multipoint_3d_point_iterator )
615 {
616 #ifdef BOOST_GEOMETRY_TEST_DEBUG
617 std::cout << "*** MULTIPOINT 3D ***" << std::endl;
618 #endif
619
620 typedef tuple_multi_point_type_3d TMP;
621 typedef multi_point_type_3d MP;
622
623 typedef test_point_iterator_of_geometry<MP, TMP> tester;
624
625 tester::apply(from_wkt<MP>("MULTIPOINT()"),
626 TMP()
627 );
628
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}}
631 );
632
633 #ifdef BOOST_GEOMETRY_TEST_DEBUG
634 std::cout << std::endl << std::endl << std::endl;
635 #endif
636 }
637
638
639 //======================================================================
640 //======================================================================
641
642
643 BOOST_AUTO_TEST_CASE( test_multilinestring_point_iterator )
644 {
645 #ifdef BOOST_GEOMETRY_TEST_DEBUG
646 std::cout << "*** MULTILINESTRING ***" << std::endl;
647 #endif
648
649 typedef tuple_multi_point_type TMP;
650 typedef multi_linestring_type ML;
651
652 typedef test_point_iterator_of_geometry<ML, TMP> tester;
653
654 tester::apply(from_wkt<ML>("MULTILINESTRING()"),
655 TMP()
656 );
657
658 tester::apply(from_wkt<ML>("MULTILINESTRING(())"),
659 TMP()
660 );
661
662 tester::apply(from_wkt<ML>("MULTILINESTRING((),(),())"),
663 TMP()
664 );
665
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}}
668 );
669
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}}
672 );
673
674 #ifdef BOOST_GEOMETRY_TEST_DEBUG
675 std::cout << std::endl << std::endl;
676 #endif
677 }
678
679
680 //======================================================================
681 //======================================================================
682
683
684 BOOST_AUTO_TEST_CASE( test_multipolygon_point_iterator )
685 {
686 #ifdef BOOST_GEOMETRY_TEST_DEBUG
687 std::cout << "*** MULTIPOLYGON ***" << std::endl;
688 #endif
689
690 typedef tuple_multi_point_type TMP;
691 typedef multi_polygon_type MPL;
692
693 typedef test_point_iterator_of_geometry<MPL, TMP> tester;
694
695 tester::apply(from_wkt<MPL>("MULTIPOLYGON()"),
696 TMP()
697 );
698
699 tester::apply(from_wkt<MPL>("MULTIPOLYGON( () )"),
700 TMP()
701 );
702
703 tester::apply(from_wkt<MPL>("MULTIPOLYGON( (()) )"),
704 TMP()
705 );
706
707 tester::apply(from_wkt<MPL>("MULTIPOLYGON( ((),()) )"),
708 TMP()
709 );
710
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}}
714 );
715
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}}
719 );
720
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}}
724 );
725
726 #ifdef BOOST_GEOMETRY_TEST_DEBUG
727 std::cout << std::endl << std::endl;
728 #endif
729 }
730
731
732 //======================================================================
733 //======================================================================
734
735
736 BOOST_AUTO_TEST_CASE( test_multipoint_of_point_pointers )
737 {
738 #ifdef BOOST_GEOMETRY_TEST_DEBUG
739 std::cout << "*** MULTIPOINT OF POINT POINTERS ***" << std::endl;
740 #endif
741
742 typedef tuple_multi_point_type TMP;
743 typedef vector_as_multipoint<test::test_point_xy*> MP;
744
745 MP multipoint;
746 for (int i = 1; i < 10; i++)
747 {
748 test::test_point_xy* p = new test::test_point_xy;
749 p->x = i;
750 p->y = -i;
751 multipoint.push_back(p);
752 }
753
754 test::test_point_xy* zero = new test::test_point_xy;
755 zero->x = 0;
756 zero->y = 0;
757
758 typedef test_point_iterator_of_geometry<MP, TMP> tester;
759
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}},
763 zero
764 );
765
766 for (unsigned int i = 0; i < multipoint.size(); i++)
767 {
768 delete multipoint[i];
769 }
770 delete zero;
771 }
772
773
774 //======================================================================
775 //======================================================================
776
777
778 BOOST_AUTO_TEST_CASE( test_linestring_of_point_pointers )
779 {
780 #ifdef BOOST_GEOMETRY_TEST_DEBUG
781 std::cout << "*** LINESTRING OF POINT POINTERS ***" << std::endl;
782 #endif
783
784 typedef tuple_multi_point_type TMP;
785 typedef vector_as_linestring<test::test_point_xy*> L;
786
787 L linestring;
788 for (int i = 1; i < 10; i++)
789 {
790 test::test_point_xy* p = new test::test_point_xy;
791 p->x = i;
792 p->y = -i;
793 linestring.push_back(p);
794 }
795
796 test::test_point_xy* zero = new test::test_point_xy;
797 zero->x = 0;
798 zero->y = 0;
799
800 typedef test_point_iterator_of_geometry<L, TMP> tester;
801
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}},
805 zero
806 );
807
808 for (unsigned int i = 0; i < linestring.size(); i++)
809 {
810 delete linestring[i];
811 }
812 delete zero;
813 }
814
815
816 //======================================================================
817 //======================================================================
818
819
820 BOOST_AUTO_TEST_CASE( test_multipoint_copy_on_dereference )
821 {
822 #ifdef BOOST_GEOMETRY_TEST_DEBUG
823 std::cout << "*** MULTIPOINT WITH COPY-ON-DEREFERENCE ITERATOR ***"
824 << std::endl;
825 #endif
826
827 typedef tuple_multi_point_type TMP;
828 typedef multipoint_copy_on_dereference<point_type> MP;
829
830 typedef test_point_iterator_of_geometry
831 <
832 MP, TMP, false // no concept checks
833 > tester;
834
835 // bg::read_wkt does not work for this multipoint type so we have
836 // to initialize the multipoint manually
837 MP multipoint;
838 for (int i = 1; i < 10; ++i)
839 {
840 multipoint.push_back(point_type(i, -i));
841 }
842
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}}
847 );
848 }
849
850
851 //======================================================================
852 //======================================================================
853
854
855 BOOST_AUTO_TEST_CASE( test_linestring_copy_on_dereference )
856 {
857 #ifdef BOOST_GEOMETRY_TEST_DEBUG
858 std::cout << "*** LINESTRING WITH COPY-ON-DEREFERENCE ITERATOR ***"
859 << std::endl;
860 #endif
861
862 typedef tuple_multi_point_type TMP;
863 typedef linestring_copy_on_dereference<point_type> L;
864
865 typedef test_point_iterator_of_geometry
866 <
867 L, TMP, false // no concept checks
868 > tester;
869
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}}
873 );
874 }