fix markers transforms calc

This commit is contained in:
artemp 2014-06-05 16:47:40 +01:00
parent 81c4b9dd59
commit de90d0ee2a
3 changed files with 16 additions and 25 deletions

View file

@ -240,6 +240,9 @@ struct vector_markers_rasterizer_dispatch_grid : mapnik::noncopyable
double opacity = get<double>(sym_,keys::opacity, feature_, vars_, 1.0); double opacity = get<double>(sym_,keys::opacity, feature_, vars_, 1.0);
bool allow_overlap = get<bool>(sym_, keys::allow_overlap, feature_, vars_, false); bool allow_overlap = get<bool>(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 || if (placement_method != MARKER_LINE_PLACEMENT ||
path.type() == geometry_type::types::Point) path.type() == geometry_type::types::Point)
{ {
@ -247,27 +250,18 @@ struct vector_markers_rasterizer_dispatch_grid : mapnik::noncopyable
double y = 0; double y = 0;
if (path.type() == geometry_type::types::LineString) if (path.type() == geometry_type::types::LineString)
{ {
if (!label::middle_point(path, x, y)) if (!label::middle_point(path, x, y)) return;
{
return;
}
} }
else if (placement_method == MARKER_INTERIOR_PLACEMENT) else if (placement_method == MARKER_INTERIOR_PLACEMENT)
{ {
if (!label::interior_position(path, x, y)) if (!label::interior_position(path, x, y)) return;
{
return;
}
} }
else else
{ {
if (!label::centroid(path, x, y)) if (!label::centroid(path, x, y)) return;
{
return;
}
} }
agg::trans_affine matrix = marker_trans_; agg::trans_affine matrix = recenter * marker_trans_;
matrix.translate(x,y); matrix.translate(x,y);
box2d<double> transformed_bbox = bbox_ * matrix; box2d<double> transformed_bbox = bbox_ * matrix;
if (allow_overlap || if (allow_overlap ||
@ -296,7 +290,7 @@ struct vector_markers_rasterizer_dispatch_grid : mapnik::noncopyable
double x, y, angle; double x, y, angle;
while (placement.get_point(x, y, angle, ignore_placement)) 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.rotate(angle);
matrix.translate(x, y); matrix.translate(x, y);
svg_renderer_.render_id(ras_, sl_, renb_, feature_.id(), matrix, opacity, bbox_); svg_renderer_.render_id(ras_, sl_, renb_, feature_.id(), matrix, opacity, bbox_);

View file

@ -106,6 +106,9 @@ struct vector_markers_rasterizer_dispatch : mapnik::noncopyable
bool allow_overlap = get<bool>(sym_, keys::allow_overlap, feature_, vars_, false); bool allow_overlap = get<bool>(sym_, keys::allow_overlap, feature_, vars_, false);
double opacity = get<double>(sym_,keys::opacity, feature_, vars_, 1.0); double opacity = get<double>(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 || if (placement_method != MARKER_LINE_PLACEMENT ||
path.type() == mapnik::geometry_type::types::Point) 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; if (!label::centroid(path, x, y)) return;
} }
agg::trans_affine matrix = marker_trans_; agg::trans_affine matrix = recenter * marker_trans_;
matrix.translate(x,y); matrix.translate(x,y);
if (snap_to_pixels_) if (snap_to_pixels_)
{ {
@ -157,7 +160,8 @@ struct vector_markers_rasterizer_dispatch : mapnik::noncopyable
double angle = 0; double angle = 0;
while (placement.get_point(x, y, angle, ignore_placement)) 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.rotate(angle);
matrix.translate(x, y); matrix.translate(x, y);
svg_renderer_.render(ras_, sl_, renb_, matrix, opacity, bbox_); svg_renderer_.render(ras_, sl_, renb_, matrix, opacity, bbox_);

View file

@ -79,13 +79,10 @@ void render_markers_symbolizer(markers_symbolizer const& sym,
auto image_transform = get_optional<transform_type>(sym, keys::image_transform); auto image_transform = get_optional<transform_type>(sym, keys::image_transform);
if (image_transform) evaluate_transform(tr, feature, common.vars_, *image_transform); if (image_transform) evaluate_transform(tr, feature, common.vars_, *image_transform);
box2d<double> bbox = marker_ellipse.bounding_box(); box2d<double> 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, vector_dispatch_type rasterizer_dispatch(svg_path,
result ? attributes : (*stock_vector_marker)->attributes(), result ? attributes : (*stock_vector_marker)->attributes(),
bbox, bbox,
marker_trans, tr,
sym, sym,
*common.detector_, *common.detector_,
common.scale_factor_, common.scale_factor_,
@ -121,14 +118,10 @@ void render_markers_symbolizer(markers_symbolizer const& sym,
svg_path_adapter svg_path(stl_storage); svg_path_adapter svg_path(stl_storage);
svg_attribute_type attributes; svg_attribute_type attributes;
bool result = push_explicit_style( (*stock_vector_marker)->attributes(), attributes, sym, feature, common.vars_); 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, vector_dispatch_type rasterizer_dispatch(svg_path,
result ? attributes : (*stock_vector_marker)->attributes(), result ? attributes : (*stock_vector_marker)->attributes(),
bbox, bbox,
marker_trans, tr,
sym, sym,
*common.detector_, *common.detector_,
common.scale_factor_, common.scale_factor_,