From 9862ac66bfe79174211eb59f47061b9da6e5687d Mon Sep 17 00:00:00 2001 From: Jiri Drbalek Date: Tue, 31 Mar 2015 10:29:33 +0000 Subject: [PATCH 1/7] fix compile json grammar with boost 1.49 --- include/mapnik/json/generic_json.hpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/mapnik/json/generic_json.hpp b/include/mapnik/json/generic_json.hpp index e86e9aa40..ec5a7b718 100644 --- a/include/mapnik/json/generic_json.hpp +++ b/include/mapnik/json/generic_json.hpp @@ -57,8 +57,7 @@ struct unicode_string : qi::grammar struct push_utf8 { - template - struct result { typedef void type; }; + typedef void result_type; void operator()(std::string& utf8, uchar code_point) const { @@ -71,8 +70,7 @@ struct push_utf8 struct push_esc { - template - struct result { typedef void type; }; + typedef void result_type; void operator()(std::string& utf8, uchar c) const { From c1bc8ffc649fbccf7e34a7f68ee3bdb01d077d4c Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 13 Apr 2015 11:17:17 +0200 Subject: [PATCH 2/7] simlified_converter - use start (move_to) x,y on close_path command (drops tiny islands) --- include/mapnik/simplify_converter.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/mapnik/simplify_converter.hpp b/include/mapnik/simplify_converter.hpp index b31a0bff5..e9a88c4cf 100644 --- a/include/mapnik/simplify_converter.hpp +++ b/include/mapnik/simplify_converter.hpp @@ -244,7 +244,8 @@ private: // We eliminated the previous point because it was too close, but // we have to output it now anyway, since this is the end of the // vertex stream. Make sure that we output SEG_CLOSE in the next call. - vtx = last; + vtx.x = start_vertex_.x; + vtx.y = start_vertex_.y; status_ = closing; } break; From 4f3c8663a37de1c09b70521582ff2f1808aefe04 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 13 Apr 2015 11:38:38 +0200 Subject: [PATCH 3/7] visual tests : fix marker-on-hex-grid --- include/mapnik/renderer_common/process_markers_symbolizer.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/mapnik/renderer_common/process_markers_symbolizer.hpp b/include/mapnik/renderer_common/process_markers_symbolizer.hpp index 799fff7af..14660fdd3 100644 --- a/include/mapnik/renderer_common/process_markers_symbolizer.hpp +++ b/include/mapnik/renderer_common/process_markers_symbolizer.hpp @@ -171,9 +171,9 @@ struct render_marker_symbolizer_visitor if (clip) // optional clip (default: true) { geometry::geometry_types type = geometry::geometry_type(feature_.get_geometry()); - if (type == geometry::geometry_types::Polygon) + if (type == geometry::geometry_types::Polygon || type == geometry::geometry_types::MultiPolygon) converter.template set(); - else if (type == geometry::geometry_types::LineString) + else if (type == geometry::geometry_types::LineString || type == geometry::geometry_types::MultiLineString) converter.template set(); } From 87e978a6b91c2b9daf4d5ac204518766713bae41 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 13 Apr 2015 15:03:19 +0200 Subject: [PATCH 4/7] prefer c++11 alias type declaration over typedef for consistency --- include/mapnik/json/generic_json.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/mapnik/json/generic_json.hpp b/include/mapnik/json/generic_json.hpp index 933470b08..c4fa67c28 100644 --- a/include/mapnik/json/generic_json.hpp +++ b/include/mapnik/json/generic_json.hpp @@ -57,7 +57,7 @@ struct unicode_string : qi::grammar struct push_utf8 { - typedef void result_type; + using result_type = void; void operator()(std::string& utf8, uchar code_point) const { @@ -70,7 +70,7 @@ struct push_utf8 struct push_esc { - typedef void result_type; + using result_type = void; void operator()(std::string& utf8, uchar c) const { From 1dc77443ab29dd6d4e127473fb90197f8c6e727f Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 13 Apr 2015 18:47:51 +0200 Subject: [PATCH 5/7] add vertex_adapter to work per polygon ring --- include/mapnik/vertex_adapters.hpp | 51 ++++++++++++++++++++++++++++++ tests/cxx/vertex_adapter.cpp | 35 +++++++++++++++++++- 2 files changed, 85 insertions(+), 1 deletion(-) diff --git a/include/mapnik/vertex_adapters.hpp b/include/mapnik/vertex_adapters.hpp index 20230b178..4a3966178 100644 --- a/include/mapnik/vertex_adapters.hpp +++ b/include/mapnik/vertex_adapters.hpp @@ -178,6 +178,57 @@ private: mutable bool start_loop_; }; +struct ring_vertex_adapter +{ + using value_type = typename point::value_type; + ring_vertex_adapter(linear_ring const& ring) + : ring_(ring), + current_index_(0), + end_index_(ring_.size()), + start_loop_(true) {} + + void rewind(unsigned) const + { + current_index_ = 0; + end_index_ = ring_.size(); + start_loop_ = true; + } + + unsigned vertex(value_type * x, value_type * y) const + { + if (current_index_ < end_index_) + { + auto const& coord = ring_[current_index_++]; + *x = coord.x; + *y = coord.y; + if (start_loop_) + { + start_loop_= false; + return mapnik::SEG_MOVETO; + } + if (current_index_ == end_index_) + { + *x = 0; + *y = 0; + return mapnik::SEG_CLOSE; + } + return mapnik::SEG_LINETO; + } + return mapnik::SEG_END; + } + + inline geometry_types type () const + { + return geometry_types::Polygon; + } + +private: + linear_ring const& ring_; + mutable std::size_t current_index_; + mutable std::size_t end_index_; + mutable bool start_loop_; +}; + template struct vertex_adapter_traits{}; diff --git a/tests/cxx/vertex_adapter.cpp b/tests/cxx/vertex_adapter.cpp index 503cee980..ef103b0a0 100644 --- a/tests/cxx/vertex_adapter.cpp +++ b/tests/cxx/vertex_adapter.cpp @@ -98,7 +98,40 @@ SECTION("polygon with hole") { REQUIRE( x == 0 ); REQUIRE( y == 0 ); - // first hole + // exterior ring via ring_vertex_adapter + mapnik::geometry::ring_vertex_adapter va2(g.exterior_ring); + cmd = va2.vertex(&x,&y); + REQUIRE( cmd == mapnik::SEG_MOVETO ); + REQUIRE( x == 0 ); + REQUIRE( y == 0 ); + + cmd = va2.vertex(&x,&y); + REQUIRE( cmd == mapnik::SEG_LINETO ); + REQUIRE( x == -10 ); + REQUIRE( y == 0 ); + + cmd = va2.vertex(&x,&y); + REQUIRE( cmd == mapnik::SEG_LINETO ); + REQUIRE( x == -10 ); + REQUIRE( y == 10 ); + + cmd = va2.vertex(&x,&y); + REQUIRE( cmd == mapnik::SEG_LINETO ); + REQUIRE( x == 0 ); + REQUIRE( y == 10 ); + + cmd = va2.vertex(&x,&y); + REQUIRE( cmd == mapnik::SEG_CLOSE ); + REQUIRE( x == 0 ); + REQUIRE( y == 0 ); + + // since ring adapter is only for exterior, next should be END + cmd = va2.vertex(&x,&y); + REQUIRE( cmd == mapnik::SEG_END ); + REQUIRE( x == 0 ); + REQUIRE( y == 0 ); + + // first hole for polygon_adapter cmd = va.vertex(&x,&y); REQUIRE( cmd == mapnik::SEG_MOVETO ); REQUIRE( x == -7 ); From feca4d9f9b01e04f51919170e8a64c1d9b0b8eb1 Mon Sep 17 00:00:00 2001 From: Blake Thompson Date: Tue, 14 Apr 2015 01:02:33 -0500 Subject: [PATCH 6/7] Updated the clipper dependency to allow it to have some methods linked externally --- deps/clipper/include/clipper.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/deps/clipper/include/clipper.hpp b/deps/clipper/include/clipper.hpp index 5af03f98f..fa3011306 100755 --- a/deps/clipper/include/clipper.hpp +++ b/deps/clipper/include/clipper.hpp @@ -178,10 +178,10 @@ void SimplifyPolygon(const Path &in_poly, Paths &out_polys, PolyFillType fillTyp void SimplifyPolygons(const Paths &in_polys, Paths &out_polys, PolyFillType fillType = pftEvenOdd); void SimplifyPolygons(Paths &polys, PolyFillType fillType = pftEvenOdd); -void CleanPolygon(const Path& in_poly, Path& out_poly, double distance = 1.415); -void CleanPolygon(Path& poly, double distance = 1.415); -void CleanPolygons(const Paths& in_polys, Paths& out_polys, double distance = 1.415); -void CleanPolygons(Paths& polys, double distance = 1.415); +MAPNIK_DECL void CleanPolygon(const Path& in_poly, Path& out_poly, double distance = 1.415); +MAPNIK_DECL void CleanPolygon(Path& poly, double distance = 1.415); +MAPNIK_DECL void CleanPolygons(const Paths& in_polys, Paths& out_polys, double distance = 1.415); +MAPNIK_DECL void CleanPolygons(Paths& polys, double distance = 1.415); void MinkowskiSum(const Path& pattern, const Path& path, Paths& solution, bool pathIsClosed); void MinkowskiSum(const Path& pattern, const Paths& paths, Paths& solution, bool pathIsClosed); From 26131fb7086f07f08931c071d4938edbd9199907 Mon Sep 17 00:00:00 2001 From: Blake Thompson Date: Wed, 15 Apr 2015 00:35:31 -0500 Subject: [PATCH 7/7] Updated clipper --- deps/clipper/include/clipper.hpp | 16 ++++++++-------- deps/clipper/src/clipper.cpp | 9 +++------ 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/deps/clipper/include/clipper.hpp b/deps/clipper/include/clipper.hpp index fa3011306..c1cb4a15f 100755 --- a/deps/clipper/include/clipper.hpp +++ b/deps/clipper/include/clipper.hpp @@ -1,8 +1,8 @@ /******************************************************************************* * * * Author : Angus Johnson * -* Version : 6.2.8 * -* Date : 10 February 2015 * +* Version : 6.2.9 * +* Date : 16 February 2015 * * Website : http://www.angusj.com * * Copyright : Angus Johnson 2010-2015 * * * @@ -170,13 +170,13 @@ private: friend class MAPNIK_DECL Clipper; //to access AllNodes }; -bool Orientation(const Path &poly); -double Area(const Path &poly); -int PointInPolygon(const IntPoint &pt, const Path &path); +MAPNIK_DECL bool Orientation(const Path &poly); +MAPNIK_DECL double Area(const Path &poly); +MAPNIK_DECL int PointInPolygon(const IntPoint &pt, const Path &path); -void SimplifyPolygon(const Path &in_poly, Paths &out_polys, PolyFillType fillType = pftEvenOdd); -void SimplifyPolygons(const Paths &in_polys, Paths &out_polys, PolyFillType fillType = pftEvenOdd); -void SimplifyPolygons(Paths &polys, PolyFillType fillType = pftEvenOdd); +MAPNIK_DECL void SimplifyPolygon(const Path &in_poly, Paths &out_polys, PolyFillType fillType = pftEvenOdd); +MAPNIK_DECL void SimplifyPolygons(const Paths &in_polys, Paths &out_polys, PolyFillType fillType = pftEvenOdd); +MAPNIK_DECL void SimplifyPolygons(Paths &polys, PolyFillType fillType = pftEvenOdd); MAPNIK_DECL void CleanPolygon(const Path& in_poly, Path& out_poly, double distance = 1.415); MAPNIK_DECL void CleanPolygon(Path& poly, double distance = 1.415); diff --git a/deps/clipper/src/clipper.cpp b/deps/clipper/src/clipper.cpp index 2e63bc7af..bc53d9159 100755 --- a/deps/clipper/src/clipper.cpp +++ b/deps/clipper/src/clipper.cpp @@ -1,8 +1,8 @@ /******************************************************************************* * * * Author : Angus Johnson * -* Version : 6.2.8 * -* Date : 10 February 2015 * +* Version : 6.2.9 * +* Date : 16 February 2015 * * Website : http://www.angusj.com * * Copyright : Angus Johnson 2010-2015 * * * @@ -969,16 +969,13 @@ TEdge* ClipperBase::ProcessBound(TEdge* E, bool NextIsForward) EStart = E->Prev; else EStart = E->Next; - if (EStart->OutIdx != Skip) - { - if (IsHorizontal(*EStart)) //ie an adjoining horizontal skip edge + if (IsHorizontal(*EStart)) //ie an adjoining horizontal skip edge { if (EStart->Bot.X != E->Bot.X && EStart->Top.X != E->Bot.X) ReverseHorizontal(*E); } else if (EStart->Bot.X != E->Bot.X) ReverseHorizontal(*E); - } } EStart = E;