Merge branch 'master' into tile-fade-in
This commit is contained in:
@@ -202,7 +202,6 @@
|
|||||||
"OpenLayers/Control/TransformFeature.js",
|
"OpenLayers/Control/TransformFeature.js",
|
||||||
"OpenLayers/Control/SLDSelect.js",
|
"OpenLayers/Control/SLDSelect.js",
|
||||||
"OpenLayers/Geometry.js",
|
"OpenLayers/Geometry.js",
|
||||||
"OpenLayers/Geometry/Rectangle.js",
|
|
||||||
"OpenLayers/Geometry/Collection.js",
|
"OpenLayers/Geometry/Collection.js",
|
||||||
"OpenLayers/Geometry/Point.js",
|
"OpenLayers/Geometry/Point.js",
|
||||||
"OpenLayers/Geometry/MultiPoint.js",
|
"OpenLayers/Geometry/MultiPoint.js",
|
||||||
|
|||||||
@@ -166,6 +166,15 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
*/
|
*/
|
||||||
dragControl: null,
|
dragControl: null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APIProperty: irregular
|
||||||
|
* {Boolean} Make scaling/resizing work irregularly. If true then
|
||||||
|
* dragging a handle causes the feature to resize in the direction
|
||||||
|
* of movement. If false then the feature resizes symetrically
|
||||||
|
* about it's center.
|
||||||
|
*/
|
||||||
|
irregular: false,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor: OpenLayers.Control.TransformFeature
|
* Constructor: OpenLayers.Control.TransformFeature
|
||||||
* Create a new transform feature control.
|
* Create a new transform feature control.
|
||||||
@@ -390,6 +399,10 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
var dy1 = this.y - centerGeometry.y;
|
var dy1 = this.y - centerGeometry.y;
|
||||||
var dx0 = dx1 - (this.x - oldGeom.x);
|
var dx0 = dx1 - (this.x - oldGeom.x);
|
||||||
var dy0 = dy1 - (this.y - oldGeom.y);
|
var dy0 = dy1 - (this.y - oldGeom.y);
|
||||||
|
if (control.irregular && !control._setfeature) {
|
||||||
|
dx1 -= (this.x - oldGeom.x) / 2;
|
||||||
|
dy1 -= (this.y - oldGeom.y) / 2;
|
||||||
|
}
|
||||||
this.x = oldX;
|
this.x = oldX;
|
||||||
this.y = oldY;
|
this.y = oldY;
|
||||||
var scale, ratio = 1;
|
var scale, ratio = 1;
|
||||||
@@ -411,6 +424,13 @@ 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.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
|
||||||
|
|||||||
@@ -1,99 +0,0 @@
|
|||||||
/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for
|
|
||||||
* full list of contributors). Published under the Clear BSD license.
|
|
||||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
|
||||||
* full text of the license. */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @requires OpenLayers/Geometry.js
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class: OpenLayers.Geometry.Rectangle
|
|
||||||
* This class is *not supported*, and probably isn't what you're looking for.
|
|
||||||
* Instead, most users probably want something like:
|
|
||||||
* (code)
|
|
||||||
* var poly = new OpenLayers.Bounds(0,0,10,10).toGeometry();
|
|
||||||
* (end)
|
|
||||||
* This will create a rectangular Polygon geometry.
|
|
||||||
*
|
|
||||||
* Inherits:
|
|
||||||
* - <OpenLayers.Geometry>
|
|
||||||
*/
|
|
||||||
|
|
||||||
OpenLayers.Geometry.Rectangle = OpenLayers.Class(OpenLayers.Geometry, {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Property: x
|
|
||||||
* {Float}
|
|
||||||
*/
|
|
||||||
x: null,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Property: y
|
|
||||||
* {Float}
|
|
||||||
*/
|
|
||||||
y: null,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Property: width
|
|
||||||
* {Float}
|
|
||||||
*/
|
|
||||||
width: null,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Property: height
|
|
||||||
* {Float}
|
|
||||||
*/
|
|
||||||
height: null,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor: OpenLayers.Geometry.Rectangle
|
|
||||||
*
|
|
||||||
* Parameters:
|
|
||||||
* points - {Array(<OpenLayers.Geometry.Point>)}
|
|
||||||
*/
|
|
||||||
initialize: function(x, y, width, height) {
|
|
||||||
OpenLayers.Geometry.prototype.initialize.apply(this, arguments);
|
|
||||||
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
|
|
||||||
this.width = width;
|
|
||||||
this.height = height;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method: calculateBounds
|
|
||||||
* Recalculate the bounds for the geometry.
|
|
||||||
*/
|
|
||||||
calculateBounds: function() {
|
|
||||||
this.bounds = new OpenLayers.Bounds(this.x, this.y,
|
|
||||||
this.x + this.width,
|
|
||||||
this.y + this.height);
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* APIMethod: getLength
|
|
||||||
*
|
|
||||||
* Returns:
|
|
||||||
* {Float} The length of the geometry
|
|
||||||
*/
|
|
||||||
getLength: function() {
|
|
||||||
var length = (2 * this.width) + (2 * this.height);
|
|
||||||
return length;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* APIMethod: getArea
|
|
||||||
*
|
|
||||||
* Returns:
|
|
||||||
* {Float} The area of the geometry
|
|
||||||
*/
|
|
||||||
getArea: function() {
|
|
||||||
var area = this.width * this.height;
|
|
||||||
return area;
|
|
||||||
},
|
|
||||||
|
|
||||||
CLASS_NAME: "OpenLayers.Geometry.Rectangle"
|
|
||||||
});
|
|
||||||
@@ -20,8 +20,10 @@
|
|||||||
* @requires OpenLayers/Format/JSON.js
|
* @requires OpenLayers/Format/JSON.js
|
||||||
* @requires OpenLayers/Format/WKT.js
|
* @requires OpenLayers/Format/WKT.js
|
||||||
* @requires OpenLayers/Format/XML.js
|
* @requires OpenLayers/Format/XML.js
|
||||||
|
* @requires OpenLayers/Geometry.js
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Namespace: OpenLayers.Class
|
* Namespace: OpenLayers.Class
|
||||||
*/
|
*/
|
||||||
@@ -4869,3 +4871,94 @@ OpenLayers.Layer.GML = OpenLayers.Class(OpenLayers.Layer.Vector, {
|
|||||||
|
|
||||||
CLASS_NAME: "OpenLayers.Layer.GML"
|
CLASS_NAME: "OpenLayers.Layer.GML"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class: OpenLayers.Geometry.Rectangle
|
||||||
|
* This class is *not supported*, and probably isn't what you're looking for.
|
||||||
|
* Instead, most users probably want something like:
|
||||||
|
* (code)
|
||||||
|
* var poly = new OpenLayers.Bounds(0,0,10,10).toGeometry();
|
||||||
|
* (end)
|
||||||
|
* This will create a rectangular Polygon geometry.
|
||||||
|
*
|
||||||
|
* Inherits:
|
||||||
|
* - <OpenLayers.Geometry>
|
||||||
|
*/
|
||||||
|
|
||||||
|
OpenLayers.Geometry.Rectangle = OpenLayers.Class(OpenLayers.Geometry, {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Property: x
|
||||||
|
* {Float}
|
||||||
|
*/
|
||||||
|
x: null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Property: y
|
||||||
|
* {Float}
|
||||||
|
*/
|
||||||
|
y: null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Property: width
|
||||||
|
* {Float}
|
||||||
|
*/
|
||||||
|
width: null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Property: height
|
||||||
|
* {Float}
|
||||||
|
*/
|
||||||
|
height: null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor: OpenLayers.Geometry.Rectangle
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* points - {Array(<OpenLayers.Geometry.Point>)}
|
||||||
|
*/
|
||||||
|
initialize: function(x, y, width, height) {
|
||||||
|
OpenLayers.Geometry.prototype.initialize.apply(this, arguments);
|
||||||
|
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: calculateBounds
|
||||||
|
* Recalculate the bounds for the geometry.
|
||||||
|
*/
|
||||||
|
calculateBounds: function() {
|
||||||
|
this.bounds = new OpenLayers.Bounds(this.x, this.y,
|
||||||
|
this.x + this.width,
|
||||||
|
this.y + this.height);
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APIMethod: getLength
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* {Float} The length of the geometry
|
||||||
|
*/
|
||||||
|
getLength: function() {
|
||||||
|
var length = (2 * this.width) + (2 * this.height);
|
||||||
|
return length;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APIMethod: getArea
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* {Float} The area of the geometry
|
||||||
|
*/
|
||||||
|
getArea: function() {
|
||||||
|
var area = this.width * this.height;
|
||||||
|
return area;
|
||||||
|
},
|
||||||
|
|
||||||
|
CLASS_NAME: "OpenLayers.Geometry.Rectangle"
|
||||||
|
});
|
||||||
|
|||||||
+2
-1
@@ -109,7 +109,7 @@ Without the WKT format included (by default), the `OpenLayers.Geometry::toString
|
|||||||
|
|
||||||
## Deprecated Components
|
## Deprecated Components
|
||||||
|
|
||||||
A number of constructors have been marked as deprecated for multiple releases in the 2.x series. For the 2.12 release this deprecated functionality has been moved to a separate deprecated.js file. If you use any of the constructors or methods below, you will have to explicitly include the deprecated.js file in your build (or add it in a separate `<script>` tag after OpenLayers.js).
|
A number of properties, methods, and constructors have been marked as deprecated for multiple releases in the 2.x series. For the 2.12 release this deprecated functionality has been moved to a separate deprecated.js file. If you use any of the constructors or methods below, you will have to explicitly include the deprecated.js file in your build (or add it in a separate `<script>` tag after OpenLayers.js).
|
||||||
|
|
||||||
* OpenLayers.Class.isPrototype
|
* OpenLayers.Class.isPrototype
|
||||||
* OpenLayers.Class.create
|
* OpenLayers.Class.create
|
||||||
@@ -142,6 +142,7 @@ A number of constructors have been marked as deprecated for multiple releases in
|
|||||||
* OpenLayers.Protocol.SQL.Gears
|
* OpenLayers.Protocol.SQL.Gears
|
||||||
* OpenLayers.Layer.Yahoo
|
* OpenLayers.Layer.Yahoo
|
||||||
* OpenLayers.Layer.GML
|
* OpenLayers.Layer.GML
|
||||||
|
* OpenLayers.Geometry.Rectangle
|
||||||
|
|
||||||
In addition, OpenLayers no longer modifies any native prototypes or objects by default. If you rely on any of the following, you'll need to include deprecated.js explicitly to get the same behavior.
|
In addition, OpenLayers no longer modifies any native prototypes or objects by default. If you rely on any of the following, you'll need to include deprecated.js explicitly to get the same behavior.
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,44 @@
|
|||||||
control.box.move(center);
|
control.box.move(center);
|
||||||
t.geom_eq(control.handles[0].geometry, control.box.geometry.components[0], "handle moved with box");
|
t.geom_eq(control.handles[0].geometry, control.box.geometry.components[0], "handle moved with box");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_handleMove(t) {
|
||||||
|
t.plan(16);
|
||||||
|
var map = new OpenLayers.Map("map", {allOverlays: true});
|
||||||
|
var layer = new OpenLayers.Layer.Vector();
|
||||||
|
var feature = new OpenLayers.Feature.Vector(
|
||||||
|
OpenLayers.Geometry.fromWKT("POLYGON((-1 -1, 1 -1, 1 1, -1 1))"));
|
||||||
|
layer.addFeatures([feature]);
|
||||||
|
map.addLayer(layer);
|
||||||
|
map.setCenter(new OpenLayers.LonLat(0, 0), 18);
|
||||||
|
var control = new OpenLayers.Control.TransformFeature(layer);
|
||||||
|
map.addControl(control);
|
||||||
|
control.setFeature(feature);
|
||||||
|
|
||||||
|
var bottomLeft = new OpenLayers.LonLat(-2, -2);
|
||||||
|
control.handles[0].move(bottomLeft);
|
||||||
|
t.geom_eq(control.handles[0].geometry, new OpenLayers.Geometry.Point(-2, -2), "bottom left handle at -2,-2");
|
||||||
|
t.geom_eq(control.handles[1].geometry, new OpenLayers.Geometry.Point(0, -2), "bottom handle at 0,-2");
|
||||||
|
t.geom_eq(control.handles[2].geometry, new OpenLayers.Geometry.Point(2, -2), "bottom right handle at 2,-2");
|
||||||
|
t.geom_eq(control.handles[3].geometry, new OpenLayers.Geometry.Point(2, 0), "right handle at 2,0");
|
||||||
|
t.geom_eq(control.handles[4].geometry, new OpenLayers.Geometry.Point(2, 2), "top right handle at 2,2");
|
||||||
|
t.geom_eq(control.handles[5].geometry, new OpenLayers.Geometry.Point(0, 2), "top handle at 0,2");
|
||||||
|
t.geom_eq(control.handles[6].geometry, new OpenLayers.Geometry.Point(-2, 2), "top left handle at -2,2");
|
||||||
|
t.geom_eq(control.handles[7].geometry, new OpenLayers.Geometry.Point(-2, 0), "left handle at -2,0");
|
||||||
|
|
||||||
|
control.irregular = true;
|
||||||
|
|
||||||
|
var bottomLeft = new OpenLayers.LonLat(-3, -3);
|
||||||
|
control.handles[0].move(bottomLeft);
|
||||||
|
t.geom_eq(control.handles[0].geometry, new OpenLayers.Geometry.Point(-3, -3), "bottom left handle at -3,-3");
|
||||||
|
t.geom_eq(control.handles[1].geometry, new OpenLayers.Geometry.Point(-0.5, -3), "bottom handle at 0,-3");
|
||||||
|
t.geom_eq(control.handles[2].geometry, new OpenLayers.Geometry.Point(2, -3), "bottom right handle at 2,-3");
|
||||||
|
t.geom_eq(control.handles[3].geometry, new OpenLayers.Geometry.Point(2, -0.5), "right handle at 2,0");
|
||||||
|
t.geom_eq(control.handles[4].geometry, new OpenLayers.Geometry.Point(2, 2), "top right handle at 2,2");
|
||||||
|
t.geom_eq(control.handles[5].geometry, new OpenLayers.Geometry.Point(-0.5, 2), "top handle at 0,2");
|
||||||
|
t.geom_eq(control.handles[6].geometry, new OpenLayers.Geometry.Point(-3, 2), "top left handle at -3,2");
|
||||||
|
t.geom_eq(control.handles[7].geometry, new OpenLayers.Geometry.Point(-3, -0.5), "left handle at -3,0");
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
@@ -34,6 +34,35 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function assertFloatEqual
|
||||||
|
* Test two objects for floating point equivalence. Throw an exception
|
||||||
|
* if not equivalent.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* got - {Object}
|
||||||
|
* expected - {Object}
|
||||||
|
* msg - {String} The message to be thrown. This message will be appended
|
||||||
|
* with ": got {got} but expected {expected}" where got and expected are
|
||||||
|
* replaced with string representations of the above arguments.
|
||||||
|
*/
|
||||||
|
function assertFloatEqual(got, expected, msg) {
|
||||||
|
var OpenLayers = Test.AnotherWay._g_test_iframe.OpenLayers;
|
||||||
|
if(got === undefined) {
|
||||||
|
got = "undefined";
|
||||||
|
} else if (got === null) {
|
||||||
|
got = "null";
|
||||||
|
}
|
||||||
|
if(expected === undefined) {
|
||||||
|
expected = "undefined";
|
||||||
|
} else if (expected === null) {
|
||||||
|
expected = "null";
|
||||||
|
}
|
||||||
|
if(Math.abs(got - expected) > Math.pow(10, -OpenLayers.Util.DEFAULT_PRECISION)) {
|
||||||
|
throw msg + ": got '" + got + "' but expected '" + expected + "'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function assertGeometryEqual
|
* Function assertGeometryEqual
|
||||||
* Test two geometries for equivalence. Geometries are considered
|
* Test two geometries for equivalence. Geometries are considered
|
||||||
@@ -58,9 +87,9 @@
|
|||||||
|
|
||||||
if(got instanceof OpenLayers.Geometry.Point) {
|
if(got instanceof OpenLayers.Geometry.Point) {
|
||||||
// compare points
|
// compare points
|
||||||
assertEqual(got.x, expected.x, "x mismatch");
|
assertFloatEqual(got.x, expected.x, "x mismatch");
|
||||||
assertEqual(got.y, expected.y, "y mismatch");
|
assertFloatEqual(got.y, expected.y, "y mismatch");
|
||||||
assertEqual(got.z, expected.z, "z mismatch");
|
assertFloatEqual(got.z, expected.z, "z mismatch");
|
||||||
} else {
|
} else {
|
||||||
// compare components
|
// compare components
|
||||||
assertEqual(
|
assertEqual(
|
||||||
@@ -107,4 +136,4 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<script src="../OLLoader.js"></script>
|
<script src="../../OLLoader.js"></script>
|
||||||
|
<script src="../../../lib/deprecated.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
function test_Rectangle_constructor (t) {
|
function test_Rectangle_constructor (t) {
|
||||||
@@ -123,7 +123,6 @@
|
|||||||
<li>Geometry/MultiPolygon.html</li>
|
<li>Geometry/MultiPolygon.html</li>
|
||||||
<li>Geometry/Point.html</li>
|
<li>Geometry/Point.html</li>
|
||||||
<li>Geometry/Polygon.html</li>
|
<li>Geometry/Polygon.html</li>
|
||||||
<li>Geometry/Rectangle.html</li>
|
|
||||||
<li>Handler.html</li>
|
<li>Handler.html</li>
|
||||||
<li>Handler/Box.html</li>
|
<li>Handler/Box.html</li>
|
||||||
<li>Handler/Click.html</li>
|
<li>Handler/Click.html</li>
|
||||||
@@ -222,6 +221,7 @@
|
|||||||
<li>deprecated/BaseTypes/Class.html</li>
|
<li>deprecated/BaseTypes/Class.html</li>
|
||||||
<li>deprecated/BaseTypes/Element.html</li>
|
<li>deprecated/BaseTypes/Element.html</li>
|
||||||
<li>deprecated/Control/MouseToolbar.html</li>
|
<li>deprecated/Control/MouseToolbar.html</li>
|
||||||
|
<li>deprecated/Geometry/Rectangle.html</li>
|
||||||
<li>deprecated/Layer/GML.html</li>
|
<li>deprecated/Layer/GML.html</li>
|
||||||
<li>deprecated/Layer/MapServer.html</li>
|
<li>deprecated/Layer/MapServer.html</li>
|
||||||
<li>deprecated/Layer/MapServer/Untiled.html</li>
|
<li>deprecated/Layer/MapServer/Untiled.html</li>
|
||||||
|
|||||||
Reference in New Issue
Block a user