diff --git a/lib/OpenLayers/BaseTypes.js b/lib/OpenLayers/BaseTypes.js index c2c22cc5a6..7ac2c5c066 100644 --- a/lib/OpenLayers/BaseTypes.js +++ b/lib/OpenLayers/BaseTypes.js @@ -491,17 +491,21 @@ OpenLayers.Bounds.prototype = { inclusive = true; } var inBottom = (bounds.bottom == this.bottom && bounds.top == this.top) ? - true : (bounds.bottom > this.bottom) && (bounds.bottom < this.top); + true : (((bounds.bottom > this.bottom) && (bounds.bottom < this.top)) || + ((this.bottom > bounds.bottom) && (this.bottom < bounds.top))); var inTop = (bounds.bottom == this.bottom && bounds.top == this.top) ? - true : (bounds.top > this.bottom) && (bounds.top < this.top); + true : (((bounds.top > this.bottom) && (bounds.top < this.top)) || + ((this.top > bounds.bottom) && (this.top < bounds.top))); var inRight = (bounds.right == this.right && bounds.left == this.left) ? - true : (bounds.right > this.left) && (bounds.right < this.right); + true : (((bounds.right > this.left) && (bounds.right < this.right)) || + ((this.right > bounds.left) && (this.right < bounds.right))); var inLeft = (bounds.right == this.right && bounds.left == this.left) ? - true : (bounds.left > this.left) && (bounds.left < this.right); + true : (((bounds.left > this.left) && (bounds.left < this.right)) || + ((this.left > bounds.left) && (this.left < bounds.right))); return (this.containsBounds(bounds, true, inclusive) || bounds.containsBounds(this, true, inclusive) || - (inTop || inBottom ) && (inLeft || inRight )); + ((inTop || inBottom ) && (inLeft || inRight ))); }, /** diff --git a/tests/test_Bounds.html b/tests/test_Bounds.html index 77d20b4fb6..cc5d84af4b 100644 --- a/tests/test_Bounds.html +++ b/tests/test_Bounds.html @@ -108,7 +108,7 @@ } function test_08a_Bounds_intersectsBounds(t) { - t.plan( 16 ); + t.plan( 17 ); var aBounds = new OpenLayers.Bounds(-180, -90, 180, 90); @@ -118,6 +118,7 @@ t.eq( aBounds.intersectsBounds(bBounds), true, "(" + aBounds.toBBOX() + ") correctly intersects (" + bBounds.toBBOX() + ")" ); t.eq( aBounds.intersectsBounds(bBounds, true), true, "(" + aBounds.toBBOX() + ") correctly intersects (" + bBounds.toBBOX() + "), inclusive is true" ); t.eq( aBounds.intersectsBounds(bBounds, false), true, "(" + aBounds.toBBOX() + ") correctly intersects (" + bBounds.toBBOX() + "), inclusive is false" ); + t.eq( aBounds.intersectsBounds(cBounds, false), true, "aBounds with cBounds adjusted one degree left passes intersect bounds. (3 sides match, 1 side different)." ); t.eq( cBounds.intersectsBounds(aBounds, false), true, "cBounds with aBounds adjusted one degree left passes intersect bounds. (3 sides match, 1 side different)." ); //outside