[OpenLayers-Commits] r5105 - in sandbox/ahocevar/sldRenderer/lib/OpenLayers: . Rule
commits at openlayers.org
commits at openlayers.org
Sat Nov 3 07:54:56 EDT 2007
Author: ahocevar
Date: 2007-11-03 07:54:53 -0400 (Sat, 03 Nov 2007)
New Revision: 5105
Modified:
sandbox/ahocevar/sldRenderer/lib/OpenLayers/Rule/Comparison.js
sandbox/ahocevar/sldRenderer/lib/OpenLayers/Style.js
Log:
changes to make styles and rules also work for non-vector features
Modified: sandbox/ahocevar/sldRenderer/lib/OpenLayers/Rule/Comparison.js
===================================================================
--- sandbox/ahocevar/sldRenderer/lib/OpenLayers/Rule/Comparison.js 2007-11-02 18:17:29 UTC (rev 5104)
+++ sandbox/ahocevar/sldRenderer/lib/OpenLayers/Rule/Comparison.js 2007-11-03 11:54:53 UTC (rev 5105)
@@ -80,6 +80,7 @@
* {boolean} true if the rule applies, false if it does not
*/
evaluate: function(feature) {
+ var attributes = feature.attributes || feature.data;
switch(this.type) {
case OpenLayers.Rule.Comparison.Type.EQUAL_TO:
case OpenLayers.Rule.Comparison.Type.LESS_THAN:
@@ -90,13 +91,13 @@
case OpenLayers.Rule.Comparison.Type.BETWEEN:
var result =
- feature.attributes[this.property] > this.lowerBoundary;
+ attributes[this.property] > this.lowerBoundary;
result = result &&
- feature.attributes[this.property] < this.upperBoundary;
+ attributes[this.property] < this.upperBoundary;
return result;
case OpenLayers.Rule.Comparison.Type.LIKE:
var regexp = new RegExp(this.value, "gi");
- return regexp.test(feature.attributes[this.property]);
+ return regexp.test(attributes[this.property]);
}
},
@@ -143,19 +144,20 @@
* {boolean}
*/
binaryCompare: function(feature, property, value) {
+ var attributes = feature.attributes || feature.data;
switch (this.type) {
case OpenLayers.Rule.Comparison.Type.EQUAL_TO:
- return feature.attributes[property] == value;
+ return attributes[property] == value;
case OpenLayers.Rule.Comparison.Type.NOT_EQUAL_TO:
- return feature.attributes[property] != value;
+ return attributes[property] != value;
case OpenLayers.Rule.Comparison.Type.LESS_THAN:
- return feature.attributes[property] < value;
+ return attributes[property] < value;
case OpenLayers.Rule.Comparison.Type.GREATER_THAN:
- return feature.attributes[property] > value;
+ return attributes[property] > value;
case OpenLayers.Rule.Comparison.Type.LESS_THAN_OR_EQUAL_TO:
- return feature.attributes[property] <= value;
+ return attributes[property] <= value;
case OpenLayers.Rule.Comparison.Type.GREATER_THAN_OR_EQUAL_TO:
- return feature.attributes[property] >= value;
+ return attributes[property] >= value;
}
},
Modified: sandbox/ahocevar/sldRenderer/lib/OpenLayers/Style.js
===================================================================
--- sandbox/ahocevar/sldRenderer/lib/OpenLayers/Style.js 2007-11-02 18:17:29 UTC (rev 5104)
+++ sandbox/ahocevar/sldRenderer/lib/OpenLayers/Style.js 2007-11-03 11:54:53 UTC (rev 5105)
@@ -34,7 +34,7 @@
/**
* APIProperty: rules
- * {Array(<OpenLayers.Rule>}
+ * Array({<OpenLayers.Rule>})
*/
rules: null,
@@ -132,9 +132,12 @@
draw = draw && (scale < this.rules[i].maxScaleDenominator);
}
+ // determine which symbolizer (Point, Line, Polygon) to use
+ var symbolizerPrefix = feature.geometry ?
+ this.getSymbolizerPrefix(feature.geometry) :
+ OpenLayers.Style.SYMBOLIZER_PREFIXES[0];
+
// now merge the style with the current style
- var symbolizerPrefix =
- this.getSymbolizerPrefix(feature.geometry);
var symbolizer = this.rules[i].symbolizer[symbolizerPrefix];
OpenLayers.Util.extend(style, symbolizer);
}
More information about the Commits
mailing list