[OpenLayers-Commits] r2335 - sandbox/vector-2.4/lib/OpenLayers

commits at openlayers.org commits at openlayers.org
Mon Mar 5 14:34:07 EST 2007


Author: euzuro
Date: 2007-03-05 14:34:04 -0500 (Mon, 05 Mar 2007)
New Revision: 2335

Modified:
   sandbox/vector-2.4/lib/OpenLayers/BaseTypes.js
Log:
updating extendBounds patch and comment

Modified: sandbox/vector-2.4/lib/OpenLayers/BaseTypes.js
===================================================================
--- sandbox/vector-2.4/lib/OpenLayers/BaseTypes.js	2007-03-05 19:32:32 UTC (rev 2334)
+++ sandbox/vector-2.4/lib/OpenLayers/BaseTypes.js	2007-03-05 19:34:04 UTC (rev 2335)
@@ -470,31 +470,36 @@
     },
     
     /**
-     * Extend the bounds to include the box specificated.
-     * Can be used to extend the bounds to a point as well
-     * using extendBounds(x,y).
+     * Extend the bounds to include the point, lonlat, or bounds specified.
+     * 
      * This function assumes that left<right and bottom<top.
-     * @param {OpenLayers.LonLat} 
+     * 
+     * @param {OpenLayers.Bounds|OpenLayers.LonLat|OpenLayers.Geometry.Point} object
      */
-    extendBounds:function(geometry){
+    extendBounds:function(object) {
+        var bounds = null;
         switch(geometry.CLASS_NAME) {
             case "OpenLayers.Geometry.Point":
             case "OpenLayers.LonLat":    
-                var left = geometry.lon;
-                var bottom = geometry.lat;
-                this.left = (left < this.left) ? left : this.left;
-                this.bottom = (bottom < this.bottom) ? bottom : this.bottom;
-                this.right = (left > this.right) ? left : this.right;
-                this.top = (bottom > this.top) ? bottom : this.top;
-                break;    
+                bounds = new OpenLayers.Bounds(geometry.lon, geometry.lat,
+                                                geometry.lon, geometry.lat);
+                break;
+                
             case "OpenLayers.Bounds":    
-               this.left = (geometry.left < this.left) ? geometry.left : this.left;
-               this.bottom = (geometry.bottom < this.bottom) ? bottom : this.bottom;
-               this.right = (geometry.right > this.right) ? geometry.right : this.right;
-               this.top = (geometry.top > this.top) ? top : this.top;
+                bounds = object;
                break;
-               
         }
+
+        if (bounds) {
+           this.left = (bounds.left < this.left) ? bounds.left 
+                                                 : this.left;
+           this.bottom = (bounds.bottom < this.bottom) ? bounds.bottom 
+                                                       : this.bottom;
+           this.right = (bounds.right > this.right) ? bounds.right 
+                                                    : this.right;
+           this.top = (bounds.top > this.top) ? bounds.top 
+                                              : this.top;
+        }
     },
 
     /**



More information about the Commits mailing list