Imported Upstream version 1.72.0
[platform/upstream/boost.git] / boost / geometry / algorithms / detail / closest_feature / point_to_range.hpp
index df67890..e5e8c6c 100644 (file)
@@ -71,8 +71,11 @@ protected:
         // check if other segments are closer
         for (++prev, ++it; it != last; ++prev, ++it)
         {
-            Distance dist = strategy.apply(point, *prev, *it);
-            if (geometry::math::equals(dist, zero))
+            Distance const dist = strategy.apply(point, *prev, *it);
+
+            // Stop only if we find exactly zero distance
+            // otherwise it may stop at some very small value and miss the min
+            if (dist == zero)
             {
                 dist_min = zero;
                 it_min1 = prev;