+ move 'smooth' property to symbolizer_base level

+ remove 'SYMBOLIZER_FAST' completely
This commit is contained in:
Artem Pavlenko 2012-05-07 16:08:16 +01:00
parent 3a8d3c5042
commit 7e49a6f44e
13 changed files with 35 additions and 136 deletions

View file

@ -43,20 +43,11 @@ void export_line_symbolizer()
{
using namespace boost::python;
enumeration_<line_rasterizer_e>("line_rasterizer")
.value("FULL",RASTERIZER_FULL)
.value("FAST",RASTERIZER_FAST)
;
class_<line_symbolizer>("LineSymbolizer",
init<>("Default LineSymbolizer - 1px solid black"))
.def(init<stroke const&>("TODO"))
.def(init<color const& ,float>())
.def_pickle(line_symbolizer_pickle_suite())
.add_property("rasterizer",
&line_symbolizer::get_rasterizer,
&line_symbolizer::set_rasterizer,
"Set/get the rasterization method of the line of the point")
.add_property("stroke",make_function
(&line_symbolizer::get_stroke,
return_value_policy<copy_const_reference>()),

View file

@ -31,37 +31,23 @@
namespace mapnik
{
enum line_rasterizer_enum {
RASTERIZER_FULL, // agg::renderer_scanline_aa_solid
RASTERIZER_FAST, // agg::rasterizer_outline_aa, twice as fast but only good for thin lines
line_rasterizer_enum_MAX
};
DEFINE_ENUM( line_rasterizer_e, line_rasterizer_enum );
struct MAPNIK_DECL line_symbolizer : public symbolizer_base
{
explicit line_symbolizer()
: symbolizer_base(),
stroke_(),
rasterizer_p_(RASTERIZER_FULL),
smooth_(0.0),
offset_(0.0)
{}
line_symbolizer(stroke const& stroke)
: symbolizer_base(),
stroke_(stroke),
rasterizer_p_(RASTERIZER_FULL),
smooth_(0.0),
offset_(0.0)
{}
line_symbolizer(color const& pen,float width=1.0)
: symbolizer_base(),
stroke_(pen,width),
rasterizer_p_(RASTERIZER_FULL),
smooth_(0.0),
offset_(0.0)
{}
@ -74,27 +60,7 @@ struct MAPNIK_DECL line_symbolizer : public symbolizer_base
{
stroke_ = stk;
}
void set_rasterizer(line_rasterizer_e rasterizer_p)
{
rasterizer_p_ = rasterizer_p;
}
line_rasterizer_e get_rasterizer() const
{
return rasterizer_p_;
}
void set_smooth(double smooth)
{
smooth_ = smooth;
}
double smooth() const
{
return smooth_;
}
void set_offset(double val)
{
offset_ = val;
@ -107,8 +73,6 @@ struct MAPNIK_DECL line_symbolizer : public symbolizer_base
private:
stroke stroke_;
line_rasterizer_e rasterizer_p_;
double smooth_;
double offset_;
};
}

View file

@ -50,13 +50,10 @@ struct MAPNIK_DECL polygon_pattern_symbolizer :
double get_gamma() const;
void set_gamma_method(gamma_method_e gamma_method);
gamma_method_e get_gamma_method() const;
void set_smooth(double smooth);
double smooth() const;
private:
pattern_alignment_e alignment_;
double gamma_;
gamma_method_e gamma_method_;
double smooth_;
};
}

View file

@ -44,14 +44,11 @@ struct MAPNIK_DECL polygon_symbolizer : public symbolizer_base
double get_gamma() const;
void set_gamma_method(gamma_method_e gamma_method);
gamma_method_e get_gamma_method() const;
void set_smooth(double smooth);
double smooth() const;
private:
color fill_;
double opacity_;
double gamma_;
gamma_method_e gamma_method_;
double smooth_;
bool clip_;
};

View file

@ -103,6 +103,8 @@ public:
std::string get_transform_string() const;
void set_clip(bool clip);
bool clip() const;
void set_smooth(double smooth);
double smooth() const;
private:
metawriter_properties properties_;
metawriter_properties properties_complete_;
@ -111,6 +113,7 @@ private:
boost::optional<composite_mode_e> comp_op_;
transform_type affine_transform_;
bool clip_;
double smooth_value_;
};

View file

@ -59,13 +59,10 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
unsigned g=col.green();
unsigned b=col.blue();
unsigned a=col.alpha();
agg::rendering_buffer buf(current_buffer_->raw_data(),width_,height_, width_ * 4);
ras_ptr->reset();
set_gamma_method(stroke_, ras_ptr);
//metawriter_with_properties writer = sym.get_metawriter();
typedef boost::mpl::vector<clip_line_tag,transform_tag, offset_transform_tag, affine_transform_tag, smooth_tag, dash_tag, stroke_tag> conv_types;
vertex_converter<box2d<double>,rasterizer,line_symbolizer, proj_transform, CoordTransform,conv_types>
converter(query_extent_,*ras_ptr,sym,t_,prj_trans,scale_factor_);

