Add scaling method to mapnik::query object

This commit is contained in:
Christoph Paulik 2018-10-22 13:24:06 +02:00
parent a044560bfe
commit b956b2c38f
3 changed files with 36 additions and 2 deletions

View file

@ -161,8 +161,10 @@ private:
struct symbolizer_attributes
{
symbolizer_attributes(std::set<std::string>& names,
double & filter_factor)
double & filter_factor,
scaling_method_e & method_)
: filter_factor_(filter_factor),
method_(method_),
f_attrs_(names),
g_attrs_(names, true) {}
@ -190,8 +192,13 @@ struct symbolizer_attributes
filter_factor_ = 2;
}
}
boost::optional<scaling_method_e> scaling_method = get_optional<scaling_method_e>(sym, keys::scaling);
method_ = scaling_method.get_value_or(SCALING_NEAR);
for (auto const& prop : sym.properties)
{
util::apply_visitor(f_attrs_, prop.second);
}
}
@ -203,6 +210,7 @@ struct symbolizer_attributes
private:
double & filter_factor_;
scaling_method_e & method_;
extract_attribute_names<std::set<std::string> > f_attrs_;
group_attribute_collector g_attrs_;
};
@ -213,18 +221,21 @@ class attribute_collector : public util::noncopyable
private:
std::set<std::string> & names_;
double filter_factor_;
scaling_method_e method_;
expression_attributes<std::set<std::string> > f_attr;
public:
attribute_collector(std::set<std::string>& names)
: names_(names),
filter_factor_(1.0),
method_(SCALING_NEAR),
f_attr(names) {}
template <typename RuleType>
void operator() (RuleType const& r)
{
typename RuleType::symbolizers const& symbols = r.get_symbolizers();
symbolizer_attributes s_attr(names_,filter_factor_);
symbolizer_attributes s_attr(names_,filter_factor_,method_);
for (auto const& sym : symbols)
{
util::apply_visitor(std::ref(s_attr), sym);
@ -238,6 +249,11 @@ public:
{
return filter_factor_;
}
scaling_method_e get_scaling_method() const
{
return method_;
}
};

View file

@ -432,6 +432,7 @@ void feature_style_processor<Processor>::prepare_layer(layer_rendering_material
}
}
q.set_filter_factor(collector.get_filter_factor());
q.set_scaling_method(collector.get_scaling_method());
// Also query the group by attribute
std::string const& group_by = lay.group_by();

View file

@ -26,6 +26,7 @@
//mapnik
#include <mapnik/geometry/box2d.hpp>
#include <mapnik/attribute.hpp>
#include <mapnik/image_scaling.hpp>
// stl
#include <set>
@ -47,6 +48,7 @@ public:
resolution_(_resolution),
scale_denominator_(_scale_denominator),
filter_factor_(1.0),
scaling_method_(SCALING_NEAR),
unbuffered_bbox_(unbuffered_bbox),
names_(),
vars_()
@ -59,6 +61,7 @@ public:
resolution_(_resolution),
scale_denominator_(_scale_denominator),
filter_factor_(1.0),
scaling_method_(SCALING_NEAR),
unbuffered_bbox_(bbox),
names_(),
vars_()
@ -69,6 +72,7 @@ public:
resolution_(resolution_type(1.0,1.0)),
scale_denominator_(1.0),
filter_factor_(1.0),
scaling_method_(SCALING_NEAR),
unbuffered_bbox_(bbox),
names_(),
vars_()
@ -79,6 +83,7 @@ public:
resolution_(other.resolution_),
scale_denominator_(other.scale_denominator_),
filter_factor_(other.filter_factor_),
scaling_method_(other.scaling_method_),
unbuffered_bbox_(other.unbuffered_bbox_),
names_(other.names_),
vars_(other.vars_)
@ -91,6 +96,7 @@ public:
resolution_=other.resolution_;
scale_denominator_=other.scale_denominator_;
filter_factor_=other.filter_factor_;
scaling_method_=other.scaling_method_;
unbuffered_bbox_=other.unbuffered_bbox_;
names_=other.names_;
vars_=other.vars_;
@ -137,6 +143,16 @@ public:
filter_factor_ = factor;
}
scaling_method_e get_scaling_method() const
{
return scaling_method_;
}
void set_scaling_method(scaling_method_e method)
{
scaling_method_ = method;
}
void add_property_name(std::string const& name)
{
names_.insert(name);
@ -162,6 +178,7 @@ private:
resolution_type resolution_;
double scale_denominator_;
double filter_factor_;
scaling_method_e scaling_method_;
box2d<double> unbuffered_bbox_;
std::set<std::string> names_;
attributes vars_;