1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 
3 // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
4 
5 // This file was modified by Oracle on 2014.
6 // Modifications copyright (c) 2014, Oracle and/or its affiliates.
7 
8 // Use, modification and distribution is subject to the Boost Software License,
9 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
10 // http://www.boost.org/LICENSE_1_0.txt)
11 
12 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
13 
14 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_LESS_HPP
15 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_LESS_HPP
16 
17 #include <boost/geometry/core/coordinate_dimension.hpp>
18 #include <boost/geometry/core/coordinate_type.hpp>
19 #include <boost/geometry/util/math.hpp>
20 
21 namespace boost { namespace geometry
22 {
23 
24 #ifndef DOXYGEN_NO_DISPATCH
25 namespace detail_dispatch { namespace relate {
26 
27 // TODO: Integrate it with geometry::less?
28 
29 template <typename Point1,
30           typename Point2,
31           std::size_t I = 0,
32           std::size_t D = geometry::dimension<Point1>::value>
33 struct less
34 {
applyboost::geometry::detail_dispatch::relate::less35     static inline bool apply(Point1 const& left, Point2 const& right)
36     {
37         typename geometry::coordinate_type<Point1>::type
38             cleft = geometry::get<I>(left);
39         typename geometry::coordinate_type<Point2>::type
40             cright = geometry::get<I>(right);
41 
42         if ( geometry::math::equals(cleft, cright) )
43         {
44             return less<Point1, Point2, I + 1, D>::apply(left, right);
45         }
46         else
47         {
48             return cleft < cright;
49         }
50     }
51 };
52 
53 template <typename Point1, typename Point2, std::size_t D>
54 struct less<Point1, Point2, D, D>
55 {
applyboost::geometry::detail_dispatch::relate::less56     static inline bool apply(Point1 const&, Point2 const&)
57     {
58         return false;
59     }
60 };
61 
62 }} // namespace detail_dispatch::relate
63 
64 #endif
65 
66 #ifndef DOXYGEN_NO_DETAIL
67 namespace detail { namespace relate {
68 
69 struct less
70 {
71     template <typename Point1, typename Point2>
operator ()boost::geometry::detail::relate::less72     inline bool operator()(Point1 const& point1, Point2 const& point2) const
73     {
74         return detail_dispatch::relate::less<Point1, Point2>::apply(point1, point2);
75     }
76 };
77 
78 }} // namespace detail::relate
79 #endif // DOXYGEN_NO_DETAIL
80 
81 }} // namespace boost::geometry
82 
83 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_LESS_HPP
84