Comparing version 0.2.0 to 1.0.0
24
index.js
module.exports = function(bbox, factor){ | ||
var currentXDistance = (bbox[2] - bbox[0]) | ||
var currentYDistance = (bbox[3] - bbox[1]) | ||
var newXDistance = currentXDistance * factor | ||
var newYDistance = currentYDistance * factor | ||
var xChange = newXDistance - currentXDistance | ||
var yChange = newYDistance - currentYDistance | ||
var currentXDistance = (bbox[2] - bbox[0]); | ||
var currentYDistance = (bbox[3] - bbox[1]); | ||
var newXDistance = currentXDistance * factor; | ||
var newYDistance = currentYDistance * factor; | ||
var xChange = newXDistance - currentXDistance; | ||
var yChange = newYDistance - currentYDistance; | ||
var lowX = bbox[0] - (xChange / 2) | ||
var lowY = bbox[1] - (yChange / 2) | ||
var highX = (xChange / 2) + bbox[2] | ||
var highY = (yChange / 2) + bbox[3] | ||
var lowX = bbox[0] - (xChange / 2); | ||
var lowY = bbox[1] - (yChange / 2); | ||
var highX = (xChange / 2) + bbox[2]; | ||
var highY = (yChange / 2) + bbox[3]; | ||
var sized = [lowX, lowY, highX, highY] | ||
return sized | ||
var sized = [lowX, lowY, highX, highY]; | ||
return sized; | ||
} |
{ | ||
"name": "turf-size", | ||
"version": "0.2.0", | ||
"version": "1.0.0", | ||
"description": "turf size module", | ||
@@ -27,4 +27,5 @@ "main": "index.js", | ||
"devDependencies": { | ||
"tape": "^2.12.3" | ||
"benchmark": "^1.0.0", | ||
"tape": "^2.13.4" | ||
} | ||
} |
@@ -7,3 +7,24 @@ turf-size | ||
###Install | ||
```sh | ||
npm install turf-size | ||
``` | ||
###Parameters | ||
|name|description| | ||
|---|---| | ||
|bbox|[xmin, ymin, xmay, ymax]| | ||
|factor|the factor to increase or decrease size by| | ||
###Usage | ||
```js | ||
size(bbox, factor) | ||
``` | ||
###Example | ||
```js | ||
var bbox = [0, 0, 10, 10] | ||
@@ -10,0 +31,0 @@ |
50
test.js
@@ -1,34 +0,34 @@ | ||
var test = require('tape') | ||
var size = require('./') | ||
var test = require('tape'); | ||
var size = require('./'); | ||
test('size', function(t){ | ||
var bbox = [0, 0, 10, 10] | ||
var sized = size(bbox, 2) | ||
t.deepEqual(sized, [-5, -5, 15, 15], 'should double the size of a bbox at 0,0,10,10') | ||
var bbox = [0, 0, 10, 10]; | ||
var sized = size(bbox, 2); | ||
t.deepEqual(sized, [-5, -5, 15, 15], 'should double the size of a bbox at 0,0,10,10'); | ||
var bbox = [0, 0, 4, 4] | ||
var sized = size(bbox, 1) | ||
t.deepEqual(sized, [0, 0, 4, 4], 'should do nothing to the size of a bbox at 0,0,4,4') | ||
var bbox = [0, 0, 4, 4]; | ||
var sized = size(bbox, 1); | ||
t.deepEqual(sized, [0, 0, 4, 4], 'should do nothing to the size of a bbox at 0,0,4,4'); | ||
var bbox = [0, 0, 4, 4] | ||
var sized = size(bbox, 2) | ||
t.deepEqual(sized, [-2, -2, 6, 6], 'should double the size of a bbox at 0,0,4,4') | ||
var bbox = [0, 0, 4, 4]; | ||
var sized = size(bbox, 2); | ||
t.deepEqual(sized, [-2, -2, 6, 6], 'should double the size of a bbox at 0,0,4,4'); | ||
var bbox = [0, 0, 4, 4] | ||
var sized = size(bbox, 0.5) | ||
t.deepEqual(sized, [1, 1, 3, 3], 'should shrink a bbox by 50% at 0,0,4,4') | ||
var bbox = [0, 0, 4, 4]; | ||
var sized = size(bbox, 0.5); | ||
t.deepEqual(sized, [1, 1, 3, 3], 'should shrink a bbox by 50% at 0,0,4,4'); | ||
var bbox = [-10, -10, 0, 0] | ||
var sized = size(bbox, 2) | ||
t.deepEqual(sized, [-15, -15, 5, 5], 'should double the size of a bbox at -10,-10') | ||
var bbox = [-10, -10, 0, 0]; | ||
var sized = size(bbox, 2); | ||
t.deepEqual(sized, [-15, -15, 5, 5], 'should double the size of a bbox at -10,-10'); | ||
var bbox = [0, 0, 10, 10] | ||
var sized = size(bbox, 1.5) | ||
t.deepEqual(sized, [-2.5, -2.5, 12.5, 12.5], 'should expand the size of a bbox by 50% at 0,0,10,10') | ||
var bbox = [0, 0, 10, 10]; | ||
var sized = size(bbox, 1.5); | ||
t.deepEqual(sized, [-2.5, -2.5, 12.5, 12.5], 'should expand the size of a bbox by 50% at 0,0,10,10'); | ||
var bbox = [0, 0, 10, 10] | ||
var sized = size(bbox, 0.5) | ||
t.deepEqual(sized, [2.5, 2.5, 7.5, 7.5], 'should shrink a bbox by 50%') | ||
var bbox = [0, 0, 10, 10]; | ||
var sized = size(bbox, 0.5); | ||
t.deepEqual(sized, [2.5, 2.5, 7.5, 7.5], 'should shrink a bbox by 50%'); | ||
t.end() | ||
}) | ||
t.end(); | ||
}); |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
4898
8
55
0
34
2
1