From fb5ca1bb8e116b2fa1c17c1e93aa68c5642cbee8 Mon Sep 17 00:00:00 2001 From: Jiri Drbalek Date: Thu, 25 Jan 2018 13:28:47 +0000 Subject: [PATCH 1/2] offset_converter: Don't filter out closing and moving segments --- include/mapnik/offset_converter.hpp | 8 ++++ test/unit/vertex_adapter/offset_converter.cpp | 45 +++++++++++++++++++ 2 files changed, 53 insertions(+) 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/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); +} + } From 223a24075113b35a15594d92874655ef649c5da3 Mon Sep 17 00:00:00 2001 From: Jiri Drbalek Date: Fri, 26 Jan 2018 11:41:19 +0000 Subject: [PATCH 2/2] Update visual tests --- test/data-visual | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/data-visual b/test/data-visual index 62747ea33..b73757062 160000 --- a/test/data-visual +++ b/test/data-visual @@ -1 +1 @@ -Subproject commit 62747ea33b88a62fbfc90f109cbf1899435e75da +Subproject commit b737570629aa453e13f12186735c53194445c53e