diff --git a/src/ol/geom/Point.js b/src/ol/geom/Point.js index 92b27d6a0e..d4a798ffc5 100644 --- a/src/ol/geom/Point.js +++ b/src/ol/geom/Point.js @@ -35,6 +35,16 @@ class Point extends SimpleGeometry { return point; } + /** + * @inheritDoc + * @override + * @api + */ + containsXY(x, y) { + const coord = this.getCoordinates(); + return coord[0] === x && coord[1] === y; + } + /** * @inheritDoc */ diff --git a/test/spec/ol/geom/point.test.js b/test/spec/ol/geom/point.test.js index 0f9e4e9aa6..3865b5ccd5 100644 --- a/test/spec/ol/geom/point.test.js +++ b/test/spec/ol/geom/point.test.js @@ -215,4 +215,22 @@ describe('ol.geom.Point', function() { }); + describe('#containsXY()', function() { + + it('does contain XY', function() { + const point = new Point([1, 2]); + + expect(point.containsXY(1, 2)).to.be(true); + }); + + it('does not contain XY', function() { + const point = new Point([1, 2]); + + expect(point.containsXY(1, 3)).to.be(false); + expect(point.containsXY(2, 2)).to.be(false); + expect(point.containsXY(2, 3)).to.be(false); + }); + + }); + });