Fix line placement of markers on points (#1548)

REFS #1604,#1350,#1607,#1548,#1625
This commit is contained in:
Dane Springmeyer 2012-12-02 19:53:44 -08:00 committed by Sandro Santilli
parent 33dcd5a459
commit 664e05b2ca
6 changed files with 74 additions and 10 deletions

View file

@ -78,11 +78,17 @@ struct raster_markers_rasterizer_dispatch_grid
{ {
marker_placement_e placement_method = sym_.get_marker_placement(); marker_placement_e placement_method = sym_.get_marker_placement();
box2d<double> bbox_(0,0, src_.width(),src_.height()); 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 x = 0;
double y = 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)) if (!label::interior_position(path, x, y))
return; return;
@ -209,11 +215,17 @@ struct vector_markers_rasterizer_dispatch_grid
void add_path(T & path) void add_path(T & path)
{ {
marker_placement_e placement_method = sym_.get_marker_placement(); 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 x = 0;
double y = 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)) if (!label::interior_position(path, x, y))
return; return;

View file

@ -87,7 +87,8 @@ struct vector_markers_rasterizer_dispatch
{ {
marker_placement_e placement_method = sym_.get_marker_placement(); 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 x = 0;
double y = 0; double y = 0;
@ -188,7 +189,8 @@ struct raster_markers_rasterizer_dispatch
marker_placement_e placement_method = sym_.get_marker_placement(); marker_placement_e placement_method = sym_.get_marker_placement();
box2d<double> bbox_(0,0, src_.width(),src_.height()); 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 x = 0;
double y = 0; double y = 0;

View file

@ -1494,11 +1494,17 @@ struct markers_dispatch
{ {
marker_placement_e placement_method = sym_.get_marker_placement(); 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 x = 0;
double y = 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)) if (!label::interior_position(path, x, y))
return; return;
@ -1577,11 +1583,17 @@ struct markers_dispatch_2
{ {
marker_placement_e placement_method = sym_.get_marker_placement(); 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 x = 0;
double y = 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)) if (!label::interior_position(path, x, y))
return; return;

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View file

@ -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 file

@ -31,6 +31,8 @@ files = [
'bbox': mapnik.Box2d(0, 0, 190, 180)}, 'bbox': mapnik.Box2d(0, 0, 190, 180)},
{'name': "marker-on-line", 'sizes':[(600,400)], {'name': "marker-on-line", 'sizes':[(600,400)],
'bbox': mapnik.Box2d(-10, 0, 15, 20)}, '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)], {'name': "whole-centroid", 'sizes':[(600,400)],
'bbox': mapnik.Box2d(736908, 4390316, 2060771, 5942346)}, 'bbox': mapnik.Box2d(736908, 4390316, 2060771, 5942346)},
{'name': "simple-E"}, {'name': "simple-E"},