turf-square
Advanced tools
Comparing version 0.1.3 to 1.0.0
44
index.js
@@ -1,31 +0,31 @@ | ||
var midpoint = require('turf-midpoint') | ||
var point = require('turf-point') | ||
var distance = require('turf-distance') | ||
var midpoint = require('turf-midpoint'); | ||
var point = require('turf-point'); | ||
var distance = require('turf-distance'); | ||
module.exports = function(bbox){ | ||
var squareBbox = [0,0,0,0] | ||
var lowLeft = point(bbox[0], bbox[1]) | ||
var topLeft = point(bbox[0], bbox[3]) | ||
var topRight = point(bbox[2], bbox[3]) | ||
var lowRight = point(bbox[2], bbox[1]) | ||
var squareBbox = [0,0,0,0]; | ||
var lowLeft = point(bbox[0], bbox[1]); | ||
var topLeft = point(bbox[0], bbox[3]); | ||
var topRight = point(bbox[2], bbox[3]); | ||
var lowRight = point(bbox[2], bbox[1]); | ||
var horizontalDistance = distance(lowLeft, lowRight, 'miles') | ||
var verticalDistance = distance(lowLeft, topLeft, 'miles') | ||
var horizontalDistance = distance(lowLeft, lowRight, 'miles'); | ||
var verticalDistance = distance(lowLeft, topLeft, 'miles'); | ||
if(horizontalDistance >= verticalDistance){ | ||
squareBbox[0] = bbox[0] | ||
squareBbox[2] = bbox[2] | ||
var verticalMidpoint = midpoint(lowLeft, topLeft) | ||
squareBbox[1] = verticalMidpoint.geometry.coordinates[1] - ((bbox[2] - bbox[0]) / 2) | ||
squareBbox[3] = verticalMidpoint.geometry.coordinates[1] + ((bbox[2] - bbox[0]) / 2) | ||
return squareBbox | ||
squareBbox[0] = bbox[0]; | ||
squareBbox[2] = bbox[2]; | ||
var verticalMidpoint = midpoint(lowLeft, topLeft); | ||
squareBbox[1] = verticalMidpoint.geometry.coordinates[1] - ((bbox[2] - bbox[0]) / 2); | ||
squareBbox[3] = verticalMidpoint.geometry.coordinates[1] + ((bbox[2] - bbox[0]) / 2); | ||
return squareBbox; | ||
} | ||
else { | ||
squareBbox[1] = bbox[1] | ||
squareBbox[3] = bbox[3] | ||
var horzontalMidpoint = midpoint(lowLeft, lowRight) | ||
squareBbox[0] = horzontalMidpoint.geometry.coordinates[0] - ((bbox[3] - bbox[1]) / 2) | ||
squareBbox[2] = horzontalMidpoint.geometry.coordinates[0] + ((bbox[3] - bbox[1]) / 2) | ||
return squareBbox | ||
squareBbox[1] = bbox[1]; | ||
squareBbox[3] = bbox[3]; | ||
var horzontalMidpoint = midpoint(lowLeft, lowRight); | ||
squareBbox[0] = horzontalMidpoint.geometry.coordinates[0] - ((bbox[3] - bbox[1]) / 2); | ||
squareBbox[2] = horzontalMidpoint.geometry.coordinates[0] + ((bbox[3] - bbox[1]) / 2); | ||
return squareBbox; | ||
} | ||
} | ||
{ | ||
"name": "turf-square", | ||
"version": "0.1.3", | ||
"version": "1.0.0", | ||
"description": "turf square module", | ||
@@ -26,9 +26,10 @@ "main": "index.js", | ||
"devDependencies": { | ||
"tape": "^2.13.4" | ||
"benchmark": "^1.0.0", | ||
"tape": "^3.0.3" | ||
}, | ||
"dependencies": { | ||
"turf-distance": "^0.1.4", | ||
"turf-midpoint": "^0.1.2", | ||
"turf-point": "^0.1.1" | ||
"turf-distance": "^0.1.5", | ||
"turf-midpoint": "^0.1.3", | ||
"turf-point": "^1.2.0" | ||
} | ||
} |
18
test.js
@@ -1,14 +0,14 @@ | ||
var test = require('tape') | ||
var square = require('./') | ||
var test = require('tape'); | ||
var square = require('./'); | ||
test('square', function(t){ | ||
var bbox1 = [0,0,5,10] | ||
var bbox2 = [0,0,10,5] | ||
var bbox1 = [0,0,5,10]; | ||
var bbox2 = [0,0,10,5]; | ||
var sq1 = square(bbox1) | ||
var sq2 = square(bbox2) | ||
var sq1 = square(bbox1); | ||
var sq2 = square(bbox2); | ||
t.deepEqual(sq1, [-2.5, 0, 7.5, 10]) | ||
t.deepEqual(sq2, [0, -2.5, 10, 7.5]) | ||
t.end() | ||
t.deepEqual(sq1, [-2.5, 0, 7.5, 10]); | ||
t.deepEqual(sq2, [0, -2.5, 10, 7.5]); | ||
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
4723
8
52
0
2
1
+ Addedminimist@1.2.8(transitive)
+ Addedturf-point@1.2.1(transitive)
Updatedturf-distance@^0.1.5
Updatedturf-midpoint@^0.1.3
Updatedturf-point@^1.2.0