1

I generated SLD style from QGIS software, and here is my final SLD:

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0"
                       xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"
                       xmlns="http://www.opengis.net/sld"
                       xmlns:sld="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">
  <NamedLayer>
    <Name>google_polygon</Name>
    <UserStyle>
      <Title>'Polygon'</Title>
      <!--TAG-->
      <FeatureTypeStyle>
        <Name>water</Name>
        <Rule>
      <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
        <ogc:Or>
          <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>natural</ogc:PropertyName>
            <ogc:Literal>water</ogc:Literal>
          </ogc:PropertyIsEqualTo>
          <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>waterway</ogc:PropertyName>
            <ogc:Literal>riverbank</ogc:Literal>
          </ogc:PropertyIsEqualTo>
        </ogc:Or>
      </ogc:Filter>
      <PolygonSymbolizer>
        <Fill>
          <CssParameter name="fill">#b6d9ff</CssParameter>
        </Fill>
      </PolygonSymbolizer>
    </Rule>
    <Rule>
      <Name>forest &amp; park</Name>

      <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
        <ogc:Or>
          <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>landuse</ogc:PropertyName>
            <ogc:Literal>forest</ogc:Literal>
          </ogc:PropertyIsEqualTo>
          <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>leisure</ogc:PropertyName>
            <ogc:Literal>park</ogc:Literal>
          </ogc:PropertyIsEqualTo>
        </ogc:Or>
      </ogc:Filter>
      <PolygonSymbolizer>
        <Fill>
          <CssParameter name="fill">#cbdfaa</CssParameter>
        </Fill>
      </PolygonSymbolizer>
    </Rule>

    <Rule>
      <Name>industrial</Name>
      <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
        <ogc:Or>
          <ogc:Not>
            <ogc:PropertyIsNull>
              <ogc:PropertyName>aeroway</ogc:PropertyName>
            </ogc:PropertyIsNull>
          </ogc:Not>
          <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>landuse</ogc:PropertyName>
            <ogc:Literal>industrial</ogc:Literal>
          </ogc:PropertyIsEqualTo>
        </ogc:Or>
      </ogc:Filter>
      <PolygonSymbolizer>
        <Fill>
          <CssParameter name="fill">#e9e6de</CssParameter>
        </Fill>
      </PolygonSymbolizer>
    </Rule>
    <Rule>
      <Name>residential</Name>
      <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
        <ogc:PropertyIsEqualTo>
          <ogc:PropertyName>landuse</ogc:PropertyName>
          <ogc:Literal>residential</ogc:Literal>
        </ogc:PropertyIsEqualTo>
      </ogc:Filter>
      <PolygonSymbolizer>
        <Fill>
          <CssParameter name="fill">#e9e6db</CssParameter>
        </Fill>
      </PolygonSymbolizer>
    </Rule>

    <Rule>
      <Name>building</Name>
      <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
        <ogc:Not>
          <ogc:PropertyIsNull>
            <ogc:PropertyName>building</ogc:PropertyName>
          </ogc:PropertyIsNull>
        </ogc:Not>
      </ogc:Filter>
      <MinScaleDenominator>1</MinScaleDenominator>
      <MaxScaleDenominator>15000</MaxScaleDenominator>
      <PolygonSymbolizer>
        <Fill>
          <CssParameter name="fill">#000000</CssParameter>
          <CssParameter name="fill-opacity">0.12</CssParameter>
        </Fill>
        *<Displacement>
          <DisplacementX>1</DisplacementX>
          <DisplacementY>1</DisplacementY>
        </Displacement>
      </PolygonSymbolizer>
      <PolygonSymbolizer>
        <Fill>
          <CssParameter name="fill">#ffffff</CssParameter>
          <CssParameter name="fill-opacity">0.20</CssParameter>
        </Fill>
        *<Displacement>
          <DisplacementX>-1</DisplacementX>
          <DisplacementY>-1</DisplacementY>
        </Displacement>
      </PolygonSymbolizer>
      <PolygonSymbolizer>
        <Fill>
          <CssParameter name="fill">#dddad4</CssParameter>
        </Fill>
      </PolygonSymbolizer>
    </Rule>
  </FeatureTypeStyle>
</UserStyle>

After validation in Geoserver 2.10.2 this style I got this errors:

line 109: cvc-complex-type.2.4.a: Invalid content was found starting with element 'Displacement'. One of '{"http://www.opengis.net/sld":Stroke}' is expected.

line 119: cvc-complex-type.2.4.a: Invalid content was found starting with element 'Displacement'. One of '{"http://www.opengis.net/sld":Stroke}' is expected.

Lines 109 and 119 I marked in code with '*'.

Can you help me to fix it?

1 Answer 1

3

If you want to offset the polygon, you could remove the displacement bit from the xml and use the offset function in geoserver as follows:

<PolygonSymbolizer>
    <Geometry>
        <ogc:Function name="offset">
            <ogc:PropertyName>the_geom</ogc:PropertyName>
            <ogc:Literal>1</ogc:Literal>
            <ogc:Literal>1</ogc:Literal>
        </ogc:Function>
    </Geometry>        
    <Fill>
        <CssParameter name="fill">#000000</CssParameter>
        <CssParameter name="fill-opacity">0.12</CssParameter>
    </Fill>
</PolygonSymbolizer>

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.