Merge pull request #1636 from strk/2.1.x-marker-placement-fixes
2.1.x marker placement fixes
This commit is contained in:
commit
41a650e568
15 changed files with 123 additions and 12 deletions
2
deps/agg/include/agg_conv_adaptor_vcgen.h
vendored
2
deps/agg/include/agg_conv_adaptor_vcgen.h
vendored
|
@ -29,6 +29,7 @@ namespace agg
|
|||
|
||||
void rewind(unsigned) {}
|
||||
unsigned vertex(double*, double*) { return path_cmd_stop; }
|
||||
unsigned type() const { return 0; }
|
||||
};
|
||||
|
||||
|
||||
|
@ -64,6 +65,7 @@ namespace agg
|
|||
}
|
||||
|
||||
unsigned vertex(double* x, double* y);
|
||||
unsigned type() const { return m_source->type(); }
|
||||
|
||||
private:
|
||||
// Prohibit copying
|
||||
|
|
1
deps/agg/include/agg_conv_adaptor_vpgen.h
vendored
1
deps/agg/include/agg_conv_adaptor_vpgen.h
vendored
|
@ -33,6 +33,7 @@ namespace agg
|
|||
|
||||
void rewind(unsigned path_id);
|
||||
unsigned vertex(double* x, double* y);
|
||||
unsigned type() const { return m_source->type(); }
|
||||
|
||||
private:
|
||||
conv_adaptor_vpgen(const conv_adaptor_vpgen<VertexSource, VPGen>&);
|
||||
|
|
1
deps/agg/include/agg_conv_clip_polygon.h
vendored
1
deps/agg/include/agg_conv_clip_polygon.h
vendored
|
@ -51,6 +51,7 @@ namespace agg
|
|||
double y1() const { return base_type::vpgen().y1(); }
|
||||
double x2() const { return base_type::vpgen().x2(); }
|
||||
double y2() const { return base_type::vpgen().y2(); }
|
||||
unsigned type() const { return base_type::type(); }
|
||||
|
||||
private:
|
||||
conv_clip_polygon(const conv_clip_polygon<VertexSource>&);
|
||||
|
|
1
deps/agg/include/agg_conv_clip_polyline.h
vendored
1
deps/agg/include/agg_conv_clip_polyline.h
vendored
|
@ -51,6 +51,7 @@ namespace agg
|
|||
double y1() const { return base_type::vpgen().y1(); }
|
||||
double x2() const { return base_type::vpgen().x2(); }
|
||||
double y2() const { return base_type::vpgen().y2(); }
|
||||
unsigned type() const { return base_type::type(); }
|
||||
|
||||
private:
|
||||
conv_clip_polyline(const conv_clip_polyline<VertexSource>&);
|
||||
|
|
2
deps/agg/include/agg_conv_smooth_poly1.h
vendored
2
deps/agg/include/agg_conv_smooth_poly1.h
vendored
|
@ -42,6 +42,7 @@ namespace agg
|
|||
|
||||
void smooth_value(double v) { base_type::generator().smooth_value(v); }
|
||||
double smooth_value() const { return base_type::generator().smooth_value(); }
|
||||
unsigned type() const { return base_type::type(); }
|
||||
|
||||
private:
|
||||
conv_smooth_poly1(const conv_smooth_poly1<VertexSource>&);
|
||||
|
@ -64,6 +65,7 @@ namespace agg
|
|||
|
||||
void smooth_value(double v) { m_smooth.generator().smooth_value(v); }
|
||||
double smooth_value() const { return m_smooth.generator().smooth_value(); }
|
||||
unsigned type() const { return m_smooth.type(); }
|
||||
|
||||
private:
|
||||
conv_smooth_poly1_curve(const conv_smooth_poly1_curve<VertexSource>&);
|
||||
|
|
|
@ -81,6 +81,11 @@ struct MAPNIK_DECL coord_transform
|
|||
geom_.rewind(pos);
|
||||
}
|
||||
|
||||
unsigned type() const
|
||||
{
|
||||
return static_cast<unsigned>(geom_.type());
|
||||
}
|
||||
|
||||
Geometry const& geom() const
|
||||
{
|
||||
return geom_;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -87,11 +87,17 @@ 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;
|
||||
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;
|
||||
|
@ -183,11 +189,17 @@ 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;
|
||||
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;
|
||||
|
|
|
@ -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;
|
||||
|
|
2
tests/visual_tests/data/marker-on-line.csv
Normal file
2
tests/visual_tests/data/marker-on-line.csv
Normal file
|
@ -0,0 +1,2 @@
|
|||
i|wkt
|
||||
1|LINESTRING(-10 0, 0 20, 10 0, 15 5)
|
|
BIN
tests/visual_tests/images/marker-on-line-600-reference.png
Normal file
BIN
tests/visual_tests/images/marker-on-line-600-reference.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
21
tests/visual_tests/styles/marker-on-line.xml
Normal file
21
tests/visual_tests/styles/marker-on-line.xml
Normal file
|
@ -0,0 +1,21 @@
|
|||
<Map>
|
||||
<Style name="line" filter-mode="first" >
|
||||
<Rule>
|
||||
<LineSymbolizer stroke="#000000" />
|
||||
</Rule>
|
||||
</Style>
|
||||
<Style name="point-placement" filter-mode="first" >
|
||||
<Rule>
|
||||
<MarkersSymbolizer placement="point" marker-type="ellipse" fill="blue" />
|
||||
</Rule>
|
||||
</Style>
|
||||
<Layer name="carto_tests">
|
||||
<StyleName>line</StyleName>
|
||||
<StyleName>point-placement</StyleName>
|
||||
<Datasource>
|
||||
<Parameter name="type">csv</Parameter>
|
||||
<Parameter name="file">../data/marker-on-line.csv</Parameter>
|
||||
<Parameter name="separator">|</Parameter>
|
||||
</Datasource>
|
||||
</Layer>
|
||||
</Map>
|
|
@ -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>
|
|
@ -29,6 +29,10 @@ files = [
|
|||
{'name': "lines-shield", 'sizes': sizes_few_square},
|
||||
{'name': "marker-multi-policy", 'sizes':[(600,400)],
|
||||
'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"},
|
||||
|
|
Loading…
Reference in a new issue