Add ol.extent.containsXY

This commit is contained in:
Éric Lemoine
2014-09-17 07:56:54 +02:00
parent b5db9db453
commit 24321f6feb

View File

@@ -159,8 +159,7 @@ ol.extent.closestSquaredDistanceXY = function(extent, x, y) {
* @api stable
*/
ol.extent.containsCoordinate = function(extent, coordinate) {
return extent[0] <= coordinate[0] && coordinate[0] <= extent[2] &&
extent[1] <= coordinate[1] && coordinate[1] <= extent[3];
return ol.extent.containsXY(extent, coordinate[0], coordinate[1]);
};
@@ -178,6 +177,20 @@ ol.extent.containsExtent = function(extent1, extent2) {
};
/**
* Checks if the passed coordinate is contained or on the edge of the extent.
*
* @param {ol.Extent} extent Extent.
* @param {number} x X coordinate.
* @param {number} y Y coordinate.
* @return {boolean} Contains.
* @api stable
*/
ol.extent.containsXY = function(extent, x, y) {
return extent[0] <= x && x <= extent[2] && extent[1] <= y && y <= extent[3];
};
/**
* Get the relationship between a coordinate and extent.
* @param {ol.Extent} extent The extent.