Skip to content

Commit

Permalink
[overlay] fix cluster by adapting tolerance
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitsuhiko-Matsukawa committed Nov 17, 2022
1 parent 952b0f6 commit bbb6f6d
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions include/boost/geometry/algorithms/detail/overlay/get_clusters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,28 @@ namespace detail { namespace overlay
template <typename Tag = no_rescale_policy_tag, bool Integral = false>
struct sweep_equal_policy
{
private:
template <typename T>
static inline T threshold()
{
// Tuned by cases of #1081
return T(3);
}
public:
template <typename P>
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<P>::type;
return approximately_equals(p1, p2, coor_t(1));
return approximately_equals(p1, p2, threshold<coor_t>());
}

template <typename T>
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<T>();
return value > limit;
}
};
Expand Down

0 comments on commit bbb6f6d

Please sign in to comment.