diff --git a/include/mapnik/grid/grid_marker_helpers.hpp b/include/mapnik/grid/grid_marker_helpers.hpp index ceb0bc042..2db731ec3 100644 --- a/include/mapnik/grid/grid_marker_helpers.hpp +++ b/include/mapnik/grid/grid_marker_helpers.hpp @@ -240,6 +240,9 @@ struct vector_markers_rasterizer_dispatch_grid : mapnik::noncopyable double opacity = get(sym_,keys::opacity, feature_, vars_, 1.0); bool allow_overlap = get(sym_, keys::allow_overlap, feature_, vars_, false); + coord2d center = bbox_.center(); + agg::trans_affine_translation recenter(-center.x, -center.y); + if (placement_method != MARKER_LINE_PLACEMENT || path.type() == geometry_type::types::Point) { @@ -247,27 +250,18 @@ struct vector_markers_rasterizer_dispatch_grid : mapnik::noncopyable double y = 0; if (path.type() == geometry_type::types::LineString) { - if (!label::middle_point(path, x, y)) - { - return; - } + if (!label::middle_point(path, x, y)) return; } else if (placement_method == MARKER_INTERIOR_PLACEMENT) { - if (!label::interior_position(path, x, y)) - { - return; - } + if (!label::interior_position(path, x, y)) return; } else { - if (!label::centroid(path, x, y)) - { - return; - } + if (!label::centroid(path, x, y)) return; } - agg::trans_affine matrix = marker_trans_; + agg::trans_affine matrix = recenter * marker_trans_; matrix.translate(x,y); box2d transformed_bbox = bbox_ * matrix; if (allow_overlap || @@ -296,7 +290,7 @@ struct vector_markers_rasterizer_dispatch_grid : mapnik::noncopyable double x, y, angle; while (placement.get_point(x, y, angle, ignore_placement)) { - agg::trans_affine matrix = marker_trans_; + agg::trans_affine matrix = recenter * marker_trans_; matrix.rotate(angle); matrix.translate(x, y); svg_renderer_.render_id(ras_, sl_, renb_, feature_.id(), matrix, opacity, bbox_); diff --git a/include/mapnik/marker_helpers.hpp b/include/mapnik/marker_helpers.hpp index 2c89dfe5f..7d057c005 100644 --- a/include/mapnik/marker_helpers.hpp +++ b/include/mapnik/marker_helpers.hpp @@ -106,6 +106,9 @@ struct vector_markers_rasterizer_dispatch : mapnik::noncopyable bool allow_overlap = get(sym_, keys::allow_overlap, feature_, vars_, false); double opacity = get(sym_,keys::opacity, feature_, vars_, 1.0); + coord2d center = bbox_.center(); + agg::trans_affine_translation recenter(-center.x, -center.y); + if (placement_method != MARKER_LINE_PLACEMENT || path.type() == mapnik::geometry_type::types::Point) { @@ -123,7 +126,7 @@ struct vector_markers_rasterizer_dispatch : mapnik::noncopyable { if (!label::centroid(path, x, y)) return; } - agg::trans_affine matrix = marker_trans_; + agg::trans_affine matrix = recenter * marker_trans_; matrix.translate(x,y); if (snap_to_pixels_) { @@ -157,7 +160,8 @@ struct vector_markers_rasterizer_dispatch : mapnik::noncopyable double angle = 0; while (placement.get_point(x, y, angle, ignore_placement)) { - agg::trans_affine matrix = marker_trans_; + + agg::trans_affine matrix = recenter * marker_trans_; matrix.rotate(angle); matrix.translate(x, y); svg_renderer_.render(ras_, sl_, renb_, matrix, opacity, bbox_); diff --git a/include/mapnik/renderer_common/process_markers_symbolizer.hpp b/include/mapnik/renderer_common/process_markers_symbolizer.hpp index b9d213d19..424b9b2fa 100644 --- a/include/mapnik/renderer_common/process_markers_symbolizer.hpp +++ b/include/mapnik/renderer_common/process_markers_symbolizer.hpp @@ -79,13 +79,10 @@ void render_markers_symbolizer(markers_symbolizer const& sym, auto image_transform = get_optional(sym, keys::image_transform); if (image_transform) evaluate_transform(tr, feature, common.vars_, *image_transform); box2d bbox = marker_ellipse.bounding_box(); - coord2d center = bbox.center(); - agg::trans_affine_translation recenter(-center.x, -center.y); - agg::trans_affine marker_trans = recenter * tr; vector_dispatch_type rasterizer_dispatch(svg_path, result ? attributes : (*stock_vector_marker)->attributes(), bbox, - marker_trans, + tr, sym, *common.detector_, common.scale_factor_, @@ -121,14 +118,10 @@ void render_markers_symbolizer(markers_symbolizer const& sym, svg_path_adapter svg_path(stl_storage); svg_attribute_type attributes; bool result = push_explicit_style( (*stock_vector_marker)->attributes(), attributes, sym, feature, common.vars_); - // TODO - clamping to >= 4 pixels - coord2d center = bbox.center(); - agg::trans_affine_translation recenter(-center.x, -center.y); - agg::trans_affine marker_trans = recenter * tr; vector_dispatch_type rasterizer_dispatch(svg_path, result ? attributes : (*stock_vector_marker)->attributes(), bbox, - marker_trans, + tr, sym, *common.detector_, common.scale_factor_,