From 3f26c439c9afcdb51c9e5e672f312e782247a2d2 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Fri, 23 Mar 2012 20:28:12 -0700 Subject: [PATCH] fix marker width/height to mean pixels - which it should have all along - closes #1134 --- CHANGELOG.md | 2 ++ bindings/python/mapnik_markers_symbolizer.cpp | 8 ++++++++ src/agg/process_markers_symbolizer.cpp | 6 ++++-- src/grid/process_markers_symbolizer.cpp | 7 +++++-- src/markers_symbolizer.cpp | 8 ++++---- tests/python_tests/render_grid_test.py | 2 ++ tests/python_tests/render_test.py | 2 ++ 7 files changed, 27 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a52b7056..2f3920059 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ For a complete change history, see the SVN log. ## Mapnik 2.1.0 +- Fix Markers rendering so that ellipse height/width units are pixels (previously were unintentially radii) + - Removed mutex locking during reprojection if using >= proj 4.7 (#1072) - Removed PointDatasource - use more robust MemoryDatasource instead (#1032) diff --git a/bindings/python/mapnik_markers_symbolizer.cpp b/bindings/python/mapnik_markers_symbolizer.cpp index 999bb40e6..17d860f11 100644 --- a/bindings/python/mapnik_markers_symbolizer.cpp +++ b/bindings/python/mapnik_markers_symbolizer.cpp @@ -116,5 +116,13 @@ void export_markers_symbolizer() .add_property("transform", &mapnik::get_svg_transform, &mapnik::set_svg_transform) + .add_property("width", + &markers_symbolizer::get_width, + &markers_symbolizer::set_width, + "Set/get the marker width") + .add_property("height", + &markers_symbolizer::get_height, + &markers_symbolizer::set_height, + "Set/get the marker height") ; } diff --git a/src/agg/process_markers_symbolizer.cpp b/src/agg/process_markers_symbolizer.cpp index ae7725bf1..17bf44f60 100644 --- a/src/agg/process_markers_symbolizer.cpp +++ b/src/agg/process_markers_symbolizer.cpp @@ -171,6 +171,8 @@ void agg_renderer::process(markers_symbolizer const& sym, unsigned s_a=col.alpha(); double w = sym.get_width(); double h = sym.get_height(); + double rx = w/2.0; + double ry = h/2.0; arrow arrow_; box2d extent; @@ -225,7 +227,7 @@ void agg_renderer::process(markers_symbolizer const& sym, if (sym.get_allow_overlap() || detector_->has_placement(label_ext)) { - agg::ellipse c(x, y, w, h); + agg::ellipse c(x, y, rx, ry); marker.concat_path(c); ras_ptr->add_path(marker); ren.color(agg::rgba8(r, g, b, int(a*sym.get_opacity()))); @@ -271,7 +273,7 @@ void agg_renderer::process(markers_symbolizer const& sym, if (marker_type == ELLIPSE) { // todo proper bbox - this is buggy - agg::ellipse c(x_t, y_t, w, h); + agg::ellipse c(x_t, y_t, rx, ry); marker.concat_path(c); agg::trans_affine matrix; matrix *= agg::trans_affine_translation(-x_t,-y_t); diff --git a/src/grid/process_markers_symbolizer.cpp b/src/grid/process_markers_symbolizer.cpp index 1f25cccc3..b5367cb51 100644 --- a/src/grid/process_markers_symbolizer.cpp +++ b/src/grid/process_markers_symbolizer.cpp @@ -148,6 +148,9 @@ void grid_renderer::process(markers_symbolizer const& sym, h = sym.get_height()/res; } + double rx = w/2.0; + double ry = h/2.0; + arrow arrow_; box2d extent; @@ -195,7 +198,7 @@ void grid_renderer::process(markers_symbolizer const& sym, if (sym.get_allow_overlap() || detector_.has_placement(label_ext)) { - agg::ellipse c(x, y, w, h); + agg::ellipse c(x, y, rx, ry); agg::path_storage marker; marker.concat_path(c); ras_ptr->add_path(marker); @@ -232,7 +235,7 @@ void grid_renderer::process(markers_symbolizer const& sym, if (marker_type == ELLIPSE) { // todo proper bbox - this is buggy - agg::ellipse c(x_t, y_t, w, h); + agg::ellipse c(x_t, y_t, rx, ry); marker.concat_path(c); agg::trans_affine matrix; matrix *= agg::trans_affine_translation(-x_t,-y_t); diff --git a/src/markers_symbolizer.cpp b/src/markers_symbolizer.cpp index a2ccd70ab..e640eac17 100644 --- a/src/markers_symbolizer.cpp +++ b/src/markers_symbolizer.cpp @@ -51,8 +51,8 @@ markers_symbolizer::markers_symbolizer() fill_(color(0,0,255)), spacing_(100.0), max_error_(0.2), - width_(5.0), - height_(5.0), + width_(10.0), + height_(10.0), stroke_(), marker_p_(MARKER_LINE_PLACEMENT), marker_type_(ARROW) {} @@ -65,8 +65,8 @@ markers_symbolizer::markers_symbolizer(path_expression_ptr filename) fill_(color(0,0,255)), spacing_(100.0), max_error_(0.2), - width_(5.0), - height_(5.0), + width_(10.0), + height_(10.0), stroke_(), marker_p_(MARKER_LINE_PLACEMENT), marker_type_(ARROW) {} diff --git a/tests/python_tests/render_grid_test.py b/tests/python_tests/render_grid_test.py index 2bf8ec2d4..140f97c9d 100644 --- a/tests/python_tests/render_grid_test.py +++ b/tests/python_tests/render_grid_test.py @@ -57,6 +57,8 @@ def create_grid_map(width,height): s = mapnik.Style() r = mapnik.Rule() symb = mapnik.MarkersSymbolizer() + symb.width = 10 + symb.height = 10 symb.allow_overlap = True r.symbols.append(symb) diff --git a/tests/python_tests/render_test.py b/tests/python_tests/render_test.py index 131906a6d..cb1f19be7 100644 --- a/tests/python_tests/render_test.py +++ b/tests/python_tests/render_test.py @@ -146,6 +146,8 @@ def test_render_grid(): s = mapnik.Style() r = mapnik.Rule() symb = mapnik.MarkersSymbolizer() + symb.width = 10 + symb.height = 10 symb.allow_overlap = True r.symbols.append(symb) s.rules.append(r)