From 7d408d523c6bd0331a3650aae2e84ee3aa3e31b8 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Sun, 2 Dec 2012 19:53:44 -0800 Subject: [PATCH] close #1548 with explict handling of point geometries and amend 629d768eae5 for cairo/grid renderers to ensure proper placement on lines (refs #1604,#1350,#1607) --- include/mapnik/grid/grid_marker_helpers.hpp | 20 +++++++-- include/mapnik/marker_helpers.hpp | 6 ++- src/cairo_renderer.cpp | 20 +++++++-- tests/visual_tests/compare.py | 2 +- ...ine_placement_on_points-500-reference.json | 40 ++++++++++++++++++ ...line_placement_on_points-500-reference.png | Bin 0 -> 2356 bytes .../marker_line_placement_on_points.xml | 36 ++++++++++++++++ tests/visual_tests/test.py | 1 + 8 files changed, 114 insertions(+), 11 deletions(-) create mode 100644 tests/visual_tests/grids/marker_line_placement_on_points-500-reference.json create mode 100644 tests/visual_tests/images/marker_line_placement_on_points-500-reference.png create mode 100644 tests/visual_tests/styles/marker_line_placement_on_points.xml diff --git a/include/mapnik/grid/grid_marker_helpers.hpp b/include/mapnik/grid/grid_marker_helpers.hpp index a77bd7510..f5e3629a7 100644 --- a/include/mapnik/grid/grid_marker_helpers.hpp +++ b/include/mapnik/grid/grid_marker_helpers.hpp @@ -78,11 +78,17 @@ struct raster_markers_rasterizer_dispatch_grid { marker_placement_e placement_method = sym_.get_marker_placement(); box2d bbox_(0,0, src_.width(),src_.height()); - if (placement_method != MARKER_LINE_PLACEMENT) + if (placement_method != MARKER_LINE_PLACEMENT || + path.type() == Point) { double x = 0; double y = 0; - if (placement_method == MARKER_INTERIOR_PLACEMENT) + if (path.type() == LineString) + { + if (!label::middle_point(path, x, y)) + return; + } + else if (placement_method == MARKER_INTERIOR_PLACEMENT) { if (!label::interior_position(path, x, y)) return; @@ -209,11 +215,17 @@ struct vector_markers_rasterizer_dispatch_grid void add_path(T & path) { marker_placement_e placement_method = sym_.get_marker_placement(); - if (placement_method != MARKER_LINE_PLACEMENT) + if (placement_method != MARKER_LINE_PLACEMENT || + path.type() == Point) { double x = 0; double y = 0; - if (placement_method == MARKER_INTERIOR_PLACEMENT) + if (path.type() == LineString) + { + if (!label::middle_point(path, x, y)) + return; + } + else if (placement_method == MARKER_INTERIOR_PLACEMENT) { if (!label::interior_position(path, x, y)) return; diff --git a/include/mapnik/marker_helpers.hpp b/include/mapnik/marker_helpers.hpp index 594617702..7d9861528 100644 --- a/include/mapnik/marker_helpers.hpp +++ b/include/mapnik/marker_helpers.hpp @@ -87,7 +87,8 @@ struct vector_markers_rasterizer_dispatch { marker_placement_e placement_method = sym_.get_marker_placement(); - if (placement_method != MARKER_LINE_PLACEMENT) + if (placement_method != MARKER_LINE_PLACEMENT || + path.type() == Point) { double x = 0; double y = 0; @@ -188,7 +189,8 @@ struct raster_markers_rasterizer_dispatch marker_placement_e placement_method = sym_.get_marker_placement(); box2d bbox_(0,0, src_.width(),src_.height()); - if (placement_method != MARKER_LINE_PLACEMENT) + if (placement_method != MARKER_LINE_PLACEMENT || + path.type() == Point) { double x = 0; double y = 0; diff --git a/src/cairo_renderer.cpp b/src/cairo_renderer.cpp index 7f43ba5cf..32d38bcf0 100644 --- a/src/cairo_renderer.cpp +++ b/src/cairo_renderer.cpp @@ -1550,11 +1550,17 @@ struct markers_dispatch { marker_placement_e placement_method = sym_.get_marker_placement(); - if (placement_method != MARKER_LINE_PLACEMENT) + if (placement_method != MARKER_LINE_PLACEMENT || + path.type() == Point) { double x = 0; double y = 0; - if (placement_method == MARKER_INTERIOR_PLACEMENT) + if (path.type() == LineString) + { + if (!label::middle_point(path, x, y)) + return; + } + else if (placement_method == MARKER_INTERIOR_PLACEMENT) { if (!label::interior_position(path, x, y)) return; @@ -1633,11 +1639,17 @@ struct markers_dispatch_2 { marker_placement_e placement_method = sym_.get_marker_placement(); - if (placement_method != MARKER_LINE_PLACEMENT) + if (placement_method != MARKER_LINE_PLACEMENT || + path.type() == Point) { double x = 0; double y = 0; - if (placement_method == MARKER_INTERIOR_PLACEMENT) + if (path.type() == LineString) + { + if (!label::middle_point(path, x, y)) + return; + } + else if (placement_method == MARKER_INTERIOR_PLACEMENT) { if (!label::interior_position(path, x, y)) return; diff --git a/tests/visual_tests/compare.py b/tests/visual_tests/compare.py index 92bea4ad8..3530688c5 100644 --- a/tests/visual_tests/compare.py +++ b/tests/visual_tests/compare.py @@ -85,7 +85,7 @@ def summary(generate=False): global passed if len(errors) != 0: - msg = "Visual text rendering: %s failures" % len(errors) + msg = "Visual text rendering: %s failed / %s passed" % (len(errors),passed) print "-"*len(msg) print msg print "-"*len(msg) diff --git a/tests/visual_tests/grids/marker_line_placement_on_points-500-reference.json b/tests/visual_tests/grids/marker_line_placement_on_points-500-reference.json new file mode 100644 index 000000000..eb5e8d76b --- /dev/null +++ b/tests/visual_tests/grids/marker_line_placement_on_points-500-reference.json @@ -0,0 +1,40 @@ +{ + "keys": [ + "", + "4", + "3", + "6", + "5", + "7", + "1", + "2" + ], + "data": {}, + "grid": [ + " !!!!!! ###### ", + " !!!!! ##### ", + " !! ## ", + " ", + " ", + " ", + " ", + " ", + " $$$$ ", + " $$$$$$ ", + " $$$$$$$ ", + " $$$$$$ ", + " %%%$$%% ", + " %%&&&&% ", + " &&&&&& ", + " &&&&&&& ", + " &&&&&& ", + " && ", + " ", + " ", + " ", + " ", + " ", + " ''' ((( ", + " ''''' ((((( " + ] +} \ No newline at end of file diff --git a/tests/visual_tests/images/marker_line_placement_on_points-500-reference.png b/tests/visual_tests/images/marker_line_placement_on_points-500-reference.png new file mode 100644 index 0000000000000000000000000000000000000000..71b1fb1f10acd634a249358b225acd66401101e8 GIT binary patch literal 2356 zcmcImdpy(o8~?H#QZ{}#T}%`a6_v>SM6~2Ymf_?!6djk4YoyKkog-8#X)>Wqxo=Wr zG$hSsri*LV##|=1xf>fh-*sN+_xqi{et(^RKCjQ~`8=QJc|Pyw{rbG0uRVHS0ZUn=&ti`oTG0)c2>Di z-br#3QrA{D`MlKAeY(g~1sr*P!Oc%D#}Dp^;O{dmYE*c6+&Wmgc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$mX5-^Z9)*JuW8&uNi_M`bQMXFa+&f$6W z=$<;s&>BoU@C%4^@22b9`A)wcd8)qV-1rVw(fNROJx*h2xiB^j9tQqRfcPx{AT1vW z0OHO7VZc9aME|Hid(_C}*^}hma<}B({azC?V=yr58*Ywm));TOYQ+yQHZ4s$0qgE& z8}h`e*8w+IgTvGfK+WrTmlr?|XbjVY8qnyr(cm4rLgYwki;dYjOcm^ropOlactQ4h;>WyF48ffnOf&>jOYt(lDJ6~-VR%}f{lsn$5D;kjV2s_g!t%>Sw}_b=^tQ0~&C z<&&SCZ8mHMbyC|_Guv;>(w$bCOb0VgsgJklTpuin&x;>R7L9bI+xhIXa4vpv;$nCc g6Tf}u-^U73|I58YW?{zd;4}o-**e&iTcdG*0NTlCBme*a literal 0 HcmV?d00001 diff --git a/tests/visual_tests/styles/marker_line_placement_on_points.xml b/tests/visual_tests/styles/marker_line_placement_on_points.xml new file mode 100644 index 000000000..db11328c6 --- /dev/null +++ b/tests/visual_tests/styles/marker_line_placement_on_points.xml @@ -0,0 +1,36 @@ + + + + + + 1 + + csv + + x,y,id + 0,0,1 + 5,0,1 + 5,5,1 + 0,5,1 + 2.5,2.5,2 + 2.5,3,3 + 2.5,2,3 + 3,2.5,3 + 2,2.5,3 + + + + \ No newline at end of file diff --git a/tests/visual_tests/test.py b/tests/visual_tests/test.py index d5192bc80..6cfb1e002 100755 --- a/tests/visual_tests/test.py +++ b/tests/visual_tests/test.py @@ -38,6 +38,7 @@ files = [ {'name': "lines-3", 'sizes': sizes_few_square,'bbox':default_text_box}, {'name': "lines-shield", 'sizes': sizes_few_square,'bbox':default_text_box}, {'name': "marker-multi-policy", 'sizes':[(600,400)]}, + {'name': "marker_line_placement_on_points"}, {'name': "whole-centroid", 'sizes':[(600,400)], 'bbox': mapnik.Box2d(736908, 4390316, 2060771, 5942346)}, {'name': "simple-E", 'bbox':mapnik.Box2d(-0.05, -0.01, 0.95, 0.01)},