#805 - all geometries now know how to rotate - see the examples/rotate-features.html for geometry.rotate in action

git-svn-id: http://svn.openlayers.org/trunk/openlayers@3602 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2007-07-05 22:03:27 +00:00
parent debca7c477
commit dcffa03e7d
6 changed files with 207 additions and 0 deletions

View File

@@ -77,6 +77,35 @@
t.eq(line.components[1].y, y1 + dy, "move() correctly modifies second y");
}
function test_LineString_rotate(t) {
t.plan(6);
var components = [new OpenLayers.Geometry.Point(10,15),
new OpenLayers.Geometry.Point(0,0)];
var geometry = new OpenLayers.Geometry.LineString(components);
var originals = [];
var comp;
var angle = 2 * Math.PI * Math.random();
var origin = new OpenLayers.Geometry.Point(10 * Math.random(),
10 * Math.random());
for(var i=0; i<geometry.components.length; ++i) {
comp = geometry.components[i];
originals[i] = comp.rotate;
comp.rotate = function(a, o) {
t.ok(true, "rotate called for component " + i);
t.ok(a == angle, "rotate called with correct angle");
t.ok(o == origin, "rotate called with correct origin");
}
}
geometry.rotate(angle, origin);
// restore the original rotate defs
for(var i=0; i<geometry.components.length; ++i) {
comp.rotate = originals[i];
}
}
function test_LineString_equals(t) {
t.plan(3);