polygon-tools icon indicating copy to clipboard operation
polygon-tools copied to clipboard

Union with empty polygon results in error

Open nene opened this issue 6 months ago • 0 comments

When performing union of non-empty polygon and empty polygon, the union works as expected:

  const nonEmpty = [
    [0, 0],
    [0, 1],
    [1, 1],
    [1, 0],
  ];
  const empty = [
    [0, 0],
    [0, 0],
    [0, 0],
    [0, 0],
  ];
  polygon.union(nonEmpty, empty)
  // returns:
  // [
  //   [
  //     [1, 1],
  //     [0, 1],
  //     [0, 0],
  //     [1, 0],
  //   ]
  // ]

However doing it the other way around causes an error:

polygon.union(empty, nonEmpty)
TypeError: Invalid attempt to destructure non-iterable instance
 ❯ node_modules/polygon-tools/lib/tesselator.js:8:585
 ❯ Tesselator.run node_modules/polygon-tools/lib/tesselator.js:234:19
 ❯ Object.run node_modules/polygon-tools/lib/tesselator.js:354:27
 ❯ Object.union node_modules/polygon-tools/lib/polygon.js:346:15

Using polygon-tools 0.4.8

nene avatar Aug 23 '25 14:08 nene