3

I've published some shapefiles including line features using GeoServer and styled them with simple stroke and label. To apply a thin border around the roads, I've used another 'FeatureTypeStyle' according to the border section of SLD cookbook as follow:

<!-- border -->
<se:FeatureTypeStyle>
    <se:Rule> 
      <se:LineSymbolizer>
        <se:Stroke>
          <se:SvgParameter name="stroke">#d9d5cd</se:SvgParameter>
          <se:SvgParameter name="stroke-width">7</se:SvgParameter>
          <se:SvgParameter name="stroke-linejoin">round</se:SvgParameter>
          <se:SvgParameter name="stroke-linecap">round</se:SvgParameter>
        </se:Stroke>
      </se:LineSymbolizer>
    </se:Rule>
</se:FeatureTypeStyle>
<!-- line -->
<se:FeatureTypeStyle>
    <se:Rule>
      <se:LineSymbolizer>
        <se:Stroke>
          <se:SvgParameter name="stroke">#F5F1E6</se:SvgParameter>
          <se:SvgParameter name="stroke-width">5</se:SvgParameter>
          <se:SvgParameter name="stroke-linejoin">round</se:SvgParameter>
          <se:SvgParameter name="stroke-linecap">round</se:SvgParameter>
        </se:Stroke>
      </se:LineSymbolizer>
      <se:TextSymbolizer>
        <se:Label>
          <ogc:PropertyName>name</ogc:PropertyName>
        </se:Label>
        <se:LabelPlacement>
          <se:LinePlacement>
            <se:PerpendicularOffset> 0 </se:PerpendicularOffset>
          </se:LinePlacement>
        </se:LabelPlacement>
        <se:Fill>
          <se:SvgParameter name="fill">#523735</se:SvgParameter>
        </se:Fill>
        <se:VendorOption name="followLine">true</se:VendorOption>
        <se:VendorOption name="maxAngleDelta">90</se:VendorOption>
      </se:TextSymbolizer>
    </se:Rule>
</se:FeatureTypeStyle>

When I applied line border, the rendering time of WMS tiles increase in comparison with simple lines situation. How can I achive an optimal rendering performance?

3

To draw roads with a border (or casing) will always take (nearly) twice as long as to draw a road with a single line. Simply, because the renderer has to draw each line twice (there are some speed ups from caching which is why it is not exactly twice).

To avoid this slow down being annoying for your users you should use a scale dependency to prevent too many roads being drawn at any one time.

3

When I tried to validate your code in my GeoServer, I've got a series of parsing errors that guided me in writing a completely valid code.

As can be seen from the link that you've just indicated, your code should be written properly, following the recommendations of the manual.

The corrected, fully functional code is the following:

 <?xml version="1.0" encoding="UTF-8"?>
 <StyledLayerDescriptor version="1.0.0" 
 xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" 
 xmlns="http://www.opengis.net/sld" 
 xmlns:ogc="http://www.opengis.net/ogc" 
 xmlns:xlink="http://www.w3.org/1999/xlink" 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <!-- a Named Layer is the basic building block of an SLD document -->
  <NamedLayer>
    <Name>line_test_style</Name>
    <UserStyle>
    <!-- Styles can have names, titles and abstracts -->
      <Title>Line_Test_Style</Title>
      <Abstract>A sample style that draws a line</Abstract>
      <!-- FeatureTypeStyles describe how to render different features -->
      <!-- A FeatureTypeStyle for rendering lines -->
<!-- border -->
<FeatureTypeStyle>
    <Rule> 
      <LineSymbolizer>
        <Stroke>
          <CssParameter name="stroke">#d9d5cd</CssParameter>
          <CssParameter name="stroke-width">7</CssParameter>
          <CssParameter name="stroke-linejoin">round</CssParameter>
          <CssParameter name="stroke-linecap">round</CssParameter>
        </Stroke>
      </LineSymbolizer>
    </Rule>
</FeatureTypeStyle>
<!-- line -->
<FeatureTypeStyle>
    <Rule>
      <LineSymbolizer>
        <Stroke>
          <CssParameter name="stroke">#F5F1E6</CssParameter>
          <CssParameter name="stroke-width">5</CssParameter>
          <CssParameter name="stroke-linejoin">round</CssParameter>
          <CssParameter name="stroke-linecap">round</CssParameter>
        </Stroke>
      </LineSymbolizer>
      <TextSymbolizer>
        <Label>
          <ogc:PropertyName>name</ogc:PropertyName>
        </Label>
        <LabelPlacement>
          <LinePlacement>
            <PerpendicularOffset> 0 </PerpendicularOffset>
          </LinePlacement>
        </LabelPlacement>
        <Fill>
          <CssParameter name="fill">#523735</CssParameter>
        </Fill>
        <VendorOption name="followLine">true</VendorOption>
        <VendorOption name="maxAngleDelta">90</VendorOption>
      </TextSymbolizer>
    </Rule>
</FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

Keep in mind, according to the manual, a correct style must contain the SLD header and footer information.

In the following image you can see the style you defined, after I have applied it to one of my layers. Although the style you defined is more elaborate than the default one, I haven't noticed annoying rendering delays on my system.

enter image description here

  • Thanks but I clipped the border part from the whole document. – nasser tahani Sep 20 '18 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.