(positions, options)
| 102262 | var _lineclip = require("./lineclip"); |
| 102263 | var _utils = require("./utils"); |
| 102264 | function cutPolylineByGrid(positions, options) { |
| 102265 | const { size =2 , broken =false , gridResolution =10 , gridOffset =[ |
| 102266 | 0, |
| 102267 | 0 |
| 102268 | ] , startIndex =0 , endIndex =positions.length } = options || {}; |
| 102269 | const numPoints = (endIndex - startIndex) / size; |
| 102270 | let part = []; |
| 102271 | const result = [ |
| 102272 | part |
| 102273 | ]; |
| 102274 | const a = (0, _utils.getPointAtIndex)(positions, 0, size, startIndex); |
| 102275 | let b; |
| 102276 | let codeB; |
| 102277 | const cell = getGridCell(a, gridResolution, gridOffset, []); |
| 102278 | const scratchPoint = []; |
| 102279 | (0, _utils.push)(part, a); |
| 102280 | for(let i = 1; i < numPoints; i++){ |
| 102281 | b = (0, _utils.getPointAtIndex)(positions, i, size, startIndex, b); |
| 102282 | codeB = (0, _lineclip.bitCode)(b, cell); |
| 102283 | while(codeB){ |
| 102284 | (0, _lineclip.intersect)(a, b, codeB, cell, scratchPoint); |
| 102285 | const codeAlt = (0, _lineclip.bitCode)(scratchPoint, cell); |
| 102286 | if (codeAlt) { |
| 102287 | (0, _lineclip.intersect)(a, scratchPoint, codeAlt, cell, scratchPoint); |
| 102288 | codeB = codeAlt; |
| 102289 | } |
| 102290 | (0, _utils.push)(part, scratchPoint); |
| 102291 | (0, _utils.copy)(a, scratchPoint); |
| 102292 | moveToNeighborCell(cell, gridResolution, codeB); |
| 102293 | if (broken && part.length > size) { |
| 102294 | part = []; |
| 102295 | result.push(part); |
| 102296 | (0, _utils.push)(part, a); |
| 102297 | } |
| 102298 | codeB = (0, _lineclip.bitCode)(b, cell); |
| 102299 | } |
| 102300 | (0, _utils.push)(part, b); |
| 102301 | (0, _utils.copy)(a, b); |
| 102302 | } |
| 102303 | return broken ? result : result[0]; |
| 102304 | } |
| 102305 | const TYPE_INSIDE = 0; |
| 102306 | const TYPE_BORDER = 1; |
| 102307 | function concatInPlace(arr1, arr2) { |
nothing calls this directly
no test coverage detected