]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/algorithms/relational_operations/touches/test_touches.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / geometry / test / algorithms / relational_operations / touches / test_touches.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3
4 // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
5
6 // This file was modified by Oracle on 2013, 2015, 2016, 2017.
7 // Modifications copyright (c) 2013-2017 Oracle and/or its affiliates.
8 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
9
10 // Use, modification and distribution is subject to the Boost Software License,
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12 // http://www.boost.org/LICENSE_1_0.txt)
13
14 #ifndef BOOST_GEOMETRY_TEST_TOUCHES_HPP
15 #define BOOST_GEOMETRY_TEST_TOUCHES_HPP
16
17
18 #include <geometry_test_common.hpp>
19
20 #include <boost/geometry/core/ring_type.hpp>
21 #include <boost/geometry/algorithms/touches.hpp>
22 #include <boost/geometry/strategies/strategies.hpp>
23 #include <boost/geometry/geometries/geometries.hpp>
24 #include <boost/geometry/geometries/point_xy.hpp>
25
26 #include <boost/geometry/io/wkt/read.hpp>
27 #include <boost/variant/variant.hpp>
28
29
30 struct no_strategy {};
31
32 template <typename Geometry1, typename Geometry2, typename Strategy>
33 void check_touches(Geometry1 const& geometry1,
34 Geometry2 const& geometry2,
35 std::string const& wkt1,
36 std::string const& wkt2,
37 bool expected,
38 Strategy const& strategy)
39 {
40 bool detected = bg::touches(geometry1, geometry2, strategy);
41
42 BOOST_CHECK_MESSAGE(detected == expected,
43 "touches: " << wkt1
44 << " with " << wkt2
45 << " -> Expected: " << expected
46 << " detected: " << detected);
47
48 detected = bg::touches(geometry2, geometry1, strategy);
49
50 BOOST_CHECK_MESSAGE(detected == expected,
51 "touches: " << wkt2
52 << " with " << wkt1
53 << " -> Expected: " << expected
54 << " detected: " << detected);
55 }
56
57 template <typename Geometry1, typename Geometry2>
58 void check_touches(Geometry1 const& geometry1,
59 Geometry2 const& geometry2,
60 std::string const& wkt1,
61 std::string const& wkt2,
62 bool expected,
63 no_strategy = no_strategy())
64 {
65 bool detected = bg::touches(geometry1, geometry2);
66
67 BOOST_CHECK_MESSAGE(detected == expected,
68 "touches: " << wkt1
69 << " with " << wkt2
70 << " -> Expected: " << expected
71 << " detected: " << detected);
72
73 detected = bg::touches(geometry2, geometry1);
74
75 BOOST_CHECK_MESSAGE(detected == expected,
76 "touches: " << wkt2
77 << " with " << wkt1
78 << " -> Expected: " << expected
79 << " detected: " << detected);
80 }
81
82 template <typename Geometry1, typename Geometry2>
83 void test_touches(std::string const& wkt1,
84 std::string const& wkt2, bool expected)
85 {
86 Geometry1 geometry1;
87 Geometry2 geometry2;
88
89 bg::read_wkt(wkt1, geometry1);
90 bg::read_wkt(wkt2, geometry2);
91
92 boost::variant<Geometry1> v1(geometry1);
93 boost::variant<Geometry2> v2(geometry2);
94
95 typedef typename bg::strategy::relate::services::default_strategy
96 <
97 Geometry1, Geometry2
98 >::type strategy_type;
99
100 check_touches(geometry1, geometry2, wkt1, wkt2, expected, no_strategy());
101 check_touches(geometry1, geometry2, wkt1, wkt2, expected, strategy_type());
102 check_touches(v1, geometry2, wkt1, wkt2, expected, no_strategy());
103 check_touches(geometry1, v2, wkt1, wkt2, expected, no_strategy());
104 check_touches(v1, v2, wkt1, wkt2, expected, no_strategy());
105 }
106
107 template <typename Geometry1, typename Geometry2>
108 void test_geometry(std::string const& wkt1,
109 std::string const& wkt2,
110 bool expected)
111 {
112 test_touches<Geometry1, Geometry2>(wkt1, wkt2, expected);
113 }
114
115
116 template <typename Geometry>
117 void check_self_touches(Geometry const& geometry,
118 std::string const& wkt,
119 bool expected)
120 {
121 bool detected = bg::touches(geometry);
122
123 BOOST_CHECK_MESSAGE(detected == expected,
124 "touches: " << wkt
125 << " -> Expected: " << expected
126 << " detected: " << detected);
127 }
128
129 template <typename Geometry>
130 void test_self_touches(std::string const& wkt, bool expected)
131 {
132 Geometry geometry;
133 bg::read_wkt(wkt, geometry);
134 boost::variant<Geometry> v(geometry);
135
136 check_self_touches(geometry, wkt, expected);
137 check_self_touches(v, wkt, expected);
138 }
139
140
141
142 #endif