serialize comp-op in save_map - refs #1292

This commit is contained in:
Dane Springmeyer 2012-07-05 17:06:41 -07:00
parent 0de815ba03
commit 2f45de8fea
3 changed files with 23 additions and 0 deletions

View file

@ -79,6 +79,7 @@ enum composite_mode_e
}; };
MAPNIK_DECL boost::optional<composite_mode_e> comp_op_from_string(std::string const& name); MAPNIK_DECL boost::optional<composite_mode_e> comp_op_from_string(std::string const& name);
MAPNIK_DECL boost::optional<std::string> comp_op_to_string(composite_mode_e comp_op);
template <typename T1, typename T2> template <typename T1, typename T2>
MAPNIK_DECL void composite(T1 & dst, T2 & src, MAPNIK_DECL void composite(T1 & dst, T2 & src,

View file

@ -88,6 +88,17 @@ boost::optional<composite_mode_e> comp_op_from_string(std::string const& name)
return mode; return mode;
} }
boost::optional<std::string> comp_op_to_string(composite_mode_e comp_op)
{
boost::optional<std::string> 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 <typename T1, typename T2> template <typename T1, typename T2>
void composite(T1 & dst, T2 & src, composite_mode_e mode, void composite(T1 & dst, T2 & src, composite_mode_e mode,
float opacity, float opacity,

View file

@ -31,6 +31,7 @@
#include <mapnik/text_placements/simple.hpp> #include <mapnik/text_placements/simple.hpp>
#include <mapnik/text_placements/list.hpp> #include <mapnik/text_placements/list.hpp>
#include <mapnik/text_placements/dummy.hpp> #include <mapnik/text_placements/dummy.hpp>
#include <mapnik/image_compositing.hpp>
// boost // boost
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
@ -538,6 +539,16 @@ void serialize_style( ptree & map_node, Map::const_style_iterator style_it, bool
set_attr(style_node, "opacity", opacity); set_attr(style_node, "opacity", opacity);
} }
boost::optional<composite_mode_e> 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 it = style.get_rules().begin();
rules::const_iterator end = style.get_rules().end(); rules::const_iterator end = style.get_rules().end();
for (; it != end; ++it) for (; it != end; ++it)