[OpenLayers-Commits] r2378 - in sandbox/vector-2.4: lib/OpenLayers tests
commits at openlayers.org
commits at openlayers.org
Tue Mar 6 10:05:55 EST 2007
Author: euzuro
Date: 2007-03-06 10:05:41 -0500 (Tue, 06 Mar 2007)
New Revision: 2378
Modified:
sandbox/vector-2.4/lib/OpenLayers/Geometry.js
sandbox/vector-2.4/tests/test_Geometry.html
Log:
reverting an earlier change that made extendBounds() and setBounds() work with lonlats and points as well as bounds. since point now has a getBounds() function that works, better to use it and keep things simple.
Modified: sandbox/vector-2.4/lib/OpenLayers/Geometry.js
===================================================================
--- sandbox/vector-2.4/lib/OpenLayers/Geometry.js 2007-03-06 14:57:54 UTC (rev 2377)
+++ sandbox/vector-2.4/lib/OpenLayers/Geometry.js 2007-03-06 15:05:41 UTC (rev 2378)
@@ -50,39 +50,23 @@
/**
* Set the bounds for this Geometry.
*
- * @param {OpenLayers.LonLat|OpenLayers.Geometry.Point|OpenLayers.Bounds} object
+ * @param {OpenLayers.Bounds} object
*/
- setBounds: function(object) {
- var bounds = null;
- if (object) {
- switch(object.CLASS_NAME) {
- case "OpenLayers.Geometry.Point":
- case "OpenLayers.LonLat":
- bounds = new OpenLayers.Bounds(object.lon, object.lat,
- object.lon, object.lat);
- break;
-
- case "OpenLayers.Bounds":
- bounds = object.clone();
- break;
- }
- }
- if (bounds) {
- this.bounds = bounds;
- }
+ setBounds: function(bounds) {
+ this.bounds = bounds;
},
/**
- * Extend the existing bounds to include the new lonlat, point, or bounds.
+ * Extend the existing bounds to include the new bounds.
* If geometry's bounds is not yet set, then set a new Bounds.
*
- * @param {OpenLayers.LonLat|OpenLayers.Geometry.Point|OpenLayers.Bounds} object
+ * @param {OpenLayers.Bounds} object
*/
- extendBounds: function(object){
+ extendBounds: function(bounds){
if (!this.bounds) {
- this.setBounds(object);
+ this.setBounds(bounds);
} else {
- this.bounds.extend(object);
+ this.bounds.extend(bounds);
}
},
@@ -94,7 +78,7 @@
*
* @type OpenLayers.Bounds
*/
- getBounds: function(){
+ getBounds: function() {
return this.bounds;
},
Modified: sandbox/vector-2.4/tests/test_Geometry.html
===================================================================
--- sandbox/vector-2.4/tests/test_Geometry.html 2007-03-06 14:57:54 UTC (rev 2377)
+++ sandbox/vector-2.4/tests/test_Geometry.html 2007-03-06 15:05:41 UTC (rev 2378)
@@ -15,7 +15,7 @@
function test_02_Geometry_setBounds(t) {
- t.plan(5);
+ t.plan( 2 );
var g = new OpenLayers.Geometry();
@@ -27,37 +27,8 @@
var object = new Object();
g.setBounds(object);
- t.ok(g.bounds == null, "setbounds with object sans classname does not crash or set bounds");
+ t.ok(g.bounds == object, "setbounds with valid object sets bounds");
- //lonlat object
- var testLonLat = new OpenLayers.LonLat(5,12);
- object = testLonLat.clone();
-
- g.setBounds(object);
-
- var testBounds = new OpenLayers.Bounds(testLonLat.lon, testLonLat.lat,
- testLonLat.lon, testLonLat.lat);
- t.ok(g.bounds.equals(testBounds), "setbounds() lonlat object correct");
-
- //point object
- var testPoint = new OpenLayers.Geometry.Point(5,12);
- object = testPoint.clone();
-
- g.setBounds(object);
-
- var testBounds = new OpenLayers.Bounds(testPoint.lon, testPoint.lat,
- testPoint.lon, testPoint.lat);
- t.ok(g.bounds.equals(testBounds), "setbounds() point object correct");
-
- //bounds object
- var testBounds = new OpenLayers.Bounds(1,2,3,4);
- object = testBounds.clone();
-
- g.setBounds(object);
-
- t.ok(g.bounds.equals(testBounds), "setbounds() bounds object correct");
-
-
}
function test_03_Geometry_extendBounds(t) {
More information about the Commits
mailing list