Socket
Socket
Sign inDemoInstall

bbox-aspect-ratio

Package Overview
Dependencies
1
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.0.1

2

dist/index.js

@@ -1,2 +0,2 @@

var t=require("@turf/turf"),e=function(t,n){return 0===n?t:e(n,t%n)};exports.calculateSizeFromAspectRatio=function(t,e){return Math.ceil(t[1]*e/t[0])},exports.default=function(n){var r,o,i,c,u,a=t.bboxPolygon(n).geometry.coordinates[0],f=t.distance(t.point(a[0]),t.point(a[3])),l=t.distance(t.point(a[0]),t.point(a[1]));return function(t,e,n){return[t/n,e/n]}(c=(i=(r=Math.ceil(l))<(o=Math.ceil(f))?[o,r]:[r,o])[0],u=i[1],e(c,u))};
var r={meters:6371008.8,metres:6371008.8,millimeters:6371008800,millimetres:6371008800,centimeters:637100880,centimetres:637100880,kilometers:6371.0088,kilometres:6371.0088,miles:3958.761333810546,nauticalmiles:6371008.8/1852,inches:6371008.8*39.37,yards:6371008.8/1.0936,feet:20902260.511392,radians:1,degrees:6371008.8/111325};function t(r,t,e){if(!i(e=e||{}))throw new Error("options is invalid");var o=e.bbox,n=e.id;if(void 0===r)throw new Error("geometry is required");if(t&&t.constructor!==Object)throw new Error("properties must be an Object");o&&s(o),n&&function(r){if(!r)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof r))throw new Error("id must be a number or a string")}(n);var a={type:"Feature"};return n&&(a.id=n),o&&(a.bbox=o),a.properties=t||{},a.geometry=r,a}function e(r,e,o){if(!r)throw new Error("coordinates is required");if(!Array.isArray(r))throw new Error("coordinates must be an Array");if(r.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!n(r[0])||!n(r[1]))throw new Error("coordinates must contain numbers");return t({type:"Point",coordinates:r},e,o)}function o(r){if(null==r)throw new Error("degrees is required");return r%360*Math.PI/180}function n(r){return!isNaN(r)&&null!==r&&!Array.isArray(r)}function i(r){return!!r&&r.constructor===Object}function s(r){if(!r)throw new Error("bbox is required");if(!Array.isArray(r))throw new Error("bbox must be an Array");if(4!==r.length&&6!==r.length)throw new Error("bbox must be an Array of 4 or 6 numbers");r.forEach(function(r){if(!n(r))throw new Error("bbox must only contain numbers")})}function a(r){if(!r)throw new Error("obj is required");var t=function(r){if(!r)throw new Error("obj is required");var t;if(r.length?t=r:r.coordinates?t=r.coordinates:r.geometry&&r.geometry.coordinates&&(t=r.geometry.coordinates),t)return function r(t){if(t.length>1&&n(t[0])&&n(t[1]))return!0;if(Array.isArray(t[0])&&t[0].length)return r(t[0]);throw new Error("coordinates must only contain numbers")}(t),t;throw new Error("No valid coordinates")}(r);if(t.length>1&&n(t[0])&&n(t[1]))return t;throw new Error("Coordinate is not a valid Point")}function u(t,e,n){if(!i(n=n||{}))throw new Error("options is invalid");var s=n.units,u=a(t),c=a(e),f=o(c[1]-u[1]),h=o(c[0]-u[0]),w=o(u[1]),l=o(c[1]),d=Math.pow(Math.sin(f/2),2)+Math.pow(Math.sin(h/2),2)*Math.cos(w)*Math.cos(l);return function(t,e){if(null==t)throw new Error("radians is required");if(e&&"string"!=typeof e)throw new Error("units must be a string");var o=r[e||"kilometers"];if(!o)throw new Error(e+" units is invalid");return t*o}(2*Math.atan2(Math.sqrt(d),Math.sqrt(1-d)),s)}var c=function(r,t){return 0===t?r:c(t,r%t)};exports.calculateSizeFromAspectRatio=function(r,t){return Math.ceil(r[1]*t/r[0])},exports.default=function(r){var o,i,a,f,h,w=function(r){s(r);var e=Number(r[0]),o=Number(r[1]),i=Number(r[2]),a=Number(r[3]);if(6===r.length)throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");var u=[e,o];return function(r,e,o){if(!r)throw new Error("coordinates is required");for(var i=0;i<r.length;i++){var s=r[i];if(s.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var a=0;a<s[s.length-1].length;a++){if(0===i&&0===a&&!n(s[0][0])||!n(s[0][1]))throw new Error("coordinates must contain numbers");if(s[s.length-1][a]!==s[0][a])throw new Error("First and last Position are not equivalent.")}}return t({type:"Polygon",coordinates:r},void 0,void 0)}([[u,[i,o],[i,a],[e,a],u]])}(r).geometry.coordinates[0],l=u(e(w[0]),e(w[3])),d=u(e(w[0]),e(w[1]));return function(r,t,e){return[r/e,t/e]}(f=(a=(o=Math.ceil(d))<(i=Math.ceil(l))?[i,o]:[o,i])[0],h=a[1],c(f,h))};
//# sourceMappingURL=index.js.map
{
"name": "bbox-aspect-ratio",
"version": "1.0.0",
"version": "1.0.1",
"description": "get aspect ratio from bounding box",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -1,3 +0,4 @@

import { BBox } from "@turf/helpers";
import { bboxPolygon, distance, point } from "@turf/turf";
import { BBox, point } from "@turf/helpers";
import bboxPolygon from "@turf/bbox-polygon";
import distance from "@turf/distance";

@@ -4,0 +5,0 @@ import aspectRatio from "./aspect-ratio";

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc