Skip to content

Instantly share code, notes, and snippets.

@raprasad
Last active March 27, 2017 18:57
Show Gist options
  • Select an option

  • Save raprasad/20c63dd2c0ebb8f2f889aabd97fce613 to your computer and use it in GitHub Desktop.

Select an option

Save raprasad/20c63dd2c0ebb8f2f889aabd97fce613 to your computer and use it in GitHub Desktop.
add polygon stroke
  • Update contrib/datavere_styles/style_rules_formatter.py

In def format_sld_xml(...), add the following after the line:

  • Existing line
        self.formatted_sld_xml = remove_whitespace_from_xml(xml_str)
  • With new lines
        # In format_sld_xml, add:

        # For polgyons, add a stroke color.
        # If this isn't a polygon, the sld wil be returned unchanged
        #
        xml_str = self.add_polygon_stroke(xml_str)

        self.formatted_sld_xml = remove_whitespace_from_xml(xml_str)

Add new method

def add_polygon_stroke(self, sld_xml_str):
        """
        The default stroke (for polygons) is:  <Stroke/>
        Update it to a lighter color.
        (If <Stroke/> isn't found, return the sld_xml_str as is)
        """
        if sld_xml_str is None:
            return None

        stroke_color = '#ececec'

        no_stroke = '<sld:Stroke/>'
        default_stroke = ('<sld:Stroke>'
                          '<sld:CssParameter name="stroke">%s</sld:CssParameter>'
                          '<sld:CssParameter name="stroke-width">0.75</sld:CssParameter>'
                          '</sld:Stroke>') % stroke_color

        return sld_xml_str.replace(no_stroke, default_stroke)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment