0

I am trying to fill polygons with a random patterns of dots or circles but nothing is working. I followed the example given in the link below but my GeoServer (version 2.20.2) gives me an error when validating the SLD and complains about the location of VendorOptions.

Here is the validation error that I get for the lower example in the link below: Invalid content was found starting with element '{"http://www.opengis.net/sld":VendorOption}'. One of '{"http://www.opengis.net/sld":Stroke}' is expected. If I add in <Stroke/> I get this error: Invalid content was found starting with element 'sld:VendorOption'. No child element is expected at this point. https://docs.geoserver.org/stable/en/user/styling/sld/extensions/randomized.html

Can it be that this is a bug?

Here is one version of what I tried, I don´t get any validation errors with this, but it seems GeoServer is not reading the vendor options.

    <?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">
  <NamedLayer>
    <Name>name</Name>
    <UserStyle>
      <Title>title</Title>
      <FeatureTypeStyle>
        <Rule>
          <PolygonSymbolizer>
            <Fill>
                <GraphicFill>
                    <Graphic>
                        <Mark>
                            <WellKnownName>ttf://Tahoma#U+002E</WellKnownName>
                                <Fill>
                                    <CssParameter name="fill">#000000</CssParameter>
                                </Fill>
                            <Stroke/>
                        </Mark>
                        <Size>10</Size>
                    </Graphic>
                </GraphicFill>
            </Fill>
            <Stroke/>
           </PolygonSymbolizer>        
        </Rule>
         <VendorOption name="random">grid</VendorOption>
         <VendorOption name="random-tile-size">100</VendorOption>
         <VendorOption name="random-symbol-count">50</VendorOption>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

1 Answer 1

1

A quick check of the manual shows that the VendorOptions go between the end of the Fill and the PolygonSymbolizer end.

 <sld:PolygonSymbolizer>
  <sld:Fill>
    <sld:GraphicFill>
      <sld:Graphic>
        <sld:Mark>
          <sld:WellKnownName>shape://slash</sld:WellKnownName>
          <sld:Stroke>
            <sld:CssParameter name="stroke">#0000ff</sld:CssParameter>
            <sld:CssParameter name="stroke-linecap">round</sld:CssParameter>
            <sld:CssParameter name="stroke-width">4</sld:CssParameter>
          </sld:Stroke>
        </sld:Mark>
        <sld:Size>8</sld:Size>
      </sld:Graphic>
    </sld:GraphicFill>
  </sld:Fill>
  <sld:VendorOption name="random-seed">5</sld:VendorOption>
  <sld:VendorOption name="random">grid</sld:VendorOption>
  <sld:VendorOption name="random-tile-size">100</sld:VendorOption>
  <sld:VendorOption name="random-rotation">free</sld:VendorOption>
  <sld:VendorOption name="random-symbol-count">50</sld:VendorOption>
</sld:PolygonSymbolizer>
3
  • Putting 'VendorOptions' between 'Fill' and 'PolygonSymbolizer' gives me a validation error. Can this be a bug?
    – user28386
    Nov 18, 2022 at 12:59
  • No it just means that those vendorOptions are not part of the standard and no one has updated our schema to reflect their existence. Feel free to submit a patch to update it if this is important to you.
    – Ian Turton
    Nov 18, 2022 at 18:17
  • Thank you, I will do that :)
    – user28386
    Nov 21, 2022 at 10:33

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.