From 2f9f45433430e799904b821ecf3deba28c995263 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Wed, 2 Apr 2014 20:21:32 +0200 Subject: [PATCH] [get_turns] fix for MultiLinestrings containing Ls with equal points In this case no sections were generated for those "empty" Linestrings but if there were some sections already generated they could be marked as last_non_duplicated. --- .../geometry/algorithms/detail/sections/sectionalize.hpp | 2 +- test/algorithms/overlay/get_turns_linear_linear.cpp | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/sections/sectionalize.hpp b/include/boost/geometry/algorithms/detail/sections/sectionalize.hpp index 71c3a9bb1..c4b6ac7c5 100644 --- a/include/boost/geometry/algorithms/detail/sections/sectionalize.hpp +++ b/include/boost/geometry/algorithms/detail/sections/sectionalize.hpp @@ -285,7 +285,7 @@ struct sectionalize_part section_type section; bool mark_first_non_duplicated = true; - std::size_t last_non_duplicate_index = 0; + std::size_t last_non_duplicate_index = sections.size(); iterator_type it = boost::begin(range); diff --git a/test/algorithms/overlay/get_turns_linear_linear.cpp b/test/algorithms/overlay/get_turns_linear_linear.cpp index ebaff5128..63dae1734 100644 --- a/test/algorithms/overlay/get_turns_linear_linear.cpp +++ b/test/algorithms/overlay/get_turns_linear_linear.cpp @@ -22,14 +22,15 @@ //TEST //#include -//#include -//#include +#include +#include template void test_all() { typedef bg::model::point pt; typedef bg::model::linestring ls; + typedef bg::model::multi_linestring mls; test_geometry("LINESTRING(0 0,2 0)", "LINESTRING(0 0,2 0)", "tii", "txx"); test_geometry("LINESTRING(0 0,2 0)", "LINESTRING(2 0,0 0)", "tix", "txi"); @@ -120,6 +121,10 @@ void test_all() // to_svg("LINESTRING(31 0,15 0,10 5,5 5,4 0,1 0,0 0,-1 1)", "LINESTRING(-1 -1,0 0,1 0,2 0,2.5 1,3 0,30 0)", "test33.svg"); // to_svg("LINESTRING(31 0,15 0,10 5,5 5,4 0,1 0,0 0,-1 1)", "LINESTRING(30 0,3 0,2.5 1,2 0,1 0,0 0,-1 -1)", "test34.svg"); //} + + test_geometry("MULTILINESTRING((0 0,10 0,30 0))", + "MULTILINESTRING((0 10,5 0,20 0,20 0,30 0),(2 0,2 0),(3 0,3 0,3 0))", + expected("mii")("ccc")("ccc")("txx")); } int test_main(int, char* [])