Intersects method for bounds.

This commit is contained in:
Tim Schaub
2012-06-21 17:11:24 +02:00
parent 08ad8c80d6
commit 0a1f8cddd8
2 changed files with 59 additions and 0 deletions

View File

@@ -105,3 +105,26 @@ ol.UnreferencedBounds.prototype.getWidth = function() {
ol.UnreferencedBounds.prototype.getHeight = function() {
return this.maxY_ - this.minY_;
};
/**
* Determine if this bounds intersects the target bounds (bounds that only
* touch are considered intersecting).
*
* @param {ol.UnreferencedBounds} bounds Target bounds.
* @return {boolean} The provided bounds intersects this bounds.
*/
ol.UnreferencedBounds.prototype.intersects = function(bounds) {
return !(
// this is left
(this.minX_ > bounds.getMaxX()) ||
// this is right
(this.maxX_ < bounds.getMinX()) ||
// this is above
(this.minY_ > bounds.getMaxY()) ||
// this is below
(this.maxY_ < bounds.getMinY())
);
};