1 // Boost.Geometry (aka GGL, Generic Geometry Library)
4 // Copyright (c) 2015-2020, Oracle and/or its affiliates.
6 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
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
13 #ifndef BOOST_TEST_MODULE
14 #define BOOST_TEST_MODULE test_expand_on_spheroid
17 #include <boost/test/included/unit_test.hpp>
24 #include <geometry_test_common.hpp>
25 #include <from_wkt.hpp>
27 #include <boost/type_traits/is_same.hpp>
29 #include <boost/geometry/core/coordinate_dimension.hpp>
30 #include <boost/geometry/core/tag.hpp>
31 #include <boost/geometry/core/tags.hpp>
33 #include <boost/geometry/geometries/geometries.hpp>
35 #include <boost/geometry/views/detail/indexed_point_view.hpp>
37 #include <boost/geometry/util/condition.hpp>
39 #include <boost/geometry/io/dsv/write.hpp>
40 #include <boost/geometry/io/wkt/wkt.hpp>
42 #include <boost/geometry/algorithms/assign.hpp>
43 #include <boost/geometry/algorithms/envelope.hpp>
44 #include <boost/geometry/algorithms/expand.hpp>
45 #include <boost/geometry/algorithms/make.hpp>
46 #include <boost/geometry/algorithms/transform.hpp>
48 #include "test_envelope_expand_on_spheroid.hpp"
51 #include <boost/geometry/strategies/envelope/geographic.hpp>
52 #include <boost/geometry/strategies/envelope/spherical.hpp>
53 #include <boost/geometry/strategies/expand/geographic.hpp>
54 #include <boost/geometry/strategies/expand/spherical.hpp>
57 class test_expand_on_spheroid
63 typename Tag
= typename
bg::tag
<Geometry
>::type
67 template <typename OutputStream
>
68 static inline OutputStream
& apply(OutputStream
& os
,
69 Geometry
const& geometry
)
71 os
<< bg::wkt(geometry
);
76 template <typename Segment
>
77 struct write_geometry
<Segment
, bg::segment_tag
>
79 template <typename OutputStream
>
80 static inline OutputStream
& apply(OutputStream
& os
,
81 Segment
const& segment
)
83 os
<< "SEGMENT" << bg::dsv(segment
);
88 template <typename Box
>
89 struct write_geometry
<Box
, bg::box_tag
>
91 template <typename OutputStream
>
92 static inline OutputStream
& apply(OutputStream
& os
,
95 os
<< "BOX" << bg::dsv(box
);
100 template <typename Box
, typename Geometry
>
101 static inline void check_message(bool same_boxes
,
102 std::string
const& case_id
,
103 std::string
const& units_str
,
105 Geometry
const& geometry
,
106 bool expected_are_different
,
107 Box
const& expected1
,
108 Box
const& expected2
,
111 std::ostringstream stream
;
112 stream
<< "case ID: " << case_id
<< ", "
113 << "MBR units: " << units_str
<< "; "
114 << "input box: BOX" << bg::dsv(box
) << ", "
117 write_geometry
<Geometry
>::apply(stream
, geometry
);
119 stream
<< std::setprecision(17);
121 stream
<< "; " << "expected: " << bg::dsv(expected1
);
123 if (expected_are_different
)
125 stream
<< " or: " << bg::dsv(expected2
);
127 stream
<< ", " << "detected: " << bg::dsv(detected
);
129 BOOST_CHECK_MESSAGE(same_boxes
, stream
.str());
133 template <bool Reverse
= false, typename
= void>
136 template <typename Box
, typename Geometry
>
137 static inline void base_test(std::string
const& case_id
,
139 Geometry
const& geometry
,
140 double lon_min1
, double lat_min1
,
142 double lon_max1
, double lat_max1
,
144 double lon_min2
, double lat_min2
,
146 double lon_max2
, double lat_max2
,
150 typedef typename
bg::coordinate_system
153 >::type::units box_units_type
;
155 std::string
const units_str
= units2string
<box_units_type
>();
158 bg::convert(box
, detected
);
159 bg::expand(detected
, geometry
);
161 bool expected_are_different
=
162 (lon_min1
!= lon_min2
) || (lat_min1
!= lat_min2
)
163 || (lon_max1
!= lon_max2
) || (lat_max1
!= lat_max2
);
166 initialize_box
<Box
>::apply(expected1
,
167 lon_min1
, lat_min1
, height_min1
,
168 lon_max1
, lat_max1
, height_max1
);
171 initialize_box
<Box
>::apply(expected2
,
172 lon_min2
, lat_min2
, height_min2
,
173 lon_max2
, lat_max2
, height_max2
);
175 #ifdef BOOST_GEOMETRY_TEST_DEBUG
176 std::cout
<< "input box: BOX" << bg::dsv(box
) << std::endl
;
178 std::cout
<< "geometry: ";
179 write_geometry
<Geometry
>::apply(std::cout
, geometry
);
181 std::cout
<< std::endl
182 << "MBR units: " << units_str
184 << "expected: " << bg::dsv(expected1
);
186 if (expected_are_different
)
188 std::cout
<< " or: " << bg::dsv(expected2
);
191 std::cout
<< std::endl
192 << "detected: " << bg::dsv(detected
)
193 << std::endl
<< std::endl
;
196 = box_equals
<Box
>::apply(detected
, expected1
, tolerance
);
198 if (expected_are_different
)
200 same_boxes
= same_boxes
201 || box_equals
<Box
>::apply(detected
, expected2
, tolerance
);
204 check_message(same_boxes
, case_id
, units_str
,
205 box
, geometry
, expected_are_different
,
206 expected1
, expected2
, detected
);
209 template <typename Box
, typename Geometry
>
210 static inline void apply(std::string
const& case_id
,
212 Geometry
const& geometry
,
213 double lon_min1
, double lat_min1
,
215 double lon_max1
, double lat_max1
,
217 double lon_min2
, double lat_min2
,
219 double lon_max2
, double lat_max2
,
223 typedef other_system_info
225 typename
bg::coordinate_system
<Box
>::type
228 typedef bg::model::box
232 typename
bg::coordinate_type
<Box
>::type
,
233 bg::dimension
<Box
>::value
,
238 #ifdef BOOST_GEOMETRY_TEST_DEBUG
239 std::cout
<< "case ID: " << case_id
240 << std::endl
<< std::endl
;
243 base_test(case_id
, box
, geometry
,
244 lon_min1
, lat_min1
, height_min1
,
245 lon_max1
, lat_max1
, height_max1
,
246 lon_min2
, lat_min2
, height_min2
,
247 lon_max2
, lat_max2
, height_max2
,
250 other_mbr_type other_box
;
252 //if the input box is the special one made from make_inverse
253 //do not convert coordinates
254 if (!is_inverse_spheroidal_coordinates(box
))
256 bg::detail::indexed_point_view
<Box
const, 0> p_min(box
);
257 bg::detail::indexed_point_view
<Box
const, 1> p_max(box
);
259 bg::detail::indexed_point_view
262 > other_min(other_box
);
264 bg::detail::indexed_point_view
267 > other_max(other_box
);
269 bg::transform(p_min
, other_min
);
270 bg::transform(p_max
, other_max
);
272 bg::set
<bg::min_corner
, 0>(other_box
, bg::get
<0, 0>(box
));
273 bg::set
<bg::min_corner
, 1>(other_box
, bg::get
<0, 1>(box
));
274 bg::set
<bg::max_corner
, 0>(other_box
, bg::get
<1, 0>(box
));
275 bg::set
<bg::max_corner
, 1>(other_box
, bg::get
<1, 1>(box
));
278 base_test(case_id
, other_box
, geometry
,
279 other::convert(lon_min1
),
280 other::convert(lat_min1
),
282 other::convert(lon_max1
),
283 other::convert(lat_max1
),
285 other::convert(lon_min2
),
286 other::convert(lat_min2
),
288 other::convert(lon_max2
),
289 other::convert(lat_max2
),
293 #ifdef BOOST_GEOMETRY_TEST_DEBUG
294 std::cout
<< "=================="
295 << std::endl
<< std::endl
;
300 template <typename Dummy
>
301 struct basic_tester
<true, Dummy
>
303 template <typename Box
, typename Geometry
>
304 static inline void apply(std::string
const& case_id
,
306 Geometry
const& geometry
,
307 double lon_min1
, double lat_min1
,
309 double lon_max1
, double lat_max1
,
311 double lon_min2
, double lat_min2
,
313 double lon_max2
, double lat_max2
,
320 >::apply(case_id
, box
, geometry
,
321 lon_min1
, lat_min1
, height_min1
,
322 lon_max1
, lat_max1
, height_max1
,
323 lon_min2
, lat_min2
, height_min1
,
324 lon_max2
, lat_max2
, height_max2
,
327 std::string case_id_r
= case_id
+ "[R]";
332 >::apply(case_id_r
, geometry
, box
,
333 lon_min1
, lat_min1
, height_min1
,
334 lon_max1
, lat_max1
, height_max1
,
335 lon_min2
, lat_min2
, height_min2
,
336 lon_max2
, lat_max2
, height_max2
,
343 template <typename Box
, typename Geometry
>
344 static inline void apply(std::string
const& case_id
,
346 Geometry
const& geometry
,
347 double lon_min1
, double lat_min1
, double height_min1
,
348 double lon_max1
, double lat_max1
, double height_max1
,
349 double lon_min2
, double lat_min2
, double height_min2
,
350 double lon_max2
, double lat_max2
, double height_max2
,
351 double tolerance
= std::numeric_limits
<double>::epsilon())
358 typename
bg::tag
<Geometry
>::type
,
361 >::apply(case_id
, box
, geometry
,
362 lon_min1
, lat_min1
, height_min1
,
363 lon_max1
, lat_max1
, height_max1
,
364 lon_min2
, lat_min2
, height_min2
,
365 lon_max2
, lat_max2
, height_max2
,
369 template <typename Box
, typename Geometry
>
370 static inline void apply(std::string
const& case_id
,
372 Geometry
const& geometry
,
373 double lon_min1
, double lat_min1
,
374 double lon_max1
, double lat_max1
,
375 double lon_min2
, double lat_min2
,
376 double lon_max2
, double lat_max2
,
377 double tolerance
= std::numeric_limits
<double>::epsilon())
379 apply(case_id
, box
, geometry
,
380 lon_min1
, lat_min1
, 0, lon_max1
, lat_max1
, 0,
381 lon_min2
, lat_min2
, 0, lon_max2
, lat_max2
, 0,
385 template <typename Box
, typename Geometry
>
386 static inline void apply(std::string
const& case_id
,
388 Geometry
const& geometry
,
389 double lon_min
, double lat_min
,
390 double lon_max
, double lat_max
,
391 double tolerance
= std::numeric_limits
<double>::epsilon())
393 apply(case_id
, box
, geometry
,
394 lon_min
, lat_min
, 0, lon_max
, lat_max
, 0,
395 lon_min
, lat_min
, 0, lon_max
, lat_max
, 0,
399 template <typename Box
, typename Geometry
>
400 static inline void apply(std::string
const& case_id
,
402 Geometry
const& geometry
,
403 double lon_min
, double lat_min
, double height_min
,
404 double lon_max
, double lat_max
, double height_max
,
405 double tolerance
= std::numeric_limits
<double>::epsilon())
407 apply(case_id
, box
, geometry
,
408 lon_min
, lat_min
, height_min
, lon_max
, lat_max
, height_max
,
409 lon_min
, lat_min
, height_min
, lon_max
, lat_max
, height_max
,
415 template <typename CoordinateSystem
>
416 void test_expand_point()
418 typedef bg::model::point
<double, 2, CoordinateSystem
> point_type
;
419 typedef bg::model::box
<point_type
> B
;
420 typedef point_type G
;
421 typedef test_expand_on_spheroid tester
;
424 from_wkt
<B
>("BOX(0 0,5 5)"),
425 from_wkt
<G
>("POINT(10 10)"),
429 from_wkt
<B
>("BOX(0 0,5 5)"),
430 from_wkt
<G
>("POINT(370 10)"),
434 from_wkt
<B
>("BOX(10 10,10 10)"),
435 from_wkt
<G
>("POINT(20 20)"),
439 from_wkt
<B
>("BOX(10 10,10 10)"),
440 from_wkt
<G
>("POINT(10 20)"),
443 // there are two possible valid longitude ranges:
444 // [10, 190] and [-170, 10]
446 from_wkt
<B
>("BOX(10 10,10 10)"),
447 from_wkt
<G
>("POINT(190 20)"),
450 // there are two possible valid longitude ranges:
451 // [10, 190] and [-170, 10]
452 tester::apply("p05a",
453 from_wkt
<B
>("BOX(10 10,10 10)"),
454 from_wkt
<G
>("POINT(-170 20)"),
459 from_wkt
<B
>("BOX(170 10,175 20)"),
460 from_wkt
<G
>("POINT(-170 15)"),
463 tester::apply("p06a",
464 from_wkt
<B
>("BOX(170 10,175 20)"),
465 from_wkt
<G
>("POINT(-170 -6)"),
468 tester::apply("p06b",
469 from_wkt
<B
>("BOX(170 10,175 20)"),
470 from_wkt
<G
>("POINT(-170 36)"),
473 // point is inside box
475 from_wkt
<B
>("BOX(-30 -45,60 55)"),
476 from_wkt
<G
>("POINT(0 0)"),
479 // point is inside box
480 tester::apply("p07a",
481 from_wkt
<B
>("BOX(-30 -45,60 55)"),
482 from_wkt
<G
>("POINT(360 0)"),
486 from_wkt
<B
>("BOX(-100 -45,-90 55)"),
487 from_wkt
<G
>("POINT(80 60)"),
491 from_wkt
<B
>("BOX(-100 -45,-90 55)"),
492 from_wkt
<G
>("POINT(170 60)"),
495 // point is north pole
497 from_wkt
<B
>("BOX(-100 -45,-90 55)"),
498 from_wkt
<G
>("POINT(-80 90)"),
501 // point is north pole
502 tester::apply("p10a",
503 from_wkt
<B
>("BOX(-100 -45,-90 55)"),
504 from_wkt
<G
>("POINT(170 90)"),
507 tester::apply("p10b",
508 from_wkt
<B
>("BOX(-100 -45,-90 55)"),
509 from_wkt
<G
>("POINT(170 80)"),
514 from_wkt
<B
>("BOX(10 90,20 90)"),
515 from_wkt
<G
>("POINT(15 89)"),
519 tester::apply("p11a",
520 from_wkt
<B
>("BOX(10 -90,20 -90)"),
521 from_wkt
<G
>("POINT(15 89)"),
524 // point is south pole
526 from_wkt
<B
>("BOX(10 80,20 85)"),
527 from_wkt
<G
>("POINT(15 -90)"),
530 // point is south pole
531 tester::apply("p12a",
532 from_wkt
<B
>("BOX(10 80,20 85)"),
533 from_wkt
<G
>("POINT(25 -90)"),
536 // box is north pole and point is south pole
538 from_wkt
<B
>("BOX(10 90,20 90)"),
539 from_wkt
<G
>("POINT(25 -90)"),
542 // box contains north pole and point is south pole
544 from_wkt
<B
>("BOX(10 80,20 90)"),
545 from_wkt
<G
>("POINT(25 -90)"),
548 // box contains south pole and point is north pole
550 from_wkt
<B
>("BOX(10 -90,30 0)"),
551 from_wkt
<G
>("POINT(25 90)"),
554 // box and point are north pole
556 from_wkt
<B
>("BOX(10 90,20 90)"),
557 from_wkt
<G
>("POINT(25 90)"),
560 // box and point are south pole
562 from_wkt
<B
>("BOX(10 -90,20 -90)"),
563 from_wkt
<G
>("POINT(-25 -90)"),
566 // box contains both poles
568 from_wkt
<B
>("BOX(10 -90,10 90)"),
569 from_wkt
<G
>("POINT(10 80)"),
572 // box contains both poles
573 tester::apply("p17a",
574 from_wkt
<B
>("BOX(10 -90,10 90)"),
575 from_wkt
<G
>("POINT(25 80)"),
578 // box contains both poles
580 from_wkt
<B
>("BOX(10 -90,100 90)"),
581 from_wkt
<G
>("POINT(25 80)"),
584 // box contains both poles
585 tester::apply("p18a",
586 from_wkt
<B
>("BOX(10 -90,100 90)"),
587 from_wkt
<G
>("POINT(-175 80)"),
590 // box contains both poles
591 tester::apply("p18b",
592 from_wkt
<B
>("BOX(10 -90,100 90)"),
593 from_wkt
<G
>("POINT(-95 80)"),
596 // box contains both poles and point is north pole
598 from_wkt
<B
>("BOX(10 -90,100 90)"),
599 from_wkt
<G
>("POINT(-95 90)"),
602 // box contains both poles and point is south pole
604 from_wkt
<B
>("BOX(10 -90,100 90)"),
605 from_wkt
<G
>("POINT(-95 -90)"),
609 BOOST_AUTO_TEST_CASE( expand_point
)
611 test_expand_point
<bg::cs::spherical_equatorial
<bg::degree
> >();
612 test_expand_point
<bg::cs::geographic
<bg::degree
> >();
616 template <typename CoordinateSystem
>
617 void test_expand_point_with_height()
619 typedef bg::model::point
<double, 3, CoordinateSystem
> point_type
;
620 typedef bg::model::box
<point_type
> B
;
621 typedef point_type G
;
622 typedef test_expand_on_spheroid tester
;
624 // deactivate this for now
625 tester::apply("ph01",
626 from_wkt
<B
>("BOX(0 0 20,5 5 100)"),
627 from_wkt
<G
>("POINT(10 10 80)"),
628 0, 0, 20, 10, 10, 100);
630 tester::apply("ph02",
631 from_wkt
<B
>("BOX(0 0 20,5 5 100)"),
632 from_wkt
<G
>("POINT(10 10 120)"),
633 0, 0, 20, 10, 10, 120);
635 tester::apply("ph03",
636 from_wkt
<B
>("BOX(0 0 20,5 5 100)"),
637 from_wkt
<G
>("POINT(10 10 5)"),
638 0, 0, 5, 10, 10, 100);
641 BOOST_AUTO_TEST_CASE( expand_point_with_height
)
643 test_expand_point_with_height
<bg::cs::spherical_equatorial
<bg::degree
> >();
644 test_expand_point_with_height
<bg::cs::geographic
<bg::degree
> >();
648 BOOST_AUTO_TEST_CASE( expand_segment_sphere
)
650 typedef bg::cs::spherical_equatorial
<bg::degree
> coordinate_system_type
;
651 typedef bg::model::point
<double, 2, coordinate_system_type
> point_type
;
652 typedef bg::model::box
<point_type
> B
;
653 typedef bg::model::segment
<point_type
> G
;
654 typedef test_expand_on_spheroid tester
;
657 from_wkt
<B
>("BOX(20 20,50 50)"),
658 from_wkt
<G
>("SEGMENT(10 10,40 40)"),
662 from_wkt
<B
>("BOX(20 20,50 50)"),
663 from_wkt
<G
>("SEGMENT(10 10,40 10)"),
667 from_wkt
<B
>("BOX(5 5,50 10)"),
668 from_wkt
<G
>("SEGMENT(40 10,10 10)"),
669 5, 5, 50, 10.34527004614999,
670 4.0 * std::numeric_limits
<double>::epsilon());
672 // segment ending at the north pole
674 from_wkt
<B
>("BOX(5 15,50 50)"),
675 from_wkt
<G
>("SEGMENT(40 45,80 90)"),
678 // segment ending at the north pole
679 tester::apply("s04a",
680 from_wkt
<B
>("BOX(5 15,30 30)"),
681 from_wkt
<G
>("SEGMENT(40 45,80 90)"),
684 // segment starting at the north pole
686 from_wkt
<B
>("BOX(5 15,50 50)"),
687 from_wkt
<G
>("SEGMENT(80 90,40 45)"),
690 // segment starting at the north pole
691 tester::apply("s05a",
692 from_wkt
<B
>("BOX(5 15,30 30)"),
693 from_wkt
<G
>("SEGMENT(80 90,40 45)"),
696 // segment passing through the south pole
698 from_wkt
<B
>("BOX(5 15,30 40)"),
699 from_wkt
<G
>("SEGMENT(-170 -45,10 -30)"),
702 // segment degenerating to the north pole
704 from_wkt
<B
>("BOX(5 15,30 40)"),
705 from_wkt
<G
>("SEGMENT(10 90,20 90)"),
708 // segment degenerating to the south pole
710 from_wkt
<B
>("BOX(5 15,30 40)"),
711 from_wkt
<G
>("SEGMENT(10 -90,20 -90)"),
714 // box degenerating to the south pole
716 from_wkt
<B
>("BOX(10 -90,30 -90)"),
717 from_wkt
<G
>("SEGMENT(10 -30,100 45)"),
720 // box degenerating to the south pole
721 tester::apply("s09a",
722 from_wkt
<B
>("BOX(10 -90,130 -90)"),
723 from_wkt
<G
>("SEGMENT(10 -30,100 45)"),
727 BOOST_AUTO_TEST_CASE( expand_segment_spherical_polar
)
729 typedef bg::cs::spherical
<bg::degree
> coordinate_system_type
;
730 typedef bg::model::point
<double, 2, coordinate_system_type
> point_type
;
731 typedef bg::model::box
<point_type
> B
;
732 typedef bg::model::segment
<point_type
> G
;
733 typedef test_expand_on_spheroid tester
;
736 from_wkt
<B
>("BOX(20 20,50 50)"),
737 from_wkt
<G
>("SEGMENT(10 10,40 20)"),
740 // segment ending at the north pole
742 from_wkt
<B
>("BOX(5 15,50 50)"),
743 from_wkt
<G
>("SEGMENT(40 45,80 0)"),
747 BOOST_AUTO_TEST_CASE( expand_segment_spheroid
)
749 typedef bg::cs::geographic
<bg::degree
> coordinate_system_type
;
750 typedef bg::model::point
<double, 2, coordinate_system_type
> point_type
;
751 typedef bg::model::box
<point_type
> B
;
752 typedef bg::model::segment
<point_type
> G
;
753 typedef test_expand_on_spheroid tester
;
756 from_wkt
<B
>("BOX(20 20,50 50)"),
757 from_wkt
<G
>("SEGMENT(10 10,40 40)"),
761 from_wkt
<B
>("BOX(20 20,50 50)"),
762 from_wkt
<G
>("SEGMENT(10 10,40 10)"),
766 from_wkt
<B
>("BOX(5 5,50 10)"),
767 from_wkt
<G
>("SEGMENT(40 10,10 10)"),
768 5, 5, 50, 10.347587099602029,
769 4.0 * std::numeric_limits
<double>::epsilon());
771 // segment ending at the north pole
773 from_wkt
<B
>("BOX(5 15,50 50)"),
774 from_wkt
<G
>("SEGMENT(40 45,80 90)"),
777 // segment ending at the north pole
778 tester::apply("s04a",
779 from_wkt
<B
>("BOX(5 15,30 30)"),
780 from_wkt
<G
>("SEGMENT(40 45,80 90)"),
783 // segment starting at the north pole
785 from_wkt
<B
>("BOX(5 15,50 50)"),
786 from_wkt
<G
>("SEGMENT(80 90,40 45)"),
789 // segment starting at the north pole
790 tester::apply("s05a",
791 from_wkt
<B
>("BOX(5 15,30 30)"),
792 from_wkt
<G
>("SEGMENT(80 90,40 45)"),
795 // segment passing through the south pole
797 from_wkt
<B
>("BOX(5 15,30 40)"),
798 from_wkt
<G
>("SEGMENT(-170 -45,10 -30)"),
801 // segment degenerating to the north pole
803 from_wkt
<B
>("BOX(5 15,30 40)"),
804 from_wkt
<G
>("SEGMENT(10 90,20 90)"),
807 // segment degenerating to the south pole
809 from_wkt
<B
>("BOX(5 15,30 40)"),
810 from_wkt
<G
>("SEGMENT(10 -90,20 -90)"),
813 // box degenerating to the south pole
815 from_wkt
<B
>("BOX(10 -90,30 -90)"),
816 from_wkt
<G
>("SEGMENT(10 -30,100 45)"),
819 // box degenerating to the south pole
820 tester::apply("s09a",
821 from_wkt
<B
>("BOX(10 -90,130 -90)"),
822 from_wkt
<G
>("SEGMENT(10 -30,100 45)"),
826 BOOST_AUTO_TEST_CASE( expand_segment_sphere_with_height
)
828 typedef bg::cs::spherical_equatorial
<bg::degree
> coordinate_system_type
;
829 typedef bg::model::point
<double, 3, coordinate_system_type
> point_type
;
830 typedef bg::model::box
<point_type
> B
;
831 typedef bg::model::segment
<point_type
> G
;
832 typedef test_expand_on_spheroid tester
;
834 tester::apply("sh01",
835 from_wkt
<B
>("BOX(20 20 100,50 50 1000)"),
836 from_wkt
<G
>("SEGMENT(10 10 150,40 40 500)"),
837 10, 10, 100, 50, 50, 1000);
839 tester::apply("sh02",
840 from_wkt
<B
>("BOX(20 20 100,50 50 1000)"),
841 from_wkt
<G
>("SEGMENT(10 10 60,40 40 1500)"),
842 10, 10, 60, 50, 50, 1500);
844 tester::apply("sh03",
845 from_wkt
<B
>("BOX(20 20 100,50 50 1000)"),
846 from_wkt
<G
>("SEGMENT(10 10 150,40 40 1500)"),
847 10, 10, 100, 50, 50, 1500);
849 tester::apply("sh04",
850 from_wkt
<B
>("BOX(20 20 100,50 50 1000)"),
851 from_wkt
<G
>("SEGMENT(10 10 60,40 40 800)"),
852 10, 10, 60, 50, 50, 1000);
855 BOOST_AUTO_TEST_CASE( expand_segment_spheroid_with_height
)
857 typedef bg::cs::geographic
<bg::degree
> coordinate_system_type
;
858 typedef bg::model::point
<double, 3, coordinate_system_type
> point_type
;
859 typedef bg::model::box
<point_type
> B
;
860 typedef bg::model::segment
<point_type
> G
;
861 typedef test_expand_on_spheroid tester
;
863 tester::apply("sh01",
864 from_wkt
<B
>("BOX(20 20 100,50 50 1000)"),
865 from_wkt
<G
>("SEGMENT(10 10 150,40 40 500)"),
866 10, 10, 100, 50, 50, 1000);
868 tester::apply("sh02",
869 from_wkt
<B
>("BOX(20 20 100,50 50 1000)"),
870 from_wkt
<G
>("SEGMENT(10 10 60,40 40 1500)"),
871 10, 10, 60, 50, 50, 1500);
873 tester::apply("sh03",
874 from_wkt
<B
>("BOX(20 20 100,50 50 1000)"),
875 from_wkt
<G
>("SEGMENT(10 10 150,40 40 1500)"),
876 10, 10, 100, 50, 50, 1500);
878 tester::apply("sh04",
879 from_wkt
<B
>("BOX(20 20 100,50 50 1000)"),
880 from_wkt
<G
>("SEGMENT(10 10 60,40 40 800)"),
881 10, 10, 60, 50, 50, 1000);
885 template <typename CoordinateSystem
>
886 void test_expand_box()
888 typedef bg::model::point
<double, 2, CoordinateSystem
> point_type
;
889 typedef bg::model::box
<point_type
> B
;
890 typedef bg::model::box
<point_type
> G
;
891 typedef test_expand_on_spheroid tester
;
894 from_wkt
<B
>("BOX(11 11,19 19)"),
895 from_wkt
<G
>("BOX(10 10,20 20)"),
899 from_wkt
<B
>("BOX(11 11,29 29)"),
900 from_wkt
<G
>("BOX(10 10,20 20)"),
904 from_wkt
<B
>("BOX(21 21,29 29)"),
905 from_wkt
<G
>("BOX(10 10,20 20)"),
909 from_wkt
<B
>("BOX(150 -10,200 60)"),
910 from_wkt
<G
>("BOX(-175 -20,-150 55)"),
913 tester::apply("b04a",
914 from_wkt
<B
>("BOX(150 -10,200 60)"),
915 from_wkt
<G
>("BOX(-175 -20,-170 55)"),
918 tester::apply("b04b",
919 from_wkt
<B
>("BOX(150 -10,200 60)"),
920 from_wkt
<G
>("BOX(-175 -20,-140 55)"),
924 from_wkt
<B
>("BOX(150 -10,170 60)"),
925 from_wkt
<G
>("BOX(179 -20,535 55)"),
929 from_wkt
<B
>("BOX(150 -10,170 60)"),
930 from_wkt
<G
>("BOX(179 -20,520 55)"),
934 from_wkt
<B
>("BOX(-100 -10,170 60)"),
935 from_wkt
<G
>("BOX(100 -20,400 55)"),
939 from_wkt
<B
>("BOX(-100 -10,100 60)"),
940 from_wkt
<G
>("BOX(150 -20,150 55)"),
944 from_wkt
<B
>("BOX(100 -10,400 60)"),
945 from_wkt
<G
>("BOX(0 -20,0 55)"),
948 // this is a border case:
949 // there are two possible MBRs with longitude intervals:
950 // [100, 430] and [70, 400]
952 from_wkt
<B
>("BOX(100 -10,400 60)"),
953 from_wkt
<G
>("BOX(70 -20,70 55)"),
957 tester::apply("b10a",
958 from_wkt
<B
>("BOX(100 -10,400 60)"),
959 from_wkt
<G
>("BOX(71 -20,71 55)"),
962 tester::apply("b10b",
963 from_wkt
<B
>("BOX(100 -10,400 60)"),
964 from_wkt
<G
>("BOX(69 -20,69 55)"),
968 from_wkt
<B
>("BOX(-90 -10,-90 60)"),
969 from_wkt
<G
>("BOX(90 -20,90 55)"),
972 // first box is the south pole
974 from_wkt
<B
>("BOX(-90 -90,80 -90)"),
975 from_wkt
<G
>("BOX(90 -20,90 55)"),
978 // first box is the south pole
979 tester::apply("b12a",
980 from_wkt
<B
>("BOX(-90 -90,80 -90)"),
981 from_wkt
<G
>("BOX(90 -20,130 55)"),
984 // first box is the north pole
986 from_wkt
<B
>("BOX(-90 90,80 90)"),
987 from_wkt
<G
>("BOX(90 -20,90 55)"),
990 // first box is the north pole
991 tester::apply("b13a",
992 from_wkt
<B
>("BOX(-90 90,80 90)"),
993 from_wkt
<G
>("BOX(90 -20,190 55)"),
996 // both boxes are the north pole
998 from_wkt
<B
>("BOX(-90 90,80 90)"),
999 from_wkt
<G
>("BOX(90 90,190 90)"),
1002 // both boxes are the south pole
1003 tester::apply("b15",
1004 from_wkt
<B
>("BOX(-90 -90,80 -90)"),
1005 from_wkt
<G
>("BOX(90 -90,190 -90)"),
1008 // one box is the south pole and the other the north pole
1009 tester::apply("b16",
1010 from_wkt
<B
>("BOX(-90 -90,80 -90)"),
1011 from_wkt
<G
>("BOX(90 90,190 90)"),
1014 // both boxes contain both poles but at different longitudes
1015 tester::apply("b17",
1016 from_wkt
<B
>("BOX(10 -90,10 90)"),
1017 from_wkt
<G
>("BOX(20 -90,20 90)"),
1020 // both boxes contain both poles but at different longitude ranges
1021 tester::apply("b17",
1022 from_wkt
<B
>("BOX(10 -90,20 90)"),
1023 from_wkt
<G
>("BOX(40 -90,60 90)"),
1027 // first box is a band
1028 tester::apply("b18",
1029 from_wkt
<B
>("BOX(0 10,360 20)"),
1030 from_wkt
<G
>("BOX(-10 -40,20 10)"),
1031 -180, -40, 180, 20);
1033 // first box contains south and north pole and is a band
1034 // (box covers the entire spheroid)
1035 tester::apply("b19",
1036 from_wkt
<B
>("BOX(0 -90,360 90)"),
1037 from_wkt
<G
>("BOX(-10 -40,20 10)"),
1038 -180, -90, 180, 90);
1040 // the envelope of the two boxes is a band
1041 tester::apply("b20",
1042 from_wkt
<B
>("BOX(-180 -40,0 -30)"),
1043 from_wkt
<G
>("BOX(0 -10,180 50)"),
1044 -180, -40, 180, 50);
1046 // the envelope of the two boxes is a band
1047 tester::apply("b20a",
1048 from_wkt
<B
>("BOX(-180 -40,0 -30)"),
1049 from_wkt
<G
>("BOX(0 -10,185 50)"),
1050 -180, -40, 180, 50);
1052 // the envelope of the two boxes is a band
1053 tester::apply("b20b",
1054 from_wkt
<B
>("BOX(-179 -40,0 -30)"),
1055 from_wkt
<G
>("BOX(0 -10,185 50)"),
1056 -180, -40, 180, 50);
1059 BOOST_AUTO_TEST_CASE( expand_box
)
1061 test_expand_box
<bg::cs::spherical_equatorial
<bg::degree
> >();
1062 test_expand_box
<bg::cs::geographic
<bg::degree
> >();
1065 template <typename CoordinateSystem
>
1066 void test_expand_make_inverse()
1068 typedef bg::model::point
<double, 2, CoordinateSystem
> point_type
;
1069 typedef bg::model::box
<point_type
> box_type
;
1070 typedef bg::model::segment
<point_type
> segment_type
;
1071 typedef test_expand_on_spheroid tester
;
1073 box_type box
= boost::geometry::make_inverse
<box_type
>();
1075 tester::apply("bi01",
1077 from_wkt
<box_type
>("BOX(10 10,20 20)"),
1079 tester::apply("bi02",
1081 from_wkt
<point_type
>("POINT(0 0)"),
1083 tester::apply("bi03",
1085 from_wkt
<point_type
>("POINT(5 0)"),
1087 tester::apply("bi04",
1089 from_wkt
<segment_type
>("SEGMENT(5 0,0 5)"),
1093 BOOST_AUTO_TEST_CASE( expand_make_inverse
)
1095 test_expand_make_inverse
<bg::cs::spherical_equatorial
<bg::degree
> >();
1096 test_expand_make_inverse
<bg::cs::geographic
<bg::degree
> >();
1099 template <typename CoordinateSystem
>
1100 void test_expand_box_with_height()
1102 typedef bg::model::point
<double, 3, CoordinateSystem
> point_type
;
1103 typedef bg::model::box
<point_type
> B
;
1104 typedef bg::model::box
<point_type
> G
;
1105 typedef test_expand_on_spheroid tester
;
1107 tester::apply("bh01",
1108 from_wkt
<B
>("BOX(11 11 100,19 19 1000)"),
1109 from_wkt
<G
>("BOX(10 10 200,20 20 800)"),
1110 10, 10, 100, 20, 20, 1000);
1112 tester::apply("bh02",
1113 from_wkt
<B
>("BOX(11 11 200,19 19 1000)"),
1114 from_wkt
<G
>("BOX(10 10 100,20 20 800)"),
1115 10, 10, 100, 20, 20, 1000);
1117 tester::apply("bh03",
1118 from_wkt
<B
>("BOX(11 11 100,19 19 800)"),
1119 from_wkt
<G
>("BOX(10 10 200,20 20 1000)"),
1120 10, 10, 100, 20, 20, 1000);
1122 tester::apply("bh04",
1123 from_wkt
<B
>("BOX(11 11 200,19 19 1000)"),
1124 from_wkt
<G
>("BOX(10 10 100,20 20 800)"),
1125 10, 10, 100, 20, 20, 1000);
1128 BOOST_AUTO_TEST_CASE( expand_box_with_height
)
1130 test_expand_box_with_height
<bg::cs::spherical_equatorial
<bg::degree
> >();
1131 test_expand_box_with_height
<bg::cs::geographic
<bg::degree
> >();