diff --git a/include/mapnik/offset_converter.hpp b/include/mapnik/offset_converter.hpp index 85994809c..a39e209a8 100644 --- a/include/mapnik/offset_converter.hpp +++ b/include/mapnik/offset_converter.hpp @@ -129,6 +129,14 @@ struct offset_converter //break; // uncomment this to see all the curls vertex2d const& u0 = vertices_[i]; + + // End or beginning of a line or ring must not be filtered out + // to not to join lines or rings together. + if (u0.cmd == SEG_CLOSE || u0.cmd == SEG_MOVETO) + { + break; + } + vertex2d const& u1 = vertices_[i+1]; double const dx = u0.x - cur_.x; double const dy = u0.y - cur_.y; diff --git a/test/data-visual b/test/data-visual index a270d939f..d374baac6 160000 --- a/test/data-visual +++ b/test/data-visual @@ -1 +1 @@ -Subproject commit a270d939f1b2b978203b9a91a3cdb4eff9f9f826 +Subproject commit d374baac6cd72e7de665a27ded9b129e92661e18 diff --git a/test/unit/vertex_adapter/offset_converter.cpp b/test/unit/vertex_adapter/offset_converter.cpp index 96c796d06..1493127d4 100644 --- a/test/unit/vertex_adapter/offset_converter.cpp +++ b/test/unit/vertex_adapter/offset_converter.cpp @@ -336,4 +336,49 @@ SECTION("s curve") { } } +SECTION("offsect converter does not skip SEG_MOVETO or SEG_CLOSE vertices") { + + const double offset = 0.2; + + fake_path path = {}; + path.vertices_.emplace_back(-2, -2, mapnik::SEG_MOVETO); + path.vertices_.emplace_back( 2, -2, mapnik::SEG_LINETO); + path.vertices_.emplace_back( 2, 2, mapnik::SEG_LINETO); + path.vertices_.emplace_back(-2, 2, mapnik::SEG_LINETO); + path.vertices_.emplace_back(-2, -1.9, mapnik::SEG_LINETO); + path.vertices_.emplace_back( 0, 0, mapnik::SEG_CLOSE); + path.vertices_.emplace_back(-1.9, -1.9, mapnik::SEG_MOVETO); + path.vertices_.emplace_back( 1, -1, mapnik::SEG_LINETO); + path.vertices_.emplace_back( 1, 1, mapnik::SEG_LINETO); + path.vertices_.emplace_back(-1, 1, mapnik::SEG_LINETO); + path.vertices_.emplace_back(-1, -1, mapnik::SEG_LINETO); + path.vertices_.emplace_back( 0, 0, mapnik::SEG_CLOSE); + path.rewind(0); + + mapnik::offset_converter off_path(path); + off_path.set_offset(offset); + + unsigned cmd; + double x, y; + + unsigned move_to_count = 0; + unsigned close_count = 0; + + while((cmd = off_path.vertex(&x, &y)) != mapnik::SEG_END) + { + switch (cmd) + { + case mapnik::SEG_MOVETO: + move_to_count++; + break; + case mapnik::SEG_CLOSE: + close_count++; + break; + } + } + + CHECK(move_to_count == 2); + CHECK(close_count == 2); +} + }