+ update to work with optional stroke (markers)
This commit is contained in:
parent
ebf1ef6bcf
commit
9d756165e0
2 changed files with 53 additions and 40 deletions
|
@ -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);
|
||||
|
@ -441,45 +441,45 @@ void map_parser::parse_style(Map & map, xml_node const& sty)
|
|||
// image filters
|
||||
mapnik::image_filter_grammar<std::string::const_iterator,
|
||||
std::vector<mapnik::filter::filter_type> > filter_grammar;
|
||||
|
||||
|
||||
optional<std::string> filters = sty.get_opt_attr<std::string>("image-filters");
|
||||
if (filters)
|
||||
{
|
||||
std::string filter_mode = *filters;
|
||||
std::string::const_iterator itr = filter_mode.begin();
|
||||
std::string::const_iterator end = filter_mode.end();
|
||||
|
||||
|
||||
bool result = boost::spirit::qi::phrase_parse(itr,end,
|
||||
filter_grammar,
|
||||
boost::spirit::qi::ascii::space,
|
||||
|
||||
bool result = boost::spirit::qi::phrase_parse(itr,end,
|
||||
filter_grammar,
|
||||
boost::spirit::qi::ascii::space,
|
||||
style.image_filters());
|
||||
if (!result || itr!=end)
|
||||
{
|
||||
throw config_error("failed to parse image-filters: '" + std::string(itr,end) + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// direct image filters (applied directly on main image buffer
|
||||
// TODO : consider creating a separate XML node e.g
|
||||
// <ImageFilter name="myfilter" op="blur emboss"/>
|
||||
//
|
||||
|
||||
// direct image filters (applied directly on main image buffer
|
||||
// TODO : consider creating a separate XML node e.g
|
||||
// <ImageFilter name="myfilter" op="blur emboss"/>
|
||||
//
|
||||
optional<std::string> direct_filters = sty.get_opt_attr<std::string>("direct-image-filters");
|
||||
if (direct_filters)
|
||||
{
|
||||
std::string filter_mode = *direct_filters;
|
||||
std::string::const_iterator itr = filter_mode.begin();
|
||||
std::string::const_iterator end = filter_mode.end();
|
||||
bool result = boost::spirit::qi::phrase_parse(itr,end,
|
||||
filter_grammar,
|
||||
boost::spirit::qi::ascii::space,
|
||||
std::string::const_iterator end = filter_mode.end();
|
||||
bool result = boost::spirit::qi::phrase_parse(itr,end,
|
||||
filter_grammar,
|
||||
boost::spirit::qi::ascii::space,
|
||||
style.direct_image_filters());
|
||||
if (!result || itr!=end)
|
||||
{
|
||||
throw config_error("failed to parse direct-image-filters: '" + std::string(itr,end) + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// rules
|
||||
xml_node::const_iterator ruleIter = sty.begin();
|
||||
xml_node::const_iterator endRule = sty.end();
|
||||
|
@ -839,7 +839,7 @@ void map_parser::parse_symbolizer_base(symbolizer_base &sym, xml_node const &pt)
|
|||
throw config_error("failed to parse comp-op: '" + *comp_op_name + "'");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
optional<std::string> geometry_transform_wkt = pt.get_opt_attr<std::string>("geometry-transform");
|
||||
if (geometry_transform_wkt)
|
||||
{
|
||||
|
@ -855,14 +855,14 @@ void map_parser::parse_symbolizer_base(symbolizer_base &sym, xml_node const &pt)
|
|||
}
|
||||
sym.set_transform(tl);
|
||||
}
|
||||
|
||||
|
||||
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");
|
||||
|
@ -878,7 +878,7 @@ void map_parser::parse_point_symbolizer(rule & rule, xml_node const & sym)
|
|||
optional<boolean> allow_overlap = sym.get_opt_attr<boolean>("allow-overlap");
|
||||
optional<boolean> ignore_placement = sym.get_opt_attr<boolean>("ignore-placement");
|
||||
optional<float> opacity = sym.get_opt_attr<float>("opacity");
|
||||
|
||||
|
||||
point_symbolizer symbol;
|
||||
if (allow_overlap)
|
||||
{
|
||||
|
@ -1019,7 +1019,7 @@ void map_parser::parse_markers_symbolizer(rule & rule, xml_node const& sym)
|
|||
}
|
||||
symbol.set_image_transform(tl);
|
||||
}
|
||||
|
||||
|
||||
optional<color> c = sym.get_opt_attr<color>("fill");
|
||||
if (c) symbol.set_fill(*c);
|
||||
optional<double> spacing = sym.get_opt_attr<double>("spacing");
|
||||
|
@ -1052,8 +1052,8 @@ void map_parser::parse_markers_symbolizer(rule & rule, xml_node const& sym)
|
|||
}
|
||||
|
||||
stroke strk;
|
||||
parse_stroke(strk,sym);
|
||||
symbol.set_stroke(strk);
|
||||
if (parse_stroke(strk,sym))
|
||||
symbol.set_stroke(strk);
|
||||
|
||||
marker_placement_e placement = sym.get_attr<marker_placement_e>("placement", MARKER_LINE_PLACEMENT);
|
||||
symbol.set_marker_placement(placement);
|
||||
|
@ -1141,11 +1141,11 @@ void map_parser::parse_polygon_pattern_symbolizer(rule & rule,
|
|||
// pattern alignment
|
||||
pattern_alignment_e p_alignment = sym.get_attr<pattern_alignment_e>("alignment",LOCAL_ALIGNMENT);
|
||||
symbol.set_alignment(p_alignment);
|
||||
|
||||
|
||||
// opacity
|
||||
optional<double> opacity = sym.get_opt_attr<double>("opacity");
|
||||
if (opacity) symbol.set_opacity(*opacity);
|
||||
|
||||
|
||||
// gamma
|
||||
optional<double> gamma = sym.get_opt_attr<double>("gamma");
|
||||
if (gamma) symbol.set_gamma(*gamma);
|
||||
|
@ -1212,7 +1212,7 @@ void map_parser::parse_shield_symbolizer(rule & rule, xml_node const& sym)
|
|||
}
|
||||
|
||||
shield_symbolizer shield_symbol = shield_symbolizer(placement_finder);
|
||||
|
||||
|
||||
optional<std::string> image_transform_wkt = sym.get_opt_attr<std::string>("transform");
|
||||
if (image_transform_wkt)
|
||||
{
|
||||
|
@ -1220,7 +1220,7 @@ void map_parser::parse_shield_symbolizer(rule & rule, xml_node const& sym)
|
|||
if (!mapnik::parse_transform(*tl, *image_transform_wkt, sym.get_tree().transform_expr_grammar))
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "Could not parse transform from '" << *image_transform_wkt
|
||||
ss << "Could not parse transform from '" << *image_transform_wkt
|
||||
<< "', expected transform attribute";
|
||||
if (strict_)
|
||||
{
|
||||
|
@ -1233,7 +1233,7 @@ void map_parser::parse_shield_symbolizer(rule & rule, xml_node const& sym)
|
|||
}
|
||||
shield_symbol.set_image_transform(tl);
|
||||
}
|
||||
|
||||
|
||||
// shield displacement
|
||||
double shield_dx = sym.get_attr("shield-dx", 0.0);
|
||||
double shield_dy = sym.get_attr("shield-dy", 0.0);
|
||||
|
@ -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");
|
||||
|
@ -1361,10 +1370,11 @@ void map_parser::parse_stroke(stroke & strk, xml_node const & sym)
|
|||
"list of floats or 'none' but got '" + (*str) + "'");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 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)
|
||||
|
@ -1374,7 +1384,7 @@ void map_parser::parse_line_symbolizer(rule & rule, xml_node const & sym)
|
|||
stroke strk;
|
||||
parse_stroke(strk,sym);
|
||||
line_symbolizer symbol = line_symbolizer(strk);
|
||||
|
||||
|
||||
// offset value
|
||||
optional<double> offset = sym.get_opt_attr<double>("offset");
|
||||
if (offset) symbol.set_offset(*offset);
|
||||
|
@ -1411,7 +1421,7 @@ 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);
|
||||
|
||||
|
||||
parse_symbolizer_base(poly_sym, sym);
|
||||
rule.append(poly_sym);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
@ -318,7 +321,7 @@ public:
|
|||
std::clog << typeid(sym).name() << " is not supported" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
serialize_symbolizer();
|
||||
|
||||
|
|
Loading…
Reference in a new issue