1 line
1.3 MiB
JavaScript
1 line
1.3 MiB
JavaScript
|
!function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=204)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),n.d(e,"earthRadius",function(){return r}),n.d(e,"factors",function(){return i}),n.d(e,"unitsFactors",function(){return o}),n.d(e,"areaFactors",function(){return a}),e.feature=s,e.geometry=function(t,e,n){void 0===n&&(n={});switch(t){case"Point":return u(e).geometry;case"LineString":return l(e).geometry;case"Polygon":return c(e).geometry;case"MultiPoint":return p(e).geometry;case"MultiLineString":return f(e).geometry;case"MultiPolygon":return d(e).geometry;default:throw new Error(t+" is invalid")}},e.point=u,e.points=function(t,e,n){void 0===n&&(n={});return h(t.map(function(t){return u(t,e)}),n)},e.polygon=c,e.polygons=function(t,e,n){void 0===n&&(n={});return h(t.map(function(t){return c(t,e)}),n)},e.lineString=l,e.lineStrings=function(t,e,n){void 0===n&&(n={});return h(t.map(function(t){return l(t,e)}),n)},e.featureCollection=h,e.multiLineString=f,e.multiPoint=p,e.multiPolygon=d,e.geometryCollection=function(t,e,n){void 0===n&&(n={});return s({type:"GeometryCollection",geometries:t},e,n)},e.round=function(t,e){void 0===e&&(e=0);if(e&&!(e>=0))throw new Error("precision must be a positive number");var n=Math.pow(10,e||0);return Math.round(t*n)/n},e.radiansToLength=g,e.lengthToRadians=y,e.lengthToDegrees=function(t,e){return v(y(t,e))},e.bearingToAzimuth=function(t){var e=t%360;e<0&&(e+=360);return e},e.radiansToDegrees=v,e.degreesToRadians=function(t){return t%360*Math.PI/180},e.convertLength=function(t,e,n){void 0===e&&(e="kilometers");void 0===n&&(n="kilometers");if(!(t>=0))throw new Error("length must be a positive number");return g(y(t,e),n)},e.convertArea=function(t,e,n){void 0===e&&(e="meters");void 0===n&&(n="kilometers");if(!(t>=0))throw new Error("area must be a positive number");var r=a[e];if(!r)throw new Error("invalid original units");var i=a[n];if(!i)throw new Error("invalid final units");return t/r*i},e.isNumber=m,e.isObject=function(t){return!!t&&t.constructor===Object},e.validateBBox=function(t){if(!t)throw new Error("bbox is required");if(!Array.isArray(t))throw new Error("bbox must be an Array");if(4!==t.length&&6!==t.length)throw new Error("bbox must be an Array of 4 or 6 numbers");t.forEach(function(t){if(!m(t))throw new Error("bbox must only contain numbers")})},e.validateId=function(t){if(!t)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof t))throw new Error("id must be a number or a string")};var r=6371008.8,i={centimeters:100*r,centimetres:100*r,degrees:r/111325,feet:3.28084*r,inches:39.37*r,kilometers:r/1e3,kilometres:r/1e3,meters:r,metres:r,miles:r/1609.344,millimeters:1e3*r,millimetres:1e3*r,nauticalmiles:r/1852,radians:1,yards:1.0936*r},o={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:.001,kilometres:.001,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/r,yards:1.0936133},a={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:3.86e-7,millimeters:1e6,millimetres:1e6,yards:1.195990046};function s(t,e,n){void 0===n&&(n={});var r={type:"Feature"};return(0===n.id||n.id)&&(r.id=n.id),n.bbox&&(r.bbox=n.bbox),r.properties=e||{},r.geometry=t,r}function u(t,e,n){if(void 0===n&&(n={}),!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");if(t.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!m(t[0])||!m(t[1]))throw new Error("coordinates must contain numbers");return s
|