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 ced6f7cb3..6972c5028 100644 --- a/src/cairo_renderer.cpp +++ b/src/cairo_renderer.cpp @@ -1494,11 +1494,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; @@ -1577,11 +1583,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/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 000000000..71b1fb1f1 Binary files /dev/null and b/tests/visual_tests/images/marker_line_placement_on_points-500-reference.png differ 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 d8fdd1ebd..ec05fde78 100755 --- a/tests/visual_tests/test.py +++ b/tests/visual_tests/test.py @@ -31,6 +31,8 @@ files = [ 'bbox': mapnik.Box2d(0, 0, 190, 180)}, {'name': "marker-on-line", 'sizes':[(600,400)], 'bbox': mapnik.Box2d(-10, 0, 15, 20)}, + {'name': "marker_line_placement_on_points", 'sizes':[(500,100)], + 'bbox': mapnik.Box2d(0, 0, 5, 5)}, {'name': "whole-centroid", 'sizes':[(600,400)], 'bbox': mapnik.Box2d(736908, 4390316, 2060771, 5942346)}, {'name': "simple-E"},