From a4b42e8bbc992e9426ec927b9109f592fe2f13bc Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Mon, 16 Jun 2014 03:30:53 +0300 Subject: [PATCH] [algorithms][is_valid] re-implement has_spikes to return false if the range has one or two distinct points (instead of calling BOOST_ASSERT) --- .../algorithms/detail/is_valid/has_spikes.hpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/is_valid/has_spikes.hpp b/include/boost/geometry/algorithms/detail/is_valid/has_spikes.hpp index d0733fe8d..9b9501748 100644 --- a/include/boost/geometry/algorithms/detail/is_valid/has_spikes.hpp +++ b/include/boost/geometry/algorithms/detail/is_valid/has_spikes.hpp @@ -12,7 +12,6 @@ #include -#include #include #include @@ -82,10 +81,20 @@ struct has_spikes iterator prev = boost::begin(view); iterator cur = std::find_if(prev, boost::end(view), not_equal(*prev)); - BOOST_ASSERT( cur != boost::end(view) ); + if ( cur == boost::end(view) ) + { + // the range has only one distinct point, so it + // cannot have a spike + return false; + } iterator next = std::find_if(cur, boost::end(view), not_equal(*cur)); - BOOST_ASSERT( next != boost::end(view) ); + if ( next == boost::end(view) ) + { + // the range has only two distinct points, so it + // cannot have a spike + return false; + } while ( next != boost::end(view) ) {