+ update to work with optional stroke (markers)

This commit is contained in:
artemp 2012-07-05 17:16:11 +01:00
parent ebf1ef6bcf
commit 9d756165e0
2 changed files with 53 additions and 40 deletions

View file

@ -115,7 +115,7 @@ private:
void parse_markers_symbolizer(rule & rule, xml_node const& sym);
void parse_raster_colorizer(raster_colorizer_ptr const& rc, xml_node const& node);
void parse_stroke(stroke & strk, xml_node const & sym);
bool parse_stroke(stroke & strk, xml_node const & sym);
void ensure_font_face(std::string const& face_name);
void find_unused_nodes(xml_node const& root);
@ -1052,7 +1052,7 @@ void map_parser::parse_markers_symbolizer(rule & rule, xml_node const& sym)
}
stroke strk;
parse_stroke(strk,sym);
if (parse_stroke(strk,sym))
symbol.set_stroke(strk);
marker_placement_e placement = sym.get_attr<marker_placement_e>("placement", MARKER_LINE_PLACEMENT);
@ -1298,15 +1298,24 @@ void map_parser::parse_shield_symbolizer(rule & rule, xml_node const& sym)
}
}
void map_parser::parse_stroke(stroke & strk, xml_node const & sym)
bool map_parser::parse_stroke(stroke & strk, xml_node const & sym)
{
bool result = false;
// stroke color
optional<color> c = sym.get_opt_attr<color>("stroke");
if (c) strk.set_color(*c);
if (c)
{
strk.set_color(*c);
result = true;
}
// stroke-width
optional<double> width = sym.get_opt_attr<double>("stroke-width");
if (width) strk.set_width(*width);
if (width && *width > 0)
{
strk.set_width(*width);
result = true;
}
// stroke-opacity
optional<double> opacity = sym.get_opt_attr<double>("stroke-opacity");
@ -1365,6 +1374,7 @@ void map_parser::parse_stroke(stroke & strk, xml_node const & sym)
// stroke-miterlimit
optional<double> miterlimit = sym.get_opt_attr<double>("stroke-miterlimit");
if (miterlimit) strk.set_miterlimit(*miterlimit);
return result;
}
void map_parser::parse_line_symbolizer(rule & rule, xml_node const & sym)

View file

@ -304,8 +304,11 @@ public:
set_attr( sym_node, "transform", tr_str );
}
const stroke & strk = sym.get_stroke();
add_stroke_attributes(sym_node, strk);
boost::optional<stroke> const& strk = sym.get_stroke();
if (strk)
{
add_stroke_attributes(sym_node, *strk);
}
add_metawriter_attributes(sym_node, sym);
}