1 /* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
2 * license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
3 * full text of the license. */
6 * @requires OpenLayers/Geometry.js
10 * Class: OpenLayers.Geometry.Rectangle
11 * This class is *not supported*, and probably isn't what you're looking for.
12 * Instead, most users probably want something like:
14 * var poly = new OpenLayers.Bounds(0,0,10,10).toGeometry();
16 * This will create a rectangular Polygon geometry.
19 * - <OpenLayers.Geometry>
22 OpenLayers.Geometry.Rectangle = OpenLayers.Class(OpenLayers.Geometry, {
49 * Constructor: OpenLayers.Geometry.Rectangle
52 * points - {Array(<OpenLayers.Geometry.Point>}
54 initialize: function(x, y, width, height) {
55 OpenLayers.Geometry.prototype.initialize.apply(this, arguments);
65 * Method: calculateBounds
66 * Recalculate the bounds for the geometry.
68 calculateBounds: function() {
69 this.bounds = new OpenLayers.Bounds(this.x, this.y,
71 this.y + this.height);
76 * APIMethod: getLength
79 * {Float} The length of the geometry
81 getLength: function() {
82 var length = (2 * this.width) + (2 * this.height);
90 * {Float} The area of the geometry
93 var area = this.width * this.height;
97 CLASS_NAME: "OpenLayers.Geometry.Rectangle"