0

I want to control the order in which the features are being loaded and drawn on the map with the GeoServer vendor parameter sortBy.

  1. I created a layer from an external WFS i'm not owner. So i'can't create a Z attribute in the data source.

  2. Then, i created succesfully a custom attribute based on this documentation : enter image description here

    if_then_else(equalTo(MU_SHORT_FRE,'BR'),1,2)

Resulting WFS attributes view and datatype in QGIS

enter image description here enter image description here

3.Now, i try to add the (validated parse) sld vendor parameter

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" version="1.1.0" xmlns:se="http://www.opengis.net/se">
  <NamedLayer>
    <se:Name>Gemeentegrenzen</se:Name>
    <UserStyle>
      <se:Name>Gemeentegrenzen</se:Name>
      <se:FeatureTypeStyle>
        <se:Rule>
          <se:Name>BR</se:Name>
          <se:Description>
            <se:Title>BR</se:Title>
          </se:Description>
          <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>MU_SHORT_FRE</ogc:PropertyName>
              <ogc:Literal>BR</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
          <se:PolygonSymbolizer>
            <se:Stroke>
              <se:SvgParameter name="stroke">#ff6283</se:SvgParameter>
              <se:SvgParameter name="stroke-width">3</se:SvgParameter>
              <se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
            </se:Stroke>
          </se:PolygonSymbolizer>
        </se:Rule>
        <se:Rule>
          <se:Name></se:Name>
          <se:ElseFilter xmlns:se="http://www.opengis.net/se"/>
          <se:PolygonSymbolizer>
            <se:Stroke>
              <se:SvgParameter name="stroke">#000000</se:SvgParameter>
              <se:SvgParameter name="stroke-width">1</se:SvgParameter>
              <se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
            </se:Stroke>
          </se:PolygonSymbolizer>
        </se:Rule>
        <se:VendorOption name="sortBy">Z</se:VendorOption>
      </se:FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

I get the following issue as the Z attribute does't exist. (If i write a non existing field name, i get the same issue).

enter image description here

2
  • Does your Z attribute appear if you grab the properties as WFS GML? What is the type?
    – BradHards
    Commented May 3 at 11:20
  • Yes, it's what i show in the post. it's the WFS GML result, i added the datatype.
    – jlSta
    Commented May 3 at 12:10

1 Answer 1

0

I simply sorted the rendering by using two FeatureTypeStyle blocks as explained in the documentation. The Z parameter vendor is only if you want to use one FeatureTypeStyle.

The impossibility to use custom attributes with Z parameter vendor stays open

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" version="1.1.0" xmlns:se="http://www.opengis.net/se">
  <NamedLayer>
    <se:Name>Gemeentegrenzen</se:Name>
    <UserStyle>
      <se:Name>Gemeentegrenzen</se:Name>
      <se:FeatureTypeStyle>
        <se:Rule>
          <se:Name>Else</se:Name>
          <se:Description>
            <se:Title>Others</se:Title>
          </se:Description>
          <se:ElseFilter xmlns:se="http://www.opengis.net/se"/>
          <se:PolygonSymbolizer>
            <se:Stroke>
              <se:SvgParameter name="stroke">#000000</se:SvgParameter>
              <se:SvgParameter name="stroke-width">1</se:SvgParameter>
              <se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
            </se:Stroke>
          </se:PolygonSymbolizer>
        </se:Rule>
      </se:FeatureTypeStyle>
      <se:FeatureTypeStyle>
        <se:Rule>
          <se:Name>BR</se:Name>
          <se:Description>
            <se:Title>Brussels</se:Title>
          </se:Description>
          <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>MU_SHORT_FRE</ogc:PropertyName>
              <ogc:Literal>BR</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
          <se:PolygonSymbolizer>
            <se:Stroke>
              <se:SvgParameter name="stroke">#ff6283</se:SvgParameter>
              <se:SvgParameter name="stroke-width">3</se:SvgParameter>
              <se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
            </se:Stroke>
          </se:PolygonSymbolizer>
        </se:Rule>
      </se:FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

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.