diff --git a/lib/OpenLayers/Geometry/Point.js b/lib/OpenLayers/Geometry/Point.js index a79ae32065..917251a462 100644 --- a/lib/OpenLayers/Geometry/Point.js +++ b/lib/OpenLayers/Geometry/Point.js @@ -128,6 +128,7 @@ OpenLayers.Geometry.Point = OpenLayers.Class(OpenLayers.Geometry, { move: function(x, y) { this.x = this.x + x; this.y = this.y + y; + this.clearBounds(); }, /** @@ -144,6 +145,7 @@ OpenLayers.Geometry.Point = OpenLayers.Class(OpenLayers.Geometry, { var theta = angle + Math.atan2(this.y - origin.y, this.x - origin.x); this.x = origin.x + (radius * Math.cos(theta)); this.y = origin.y + (radius * Math.sin(theta)); + this.clearBounds(); }, /** @@ -160,7 +162,9 @@ OpenLayers.Geometry.Point = OpenLayers.Class(OpenLayers.Geometry, { */ resize: function(scale, origin) { this.x = origin.x + (scale * (this.x - origin.x)); + this.y = origin.y + (scale * (this.y - origin.y)); + this.clearBounds(); }, CLASS_NAME: "OpenLayers.Geometry.Point" diff --git a/tests/Geometry/test_Point.html b/tests/Geometry/test_Point.html index 1be5ae439a..3655dcee9e 100644 --- a/tests/Geometry/test_Point.html +++ b/tests/Geometry/test_Point.html @@ -65,7 +65,7 @@ } function test_06_Point_move(t) { - t.plan(2); + t.plan(3); var x = 10; var y = 20; @@ -76,10 +76,12 @@ point.move(dx, dy); t.eq(point.x, x + dx, "move() correctly modifies x"); t.eq(point.y, y + dy, "move() correctly modifies y"); + + t.ok(point.bounds == null, "bounds is cleared after a move()"); } function test_Point_rotate(t) { - t.plan(4); + t.plan(5); var tolerance = 1e-10; var x = 10; @@ -92,23 +94,26 @@ t.ok(((point.x - x) / x) < tolerance, "rotate by 2 * Math.PI returns to the same y"); t.ok(((point.y - y) / y) < tolerance, - "rotate by 2 * Math.PI returns to the same y") + "rotate by 2 * Math.PI returns to the same y"); + + t.ok(point.bounds == null, "bounds is cleared after a rotate()"); // rotate an 1/8 turn point.rotate(Math.PI / 4, origin); t.ok(((point.x - 1.4644660940672636) / 1.4644660940672636) < tolerance, "rotate 1/8 turn correctly"); t.ok(((point.y - 20.606601717798213) / 20.606601717798213) < tolerance, - "rotate 1/8 turn correctly") + "rotate 1/8 turn correctly"); } function test_Point_resize(t) { - t.plan(2); + t.plan(3); var tolerance = 1e-10; var x = 100 * Math.random(); var y = 100 * Math.random(); var point = new OpenLayers.Geometry.Point(x, y); + var bounds = point.getBounds(); var i = 100 * Math.random(); var j = 100 * Math.random(); @@ -123,7 +128,10 @@ t.ok((origin.x == i) && (origin.y == j), "resize leaves the origin untouched"); t.ok((((newDistance / oldDistance) - scale) / scale) < tolerance, - "resize moves points the correct distance from the origin") + "resize moves points the correct distance from the origin"); + + t.ok(point.bounds == null, "bounds is correctly cleared after a resize()"); + } function test_Point_equals(t) {