diff --git a/include/boost/geometry/algorithms/detail/is_valid/ring.hpp b/include/boost/geometry/algorithms/detail/is_valid/ring.hpp index 46fb413d3..bb3d036da 100644 --- a/include/boost/geometry/algorithms/detail/is_valid/ring.hpp +++ b/include/boost/geometry/algorithms/detail/is_valid/ring.hpp @@ -21,12 +21,12 @@ #include -#include #include #include #include #include +#include #include #include #include @@ -151,29 +151,40 @@ struct is_valid_ring { // return invalid if any of the following condition holds: // (a) the ring's size is below the minimal one - // (b) the ring is not topologically closed - // (c) the ring has spikes - // (d) the ring has duplicate points (if AllowDuplicates is false) - // (e) the boundary of the ring has self-intersections - // (f) the order of the points is inconsistent with the defined order + // (b) the ring consists of at most two distinct points + // (c) the ring is not topologically closed + // (d) the ring has spikes + // (e) the ring has duplicate points (if AllowDuplicates is false) + // (f) the boundary of the ring has self-intersections + // (g) the order of the points is inconsistent with the defined order // // Note: no need to check if the area is zero. If this is the // case, then the ring must have at least two spikes, which is // checked by condition (c). closure_selector const closure = geometry::closure::value; + typedef typename closeable_view::type view_type; - if ( boost::size(ring) - < core_detail::closure::minimum_ring_size::value ) + if (boost::size(ring) + < core_detail::closure::minimum_ring_size::value) { visitor.template apply(); return false; } + view_type const view(ring); + if (detail::num_distinct_consecutive_points + < + view_type, 4u, true, + not_equal_to::type> + >::apply(view) + < 4u) + { + visitor.template apply(); + return false; + } + return - /*( boost::size(ring) - >= core_detail::closure::minimum_ring_size::value ) - &&*/ is_topologically_closed::apply(ring, visitor) && (AllowDuplicates || ! has_duplicates::apply(ring, visitor))