+ experimental compositing symbolizer (fill only)

This commit is contained in:
Artem Pavlenko 2012-03-21 15:47:33 +00:00
parent aefa23fb5b
commit 95cfb061af
6 changed files with 72 additions and 4 deletions

View file

@ -94,6 +94,13 @@ public:
{ {
return "markers"; return "markers";
} }
template <typename Symbolizer>
std::string operator() ( Symbolizer const& sym)
{
boost::ignore_unused_variable_warning(sym);
return "unknown";
}
}; };
std::string get_symbol_type(const symbolizer& symbol) std::string get_symbol_type(const symbolizer& symbol)

View file

@ -97,6 +97,10 @@ public:
void process(markers_symbolizer const& sym, void process(markers_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_ptr const& feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
void process(compositing_symbolizer const& sym,
mapnik::feature_ptr const& feature,
proj_transform const& prj_trans);
inline bool process(rule::symbolizers const& /*syms*/, inline bool process(rule::symbolizers const& /*syms*/,
mapnik::feature_ptr const& /*feature*/, mapnik::feature_ptr const& /*feature*/,
proj_transform const& /*prj_trans*/) proj_transform const& /*prj_trans*/)

View file

@ -34,6 +34,7 @@
#include <mapnik/shield_symbolizer.hpp> #include <mapnik/shield_symbolizer.hpp>
#include <mapnik/text_symbolizer.hpp> #include <mapnik/text_symbolizer.hpp>
#include <mapnik/markers_symbolizer.hpp> #include <mapnik/markers_symbolizer.hpp>
#include <mapnik/compositing_symbolizer.hpp>
#include <mapnik/feature.hpp> #include <mapnik/feature.hpp>
#include <mapnik/expression.hpp> #include <mapnik/expression.hpp>
#include <mapnik/expression_string.hpp> #include <mapnik/expression_string.hpp>
@ -108,6 +109,12 @@ inline bool operator==(markers_symbolizer const& lhs,
return (&lhs == &rhs); return (&lhs == &rhs);
} }
inline bool operator==(compositing_symbolizer const& lhs,
compositing_symbolizer const& rhs)
{
return (&lhs == &rhs);
}
typedef boost::variant<point_symbolizer, typedef boost::variant<point_symbolizer,
line_symbolizer, line_symbolizer,
line_pattern_symbolizer, line_pattern_symbolizer,
@ -117,10 +124,8 @@ typedef boost::variant<point_symbolizer,
shield_symbolizer, shield_symbolizer,
text_symbolizer, text_symbolizer,
building_symbolizer, building_symbolizer,
markers_symbolizer> symbolizer; markers_symbolizer,
compositing_symbolizer> symbolizer;
class rule class rule
{ {

View file

@ -104,6 +104,7 @@ else: # Linux and others
source = Split( source = Split(
""" """
color.cpp color.cpp
compositing_symbolizer.cpp
conversions.cpp conversions.cpp
image_compositing.cpp image_compositing.cpp
box2d.cpp box2d.cpp
@ -251,6 +252,7 @@ source += Split(
agg/process_raster_symbolizer.cpp agg/process_raster_symbolizer.cpp
agg/process_shield_symbolizer.cpp agg/process_shield_symbolizer.cpp
agg/process_markers_symbolizer.cpp agg/process_markers_symbolizer.cpp
agg/process_compositing_symbolizer.cpp
""" """
) )

View file

@ -25,6 +25,7 @@
#include <mapnik/xml_tree.hpp> #include <mapnik/xml_tree.hpp>
#include <mapnik/version.hpp> #include <mapnik/version.hpp>
#include <mapnik/image_reader.hpp> #include <mapnik/image_reader.hpp>
#include <mapnik/image_compositing.hpp>
#include <mapnik/color.hpp> #include <mapnik/color.hpp>
#include <mapnik/color_factory.hpp> #include <mapnik/color_factory.hpp>
#include <mapnik/symbolizer.hpp> #include <mapnik/symbolizer.hpp>
@ -107,6 +108,7 @@ private:
void parse_shield_symbolizer(rule & rule, xml_node const& sym); void parse_shield_symbolizer(rule & rule, xml_node const& sym);
void parse_line_symbolizer(rule & rule, xml_node const& sym); void parse_line_symbolizer(rule & rule, xml_node const& sym);
void parse_polygon_symbolizer(rule & rule, xml_node const& sym); void parse_polygon_symbolizer(rule & rule, xml_node const& sym);
void parse_compositing_symbolizer(rule & rule, xml_node const& sym);
void parse_building_symbolizer(rule & rule, xml_node const& sym); void parse_building_symbolizer(rule & rule, xml_node const& sym);
void parse_raster_symbolizer(rule & rule, xml_node const& sym); void parse_raster_symbolizer(rule & rule, xml_node const& sym);
void parse_markers_symbolizer(rule & rule, xml_node const& sym); void parse_markers_symbolizer(rule & rule, xml_node const& sym);
@ -691,6 +693,10 @@ void map_parser::parse_rule(feature_type_style & style, xml_node const& r)
{ {
parse_polygon_pattern_symbolizer(rule, *symIter); parse_polygon_pattern_symbolizer(rule, *symIter);
} }
else if (symIter->is("CompositingSymbolizer"))
{
parse_compositing_symbolizer(rule, *symIter);
}
else if (symIter->is("TextSymbolizer")) else if (symIter->is("TextSymbolizer"))
{ {
parse_text_symbolizer(rule, *symIter); parse_text_symbolizer(rule, *symIter);
@ -1314,6 +1320,41 @@ void map_parser::parse_polygon_symbolizer(rule & rule, xml_node const & sym)
} }
} }
void map_parser::parse_compositing_symbolizer(rule & rule, xml_node const & sym)
{
try
{
compositing_symbolizer comp_sym;
// fill
optional<color> fill = sym.get_opt_attr<color>("fill");
if (fill) comp_sym.set_fill(*fill);
// fill-opacity
optional<double> opacity = sym.get_opt_attr<double>("fill-opacity");
if (opacity) comp_sym.set_opacity(*opacity);
// gamma
optional<double> gamma = sym.get_opt_attr<double>("gamma");
if (gamma) comp_sym.set_gamma(*gamma);
// gamma method
optional<gamma_method_e> gamma_method = sym.get_opt_attr<gamma_method_e>("gamma-method");
if (gamma_method) comp_sym.set_gamma_method(*gamma_method);
// smooth value
optional<double> smooth = sym.get_opt_attr<double>("smooth");
if (smooth) comp_sym.set_smooth(*smooth);
optional<std::string> comp_op_name = sym.get_opt_attr<std::string>("comp-op");
if (comp_op_name)
{
composite_mode_e comp_op = comp_op_from_string(*comp_op_name);
comp_sym.set_comp_op(comp_op);
}
rule.append(comp_sym);
}
catch (const config_error & ex)
{
ex.append_context("in CompositingSymbolizer", sym);
throw;
}
}
void map_parser::parse_building_symbolizer(rule & rule, xml_node const & sym) void map_parser::parse_building_symbolizer(rule & rule, xml_node const & sym)
{ {

View file

@ -321,6 +321,15 @@ public:
add_metawriter_attributes(sym_node, sym); add_metawriter_attributes(sym_node, sym);
} }
template <typename Symbolizer>
void operator () ( Symbolizer const& sym)
{
// not-supported
#ifdef MAPNIK_DEBUG
std::clog << typeid(sym).name() << " is not supported" << std::endl;
#endif
}
private: private:
serialize_symbolizer(); serialize_symbolizer();