diff --git a/src/ol/extent.js b/src/ol/extent.js index d9d592a03f..3e5c92e2e3 100644 --- a/src/ol/extent.js +++ b/src/ol/extent.js @@ -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.