summaryrefslogtreecommitdiff
path: root/boost/geometry/policies/compare.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/geometry/policies/compare.hpp')
-rw-r--r--boost/geometry/policies/compare.hpp280
1 files changed, 221 insertions, 59 deletions
diff --git a/boost/geometry/policies/compare.hpp b/boost/geometry/policies/compare.hpp
index 6a081af837..9dd8a694cc 100644
--- a/boost/geometry/policies/compare.hpp
+++ b/boost/geometry/policies/compare.hpp
@@ -2,9 +2,10 @@
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
-// This file was modified by Oracle on 2017, 2019.
-// Modifications copyright (c) 2017, 2019, Oracle and/or its affiliates.
+// This file was modified by Oracle on 2017-2023.
+// Modifications copyright (c) 2017-2023, Oracle and/or its affiliates.
+// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
@@ -18,6 +19,7 @@
#include <cstddef>
#include <boost/geometry/strategies/compare.hpp>
+#include <boost/geometry/strategies/spherical/compare.hpp>
#include <boost/geometry/util/math.hpp>
@@ -36,92 +38,244 @@ namespace boost { namespace geometry
on equal x-es then on y, etc.
If a dimension is specified, only that dimension is considered
*/
+
template
<
typename Point = void,
int Dimension = -1,
- typename CSTag = void
+ typename StrategyOrTag = void
+>
+struct less_exact
+{
+ using first_argument_type = Point;
+ using second_argument_type = Point;
+ using result_type = bool;
+
+ inline bool operator()(Point const& left, Point const& right) const
+ {
+ return StrategyOrTag::template compare_type
+ <
+ strategy::compare::less,
+ strategy::compare::equals_exact
+ >::apply(left, right);
+ }
+};
+
+template
+<
+ typename Point = void,
+ int Dimension = -1,
+ typename StrategyOrTag = void
>
struct less
{
- typedef Point first_argument_type;
- typedef Point second_argument_type;
- typedef bool result_type;
+ using first_argument_type = Point;
+ using second_argument_type = Point;
+ using result_type = bool;
+
+ inline bool operator()(Point const& left, Point const& right) const
+ {
+ return StrategyOrTag::template compare_type
+ <
+ strategy::compare::less,
+ strategy::compare::equals_epsilon
+ >::apply(left, right);
+ }
+};
+
+
+template <typename Point, int Dimension>
+struct less<Point, Dimension, void>
+{
+ using first_argument_type = Point;
+ using second_argument_type = Point;
+ using result_type = bool;
inline bool operator()(Point const& left, Point const& right) const
{
- typedef typename strategy::compare::services::default_strategy
+ using strategy_type = typename strategy::compare::services::default_strategy
<
strategy::compare::less,
+ strategy::compare::equals_epsilon,
Point, Point,
- Dimension,
- CSTag, CSTag
- >::type strategy_type;
+ Dimension
+ >::type;
return strategy_type::apply(left, right);
}
};
-template <int Dimension, typename CSTag>
-struct less<void, Dimension, CSTag>
+template <int Dimension, typename Strategy>
+struct less<void, Dimension, Strategy>
{
- typedef bool result_type;
+ using result_type = bool;
template <typename Point1, typename Point2>
inline bool operator()(Point1 const& left, Point2 const& right) const
{
- typedef typename strategy::compare::services::default_strategy
+ return Strategy::template compare_type
<
strategy::compare::less,
- Point1, Point2,
+ strategy::compare::equals_epsilon
+ >::apply(left, right);
+ }
+};
+
+// for backward compatibility
+
+template <typename Point, int Dimension>
+struct less<Point, Dimension, boost::geometry::cartesian_tag>
+{
+ using first_argument_type = Point;
+ using second_argument_type = Point;
+ using result_type = bool;
+
+ inline bool operator()(Point const& left, Point const& right) const
+ {
+ using strategy_type = typename strategy::compare::services::default_strategy
+ <
+ strategy::compare::less,
+ strategy::compare::equals_epsilon,
+ Point, Point,
Dimension,
- CSTag, CSTag
- >::type strategy_type;
+ boost::geometry::cartesian_tag, boost::geometry::cartesian_tag
+ >::type;
return strategy_type::apply(left, right);
}
};
template <typename Point, int Dimension>
-struct less<Point, Dimension, void>
+struct less<Point, Dimension, boost::geometry::spherical_tag>
{
- typedef Point first_argument_type;
- typedef Point second_argument_type;
- typedef bool result_type;
+ using first_argument_type = Point;
+ using second_argument_type = Point;
+ using result_type = bool;
inline bool operator()(Point const& left, Point const& right) const
{
- typedef typename strategy::compare::services::default_strategy
+ using strategy_type = typename strategy::compare::services::default_strategy
<
strategy::compare::less,
+ strategy::compare::equals_epsilon,
Point, Point,
- Dimension
- >::type strategy_type;
+ Dimension,
+ boost::geometry::spherical_tag, boost::geometry::spherical_tag
+ >::type;
+
+ return strategy_type::apply(left, right);
+ }
+};
+
+template <typename Point, int Dimension>
+struct less<Point, Dimension, boost::geometry::geographic_tag>
+{
+ using first_argument_type = Point;
+ using second_argument_type = Point;
+ using result_type = bool;
+
+ inline bool operator()(Point const& left, Point const& right) const
+ {
+ using strategy_type = typename strategy::compare::services::default_strategy
+ <
+ strategy::compare::less,
+ strategy::compare::equals_epsilon,
+ Point, Point,
+ Dimension,
+ boost::geometry::geographic_tag, boost::geometry::geographic_tag
+ >::type;
+
+ return strategy_type::apply(left, right);
+ }
+};
+
+template <int Dimension>
+struct less<void, Dimension, boost::geometry::cartesian_tag>
+{
+ using result_type = bool;
+
+ template <typename Point1, typename Point2>
+ inline bool operator()(Point1 const& left, Point2 const& right) const
+ {
+ using strategy_type = typename strategy::compare::services::default_strategy
+ <
+ strategy::compare::less,
+ strategy::compare::equals_epsilon,
+ Point1, Point2,
+ Dimension,
+ boost::geometry::cartesian_tag, boost::geometry::cartesian_tag
+ >::type;
return strategy_type::apply(left, right);
}
};
template <int Dimension>
+struct less<void, Dimension, boost::geometry::spherical_tag>
+{
+ using result_type = bool;
+
+ template <typename Point1, typename Point2>
+ inline bool operator()(Point1 const& left, Point2 const& right) const
+ {
+ using strategy_type = typename strategy::compare::services::default_strategy
+ <
+ strategy::compare::less,
+ strategy::compare::equals_epsilon,
+ Point1, Point2,
+ Dimension,
+ boost::geometry::spherical_tag, boost::geometry::spherical_tag
+ >::type;
+
+ return strategy_type::apply(left, right);
+ }
+};
+
+template <int Dimension>
+struct less<void, Dimension, boost::geometry::geographic_tag>
+{
+ using result_type = bool;
+
+ template <typename Point1, typename Point2>
+ inline bool operator()(Point1 const& left, Point2 const& right) const
+ {
+ using strategy_type = typename strategy::compare::services::default_strategy
+ <
+ strategy::compare::less,
+ strategy::compare::equals_epsilon,
+ Point1, Point2,
+ Dimension,
+ boost::geometry::geographic_tag, boost::geometry::geographic_tag
+ >::type;
+
+ return strategy_type::apply(left, right);
+ }
+};
+
+
+template <int Dimension>
struct less<void, Dimension, void>
{
- typedef bool result_type;
+ using result_type = bool;
template <typename Point1, typename Point2>
inline bool operator()(Point1 const& left, Point2 const& right) const
{
- typedef typename strategy::compare::services::default_strategy
+ using strategy_type = typename strategy::compare::services::default_strategy
<
strategy::compare::less,
+ strategy::compare::equals_epsilon,
Point1, Point2,
Dimension
- >::type strategy_type;
+ >::type;
return strategy_type::apply(left, right);
}
};
+
+
/*!
\brief Greater functor
\ingroup compare
@@ -136,19 +290,20 @@ template
>
struct greater
{
- typedef Point first_argument_type;
- typedef Point second_argument_type;
- typedef bool result_type;
+ using first_argument_type = Point;
+ using second_argument_type = Point;
+ using result_type = bool;
bool operator()(Point const& left, Point const& right) const
{
- typedef typename strategy::compare::services::default_strategy
+ using strategy_type = typename strategy::compare::services::default_strategy
<
strategy::compare::greater,
+ strategy::compare::equals_epsilon,
Point, Point,
Dimension,
CSTag, CSTag
- >::type strategy_type;
+ >::type;
return strategy_type::apply(left, right);
}
@@ -157,18 +312,19 @@ struct greater
template <int Dimension, typename CSTag>
struct greater<void, Dimension, CSTag>
{
- typedef bool result_type;
+ using result_type = bool;
template <typename Point1, typename Point2>
bool operator()(Point1 const& left, Point2 const& right) const
{
- typedef typename strategy::compare::services::default_strategy
+ using strategy_type = typename strategy::compare::services::default_strategy
<
strategy::compare::greater,
+ strategy::compare::equals_epsilon,
Point1, Point2,
Dimension,
CSTag, CSTag
- >::type strategy_type;
+ >::type;
return strategy_type::apply(left, right);
}
@@ -177,18 +333,19 @@ struct greater<void, Dimension, CSTag>
template <typename Point, int Dimension>
struct greater<Point, Dimension, void>
{
- typedef Point first_argument_type;
- typedef Point second_argument_type;
- typedef bool result_type;
+ using first_argument_type = Point;
+ using second_argument_type = Point;
+ using result_type = bool;
bool operator()(Point const& left, Point const& right) const
{
- typedef typename strategy::compare::services::default_strategy
+ using strategy_type = typename strategy::compare::services::default_strategy
<
strategy::compare::greater,
+ strategy::compare::equals_epsilon,
Point, Point,
Dimension
- >::type strategy_type;
+ >::type;
return strategy_type::apply(left, right);
}
@@ -197,17 +354,18 @@ struct greater<Point, Dimension, void>
template <int Dimension>
struct greater<void, Dimension, void>
{
- typedef bool result_type;
+ using result_type = bool;
template <typename Point1, typename Point2>
bool operator()(Point1 const& left, Point2 const& right) const
{
- typedef typename strategy::compare::services::default_strategy
+ using strategy_type = typename strategy::compare::services::default_strategy
<
strategy::compare::greater,
+ strategy::compare::equals_epsilon,
Point1, Point2,
Dimension
- >::type strategy_type;
+ >::type;
return strategy_type::apply(left, right);
}
@@ -230,19 +388,20 @@ template
>
struct equal_to
{
- typedef Point first_argument_type;
- typedef Point second_argument_type;
- typedef bool result_type;
+ using first_argument_type = Point;
+ using second_argument_type = Point;
+ using result_type = bool;
bool operator()(Point const& left, Point const& right) const
{
- typedef typename strategy::compare::services::default_strategy
+ using strategy_type = typename strategy::compare::services::default_strategy
<
strategy::compare::equal_to,
+ strategy::compare::equals_epsilon,
Point, Point,
Dimension,
CSTag, CSTag
- >::type strategy_type;
+ >::type;
return strategy_type::apply(left, right);
}
@@ -251,18 +410,19 @@ struct equal_to
template <int Dimension, typename CSTag>
struct equal_to<void, Dimension, CSTag>
{
- typedef bool result_type;
+ using result_type = bool;
template <typename Point1, typename Point2>
bool operator()(Point1 const& left, Point2 const& right) const
{
- typedef typename strategy::compare::services::default_strategy
+ using strategy_type = typename strategy::compare::services::default_strategy
<
strategy::compare::equal_to,
+ strategy::compare::equals_epsilon,
Point1, Point2,
Dimension,
CSTag, CSTag
- >::type strategy_type;
+ >::type;
return strategy_type::apply(left, right);
}
@@ -271,18 +431,19 @@ struct equal_to<void, Dimension, CSTag>
template <typename Point, int Dimension>
struct equal_to<Point, Dimension, void>
{
- typedef Point first_argument_type;
- typedef Point second_argument_type;
- typedef bool result_type;
+ using first_argument_type = Point;
+ using second_argument_type = Point;
+ using result_type = bool;
bool operator()(Point const& left, Point const& right) const
{
- typedef typename strategy::compare::services::default_strategy
+ using strategy_type = typename strategy::compare::services::default_strategy
<
strategy::compare::equal_to,
+ strategy::compare::equals_epsilon,
Point, Point,
Dimension
- >::type strategy_type;
+ >::type;
return strategy_type::apply(left, right);
}
@@ -291,17 +452,18 @@ struct equal_to<Point, Dimension, void>
template <int Dimension>
struct equal_to<void, Dimension, void>
{
- typedef bool result_type;
+ using result_type = bool;
template <typename Point1, typename Point2>
bool operator()(Point1 const& left, Point2 const& right) const
{
- typedef typename strategy::compare::services::default_strategy
+ using strategy_type = typename strategy::compare::services::default_strategy
<
strategy::compare::equal_to,
+ strategy::compare::equals_epsilon,
Point1, Point2,
Dimension
- >::type strategy_type;
+ >::type;
return strategy_type::apply(left, right);
}