Skip to content

Commit

Permalink
Moving Rectangle geometries to deprecated.js.
Browse files Browse the repository at this point in the history
The VML and SVG renderers still have support for drawing rectangles.  This can be safely removed in 3.0.
  • Loading branch information
tschaub committed Dec 29, 2011
1 parent 9075f14 commit 958221d
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 102 deletions.
1 change: 0 additions & 1 deletion lib/OpenLayers.js
Expand Up @@ -202,7 +202,6 @@
"OpenLayers/Control/TransformFeature.js",
"OpenLayers/Control/SLDSelect.js",
"OpenLayers/Geometry.js",
"OpenLayers/Geometry/Rectangle.js",
"OpenLayers/Geometry/Collection.js",
"OpenLayers/Geometry/Point.js",
"OpenLayers/Geometry/MultiPoint.js",
Expand Down
99 changes: 0 additions & 99 deletions lib/OpenLayers/Geometry/Rectangle.js

This file was deleted.

93 changes: 93 additions & 0 deletions lib/deprecated.js
Expand Up @@ -20,8 +20,10 @@
* @requires OpenLayers/Format/JSON.js
* @requires OpenLayers/Format/WKT.js
* @requires OpenLayers/Format/XML.js
* @requires OpenLayers/Geometry.js
*/


/**
* Namespace: OpenLayers.Class
*/
Expand Down Expand Up @@ -4938,3 +4940,94 @@ OpenLayers.Layer.GML = OpenLayers.Class(OpenLayers.Layer.Vector, {

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"
});
@@ -1,6 +1,7 @@
<html>
<head>
<script src="../OLLoader.js"></script>
<script src="../../OLLoader.js"></script>
<script src="../../../lib/deprecated.js"></script>
<script type="text/javascript">

function test_Rectangle_constructor (t) {
Expand Down
2 changes: 1 addition & 1 deletion tests/list-tests.html
Expand Up @@ -123,7 +123,6 @@
<li>Geometry/MultiPolygon.html</li>
<li>Geometry/Point.html</li>
<li>Geometry/Polygon.html</li>
<li>Geometry/Rectangle.html</li>
<li>Handler.html</li>
<li>Handler/Box.html</li>
<li>Handler/Click.html</li>
Expand Down Expand Up @@ -222,6 +221,7 @@
<li>deprecated/BaseTypes/Class.html</li>
<li>deprecated/BaseTypes/Element.html</li>
<li>deprecated/Control/MouseToolbar.html</li>
<li>deprecated/Geometry/Rectangle.html</li>
<li>deprecated/Layer/GML.html</li>
<li>deprecated/Layer/MapServer.html</li>
<li>deprecated/Layer/MapServer/Untiled.html</li>
Expand Down

0 comments on commit 958221d

Please sign in to comment.