Stylesheet is code that, when applied to geographic data, determines
the visual appearance of the content. Once added in Geoserver and
connected to the
relevant layers, a
proper map can be displayed
through a WMS
feed.
To style OS Open Map Local in
the ‘backdrop’ theme, different
stylesheets are
requested for each layer depending of geometry and classification -
building, river, road, etc. In this blogpost, polygon with building,
line with road and points
with London Underground logo will be presented
and explained.
Building:
For
building, the stylesheet
is simple with just minimum and maximum scale limit and color defined
by HEX code color.
Road:
To style line data as
roads, minimum
and maximum scale rules are
used. The rule
for A Road is defined with the LineSymbolizer. Color is specified via
HEX code color, width of line in pixel (12 pixels), stroke-linecap
parameter renders the ends of line as rounded instead of flat and the
stroke-linejoin parameter renders the
junction with other line as rounded.
Label
is set with TextSymbolizer with different parameters: Font,
LabelPlacement, Halo, Fill, VendorOption.
Font
set identifies font family, font size and font weight.
LabelPlacement
set defines label position in regard
to the line in
pixels. In the
case of A Roads
PerpendicularOffset is set to the default,
which is 0. A
positive value displaces upwards, a negative value downwards.
Halo
set characterizes a halo
around the font
with radius in pixels
and fill with HEX code color.
Fill
set identifies label color with HEX
code color.
Vendor
option sets is a
Geoserver specific option composed of
multiple parameters.
- spaceAround allow labels to overlap (negative value) or add extra space around labels (positive value)
- followLine forces the labels to follow the curve of the line
- Group allows display of a single label for multiple features in a logical group
- maxAngleDelta sets the maximum angle, in degrees, between two characters. Used in conjunction with followLine.
- maxDisplacement controls the displacement of the label along the line. This option avoids conflict by using alternate location with pixels along the line.
- Repeat defines how often a label is displayed along a line.
London Underground Station:
To style a point
with the London
underground logo, the
stylesheet uses a
link to an
external SVG file
which contains the London
underground logo. In this case only minimum and maximum scale are
determined and SVG size. This method can be
used for any complex object that cannot be created using standard
stylesheets.