diff --git a/lib/OpenLayers/Geometry/Collection.js b/lib/OpenLayers/Geometry/Collection.js index d62866ceb7..b5e784187b 100644 --- a/lib/OpenLayers/Geometry/Collection.js +++ b/lib/OpenLayers/Geometry/Collection.js @@ -272,11 +272,15 @@ OpenLayers.Geometry.Collection = OpenLayers.Class(OpenLayers.Geometry, { * will have four times the area). * origin - {} Point of origin for resizing * ratio - {Float} Optional x:y ratio for resizing. Default ratio is 1. + * + * Returns: + * {OpenLayers.Geometry} - The current geometry. */ resize: function(scale, origin, ratio) { for(var i=0; i} Point of origin for resizing * ratio - {Float} Optional x:y ratio for resizing. Default ratio is 1. + * + * Returns: + * {OpenLayers.Geometry} - The current geometry. */ resize: function(scale, origin, ratio) { for(var i=0, len=this.components.length; i} Point of origin for resizing * ratio - {Float} Optional x:y ratio for resizing. Default ratio is 1. + * + * Returns: + * {OpenLayers.Geometry} - The current geometry. */ resize: function(scale, origin, ratio) { ratio = (ratio == undefined) ? 1 : ratio; this.x = origin.x + (scale * ratio * (this.x - origin.x)); this.y = origin.y + (scale * (this.y - origin.y)); this.clearBounds(); + return this; }, /** diff --git a/tests/Geometry/LineString.html b/tests/Geometry/LineString.html index 288f194e04..3dddca09f0 100644 --- a/tests/Geometry/LineString.html +++ b/tests/Geometry/LineString.html @@ -107,7 +107,7 @@ } function test_LineString_resize(t) { - t.plan(7); + t.plan(8); var tolerance = 1e-10; @@ -123,7 +123,8 @@ var scale = 10 * Math.random(); var oldLength = geometry.getLength(); - geometry.resize(scale, origin); + var ret = geometry.resize(scale, origin); + t.ok(ret === geometry, "resize returns geometry"); var newLength = geometry.getLength(); t.ok((((newLength / oldLength) - scale) / scale) < tolerance, "resize correctly changes the length of a linestring") diff --git a/tests/Geometry/Point.html b/tests/Geometry/Point.html index f528feaa78..ed22966289 100644 --- a/tests/Geometry/Point.html +++ b/tests/Geometry/Point.html @@ -132,7 +132,7 @@ } function test_Point_resize(t) { - t.plan(5); + t.plan(6); var tolerance = 1e-10; var x = 100 * Math.random(); @@ -147,9 +147,10 @@ var scale = 10 * Math.random(); var oldDistance = origin.distanceTo(point); - point.resize(scale, origin); + var ret = point.resize(scale, origin); var newDistance = origin.distanceTo(point); + t.ok(ret === point, "resize returns geometry"); t.ok((origin.x == i) && (origin.y == j), "resize leaves the origin untouched"); t.ok((((newDistance / oldDistance) - scale) / scale) < tolerance,