Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@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.
Parameters
geojson
(FeatureCollection | Feature<(Polygon | MultiPolygon)>) GeoJSON Polygon or MultiPolygonExamples
var poly = turf.polygon([[[0, 0], [2, 0], [0, 2], [2, 2], [0, 0]]]);
var result = turf.unkinkPolygon(poly);
//addToMap
var 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 module individually:
$ npm install @turf/unkink-polygon
Or install the Turf module that includes it as a function:
$ npm install @turf/turf
FAQs
turf unkink-polygon module
The npm package @turf/unkink-polygon receives a total of 749,643 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.