[OpenLayers-Commits] r5130 - sandbox/ahocevar/sldRenderer/lib/OpenLayers/Format
commits at openlayers.org
commits at openlayers.org
Tue Nov 6 15:35:12 EST 2007
Author: ahocevar
Date: 2007-11-06 15:35:10 -0500 (Tue, 06 Nov 2007)
New Revision: 5130
Modified:
sandbox/ahocevar/sldRenderer/lib/OpenLayers/Format/SLD.js
Log:
code cleanup
Modified: sandbox/ahocevar/sldRenderer/lib/OpenLayers/Format/SLD.js
===================================================================
--- sandbox/ahocevar/sldRenderer/lib/OpenLayers/Format/SLD.js 2007-11-06 20:14:26 UTC (rev 5129)
+++ sandbox/ahocevar/sldRenderer/lib/OpenLayers/Format/SLD.js 2007-11-06 20:35:10 UTC (rev 5130)
@@ -385,33 +385,32 @@
}
// get the property value from the node matching attributeName
- // and attributeValue
+ // and attributeValue, eg.:
+ // <CssParameter name="stroke">
+ // <ogc:Literal>red</ogc:Literal>
+ // </CssParameter>
+ // or:
+ // <CssParameter name="stroke">red</CssParameter>
if (attributeName && attributeValue) {
propertyNode = this.getNodeWithAttribute(propertyNodeList,
attributeName, attributeValue);
- result = this.parsePropertyNameAndLiteral(propertyNode);
+ result = this.parseParameter(propertyNode);
}
- // get the attribute value and use it as result
+ // get the attribute value and use it as result, eg.:
+ // <sld:OnlineResource xlink:href="../img/marker.png"/>
if (attributeName && !attributeValue) {
var propertyNode = this.getNodeWithAttribute(propertyNodeList,
attributeName);
result = propertyNode.getAttribute(attributeName);
}
+ // get the property value directly or from an ogc:propertyName,
+ // ogc:Literal or any other property at the level of the property
+ // node, eg.:
+ // <sld:Opacity>0.5</sld:Opacity>
if (!attributeName) {
-
- // get the property value directly or from an ogc:propertyName
- // or ogc:Literal at the level of the property node.
- var result = propertyNode.firstChild ?
- propertyNode.firstChild.nodeValue :
- this.parsePropertyNameAndLiteral(propertyNode);
-
- // finally, get the property value from an ogc:propertyName
- // or ogc:Literal at the same level as the xmlNode
- if (!result) {
- var result = this.parsePropertyNameAndLiteral(xmlNode);
- }
+ var result = this.parseParameter(propertyNode);
}
}
@@ -427,9 +426,9 @@
},
/**
- * Method: parsePropertyNameAndLiteral
- * parses a property for propertyNames and Literals and creates the
- * according value string.
+ * Method: parseParameter
+ * parses a property for propertyNames, Literals and textContent and
+ * creates the according value string.
*
* Parameters:
* xmlNode - {<DOMElement>}
@@ -437,7 +436,7 @@
* Returns:
* {String} a string holding a value suitable for OpenLayers.Style.value
*/
- parsePropertyNameAndLiteral: function(xmlNode) {
+ parseParameter: function(xmlNode) {
if (!xmlNode) {
return null;
}
@@ -446,13 +445,16 @@
return null;
}
- var value = [];
+ var value = new Array(childNodes.length);
for (var i=0; i<childNodes.length; i++) {
if (childNodes[i].nodeName.indexOf("Literal") != -1) {
- value.push(this.getChildValue(childNodes[i]));
+ value[i] = this.getChildValue(childNodes[i]);
} else
if (childNodes[i].nodeName.indexOf("propertyName") != -1) {
- value.push("${"+this.getChildValue(childNodes[i])+"}");
+ value[i] = "${" + this.getChildValue(childNodes[i]) + "}";
+ } else
+ if (childNodes[i].nodeType == 3) {
+ value[i] = childNodes[i].text || childNodes[i].textContent;
}
}
return value.join("");
More information about the Commits
mailing list