

Lines 12-13 set the color of the line to be a dark green If this condition is true for a particular line, the rule is rendered according Lines 4-9 set the filter for this rule, such that the “type”Īttribute has a value of “local-road”. is drawn based on the order in which it appears in the SLD. This ensures that each road type is rendered in order, as each In order to handle each case separately, there is more than one “highway”, “secondary”, and “local-road”. There are three types of road classes in our fictional country, ranging from back roads to high-speed freeways: This example has eschewed labels in order to simplify the style, but you can refer to the example Optimized and styled label to see which attributes correspond to which points. Refer to the Example lines layer to see the attributes for the layer. A feature will typically receive only one label, but this can cause confusion for long lines. Finally, line 21 sets the labels to be repeated every 150 pixels. This value sets how far the label can be moved relative to its original placement. In order to resolve conflicts with overlapping labels, GeoServer will attempt to move the labels such that they are no longer overlapping. Line 20 sets the maximum displacement of the label to be 400 pixels. This sets the label to never bend more than 90 degrees to prevent the label from becoming illegible due to a pronounced curve or angle. Line 19 sets the maximum angle that the label will follow. The only differences are contained in lines 18-21. This example is similar to the previous example, Label following line. On and use other label placement options to ensure that labels are drawn as often as desired and in the correct places. While this setting can be toggled, it is usually a good idea to leave it

This accounts for the reason why many lines don’t have labels in the previous example, GeoServer uses “conflict resolution” to ensure that labels aren’t drawn on top of other labels, obscuring them both. The result is a 3 pixel blue line with a 1 pixel gray border, since the 5 pixel gray line will display 1 pixel on each

Pixels, and line 18 again renders the edges of the line to be rounded instead of flat. Specifies the color of the line to be a medium blue ( #6699FF), line 17 specifies the width of this line to be 3 Lines 12-22 comprise the second, which is the inner line (or “fill”). (When working with bordered lines using a round line cap ensures that the border connects properly at the ends of the lines.) Renders the ends of the line as rounded instead of flat. To be 5 pixels, and in line 7 a stroke-linecap parameter of round Line 5 specifies the color of the line to be dark gray ( #333333), line 6 specifies the width of this line In this example, lines 1-11 comprise the first, which is the outer line (or “stroke”). This ensures that the blue lines are not obscured by the gray lines,Īnd also ensures proper rendering at intersections, so that the blue lines “connect”. GeoServer renders s in the order that they are presented in the SLD.Īre drawn first via the first, followed by the blue center lines in a second Since every line is drawn twice, the order of the rendering is very important. Larger lines everywhere except along the edges of the smaller lines. This gives the illusion of fill and stroke by obscuring the It is, however, possible to achieve this effect by drawing each line twice: once with aĬertain width and again with a slightly smaller width. Thus, unlike points or polygons, it is not possible to style the Lines in SLD have no notion of a “fill”, only “stroke”. For reference, the attribute table for the points in this layer is included below. The lines layer used in the examples below contains road information for aįictional country.
