0

I've created SLD style for GeoServer and send it to GeoServer. But after sending GeoServer change it to another SLD. It is source SLD I send

<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:gml="http://www.opengis.net/gml"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <NamedLayer>
        <Name>test</Name>
        <UserStyle>
            <Title>test</Title>
            <FeatureTypeStyle>
                <Rule>
                    <Name>www</Name>
                    <PolygonSymbolizer>
                        <Fill>
                            <CssParameter name="fill">#ff0000</CssParameter>
                            <CssParameter name="fill-opacity">1</CssParameter>
                        </Fill>
                        <Stroke>
                            <CssParameter name="stroke">#000000</CssParameter>
                            <CssParameter name="stroke-width">1</CssParameter>
                        </Stroke>
                    </PolygonSymbolizer>
                    <ogc:Filter>
                        <Within>
                            <ogc:PropertyName>the_geom</ogc:PropertyName>
                            <ogc:Literal>
                                <gml:Polygon gml:id="polygon.1" gml:srsName="http://www.opengis.net/def/crs/EPSG/0/26713">
                                    <gml:exterior>
                                        <gml:LinearRing>
                                            <gml:posList>51.443481,32.625497,51.443481,32.971804,52.146606,32.971804,52.146606,32.625497,51.443481,32.625497</gml:posList>
                                        </gml:LinearRing>
                                    </gml:exterior>
                                </gml:Polygon>
                            </ogc:Literal>
                        </Within>
                    </ogc:Filter>
                </Rule>
            </FeatureTypeStyle>
        </UserStyle>
    </NamedLayer>
</StyledLayerDescriptor>

and it is when GeoServer generate

<?xml version="1.0" encoding="UTF-8"?><sld:StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:sld="http://www.opengis.net/sld" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" version="1.0.0">
  <sld:NamedLayer>
    <sld:Name>Default Styler</sld:Name>
    <sld:UserStyle>
      <sld:Name>Default Styler</sld:Name>
      <sld:Title>test</sld:Title>
      <sld:FeatureTypeStyle>
        <sld:Name>name</sld:Name>
        <sld:Rule>
          <sld:Name>www</sld:Name>
          <ogc:Filter>
            <ogc:Within>
              <ogc:PropertyName>the_geom</ogc:PropertyName>
              <gml:Polygon>
                <gml:outerBoundaryIs>
                  <gml:LinearRing>
                    <gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" "/>
                  </gml:LinearRing>
                </gml:outerBoundaryIs>
              </gml:Polygon>
            </ogc:Within>
          </ogc:Filter>
          <sld:PolygonSymbolizer>
            <sld:Fill>
              <sld:CssParameter name="fill">#ff0000</sld:CssParameter>
            </sld:Fill>
            <sld:Stroke/>
          </sld:PolygonSymbolizer>
        </sld:Rule>
      </sld:FeatureTypeStyle>
    </sld:UserStyle>
  </sld:NamedLayer>
</sld:StyledLayerDescriptor>

What is the problem and what format should I use to filter SLD by polygon coordinates?

1 Answer 1

1

There are at least two problems with your input SLD:

  1. You have told the parser that you are using GML 2 but are passing in GML 3 so GeoServer is ignoring the bits that it doesn't expect. So you should send a Polygon like:

           <gml:Polygon>
             <gml:outerBoundaryIs>
               <gml:LinearRing>
                 <gml:coordinates  decimal="." cs="," ts=" ">
                    51.443481,32.625497 51.443481,32.971804 52.146606,32.971804 52.146606,32.625497 51.443481,32.625497
                 </gml:coordinates>
               </gml:LinearRing>
             </gml:outerBoundaryIs>
           </gml:Polygon>
    
  2. The Filter element should come before the Symbolizer the order of the elements is fixed in the SLD standard and the XML schema. But GeoServer is relaxed about reading that so it less of a problem.

And if you are sticking with GML3 then the PosList should not have commas between the values.

2
  • tnx bro . how do u understand it's gml2 or gml3?
    – hamed
    Jul 31, 2021 at 14:24
  • Because the standard specifies which one to use and that form of a polygon changed between them.
    – Ian Turton
    Jul 31, 2021 at 16:47

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.