Permalink
Browse files

serialize all properties shared by all symbolizers

  • Loading branch information...
Dane Springmeyer
Dane Springmeyer committed Jul 6, 2012
1 parent 9beceae commit c44b92193fa1fbb47da94533d71cca811f5f8824
Showing with 39 additions and 27 deletions.
  1. +39 −27 src/save_map.cpp
View
@@ -75,7 +75,7 @@ class serialize_symbolizer : public boost::static_visitor<>
{
set_attr( sym_node, "placement", sym.get_point_placement() );
}
- add_metawriter_attributes(sym_node, sym);
+ serialize_symbolizer_base(sym_node, sym);
}
void operator () ( line_symbolizer const& sym )
@@ -85,13 +85,13 @@ class serialize_symbolizer : public boost::static_visitor<>
const stroke & strk = sym.get_stroke();
add_stroke_attributes(sym_node, strk);
- add_metawriter_attributes(sym_node, sym);
line_symbolizer dfl;
if ( sym.get_rasterizer() != dfl.get_rasterizer() || explicit_defaults_ )
{
set_attr( sym_node, "rasterizer", sym.get_rasterizer() );
}
+ serialize_symbolizer_base(sym_node, sym);
}
void operator () ( line_pattern_symbolizer const& sym )
@@ -101,7 +101,7 @@ class serialize_symbolizer : public boost::static_visitor<>
ptree()))->second;
add_image_attributes( sym_node, sym );
- add_metawriter_attributes(sym_node, sym);
+ serialize_symbolizer_base(sym_node, sym);
}
void operator () ( polygon_symbolizer const& sym )
@@ -126,7 +126,7 @@ class serialize_symbolizer : public boost::static_visitor<>
{
set_attr( sym_node, "gamma-method", sym.get_gamma_method() );
}
- add_metawriter_attributes(sym_node, sym);
+ serialize_symbolizer_base(sym_node, sym);
}
void operator () ( polygon_pattern_symbolizer const& sym )
@@ -149,7 +149,7 @@ class serialize_symbolizer : public boost::static_visitor<>
set_attr( sym_node, "gamma-method", sym.get_gamma_method() );
}
add_image_attributes( sym_node, sym );
- add_metawriter_attributes(sym_node, sym);
+ serialize_symbolizer_base(sym_node, sym);
}
void operator () ( raster_symbolizer const& sym )
@@ -183,7 +183,7 @@ class serialize_symbolizer : public boost::static_visitor<>
serialize_raster_colorizer(sym_node, sym.get_colorizer(),
explicit_defaults_);
}
- //Note: raster_symbolizer doesn't support metawriters
+ serialize_symbolizer_base(sym_node, sym);
}
void operator () ( shield_symbolizer const& sym )
@@ -194,7 +194,6 @@ class serialize_symbolizer : public boost::static_visitor<>
add_font_attributes(sym_node, sym);
add_image_attributes(sym_node, sym);
- add_metawriter_attributes(sym_node, sym);
// pseudo-default-construct a shield_symbolizer. It is used
// to avoid printing of attributes with default values without
@@ -220,7 +219,7 @@ class serialize_symbolizer : public boost::static_visitor<>
{
set_attr(sym_node, "shield-dy", displacement.second);
}
-
+ serialize_symbolizer_base(sym_node, sym);
}
void operator () ( text_symbolizer const& sym )
@@ -230,7 +229,7 @@ class serialize_symbolizer : public boost::static_visitor<>
ptree()))->second;
add_font_attributes( sym_node, sym);
- add_metawriter_attributes(sym_node, sym);
+ serialize_symbolizer_base(sym_node, sym);
}
void operator () ( building_symbolizer const& sym )
@@ -252,7 +251,7 @@ class serialize_symbolizer : public boost::static_visitor<>
set_attr( sym_node, "height", mapnik::to_expression_string(*sym.height()) );
}
- add_metawriter_attributes(sym_node, sym);
+ serialize_symbolizer_base(sym_node, sym);
}
void operator () ( markers_symbolizer const& sym)
@@ -313,7 +312,7 @@ class serialize_symbolizer : public boost::static_visitor<>
add_stroke_attributes(sym_node, *strk);
}
- add_metawriter_attributes(sym_node, sym);
+ serialize_symbolizer_base(sym_node, sym);
}
template <typename Symbolizer>
@@ -328,6 +327,34 @@ class serialize_symbolizer : public boost::static_visitor<>
private:
serialize_symbolizer();
+ void serialize_symbolizer_base(ptree & node, symbolizer_base const& sym)
+ {
+ symbolizer_base dfl = symbolizer_base();
+ if (!sym.get_metawriter_name().empty() || explicit_defaults_) {
+ set_attr(node, "meta-writer", sym.get_metawriter_name());
+ }
+ if (!sym.get_metawriter_properties_overrides().empty() || explicit_defaults_) {
+ set_attr(node, "meta-output", sym.get_metawriter_properties_overrides().to_string());
+ }
+ if (sym.get_transform())
+ {
+ std::string tr_str = sym.get_transform_string();
+ set_attr( node, "geometry-transform", tr_str );
+ }
+ if (sym.clip() != dfl.clip() || explicit_defaults_)
+ {
+ set_attr( node, "clip", sym.clip() );
+ }
+ if (sym.smooth() != dfl.smooth() || explicit_defaults_)
+ {
+ set_attr( node, "smooth", sym.smooth() );
+ }
+ if (sym.comp_op() != dfl.comp_op() || explicit_defaults_)
+ {
+ set_attr( node, "comp-op", *comp_op_to_string(sym.comp_op()) );
+ }
+ }
+
void serialize_raster_colorizer(ptree & sym_node,
raster_colorizer_ptr const& colorizer,
bool explicit_defaults)
@@ -352,7 +379,7 @@ class serialize_symbolizer : public boost::static_visitor<>
}
- void add_image_attributes(ptree & node, const symbolizer_with_image & sym)
+ void add_image_attributes(ptree & node, symbolizer_with_image const& sym)
{
if (sym.get_filename())
{
@@ -442,21 +469,6 @@ class serialize_symbolizer : public boost::static_visitor<>
}
}
- void add_metawriter_attributes(ptree & node, symbolizer_base const& sym)
- {
- if (!sym.get_metawriter_name().empty() || explicit_defaults_) {
- set_attr(node, "meta-writer", sym.get_metawriter_name());
- }
- if (!sym.get_metawriter_properties_overrides().empty() || explicit_defaults_) {
- set_attr(node, "meta-output", sym.get_metawriter_properties_overrides().to_string());
- }
- if (sym.get_transform())
- {
- std::string tr_str = sym.get_transform_string();
- set_attr( node, "view-transform", tr_str );
- }
- }
-
ptree & rule_;
bool explicit_defaults_;
};

0 comments on commit c44b921

Please sign in to comment.