[OpenLayers-Commits] r12014 -
sandbox/tschaub/editing/lib/OpenLayers/Geometry
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Wed May 25 19:36:25 EDT 2011
Author: tschaub
Date: 2011-05-25 16:36:24 -0700 (Wed, 25 May 2011)
New Revision: 12014
Modified:
sandbox/tschaub/editing/lib/OpenLayers/Geometry/Collection.js
sandbox/tschaub/editing/lib/OpenLayers/Geometry/LineString.js
sandbox/tschaub/editing/lib/OpenLayers/Geometry/LinearRing.js
Log:
Adding a useful return when removing components.
Modified: sandbox/tschaub/editing/lib/OpenLayers/Geometry/Collection.js
===================================================================
--- sandbox/tschaub/editing/lib/OpenLayers/Geometry/Collection.js 2011-05-25 21:13:41 UTC (rev 12013)
+++ sandbox/tschaub/editing/lib/OpenLayers/Geometry/Collection.js 2011-05-25 23:36:24 UTC (rev 12014)
@@ -183,14 +183,20 @@
*
* Parameters:
* components - {Array(<OpenLayers.Geometry>)} The components to be removed
+ *
+ * Returns:
+ * {Boolean} A component was removed.
*/
removeComponents: function(components) {
+ var removed = false;
+
if(!(components instanceof Array)) {
components = [components];
}
for(var i=components.length-1; i>=0; --i) {
- this.removeComponent(components[i]);
+ removed = this.removeComponent(components[i]) || removed;
}
+ return removed;
},
/**
@@ -199,6 +205,9 @@
*
* Parameters:
* component - {<OpenLayers.Geometry>}
+ *
+ * Returns:
+ * {Boolean} The component was removed.
*/
removeComponent: function(component) {
@@ -207,6 +216,7 @@
// clearBounds() so that it gets recalculated on the next call
// to this.getBounds();
this.clearBounds();
+ return true;
},
/**
Modified: sandbox/tschaub/editing/lib/OpenLayers/Geometry/LineString.js
===================================================================
--- sandbox/tschaub/editing/lib/OpenLayers/Geometry/LineString.js 2011-05-25 21:13:41 UTC (rev 12013)
+++ sandbox/tschaub/editing/lib/OpenLayers/Geometry/LineString.js 2011-05-25 23:36:24 UTC (rev 12014)
@@ -37,12 +37,17 @@
*
* Parameters:
* point - {<OpenLayers.Geometry.Point>} The point to be removed
+ *
+ * Returns:
+ * {Boolean} The component was removed.
*/
removeComponent: function(point) {
- if ( this.components && (this.components.length > 2)) {
+ var removed = this.components && (this.components.length > 2);
+ if (removed) {
OpenLayers.Geometry.Collection.prototype.removeComponent.apply(this,
arguments);
}
+ return removed;
},
/**
Modified: sandbox/tschaub/editing/lib/OpenLayers/Geometry/LinearRing.js
===================================================================
--- sandbox/tschaub/editing/lib/OpenLayers/Geometry/LinearRing.js 2011-05-25 21:13:41 UTC (rev 12013)
+++ sandbox/tschaub/editing/lib/OpenLayers/Geometry/LinearRing.js 2011-05-25 23:36:24 UTC (rev 12014)
@@ -91,10 +91,13 @@
*
* Parameters:
* point - {<OpenLayers.Geometry.Point>}
+ *
+ * Returns:
+ * {Boolean} The component was removed.
*/
removeComponent: function(point) {
- if (this.components.length > 3) {
-
+ var removed = this.components && (this.components.length > 3);
+ if (removed) {
//remove last point
this.components.pop();
@@ -106,6 +109,7 @@
OpenLayers.Geometry.Collection.prototype.addComponent.apply(this,
[firstPoint]);
}
+ return removed;
},
/**
More information about the Commits
mailing list