Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
@turf/unkink-polygon
Advanced tools
@turf/unkink-polygon is a module in the Turf.js library that is used to convert polygons with self-intersections (kinks) into simple polygons without self-intersections. This is useful for ensuring that polygon geometries are valid and can be used in various geospatial analyses.
Unkink Polygon
This feature takes a polygon with self-intersections and returns a FeatureCollection of polygons without self-intersections. The code sample demonstrates how to use the `unkinkPolygon` function to process a polygon and output the resulting simple polygons.
const turf = require('@turf/turf');
const unkinkPolygon = require('@turf/unkink-polygon');
const polygon = turf.polygon([[
[-12.034835, 8.901183],
[-12.060413, 8.899826],
[-12.03638, 8.873199],
[-12.059383, 8.871418],
[-12.034835, 8.901183]
]]);
const result = unkinkPolygon(polygon);
console.log(result);
JSTS (JavaScript Topology Suite) is a JavaScript library for processing and analyzing planar geometric objects. It provides a wide range of geometric operations, including the ability to handle self-intersecting polygons. Compared to @turf/unkink-polygon, JSTS offers more comprehensive geometric processing capabilities but may be more complex to use for simple tasks.
Martinez Polygon Clipping is a library for performing boolean operations on polygons, such as union, intersection, difference, and xor. It can handle self-intersecting polygons and is known for its performance. While it provides similar functionality to @turf/unkink-polygon in terms of handling complex polygons, it focuses more on boolean operations rather than just unkinking polygons.
Takes a kinked polygon and returns a feature collection of polygons that have no kinks.
Uses simplepolygon internally.
geojson
(FeatureCollection<(Polygon | MultiPolygon)> | Feature<(Polygon | MultiPolygon)> | Polygon | MultiPolygon) polygons to unkinkconst poly = turf.polygon([[[0, 0], [2, 0], [0, 2], [2, 2], [0, 0]]]);
const result = turf.unkinkPolygon(poly);
//addToMap
const addToMap = [poly, result]
Returns FeatureCollection<Polygon> Unkinked polygons
This module is part of the Turfjs project, an open source module collection dedicated to geographic algorithms. It is maintained in the Turfjs/turf repository, where you can create PRs and issues.
Install this single module individually:
$ npm install @turf/unkink-polygon
Or install the all-encompassing @turf/turf module that includes all modules as functions:
$ npm install @turf/turf
FAQs
turf unkink-polygon module
The npm package @turf/unkink-polygon receives a total of 383,785 weekly downloads. As such, @turf/unkink-polygon popularity was classified as popular.
We found that @turf/unkink-polygon demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.