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.
7 // This file was modified by Oracle on 2017.
8 // Modifications copyright (c) 2017, 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)
20 #ifndef BOOST_GEOMETRY_STRATEGIES_COMPARE_HPP
21 #define BOOST_GEOMETRY_STRATEGIES_COMPARE_HPP
27 #include <boost/mpl/assert.hpp>
28 #include <boost/mpl/min.hpp>
30 #include <boost/geometry/core/access.hpp>
31 #include <boost/geometry/core/cs.hpp>
32 #include <boost/geometry/core/coordinate_type.hpp>
33 #include <boost/geometry/core/coordinate_dimension.hpp>
35 #include <boost/geometry/util/math.hpp>
38 namespace boost { namespace geometry
42 namespace strategy { namespace compare
48 template <typename T1, typename T2>
49 static inline bool apply(T1 const& l, T2 const& r)
57 template <typename T1, typename T2>
58 static inline bool apply(T1 const& l, T2 const& r)
66 template <typename T1, typename T2>
67 static inline bool apply(T1 const& , T2 const& )
74 #ifndef DOXYGEN_NO_DETAIL
81 typename ComparePolicy,
82 std::size_t Dimension,
83 std::size_t DimensionCount
87 template <typename Point1, typename Point2>
88 static inline bool apply(Point1 const& left, Point2 const& right)
90 typename geometry::coordinate_type<Point1>::type const&
91 cleft = geometry::get<Dimension>(left);
92 typename geometry::coordinate_type<Point2>::type const&
93 cright = geometry::get<Dimension>(right);
95 if (math::equals(cleft, cright))
100 Dimension + 1, DimensionCount
101 >::apply(left, right);
105 return ComparePolicy::apply(cleft, cright);
112 typename ComparePolicy,
113 std::size_t DimensionCount
115 struct compare_loop<ComparePolicy, DimensionCount, DimensionCount>
117 template <typename Point1, typename Point2>
118 static inline bool apply(Point1 const& , Point2 const& )
120 // On coming here, points are equal.
121 // Return false for less/greater.
128 std::size_t DimensionCount
130 struct compare_loop<strategy::compare::equal_to, DimensionCount, DimensionCount>
132 template <typename Point1, typename Point2>
133 static inline bool apply(Point1 const& , Point2 const& )
135 // On coming here, points are equal.
136 // Return true for equal_to.
141 } // namespace detail
142 #endif // DOXYGEN_NO_DETAIL
147 typename ComparePolicy,
152 template <typename Point1, typename Point2>
153 static inline bool apply(Point1 const& left, Point2 const& right)
155 return compare::detail::compare_loop
157 ComparePolicy, Dimension, Dimension + 1
158 >::apply(left, right);
162 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
165 typename ComparePolicy
167 struct cartesian<ComparePolicy, -1>
169 template <typename Point1, typename Point2>
170 static inline bool apply(Point1 const& left, Point2 const& right)
172 return compare::detail::compare_loop
178 geometry::dimension<Point1>,
179 geometry::dimension<Point2>
181 >::apply(left, right);
184 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
192 typename ComparePolicy,
194 typename Point2 = Point1,
196 typename CSTag1 = typename cs_tag<Point1>::type,
197 typename CSTag2 = typename cs_tag<Point2>::type
199 struct default_strategy
204 NOT_IMPLEMENTED_FOR_THESE_TYPES,
205 (types<CSTag1, CSTag2>)
210 template <typename ComparePolicy, typename Point1, typename Point2, int Dimension>
211 struct default_strategy<ComparePolicy, Point1, Point2, Dimension, cartesian_tag, cartesian_tag>
213 typedef compare::cartesian<ComparePolicy, Dimension> type;
217 } // namespace services
220 }} // namespace strategy compare
223 }} // namespace boost::geometry
226 #endif // BOOST_GEOMETRY_STRATEGIES_COMPARE_HPP