From dfe128244231707869e41aaf5c59479292eb5d8b Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Wed, 24 Dec 2008 00:10:16 +0000 Subject: [PATCH] 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 --- lib/OpenLayers/Format/SLD/v1.js | 4 ++-- tests/Format/SLD/v1_0_0.html | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/OpenLayers/Format/SLD/v1.js b/lib/OpenLayers/Format/SLD/v1.js index 0c9846515c..13fb9dba81 100644 --- a/lib/OpenLayers/Format/SLD/v1.js +++ b/lib/OpenLayers/Format/SLD/v1.js @@ -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; diff --git a/tests/Format/SLD/v1_0_0.html b/tests/Format/SLD/v1_0_0.html index b7725af483..7139b3e32a 100644 --- a/tests/Format/SLD/v1_0_0.html +++ b/tests/Format/SLD/v1_0_0.html @@ -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 = + '' + + 'red' + + '0' + + ''; + t.xml_eq(got, expect, "zero fill opacity written"); } function test_writeTextSymbolizer(t) {