diff --git a/include/boost/geometry/algorithms/detail/equals/collect_vectors.hpp b/include/boost/geometry/algorithms/detail/equals/collect_vectors.hpp index 54f0eaf22..c809f0064 100644 --- a/include/boost/geometry/algorithms/detail/equals/collect_vectors.hpp +++ b/include/boost/geometry/algorithms/detail/equals/collect_vectors.hpp @@ -111,6 +111,9 @@ struct range_collect_vectors return; } + typedef boost::range_size::type collection_size_t; + collection_size_t c_old_size = boost::size(collection); + typedef typename boost::range_iterator::type iterator; bool first = true; @@ -150,10 +153,14 @@ struct range_collect_vectors } // If first one has same direction as last one, remove first one - if (boost::size(collection) > 1 - && collection.front().same_direction(collection.back())) + collection_size_t collected_count = boost::size(collection) - c_old_size; + if ( collected_count > 1 ) { - collection.erase(collection.begin()); + typedef typename boost::range_iterator::type c_iterator; + c_iterator first = collection.begin() + c_old_size; + + if ( first->same_direction(collection.back()) ) + collection.erase(first); } } }; diff --git a/test/algorithms/equals.cpp b/test/algorithms/equals.cpp index c651b13ee..4ba31d64c 100644 --- a/test/algorithms/equals.cpp +++ b/test/algorithms/equals.cpp @@ -98,6 +98,9 @@ void test_all() // Is this equal? To be decided. //test_geometry("ls1", "LINESTRING(1 1,2 2)", "LINESTRING(2 2,1 1)", true); + test_geometry("poly_holes_shifted_points", + "POLYGON((0 0,0 3,3 3,3 0,0 0),(1 1,2 1,2 2,1 2,1 1))", + "POLYGON((0 0,0 3,3 3,3 0,0 0),(2 2,1 2,1 1,2 1,2 2))", true); }