Permalink
Browse files

Merge pull request #461 from mortenbekditlevsen/boundsintersection

Bounds intersection
  • Loading branch information...
2 parents 10aa67a + 4d131e7 commit 77a24f107a7e452deb8a82a83f74bf76a50edfb3 @mourner mourner committed Feb 3, 2012
Showing with 13 additions and 0 deletions.
  1. +13 −0 src/geometry/Bounds.js
View
@@ -46,5 +46,18 @@ L.Bounds = L.Class.extend({
(max.x <= this.max.x) &&
(min.y >= this.min.y) &&
(max.y <= this.max.y);
+ },
+
+ intersects: function (/*Bounds*/ bounds) {
+ var min = this.min,
+ max = this.max,
+ min2 = bounds.min,
+ max2 = bounds.max;
+
+ var xIntersects = (max2.x >= min.x) && (min2.x <= max.x),
+ yIntersects = (max2.y >= min.y) && (min2.y <= max.y);
+
+ return xIntersects && yIntersects;
}
+
});

0 comments on commit 77a24f1

Please sign in to comment.