From bbb6f6d1f1fd18b0db639b332b0a1ef2b5240502 Mon Sep 17 00:00:00 2001 From: matsu Date: Thu, 17 Nov 2022 12:45:03 +0800 Subject: [PATCH] [overlay] fix cluster by adapting tolerance https://github.com/boostorg/geometry/pull/1093 --- .../algorithms/detail/overlay/get_clusters.hpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/overlay/get_clusters.hpp b/include/boost/geometry/algorithms/detail/overlay/get_clusters.hpp index 971cc7b6a9..544bf424ab 100644 --- a/include/boost/geometry/algorithms/detail/overlay/get_clusters.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/get_clusters.hpp @@ -35,20 +35,28 @@ namespace detail { namespace overlay template struct sweep_equal_policy { +private: + template + static inline T threshold() + { + // Tuned by cases of #1081 + return T(3); + } +public: template static inline bool equals(P const& p1, P const& p2) { - // Points within a epsilon are considered as equal + // Points within a some epsilons are considered as equal using coor_t = typename coordinate_type

::type; - return approximately_equals(p1, p2, coor_t(1)); + return approximately_equals(p1, p2, threshold()); } template static inline bool exceeds(T value) { // This threshold is an arbitrary value - // as long as it is than the used epsilon - T const limit = T(1) / T(1); + // as long as it is bigger than the used value above + T const limit = T(1) / threshold(); return value > limit; } };