View file

@ -26,15 +26,6 @@
namespace mapnik
{
static const char * line_rasterizer_strings[] = {
"full",
"fast",
""
};
IMPLEMENT_ENUM( line_rasterizer_e, line_rasterizer_strings )
//
}

View file

@ -96,7 +96,7 @@ private:
void parse_style(Map & map, xml_node const& sty);
void parse_layer(Map & map, xml_node const& lay);
void parse_metawriter(Map & map, xml_node const& lay);
void parse_metawriter_in_symbolizer(symbolizer_base &sym, xml_node const& pt);
void parse_symbolizer_base(symbolizer_base &sym, xml_node const& pt);
void parse_fontset(Map & map, xml_node const & fset);
bool parse_font(font_set & fset, xml_node const& f);
@ -819,7 +819,7 @@ void map_parser::parse_rule(feature_type_style & style, xml_node const& r)
}
}
void map_parser::parse_metawriter_in_symbolizer(symbolizer_base &sym, xml_node const &pt)
void map_parser::parse_symbolizer_base(symbolizer_base &sym, xml_node const &pt)
{
optional<std::string> comp_op_name = pt.get_opt_attr<std::string>("comp-op");
if (comp_op_name)
@ -856,6 +856,10 @@ void map_parser::parse_metawriter_in_symbolizer(symbolizer_base &sym, xml_node c
optional<boolean> clip = pt.get_opt_attr<boolean>("clip");
if (clip) sym.set_clip(*clip);
// smooth value
optional<double> smooth = pt.get_opt_attr<double>("smooth");
if (smooth) sym.set_smooth(*smooth);
optional<std::string> writer = pt.get_opt_attr<std::string>("meta-writer");
if (!writer) return;
optional<std::string> output = pt.get_opt_attr<std::string>("meta-output");
@ -949,7 +953,7 @@ void map_parser::parse_point_symbolizer(rule & rule, xml_node const & sym)
}
}
}
parse_metawriter_in_symbolizer(symbol, sym);
parse_symbolizer_base(symbol, sym);
rule.append(symbol);
}
catch (const config_error & ex)
@ -1075,7 +1079,7 @@ void map_parser::parse_markers_symbolizer(rule & rule, xml_node const& sym)
marker_type_e marker_type = sym.get_attr<marker_type_e>("marker-type", dfl_marker_type);
symbol.set_marker_type(marker_type);
parse_metawriter_in_symbolizer(symbol, sym);
parse_symbolizer_base(symbol, sym);
rule.append(symbol);
}
catch (const config_error & ex)
@ -1111,7 +1115,7 @@ void map_parser::parse_line_pattern_symbolizer(rule & rule, xml_node const & sym
}
line_pattern_symbolizer symbol(expr);
parse_metawriter_in_symbolizer(symbol, sym);
parse_symbolizer_base(symbol, sym);
rule.append(symbol);
}
catch (image_reader_exception const & ex)
@ -1175,11 +1179,7 @@ void map_parser::parse_polygon_pattern_symbolizer(rule & rule,
optional<gamma_method_e> gamma_method = sym.get_opt_attr<gamma_method_e>("gamma-method");
if (gamma_method) symbol.set_gamma_method(*gamma_method);
// smooth value
optional<double> smooth = sym.get_opt_attr<double>("smooth");
if (smooth) symbol.set_smooth(*smooth);
parse_metawriter_in_symbolizer(symbol, sym);
parse_symbolizer_base(symbol, sym);
rule.append(symbol);
}
catch (image_reader_exception const & ex)
@ -1222,7 +1222,7 @@ void map_parser::parse_text_symbolizer(rule & rule, xml_node const& sym)
}
text_symbolizer text_symbol = text_symbolizer(placement_finder);
parse_metawriter_in_symbolizer(text_symbol, sym);
parse_symbolizer_base(text_symbol, sym);
rule.append(text_symbol);
}
catch (const config_error & ex)
@ -1304,7 +1304,7 @@ void map_parser::parse_shield_symbolizer(rule & rule, xml_node const& sym)
shield_symbol.set_unlock_image(* unlock_image);
}
parse_metawriter_in_symbolizer(shield_symbol, sym);
parse_symbolizer_base(shield_symbol, sym);
std::string image_file = sym.get_attr<std::string>("file");
optional<std::string> base = sym.get_opt_attr<std::string>("base");
@ -1426,21 +1426,13 @@ void map_parser::parse_line_symbolizer(rule & rule, xml_node const & sym)
stroke strk;
parse_stroke(strk,sym);
line_symbolizer symbol = line_symbolizer(strk);
// rasterizer method
line_rasterizer_e rasterizer = sym.get_attr<line_rasterizer_e>("rasterizer", RASTERIZER_FULL);
//optional<line_rasterizer_e> rasterizer_method = sym.get_opt_attr<line_rasterizer_e>("full");
symbol.set_rasterizer(rasterizer);
// smooth value
optional<double> smooth = sym.get_opt_attr<double>("smooth");
if (smooth) symbol.set_smooth(*smooth);
// offset value
optional<double> offset = sym.get_opt_attr<double>("offset");
if (offset) symbol.set_offset(*offset);
// meta-writer
parse_metawriter_in_symbolizer(symbol, sym);
parse_symbolizer_base(symbol, sym);
rule.append(symbol);
}
catch (const config_error & ex)
@ -1468,11 +1460,8 @@ void map_parser::parse_polygon_symbolizer(rule & rule, xml_node const & sym)
// gamma method
optional<gamma_method_e> gamma_method = sym.get_opt_attr<gamma_method_e>("gamma-method");
if (gamma_method) poly_sym.set_gamma_method(*gamma_method);
// smooth value
optional<double> smooth = sym.get_opt_attr<double>("smooth");
if (smooth) poly_sym.set_smooth(*smooth);
parse_metawriter_in_symbolizer(poly_sym, sym);
parse_symbolizer_base(poly_sym, sym);
rule.append(poly_sym);
}
catch (const config_error & ex)
@ -1498,7 +1487,7 @@ void map_parser::parse_building_symbolizer(rule & rule, xml_node const & sym)
optional<expression_ptr> height = sym.get_opt_attr<expression_ptr>("height");
if (height) building_sym.set_height(*height);
parse_metawriter_in_symbolizer(building_sym, sym);
parse_symbolizer_base(building_sym, sym);
rule.append(building_sym);
}
catch (const config_error & ex)

