1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
6 // Copyright (c) 2014 Samuel Debionne, Grenoble, France.
8 // This file was modified by Oracle on 2014-2021.
9 // Modifications copyright (c) 2014-2021 Oracle and/or its affiliates.
11 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
13 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
14 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
16 // Use, modification and distribution is subject to the Boost Software License,
17 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
18 // http://www.boost.org/LICENSE_1_0.txt)
20 #ifndef BOOST_GEOMETRY_ALGORITHMS_CROSSES_HPP
21 #define BOOST_GEOMETRY_ALGORITHMS_CROSSES_HPP
25 #include <boost/variant/apply_visitor.hpp>
26 #include <boost/variant/static_visitor.hpp>
27 #include <boost/variant/variant_fwd.hpp>
29 #include <boost/geometry/algorithms/relate.hpp>
30 #include <boost/geometry/algorithms/detail/relate/relate_impl.hpp>
31 #include <boost/geometry/core/access.hpp>
32 #include <boost/geometry/geometries/concepts/check.hpp>
33 #include <boost/geometry/strategies/default_strategy.hpp>
34 #include <boost/geometry/strategies/detail.hpp>
35 #include <boost/geometry/strategies/relate/cartesian.hpp>
36 #include <boost/geometry/strategies/relate/geographic.hpp>
37 #include <boost/geometry/strategies/relate/spherical.hpp>
40 namespace boost { namespace geometry
43 #ifndef DOXYGEN_NO_DISPATCH
52 typename Tag1 = typename tag<Geometry1>::type,
53 typename Tag2 = typename tag<Geometry2>::type
56 : detail::relate::relate_impl
58 detail::de9im::static_mask_crosses_type,
65 } // namespace dispatch
66 #endif // DOXYGEN_NO_DISPATCH
69 namespace resolve_strategy
75 bool IsUmbrella = strategies::detail::is_umbrella_strategy<Strategy>::value
79 template <typename Geometry1, typename Geometry2>
80 static inline bool apply(Geometry1 const& geometry1,
81 Geometry2 const& geometry2,
82 Strategy const& strategy)
84 concepts::check<Geometry1 const>();
85 concepts::check<Geometry2 const>();
87 return dispatch::crosses
90 >::apply(geometry1, geometry2, strategy);
94 template <typename Strategy>
95 struct crosses<Strategy, false>
97 template <typename Geometry1, typename Geometry2>
98 static inline bool apply(Geometry1 const& geometry1,
99 Geometry2 const& geometry2,
100 Strategy const& strategy)
102 //using strategies::crosses::services::strategy_converter;
103 using strategies::relate::services::strategy_converter;
106 decltype(strategy_converter<Strategy>::get(strategy))
107 >::apply(geometry1, geometry2,
108 strategy_converter<Strategy>::get(strategy));
113 struct crosses<default_strategy, false>
115 template <typename Geometry1, typename Geometry2>
116 static inline bool apply(Geometry1 const& geometry1,
117 Geometry2 const& geometry2,
120 //typedef typename strategies::crosses::services::default_strategy
121 typedef typename strategies::relate::services::default_strategy
125 >::type strategy_type;
130 >::apply(geometry1, geometry2, strategy_type());
134 } // namespace resolve_strategy
137 namespace resolve_variant
139 template <typename Geometry1, typename Geometry2>
142 template <typename Strategy>
143 static inline bool apply(Geometry1 const& geometry1,
144 Geometry2 const& geometry2,
145 Strategy const& strategy)
147 return resolve_strategy::crosses
150 >::apply(geometry1, geometry2, strategy);
155 template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Geometry2>
156 struct crosses<variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Geometry2>
158 template <typename Strategy>
159 struct visitor: static_visitor<bool>
161 Geometry2 const& m_geometry2;
162 Strategy const& m_strategy;
164 visitor(Geometry2 const& geometry2, Strategy const& strategy)
165 : m_geometry2(geometry2)
166 , m_strategy(strategy)
169 template <typename Geometry1>
170 result_type operator()(Geometry1 const& geometry1) const
176 >::apply(geometry1, m_geometry2, m_strategy);
180 template <typename Strategy>
181 static inline bool apply(variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry1,
182 Geometry2 const& geometry2,
183 Strategy const& strategy)
185 return boost::apply_visitor(visitor<Strategy>(geometry2, strategy), geometry1);
190 template <typename Geometry1, BOOST_VARIANT_ENUM_PARAMS(typename T)>
191 struct crosses<Geometry1, variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
193 template <typename Strategy>
194 struct visitor: static_visitor<bool>
196 Geometry1 const& m_geometry1;
197 Strategy const& m_strategy;
199 visitor(Geometry1 const& geometry1, Strategy const& strategy)
200 : m_geometry1(geometry1)
201 , m_strategy(strategy)
204 template <typename Geometry2>
205 result_type operator()(Geometry2 const& geometry2) const
211 >::apply(m_geometry1, geometry2, m_strategy);
215 template <typename Strategy>
216 static inline bool apply(Geometry1 const& geometry1,
217 variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry2,
218 Strategy const& strategy)
220 return boost::apply_visitor(visitor<Strategy>(geometry1, strategy), geometry2);
225 template <BOOST_VARIANT_ENUM_PARAMS(typename T1), BOOST_VARIANT_ENUM_PARAMS(typename T2)>
226 struct crosses<variant<BOOST_VARIANT_ENUM_PARAMS(T1)>, variant<BOOST_VARIANT_ENUM_PARAMS(T2)> >
228 template <typename Strategy>
229 struct visitor: static_visitor<bool>
231 Strategy const& m_strategy;
233 visitor(Strategy const& strategy)
234 : m_strategy(strategy)
237 template <typename Geometry1, typename Geometry2>
238 result_type operator()(Geometry1 const& geometry1,
239 Geometry2 const& geometry2) const
245 >::apply(geometry1, geometry2, m_strategy);
249 template <typename Strategy>
250 static inline bool apply(variant<BOOST_VARIANT_ENUM_PARAMS(T1)> const& geometry1,
251 variant<BOOST_VARIANT_ENUM_PARAMS(T2)> const& geometry2,
252 Strategy const& strategy)
254 return boost::apply_visitor(visitor<Strategy>(strategy), geometry1, geometry2);
258 } // namespace resolve_variant
262 \brief \brief_check2{crosses}
264 \tparam Geometry1 \tparam_geometry
265 \tparam Geometry2 \tparam_geometry
266 \tparam Strategy \tparam_strategy{Crosses}
267 \param geometry1 \param_geometry
268 \param geometry2 \param_geometry
269 \param strategy \param_strategy{crosses}
270 \return \return_check2{crosses}
272 \qbk{distinguish,with strategy}
273 \qbk{[include reference/algorithms/crosses.qbk]}
275 template <typename Geometry1, typename Geometry2, typename Strategy>
276 inline bool crosses(Geometry1 const& geometry1,
277 Geometry2 const& geometry2,
278 Strategy const& strategy)
280 return resolve_variant::crosses
283 >::apply(geometry1, geometry2, strategy);
287 \brief \brief_check2{crosses}
289 \tparam Geometry1 \tparam_geometry
290 \tparam Geometry2 \tparam_geometry
291 \param geometry1 \param_geometry
292 \param geometry2 \param_geometry
293 \return \return_check2{crosses}
295 \qbk{[include reference/algorithms/crosses.qbk]}
302 template <typename Geometry1, typename Geometry2>
303 inline bool crosses(Geometry1 const& geometry1, Geometry2 const& geometry2)
305 return resolve_variant::crosses
308 >::apply(geometry1, geometry2, default_strategy());
311 }} // namespace boost::geometry
313 #endif // BOOST_GEOMETRY_ALGORITHMS_CROSSES_HPP