From 2912e1b1991435f5c2d564276bb2069a6351e78d Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Wed, 9 Jul 2014 17:30:38 +0200 Subject: [PATCH] [strategies] Add more robust check in projected_point_ax_less --- .../cartesian/distance_projected_point_ax.hpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/include/boost/geometry/strategies/cartesian/distance_projected_point_ax.hpp b/include/boost/geometry/strategies/cartesian/distance_projected_point_ax.hpp index c70aa8b6f..71ac637f2 100644 --- a/include/boost/geometry/strategies/cartesian/distance_projected_point_ax.hpp +++ b/include/boost/geometry/strategies/cartesian/distance_projected_point_ax.hpp @@ -21,6 +21,8 @@ #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_PROJECTED_POINT_AX_HPP +#include + #include #include #include @@ -58,6 +60,8 @@ namespace detail template struct projected_point_ax_result { + typedef T value_type; + projected_point_ax_result(T const& c = T(0)) : atd(c), xtd(c) {} @@ -89,7 +93,19 @@ public: inline bool operator()(Distance const& left, Distance const& right) const { - return left.xtd < right.xtd && right.atd < m_max_distance.atd; + //return left.xtd < right.xtd && right.atd < m_max_distance.atd; + + typedef typename Distance::value_type value_type; + + value_type const lx = left.xtd > m_max_distance.xtd ? left.xtd - m_max_distance.xtd : 0; + value_type const rx = right.xtd > m_max_distance.xtd ? right.xtd - m_max_distance.xtd : 0; + value_type const la = left.atd > m_max_distance.atd ? left.atd - m_max_distance.atd : 0; + value_type const ra = right.atd > m_max_distance.atd ? right.atd - m_max_distance.atd : 0; + + value_type const l = (std::max)(lx, la); + value_type const r = (std::max)(rx, ra); + + return l < r; } private: Distance const& m_max_distance;