Add ol.Rectangle.intersects

This commit is contained in:
Tom Payne
2012-07-17 15:51:13 +02:00
parent d8a5126265
commit 41175a475f
2 changed files with 56 additions and 0 deletions
+13
View File
@@ -40,6 +40,19 @@ ol.Rectangle = function(minX, minY, maxX, maxY) {
};
/**
* @param {ol.Rectangle} rectangle1 Rectangle.
* @param {ol.Rectangle} rectangle2 Rectangle.
* @return {boolean} Intersects.
*/
ol.Rectangle.intersects = function(rectangle1, rectangle2) {
return rectangle1.minX <= rectangle2.maxX &&
rectangle1.maxX >= rectangle2.minX &&
rectangle1.minY <= rectangle2.maxY &&
rectangle1.maxY >= rectangle2.minY;
};
/**
* @return {ol.Rectangle} Clone.
*/