1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 1 1 1 1 1 1 1 4 1 | describe('PolyUtil', function () { describe('#clipPolygon', function () { it('clips polygon by bounds', 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).to.eql([ new L.Point(7.5, 10), new L.Point(5, 5), new L.Point(10, 7.5), new L.Point(10, 10) ]); }); }); }); |