Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

turf-square

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

turf-square - npm Package Compare versions

Comparing version 0.1.3 to 1.0.0

bench.js

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"
}
}

@@ -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();
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc