1 // Boost.Geometry (aka GGL, Generic Geometry Library)
4 // Copyright (c) 2015, Oracle and/or its affiliates.
6 // Licensed under the Boost Software License version 1.0.
7 // http://www.boost.org/users/license.html
9 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
11 #ifndef BOOST_TEST_MODULE
12 #define BOOST_TEST_MODULE test_equals_on_spheroid
17 #include <boost/test/included/unit_test.hpp>
19 #include "test_equals.hpp"
21 #include <boost/geometry/geometries/geometries.hpp>
23 #include <boost/geometry/core/cs.hpp>
25 namespace bgm
= bg::model
;
27 template <typename P1
, typename P2
= P1
>
28 struct test_point_point
30 static inline void apply(std::string
const& header
)
32 std::string
const str
= header
+ "-";
34 test_geometry
<P1
, P2
>(str
+ "pp_01", "POINT(0 0)", "POINT(0 0)", true);
35 test_geometry
<P1
, P2
>(str
+ "pp_02", "POINT(0 0)", "POINT(10 0)", false);
37 // points whose longitudes differ by 360 degrees
38 test_geometry
<P1
, P2
>(str
+ "pp_03", "POINT(0 0)", "POINT(360 0)", true);
39 test_geometry
<P1
, P2
>(str
+ "pp_04", "POINT(10 0)", "POINT(370 0)", true);
40 test_geometry
<P1
, P2
>(str
+ "pp_05", "POINT(10 0)", "POINT(-350 0)", true);
41 test_geometry
<P1
, P2
>(str
+ "pp_06", "POINT(180 10)", "POINT(-180 10)", true);
42 test_geometry
<P1
, P2
>(str
+ "pp_06a", "POINT(540 10)", "POINT(-540 10)", true);
44 #ifdef BOOST_GEOMETRY_NORMALIZE_LATITUDE
45 test_geometry
<P1
, P2
>(str
+ "pp_06b", "POINT(540 370)", "POINT(-540 -350)", true);
46 test_geometry
<P1
, P2
>(str
+ "pp_06c", "POINT(1260 370)", "POINT(-1260 -350)", true);
47 test_geometry
<P1
, P2
>(str
+ "pp_06d", "POINT(2340 370)", "POINT(-2340 -350)", true);
50 test_geometry
<P1
, P2
>(str
+ "pp_06e", "POINT(-180 10)", "POINT(-540 10)", true);
51 test_geometry
<P1
, P2
>(str
+ "pp_06f", "POINT(180 10)", "POINT(-540 10)", true);
54 test_geometry
<P1
, P2
>(str
+ "pp_07", "POINT(0 90)", "POINT(0 90)", true);
56 #ifdef BOOST_GEOMETRY_NORMALIZE_LATITUDE
57 test_geometry
<P1
, P2
>(str
+ "pp_07a", "POINT(0 450)", "POINT(10 -270)", true);
58 test_geometry
<P1
, P2
>(str
+ "pp_07b", "POINT(0 270)", "POINT(10 90)", false);
59 test_geometry
<P1
, P2
>(str
+ "pp_07c", "POINT(0 -450)", "POINT(10 90)", false);
62 test_geometry
<P1
, P2
>(str
+ "pp_08", "POINT(0 90)", "POINT(10 90)", true);
63 test_geometry
<P1
, P2
>(str
+ "pp_09", "POINT(0 90)", "POINT(0 -90)", false);
64 test_geometry
<P1
, P2
>(str
+ "pp_10", "POINT(0 -90)", "POINT(0 -90)", true);
65 test_geometry
<P1
, P2
>(str
+ "pp_11", "POINT(0 -90)", "POINT(10 -90)", true);
66 test_geometry
<P1
, P2
>(str
+ "pp_11a", "POINT(0 -90)", "POINT(10 90)", false);
67 test_geometry
<P1
, P2
>(str
+ "pp_12", "POINT(0 -90)", "POINT(0 -85)", false);
68 test_geometry
<P1
, P2
>(str
+ "pp_13", "POINT(0 90)", "POINT(0 85)", false);
69 test_geometry
<P1
, P2
>(str
+ "pp_14", "POINT(0 90)", "POINT(10 85)", false);
71 // symmetric wrt prime meridian
72 test_geometry
<P1
, P2
>(str
+ "pp_15", "POINT(-10 45)", "POINT(10 45)", false);
73 test_geometry
<P1
, P2
>(str
+ "pp_16", "POINT(-170 45)", "POINT(170 45)", false);
76 test_geometry
<P1
, P2
>(str
+ "pp_17", "POINT(-10 45)", "POINT(10 -45)", false);
77 test_geometry
<P1
, P2
>(str
+ "pp_18", "POINT(-10 -45)", "POINT(10 45)", false);
78 test_geometry
<P1
, P2
>(str
+ "pp_19", "POINT(10 -135)", "POINT(10 45)", false);
80 #ifdef BOOST_GEOMETRY_NORMALIZE_LATITUDE
81 test_geometry
<P1
, P2
>(str
+ "pp_20", "POINT(190 135)", "POINT(10 45)", true);
82 test_geometry
<P1
, P2
>(str
+ "pp_21", "POINT(190 150)", "POINT(10 30)", true);
83 test_geometry
<P1
, P2
>(str
+ "pp_21a", "POINT(-170 150)", "POINT(10 30)", true);
84 test_geometry
<P1
, P2
>(str
+ "pp_22", "POINT(190 -135)", "POINT(10 -45)", true);
85 test_geometry
<P1
, P2
>(str
+ "pp_23", "POINT(190 -150)", "POINT(10 -30)", true);
86 test_geometry
<P1
, P2
>(str
+ "pp_23a", "POINT(-170 -150)", "POINT(10 -30)", true);
92 template <typename P1
, typename P2
= P1
>
93 struct test_point_point_with_height
95 static inline void apply(std::string
const& header
)
97 std::string
const str
= header
+ "-";
99 test_geometry
<P1
, P2
>(str
+ "pp_01",
104 test_geometry
<P1
, P2
>(str
+ "pp_02",
109 // points whose longitudes differ by 360 degrees
110 test_geometry
<P1
, P2
>(str
+ "pp_03",
115 // points whose longitudes differ by 360 degrees
116 test_geometry
<P1
, P2
>(str
+ "pp_04",
121 test_geometry
<P1
, P2
>(str
+ "pp_05",
129 template <typename P
>
130 void test_segment_segment(std::string
const& header
)
132 typedef bgm::segment
<P
> seg
;
134 std::string
const str
= header
+ "-";
136 test_geometry
<seg
, seg
>(str
+ "ss_01",
137 "SEGMENT(10 0,180 0)",
138 "SEGMENT(10 0,-180 0)",
140 test_geometry
<seg
, seg
>(str
+ "ss_02",
141 "SEGMENT(0 90,180 0)",
142 "SEGMENT(10 90,-180 0)",
144 test_geometry
<seg
, seg
>(str
+ "ss_03",
145 "SEGMENT(0 90,0 -90)",
146 "SEGMENT(10 90,20 -90)",
148 test_geometry
<seg
, seg
>(str
+ "ss_04",
149 "SEGMENT(10 80,10 -80)",
150 "SEGMENT(10 80,20 -80)",
152 test_geometry
<seg
, seg
>(str
+ "ss_05",
153 "SEGMENT(170 10,-170 10)",
154 "SEGMENT(170 10,350 10)",
159 BOOST_AUTO_TEST_CASE( equals_point_point_se
)
161 typedef bg::cs::spherical_equatorial
<bg::degree
> cs_type
;
163 test_point_point
<bgm::point
<int, 2, cs_type
> >::apply("se");
164 test_point_point
<bgm::point
<double, 2, cs_type
> >::apply("se");
165 test_point_point
<bgm::point
<long double, 2, cs_type
> >::apply("se");
170 bgm::point
<double, 2, cs_type
>, bgm::point
<int, 2, cs_type
>
175 bgm::point
<double, 2, cs_type
>, bgm::point
<long double, 2, cs_type
>
178 #if defined(HAVE_TTMATH)
179 test_point_point
<bgm::point
<ttmath_big
, 2, cs_type
> >::apply("se");
183 BOOST_AUTO_TEST_CASE( equals_point_point_with_height_se
)
185 typedef bg::cs::spherical_equatorial
<bg::degree
> cs_type
;
187 test_point_point
<bgm::point
<int, 3, cs_type
> >::apply("seh");
188 test_point_point
<bgm::point
<double, 3, cs_type
> >::apply("seh");
189 test_point_point
<bgm::point
<long double, 3, cs_type
> >::apply("seh");
194 bgm::point
<double, 3, cs_type
>, bgm::point
<int, 3, cs_type
>
199 bgm::point
<double, 3, cs_type
>, bgm::point
<long double, 3, cs_type
>
202 #if defined(HAVE_TTMATH)
203 test_point_point
<bgm::point
<ttmath_big
, 3, cs_type
> >::apply("seh");
207 BOOST_AUTO_TEST_CASE( equals_point_point_geo
)
209 typedef bg::cs::geographic
<bg::degree
> cs_type
;
211 test_point_point
<bgm::point
<int, 2, cs_type
> >::apply("geo");
212 test_point_point
<bgm::point
<double, 2, cs_type
> >::apply("geo");
213 test_point_point
<bgm::point
<long double, 2, cs_type
> >::apply("geo");
218 bgm::point
<double, 2, cs_type
>, bgm::point
<int, 2, cs_type
>
223 bgm::point
<double, 2, cs_type
>, bgm::point
<long double, 2, cs_type
>
226 #if defined(HAVE_TTMATH)
227 test_point_point
<bgm::point
<ttmath_big
, 2, cs_type
> >::apply("geo");
231 BOOST_AUTO_TEST_CASE( equals_segment_segment_se
)
233 typedef bg::cs::spherical_equatorial
<bg::degree
> cs_type
;
235 test_segment_segment
<bgm::point
<int, 2, cs_type
> >("se");
236 test_segment_segment
<bgm::point
<double, 2, cs_type
> >("se");
237 test_segment_segment
<bgm::point
<long double, 2, cs_type
> >("se");
239 #if defined(HAVE_TTMATH)
240 test_segment_segment
<bgm::point
<ttmath_big
, 2, cs_type
> >("se");
244 BOOST_AUTO_TEST_CASE( equals_segment_segment_geo
)
246 typedef bg::cs::geographic
<bg::degree
> cs_type
;
248 test_segment_segment
<bgm::point
<int, 2, cs_type
> >("geo");
249 test_segment_segment
<bgm::point
<double, 2, cs_type
> >("geo");
250 test_segment_segment
<bgm::point
<long double, 2, cs_type
> >("geo");
252 #if defined(HAVE_TTMATH)
253 test_segment_segment
<bgm::point
<ttmath_big
, 2, cs_type
> >("geo");