Modifying bounds.intersectsBounds to it catches bounds intersections where corners of one bounds are not contains in the other bounds. Thanks for the review. r=sderle (closes #1951)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@9052 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2009-03-15 03:44:22 +00:00
parent 49d6463f4e
commit f9e9eb61ae
2 changed files with 49 additions and 33 deletions

View File

@@ -165,7 +165,7 @@
}
function test_Bounds_intersectsBounds(t) {
t.plan( 19 );
t.plan(21);
var aBounds = new OpenLayers.Bounds(-180, -90, 180, 90);
@@ -209,6 +209,13 @@
20037508.34,20037508.34);
t.eq( merc_aBounds.intersectsBounds(merc_bBounds, true), true, "intersect shouldn't fall prey to floating point errors, inclusive is true");
t.eq( merc_aBounds.intersectsBounds(merc_bBounds, false), false, "intersect shouldn't fall prey to floating point errors, inclusive is false");
// test for bounds intersection where none of the corners are contained within the other bounds
var b1 = new OpenLayers.Bounds(-1, -2, 1, 2);
var b2 = new OpenLayers.Bounds(-2, -1, 2, 1);
t.eq(b1.intersectsBounds(b2), true, "vertical rectangle intersects horizontal rectangle");
t.eq(b2.intersectsBounds(b1), true, "horizontal rectangle intersects vertical rectangle");
}
function test_Bounds_containsBounds(t) {
@@ -263,7 +270,8 @@
t.eq( containerBounds.containsBounds(bounds, false, false), true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is false, inclusive is false" );
t.eq( containerBounds.containsBounds(bounds, true) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is true" );
t.eq( containerBounds.containsBounds(bounds, true, true) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is true, inclusive is true" );
t.eq( containerBounds.containsBounds(bounds, true, false) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is true, inclusive is false" );
t.eq( containerBounds.containsBounds(bounds, true, false) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is true, inclusive is false" );
}
function test_Bounds_determineQuadrant(t) {