@turf/convex
Advanced tools
Comparing version 6.5.0 to 7.0.0-alpha.0
@@ -1,2 +0,2 @@ | ||
import { polygon, } from "@turf/helpers"; | ||
import { polygon } from "@turf/helpers"; | ||
import { coordEach } from "@turf/meta"; | ||
@@ -32,10 +32,9 @@ import concaveman from "concaveman"; | ||
*/ | ||
export default function convex(geojson, options) { | ||
if (options === void 0) { options = {}; } | ||
export default function convex(geojson, options = {}) { | ||
// Default parameters | ||
options.concavity = options.concavity || Infinity; | ||
// Container | ||
var points = []; | ||
const points = []; | ||
// Convert all points to flat 2D coordinate Array | ||
coordEach(geojson, function (coord) { | ||
coordEach(geojson, (coord) => { | ||
points.push([coord[0], coord[1]]); | ||
@@ -46,3 +45,3 @@ }); | ||
} | ||
var convexHull = concaveman(points, options.concavity); | ||
const convexHull = concaveman(points, options.concavity); | ||
// Convex hull should have at least 3 different vertices in order to create a valid polygon | ||
@@ -49,0 +48,0 @@ if (convexHull.length > 3) { |
@@ -1,2 +0,3 @@ | ||
import { AllGeoJSON, Feature, Polygon, Properties } from "@turf/helpers"; | ||
import { Feature, GeoJsonProperties, Polygon } from "geojson"; | ||
import { AllGeoJSON } from "@turf/helpers"; | ||
/** | ||
@@ -30,5 +31,5 @@ * Takes a {@link Feature} or a {@link FeatureCollection} and returns a convex hull {@link Polygon}. | ||
*/ | ||
export default function convex<P = Properties>(geojson: AllGeoJSON, options?: { | ||
export default function convex<P = GeoJsonProperties>(geojson: AllGeoJSON, options?: { | ||
concavity?: number; | ||
properties?: P; | ||
}): Feature<Polygon, P> | null; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var helpers_1 = require("@turf/helpers"); | ||
var meta_1 = require("@turf/meta"); | ||
var concaveman_1 = __importDefault(require("concaveman")); | ||
const tslib_1 = require("tslib"); | ||
const helpers_1 = require("@turf/helpers"); | ||
const meta_1 = require("@turf/meta"); | ||
const concaveman_1 = tslib_1.__importDefault(require("concaveman")); | ||
/** | ||
@@ -37,10 +35,9 @@ * Takes a {@link Feature} or a {@link FeatureCollection} and returns a convex hull {@link Polygon}. | ||
*/ | ||
function convex(geojson, options) { | ||
if (options === void 0) { options = {}; } | ||
function convex(geojson, options = {}) { | ||
// Default parameters | ||
options.concavity = options.concavity || Infinity; | ||
// Container | ||
var points = []; | ||
const points = []; | ||
// Convert all points to flat 2D coordinate Array | ||
meta_1.coordEach(geojson, function (coord) { | ||
meta_1.coordEach(geojson, (coord) => { | ||
points.push([coord[0], coord[1]]); | ||
@@ -51,3 +48,3 @@ }); | ||
} | ||
var convexHull = concaveman_1.default(points, options.concavity); | ||
const convexHull = concaveman_1.default(points, options.concavity); | ||
// Convex hull should have at least 3 different vertices in order to create a valid polygon | ||
@@ -54,0 +51,0 @@ if (convexHull.length > 3) { |
{ | ||
"name": "@turf/convex", | ||
"version": "6.5.0", | ||
"version": "7.0.0-alpha.0", | ||
"description": "turf convex module", | ||
@@ -47,3 +47,3 @@ "author": "Turf Authors", | ||
"devDependencies": { | ||
"@types/concaveman": "*", | ||
"@types/concaveman": "^1.1.3", | ||
"@types/tape": "*", | ||
@@ -61,7 +61,8 @@ "benchmark": "*", | ||
"dependencies": { | ||
"@turf/helpers": "^6.5.0", | ||
"@turf/meta": "^6.5.0", | ||
"concaveman": "*" | ||
"@turf/helpers": "^7.0.0-alpha.0", | ||
"@turf/meta": "^7.0.0-alpha.0", | ||
"concaveman": "^1.2.1", | ||
"tslib": "^2.3.0" | ||
}, | ||
"gitHead": "5375941072b90d489389db22b43bfe809d5e451e" | ||
"gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189" | ||
} |
@@ -10,14 +10,15 @@ # @turf/convex | ||
Internally this uses | ||
the [convex-hull][4] module that | ||
implements a [monotone chain hull][5]. | ||
the [convex-hull][4] module that implements a | ||
[monotone chain hull][5]. | ||
**Parameters** | ||
### Parameters | ||
- `geojson` **[GeoJSON][6]** input Feature or FeatureCollection | ||
- `options` **[Object][7]** Optional parameters (optional, default `{}`) | ||
- `options.concavity` **[number][8]** 1 - thin shape. Infinity - convex hull. (optional, default `Infinity`) | ||
- `options.properties` **[Object][7]** Translate Properties to Feature (optional, default `{}`) | ||
* `geojson` **[GeoJSON][6]** input Feature or FeatureCollection | ||
* `options` **[Object][7]** Optional parameters (optional, default `{}`) | ||
**Examples** | ||
* `options.concavity` **[number][8]** 1 - thin shape. Infinity - convex hull. (optional, default `Infinity`) | ||
* `options.properties` **[Object][7]** Translate Properties to Feature (optional, default `{}`) | ||
### Examples | ||
```javascript | ||
@@ -39,3 +40,3 @@ var points = turf.featureCollection([ | ||
Returns **[Feature][9]<[Polygon][10]>** a convex hull | ||
Returns **[Feature][9]<[Polygon][10]>** a convex hull | ||
@@ -42,0 +43,0 @@ [1]: https://tools.ietf.org/html/rfc7946#section-3.2 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
0
85
10330
4
138
1
+ Addedtslib@^2.3.0
+ Added@turf/helpers@7.2.0(transitive)
+ Added@turf/meta@7.2.0(transitive)
+ Added@types/geojson@7946.0.15(transitive)
+ Addedtslib@2.8.1(transitive)
- Removed@turf/helpers@6.5.0(transitive)
- Removed@turf/meta@6.5.0(transitive)
Updated@turf/helpers@^7.0.0-alpha.0
Updated@turf/meta@^7.0.0-alpha.0
Updatedconcaveman@^1.2.1