MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / eliminateHoles

Function eliminateHoles

libs/mapv/mapv.js:1857–1882  ·  view source on GitHub ↗
(data, holeIndices, outerNode, dim)

Source from the content-addressed store, hash-verified

1855
1856// link every hole into the outer loop, producing a single-ring polygon without holes
1857function eliminateHoles(data, holeIndices, outerNode, dim) {
1858 var queue = [],
1859 i,
1860 len,
1861 start,
1862 end,
1863 list;
1864
1865 for (i = 0, len = holeIndices.length; i < len; i++) {
1866 start = holeIndices[i] * dim;
1867 end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
1868 list = linkedList(data, start, end, dim, false);
1869 if (list === list.next) list.steiner = true;
1870 queue.push(getLeftmost(list));
1871 }
1872
1873 queue.sort(compareX);
1874
1875 // process holes from left to right
1876 for (i = 0; i < queue.length; i++) {
1877 eliminateHole(queue[i], outerNode);
1878 outerNode = filterPoints(outerNode, outerNode.next);
1879 }
1880
1881 return outerNode;
1882}
1883
1884function compareX(a, b) {
1885 return a.x - b.x;

Callers 1

earcutFunction · 0.85

Calls 5

linkedListFunction · 0.85
getLeftmostFunction · 0.85
eliminateHoleFunction · 0.85
filterPointsFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected