refactoring following comment on pull request

This commit is contained in:
Cezary Tarnowski 2011-12-13 15:28:18 +01:00
parent 0882f0e668
commit 79af8fdbc9
4 changed files with 17 additions and 18 deletions

View file

@ -213,12 +213,12 @@ struct symbolizer_attributes : public boost::static_visitor<>
void operator () (building_symbolizer const& sym) void operator () (building_symbolizer const& sym)
{ {
expression_ptr const& height_expr = sym.height(); expression_ptr const& height_expr = sym.height();
if (height_expr) if (height_expr)
{ {
expression_attributes f_attr(names_); expression_attributes f_attr(names_);
boost::apply_visitor(f_attr,*height_expr); boost::apply_visitor(f_attr,*height_expr);
} }
collect_metawriter(sym); collect_metawriter(sym);
} }
// TODO - support remaining syms // TODO - support remaining syms

View file

@ -71,8 +71,8 @@ void agg_renderer<T>::process(building_symbolizer const& sym,
expression_ptr height_expr = sym.height(); expression_ptr height_expr = sym.height();
if (height_expr) if (height_expr)
{ {
value_type result = boost::apply_visitor(evaluate<Feature,value_type>(feature), *height_expr); value_type result = boost::apply_visitor(evaluate<Feature,value_type>(feature), *height_expr);
height = result.to_double() * scale_factor_; height = result.to_double() * scale_factor_;
} }
for (unsigned i=0;i<feature.num_geometries();++i) for (unsigned i=0;i<feature.num_geometries();++i)

View file

@ -780,12 +780,12 @@ void cairo_renderer_base::process(building_symbolizer const& sym,
color const& fill = sym.get_fill(); color const& fill = sym.get_fill();
double height = 0.0; double height = 0.0;
expression_ptr height_expr = sym.height(); expression_ptr height_expr = sym.height();
if (height_expr) if (height_expr)
{ {
value_type result = boost::apply_visitor(evaluate<Feature,value_type>(feature), *height_expr); value_type result = boost::apply_visitor(evaluate<Feature,value_type>(feature), *height_expr);
height = 0.7071 * result.to_double(); height = 0.7071 * result.to_double();
} }
for (unsigned i = 0; i < feature.num_geometries(); ++i) for (unsigned i = 0; i < feature.num_geometries(); ++i)
{ {

View file

@ -241,10 +241,9 @@ public:
{ {
set_attr( sym_node, "fill-opacity", sym.get_opacity() ); set_attr( sym_node, "fill-opacity", sym.get_opacity() );
} }
if ( sym.height() != dfl.height() || explicit_defaults_ )
{ set_attr( sym_node, "height", to_expression_string(*sym.height()) );
set_attr( sym_node, "height", sym.height() );
}
add_metawriter_attributes(sym_node, sym); add_metawriter_attributes(sym_node, sym);
} }