Chris@16
|
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
|
Chris@16
|
2
|
Chris@16
|
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
Chris@16
|
4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
|
Chris@16
|
5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
|
Chris@16
|
6
|
Chris@16
|
7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
Chris@16
|
8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
Chris@16
|
9
|
Chris@16
|
10 // Use, modification and distribution is subject to the Boost Software License,
|
Chris@16
|
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
12 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
13
|
Chris@16
|
14
|
Chris@16
|
15 #ifndef BOOST_GEOMETRY_STRATEGIES_COMPARE_HPP
|
Chris@16
|
16 #define BOOST_GEOMETRY_STRATEGIES_COMPARE_HPP
|
Chris@16
|
17
|
Chris@16
|
18 #include <cstddef>
|
Chris@16
|
19 #include <functional>
|
Chris@16
|
20
|
Chris@16
|
21 #include <boost/mpl/if.hpp>
|
Chris@16
|
22
|
Chris@16
|
23 #include <boost/geometry/core/cs.hpp>
|
Chris@16
|
24 #include <boost/geometry/core/coordinate_type.hpp>
|
Chris@16
|
25
|
Chris@16
|
26 #include <boost/geometry/strategies/tags.hpp>
|
Chris@16
|
27
|
Chris@16
|
28
|
Chris@16
|
29 namespace boost { namespace geometry
|
Chris@16
|
30 {
|
Chris@16
|
31
|
Chris@16
|
32
|
Chris@16
|
33 /*!
|
Chris@16
|
34 \brief Traits class binding a comparing strategy to a coordinate system
|
Chris@16
|
35 \ingroup util
|
Chris@16
|
36 \tparam Tag tag of coordinate system of point-type
|
Chris@16
|
37 \tparam Direction direction to compare on: 1 for less (-> ascending order)
|
Chris@16
|
38 and -1 for greater (-> descending order)
|
Chris@16
|
39 \tparam Point point-type
|
Chris@16
|
40 \tparam CoordinateSystem coordinate sytem of point
|
Chris@16
|
41 \tparam Dimension: the dimension to compare on
|
Chris@16
|
42 */
|
Chris@16
|
43 template
|
Chris@16
|
44 <
|
Chris@16
|
45 typename Tag,
|
Chris@16
|
46 int Direction,
|
Chris@16
|
47 typename Point,
|
Chris@16
|
48 typename CoordinateSystem,
|
Chris@16
|
49 std::size_t Dimension
|
Chris@16
|
50 >
|
Chris@16
|
51 struct strategy_compare
|
Chris@16
|
52 {
|
Chris@16
|
53 typedef strategy::not_implemented type;
|
Chris@16
|
54 };
|
Chris@16
|
55
|
Chris@16
|
56
|
Chris@16
|
57 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
Chris@16
|
58
|
Chris@16
|
59 // For compare we add defaults specializations,
|
Chris@16
|
60 // because they defaultly redirect to std::less / greater / equal_to
|
Chris@16
|
61 template
|
Chris@16
|
62 <
|
Chris@16
|
63 typename Tag,
|
Chris@16
|
64 typename Point,
|
Chris@16
|
65 typename CoordinateSystem,
|
Chris@16
|
66 std::size_t Dimension
|
Chris@16
|
67 >
|
Chris@16
|
68 struct strategy_compare<Tag, 1, Point, CoordinateSystem, Dimension>
|
Chris@16
|
69 {
|
Chris@16
|
70 typedef std::less<typename coordinate_type<Point>::type> type;
|
Chris@16
|
71 };
|
Chris@16
|
72
|
Chris@16
|
73
|
Chris@16
|
74 template
|
Chris@16
|
75 <
|
Chris@16
|
76 typename Tag,
|
Chris@16
|
77 typename Point,
|
Chris@16
|
78 typename CoordinateSystem,
|
Chris@16
|
79 std::size_t Dimension
|
Chris@16
|
80 >
|
Chris@16
|
81 struct strategy_compare<Tag, -1, Point, CoordinateSystem, Dimension>
|
Chris@16
|
82 {
|
Chris@16
|
83 typedef std::greater<typename coordinate_type<Point>::type> type;
|
Chris@16
|
84 };
|
Chris@16
|
85
|
Chris@16
|
86
|
Chris@16
|
87 template
|
Chris@16
|
88 <
|
Chris@16
|
89 typename Tag,
|
Chris@16
|
90 typename Point,
|
Chris@16
|
91 typename CoordinateSystem,
|
Chris@16
|
92 std::size_t Dimension
|
Chris@16
|
93 >
|
Chris@16
|
94 struct strategy_compare<Tag, 0, Point, CoordinateSystem, Dimension>
|
Chris@16
|
95 {
|
Chris@16
|
96 typedef std::equal_to<typename coordinate_type<Point>::type> type;
|
Chris@16
|
97 };
|
Chris@16
|
98
|
Chris@16
|
99
|
Chris@16
|
100 #endif
|
Chris@16
|
101
|
Chris@16
|
102
|
Chris@16
|
103 namespace strategy { namespace compare
|
Chris@16
|
104 {
|
Chris@16
|
105
|
Chris@16
|
106
|
Chris@16
|
107 /*!
|
Chris@16
|
108 \brief Default strategy, indicates the default strategy for comparisons
|
Chris@16
|
109 \details The default strategy for comparisons defer in most cases
|
Chris@16
|
110 to std::less (for ascending) and std::greater (for descending).
|
Chris@16
|
111 However, if a spherical coordinate system is used, and comparison
|
Chris@16
|
112 is done on longitude, it will take another strategy handling circular
|
Chris@16
|
113 */
|
Chris@16
|
114 struct default_strategy {};
|
Chris@16
|
115
|
Chris@16
|
116
|
Chris@16
|
117 #ifndef DOXYGEN_NO_DETAIL
|
Chris@16
|
118 namespace detail
|
Chris@16
|
119 {
|
Chris@16
|
120
|
Chris@16
|
121 template <typename Type>
|
Chris@16
|
122 struct is_default : boost::false_type
|
Chris@16
|
123 {};
|
Chris@16
|
124
|
Chris@16
|
125
|
Chris@16
|
126 template <>
|
Chris@16
|
127 struct is_default<default_strategy> : boost::true_type
|
Chris@16
|
128 {};
|
Chris@16
|
129
|
Chris@16
|
130
|
Chris@16
|
131 /*!
|
Chris@16
|
132 \brief Meta-function to select strategy
|
Chris@16
|
133 \details If "default_strategy" is specified, it will take the
|
Chris@16
|
134 traits-registered class for the specified coordinate system.
|
Chris@16
|
135 If another strategy is explicitly specified, it takes that one.
|
Chris@16
|
136 */
|
Chris@16
|
137 template
|
Chris@16
|
138 <
|
Chris@16
|
139 typename Strategy,
|
Chris@16
|
140 int Direction,
|
Chris@16
|
141 typename Point,
|
Chris@16
|
142 std::size_t Dimension
|
Chris@16
|
143 >
|
Chris@16
|
144 struct select_strategy
|
Chris@16
|
145 {
|
Chris@16
|
146 typedef typename
|
Chris@16
|
147 boost::mpl::if_
|
Chris@16
|
148 <
|
Chris@16
|
149 is_default<Strategy>,
|
Chris@16
|
150 typename strategy_compare
|
Chris@16
|
151 <
|
Chris@16
|
152 typename cs_tag<Point>::type,
|
Chris@16
|
153 Direction,
|
Chris@16
|
154 Point,
|
Chris@16
|
155 typename coordinate_system<Point>::type,
|
Chris@16
|
156 Dimension
|
Chris@16
|
157 >::type,
|
Chris@16
|
158 Strategy
|
Chris@16
|
159 >::type type;
|
Chris@16
|
160 };
|
Chris@16
|
161
|
Chris@16
|
162 } // namespace detail
|
Chris@16
|
163 #endif // DOXYGEN_NO_DETAIL
|
Chris@16
|
164
|
Chris@16
|
165
|
Chris@16
|
166 }} // namespace strategy::compare
|
Chris@16
|
167
|
Chris@16
|
168
|
Chris@16
|
169 }} // namespace boost::geometry
|
Chris@16
|
170
|
Chris@16
|
171
|
Chris@16
|
172 #endif // BOOST_GEOMETRY_STRATEGIES_COMPARE_HPP
|