Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

as_sld function #15

Open
mkeller3 opened this issue Jan 11, 2019 · 1 comment
Open

as_sld function #15

mkeller3 opened this issue Jan 11, 2019 · 1 comment

Comments

@mkeller3
Copy link

When I go to print my sld out my filter ends up below my symbolizer. Is there any way to avoid since this violates sld styling policies? Here is my code.

mysld = sld.StyledLayerDescriptor()
nl = mysld.create_namedlayer('test')
ustyle = nl.create_userstyle()
fts = ustyle.create_featuretypestyle()
firstRule = fts.create_rule('test',sld.PolygonSymbolizer)
firstRule.create_filter('value', '>', 'T')
print mysld.as_sld(pretty_print=True)

@dzwarg
Copy link
Contributor

dzwarg commented Feb 17, 2021

Hello @mkeller3,

Here's the SLD that your code generates:

<sld:StyledLayerDescriptor xmlns:ogc="http://www.opengis.net/ogc" xmlns:sld="http://www.opengis.net/sld" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0.0">
  <sld:NamedLayer>
    <sld:Name>test</sld:Name>
    <sld:UserStyle>
      <sld:FeatureTypeStyle>
        <sld:Rule>
          <sld:Title>test</sld:Title>
          <sld:PolygonSymbolizer>
            <sld:Fill>
              <sld:CssParameter name="fill">#AAAAAA</sld:CssParameter>
            </sld:Fill>
            <sld:Stroke>
              <sld:CssParameter name="stroke">#000000</sld:CssParameter>
              <sld:CssParameter name="stroke-width">1</sld:CssParameter>
            </sld:Stroke>
          </sld:PolygonSymbolizer>
          <ogc:Filter>
            <ogc:PropertyIsGreaterThan>
              <ogc:PropertyName>value</ogc:PropertyName>
              <ogc:Literal>T</ogc:Literal>
            </ogc:PropertyIsGreaterThan>
          </ogc:Filter>
        </sld:Rule>
      </sld:FeatureTypeStyle>
    </sld:UserStyle>
  </sld:NamedLayer>
</sld:StyledLayerDescriptor>

According to https://docs.geoserver.org/stable/en/user/styling/sld/reference/rules.html, both <ogc:Filter> and <sld:PolygonSymbolizer> elements are direct descendants of <Rule>, so this is conformant. Let me know if you are still running into issues with this library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants