New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@turf/concave

Package Overview
Dependencies
Maintainers
4
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/concave - npm Package Compare versions

Comparing version 4.7.3 to 5.0.4

main.js

17

index.d.ts

@@ -1,13 +0,12 @@

/// <reference types="geojson" />
import { Point, Feature, FeatureCollection, MultiPolygon, Polygon, Units} from '@turf/helpers'
import {Units} from '@turf/helpers'
type Points = GeoJSON.FeatureCollection<GeoJSON.Point>;
type Polygon = GeoJSON.Feature<GeoJSON.Polygon | GeoJSON.MultiPolygon>;
/**
* http://turfjs.org/docs/#concave
*/
declare function concave(points: Points, maxEdge: number, units?: Units): Polygon;
declare namespace concave { }
export = concave;
export default function concave(
points: FeatureCollection<Point>,
options?: {
maxEdge?: number,
units?: Units
}
): Feature<Polygon | MultiPolygon>;

@@ -1,8 +0,6 @@

var tin = require('@turf/tin');
var helpers = require('@turf/helpers');
var distance = require('@turf/distance');
var dissolve = require('geojson-dissolve');
var featureEach = require('@turf/meta').featureEach;
var feature = helpers.feature;
var featureCollection = helpers.featureCollection;
import tin from '@turf/tin';
import dissolve from './turf-dissolve';
import distance from '@turf/distance';
import { feature, featureCollection, isObject, isNumber } from '@turf/helpers';
import { featureEach } from '@turf/meta';

@@ -15,6 +13,6 @@ /**

* @param {FeatureCollection<Point>} points input points
* @param {number} maxEdge the length (in 'units') of an edge necessary for part of the hull to become concave
* @param {string} [units=kilometers] can be degrees, radians, miles, or kilometers
* @returns {Feature<(Polygon|MultiPolygon)>} a concave hull
* @throws {Error} if maxEdge parameter is missing or unable to compute hull
* @param {Object} [options={}] Optional parameters
* @param {number} [options.maxEdge=Infinity] the length (in 'units') of an edge necessary for part of the hull to become concave.
* @param {string} [options.units='kilometers'] can be degrees, radians, miles, or kilometers
* @returns {Feature<(Polygon|MultiPolygon)>|null} a concave hull (null value is returned if unable to compute hull)
* @example

@@ -29,4 +27,5 @@ * var points = turf.featureCollection([

* ]);
* var options = {units: 'miles', maxEdge: 1};
*
* var hull = turf.concave(points, 1, 'miles');
* var hull = turf.concave(points, options);
*

@@ -36,7 +35,11 @@ * //addToMap

*/
module.exports = function (points, maxEdge, units) {
function concave(points, options) {
// Optional parameters
options = options || {};
if (!isObject(options)) throw new Error('options is invalid');
// validation
if (!points) throw new Error('points is required');
if (maxEdge === undefined || maxEdge === null) throw new Error('maxEdge is required');
if (typeof maxEdge !== 'number') throw new Error('invalid maxEdge');
var maxEdge = options.maxEdge || Infinity;
if (!isNumber(maxEdge)) throw new Error('maxEdge is invalid');

@@ -52,12 +55,13 @@ var cleaned = removeDuplicates(points);

var pt3 = triangle.geometry.coordinates[0][2];
var dist1 = distance(pt1, pt2, units);
var dist2 = distance(pt2, pt3, units);
var dist3 = distance(pt1, pt3, units);
var dist1 = distance(pt1, pt2, options);
var dist2 = distance(pt2, pt3, options);
var dist3 = distance(pt1, pt3, options);
return (dist1 <= maxEdge && dist2 <= maxEdge && dist3 <= maxEdge);
});
if (tinPolys.features.length < 1) throw new Error('too few polygons found to compute concave hull');
if (tinPolys.features.length < 1) return null;
// merge the adjacent triangles
var dissolved = dissolve(tinPolys.features);
var dissolved = dissolve(tinPolys, options);
// geojson-dissolve always returns a MultiPolygon

@@ -69,3 +73,3 @@ if (dissolved.coordinates.length === 1) {

return feature(dissolved);
};
}

@@ -93,1 +97,3 @@ /**

}
export default concave;
{
"name": "@turf/concave",
"version": "4.7.3",
"version": "5.0.4",
"description": "turf concave module",
"main": "index.js",
"main": "main",
"module": "index",
"jsnext:main": "index",
"types": "index.d.ts",
"files": [
"index.js",
"index.d.ts"
"index.d.ts",
"main.js",
"turf-dissolve.js",
"turf-line-dissolve.js",
"turf-polygon-dissolve.js"
],
"scripts": {
"test": "node test.js",
"bench": "node bench.js"
"pretest": "rollup -c ../../rollup.config.js",
"test": "node -r @std/esm test.js",
"bench": "node -r @std/esm bench.js"
},

@@ -43,14 +50,23 @@ "repository": {

"devDependencies": {
"benchmark": "^2.1.4",
"load-json-file": "^2.0.0",
"tape": "^4.6.3",
"write-json-file": "^2.1.4"
"@std/esm": "*",
"benchmark": "*",
"load-json-file": "*",
"rollup": "*",
"tape": "*",
"write-json-file": "*"
},
"dependencies": {
"@turf/distance": "^4.7.3",
"@turf/helpers": "^4.7.3",
"@turf/meta": "^4.7.3",
"@turf/tin": "^4.7.3",
"geojson-dissolve": "3.1.0"
"@turf/clone": "^5.0.4",
"@turf/distance": "^5.0.4",
"@turf/helpers": "^5.0.4",
"@turf/invariant": "^5.0.4",
"@turf/meta": "^5.0.4",
"@turf/tin": "^5.0.4",
"topojson-client": "3.x",
"topojson-server": "3.x"
},
"@std/esm": {
"esm": "js",
"cjs": true
}
}
# @turf/concave
# concave
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
## concave
Takes a set of [points](http://geojson.org/geojson-spec.html#point) and returns a concave hull Polygon or MultiPolygon.

@@ -11,4 +13,5 @@ Internally, this uses [turf-tin](https://github.com/Turfjs/turf-tin) to generate geometries.

- `points` **[FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects)&lt;[Point](http://geojson.org/geojson-spec.html#point)>** input points
- `maxEdge` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the length (in 'units') of an edge necessary for part of the hull to become concave
- `units` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** can be degrees, radians, miles, or kilometers (optional, default `kilometers`)
- `options` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Optional parameters (optional, default `{}`)
- `options.maxEdge` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the length (in 'units') of an edge necessary for part of the hull to become concave. (optional, default `Infinity`)
- `options.units` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** can be degrees, radians, miles, or kilometers (optional, default `'kilometers'`)

@@ -26,4 +29,5 @@ **Examples**

]);
var options = {units: 'miles', maxEdge: 1};
var hull = turf.concave(points, 1, 'miles');
var hull = turf.concave(points, options);

@@ -34,6 +38,4 @@ //addToMap

- Throws **[Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)** if maxEdge parameter is missing or unable to compute hull
Returns **([Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;([Polygon](http://geojson.org/geojson-spec.html#polygon) \| [MultiPolygon](http://geojson.org/geojson-spec.html#multipolygon))> | null)** a concave hull (null value is returned if unable to compute hull)
Returns **[Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;([Polygon](http://geojson.org/geojson-spec.html#polygon) \| [MultiPolygon](http://geojson.org/geojson-spec.html#multipolygon))>** a concave hull
<!-- This file is automatically generated. Please don't edit it directly:

@@ -40,0 +42,0 @@ if you find an error, edit the source file (likely index.js), and re-run

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc