From b956b2c38febf40faa5d8e651ebf622b040ba9e8 Mon Sep 17 00:00:00 2001 From: Christoph Paulik Date: Mon, 22 Oct 2018 13:24:06 +0200 Subject: [PATCH] Add scaling method to mapnik::query object --- include/mapnik/attribute_collector.hpp | 20 +++++++++++++++++-- .../mapnik/feature_style_processor_impl.hpp | 1 + include/mapnik/query.hpp | 17 ++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/include/mapnik/attribute_collector.hpp b/include/mapnik/attribute_collector.hpp index 593234a4c..f44618a07 100644 --- a/include/mapnik/attribute_collector.hpp +++ b/include/mapnik/attribute_collector.hpp @@ -161,8 +161,10 @@ private: struct symbolizer_attributes { symbolizer_attributes(std::set& 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 = get_optional(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 > f_attrs_; group_attribute_collector g_attrs_; }; @@ -213,18 +221,21 @@ class attribute_collector : public util::noncopyable private: std::set & names_; double filter_factor_; + scaling_method_e method_; expression_attributes > f_attr; public: attribute_collector(std::set& names) : names_(names), filter_factor_(1.0), + method_(SCALING_NEAR), f_attr(names) {} template 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_; + } }; diff --git a/include/mapnik/feature_style_processor_impl.hpp b/include/mapnik/feature_style_processor_impl.hpp index f5e605d4b..baf713b7d 100644 --- a/include/mapnik/feature_style_processor_impl.hpp +++ b/include/mapnik/feature_style_processor_impl.hpp @@ -432,6 +432,7 @@ void feature_style_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(); diff --git a/include/mapnik/query.hpp b/include/mapnik/query.hpp index 857589dcb..fe4e6858f 100644 --- a/include/mapnik/query.hpp +++ b/include/mapnik/query.hpp @@ -26,6 +26,7 @@ //mapnik #include #include +#include // stl #include @@ -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 unbuffered_bbox_; std::set names_; attributes vars_;