def to_css(self, selector): css = selector + " {\n" if "fillcolor" in self.node.attrib: color = utils.cs_rgb_to_hex(self.node.attrib["fillcolor"]) css += " fill: {0};\n".format(color) if "boundary" in self.node.attrib and self.node.attrib["boundary"] == "true": if "boundarycolor" in self.node.attrib: color = utils.cs_rgb_to_hex(self.node.attrib["boundarycolor"]) css += " stroke: {0};\n".format(color) if "boundarywidth" in self.node.attrib: width = self.node.attrib["boundarywidth"] css += " stroke-width: {0}px;\n".format(width) css += "}\n" return css
def to_sld(self): poly = ET.Element("PolygonSymbolizer") fill = ET.SubElement(poly, "Fill") boundary = ET.SubElement(poly, "Stroke") if "fillcolor" in self.node.attrib: fillcolor = ET.SubElement(fill, "CssParameter") fillcolor.attrib["name"] = "fill" fillcolor.text = utils.cs_rgb_to_hex(self.node.attrib["fillcolor"]) # @TODO: Opacities! if "boundary" in self.node.attrib and self.node.attrib["boundary"] == "true": if "boundarycolor" in self.node.attrib: boundarycolor = ET.SubElement(boundary, "CssParameter") boundarycolor.attrib["name"] = "stroke" boundarycolor.text = utils.cs_rgb_to_hex(self.node.attrib["boundarycolor"]) if "boundarywidth" in self.node.attrib: boundarywidth = ET.SubElement(boundary, "CssParameter") boundarywidth.attrib["name"] = "stroke-width" boundarywidth.text = self.node.attrib["boundarywidth"] # @TODO: Size conversion? return poly
def to_css(self, selector): css = selector + " {\n" if "color" in self.node.attrib: color = utils.cs_rgb_to_hex(self.node.attrib["color"]) css += " stroke: {0};\n".format(color) if "width" in self.node.attrib: width = self.node.attrib["width"] css += " stroke-width: {0}px;\n".format(width) css += " stroke-linecap: round;\n" css += "}\n" return css
def to_sld(self): line = ET.Element("LineSymbolizer") stroke = ET.SubElement(line, "Stroke") if "color" in self.node.attrib: strokecolor = ET.SubElement(stroke, "CssParameter") strokecolor.attrib["name"] = "stroke" strokecolor.text = utils.cs_rgb_to_hex(self.node.attrib["color"]) if "width" in self.node.attrib: strokewidth = ET.SubElement(stroke, "CssParameter") strokewidth.attrib["name"] = "stroke-width" strokewidth.text = self.node.attrib["width"] # @TODO: Size conversion? return line
def to_sld(self): point = ET.Element("PointSymbolizer") graphic = ET.SubElement(point, "Graphic") mark = ET.SubElement(graphic, "Mark") # @TODO: Check empty tag does nothing? if "font" in self.node.attrib and "character" in self.node.attrib: well_known_name = ET.SubElement(mark, "WellKnownName") # {:X} outputs the character code in hex. GeoServer documentation is ambiguous on whether we need to. well_known_name.text = "ttf://{}#0x{:X}".format(self.node.attrib["font"], int(self.node.attrib["character"])) if "fontcolor" in self.node.attrib: fill = ET.SubElement(mark, "Fill") fillcolor = ET.SubElement(fill, "CssParameter") fillcolor.attrib["name"] = "fill" fillcolor.text = utils.cs_rgb_to_hex(self.node.attrib["fontcolor"]) if "fontsize" in self.node.attrib: size = ET.SubElement(graphic, "Size") size.text = self.node.attrib["fontsize"] # @TODO: Size conversion? return point