add equals() function to OpenLayers.Bounds. plus test
git-svn-id: http://svn.openlayers.org/trunk/openlayers@389 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -267,6 +267,18 @@ OpenLayers.Bounds.prototype = {
|
|||||||
this.right, this.top);
|
this.right, this.top);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {OpenLayers.Bounds} bounds
|
||||||
|
* @returns Boolean value indicating whether the passed-in OpenLayers.Bounds
|
||||||
|
* object has the same left, right, top, bottom components as this
|
||||||
|
*
|
||||||
|
* @type bool
|
||||||
|
*/
|
||||||
|
equals:function(bounds) {
|
||||||
|
return ((this.left == bounds.left) && (this.right == bounds.right) &&
|
||||||
|
(this.top == bounds.top) && (this.bottom == bounds.bottom));
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation of OpenLayers.Bounds object.
|
* @return String representation of OpenLayers.Bounds object.
|
||||||
* (ex.<i>"left-bottom=(5,42) right-top=(10,45)"</i>)
|
* (ex.<i>"left-bottom=(5,42) right-top=(10,45)"</i>)
|
||||||
|
|||||||
@@ -164,6 +164,17 @@
|
|||||||
t.eq( OpenLayers.Bounds.oppositeQuadrant("bl"), "tr", "OpenLayers.Bounds.oppositeQuadrant returns 'tr' for 'bl'");
|
t.eq( OpenLayers.Bounds.oppositeQuadrant("bl"), "tr", "OpenLayers.Bounds.oppositeQuadrant returns 'tr' for 'bl'");
|
||||||
t.eq( OpenLayers.Bounds.oppositeQuadrant("br"), "tl", "OpenLayers.Bounds.oppositeQuadrant returns 'tl' for 'br'");
|
t.eq( OpenLayers.Bounds.oppositeQuadrant("br"), "tl", "OpenLayers.Bounds.oppositeQuadrant returns 'tl' for 'br'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_11_Bounds_equals(t) {
|
||||||
|
t.plan( 2 );
|
||||||
|
var boundsA = new OpenLayers.Bounds(1,2,3,4);
|
||||||
|
var boundsB = new OpenLayers.Bounds(1,2,3,4);
|
||||||
|
var boundsC = new OpenLayers.Bounds(1,5,3,4);
|
||||||
|
|
||||||
|
t.ok( boundsA.equals(boundsB), "equals() returns true on two equal bounds." );
|
||||||
|
t.ok( !boundsA.equals(boundsC), "equals() returns false on two different bounds." );
|
||||||
|
}
|
||||||
|
|
||||||
// -->
|
// -->
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
Reference in New Issue
Block a user