]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/algorithms/detail/relation/interface.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / geometry / algorithms / detail / relation / interface.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
4
5 // This file was modified by Oracle on 2013, 2014, 2015, 2017.
6 // Modifications copyright (c) 2013-2017 Oracle and/or its affiliates.
7
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_ALGORITHMS_DETAIL_RELATION_INTERFACE_HPP
15 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATION_INTERFACE_HPP
16
17
18 #include <boost/geometry/algorithms/detail/relate/interface.hpp>
19
20
21 namespace boost { namespace geometry
22 {
23
24 #ifndef DOXYGEN_NO_DETAIL
25 namespace detail { namespace relate
26 {
27
28 template <typename Geometry1, typename Geometry2>
29 struct result_handler_type<Geometry1, Geometry2, geometry::de9im::matrix, false>
30 {
31 typedef matrix_handler<geometry::de9im::matrix> type;
32 };
33
34
35 }} // namespace detail::relate
36 #endif // DOXYGEN_NO_DETAIL
37
38 namespace resolve_variant
39 {
40
41 template <typename Geometry1, typename Geometry2>
42 struct relation
43 {
44 template <typename Matrix, typename Strategy>
45 static inline Matrix apply(Geometry1 const& geometry1,
46 Geometry2 const& geometry2,
47 Strategy const& strategy)
48 {
49 concepts::check<Geometry1 const>();
50 concepts::check<Geometry2 const>();
51 assert_dimension_equal<Geometry1, Geometry2>();
52
53 typename detail::relate::result_handler_type
54 <
55 Geometry1,
56 Geometry2,
57 Matrix
58 >::type handler;
59
60 resolve_strategy::relate::apply(geometry1, geometry2, handler, strategy);
61
62 return handler.result();
63 }
64 };
65
66 template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Geometry2>
67 struct relation<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Geometry2>
68 {
69 template <typename Matrix, typename Strategy>
70 struct visitor : boost::static_visitor<Matrix>
71 {
72 Geometry2 const& m_geometry2;
73 Strategy const& m_strategy;
74
75 visitor(Geometry2 const& geometry2, Strategy const& strategy)
76 : m_geometry2(geometry2), m_strategy(strategy) {}
77
78 template <typename Geometry1>
79 Matrix operator()(Geometry1 const& geometry1) const
80 {
81 return relation<Geometry1, Geometry2>
82 ::template apply<Matrix>(geometry1, m_geometry2, m_strategy);
83 }
84 };
85
86 template <typename Matrix, typename Strategy>
87 static inline Matrix
88 apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry1,
89 Geometry2 const& geometry2,
90 Strategy const& strategy)
91 {
92 return boost::apply_visitor(visitor<Matrix, Strategy>(geometry2, strategy), geometry1);
93 }
94 };
95
96 template <typename Geometry1, BOOST_VARIANT_ENUM_PARAMS(typename T)>
97 struct relation<Geometry1, boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
98 {
99 template <typename Matrix, typename Strategy>
100 struct visitor : boost::static_visitor<Matrix>
101 {
102 Geometry1 const& m_geometry1;
103 Strategy const& m_strategy;
104
105 visitor(Geometry1 const& geometry1, Strategy const& strategy)
106 : m_geometry1(geometry1), m_strategy(strategy) {}
107
108 template <typename Geometry2>
109 Matrix operator()(Geometry2 const& geometry2) const
110 {
111 return relation<Geometry1, Geometry2>
112 ::template apply<Matrix>(m_geometry1, geometry2, m_strategy);
113 }
114 };
115
116 template <typename Matrix, typename Strategy>
117 static inline Matrix
118 apply(Geometry1 const& geometry1,
119 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry2,
120 Strategy const& strategy)
121 {
122 return boost::apply_visitor(visitor<Matrix, Strategy>(geometry1, strategy), geometry2);
123 }
124 };
125
126 template
127 <
128 BOOST_VARIANT_ENUM_PARAMS(typename T1),
129 BOOST_VARIANT_ENUM_PARAMS(typename T2)
130 >
131 struct relation
132 <
133 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T1)>,
134 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T2)>
135 >
136 {
137 template <typename Matrix, typename Strategy>
138 struct visitor : boost::static_visitor<Matrix>
139 {
140 Strategy const& m_strategy;
141
142 visitor(Strategy const& strategy)
143 : m_strategy(strategy) {}
144
145 template <typename Geometry1, typename Geometry2>
146 Matrix operator()(Geometry1 const& geometry1,
147 Geometry2 const& geometry2) const
148 {
149 return relation<Geometry1, Geometry2>
150 ::template apply<Matrix>(geometry1, geometry2, m_strategy);
151 }
152 };
153
154 template <typename Matrix, typename Strategy>
155 static inline Matrix
156 apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T1)> const& geometry1,
157 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T2)> const& geometry2,
158 Strategy const& strategy)
159 {
160 return boost::apply_visitor(visitor<Matrix, Strategy>(strategy), geometry1, geometry2);
161 }
162 };
163
164 } // namespace resolve_variant
165
166
167 /*!
168 \brief Calculates the relation between a pair of geometries as defined in DE-9IM.
169 \ingroup relation
170 \tparam Geometry1 \tparam_geometry
171 \tparam Geometry2 \tparam_geometry
172 \tparam Strategy \tparam_strategy{Relation}
173 \param geometry1 \param_geometry
174 \param geometry2 \param_geometry
175 \param strategy \param_strategy{relation}
176 \return The DE-9IM matrix expressing the relation between geometries.
177
178 \qbk{distinguish,with strategy}
179 \qbk{[include reference/algorithms/relation.qbk]}
180 */
181 template <typename Geometry1, typename Geometry2, typename Strategy>
182 inline de9im::matrix relation(Geometry1 const& geometry1,
183 Geometry2 const& geometry2,
184 Strategy const& strategy)
185 {
186 return resolve_variant::relation
187 <
188 Geometry1,
189 Geometry2
190 >::template apply<de9im::matrix>(geometry1, geometry2, strategy);
191 }
192
193
194 /*!
195 \brief Calculates the relation between a pair of geometries as defined in DE-9IM.
196 \ingroup relation
197 \tparam Geometry1 \tparam_geometry
198 \tparam Geometry2 \tparam_geometry
199 \param geometry1 \param_geometry
200 \param geometry2 \param_geometry
201 \return The DE-9IM matrix expressing the relation between geometries.
202
203 \qbk{[include reference/algorithms/relation.qbk]}
204 */
205 template <typename Geometry1, typename Geometry2>
206 inline de9im::matrix relation(Geometry1 const& geometry1,
207 Geometry2 const& geometry2)
208 {
209 return resolve_variant::relation
210 <
211 Geometry1,
212 Geometry2
213 >::template apply<de9im::matrix>(geometry1, geometry2, default_strategy());
214 }
215
216
217 }} // namespace boost::geometry
218
219 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_INTERFACE_HPP