3.10.13. ArcSymbolizer
|
Note
|
The ArcSymbolizer is a recent experimental addition (not in a Mapnik release yet). It supports the AGG, Cairo and SVG renderer backends. |
The ArcSymbolizer can draw full circles and partial arcs. The arc center point is defined by the layer geometry while radius, start and end angle in case of arcs, and visual styling are defined by the symbolizer attributes.
The motivation to create the ArcSymbolizer was to be able to render sea navigation lights in a way similar to how the custom OpenSeaMap renderer does it, but can also be used for other purposes like e.g visualization of camera viewing areas, or even to add simple pie charts to a map.
Arcs are drawn clockwise from the start-angle to the end-angle, angle values are given in degrees with 0° / 360° being north / up. As the angles default to 0° and 360° a full circle is drawn when no angle values are given explicitly.
The ArcSymbolizer allows to style how the arc is filled and what strokes to use for the actual ark, and for the radius lines connecting the end points of the arc to the center point. Adding a textual label is also possible, the text will be drawn curved along the arc when the arc is longer than the text; otherwise the text will be drawn facing outwards from the arc center.
The stroke- attributes style both the arc line and the radius lines. Each of them can be overridden separately for just the arc line by an arc-stroke- attribute, and for just the radius lines by a radius-stroke-* attribute. The radius lines are drawn whenever stroke or radius-stroke is set; to draw an arc line without radius lines, use arc-stroke instead of stroke.
|
Note
|
The attribute names are not final yet. |
| Attribute | Type | Default | Description |
|---|---|---|---|
float |
0 |
Radius in pixels |
|
float |
0 |
Starting arc angle, 0° being north/up |
|
float |
360 |
Ending arc angle, arc is drawn clockwise from start to end |
|
color |
none |
Circle / arc fill color |
|
|
0.0 - 1.0 |
1 |
… TODO … |
color |
none |
Color of both the arc line and the radius lines |
|
|
float |
1 |
Width of both the arc line and the radius lines |
|
0.0 - 1.0 |
1 |
|
|
number list |
none |
Dash pattern for both the arc line and the radius lines |
|
float |
0 |
|
color |
stroke |
Color of the arc line only |
|
|
float |
stroke-width |
Width of the arc line only |
|
0.0 - 1.0 |
stroke-opacity |
|
|
number list |
stroke-dasharray |
Dash pattern for the arc line only |
|
float |
stroke-dashoffset |
|
color |
stroke |
Color of the radius lines only |
|
float |
stroke-width |
Width of the radius lines only |
|
|
0.0 - 1.0 |
stroke-opacity |
|
number list |
stroke-dasharray |
Dash pattern for the radius lines only |
|
|
float |
stroke-dashoffset |
|
expression |
none |
Label, bent along the arc or placed perpendicular to it |
|
|
string |
Font face for the label, required with text |
|
|
string |
Fontset alternative to text-face-name |
|
|
float |
10 |
|
|
color |
black |
Text color |
|
0.0 - 1.0 |
1 |
|
|
color |
white |
|
|
float |
0 |
|
|
0.0 - 1.0 |
1 |
|
|
float |
0 |
|
|
none, uppercase, lowercase, capitalize, reverse |
none |
Case conversion applied to the label text |
|
string |
none |
Comma separated list of OpenType typographic features |
float |
2 |
Radial gap between the arc line and the label |
|
|
boolean |
false |
Draw the label even if it collides with other labels; otherwise it is dropped on a collision |
|
string |
src-over |
See Compositing |
<?xml version="1.0" encoding="utf-8"?>
<!-- simple example showing use of start and end angles -->
<Map background-color="white">
<Style name="style">
<Rule>
<ArcSymbolizer radius="40" start-angle="[start]" end-angle="[end]"
fill="steelblue" fill-opacity="0.3"
stroke="steelblue" stroke-width="2"/>
<TextSymbolizer face-name="DejaVu Sans Book" allow-overlap="true" dy="55">[start]+"-"+[end]</TextSymbolizer>
</Rule>
</Style>
<Layer name="layer">
<StyleName>style</StyleName>
<Datasource>
<Parameter name="type">csv</Parameter>
<Parameter name="inline">
wkt,start,end
"POINT(0 0)",45,135
"POINT(2 0)",134,45
"POINT(4 0)",0,360
</Parameter>
</Datasource>
</Layer>
</Map>
<?xml version="1.0" encoding="utf-8"?>
<Map background-color="white">
<Style name="style">
<Rule>
<Filter>[variant] = 'fill'</Filter>
<ArcSymbolizer radius="50" start-angle="270" end-angle="90"
fill="orange"/>
</Rule>
<Rule>
<Filter>[variant] = 'stroke'</Filter>
<ArcSymbolizer radius="50" start-angle="270" end-angle="90"
stroke="black" stroke-width="2"/>
</Rule>
<Rule>
<Filter>[variant] = 'both'</Filter>
<ArcSymbolizer radius="50" start-angle="270" end-angle="90"
fill="orange" stroke="black" stroke-width="2"/>
</Rule>
<Rule>
<TextSymbolizer face-name="DejaVu Sans Book" allow-overlap="true" dy="20">[variant]</TextSymbolizer>
</Rule>
</Style>
<Layer name="layer">
<StyleName>style</StyleName>
<Datasource>
<Parameter name="type">csv</Parameter>
<Parameter name="inline">
wkt,variant
"POINT(0 0)",fill
"POINT(2 0)",stroke
"POINT(4 0)",both
</Parameter>
</Datasource>
</Layer>
</Map>
Radius lines use the stroke- attributes by default, and radius-stroke- attributes change them without affecting the arc line. Setting only arc-stroke instead of stroke draws the arc line without radius lines.
<?xml version="1.0" encoding="utf-8"?>
<Map background-color="white">
<Style name="style">
<Rule>
<Filter>[variant] = 'default'</Filter>
<ArcSymbolizer radius="50" start-angle="300" end-angle="60"
stroke="blue" stroke-width="2"/>
</Rule>
<Rule>
<Filter>[variant] = 'styled'</Filter>
<ArcSymbolizer radius="50" start-angle="300" end-angle="60"
stroke="blue" stroke-width="2"
radius-stroke="red" radius-stroke-width="4"/>
</Rule>
<Rule>
<Filter>[variant] = 'dashed'</Filter>
<ArcSymbolizer radius="50" start-angle="300" end-angle="60"
stroke="blue" stroke-width="2"
radius-stroke-dasharray="4,3"/>
</Rule>
<Rule>
<Filter>[variant] = 'none'</Filter>
<ArcSymbolizer radius="50" start-angle="300" end-angle="60"
arc-stroke="blue" arc-stroke-width="2"/>
</Rule>
<Rule>
<TextSymbolizer face-name="DejaVu Sans Book" allow-overlap="true" dy="20">[variant]</TextSymbolizer>
</Rule>
</Style>
<Layer name="layer">
<StyleName>style</StyleName>
<Datasource>
<Parameter name="type">csv</Parameter>
<Parameter name="inline">
wkt,variant
"POINT(0 0)",default
"POINT(2 0)",styled
"POINT(4 0)",dashed
"POINT(6 0)",none
</Parameter>
</Datasource>
</Layer>
</Map>
The first arc is long enough for its label, so the text is bent along its outside. The same goes for the second, on the lower half of the circle, where the reading direction is flipped to stay readable. The third arc is too short for its label, so the text is placed perpendicular to the arc instead.
<?xml version="1.0" encoding="utf-8"?>
<Map background-color="white">
<Style name="style">
<Rule>
<ArcSymbolizer radius="[radius]" start-angle="[start]" end-angle="[end]"
stroke="darkblue" stroke-width="2"
text="[label]" text-face-name="DejaVu Sans Book"
text-size="10" text-fill="black"/>
<DotSymbolizer width="5" height="5" fill="red"/>
</Rule>
</Style>
<Layer name="layer">
<StyleName>style</StyleName>
<Datasource>
<Parameter name="type">csv</Parameter>
<Parameter name="inline">
wkt,radius,start,end,label
"POINT(0 0)",50,300,60,"above"
"POINT(2 0)",50,120,240,"below"
"POINT(4 0)",45,80,100,"small arc"
</Parameter>
</Datasource>
</Layer>
</Map>
Using the ArcSymbolizer to display navigational lights in a way similar to the custom OpenSeaMap renderer:
<?xml version="1.0" encoding="utf-8"?>
<Map background-color="white">
<!-- Visibility sectors of a naval navigation light, in the style
used by OpenSeaMap: one coloured arc per sector labelled with its
light characteristic, with dashed radius lines marking the sector
limits. -->
<Style name="style">
<Rule>
<ArcSymbolizer radius="[radius]" start-angle="[start]" end-angle="[end]"
stroke="[colour]" stroke-width="4"
radius-stroke="dimgray" radius-stroke-width="1"
radius-stroke-dasharray="6,4"
text="[character]" text-face-name="DejaVu Sans Book"
text-size="9" text-fill="black"/>
<DotSymbolizer width="8" height="8" fill="black"/>
</Rule>
</Style>
<Layer name="layer">
<StyleName>style</StyleName>
<Datasource>
<Parameter name="type">csv</Parameter>
<Parameter name="inline">
wkt,start,end,radius,colour,character
"POINT(0 0)",290,10,80,red,Fl.R.4s
"POINT(0 0)",10,20,90,gold,Fl.W.4s
"POINT(0 0)",20,100,80,green,Fl.G.4s
</Parameter>
</Datasource>
</Layer>
</Map>