ol/geom/Point#containsXY

This commit is contained in:
timkeane
2018-10-25 17:53:42 -04:00
committed by Frederic Junod
parent 4a5fa1f840
commit daffbde80b
2 changed files with 28 additions and 0 deletions

View File

@@ -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
*/

View File

@@ -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);
});
});
});