Allowing zero fill opacity to be written in SLD docs. The SLD format deserves a bit more of an overhaul (given changes to OL.Format.XML), and we've got decent changes sitting around in various sandboxes, but this is a simple fix for a small problem. r=ahocevar (closes #1884)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@8549 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2008-12-24 00:10:16 +00:00
parent 1161049ed5
commit dfe1282442
2 changed files with 16 additions and 3 deletions

View File

@@ -686,7 +686,7 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
{symbolizer: symbolizer, key: "fillColor"}
);
}
if(symbolizer.fillOpacity) {
if(symbolizer.fillOpacity != null) {
this.writeNode(
node, "CssParameter",
{symbolizer: symbolizer, key: "fillOpacity"}
@@ -890,7 +890,7 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
if(options.attributes) {
this.setAttributes(node, options.attributes);
}
if(options.value) {
if(options.value != null) {
node.appendChild(this.createTextNode(options.value));
}
return node;

View File

@@ -138,7 +138,7 @@
}
function test_write(t) {
t.plan(1);
t.plan(2);
// read first - testing that write produces the SLD aboce
var parser = new OpenLayers.Format.SLD.v1_0_0();
@@ -148,6 +148,19 @@
var node = parser.write(obj);
t.xml_eq(node, sld, "SLD correctly written");
// test that 0 fill opacity gets written
var symbolizer = {
fillColor: "red",
fillOpacity: 0
};
var root = parser.createElementNSPlus("PolygonSymbolizer");
var got = parser.writeNode(root, "Fill", symbolizer);
var expect =
'<Fill xmlns="http://www.opengis.net/sld">' +
'<CssParameter name="fill">red</CssParameter>' +
'<CssParameter name="fill-opacity">0</CssParameter>' +
'</Fill>';
t.xml_eq(got, expect, "zero fill opacity written");
}
function test_writeTextSymbolizer(t) {