diff --git a/include/mapnik/image_compositing.hpp b/include/mapnik/image_compositing.hpp index 65f173ba3..c4fbef407 100644 --- a/include/mapnik/image_compositing.hpp +++ b/include/mapnik/image_compositing.hpp @@ -79,6 +79,7 @@ enum composite_mode_e }; MAPNIK_DECL boost::optional comp_op_from_string(std::string const& name); +MAPNIK_DECL boost::optional comp_op_to_string(composite_mode_e comp_op); template MAPNIK_DECL void composite(T1 & dst, T2 & src, diff --git a/src/image_compositing.cpp b/src/image_compositing.cpp index 8eff43bb5..e6c64100e 100644 --- a/src/image_compositing.cpp +++ b/src/image_compositing.cpp @@ -88,6 +88,17 @@ boost::optional comp_op_from_string(std::string const& name) return mode; } +boost::optional comp_op_to_string(composite_mode_e comp_op) +{ + boost::optional mode; + comp_op_lookup_type::left_const_iterator left_iter = comp_lookup.left.find(comp_op); + if (left_iter != comp_lookup.left.end()) + { + mode.reset(left_iter->second); + } + return mode; +} + template void composite(T1 & dst, T2 & src, composite_mode_e mode, float opacity, diff --git a/src/save_map.cpp b/src/save_map.cpp index 5cd1c4756..6006a903c 100644 --- a/src/save_map.cpp +++ b/src/save_map.cpp @@ -31,6 +31,7 @@ #include #include #include +#include // boost #include @@ -538,6 +539,16 @@ void serialize_style( ptree & map_node, Map::const_style_iterator style_it, bool set_attr(style_node, "opacity", opacity); } + boost::optional comp_op = style.comp_op(); + if (comp_op) + { + set_attr(style_node, "comp-op", *comp_op_to_string(*comp_op)); + } + else if (explicit_defaults) + { + set_attr(style_node, "comp-op", "src-over"); + } + rules::const_iterator it = style.get_rules().begin(); rules::const_iterator end = style.get_rules().end(); for (; it != end; ++it)