Merge branch 'master' into python-textplacement
This commit is contained in:
commit
32320dd857
6 changed files with 27 additions and 34 deletions
|
@ -88,8 +88,9 @@ struct symbolizer_attributes : public boost::static_visitor<>
|
||||||
|
|
||||||
void operator () (text_symbolizer const& sym)
|
void operator () (text_symbolizer const& sym)
|
||||||
{
|
{
|
||||||
std::set<expression_ptr>::const_iterator it;
|
expression_set::const_iterator it;
|
||||||
std::set<expression_ptr> expressions = sym.get_placement_options()->get_all_expressions();
|
expression_set expressions;
|
||||||
|
sym.get_placement_options()->add_expressions(expressions);
|
||||||
expression_attributes f_attr(names_);
|
expression_attributes f_attr(names_);
|
||||||
for (it=expressions.begin(); it != expressions.end(); it++)
|
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)
|
void operator () (shield_symbolizer const& sym)
|
||||||
{
|
{
|
||||||
std::set<expression_ptr>::const_iterator it;
|
expression_set::const_iterator it;
|
||||||
std::set<expression_ptr> expressions = sym.get_placement_options()->get_all_expressions();
|
expression_set expressions;
|
||||||
|
sym.get_placement_options()->add_expressions(expressions);
|
||||||
expression_attributes f_attr(names_);
|
expression_attributes f_attr(names_);
|
||||||
for (it=expressions.begin(); it != expressions.end(); it++)
|
for (it=expressions.begin(); it != expressions.end(); it++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -91,7 +91,7 @@ struct text_symbolizer_properties
|
||||||
formating::node_ptr format_tree() const;
|
formating::node_ptr format_tree() const;
|
||||||
/** Get a list of all expressions used in any placement.
|
/** Get a list of all expressions used in any placement.
|
||||||
* This function is used to collect attributes. */
|
* 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
|
//Per symbolizer options
|
||||||
expression_ptr orientation;
|
expression_ptr orientation;
|
||||||
|
@ -236,7 +236,7 @@ public:
|
||||||
/** Get a list of all expressions used in any placement.
|
/** Get a list of all expressions used in any placement.
|
||||||
* This function is used to collect attributes.
|
* This function is used to collect attributes.
|
||||||
*/
|
*/
|
||||||
virtual std::set<expression_ptr> get_all_expressions();
|
virtual void add_expressions(expression_set &output);
|
||||||
|
|
||||||
/** Destructor. */
|
/** Destructor. */
|
||||||
virtual ~text_placements() {}
|
virtual ~text_placements() {}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public:
|
||||||
text_placements_list();
|
text_placements_list();
|
||||||
text_placement_info_ptr get_placement_info(
|
text_placement_info_ptr get_placement_info(
|
||||||
double scale_factor, dimension_type dim, bool has_dimensions) const;
|
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 & add();
|
||||||
text_symbolizer_properties & get(unsigned i);
|
text_symbolizer_properties & get(unsigned i);
|
||||||
unsigned size() const;
|
unsigned size() const;
|
||||||
|
|
|
@ -42,6 +42,8 @@ namespace mapnik
|
||||||
class processed_text;
|
class processed_text;
|
||||||
struct char_properties;
|
struct char_properties;
|
||||||
|
|
||||||
|
typedef std::set<expression_ptr> expression_set;
|
||||||
|
|
||||||
enum label_placement_enum {
|
enum label_placement_enum {
|
||||||
POINT_PLACEMENT,
|
POINT_PLACEMENT,
|
||||||
LINE_PLACEMENT,
|
LINE_PLACEMENT,
|
||||||
|
@ -104,7 +106,7 @@ public:
|
||||||
virtual void to_xml(boost::property_tree::ptree &xml) const;
|
virtual void to_xml(boost::property_tree::ptree &xml) const;
|
||||||
static node_ptr from_xml(boost::property_tree::ptree const& xml);
|
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 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 {
|
class list_node: public node {
|
||||||
|
@ -112,7 +114,7 @@ public:
|
||||||
list_node() : node(), children_() {}
|
list_node() : node(), children_() {}
|
||||||
virtual void to_xml(boost::property_tree::ptree &xml) const;
|
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 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 push_back(node_ptr n);
|
||||||
void set_children(std::vector<node_ptr> const& children);
|
void set_children(std::vector<node_ptr> const& children);
|
||||||
|
@ -128,7 +130,7 @@ public:
|
||||||
void to_xml(boost::property_tree::ptree &xml) const;
|
void to_xml(boost::property_tree::ptree &xml) const;
|
||||||
static node_ptr from_xml(boost::property_tree::ptree const& xml);
|
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 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);
|
void set_text(expression_ptr text);
|
||||||
expression_ptr get_text() const;
|
expression_ptr get_text() const;
|
||||||
|
|
|
@ -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;
|
output.insert(orientation);
|
||||||
if (tree_) tree_->add_expressions(result);
|
if (tree_) tree_->add_expressions(output);
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void text_symbolizer_properties::set_old_style_expression(expression_ptr expr)
|
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;
|
properties.add_expressions(output);
|
||||||
tmp = properties.get_all_expressions();
|
|
||||||
result.insert(tmp.begin(), tmp.end());
|
|
||||||
result.insert(properties.orientation);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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;
|
properties.add_expressions(output);
|
||||||
tmp = properties.get_all_expressions();
|
|
||||||
result.insert(tmp.begin(), tmp.end());
|
|
||||||
result.insert(properties.orientation);
|
|
||||||
|
|
||||||
std::vector<text_symbolizer_properties>::const_iterator it;
|
std::vector<text_symbolizer_properties>::const_iterator it;
|
||||||
for (it=list_.begin(); it != list_.end(); it++)
|
for (it=list_.begin(); it != list_.end(); it++)
|
||||||
{
|
{
|
||||||
tmp = it->get_all_expressions();
|
it->add_expressions(output);
|
||||||
result.insert(tmp.begin(), tmp.end());
|
|
||||||
result.insert(it->orientation);
|
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned text_placements_list::size() const
|
unsigned text_placements_list::size() const
|
||||||
|
|
|
@ -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
|
//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 itr = children_.begin();
|
||||||
std::vector<node_ptr>::const_iterator end = children_.end();
|
std::vector<node_ptr>::const_iterator end = children_.end();
|
||||||
for (;itr != end; itr++)
|
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_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue