Skip to content

Union with empty polygon results in error #5

@nene

Description

@nene

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions