@turf/convex
Advanced tools
Comparing version 5.1.5 to 6.0.0
32
index.js
@@ -1,5 +0,6 @@ | ||
import concaveman from 'concaveman'; | ||
import { coordEach } from '@turf/meta'; | ||
import { polygon, isObject } from '@turf/helpers'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var concaveman_1 = require("concaveman"); | ||
var meta_1 = require("@turf/meta"); | ||
var helpers_1 = require("@turf/helpers"); | ||
/** | ||
@@ -33,23 +34,20 @@ * Takes a {@link Feature} or a {@link FeatureCollection} and returns a convex hull {@link Polygon}. | ||
function convex(geojson, options) { | ||
// Optional parameters | ||
options = options || {}; | ||
if (!isObject(options)) throw new Error('options is invalid'); | ||
var concavity = options.concavity || Infinity; | ||
if (options === void 0) { options = {}; } | ||
// Default parameters | ||
options.concavity = options.concavity || Infinity; | ||
// Container | ||
var points = []; | ||
// Convert all points to flat 2D coordinate Array | ||
coordEach(geojson, function (coord) { | ||
meta_1.coordEach(geojson, function (coord) { | ||
points.push([coord[0], coord[1]]); | ||
}); | ||
if (!points.length) return null; | ||
var convexHull = concaveman(points, concavity); | ||
if (!points.length) | ||
return null; | ||
var convexHull = concaveman_1.default(points, options.concavity); | ||
// Convex hull should have at least 3 different vertices in order to create a valid polygon | ||
if (convexHull.length > 3) { | ||
return polygon([convexHull]); | ||
return helpers_1.polygon([convexHull]); | ||
} | ||
return null; | ||
} | ||
export default convex; | ||
exports.default = convex; |
{ | ||
"name": "@turf/convex", | ||
"version": "5.1.5", | ||
"version": "6.0.0", | ||
"description": "turf convex module", | ||
"main": "main.js", | ||
"module": "main.es.js", | ||
"types": "index.d.ts", | ||
"main": "index", | ||
"files": [ | ||
"index.js", | ||
"index.d.ts", | ||
"main.js", | ||
"main.es.js" | ||
"index.ts" | ||
], | ||
"scripts": { | ||
"pretest": "rollup -c ../../rollup.config.js", | ||
"test": "node -r @std/esm test.js", | ||
"posttest": "node -r @std/esm ../../scripts/validate-es5-dependencies.js", | ||
"bench": "node -r @std/esm bench.js", | ||
"prepare": "tsc", | ||
"pretest": "tsc", | ||
"test": "node test.js", | ||
"bench": "node bench.js", | ||
"docs": "node ../../scripts/generate-readmes" | ||
@@ -36,7 +32,6 @@ }, | ||
"devDependencies": { | ||
"@std/esm": "*", | ||
"benchmark": "*", | ||
"glob": "*", | ||
"load-json-file": "*", | ||
"rollup": "*", | ||
"typescript": "*", | ||
"tape": "*", | ||
@@ -46,10 +41,6 @@ "write-json-file": "*" | ||
"dependencies": { | ||
"@turf/helpers": "^5.1.5", | ||
"@turf/meta": "^5.1.5", | ||
"@turf/helpers": "6.x", | ||
"@turf/meta": "6.x", | ||
"concaveman": "*" | ||
}, | ||
"@std/esm": { | ||
"esm": "js", | ||
"cjs": true | ||
} | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
6
7987
5
103
1
+ Added@turf/helpers@6.5.0(transitive)
+ Added@turf/meta@6.5.0(transitive)
- Removed@turf/helpers@5.1.5(transitive)
- Removed@turf/meta@5.2.0(transitive)
Updated@turf/helpers@6.x
Updated@turf/meta@6.x