Turfjs / Turfjs/turf

@turf/unkink-polygon v7.2.0 eliminates holes in polygons

Open
#2,869 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
10.5k
Forks
1k
Avg merge
1h 11m
Merged PRs (30d)
4

Description

The following Jest test calls unkink-polygon with a simple polygon consisting of a square with a square hole. This polygon has no kinks, so unkink should return the same feature back. Instead it returns two features, one being a polygon in the shape of the square but without any hole, and the other a square polygon in the shape of the hole.

import {polygon} from '@turf/helpers';
import unkinkPolygon from '@turf/unkink-polygon';

describe('@turf/unkink-polygon', () => {
  it('should work unkinking a square with a hole', () => {
    const feature = polygon([
      [[20,20],[0,20],[0,0],[20,0],[20,20]],
      [[15,15],[5,15],[5,5],[15,5],[15,15]]
    ]);
    const result = unkinkPolygon(feature);
    expect(result.features.length).toBe(1); // gets 2 features instead!
    expect(result.features[0]).toEqual(feature); // expect fails!
  });
});

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the @turf/unkink-polygon entry point and reproduce the supplied Jest case using a square with a square hole. Trace how the input feature is processed when it has no kinks. Done means the result contains one feature equal to the original polygon, including its hole.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.