Hi!
<br /><br />
I'm currently implementing GWT-classes to support TransformFeature with gwt-openlayers. Everything was ok except one thing: when calling unsetfeature() then setfeature(f) after a rotation, the box's shape became inconsistent.
<br />
<br />
I first started looking for the bug in my java code, but after some research, I found that the problem was in the Javascript.
<br />
Indeed in the setFeature method, the box is moved to the new feature, then rotate at the inverse of the current rotation, finally scaled.
<br />
<hr />
<i>
<pre>
setFeature: function(feature, initialParams) {
...
var oldRotation = this.rotation;
var oldCenter = this.center;
...
var featureBounds = this.feature.geometry.getBounds();
this.box.move(featureBounds.getCenterLonLat());
<b>this.box.geometry.rotate(-oldRotation, oldCenter);</b>
this._angle = 0;
...
}
</pre>
</i>
<hr />
I found the problem did not happen when I didn't call the "deactivate()" or "unsetfeature()" functions. Then I found this little line in the TransformFeature.js (line 327):
<hr />
<pre>
<i>
unsetFeature: function() {
        if (this.active) {
                this.deactivate();
        } else {
                 this.feature = null;
                 <b>this.rotation = 0;</b>
                 this.scale = 1;
                 this.ratio = 1;
        }
}
</i>
</pre>
<hr />
It means that when you unset a rotated feature then you set a new one, the box cannot be unrotated, the scale arrive on it and the great box became dirty.
<br />
<br />
After commented it, the bug is gone. I looked for it on the OpenLayers.transformFeature example and found that the unsetFeature (or deactivate) method is never called. After putting a call in the code, the bug appears. Here the code I added to this file "http://dev.openlayers.org/releases/OpenLayers-2.11/examples/transform-feature.html" to make the bug appear (just after control creation) :
<hr />
<i>
control.events.register("transformcomplete", control, function()
{
var feature = control.feature;
control.unsetFeature();
control.setFeature(feature);
});
</i>
<hr />
Did you ever heard about it ? Is that really a bug or a bad manipulation from me ?
<br /><br />
Regards,
<br /><br />
Guillaume
        
<br/><hr align="left" width="300" />
View this message in context: <a href="http://osgeo-org.1560.n6.nabble.com/TransformFeature-unsetFeature-seems-to-have-a-bug-tp4692609p4692609.html">TransformFeature.unsetFeature seems to have a bug</a><br/>
Sent from the <a href="http://osgeo-org.1560.n6.nabble.com/OpenLayers-Dev-f3888596.html">OpenLayers Dev mailing list archive</a> at Nabble.com.<br/>