File indexing completed on 2025-01-18 09:35:37
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef BOOST_GEOMETRY_POLICIES_COMPARE_HPP
0016 #define BOOST_GEOMETRY_POLICIES_COMPARE_HPP
0017
0018
0019 #include <cstddef>
0020
0021 #include <boost/geometry/strategies/compare.hpp>
0022 #include <boost/geometry/strategies/spherical/compare.hpp>
0023 #include <boost/geometry/util/math.hpp>
0024
0025
0026 namespace boost { namespace geometry
0027 {
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 template
0043 <
0044 typename Point = void,
0045 int Dimension = -1,
0046 typename StrategyOrTag = void
0047 >
0048 struct less_exact
0049 {
0050 using first_argument_type = Point;
0051 using second_argument_type = Point;
0052 using result_type = bool;
0053
0054 inline bool operator()(Point const& left, Point const& right) const
0055 {
0056 return StrategyOrTag::template compare_type
0057 <
0058 strategy::compare::less,
0059 strategy::compare::equals_exact
0060 >::apply(left, right);
0061 }
0062 };
0063
0064 template
0065 <
0066 typename Point = void,
0067 int Dimension = -1,
0068 typename StrategyOrTag = void
0069 >
0070 struct less
0071 {
0072 using first_argument_type = Point;
0073 using second_argument_type = Point;
0074 using result_type = bool;
0075
0076 inline bool operator()(Point const& left, Point const& right) const
0077 {
0078 return StrategyOrTag::template compare_type
0079 <
0080 strategy::compare::less,
0081 strategy::compare::equals_epsilon
0082 >::apply(left, right);
0083 }
0084 };
0085
0086
0087 template <typename Point, int Dimension>
0088 struct less<Point, Dimension, void>
0089 {
0090 using first_argument_type = Point;
0091 using second_argument_type = Point;
0092 using result_type = bool;
0093
0094 inline bool operator()(Point const& left, Point const& right) const
0095 {
0096 using strategy_type = typename strategy::compare::services::default_strategy
0097 <
0098 strategy::compare::less,
0099 strategy::compare::equals_epsilon,
0100 Point, Point,
0101 Dimension
0102 >::type;
0103
0104 return strategy_type::apply(left, right);
0105 }
0106 };
0107
0108 template <int Dimension, typename Strategy>
0109 struct less<void, Dimension, Strategy>
0110 {
0111 using result_type = bool;
0112
0113 template <typename Point1, typename Point2>
0114 inline bool operator()(Point1 const& left, Point2 const& right) const
0115 {
0116 return Strategy::template compare_type
0117 <
0118 strategy::compare::less,
0119 strategy::compare::equals_epsilon
0120 >::apply(left, right);
0121 }
0122 };
0123
0124
0125
0126 template <typename Point, int Dimension>
0127 struct less<Point, Dimension, boost::geometry::cartesian_tag>
0128 {
0129 using first_argument_type = Point;
0130 using second_argument_type = Point;
0131 using result_type = bool;
0132
0133 inline bool operator()(Point const& left, Point const& right) const
0134 {
0135 using strategy_type = typename strategy::compare::services::default_strategy
0136 <
0137 strategy::compare::less,
0138 strategy::compare::equals_epsilon,
0139 Point, Point,
0140 Dimension,
0141 boost::geometry::cartesian_tag, boost::geometry::cartesian_tag
0142 >::type;
0143
0144 return strategy_type::apply(left, right);
0145 }
0146 };
0147
0148 template <typename Point, int Dimension>
0149 struct less<Point, Dimension, boost::geometry::spherical_tag>
0150 {
0151 using first_argument_type = Point;
0152 using second_argument_type = Point;
0153 using result_type = bool;
0154
0155 inline bool operator()(Point const& left, Point const& right) const
0156 {
0157 using strategy_type = typename strategy::compare::services::default_strategy
0158 <
0159 strategy::compare::less,
0160 strategy::compare::equals_epsilon,
0161 Point, Point,
0162 Dimension,
0163 boost::geometry::spherical_tag, boost::geometry::spherical_tag
0164 >::type;
0165
0166 return strategy_type::apply(left, right);
0167 }
0168 };
0169
0170 template <typename Point, int Dimension>
0171 struct less<Point, Dimension, boost::geometry::geographic_tag>
0172 {
0173 using first_argument_type = Point;
0174 using second_argument_type = Point;
0175 using result_type = bool;
0176
0177 inline bool operator()(Point const& left, Point const& right) const
0178 {
0179 using strategy_type = typename strategy::compare::services::default_strategy
0180 <
0181 strategy::compare::less,
0182 strategy::compare::equals_epsilon,
0183 Point, Point,
0184 Dimension,
0185 boost::geometry::geographic_tag, boost::geometry::geographic_tag
0186 >::type;
0187
0188 return strategy_type::apply(left, right);
0189 }
0190 };
0191
0192 template <int Dimension>
0193 struct less<void, Dimension, boost::geometry::cartesian_tag>
0194 {
0195 using result_type = bool;
0196
0197 template <typename Point1, typename Point2>
0198 inline bool operator()(Point1 const& left, Point2 const& right) const
0199 {
0200 using strategy_type = typename strategy::compare::services::default_strategy
0201 <
0202 strategy::compare::less,
0203 strategy::compare::equals_epsilon,
0204 Point1, Point2,
0205 Dimension,
0206 boost::geometry::cartesian_tag, boost::geometry::cartesian_tag
0207 >::type;
0208
0209 return strategy_type::apply(left, right);
0210 }
0211 };
0212
0213 template <int Dimension>
0214 struct less<void, Dimension, boost::geometry::spherical_tag>
0215 {
0216 using result_type = bool;
0217
0218 template <typename Point1, typename Point2>
0219 inline bool operator()(Point1 const& left, Point2 const& right) const
0220 {
0221 using strategy_type = typename strategy::compare::services::default_strategy
0222 <
0223 strategy::compare::less,
0224 strategy::compare::equals_epsilon,
0225 Point1, Point2,
0226 Dimension,
0227 boost::geometry::spherical_tag, boost::geometry::spherical_tag
0228 >::type;
0229
0230 return strategy_type::apply(left, right);
0231 }
0232 };
0233
0234 template <int Dimension>
0235 struct less<void, Dimension, boost::geometry::geographic_tag>
0236 {
0237 using result_type = bool;
0238
0239 template <typename Point1, typename Point2>
0240 inline bool operator()(Point1 const& left, Point2 const& right) const
0241 {
0242 using strategy_type = typename strategy::compare::services::default_strategy
0243 <
0244 strategy::compare::less,
0245 strategy::compare::equals_epsilon,
0246 Point1, Point2,
0247 Dimension,
0248 boost::geometry::geographic_tag, boost::geometry::geographic_tag
0249 >::type;
0250
0251 return strategy_type::apply(left, right);
0252 }
0253 };
0254
0255
0256 template <int Dimension>
0257 struct less<void, Dimension, void>
0258 {
0259 using result_type = bool;
0260
0261 template <typename Point1, typename Point2>
0262 inline bool operator()(Point1 const& left, Point2 const& right) const
0263 {
0264 using strategy_type = typename strategy::compare::services::default_strategy
0265 <
0266 strategy::compare::less,
0267 strategy::compare::equals_epsilon,
0268 Point1, Point2,
0269 Dimension
0270 >::type;
0271
0272 return strategy_type::apply(left, right);
0273 }
0274 };
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285 template
0286 <
0287 typename Point = void,
0288 int Dimension = -1,
0289 typename CSTag = void
0290 >
0291 struct greater
0292 {
0293 using first_argument_type = Point;
0294 using second_argument_type = Point;
0295 using result_type = bool;
0296
0297 bool operator()(Point const& left, Point const& right) const
0298 {
0299 using strategy_type = typename strategy::compare::services::default_strategy
0300 <
0301 strategy::compare::greater,
0302 strategy::compare::equals_epsilon,
0303 Point, Point,
0304 Dimension,
0305 CSTag, CSTag
0306 >::type;
0307
0308 return strategy_type::apply(left, right);
0309 }
0310 };
0311
0312 template <int Dimension, typename CSTag>
0313 struct greater<void, Dimension, CSTag>
0314 {
0315 using result_type = bool;
0316
0317 template <typename Point1, typename Point2>
0318 bool operator()(Point1 const& left, Point2 const& right) const
0319 {
0320 using strategy_type = typename strategy::compare::services::default_strategy
0321 <
0322 strategy::compare::greater,
0323 strategy::compare::equals_epsilon,
0324 Point1, Point2,
0325 Dimension,
0326 CSTag, CSTag
0327 >::type;
0328
0329 return strategy_type::apply(left, right);
0330 }
0331 };
0332
0333 template <typename Point, int Dimension>
0334 struct greater<Point, Dimension, void>
0335 {
0336 using first_argument_type = Point;
0337 using second_argument_type = Point;
0338 using result_type = bool;
0339
0340 bool operator()(Point const& left, Point const& right) const
0341 {
0342 using strategy_type = typename strategy::compare::services::default_strategy
0343 <
0344 strategy::compare::greater,
0345 strategy::compare::equals_epsilon,
0346 Point, Point,
0347 Dimension
0348 >::type;
0349
0350 return strategy_type::apply(left, right);
0351 }
0352 };
0353
0354 template <int Dimension>
0355 struct greater<void, Dimension, void>
0356 {
0357 using result_type = bool;
0358
0359 template <typename Point1, typename Point2>
0360 bool operator()(Point1 const& left, Point2 const& right) const
0361 {
0362 using strategy_type = typename strategy::compare::services::default_strategy
0363 <
0364 strategy::compare::greater,
0365 strategy::compare::equals_epsilon,
0366 Point1, Point2,
0367 Dimension
0368 >::type;
0369
0370 return strategy_type::apply(left, right);
0371 }
0372 };
0373
0374
0375
0376
0377
0378
0379
0380
0381
0382
0383 template
0384 <
0385 typename Point,
0386 int Dimension = -1,
0387 typename CSTag = void
0388 >
0389 struct equal_to
0390 {
0391 using first_argument_type = Point;
0392 using second_argument_type = Point;
0393 using result_type = bool;
0394
0395 bool operator()(Point const& left, Point const& right) const
0396 {
0397 using strategy_type = typename strategy::compare::services::default_strategy
0398 <
0399 strategy::compare::equal_to,
0400 strategy::compare::equals_epsilon,
0401 Point, Point,
0402 Dimension,
0403 CSTag, CSTag
0404 >::type;
0405
0406 return strategy_type::apply(left, right);
0407 }
0408 };
0409
0410 template <int Dimension, typename CSTag>
0411 struct equal_to<void, Dimension, CSTag>
0412 {
0413 using result_type = bool;
0414
0415 template <typename Point1, typename Point2>
0416 bool operator()(Point1 const& left, Point2 const& right) const
0417 {
0418 using strategy_type = typename strategy::compare::services::default_strategy
0419 <
0420 strategy::compare::equal_to,
0421 strategy::compare::equals_epsilon,
0422 Point1, Point2,
0423 Dimension,
0424 CSTag, CSTag
0425 >::type;
0426
0427 return strategy_type::apply(left, right);
0428 }
0429 };
0430
0431 template <typename Point, int Dimension>
0432 struct equal_to<Point, Dimension, void>
0433 {
0434 using first_argument_type = Point;
0435 using second_argument_type = Point;
0436 using result_type = bool;
0437
0438 bool operator()(Point const& left, Point const& right) const
0439 {
0440 using strategy_type = typename strategy::compare::services::default_strategy
0441 <
0442 strategy::compare::equal_to,
0443 strategy::compare::equals_epsilon,
0444 Point, Point,
0445 Dimension
0446 >::type;
0447
0448 return strategy_type::apply(left, right);
0449 }
0450 };
0451
0452 template <int Dimension>
0453 struct equal_to<void, Dimension, void>
0454 {
0455 using result_type = bool;
0456
0457 template <typename Point1, typename Point2>
0458 bool operator()(Point1 const& left, Point2 const& right) const
0459 {
0460 using strategy_type = typename strategy::compare::services::default_strategy
0461 <
0462 strategy::compare::equal_to,
0463 strategy::compare::equals_epsilon,
0464 Point1, Point2,
0465 Dimension
0466 >::type;
0467
0468 return strategy_type::apply(left, right);
0469 }
0470 };
0471
0472
0473 }}
0474
0475
0476 #endif