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 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
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)
15 #ifndef BOOST_GEOMETRY_STRATEGIES_COMPARE_HPP
16 #define BOOST_GEOMETRY_STRATEGIES_COMPARE_HPP
21 #include <boost/mpl/if.hpp>
23 #include <boost/geometry/core/cs.hpp>
24 #include <boost/geometry/core/coordinate_type.hpp>
26 #include <boost/geometry/strategies/tags.hpp>
29 namespace boost { namespace geometry
34 \brief Traits class binding a comparing strategy to a coordinate system
36 \tparam Tag tag of coordinate system of point-type
37 \tparam Direction direction to compare on: 1 for less (-> ascending order)
38 and -1 for greater (-> descending order)
39 \tparam Point point-type
40 \tparam CoordinateSystem coordinate sytem of point
41 \tparam Dimension: the dimension to compare on
48 typename CoordinateSystem,
51 struct strategy_compare
53 typedef strategy::not_implemented type;
57 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
59 // For compare we add defaults specializations,
60 // because they defaultly redirect to std::less / greater / equal_to
65 typename CoordinateSystem,
68 struct strategy_compare<Tag, 1, Point, CoordinateSystem, Dimension>
70 typedef std::less<typename coordinate_type<Point>::type> type;
78 typename CoordinateSystem,
81 struct strategy_compare<Tag, -1, Point, CoordinateSystem, Dimension>
83 typedef std::greater<typename coordinate_type<Point>::type> type;
91 typename CoordinateSystem,
94 struct strategy_compare<Tag, 0, Point, CoordinateSystem, Dimension>
96 typedef std::equal_to<typename coordinate_type<Point>::type> type;
103 namespace strategy { namespace compare
108 \brief Default strategy, indicates the default strategy for comparisons
109 \details The default strategy for comparisons defer in most cases
110 to std::less (for ascending) and std::greater (for descending).
111 However, if a spherical coordinate system is used, and comparison
112 is done on longitude, it will take another strategy handling circular
114 struct default_strategy {};
117 #ifndef DOXYGEN_NO_DETAIL
121 template <typename Type>
122 struct is_default : boost::false_type
127 struct is_default<default_strategy> : boost::true_type
132 \brief Meta-function to select strategy
133 \details If "default_strategy" is specified, it will take the
134 traits-registered class for the specified coordinate system.
135 If another strategy is explicitly specified, it takes that one.
142 std::size_t Dimension
144 struct select_strategy
149 is_default<Strategy>,
150 typename strategy_compare
152 typename cs_tag<Point>::type,
155 typename coordinate_system<Point>::type,
162 } // namespace detail
163 #endif // DOXYGEN_NO_DETAIL
166 }} // namespace strategy::compare
169 }} // namespace boost::geometry
172 #endif // BOOST_GEOMETRY_STRATEGIES_COMPARE_HPP