bbox-aspect-ratio
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -1,2 +0,2 @@ | ||
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))}; | ||
function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var e=require("@turf/helpers"),r=t(require("@turf/bbox-polygon")),n=t(require("@turf/distance")),o=function(t,e){return 0===e?t:o(e,t%e)};exports.calculateSizeFromAspectRatio=function(t,e){return Math.ceil(t[1]*e/t[0])},exports.default=function(t){var i,u,c,a,f,l=r(t).geometry.coordinates[0],p=n(e.point(l[0]),e.point(l[3])),s=n(e.point(l[0]),e.point(l[1]));return function(t,e,r){return[t/r,e/r]}(a=(c=(i=Math.ceil(s))<(u=Math.ceil(p))?[u,i]:[i,u])[0],f=c[1],o(a,f))}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "bbox-aspect-ratio", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "get aspect ratio from bounding box", | ||
@@ -17,3 +17,2 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@turf/turf": "^5.1.6", | ||
"@types/jest": "^24.0.15", | ||
@@ -24,3 +23,7 @@ "jest": "^24.8.0", | ||
}, | ||
"dependencies": {} | ||
"dependencies": { | ||
"@turf/bbox-polygon": "^6.0.1", | ||
"@turf/distance": "^6.0.1", | ||
"@turf/helpers": "^6.1.4" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
4
6744
3
80
1
+ Added@turf/bbox-polygon@^6.0.1
+ Added@turf/distance@^6.0.1
+ Added@turf/helpers@^6.1.4
+ Added@turf/bbox-polygon@6.5.0(transitive)
+ Added@turf/distance@6.5.0(transitive)
+ Added@turf/helpers@6.5.0(transitive)
+ Added@turf/invariant@6.5.0(transitive)