ol/geom/Point#containsXY
This commit is contained in:
@@ -35,6 +35,16 @@ class Point extends SimpleGeometry {
|
|||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
* @override
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
containsXY(x, y) {
|
||||||
|
const coord = this.getCoordinates();
|
||||||
|
return coord[0] === x && coord[1] === y;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user