2

I've used SLD to style two type of roads with the border in GeoServer.

How can I remove the border of a road when another road or street connects to it?

As shown in the image, when roads are in the same layer they are good in conjunction (2) but, roads in different layers are drawn as (1).

enter image description here

This is the simplified code I'm using for styles:

<!--First layer-->
    <se:FeatureTypeStyle>
    <se:Rule>
      <se:Name>Motorway</se:Name>
      <se:Description>
        <se:Title>Motorway</se:Title>
      </se:Description>
      <se:LineSymbolizer>
        <se:Stroke>
          <se:SvgParameter name="stroke">#94622F</se:SvgParameter>
          <se:SvgParameter name="stroke-width">12</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>
    
    <se:FeatureTypeStyle>
    <se:Rule>
      <se:Name>Motorway</se:Name>
      <se:Description>
        <se:Title>Motorway</se:Title>
      </se:Description>
      <se:LineSymbolizer>
        <se:Stroke>
          <se:SvgParameter name="stroke">#F8C967</se:SvgParameter>
          <se:SvgParameter name="stroke-width">11</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>

And the other style:

<!-- Second layer -->
<se:FeatureTypeStyle>
<se:Rule>
  <se:Name>Link</se:Name>
  <se:Description>
    <se:Title>Link</se:Title>
  </se:Description>
  <se:LineSymbolizer>
    <se:Stroke>
      <se:SvgParameter name="stroke">#000000</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:Rule>
</se:FeatureTypeStyle>

<se:FeatureTypeStyle>
<se:Rule>
  <se:Name>Link</se:Name>
  <se:Description>
    <se:Title>Link</se:Title>
  </se:Description>
  <se:LineSymbolizer>
    <se:Stroke>
      <se:SvgParameter name="stroke">#FDFCF8</se:SvgParameter>
      <se:SvgParameter name="stroke-width">4</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>

1 Answer 1

5

The usual way to fix this is to draw all of the casings and then draw the road centres in reverse order of importance.

For example this OS road style:

  <sld:FeatureTypeStyle>
    <sld:Name>name</sld:Name>
    <sld:Rule>
      <sld:Name>Primary Level 1 Case</sld:Name>
      <ogc:Filter>
        <ogc:And>
          <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>level</ogc:PropertyName>
            <ogc:Literal>1</ogc:Literal>
          </ogc:PropertyIsEqualTo>
          <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>type</ogc:PropertyName>
            <ogc:Literal>Primary</ogc:Literal>
          </ogc:PropertyIsEqualTo>
        </ogc:And>
      </ogc:Filter>
      <sld:MinScaleDenominator>1.0</sld:MinScaleDenominator>
      <sld:MaxScaleDenominator>40000.0</sld:MaxScaleDenominator>
      <sld:LineSymbolizer uom="http://www.opengeospatial.org/se/units/metre">
        <sld:Stroke>
          <sld:CssParameter name="stroke">#ebebe0</sld:CssParameter>
          <sld:CssParameter name="stroke-linejoin">round</sld:CssParameter>
          <sld:CssParameter name="stroke-width">21.5</sld:CssParameter>
        </sld:Stroke>
      </sld:LineSymbolizer>
    </sld:Rule>
  </sld:FeatureTypeStyle>
  <sld:FeatureTypeStyle>
    <sld:Name>name</sld:Name>
    <sld:Rule>
      <sld:Name>Motorway Level 1 Case</sld:Name>
      <ogc:Filter>
        <ogc:And>
          <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>level</ogc:PropertyName>
            <ogc:Literal>1</ogc:Literal>
          </ogc:PropertyIsEqualTo>
          <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>type</ogc:PropertyName>
            <ogc:Literal>Motorway</ogc:Literal>
          </ogc:PropertyIsEqualTo>
        </ogc:And>
      </ogc:Filter>
      <sld:MinScaleDenominator>1.0</sld:MinScaleDenominator>
      <sld:MaxScaleDenominator>40000.0</sld:MaxScaleDenominator>
      <sld:LineSymbolizer uom="http://www.opengeospatial.org/se/units/metre">
        <sld:Stroke>
          <sld:CssParameter name="stroke">#ebebe0</sld:CssParameter>
          <sld:CssParameter name="stroke-linejoin">round</sld:CssParameter>
          <sld:CssParameter name="stroke-width">22.5</sld:CssParameter>
        </sld:Stroke>
      </sld:LineSymbolizer>
    </sld:Rule>
  </sld:FeatureTypeStyle>
  <sld:FeatureTypeStyle>
    <sld:Name>name</sld:Name>
    <sld:Rule>
      <sld:Name>Primary Level 1 Fills</sld:Name>
      <ogc:Filter>
        <ogc:And>
          <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>level</ogc:PropertyName>
            <ogc:Literal>1</ogc:Literal>
          </ogc:PropertyIsEqualTo>
          <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>type</ogc:PropertyName>
            <ogc:Literal>Primary</ogc:Literal>
          </ogc:PropertyIsEqualTo>
        </ogc:And>
      </ogc:Filter>
      <sld:MinScaleDenominator>1.0</sld:MinScaleDenominator>
      <sld:MaxScaleDenominator>40000.0</sld:MaxScaleDenominator>
      <sld:LineSymbolizer uom="http://www.opengeospatial.org/se/units/metre">
        <sld:Stroke>
          <sld:CssParameter name="stroke">#77c776</sld:CssParameter>
          <sld:CssParameter name="stroke-linecap">round</sld:CssParameter>
          <sld:CssParameter name="stroke-linejoin">round</sld:CssParameter>
          <sld:CssParameter name="stroke-width">15.5</sld:CssParameter>
        </sld:Stroke>
      </sld:LineSymbolizer>
    </sld:Rule>
  </sld:FeatureTypeStyle>
  <sld:FeatureTypeStyle>
    <sld:Name>name</sld:Name>
    <sld:Rule>
      <sld:Name>Motorway Level 1 Fills</sld:Name>
      <ogc:Filter>
        <ogc:And>
          <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>level</ogc:PropertyName>
            <ogc:Literal>1</ogc:Literal>
          </ogc:PropertyIsEqualTo>
          <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>type</ogc:PropertyName>
            <ogc:Literal>Motorway</ogc:Literal>
          </ogc:PropertyIsEqualTo>
        </ogc:And>
      </ogc:Filter>
      <sld:MinScaleDenominator>1.0</sld:MinScaleDenominator>
      <sld:MaxScaleDenominator>40000.0</sld:MaxScaleDenominator>
      <sld:LineSymbolizer uom="http://www.opengeospatial.org/se/units/metre">
        <sld:Stroke>
          <sld:CssParameter name="stroke">#08b8e8</sld:CssParameter>
          <sld:CssParameter name="stroke-linecap">round</sld:CssParameter>
          <sld:CssParameter name="stroke-linejoin">round</sld:CssParameter>
          <sld:CssParameter name="stroke-width">16.5</sld:CssParameter>
        </sld:Stroke>
      </sld:LineSymbolizer>
    </sld:Rule>
  </sld:FeatureTypeStyle>
4
  • Thanks, Ian. Is it applicable to separated layers in the database which have different SLD style files? Commented Sep 26, 2018 at 8:54
  • No, in that case you will need 4 (or 2*n) layers to do all the casing and then all the centres
    – Ian Turton
    Commented Sep 26, 2018 at 13:02
  • How about applying this to the layers with different z-order in connecting links? I tested it and failed. Commented Oct 13, 2018 at 7:02
  • Try this: docs.geoserver.org/master/en/user/styling/sld/extensions/… Commented Jul 29, 2021 at 7:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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