Make irregular transforms work on rotated features

Rework support for irregular transforms to handle features
which have been rotated correctly.
This commit is contained in:
Tom Hughes
2011-10-18 09:55:25 +01:00
parent a46707e727
commit 1b6eb38d46

View File

@@ -399,10 +399,6 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, {
if (control.irregular && !control._setfeature) { if (control.irregular && !control._setfeature) {
dx1 -= (this.x - oldGeom.x) / 2; dx1 -= (this.x - oldGeom.x) / 2;
dy1 -= (this.y - oldGeom.y) / 2; dy1 -= (this.y - oldGeom.y) / 2;
var newCenter = centerGeometry.clone();
newCenter.x += Math.abs(dx0) < 0.00001 ? 0 : (this.x - oldGeom.x) / 2;
newCenter.y += Math.abs(dy0) < 0.00001 ? 0 : (this.y - oldGeom.y) / 2;
control.transformFeature({center: newCenter});
} }
this.x = oldX; this.x = oldX;
this.y = oldY; this.y = oldY;
@@ -424,8 +420,14 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, {
control.box.geometry.resize(scale, centerGeometry, ratio); control.box.geometry.resize(scale, centerGeometry, ratio);
control.box.geometry.rotate(control.rotation, centerGeometry); control.box.geometry.rotate(control.rotation, centerGeometry);
control.box.move(control.feature.geometry.getBounds().getCenterLonLat());
control.transformFeature({scale: scale, ratio: ratio}); control.transformFeature({scale: scale, ratio: ratio});
if (control.irregular && !control._setfeature) {
var newCenter = centerGeometry.clone();
newCenter.x += Math.abs(oldX - centerGeometry.x) < 0.00001 ? 0 : (this.x - oldX);
newCenter.y += Math.abs(oldY - centerGeometry.y) < 0.00001 ? 0 : (this.y - oldY);
control.box.geometry.move(this.x - oldX, this.y - oldY);
control.transformFeature({center: newCenter});
}
}; };
// Override for rotation handle move - make sure that the box and // Override for rotation handle move - make sure that the box and