From 467bf66163783ff59c513899fd3a56c1f0179fb4 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Sat, 23 Mar 2013 11:49:17 +0100 Subject: [PATCH] Bounds: Simplified extend() method .. by using the new extendXY() method if the given object is LonLat or a Point. --- lib/OpenLayers/BaseTypes/Bounds.js | 47 +++++++++++++----------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/lib/OpenLayers/BaseTypes/Bounds.js b/lib/OpenLayers/BaseTypes/Bounds.js index 1d64a4f8dc..a828eb0cc2 100644 --- a/lib/OpenLayers/BaseTypes/Bounds.js +++ b/lib/OpenLayers/BaseTypes/Bounds.js @@ -355,39 +355,32 @@ OpenLayers.Bounds = OpenLayers.Class({ * object. */ extend:function(object) { - var bounds = null; if (object) { switch(object.CLASS_NAME) { - case "OpenLayers.LonLat": - bounds = new OpenLayers.Bounds(object.lon, object.lat, - object.lon, object.lat); + case "OpenLayers.LonLat": + this.extendXY(object.lon, object.lat); break; case "OpenLayers.Geometry.Point": - bounds = new OpenLayers.Bounds(object.x, object.y, - object.x, object.y); + this.extendXY(object.x, object.y); break; - - case "OpenLayers.Bounds": - bounds = object; - break; - } - - if (bounds) { - // clear cached center location - this.centerLonLat = null; - if ( (this.left == null) || (bounds.left < this.left)) { - this.left = bounds.left; - } - if ( (this.bottom == null) || (bounds.bottom < this.bottom) ) { - this.bottom = bounds.bottom; - } - if ( (this.right == null) || (bounds.right > this.right) ) { - this.right = bounds.right; - } - if ( (this.top == null) || (bounds.top > this.top) ) { - this.top = bounds.top; - } + case "OpenLayers.Bounds": + // clear cached center location + this.centerLonLat = null; + + if ( (this.left == null) || (object.left < this.left)) { + this.left = object.left; + } + if ( (this.bottom == null) || (object.bottom < this.bottom) ) { + this.bottom = object.bottom; + } + if ( (this.right == null) || (object.right > this.right) ) { + this.right = object.right; + } + if ( (this.top == null) || (object.top > this.top) ) { + this.top = object.top; + } + break; } } },