[OpenLayers-Commits] r4758 - in sandbox/ahocevar/sldRenderer: examples lib/OpenLayers lib/OpenLayers/Rule tests
commits at openlayers.org
commits at openlayers.org
Tue Oct 2 20:03:45 EDT 2007
Author: ahocevar
Date: 2007-10-02 20:03:43 -0400 (Tue, 02 Oct 2007)
New Revision: 4758
Modified:
sandbox/ahocevar/sldRenderer/examples/gml-layer-sld.html
sandbox/ahocevar/sldRenderer/lib/OpenLayers/Rule.js
sandbox/ahocevar/sldRenderer/lib/OpenLayers/Rule/Comparison.js
sandbox/ahocevar/sldRenderer/lib/OpenLayers/Rule/FeatureId.js
sandbox/ahocevar/sldRenderer/lib/OpenLayers/Rule/Logical.js
sandbox/ahocevar/sldRenderer/lib/OpenLayers/Style.js
sandbox/ahocevar/sldRenderer/tests/list-tests.html
Log:
added basic tests for all new classes. also fixed some invalid destructors and added parent classes to the Rule subclasses properly.
Modified: sandbox/ahocevar/sldRenderer/examples/gml-layer-sld.html
===================================================================
--- sandbox/ahocevar/sldRenderer/examples/gml-layer-sld.html 2007-10-02 21:22:42 UTC (rev 4757)
+++ sandbox/ahocevar/sldRenderer/examples/gml-layer-sld.html 2007-10-03 00:03:43 UTC (rev 4758)
@@ -13,7 +13,7 @@
var lon = 5;
var lat = 40;
var zoom = 5;
- var map, layer;
+ var map, layer, hover;
function load(){
OpenLayers.loadURL("xml/sld.xml", "", null, init);
@@ -34,6 +34,7 @@
if (gmlLayer) {
hover.deactivate();
hover.destroy();
+ map.removeLayer(gmlLayer);
gmlLayer.destroy();
}
gmlLayer = new OpenLayers.Layer.GML("GML", "gml/polygon.xml", {style: sld[styleName]});
Modified: sandbox/ahocevar/sldRenderer/lib/OpenLayers/Rule/Comparison.js
===================================================================
--- sandbox/ahocevar/sldRenderer/lib/OpenLayers/Rule/Comparison.js 2007-10-02 21:22:42 UTC (rev 4757)
+++ sandbox/ahocevar/sldRenderer/lib/OpenLayers/Rule/Comparison.js 2007-10-03 00:03:43 UTC (rev 4758)
@@ -14,7 +14,7 @@
* Inherits from
* - <OpenLayers.Rule>
*/
-OpenLayers.Rule.Comparison = OpenLayers.Class({
+OpenLayers.Rule.Comparison = OpenLayers.Class(OpenLayers.Rule, {
/**
* APIProperty: type
@@ -89,8 +89,7 @@
return this.binaryCompare(feature, this.property, this.value);
case OpenLayers.Rule.Comparison.Type.BETWEEN:
- var result = false;
- result = result &&
+ var result =
feature.attributes[this.property] > this.lowerBoundary;
result = result &&
feature.attributes[this.property] < this.upperBoundary;
Modified: sandbox/ahocevar/sldRenderer/lib/OpenLayers/Rule/FeatureId.js
===================================================================
--- sandbox/ahocevar/sldRenderer/lib/OpenLayers/Rule/FeatureId.js 2007-10-02 21:22:42 UTC (rev 4757)
+++ sandbox/ahocevar/sldRenderer/lib/OpenLayers/Rule/FeatureId.js 2007-10-03 00:03:43 UTC (rev 4758)
@@ -14,7 +14,7 @@
* Inherits from
* - <OpenLayers.Rule>
*/
-OpenLayers.Rule.FeatureId = OpenLayers.Class({
+OpenLayers.Rule.FeatureId = OpenLayers.Class(OpenLayers.Rule, {
/**
* APIProperty: fid
Modified: sandbox/ahocevar/sldRenderer/lib/OpenLayers/Rule/Logical.js
===================================================================
--- sandbox/ahocevar/sldRenderer/lib/OpenLayers/Rule/Logical.js 2007-10-02 21:22:42 UTC (rev 4757)
+++ sandbox/ahocevar/sldRenderer/lib/OpenLayers/Rule/Logical.js 2007-10-03 00:03:43 UTC (rev 4758)
@@ -13,7 +13,7 @@
* Inherits from
* - <OpenLayers.Rule>
*/
-OpenLayers.Rule.Logical = OpenLayers.Class({
+OpenLayers.Rule.Logical = OpenLayers.Class(OpenLayers.Rule, {
/**
* APIProperty: children
@@ -43,6 +43,18 @@
OpenLayers.Rule.prototype.initialize.apply(
this, [options]);
},
+
+ /**
+ * APIMethod: destroy
+ * nullify references to prevent circular references and memory leaks
+ */
+ destroy: function() {
+ for (var i=0; i<this.children.length; i++) {
+ this.children[i].destroy();
+ }
+ this.children = null;
+ OpenLayers.Rule.prototype.destroy.apply(this, arguments);
+ },
/**
* APIMethod: evaluate
Modified: sandbox/ahocevar/sldRenderer/lib/OpenLayers/Rule.js
===================================================================
--- sandbox/ahocevar/sldRenderer/lib/OpenLayers/Rule.js 2007-10-02 21:22:42 UTC (rev 4757)
+++ sandbox/ahocevar/sldRenderer/lib/OpenLayers/Rule.js 2007-10-03 00:03:43 UTC (rev 4758)
@@ -47,9 +47,9 @@
* {<OpenLayers.Rule>}
*/
initialize: function(options) {
+ this.symbolizer = {};
+
OpenLayers.Util.extend(this, options);
-
- this.symbolizer = {};
},
/**
@@ -57,10 +57,10 @@
* nullify references to prevent circular references and memory leaks
*/
destroy: function() {
- for (var i=0; i<children.length; i++) {
- this.children[i].destroy();
+ for (var i in this.symbolizer) {
+ this.symbolizer[i] = null;
}
- this.children = null;
+ this.symbolizer = null;
},
/**
Modified: sandbox/ahocevar/sldRenderer/lib/OpenLayers/Style.js
===================================================================
--- sandbox/ahocevar/sldRenderer/lib/OpenLayers/Style.js 2007-10-02 21:22:42 UTC (rev 4757)
+++ sandbox/ahocevar/sldRenderer/lib/OpenLayers/Style.js 2007-10-03 00:03:43 UTC (rev 4758)
@@ -46,6 +46,8 @@
* {<OpenLayers.Style>}
*/
initialize: function(options) {
+ this.rules = [];
+
// simple style with defaults from the SLD spec
this.defaultStyle = {
fillColor: "#808080",
@@ -60,8 +62,6 @@
OpenLayers.Feature.Vector.style["select"]);
OpenLayers.Util.extend(this, options);
-
- this.rules = [];
},
/**
@@ -69,11 +69,13 @@
* nullify references to prevent circular references and memory leaks
*/
destroy: function() {
- for (var i=0; i<rules.length; i++) {
- this.rules[i].symbolizer = null;
+ for (var i=0; i<this.rules.length; i++) {
+ this.rules[i].destroy();
this.rules[i] = null;
}
this.rules = null;
+ this.defaultStyle = null;
+ this.defaultSelectStyle = null;
},
/**
Modified: sandbox/ahocevar/sldRenderer/tests/list-tests.html
===================================================================
--- sandbox/ahocevar/sldRenderer/tests/list-tests.html 2007-10-02 21:22:42 UTC (rev 4757)
+++ sandbox/ahocevar/sldRenderer/tests/list-tests.html 2007-10-03 00:03:43 UTC (rev 4758)
@@ -35,6 +35,11 @@
<li>Popup/test_Anchored.html</li>
<li>test_Feature.html</li>
<li>Feature/test_Vector.html</li>
+ <li>test_Style.html</li>
+ <li>test_Rule.html</li>
+ <li>Rule/test_FeatureId.html</li>
+ <li>Rule/test_Logical.html</li>
+ <li>Rule/test_Comparison.html</li>
<li>test_Events.html</li>
<li>test_Util.html</li>
<li>test_Layer.html</li>
More information about the Commits
mailing list