1 // Boost.Geometry (aka GGL, Generic Geometry Library)
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.
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
12 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
13 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
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)
19 #ifndef BOOST_GEOMETRY_TEST_DISJOINT_HPP
20 #define BOOST_GEOMETRY_TEST_DISJOINT_HPP
24 #include <boost/variant/variant.hpp>
26 #include <geometry_test_common.hpp>
28 #include <boost/geometry/algorithms/disjoint.hpp>
29 #include <boost/geometry/geometries/geometry_collection.hpp>
30 #include <boost/geometry/io/wkt/read.hpp>
33 template <typename Geometry1, typename Geometry2, typename Strategy>
34 bool call_disjoint(Geometry1 const& geometry1,
35 Geometry2 const& geometry2,
36 Strategy const& strategy)
38 return bg::disjoint(geometry1, geometry2, strategy);
41 template <typename Geometry1, typename Geometry2>
42 bool call_disjoint(Geometry1 const& geometry1,
43 Geometry2 const& geometry2,
44 bg::default_strategy const&)
46 return bg::disjoint(geometry1, geometry2);
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,
56 Strategy const& strategy)
58 bool detected = call_disjoint(g1, g2, strategy);
61 BOOST_CHECK_MESSAGE(detected == expected,
62 "disjoint: " << wkt1 << " and " << wkt2
63 << " -> Expected: " << expected
64 << " detected: " << detected);
68 BOOST_CHECK_MESSAGE(detected == expected,
70 << " -> Expected: " << expected
71 << " detected: " << detected);
75 template <typename G1, typename G2>
76 void test_disjoint(std::string const& id,
77 std::string const& wkt1,
78 std::string const& wkt2,
82 bg::read_wkt(wkt1, g1);
85 bg::read_wkt(wkt2, g2);
87 boost::variant<G1> v1(g1);
88 boost::variant<G2> v2(g2);
90 bg::model::geometry_collection<boost::variant<G1>> gc1{v1};
91 bg::model::geometry_collection<boost::variant<G2>> gc2{v2};
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;
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());
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());
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());
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());
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());
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());
130 template <typename G1, typename G2>
131 void test_geometry(std::string const& wkt1,
132 std::string const& wkt2,
135 test_disjoint<G1, G2>("", wkt1, wkt2, expected);
138 #endif // BOOST_GEOMETRY_TEST_DISJOINT_HPP