View file

@ -38,15 +38,13 @@ polygon_pattern_symbolizer::polygon_pattern_symbolizer(path_expression_ptr file)
: symbolizer_with_image(file), symbolizer_base(),
alignment_(LOCAL_ALIGNMENT),
gamma_(1.0),
gamma_method_(GAMMA_POWER),
smooth_(0.0) {}
gamma_method_(GAMMA_POWER) {}
polygon_pattern_symbolizer::polygon_pattern_symbolizer(polygon_pattern_symbolizer const& rhs)
: symbolizer_with_image(rhs), symbolizer_base(rhs),
alignment_(rhs.alignment_),
gamma_(rhs.gamma_),
gamma_method_(rhs.gamma_method_),
smooth_(rhs.smooth_) {}
gamma_method_(rhs.gamma_method_) {}
pattern_alignment_e polygon_pattern_symbolizer::get_alignment() const
{
@ -78,15 +76,5 @@ gamma_method_e polygon_pattern_symbolizer::get_gamma_method() const
return gamma_method_;
}
void polygon_pattern_symbolizer::set_smooth(double smooth)
{
smooth_ = smooth;
}
double polygon_pattern_symbolizer::smooth() const
{
return smooth_;
}
}

View file

@ -39,8 +39,7 @@ polygon_symbolizer::polygon_symbolizer(color const& fill)
fill_(fill),
opacity_(1.0),
gamma_(1.0),
gamma_method_(GAMMA_POWER),
smooth_(0.0)
gamma_method_(GAMMA_POWER)
{}
color const& polygon_symbolizer::get_fill() const
@ -83,14 +82,4 @@ gamma_method_e polygon_symbolizer::get_gamma_method() const
return gamma_method_;
}
void polygon_symbolizer::set_smooth(double smooth)
{
smooth_ = smooth;
}
double polygon_symbolizer::smooth() const
{
return smooth_;
}
}

View file

@ -84,16 +84,6 @@ public:
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() );
}
if ( sym.smooth() != dfl.smooth() || explicit_defaults_ )
{
set_attr( sym_node, "smooth", sym.smooth() );
}
}
void operator () ( line_pattern_symbolizer const& sym )
@ -128,10 +118,6 @@ public:
{
set_attr( sym_node, "gamma-method", sym.get_gamma_method() );
}
if ( sym.smooth() != dfl.smooth() || explicit_defaults_ )
{
set_attr( sym_node, "smooth", sym.smooth() );
}
add_metawriter_attributes(sym_node, sym);
}

View file

@ -108,6 +108,15 @@ bool symbolizer_base::clip() const
return clip_;
}
void symbolizer_base::set_smooth(double smooth)
{
smooth_value_ = smooth;
}
double symbolizer_base::smooth() const
{
return smooth_value_;
}
///////////////////////////////////////////////////////////////////////////////////////

View file

@ -461,7 +461,6 @@ compile_get_opt_attr(float);
compile_get_opt_attr(double);
compile_get_opt_attr(color);
compile_get_opt_attr(gamma_method_e);
compile_get_opt_attr(line_rasterizer_e);
compile_get_opt_attr(line_join_e);
compile_get_opt_attr(line_cap_e);
compile_get_opt_attr(text_transform_e);
@ -476,7 +475,6 @@ compile_get_attr(point_placement_e);
compile_get_attr(marker_placement_e);
compile_get_attr(marker_type_e);
compile_get_attr(pattern_alignment_e);
compile_get_attr(line_rasterizer_e);
compile_get_attr(colorizer_mode);
compile_get_attr(double);
compile_get_value(int);