diff --git a/include/mapnik/symbolizer.hpp b/include/mapnik/symbolizer.hpp index 96ef8deae..4a84203ea 100644 --- a/include/mapnik/symbolizer.hpp +++ b/include/mapnik/symbolizer.hpp @@ -51,8 +51,6 @@ // boost #include #include -// agg -#include "agg_pixfmt_rgba.h" namespace agg { struct trans_affine; } @@ -132,7 +130,8 @@ enum class property_types : std::uint8_t target_dash_array, target_colorizer, target_repeat_key, - target_group_symbolizer_properties + target_group_symbolizer_properties, + target_halo_comp_op }; inline bool operator==(symbolizer_base const& lhs, symbolizer_base const& rhs) @@ -174,7 +173,9 @@ struct expression_result typedef T result_type; static result_type convert(value_type const& val) { - return static_cast(val.convert()); + auto result = comp_op_from_string(val.to_string()); + if (result) return static_cast(*result); + return result_type(0); } }; @@ -188,18 +189,6 @@ struct expression_result } }; -template <> -struct expression_result -{ - typedef agg::comp_op_e result_type; - static result_type convert(value_type const& val) - { - auto result = comp_op_from_string(val.to_string()); - if (result) return static_cast(*result); - return agg::comp_op_src_over; - } -}; - // enum template diff --git a/src/load_map.cpp b/src/load_map.cpp index 5cfd2dac2..0272f783a 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -862,7 +862,7 @@ struct set_symbolizer_property_impl } catch (config_error const&) { - // try parser as an expression + // try parsing as an expression optional val = node.get_opt_attr(name); if (val) put(sym, key, *val); } @@ -878,13 +878,14 @@ struct set_symbolizer_property_impl std::string const& name = std::get<0>(get_meta(key)); try { - optional comp_op_name = node.get_opt_attr("comp-op"); + optional comp_op_name = node.get_opt_attr(name); + if (comp_op_name) { optional comp_op = comp_op_from_string(*comp_op_name); if (comp_op) { - put(sym, keys::comp_op, *comp_op); + put(sym, key, *comp_op); } else { @@ -1203,19 +1204,7 @@ void map_parser::parse_text_symbolizer(rule & rule, xml_node const& node) text_symbolizer text_symbol; parse_symbolizer_base(text_symbol, node); // halo-comp-op - optional comp_op_name = node.get_opt_attr("halo-comp-op"); - if (comp_op_name) - { - optional halo_comp_op = comp_op_from_string(*comp_op_name); - if (halo_comp_op) - { - put(text_symbol, keys::halo_comp_op, *halo_comp_op); - } - else - { - throw config_error("failed to parse halo-comp-op: '" + *comp_op_name + "'"); - } - } + set_symbolizer_property(text_symbol, keys::halo_comp_op, node); put(text_symbol, keys::text_placements_, placement_finder); optional halo_rasterizer_ = node.get_opt_attr("halo-rasterizer"); diff --git a/src/symbolizer_keys.cpp b/src/symbolizer_keys.cpp index 0eff55b62..a94fd7c3d 100644 --- a/src/symbolizer_keys.cpp +++ b/src/symbolizer_keys.cpp @@ -98,7 +98,7 @@ static const property_meta_type key_meta[to_integral(keys::MAX_SYMBOLIZER_KEY)] property_meta_type{ "largest-box-only", false, nullptr, property_types::target_bool }, property_meta_type{ "minimum-path-length", false, nullptr, property_types::target_double }, property_meta_type{ "halo-comp-op", enumeration_wrapper(src_over), - [](enumeration_wrapper e) { return *comp_op_to_string(composite_mode_e(e.value)); }, property_types::target_comp_op}, + [](enumeration_wrapper e) { return *comp_op_to_string(composite_mode_e(e.value)); }, property_types::target_halo_comp_op}, }; property_meta_type const& get_meta(mapnik::keys key)