@turf/random
Advanced tools
Comparing version 7.1.0-alpha.7 to 7.1.0-alpha.70
@@ -49,2 +49,5 @@ // index.ts | ||
} | ||
if (options.bbox === void 0 || options.bbox === null) { | ||
options.bbox = [-180, -90, 180, 90]; | ||
} | ||
if (!isNumber(options.num_vertices) || options.num_vertices === void 0) { | ||
@@ -56,2 +59,14 @@ options.num_vertices = 10; | ||
} | ||
const bboxWidth = Math.abs(options.bbox[0] - options.bbox[2]); | ||
const bboxHeight = Math.abs(options.bbox[1] - options.bbox[3]); | ||
const maxRadius = Math.min(bboxWidth / 2, bboxHeight / 2); | ||
if (options.max_radial_length > maxRadius) { | ||
throw new Error("max_radial_length is greater than the radius of the bbox"); | ||
} | ||
const paddedBbox = [ | ||
options.bbox[0] + options.max_radial_length, | ||
options.bbox[1] + options.max_radial_length, | ||
options.bbox[2] - options.max_radial_length, | ||
options.bbox[3] - options.max_radial_length | ||
]; | ||
const features = []; | ||
@@ -74,3 +89,3 @@ for (let i = 0; i < count; i++) { | ||
vertices = vertices.map( | ||
vertexToCoordinate(randomPositionUnchecked(options.bbox)) | ||
vertexToCoordinate(randomPositionUnchecked(paddedBbox)) | ||
); | ||
@@ -77,0 +92,0 @@ features.push(polygon([vertices])); |
{ | ||
"name": "@turf/random", | ||
"version": "7.1.0-alpha.7+0ce6ecca0", | ||
"version": "7.1.0-alpha.70+948cdafaf", | ||
"description": "turf random module", | ||
@@ -63,6 +63,7 @@ "author": "Turf Authors", | ||
"dependencies": { | ||
"@turf/helpers": "^7.1.0-alpha.7+0ce6ecca0", | ||
"@turf/helpers": "^7.1.0-alpha.70+948cdafaf", | ||
"@types/geojson": "^7946.0.10", | ||
"tslib": "^2.6.2" | ||
}, | ||
"gitHead": "0ce6ecca05829690270fec6d6bed2003495fe0ea" | ||
"gitHead": "948cdafaf70606d2e27fcc79973fa48ee1182067" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
48830
382
3