Leaflet/spec/suites/geometry/PolyUtilSpec.js
2013-02-05 13:51:27 +02:00

28 lines
580 B
JavaScript

describe('PolyUtil', function () {
describe('#clipPolygon', function () {
it('should clip polygon by bounds correctly', function () {
var bounds = L.bounds([0, 0], [10, 10]);
var points = [
new L.Point(5, 5),
new L.Point(15, 10),
new L.Point(10, 15)
];
var clipped = L.PolyUtil.clipPolygon(points, bounds);
for (var i = 0, len = clipped.length; i < len; i++) {
delete clipped[i]._code;
}
expect(clipped).toEqual([
new L.Point(7.5, 10),
new L.Point(5, 5),
new L.Point(10, 7.5),
new L.Point(10, 10)
]);
});
});
});