[OpenLayers-Commits] r4750 - in sandbox/ahocevar/sldRenderer/lib/OpenLayers: . Format

commits at openlayers.org commits at openlayers.org
Tue Oct 2 02:43:27 EDT 2007


Author: ahocevar
Date: 2007-10-02 02:43:25 -0400 (Tue, 02 Oct 2007)
New Revision: 4750

Modified:
   sandbox/ahocevar/sldRenderer/lib/OpenLayers/Format/SLD.js
   sandbox/ahocevar/sldRenderer/lib/OpenLayers/Style.js
Log:
fixed parser bug that would assign incorrect values to a style if an attributeName-attributeValue constraint is not found.

Modified: sandbox/ahocevar/sldRenderer/lib/OpenLayers/Format/SLD.js
===================================================================
--- sandbox/ahocevar/sldRenderer/lib/OpenLayers/Format/SLD.js	2007-10-02 04:46:10 UTC (rev 4749)
+++ sandbox/ahocevar/sldRenderer/lib/OpenLayers/Format/SLD.js	2007-10-02 06:43:25 UTC (rev 4750)
@@ -185,7 +185,8 @@
                     style.fillColor = this.parseProperty(fill[0], this.sldns,
                             "CssParameter", "name", "fill");
                     style.fillOpacity = this.parseProperty(fill[0],
-                            this.sldns, "CssParameter", "name", "fill-opacity");
+                            this.sldns, "CssParameter", "name",
+                            "fill-opacity") || 1;
                 }
             
                 // stroke
@@ -196,7 +197,7 @@
                             this.sldns, "CssParameter", "name", "stroke");
                     style.strokeOpacity = this.parseProperty(stroke[0],
                             this.sldns, "CssParameter", "name",
-                            "stroke-opacity");
+                            "stroke-opacity") || 1;
                     style.strokeWidth = this.parseProperty(stroke[0],
                             this.sldns, "CssParameter", "name",
                             "stroke-width");
@@ -373,24 +374,28 @@
                 result = propertyNode.getAttribute(attributeName);                
             }
             
-            // get the property value from the textContent of the first node
-            if (!result) {
+            if (!attributeName) {
+
+                // get the property value from the textContent of the first
+                // node
                 propertyNode = propertyNodeList[0];
                 result = OpenLayers.Util.getXmlNodeValue(propertyNode);
+
+                // get the property value from an ogc:Literal at the level of
+                // the property node.
+                if (!result) {
+                    var result = this.parseProperty(
+                            propertyNode, this.ogcns, "Literal");
+                }
+                
+                // finally, get the property value from an ogc:Literal at the
+                // same level as the xmlNode
+                if (!result) {
+                    var result = this.parseProperty(xmlNode, this.ogcns,
+                            "Literal");
+                }
             }
             
-            // get the property value from an ogc:Literal at the level of
-            // the property node.
-            if (!result) {
-                var result = this.parseProperty(
-                        propertyNode, this.ogcns, "Literal");
-            }
-            
-            // finally, get the property value from an ogc:Literal at the same
-            // level as the xmlNode
-            if (!result) {
-                var result = this.parseProperty(xmlNode, this.ogcns, "Literal");
-            }
         }
         
         // adjust the result to be a trimmed string or a number

Modified: sandbox/ahocevar/sldRenderer/lib/OpenLayers/Style.js
===================================================================
--- sandbox/ahocevar/sldRenderer/lib/OpenLayers/Style.js	2007-10-02 04:46:10 UTC (rev 4749)
+++ sandbox/ahocevar/sldRenderer/lib/OpenLayers/Style.js	2007-10-02 06:43:25 UTC (rev 4750)
@@ -49,6 +49,7 @@
         // simple style with defaults from the SLD spec
         this.defaultStyle = {
             fillColor: "#808080",
+            fillOpacity: 1,
             strokeColor: "#000000",
             strokeOpacity: 1,
             strokeWidth: 1
@@ -116,7 +117,7 @@
                 OpenLayers.Util.extend(style, symbolizer);
             }
         }
-        
+
         return style;
     },
         



More information about the Commits mailing list