Merge branch 'master' into python-textplacement

This commit is contained in:
Hermann Kraus 2012-02-05 03:11:15 +01:00
commit 32320dd857
6 changed files with 27 additions and 34 deletions

View file

@ -88,8 +88,9 @@ struct symbolizer_attributes : public boost::static_visitor<>
void operator () (text_symbolizer const& sym)
{
std::set<expression_ptr>::const_iterator it;
std::set<expression_ptr> expressions = sym.get_placement_options()->get_all_expressions();
expression_set::const_iterator it;
expression_set expressions;
sym.get_placement_options()->add_expressions(expressions);
expression_attributes f_attr(names_);
for (it=expressions.begin(); it != expressions.end(); it++)
{
@ -141,8 +142,9 @@ struct symbolizer_attributes : public boost::static_visitor<>
void operator () (shield_symbolizer const& sym)
{
std::set<expression_ptr>::const_iterator it;
std::set<expression_ptr> expressions = sym.get_placement_options()->get_all_expressions();
expression_set::const_iterator it;
expression_set expressions;
sym.get_placement_options()->add_expressions(expressions);
expression_attributes f_attr(names_);
for (it=expressions.begin(); it != expressions.end(); it++)
{

View file

@ -91,7 +91,7 @@ struct text_symbolizer_properties
formating::node_ptr format_tree() const;
/** Get a list of all expressions used in any placement.
* This function is used to collect attributes. */
std::set<expression_ptr> get_all_expressions() const;
void add_expressions(expression_set &output) const;
//Per symbolizer options
expression_ptr orientation;
@ -236,7 +236,7 @@ public:
/** Get a list of all expressions used in any placement.
* This function is used to collect attributes.
*/
virtual std::set<expression_ptr> get_all_expressions();
virtual void add_expressions(expression_set &output);
/** Destructor. */
virtual ~text_placements() {}

View file

@ -35,7 +35,7 @@ public:
text_placements_list();
text_placement_info_ptr get_placement_info(
double scale_factor, dimension_type dim, bool has_dimensions) const;
virtual std::set<expression_ptr> get_all_expressions();
virtual void add_expressions(expression_set &output);
text_symbolizer_properties & add();
text_symbolizer_properties & get(unsigned i);
unsigned size() const;

View file

@ -42,6 +42,8 @@ namespace mapnik
class processed_text;
struct char_properties;
typedef std::set<expression_ptr> expression_set;
enum label_placement_enum {
POINT_PLACEMENT,
LINE_PLACEMENT,
@ -104,7 +106,7 @@ public:
virtual void to_xml(boost::property_tree::ptree &xml) const;
static node_ptr from_xml(boost::property_tree::ptree const& xml);
virtual void apply(char_properties const& p, Feature const& feature, processed_text &output) const = 0;
virtual void add_expressions(std::set<expression_ptr> &expressions) const;
virtual void add_expressions(expression_set &output) const;
};
class list_node: public node {
@ -112,7 +114,7 @@ public:
list_node() : node(), children_() {}
virtual void to_xml(boost::property_tree::ptree &xml) const;
virtual void apply(char_properties const& p, Feature const& feature, processed_text &output) const;
virtual void add_expressions(std::set<expression_ptr> &expressions) const;
virtual void add_expressions(expression_set &output) const;
void push_back(node_ptr n);
void set_children(std::vector<node_ptr> const& children);
@ -128,7 +130,7 @@ public:
void to_xml(boost::property_tree::ptree &xml) const;
static node_ptr from_xml(boost::property_tree::ptree const& xml);
virtual void apply(char_properties const& p, Feature const& feature, processed_text &output) const;
virtual void add_expressions(std::set<expression_ptr> &expressions) const;
virtual void add_expressions(expression_set &output) const;
void set_text(expression_ptr text);
expression_ptr get_text() const;

View file

@ -217,11 +217,10 @@ void text_symbolizer_properties::to_xml(boost::property_tree::ptree &node, bool
}
std::set<expression_ptr> text_symbolizer_properties::get_all_expressions() const
void text_symbolizer_properties::add_expressions(expression_set &output) const
{
std::set<expression_ptr> result;
if (tree_) tree_->add_expressions(result);
return result;
output.insert(orientation);
if (tree_) tree_->add_expressions(output);
}
void text_symbolizer_properties::set_old_style_expression(expression_ptr expr)
@ -356,13 +355,9 @@ text_placements::text_placements() : properties()
{
}
std::set<expression_ptr> text_placements::get_all_expressions()
void text_placements::add_expressions(expression_set &output)
{
std::set<expression_ptr> result, tmp;
tmp = properties.get_all_expressions();
result.insert(tmp.begin(), tmp.end());
result.insert(properties.orientation);
return result;
properties.add_expressions(output);
}
@ -566,21 +561,15 @@ text_placements_list::text_placements_list() : text_placements(), list_(0)
}
std::set<expression_ptr> text_placements_list::get_all_expressions()
void text_placements_list::add_expressions(expression_set &output)
{
std::set<expression_ptr> result, tmp;
tmp = properties.get_all_expressions();
result.insert(tmp.begin(), tmp.end());
result.insert(properties.orientation);
properties.add_expressions(output);
std::vector<text_symbolizer_properties>::const_iterator it;
for (it=list_.begin(); it != list_.end(); it++)
{
tmp = it->get_all_expressions();
result.insert(tmp.begin(), tmp.end());
result.insert(it->orientation);
it->add_expressions(output);
}
return result;
}
unsigned text_placements_list::size() const

View file

@ -75,7 +75,7 @@ node_ptr node::from_xml(boost::property_tree::ptree const& xml)
}
}
void node::add_expressions(std::set<expression_ptr> &expressions) const
void node::add_expressions(expression_set &output) const
{
//Do nothing by default
}
@ -104,13 +104,13 @@ void list_node::apply(char_properties const& p, Feature const& feature, processe
}
void list_node::add_expressions(std::set<expression_ptr> &expressions) const
void list_node::add_expressions(expression_set &output) const
{
std::vector<node_ptr>::const_iterator itr = children_.begin();
std::vector<node_ptr>::const_iterator end = children_.end();
for (;itr != end; itr++)
{
(*itr)->add_expressions(expressions);
(*itr)->add_expressions(output);
}
}
@ -179,9 +179,9 @@ void text_node::apply(char_properties const& p, Feature const& feature, processe
}
void text_node::add_expressions(std::set<expression_ptr> &expressions) const
void text_node::add_expressions(expression_set &output) const
{
if (text_) expressions.insert(text_);
if (text_) output.insert(text_);
}