]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/algorithms/disjoint/test_disjoint.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / geometry / test / algorithms / disjoint / test_disjoint.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3
4 // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
6 // Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
7
8 // This file was modified by Oracle on 2017-2021.
9 // Modifications copyright (c) 2017-2021 Oracle and/or its affiliates.
10 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
11
12 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
13 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
14
15 // Use, modification and distribution is subject to the Boost Software License,
16 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
17 // http://www.boost.org/LICENSE_1_0.txt)
18
19 #ifndef BOOST_GEOMETRY_TEST_DISJOINT_HPP
20 #define BOOST_GEOMETRY_TEST_DISJOINT_HPP
21
22 #include <iostream>
23 #include <string>
24 #include <boost/variant/variant.hpp>
25
26 #include <geometry_test_common.hpp>
27
28 #include <boost/geometry/algorithms/disjoint.hpp>
29 #include <boost/geometry/geometries/geometry_collection.hpp>
30 #include <boost/geometry/io/wkt/read.hpp>
31
32
33 template <typename Geometry1, typename Geometry2, typename Strategy>
34 bool call_disjoint(Geometry1 const& geometry1,
35 Geometry2 const& geometry2,
36 Strategy const& strategy)
37 {
38 return bg::disjoint(geometry1, geometry2, strategy);
39 }
40
41 template <typename Geometry1, typename Geometry2>
42 bool call_disjoint(Geometry1 const& geometry1,
43 Geometry2 const& geometry2,
44 bg::default_strategy const&)
45 {
46 return bg::disjoint(geometry1, geometry2);
47 }
48
49 template <typename G1, typename G2, typename Strategy>
50 void check_disjoint(std::string const& id,
51 std::string const& wkt1,
52 std::string const& wkt2,
53 G1 const& g1,
54 G2 const& g2,
55 bool expected,
56 Strategy const& strategy)
57 {
58 bool detected = call_disjoint(g1, g2, strategy);
59 if (id.empty())
60 {
61 BOOST_CHECK_MESSAGE(detected == expected,
62 "disjoint: " << wkt1 << " and " << wkt2
63 << " -> Expected: " << expected
64 << " detected: " << detected);
65 }
66 else
67 {
68 BOOST_CHECK_MESSAGE(detected == expected,
69 "disjoint: " << id
70 << " -> Expected: " << expected
71 << " detected: " << detected);
72 }
73 }
74
75 template <typename G1, typename G2>
76 void test_disjoint(std::string const& id,
77 std::string const& wkt1,
78 std::string const& wkt2,
79 bool expected)
80 {
81 G1 g1;
82 bg::read_wkt(wkt1, g1);
83
84 G2 g2;
85 bg::read_wkt(wkt2, g2);
86
87 boost::variant<G1> v1(g1);
88 boost::variant<G2> v2(g2);
89
90 bg::model::geometry_collection<boost::variant<G1>> gc1{v1};
91 bg::model::geometry_collection<boost::variant<G2>> gc2{v2};
92
93 using strategy_t = typename bg::strategy::disjoint::services::default_strategy<G1, G2>::type;
94 using strategies_t = typename bg::strategies::relate::services::default_strategy<G1, G2>::type;
95
96 check_disjoint(id, wkt1, wkt2, g1, g2, expected, bg::default_strategy());
97 check_disjoint(id, wkt1, wkt2, g1, g2, expected, strategy_t());
98 check_disjoint(id, wkt1, wkt2, g1, g2, expected, strategies_t());
99
100 check_disjoint(id, wkt1, wkt2, v1, v2, expected, bg::default_strategy());
101 check_disjoint(id, wkt1, wkt2, v1, v2, expected, strategy_t());
102 check_disjoint(id, wkt1, wkt2, v1, v2, expected, strategies_t());
103
104 check_disjoint(id, wkt1, wkt2, gc1, gc2, expected, bg::default_strategy());
105 check_disjoint(id, wkt1, wkt2, gc1, gc2, expected, strategy_t());
106 check_disjoint(id, wkt1, wkt2, gc1, gc2, expected, strategies_t());
107
108 check_disjoint(id, wkt1, wkt2, v1, g2, expected, bg::default_strategy());
109 check_disjoint(id, wkt1, wkt2, v1, g2, expected, strategy_t());
110 check_disjoint(id, wkt1, wkt2, v1, g2, expected, strategies_t());
111 check_disjoint(id, wkt1, wkt2, g1, v2, expected, bg::default_strategy());
112 check_disjoint(id, wkt1, wkt2, g1, v2, expected, strategy_t());
113 check_disjoint(id, wkt1, wkt2, g1, v2, expected, strategies_t());
114
115 check_disjoint(id, wkt1, wkt2, gc1, g2, expected, bg::default_strategy());
116 check_disjoint(id, wkt1, wkt2, gc1, g2, expected, strategy_t());
117 check_disjoint(id, wkt1, wkt2, gc1, g2, expected, strategies_t());
118 check_disjoint(id, wkt1, wkt2, g1, gc2, expected, bg::default_strategy());
119 check_disjoint(id, wkt1, wkt2, g1, gc2, expected, strategy_t());
120 check_disjoint(id, wkt1, wkt2, g1, gc2, expected, strategies_t());
121
122 check_disjoint(id, wkt1, wkt2, gc1, v2, expected, bg::default_strategy());
123 check_disjoint(id, wkt1, wkt2, gc1, v2, expected, strategy_t());
124 check_disjoint(id, wkt1, wkt2, gc1, v2, expected, strategies_t());
125 check_disjoint(id, wkt1, wkt2, v1, gc2, expected, bg::default_strategy());
126 check_disjoint(id, wkt1, wkt2, v1, gc2, expected, strategy_t());
127 check_disjoint(id, wkt1, wkt2, v1, gc2, expected, strategies_t());
128 }
129
130 template <typename G1, typename G2>
131 void test_geometry(std::string const& wkt1,
132 std::string const& wkt2,
133 bool expected)
134 {
135 test_disjoint<G1, G2>("", wkt1, wkt2, expected);
136 }
137
138 #endif // BOOST_GEOMETRY_TEST_DISJOINT_HPP