diff --git a/bindings/python/mapnik_line_pattern_symbolizer.cpp b/bindings/python/mapnik_line_pattern_symbolizer.cpp index ed409018d..ef8c1148c 100644 --- a/bindings/python/mapnik_line_pattern_symbolizer.cpp +++ b/bindings/python/mapnik_line_pattern_symbolizer.cpp @@ -26,6 +26,7 @@ #include #include #include +#include "mapnik_svg.hpp" using mapnik::line_pattern_symbolizer; using mapnik::path_processor_type; @@ -52,5 +53,8 @@ void export_line_pattern_symbolizer() init ("")) //.def_pickle(line_pattern_symbolizer_pickle_suite()) + .add_property("transform", + mapnik::get_svg_transform, + mapnik::set_svg_transform) ; } diff --git a/bindings/python/mapnik_markers_symbolizer.cpp b/bindings/python/mapnik_markers_symbolizer.cpp index 77f325295..b2cabd8e3 100644 --- a/bindings/python/mapnik_markers_symbolizer.cpp +++ b/bindings/python/mapnik_markers_symbolizer.cpp @@ -26,6 +26,7 @@ #include #include #include +#include "mapnik_svg.hpp" using mapnik::markers_symbolizer; using mapnik::symbolizer_with_image; @@ -107,5 +108,8 @@ void export_markers_symbolizer() &markers_symbolizer::get_opacity, &markers_symbolizer::set_opacity, "Set/get the text opacity") + .add_property("transform", + mapnik::get_svg_transform, + mapnik::set_svg_transform) ; } diff --git a/bindings/python/mapnik_point_symbolizer.cpp b/bindings/python/mapnik_point_symbolizer.cpp index d79a13f0c..c2b21f29b 100644 --- a/bindings/python/mapnik_point_symbolizer.cpp +++ b/bindings/python/mapnik_point_symbolizer.cpp @@ -26,6 +26,7 @@ #include #include #include +#include "mapnik_svg.hpp" using mapnik::point_symbolizer; using mapnik::symbolizer_with_image; @@ -70,10 +71,11 @@ struct point_symbolizer_pickle_suite : boost::python::pickle_suite namespace { using namespace boost::python; + const std::string get_filename(mapnik::point_symbolizer& symbolizer) { return path_processor_type::to_string(*symbolizer.get_filename()); -} +} } @@ -99,5 +101,8 @@ void export_point_symbolizer() .add_property("ignore_placement", &point_symbolizer::get_ignore_placement, &point_symbolizer::set_ignore_placement) + .add_property("transform", + mapnik::get_svg_transform, + mapnik::set_svg_transform) ; } diff --git a/bindings/python/mapnik_polygon_pattern_symbolizer.cpp b/bindings/python/mapnik_polygon_pattern_symbolizer.cpp index 356cabc89..9e61ecef3 100644 --- a/bindings/python/mapnik_polygon_pattern_symbolizer.cpp +++ b/bindings/python/mapnik_polygon_pattern_symbolizer.cpp @@ -26,6 +26,7 @@ #include #include "mapnik_enumeration.hpp" #include +#include "mapnik_svg.hpp" using namespace mapnik; using mapnik::polygon_pattern_symbolizer; @@ -82,6 +83,8 @@ void export_polygon_pattern_symbolizer() &polygon_pattern_symbolizer::get_alignment, &polygon_pattern_symbolizer::set_alignment, "Set/get the alignment of the pattern") - + .add_property("transform", + mapnik::get_svg_transform, + mapnik::set_svg_transform) ; } diff --git a/bindings/python/mapnik_shield_symbolizer.cpp b/bindings/python/mapnik_shield_symbolizer.cpp index cb16b47b3..46ed62da5 100644 --- a/bindings/python/mapnik_shield_symbolizer.cpp +++ b/bindings/python/mapnik_shield_symbolizer.cpp @@ -26,6 +26,7 @@ #include #include #include +#include "mapnik_svg.hpp" using mapnik::color; using mapnik::shield_symbolizer; @@ -218,9 +219,9 @@ void export_shield_symbolizer() .add_property("filename", get_filename, &shield_symbolizer::set_filename) - //.add_property("transform", - // &shield_symbolizer::get_transform, - // &shield_symbolizer::set_transform) + .add_property("transform", + mapnik::get_svg_transform, + mapnik::set_svg_transform) ; diff --git a/bindings/python/mapnik_svg.hpp b/bindings/python/mapnik_svg.hpp new file mode 100644 index 000000000..c16b2e94f --- /dev/null +++ b/bindings/python/mapnik_svg.hpp @@ -0,0 +1,53 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2010 Robert Coup + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ +#ifndef MAPNIK_PYTHON_BINDING_SVG_INCLUDED +#define MAPNIK_PYTHON_BINDING_SVG_INCLUDED + +#include +#include +#include +#include "agg_trans_affine.h" + +namespace mapnik { +using namespace boost::python; + +template +const std::string get_svg_transform(T& symbolizer) +{ + mapnik::transform_type matrix = symbolizer.get_transform(); + std::string s = (boost::format("matrix(%f, %f, %f, %f, %f, %f)") % matrix[0] % matrix[1] % matrix[2] % matrix[3] % matrix[4] % matrix[5]).str(); + return s; +}; + +template +void set_svg_transform(T& symbolizer, std::string const& transform_wkt) +{ + agg::trans_affine tr; + mapnik::svg::parse_transform(transform_wkt, tr); + mapnik::transform_type matrix; + tr.store_to(&matrix[0]); + symbolizer.set_transform(matrix); +}; + +} // end of namespace mapnik + +#endif // MAPNIK_PYTHON_BINDING_SVG_INCLUDED