support scale_factor in geometry-transform translate and scale - refs #1926
This commit is contained in:
parent
fead2e2584
commit
3dd05bd171
14 changed files with 34 additions and 29 deletions
|
@ -50,7 +50,7 @@ typedef transform_list_ptr transform_type;
|
|||
class feature_impl;
|
||||
|
||||
MAPNIK_DECL void evaluate_transform(agg::trans_affine& tr, feature_impl const& feature,
|
||||
transform_type const& trans_expr);
|
||||
transform_type const& trans_expr, double scale_factor=1.0);
|
||||
|
||||
class MAPNIK_DECL symbolizer_base
|
||||
{
|
||||
|
|
|
@ -107,8 +107,12 @@ struct transform_processor
|
|||
|
||||
struct node_evaluator : boost::static_visitor<void>
|
||||
{
|
||||
node_evaluator(transform_type& tr, feature_type const& feat)
|
||||
: transform_(tr), feature_(feat) {}
|
||||
node_evaluator(transform_type& tr,
|
||||
feature_type const& feat,
|
||||
double scale_factor)
|
||||
: transform_(tr),
|
||||
feature_(feat),
|
||||
scale_factor_(scale_factor) {}
|
||||
|
||||
void operator() (identity_node const& node)
|
||||
{
|
||||
|
@ -117,26 +121,26 @@ struct transform_processor
|
|||
|
||||
void operator() (matrix_node const& node)
|
||||
{
|
||||
double a = eval(node.a_);
|
||||
double a = eval(node.a_) * scale_factor_; // scale x;
|
||||
double b = eval(node.b_);
|
||||
double c = eval(node.c_);
|
||||
double d = eval(node.d_);
|
||||
double e = eval(node.e_);
|
||||
double f = eval(node.f_);
|
||||
double d = eval(node.d_) * scale_factor_; // scale y;
|
||||
double e = eval(node.e_) * scale_factor_; // translate x
|
||||
double f = eval(node.f_) * scale_factor_; // translate y
|
||||
transform_.multiply(agg::trans_affine(a, b, c, d, e, f));
|
||||
}
|
||||
|
||||
void operator() (translate_node const& node)
|
||||
{
|
||||
double tx = eval(node.tx_);
|
||||
double ty = eval(node.ty_, 0.0);
|
||||
double tx = eval(node.tx_) * scale_factor_;
|
||||
double ty = eval(node.ty_, 0.0) * scale_factor_;
|
||||
transform_.translate(tx, ty);
|
||||
}
|
||||
|
||||
void operator() (scale_node const& node)
|
||||
{
|
||||
double sx = eval(node.sx_);
|
||||
double sy = eval(node.sy_, sx);
|
||||
double sx = eval(node.sx_) * scale_factor_;
|
||||
double sy = eval(node.sy_, sx) * scale_factor_;
|
||||
transform_.scale(sx, sy);
|
||||
}
|
||||
|
||||
|
@ -172,7 +176,7 @@ struct transform_processor
|
|||
double eval(expr_node const& x) const
|
||||
{
|
||||
mapnik::evaluate<feature_type, value_type> e(feature_);
|
||||
return boost::apply_visitor(e, x).to_double();
|
||||
return boost::apply_visitor(e, x).to_double() * scale_factor_;
|
||||
}
|
||||
|
||||
double eval(expr_node const& x, double def) const
|
||||
|
@ -182,6 +186,7 @@ struct transform_processor
|
|||
|
||||
transform_type& transform_;
|
||||
feature_type const& feature_;
|
||||
double scale_factor_;
|
||||
};
|
||||
|
||||
template <typename Container>
|
||||
|
@ -197,9 +202,9 @@ struct transform_processor
|
|||
}
|
||||
|
||||
static void evaluate(transform_type& tr, feature_type const& feat,
|
||||
transform_list const& list)
|
||||
transform_list const& list, double scale_factor)
|
||||
{
|
||||
node_evaluator eval(tr, feat);
|
||||
node_evaluator eval(tr, feat, scale_factor);
|
||||
|
||||
#ifdef MAPNIK_LOG
|
||||
MAPNIK_LOG_DEBUG(transform) << "transform: begin with " << to_string(matrix_node(tr));
|
||||
|
|
|
@ -125,7 +125,7 @@ void agg_renderer<T>::process(line_pattern_symbolizer const& sym,
|
|||
rasterizer_type ras(ren);
|
||||
|
||||
agg::trans_affine tr;
|
||||
evaluate_transform(tr, feature, sym.get_transform());
|
||||
evaluate_transform(tr, feature, sym.get_transform(), scale_factor_);
|
||||
|
||||
box2d<double> clip_box = clipping_extent();
|
||||
if (sym.clip())
|
||||
|
|
|
@ -90,7 +90,7 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
|
|||
renderer_base renb(pixf);
|
||||
|
||||
agg::trans_affine tr;
|
||||
evaluate_transform(tr, feature, sym.get_transform());
|
||||
evaluate_transform(tr, feature, sym.get_transform(), scale_factor_);
|
||||
|
||||
box2d<double> clip_box = clipping_extent();
|
||||
if (sym.clip())
|
||||
|
|
|
@ -146,7 +146,7 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
|
|||
renderer_type rp(renb,sa, sg, unsigned(sym.get_opacity()*255));
|
||||
|
||||
agg::trans_affine tr;
|
||||
evaluate_transform(tr, feature, sym.get_transform());
|
||||
evaluate_transform(tr, feature, sym.get_transform(), scale_factor_);
|
||||
|
||||
typedef boost::mpl::vector<clip_poly_tag,transform_tag,affine_transform_tag,simplify_tag,smooth_tag> conv_types;
|
||||
vertex_converter<box2d<double>, rasterizer, polygon_pattern_symbolizer,
|
||||
|
|
|
@ -57,7 +57,7 @@ void agg_renderer<T>::process(polygon_symbolizer const& sym,
|
|||
gamma_ = sym.get_gamma();
|
||||
}
|
||||
agg::trans_affine tr;
|
||||
evaluate_transform(tr, feature, sym.get_transform());
|
||||
evaluate_transform(tr, feature, sym.get_transform(), scale_factor_);
|
||||
box2d<double> clip_box = clipping_extent();
|
||||
typedef boost::mpl::vector<clip_poly_tag,transform_tag,affine_transform_tag,simplify_tag,smooth_tag> conv_types;
|
||||
vertex_converter<box2d<double>, rasterizer, polygon_symbolizer,
|
||||
|
|
|
@ -314,7 +314,7 @@ void cairo_renderer_base::process(polygon_symbolizer const& sym,
|
|||
context_.set_color(sym.get_fill(), sym.get_opacity());
|
||||
|
||||
agg::trans_affine tr;
|
||||
evaluate_transform(tr, feature, sym.get_transform());
|
||||
evaluate_transform(tr, feature, sym.get_transform(), scale_factor_);
|
||||
|
||||
typedef boost::mpl::vector<clip_poly_tag,transform_tag,affine_transform_tag,simplify_tag,smooth_tag> conv_types;
|
||||
vertex_converter<box2d<double>, cairo_context, polygon_symbolizer,
|
||||
|
@ -465,7 +465,7 @@ void cairo_renderer_base::process(line_symbolizer const& sym,
|
|||
}
|
||||
|
||||
agg::trans_affine tr;
|
||||
evaluate_transform(tr, feature, sym.get_transform());
|
||||
evaluate_transform(tr, feature, sym.get_transform(), scale_factor_);
|
||||
|
||||
box2d<double> clipping_extent = query_extent_;
|
||||
if (sym.clip())
|
||||
|
@ -847,7 +847,7 @@ void cairo_renderer_base::process(polygon_pattern_symbolizer const& sym,
|
|||
//}
|
||||
|
||||
agg::trans_affine tr;
|
||||
evaluate_transform(tr, feature, sym.get_transform());
|
||||
evaluate_transform(tr, feature, sym.get_transform(), scale_factor_);
|
||||
|
||||
typedef boost::mpl::vector<clip_poly_tag,transform_tag,affine_transform_tag,simplify_tag,smooth_tag> conv_types;
|
||||
vertex_converter<box2d<double>, cairo_context, polygon_pattern_symbolizer,
|
||||
|
@ -1156,7 +1156,7 @@ void cairo_renderer_base::process(markers_symbolizer const& sym,
|
|||
if (mark && *mark)
|
||||
{
|
||||
agg::trans_affine geom_tr;
|
||||
evaluate_transform(geom_tr, feature, sym.get_transform());
|
||||
evaluate_transform(geom_tr, feature, sym.get_transform(), scale_factor_);
|
||||
box2d<double> const& bbox = (*mark)->bounding_box();
|
||||
setup_transform_scaling(tr, bbox.width(), bbox.height(), feature, sym);
|
||||
evaluate_transform(tr, feature, sym.get_image_transform());
|
||||
|
|
|
@ -83,7 +83,7 @@ void grid_renderer<T>::process(line_pattern_symbolizer const& sym,
|
|||
int stroke_width = (*pat)->width();
|
||||
|
||||
agg::trans_affine tr;
|
||||
evaluate_transform(tr, feature, sym.get_transform());
|
||||
evaluate_transform(tr, feature, sym.get_transform(), scale_factor_);
|
||||
|
||||
box2d<double> clipping_extent = query_extent_;
|
||||
if (sym.clip())
|
||||
|
|
|
@ -69,7 +69,7 @@ void grid_renderer<T>::process(line_symbolizer const& sym,
|
|||
stroke const& stroke_ = sym.get_stroke();
|
||||
|
||||
agg::trans_affine tr;
|
||||
evaluate_transform(tr, feature, sym.get_transform());
|
||||
evaluate_transform(tr, feature, sym.get_transform(), scale_factor_);
|
||||
|
||||
box2d<double> clipping_extent = query_extent_;
|
||||
if (sym.clip())
|
||||
|
|
|
@ -96,7 +96,7 @@ void grid_renderer<T>::process(markers_symbolizer const& sym,
|
|||
{
|
||||
ras_ptr->reset();
|
||||
agg::trans_affine geom_tr;
|
||||
evaluate_transform(geom_tr, feature, sym.get_transform());
|
||||
evaluate_transform(geom_tr, feature, sym.get_transform(), scale_factor_);
|
||||
agg::trans_affine tr = agg::trans_affine_scaling(scale_factor_*(1.0/pixmap_.get_resolution()));
|
||||
|
||||
if ((*mark)->is_vector())
|
||||
|
|
|
@ -68,7 +68,7 @@ void grid_renderer<T>::process(polygon_pattern_symbolizer const& sym,
|
|||
ras_ptr->reset();
|
||||
|
||||
agg::trans_affine tr;
|
||||
evaluate_transform(tr, feature, sym.get_transform());
|
||||
evaluate_transform(tr, feature, sym.get_transform(), scale_factor_);
|
||||
|
||||
typedef boost::mpl::vector<clip_poly_tag,transform_tag,affine_transform_tag,smooth_tag> conv_types;
|
||||
vertex_converter<box2d<double>, grid_rasterizer, polygon_pattern_symbolizer,
|
||||
|
|
|
@ -55,7 +55,7 @@ void grid_renderer<T>::process(polygon_symbolizer const& sym,
|
|||
ras_ptr->reset();
|
||||
|
||||
agg::trans_affine tr;
|
||||
evaluate_transform(tr, feature, sym.get_transform());
|
||||
evaluate_transform(tr, feature, sym.get_transform(), scale_factor_);
|
||||
|
||||
typedef boost::mpl::vector<clip_poly_tag,transform_tag,affine_transform_tag,simplify_tag,smooth_tag> conv_types;
|
||||
vertex_converter<box2d<double>, grid_rasterizer, polygon_symbolizer,
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
namespace mapnik {
|
||||
|
||||
void evaluate_transform(agg::trans_affine& tr, feature_impl const& feature,
|
||||
transform_list_ptr const& trans_expr)
|
||||
transform_list_ptr const& trans_expr, double scale_factor)
|
||||
{
|
||||
if (trans_expr)
|
||||
{
|
||||
|
@ -37,7 +37,7 @@ void evaluate_transform(agg::trans_affine& tr, feature_impl const& feature,
|
|||
MAPNIK_LOG_DEBUG(transform) << "transform: evaluate "
|
||||
<< transform_processor_type::to_string(*trans_expr);
|
||||
#endif
|
||||
transform_processor_type::evaluate(tr, feature, *trans_expr);
|
||||
transform_processor_type::evaluate(tr, feature, *trans_expr, scale_factor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Loading…
Reference in a new issue