Add containsExtent to ol.Extent

This commit is contained in:
Éric Lemoine
2013-01-28 12:25:04 +01:00
parent f581040b0f
commit 35a6cac37f
2 changed files with 67 additions and 28 deletions

View File

@@ -46,17 +46,31 @@ ol.Extent.boundingExtent = function(var_args) {
/**
* Checks if the given coordinate is contained or on the edge of the extent.
* Checks if the passed coordinate is contained or on the edge
* of the extent.
*
* @param {ol.Coordinate} coordinate Coordinate.
* @return {boolean} Contains.
*/
ol.Extent.prototype.contains = function(coordinate) {
ol.Extent.prototype.containsCoordinate = function(coordinate) {
return this.minX <= coordinate.x && coordinate.x <= this.maxX &&
this.minY <= coordinate.y && coordinate.y <= this.maxY;
};
/**
* Checks if the passed extent is contained or on the edge of the
* extent.
*
* @param {ol.Extent} extent Extent.
* @return {boolean} Contains.
*/
ol.Extent.prototype.containsExtent = function(extent) {
return this.minX <= extent.minX && extent.maxX <= this.maxX &&
this.minY <= extent.minY && extent.maxY <= this.maxY;
};
/**
* @return {ol.Coordinate} Bottom left coordinate.
*/