@turf/voronoi
Advanced tools
Comparing version 6.2.0-alpha.2 to 6.2.0-alpha.3
@@ -11,5 +11,5 @@ import { polygon, featureCollection, isObject } from '@turf/helpers'; | ||
function coordsToPolygon(coords) { | ||
coords = coords.slice(); | ||
coords.push(coords[0]); | ||
return polygon([coords]); | ||
coords = coords.slice(); | ||
coords.push(coords[0]); | ||
return polygon([coords]); | ||
} | ||
@@ -39,23 +39,30 @@ | ||
function voronoi$1(points, options) { | ||
// Optional params | ||
options = options || {}; | ||
if (!isObject(options)) throw new Error('options is invalid'); | ||
var bbox = options.bbox || [-180, -85, 180, 85]; | ||
// Optional params | ||
options = options || {}; | ||
if (!isObject(options)) throw new Error("options is invalid"); | ||
var bbox = options.bbox || [-180, -85, 180, 85]; | ||
// Input Validation | ||
if (!points) throw new Error('points is required'); | ||
if (!Array.isArray(bbox)) throw new Error('bbox is invalid'); | ||
collectionOf(points, 'Point', 'points'); | ||
// Input Validation | ||
if (!points) throw new Error("points is required"); | ||
if (!Array.isArray(bbox)) throw new Error("bbox is invalid"); | ||
collectionOf(points, "Point", "points"); | ||
// Main | ||
return featureCollection( | ||
voronoi() | ||
.x(function (feature) { return feature.geometry.coordinates[0]; }) | ||
.y(function (feature) { return feature.geometry.coordinates[1]; }) | ||
.extent([[bbox[0], bbox[1]], [bbox[2], bbox[3]]]) | ||
.polygons(points.features) | ||
.map(coordsToPolygon) | ||
); | ||
// Main | ||
return featureCollection( | ||
voronoi() | ||
.x(function (feature) { | ||
return feature.geometry.coordinates[0]; | ||
}) | ||
.y(function (feature) { | ||
return feature.geometry.coordinates[1]; | ||
}) | ||
.extent([ | ||
[bbox[0], bbox[1]], | ||
[bbox[2], bbox[3]], | ||
]) | ||
.polygons(points.features) | ||
.map(coordsToPolygon) | ||
); | ||
} | ||
export default voronoi$1; |
@@ -13,5 +13,5 @@ 'use strict'; | ||
function coordsToPolygon(coords) { | ||
coords = coords.slice(); | ||
coords.push(coords[0]); | ||
return helpers.polygon([coords]); | ||
coords = coords.slice(); | ||
coords.push(coords[0]); | ||
return helpers.polygon([coords]); | ||
} | ||
@@ -41,24 +41,30 @@ | ||
function voronoi(points, options) { | ||
// Optional params | ||
options = options || {}; | ||
if (!helpers.isObject(options)) throw new Error('options is invalid'); | ||
var bbox = options.bbox || [-180, -85, 180, 85]; | ||
// Optional params | ||
options = options || {}; | ||
if (!helpers.isObject(options)) throw new Error("options is invalid"); | ||
var bbox = options.bbox || [-180, -85, 180, 85]; | ||
// Input Validation | ||
if (!points) throw new Error('points is required'); | ||
if (!Array.isArray(bbox)) throw new Error('bbox is invalid'); | ||
invariant.collectionOf(points, 'Point', 'points'); | ||
// Input Validation | ||
if (!points) throw new Error("points is required"); | ||
if (!Array.isArray(bbox)) throw new Error("bbox is invalid"); | ||
invariant.collectionOf(points, "Point", "points"); | ||
// Main | ||
return helpers.featureCollection( | ||
d3voronoi.voronoi() | ||
.x(function (feature) { return feature.geometry.coordinates[0]; }) | ||
.y(function (feature) { return feature.geometry.coordinates[1]; }) | ||
.extent([[bbox[0], bbox[1]], [bbox[2], bbox[3]]]) | ||
.polygons(points.features) | ||
.map(coordsToPolygon) | ||
); | ||
// Main | ||
return helpers.featureCollection( | ||
d3voronoi.voronoi() | ||
.x(function (feature) { | ||
return feature.geometry.coordinates[0]; | ||
}) | ||
.y(function (feature) { | ||
return feature.geometry.coordinates[1]; | ||
}) | ||
.extent([ | ||
[bbox[0], bbox[1]], | ||
[bbox[2], bbox[3]], | ||
]) | ||
.polygons(points.features) | ||
.map(coordsToPolygon) | ||
); | ||
} | ||
module.exports = voronoi; | ||
module.exports.default = voronoi; |
@@ -1,2 +0,2 @@ | ||
import { FeatureCollection, BBox, Point, Polygon } from '@turf/helpers'; | ||
import { FeatureCollection, BBox, Point, Polygon } from "@turf/helpers"; | ||
@@ -7,4 +7,4 @@ /** | ||
export default function voronoi( | ||
points: FeatureCollection<Point>, | ||
options: {bbox: BBox} | ||
points: FeatureCollection<Point>, | ||
options: { bbox: BBox } | ||
): FeatureCollection<Polygon>; |
{ | ||
"name": "@turf/voronoi", | ||
"version": "6.2.0-alpha.2", | ||
"version": "6.2.0-alpha.3", | ||
"description": "turf voronoi module", | ||
@@ -33,2 +33,6 @@ "author": "Turf Authors", | ||
"module": "dist/es/index.js", | ||
"exports": { | ||
"import": "./dist/es/index.js", | ||
"require": "./dist/js/index.js" | ||
}, | ||
"types": "index.d.ts", | ||
@@ -41,8 +45,7 @@ "sideEffects": false, | ||
"scripts": { | ||
"bench": "npm-run-all prepare bench:run", | ||
"bench:run": "node bench.js", | ||
"bench": "node -r esm bench.js", | ||
"build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json", | ||
"docs": "node ../../scripts/generate-readmes", | ||
"posttest": "node -r esm ../../scripts/validate-es5-dependencies.js", | ||
"prepare": "rollup -c ../../rollup.config.js", | ||
"test": "npm-run-all prepare test:*", | ||
"test": "npm-run-all test:*", | ||
"test:tape": "node -r esm test.js" | ||
@@ -60,7 +63,7 @@ }, | ||
"dependencies": { | ||
"@turf/helpers": "^6.2.0-alpha.2", | ||
"@turf/invariant": "^6.2.0-alpha.2", | ||
"@turf/helpers": "^6.2.0-alpha.3", | ||
"@turf/invariant": "^6.2.0-alpha.3", | ||
"d3-voronoi": "1.1.2" | ||
}, | ||
"gitHead": "23d5cb91d77e0c1e2e903a2252f525797f1d0d09" | ||
"gitHead": "dce9edfc705352e8cb9e0083c9330ba0e8d77409" | ||
} |
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
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
12938
9
241