We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I am running this script:
from sld import * sld_doc = StyledLayerDescriptor() # Create Layer nl = sld_doc.create_namedlayer('Drivetime Polygon Style ') us = nl.create_userstyle() us.Title = 'Drivetime' # Create Rule fts = us.create_featuretypestyle() r1 = fts.create_rule('Interval 1', PolygonSymbolizer) # Create Filter f1 = Filter(r1) f1.PropertyIsEqualTo = PropertyCriterion(f1, 'PropertyIsEqualTo') f1.PropertyIsEqualTo.PropertyName = 'drivetime' f1.PropertyIsEqualTo.Literal = 'v1' r1.Filter = f1 content = sld_doc.as_sld(pretty_print=True) print content
And it creates this sld file:
<sld:StyledLayerDescriptor xmlns:sld="http://www.opengis.net/sld" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ogc="http://www.opengis.net/ogc" version="1.0.0"> <sld:NamedLayer> <sld:Name>Drivetime Polygon Style </sld:Name> <sld:UserStyle> <sld:Title>Drivetime</sld:Title> <sld:FeatureTypeStyle> <sld:Rule> <sld:Title>Interval 1</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:PropertyIsEqualTo> <ogc:PropertyName>drivetime</ogc:PropertyName> <ogc:Literal>v1</ogc:Literal> </ogc:PropertyIsEqualTo> </ogc:Filter> </sld:Rule> </sld:FeatureTypeStyle> </sld:UserStyle> </sld:NamedLayer> </sld:StyledLayerDescriptor>
The file is not valid, because the PolygonSymbolizer is before the filter. Is this a bug or am I doing something wrong?
The text was updated successfully, but these errors were encountered:
Hello @ustroetz,
You must 'normalize' the doc before serializing it. You can call the 'normalize' method on the SLD object to perform this re-arrangement.
# Rearranges filters in the order defined by the schema # note: the sld object is modified in place sld_doc.normalize()
In addition, you can check the validity of the sld against the schema with validate, too:
validate
# Validate that an SLD conforms to the schema sld_doc.validate()
Sorry, something went wrong.
Oh cool! Thanks for letting me know dzwarg!
No branches or pull requests
I am running this script:
And it creates this sld file:
The file is not valid, because the PolygonSymbolizer is before the filter. Is this a bug or am I doing something wrong?
The text was updated successfully, but these errors were encountered: