diff --git a/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp b/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp index 202a46c4d..c9ea6f1c7 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp @@ -159,23 +159,14 @@ struct buffer_range point_type penultimate_point, ultimate_point; // last two points from begin/end - for (Iterator prev = it++; it != end; ++it) { if (! detail::equals::equals_point_point(*prev, *it)) { output_point_type p1, p2; - penultimate_point = *prev; - ultimate_point = *it; generate_side(*prev, *it, side, distance_strategy, p1, p2); - if (first) - { - first = false; - first_p1 = p1; - first_p2 = p2; - } - else + if (! first) { add_join(collection, *prev, previous_p1, previous_p2, @@ -183,11 +174,20 @@ struct buffer_range side, distance_strategy, join_strategy, robust_policy); } - collection.add_piece(strategy::buffer::buffered_segment, *prev, *it, p1, p2); + collection.add_piece(strategy::buffer::buffered_segment, + *prev, *it, p1, p2, first); + penultimate_point = *prev; + ultimate_point = *it; previous_p1 = p1; previous_p2 = p2; prev = it; + if (first) + { + first = false; + first_p1 = p1; + first_p2 = p2; + } } } diff --git a/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp b/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp index 99057d269..0373c7ce7 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp @@ -590,13 +590,8 @@ struct buffered_piece_collection } inline void add_piece(strategy::buffer::piece_type type, point_type const& p1, point_type const& p2, - point_type const& b1, point_type const& b2) + point_type const& b1, point_type const& b2, bool first) { - // For the first segment, add starting point, else skip that and - // decrease next segment_index because it uses the last one - bool const first = m_pieces.empty() - || m_pieces.back().first_seg_id.multi_index != current_segment_id.multi_index; - piece& pc = add_piece(type, ! first); // If it follows a non-join (so basically the same piece-type) point b1 should be added.