[OpenLayers-Commits] r5138 - sandbox/ahocevar/sldRenderer/lib/OpenLayers
commits at openlayers.org
commits at openlayers.org
Wed Nov 7 05:01:43 EST 2007
Author: ahocevar
Date: 2007-11-07 05:01:43 -0500 (Wed, 07 Nov 2007)
New Revision: 5138
Modified:
sandbox/ahocevar/sldRenderer/lib/OpenLayers/Style.js
Log:
added cache for properties that need to be parsed for propertyNames. This costs more on the first call of createStyle, but prevents looping through all properties on subsequent calls.
Modified: sandbox/ahocevar/sldRenderer/lib/OpenLayers/Style.js
===================================================================
--- sandbox/ahocevar/sldRenderer/lib/OpenLayers/Style.js 2007-11-07 08:39:47 UTC (rev 5137)
+++ sandbox/ahocevar/sldRenderer/lib/OpenLayers/Style.js 2007-11-07 10:01:43 UTC (rev 5138)
@@ -52,6 +52,13 @@
*/
defaultSelectStyle: null,
+ /**
+ * Property: propertyStyles
+ * {Hash of Boolean} cache of style properties that need to be parsed for
+ * propertyNames. Property names are keys, values won't be used.
+ */
+ propertyStyles: null,
+
/**
* Constructor: OpenLayers.Style
@@ -145,7 +152,30 @@
style.hidden = !draw;
- for (var i in style) {
+ // create cache of style properties that need to be parsed for
+ // propertyNames. Will only be done on the first call of createStyle.
+ if (!this.propertyStyles) {
+ this.propertyStyles = {};
+ // walk through all rules to check for properties in their
+ // symbolizer
+ var r, s;
+ for (var i in (r = style.rules)) {
+ for (var j in (s = r[i].symbolizer[symbolizerPrefix])) {
+ if (typeof s[j] == "string" && s[j].match(/\$\{\w+\}/)) {
+ this.propertyStyles[j] = true;
+ }
+ }
+ }
+ for (var i in baseStyle) {
+ if (typeof baseStyle[i] == "string" &&
+ baseStyle[i].match(/\$\{\w+\}/)) {
+ this.propertyStyles[i] = true;
+ }
+ }
+ }
+
+ // calculate literals for all styles in the propertyStyles cache
+ for (var i in this.propertyStyles) {
style[i] = OpenLayers.Style.createLiteral(style[i], feature);
}
More information about the Commits
mailing list