question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@turf/kinks and @turf/unkink-polygon

See original GitHub issue

The kinks package detects self-intersection in the following shape: https://gist.github.com/polizz/53bfb5d8cd0e7cac09ae6543e1c89528. When I run the shape through unkink-polygon, I get the same shape back out. Not sure what is wrong here. The unkink-polygon function does work on other self-intersecting polygons. Let me know if I can provide more information.

export function removeDuplicatesAndFormatGeoJson(wkt) {
  try {
    let cleanGeom = clean(parse(wkt));
    const hasKinks = get(kinks(cleanGeom), 'features[0].geometry', false);

    if (hasKinks) {
      const unkinked = unkink(cleanGeom);
...

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
barnabas-avalaracommented, Oct 3, 2018

Hi @DenisCarriere. I had to re-implement kink and unkinkPolygon functions in my own project because of this issue. It’s ES6 and a little brute-force but it does the job. Cheers!

https://gist.github.com/barnabas-avalara/2a9d9be5edd84fe2da8e769a9a9c509e

0reactions
DenisCarrierecommented, Jan 9, 2018

👍 @rowanwins Agreed, having both modules align would be the best approach using geojson-polygon-self-intersections, unfortunately that’s not a quick fix and would require some serious effort in making that modification.

Read more comments on GitHub >

github_iconTop Results From Across the Web

turf-kinks - Find all self-intersections of a given Polygon - GitHub
Takes a Polygon|polygon and returns Point|points at all self-intersections. Parameters. parameter, type, description. polygon, Feature ...
Read more >
@turf/kinks - npm
Start using @turf/kinks in your project by running `npm i @turf/kinks`. There are 33 other projects in the npm registry using @turf/kinks.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found