From 03092107b68f9f71c035798e00ebe7f7c015dfdb Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Sun, 13 Jun 2010 20:24:46 +0000 Subject: [PATCH] + refactor path grammar to match svg spec close + ensure first 'moveto' command is always in absolute coordinates FIXME:probably better to modify path grammar to handle this. + vertex_stl_storage --- agg/include/agg_path_storage.h | 15 ++++++++------- include/mapnik/svg/svg_path_grammar.hpp | 6 ++++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/agg/include/agg_path_storage.h b/agg/include/agg_path_storage.h index f735b59b7..2f4b78fd7 100644 --- a/agg/include/agg_path_storage.h +++ b/agg/include/agg_path_storage.h @@ -869,7 +869,8 @@ namespace agg *x += x2; *y += y2; } - else if (is_vertex(m_vertices.prev_vertex(&x2, &y2))) + else if (!is_stop(m_vertices.last_command()) && + is_vertex(m_vertices.prev_vertex(&x2, &y2))) { *x += x2; *y += y2; @@ -1526,7 +1527,7 @@ namespace agg }; //-----------------------------------------------------------path_storage - typedef path_base > path_storage; + //typedef path_base > path_storage; // Example of declarations path_storage with pod_bvector as a container //----------------------------------------------------------------------- @@ -1538,11 +1539,11 @@ namespace agg // Example of declarations path_storage with std::vector as a container //--------------------------------------------------------------------------- -//#include -//namespace agg -//{ -// typedef path_base > > stl_path_storage; -//} +#include +namespace agg +{ + typedef path_base > > path_storage; +} diff --git a/include/mapnik/svg/svg_path_grammar.hpp b/include/mapnik/svg/svg_path_grammar.hpp index cdc69eaa4..fdce29dfd 100644 --- a/include/mapnik/svg/svg_path_grammar.hpp +++ b/include/mapnik/svg/svg_path_grammar.hpp @@ -71,8 +71,9 @@ namespace mapnik { namespace svg { using qi::no_case; start = +cmd; - cmd = M | L | H | V | C | S | Q | T | A | Z; - + cmd = M >> *drawto_cmd; + drawto_cmd = L | H | V | C | S | Q | T | A | Z; + M = (lit('M')[_a = false] | lit('m')[_a = true] ) >> coord[move_to_(_1,_a)] // move_to >> *(-lit(',') >> coord [ line_to_(_1,_a) ] ); // *line_to @@ -127,6 +128,7 @@ namespace mapnik { namespace svg { // rules qi::rule start; qi::rule cmd; + qi::rule drawto_cmd; qi::rule,SkipType> M; // M,m qi::rule,SkipType> L; // L,l qi::rule,SkipType> H; // H,h