Skip to content
Browse files

Fix line placement of markers on points (#1548)

  • Loading branch information...
1 parent 33dcd5a commit 664e05b2ca86a37c19d47e9de66a47a19e912f50 @springmeyer springmeyer committed with strk Dec 2, 2012
View
20 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<double> 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;
View
6 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<double> 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;
View
20 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;
View
BIN tests/visual_tests/images/marker_line_placement_on_points-500-reference.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
36 tests/visual_tests/styles/marker_line_placement_on_points.xml
@@ -0,0 +1,36 @@
+<!DOCTYPE Map>
+<Map background-color="white" srs="+init=epsg:4326" minimum-version="0.7.2">
+
+ <Style name="1">
+ <Rule>
+ <Filter>[id]=1</Filter>
+ <MarkersSymbolizer fill="darkgreen" opacity=".7" width="15" height="10" stroke="green" stroke-width="7" stroke-opacity=".2" placement="line" marker-type="ellipse"/>
+ </Rule>
+ <Rule>
+ <Filter>[id]=2</Filter>
+ <MarkersSymbolizer fill="darkorange" opacity=".7" width="20" height="10" stroke="orange" stroke-width="7" stroke-opacity=".2" placement="line" marker-type="ellipse"/>
+ </Rule>
+ <Rule>
+ <Filter>[id]=3</Filter>
+ <MarkersSymbolizer fill="darkred" opacity=".7" width="20" height="10" stroke="orange" stroke-width="7" stroke-opacity=".2" placement="line" marker-type="ellipse"/>
+ </Rule>
+ </Style>
+ <Layer name="point" srs="+init=epsg:4326">
+ <StyleName>1</StyleName>
+ <Datasource>
+ <Parameter name="type">csv</Parameter>
+ <Parameter name="inline">
+ 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
+ </Parameter>
+ </Datasource>
+ </Layer>
+</Map>
View
2 tests/visual_tests/test.py
@@ -31,6 +31,8 @@
'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"},

0 comments on commit 664e05b

Please sign in to comment.
Something went wrong with that request. Please try again.