]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/geometry/algorithms/detail/equals/interface.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / geometry / algorithms / detail / equals / interface.hpp
CommitLineData
b32b8144
FG
1// Boost.Geometry (aka GGL, Generic Geometry Library)
2
3// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
4// Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
5// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
6// Copyright (c) 2014-2015 Adam Wulkiewicz, Lodz, Poland.
7
92f5a8d4
TL
8// This file was modified by Oracle on 2014, 2015, 2016, 2017, 2019.
9// Modifications copyright (c) 2014-2019 Oracle and/or its affiliates.
b32b8144
FG
10
11// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
12// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
13
14// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
15// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
16
17// Use, modification and distribution is subject to the Boost Software License,
18// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
19// http://www.boost.org/LICENSE_1_0.txt)
20
21#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_EQUALS_INTERFACE_HPP
22#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_EQUALS_INTERFACE_HPP
23
24
25#include <cstddef>
26
27#include <boost/variant/apply_visitor.hpp>
28#include <boost/variant/static_visitor.hpp>
29#include <boost/variant/variant_fwd.hpp>
30
31#include <boost/geometry/core/coordinate_dimension.hpp>
32#include <boost/geometry/core/reverse_dispatch.hpp>
33
34#include <boost/geometry/geometries/concepts/check.hpp>
35
36#include <boost/geometry/algorithms/not_implemented.hpp>
37
38#include <boost/geometry/strategies/default_strategy.hpp>
39#include <boost/geometry/strategies/relate.hpp>
40
41
42namespace boost { namespace geometry
43{
44
45#ifndef DOXYGEN_NO_DISPATCH
46namespace dispatch
47{
48
49template
50<
51 typename Geometry1,
52 typename Geometry2,
53 typename Tag1 = typename tag<Geometry1>::type,
54 typename Tag2 = typename tag<Geometry2>::type,
92f5a8d4
TL
55 typename CastedTag1 = typename tag_cast<Tag1, pointlike_tag, linear_tag, areal_tag>::type,
56 typename CastedTag2 = typename tag_cast<Tag2, pointlike_tag, linear_tag, areal_tag>::type,
b32b8144
FG
57 std::size_t DimensionCount = dimension<Geometry1>::type::value,
58 bool Reverse = reverse_dispatch<Geometry1, Geometry2>::type::value
59>
60struct equals: not_implemented<Tag1, Tag2>
61{};
62
63
64// If reversal is needed, perform it
65template
66<
67 typename Geometry1, typename Geometry2,
68 typename Tag1, typename Tag2,
92f5a8d4 69 typename CastedTag1, typename CastedTag2,
b32b8144
FG
70 std::size_t DimensionCount
71>
92f5a8d4
TL
72struct equals<Geometry1, Geometry2, Tag1, Tag2, CastedTag1, CastedTag2, DimensionCount, true>
73 : equals<Geometry2, Geometry1, Tag2, Tag1, CastedTag2, CastedTag1, DimensionCount, false>
b32b8144
FG
74{
75 template <typename Strategy>
76 static inline bool apply(Geometry1 const& g1, Geometry2 const& g2, Strategy const& strategy)
77 {
78 return equals
79 <
80 Geometry2, Geometry1,
81 Tag2, Tag1,
92f5a8d4 82 CastedTag2, CastedTag1,
b32b8144
FG
83 DimensionCount,
84 false
85 >::apply(g2, g1, strategy);
86 }
87};
88
89
90} // namespace dispatch
91#endif // DOXYGEN_NO_DISPATCH
92
93
94namespace resolve_strategy
95{
96
97struct equals
98{
99 template <typename Geometry1, typename Geometry2, typename Strategy>
100 static inline bool apply(Geometry1 const& geometry1,
101 Geometry2 const& geometry2,
102 Strategy const& strategy)
103 {
104 return dispatch::equals
105 <
106 Geometry1, Geometry2
107 >::apply(geometry1, geometry2, strategy);
108 }
109
110 template <typename Geometry1, typename Geometry2>
111 static inline bool apply(Geometry1 const& geometry1,
112 Geometry2 const& geometry2,
113 default_strategy)
114 {
115 typedef typename strategy::relate::services::default_strategy
116 <
117 Geometry1,
118 Geometry2
119 >::type strategy_type;
120
121 return dispatch::equals
122 <
123 Geometry1, Geometry2
124 >::apply(geometry1, geometry2, strategy_type());
125 }
126};
127
128} // namespace resolve_strategy
129
130
131namespace resolve_variant {
132
133template <typename Geometry1, typename Geometry2>
134struct equals
135{
136 template <typename Strategy>
137 static inline bool apply(Geometry1 const& geometry1,
138 Geometry2 const& geometry2,
139 Strategy const& strategy)
140 {
141 concepts::check_concepts_and_equal_dimensions
142 <
143 Geometry1 const,
144 Geometry2 const
145 >();
146
147 return resolve_strategy::equals
148 ::apply(geometry1, geometry2, strategy);
149 }
150};
151
152template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Geometry2>
153struct equals<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Geometry2>
154{
155 template <typename Strategy>
156 struct visitor: static_visitor<bool>
157 {
158 Geometry2 const& m_geometry2;
159 Strategy const& m_strategy;
160
161 visitor(Geometry2 const& geometry2, Strategy const& strategy)
162 : m_geometry2(geometry2)
163 , m_strategy(strategy)
164 {}
165
166 template <typename Geometry1>
167 inline bool operator()(Geometry1 const& geometry1) const
168 {
169 return equals<Geometry1, Geometry2>
170 ::apply(geometry1, m_geometry2, m_strategy);
171 }
172
173 };
174
175 template <typename Strategy>
176 static inline bool apply(
177 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry1,
178 Geometry2 const& geometry2,
179 Strategy const& strategy
180 )
181 {
182 return boost::apply_visitor(visitor<Strategy>(geometry2, strategy), geometry1);
183 }
184};
185
186template <typename Geometry1, BOOST_VARIANT_ENUM_PARAMS(typename T)>
187struct equals<Geometry1, boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
188{
189 template <typename Strategy>
190 struct visitor: static_visitor<bool>
191 {
192 Geometry1 const& m_geometry1;
193 Strategy const& m_strategy;
194
195 visitor(Geometry1 const& geometry1, Strategy const& strategy)
196 : m_geometry1(geometry1)
197 , m_strategy(strategy)
198 {}
199
200 template <typename Geometry2>
201 inline bool operator()(Geometry2 const& geometry2) const
202 {
203 return equals<Geometry1, Geometry2>
204 ::apply(m_geometry1, geometry2, m_strategy);
205 }
206
207 };
208
209 template <typename Strategy>
210 static inline bool apply(
211 Geometry1 const& geometry1,
212 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry2,
213 Strategy const& strategy
214 )
215 {
216 return boost::apply_visitor(visitor<Strategy>(geometry1, strategy), geometry2);
217 }
218};
219
220template <
221 BOOST_VARIANT_ENUM_PARAMS(typename T1),
222 BOOST_VARIANT_ENUM_PARAMS(typename T2)
223>
224struct equals<
225 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T1)>,
226 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T2)>
227>
228{
229 template <typename Strategy>
230 struct visitor: static_visitor<bool>
231 {
232 Strategy const& m_strategy;
233
234 visitor(Strategy const& strategy)
235 : m_strategy(strategy)
236 {}
237
238 template <typename Geometry1, typename Geometry2>
239 inline bool operator()(Geometry1 const& geometry1,
240 Geometry2 const& geometry2) const
241 {
242 return equals<Geometry1, Geometry2>
243 ::apply(geometry1, geometry2, m_strategy);
244 }
245
246 };
247
248 template <typename Strategy>
249 static inline bool apply(
250 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T1)> const& geometry1,
251 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T2)> const& geometry2,
252 Strategy const& strategy
253 )
254 {
255 return boost::apply_visitor(visitor<Strategy>(strategy), geometry1, geometry2);
256 }
257};
258
259} // namespace resolve_variant
260
261
262/*!
263\brief \brief_check{are spatially equal}
264\details \details_check12{equals, is spatially equal}. Spatially equal means
265 that the same point set is included. A box can therefore be spatially equal
266 to a ring or a polygon, or a linestring can be spatially equal to a
267 multi-linestring or a segment. This only works theoretically, not all
268 combinations are implemented yet.
269\ingroup equals
270\tparam Geometry1 \tparam_geometry
271\tparam Geometry2 \tparam_geometry
272\tparam Strategy \tparam_strategy{Equals}
273\param geometry1 \param_geometry
274\param geometry2 \param_geometry
275\param strategy \param_strategy{equals}
276\return \return_check2{are spatially equal}
277
278\qbk{distinguish,with strategy}
279\qbk{[include reference/algorithms/equals.qbk]}
280 */
281template <typename Geometry1, typename Geometry2, typename Strategy>
282inline bool equals(Geometry1 const& geometry1,
283 Geometry2 const& geometry2,
284 Strategy const& strategy)
285{
286 return resolve_variant::equals
287 <
288 Geometry1, Geometry2
289 >::apply(geometry1, geometry2, strategy);
290}
291
292
293/*!
294\brief \brief_check{are spatially equal}
295\details \details_check12{equals, is spatially equal}. Spatially equal means
296 that the same point set is included. A box can therefore be spatially equal
297 to a ring or a polygon, or a linestring can be spatially equal to a
298 multi-linestring or a segment. This only works theoretically, not all
299 combinations are implemented yet.
300\ingroup equals
301\tparam Geometry1 \tparam_geometry
302\tparam Geometry2 \tparam_geometry
303\param geometry1 \param_geometry
304\param geometry2 \param_geometry
305\return \return_check2{are spatially equal}
306
307\qbk{[include reference/algorithms/equals.qbk]}
308 */
309template <typename Geometry1, typename Geometry2>
310inline bool equals(Geometry1 const& geometry1, Geometry2 const& geometry2)
311{
312 return resolve_variant::equals<Geometry1, Geometry2>
313 ::apply(geometry1, geometry2, default_strategy());
314}
315
316
317}} // namespace boost::geometry
318
319
320#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_EQUALS_INTERFACE_HPP
321