text: !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.geo=e():t.geo=e()}(window,(function(){return function(t){var e={};function n(a){if(e[a])return e[a].exports;var o=e[a]={i:a,l:!1,exports:{}};return t[a].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,a){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(a,o,function(e){return t[e]}.bind(null,o));return a},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=2)}([function(t,e,n){const a=n(3),o=n(4);n(1);const r=(t,e={})=>{if(null==t)return null;if("string"==typeof t||"number"==typeof t)return o(t,e);if(Array.isArray(t))return e.flatten?t.reduce((t,n)=>t.concat(r(n,e)),[]):t.map(t=>r(t,e));if("object"==typeof t)return a(t,e,r);throw{error:"Malformed Position Data",message:"Malformed Data"}};t.exports=r},function(t,e,n){const a=n(0);Number.prototype.toFixedNumber=function(t,e){var n=Math.pow(e||10,t);return Math.round(this*n)/n},Number.prototype.toRad=function(){return this*Math.PI/180},Number.prototype.toDeg=function(){return 180*this/Math.PI},Number.prototype.toBNG=function(){return(this.toDeg()+360)%360},Number.prototype.toDMS=function(){let t=Math.abs(this);t+=1/7200;let e=Math.floor(t),n=Math.floor(60*(t-e)),a=Number((3600*(t-e-n/60)).toFixed(2));return e<100&&(e="0"+e),e<10&&(e="0"+e),n<10&&(n="0"+n),a<10&&(a="0"+a),`${e}°${n}'${a}"`},Number.prototype.toLat=function(){return this.toDMS().slice(1)+(this<0?"S":"N")},Number.prototype.toLon=function(){return this.toDMS()+(this>0?"E":"W")},String.prototype.parseDMS=function(){return a(this)}},function(t,e,n){const a=n(0),{getAvgOfBearings:o,getBearingBetweenTwoPoints:r,getBearingDiff:i,addHeading:s,invertHDG:l,findMiddleAngle:u}=n(7),{getBoundsOfData:c,getMinMaxAvgFromArray:M}=n(8),{getDistanceCos:h,getDistanceHaversine:g,getDistanceFromSpeedTime:f,crossTrackDistanceTo:d}=n(9),{getIntersectionPoint:p,getPostionFromBearingAndDistance:m,mercator:N}=n(10),{humanTime:D}=n(11),{GDP_smoother:b}=n(12);t.exports={getAvgOfBearings:o,getBearingBetweenTwoPoints:r,getBearingDiff:i,addHeading:s,invertHDG:l,findMiddleAngle:u,parseDMS:a,getBoundsOfData:c,getMinMaxAvgFromArray:M,getDistanceCos:h,getDistanceHaversine:g,getDistanceFromSpeedTime:f,crossTrackDistanceTo:d,getIntersectionPoint:p,getPostionFromBearingAndDistance:m,mercator:N,humanTime:D,GDP_smoother:b}},function(t,e){const n=t=>!(!t.hasOwnProperty("lat")||!t.hasOwnProperty("lon"));t.exports=(t,e,a)=>{if(n){const n=Math.abs(parseFloat(t.lat))>90?{error:"Latitude out of bounds"}:a(t.lat,e),o=Math.abs(parseFloat(t.lon))>180?{error:"Longitude out of bounds"}:a(t.lon,e);if(!e.continueOnError){if(n.error)throw n.error;if(o.error)throw o.error}return e.flatten?[n,o]:{lat:n,lon:o}}return e.flatten?Object.keys(t).map(n=>a(t[n],e)):Object.keys(t).reduce((n,o)=>(n[o]=a(t[o],e),n),{})}},function(t,e,n){const a=n(5),o=n(6);t.exports=(t,e)=>{try{if(/[^0-9.,NSEW\-\s\u00B0\'\"]/i.test(t))throw"Malformed Position Data";if(!isNaN(parseFloat(t))&&isFinite(t)&&Math.abs(t)){if(Math.abs(t)>180)throw"Position Out of Bounds";return Number(t)}let e,n=t.replace(/^-/,"").replace(/[NSEW]/i,"").split(/[^0-9.,]+/);return n.forEach((t,e)=>{if(""==t){if(e<n.length-1)throw"Malformed Position Data";n.splice(e,1)}}),a(t,n),e=o(n),(/^-/.test(t)||/[WS]/i.test(t))&&(e=-e),e.toFixedNumber(7)}catch(t){if(e.continueOnError)return{error:t};throw t}}},function(t,e){t.exports=(t,e)=>{if(Math.abs(e[0])>180)throw"DMS degrees out of bounds";if(/[NS]/i.test(t)&&Math.abs(e[0])>90)throw"DMS degrees out of bounds";switch(e.length){case 3:if(e[1]>60)throw"DMS minutes out of bounds";if(e[2]>60)throw"DMS seconds out of bounds";case 2:if(e[1]>60)throw"DMS minutes out of bounds";default:return}}},function(t,e){t.exports=t=>{let e;switch(t.length){case 3:e=t[0]/1+t[1]/60+t[2]/3600;break;case 2:e=t[0]/1+t[1]/60;break;case 1:e=t[0].slice(0,3)/1+t[0].slice(3,5)/60+t[0].slice(5)/3600;break;default:throw"Malformed Position Data"}return e}},function(t,e,n){const a=n(0);n(1);const o=t=>{throw{error:"Invalid Bearings",message:t}},r=(t,e)=>{let n=[];return t.forEach((function(t,a){if(isNaN(t)||t>=360||t<0||null===t)return n.push({index:a,value:t});e||"string"!=typeof t||n.push({index:a,value:t})})),n};t.exports={validateBearings:r,getAvgOfBearings:t=>{try{if(t.length<2)throw o("Less than two bearings");let e=r(t);if(e.length>0)throw e;let n=t.reduce((function(t,e){return{sinValue:t.sinValue+=Math.sin(e.toRad()),cosValue:t.cosValue+=Math.cos(e.toRad())}}),{sinValue:0,cosValue:0}),a=Math.atan2(n.sinValue,n.cosValue),i=a.toDeg();return i<=-1&&(i+=359),{degrees:Math.abs(Math.round(100*i)/100),radians:a}}catch(t){o(t)}},getBearingBetweenTwoPoints:(t,e,n=0)=>{try{const[o,r]=a([t,e]);let i=o.lat.toRad(),s=r.lat.toRad(),l=(r.lon-o.lon).toRad(),u=Math.sin(l)*Math.cos(s),c=Math.cos(i)*Math.sin(s)-Math.sin(i)*Math.cos(s)*Math.cos(l);return((Math.atan2(u,c).toDeg()+360)%360).toFixedNumber(n)}catch(t){throw t}},getBearingDiff:(t,e)=>((t>=360||t<0||e>=360||e<0)&&o("Out of bounds"),Math.min(t-e<0?t-e+360:t-e,e-t<0?e-t+360:e-t)),addHeading:(t,e)=>(hdg=t+e,hdg<0&&(hdg+=360),hdg>=360&&(hdg-=360),hdg),invertHDG:t=>((t+=180)<0&&(t+=360),t>=360&&(t-=360),t),findMiddleAngle:(t,e)=>{t=Math.round(t),e=Math.round(e);let n=this.getBearingDiff(t,e);return this.addHeading(t,n)==e?this.addHeading(t,n/2):this.addHeading(t,-1*n/2)}}},function(t,e){t.exports={getMinMaxAvgFromArray:t=>{let e=t.reduce((function(t,e){return(isNaN(t)||null===t||""===t)&&(t=-1/0),(isNaN(e)||null===e||""===e)&&(e=-1/0),Math.max(t,e)}),-1/0);return{min:t.reduce((function(t,e){return(isNaN(t)||null===t||""===t)&&(t=1/0),(isNaN(e)||null===e||""===e)&&(e=1/0),Math.min(t,e)}),1/0),max:e,avg:t.reduce((function(t,e){return isNaN(e)||null===e||""===e?t:t+Number(e)}),0)/t.length}},getBoundsOfData:t=>{t.reduce((function(t,e){return{latMin:isNaN(t.latMin)||t.latMin>e.lat?e.lat:t.latMin,latMax:isNaN(t.latMax)||t.latMax<e.lat?e.lat:t.latMax,lngMin:isNaN(t.lngMin)||t.lngMin>e.lng?e.lng:t.lngMin,lngMax:isNaN(t.lngMax)||t.lngMax<e.lng?e.lng:t.lngMax}}),{latMin:1/0,latMax:-1/0,lngMin:1/0,lngMax:-1/0})}}},function(t,e){t.exports={getDistanceCos:(t,e,n)=>{let a=n||geo_const.MEAN_RADIUS_IN_M/1e3;return Math.acos(Math.sin(t.lat*Math.PI/180)*Math.sin(e.lat*Math.PI/180)+Math.cos(t.lat*Math.PI/180)*Math.cos(e.lat*Math.PI/180)*Math.cos((e.lon-t.lon)*Math.PI/180))*a},getDistanceHaversine:(t,e)=>{let n=geo_const.MEAN_RADIUS_IN_M/1e3,a=(e.lat-t.lat)*Math.PI/180,o=(e.lon-t.lon)*Math.PI/180;t.lat=t.lat*Math.PI/180,e.lat=e.lat*Math.PI/180;let r=Math.sin(a/2)*Math.sin(a/2)+Math.cos(t.lat)*Math.cos(e.lat)*Math.sin(o/2)*Math.sin(o/2);return n*(2*Math.atan2(Math.sqrt(r),Math.sqrt(1-r)))},getDistanceFromSpeedTime:(t,e)=>({distInDegree:t*(e/geo_const.HOUR)/geo_const.KM_IN_DEG,distInFeet:t*(e/geo_const.HOUR)*geo_const.KM_TO_FEET,distInKilometers:t*(e/geo_const.HOUR),distInNM:t*(e/geo_const.HOUR)*geo_const.KM_TO_NM}),crossTrackDistanceTo:function({lineStart:t,lineEnd:e,currentPoint:n,haversine:a=!1}){let o=a?this.getDistanceHaversine(t,n,geo_const.MEAN_RADIUS_IN_M)/geo_const.MEAN_RADIUS_IN_M:this.getDistanceCos(t,n,geo_const.MEAN_RADIUS_IN_M)/geo_const.MEAN_RADIUS_IN_M,r=this.getBearingBetweenTwoPoints(t,n)*(Math.PI/180),i=this.getBearingBetweenTwoPoints(t,e)*(Math.PI/180);return Math.asin(Math.sin(o)*Math.sin(r-i))*geo_const.MEAN_RADIUS_IN_M}}},function(t,e){t.exports={getIntersectionPoint:({lineA:t,lineB:e})=>{let n=t.start.lon-t.end.lon,a=e.start.lon-e.end.lon,o=t.start.lat-t.end.lat,r=e.start.lat-e.end.lat,i=n*r-o*a;if(0==i)return!1;let s=t.start.lon*t.end.lat-arrs.lineA.start.lat*t.end.lon,l=e.start.lon*e.end.lat-e.start.lat*e.end.lon;return{lat:(s*r-l*o)/i,lon:(s*a-l*n)/i}},getPostionFromBearingAndDistance:(t,e,n)=>{let a={lat:t.lat(),lng:t.lng()};dist=e/geo_const.MEAN_RADIUS_IN_M/1e3;let o=Number(n)*Math.PI/180,r=a.lat;r=r*Math.PI/180;let i=a.lng;i=i*Math.PI/180;let s=Math.asin(Math.sin(r)*Math.cos(dist)+Math.cos(r)*Math.sin(dist)*Math.cos(o)),l=i+Math.atan2(Math.sin(o)*Math.sin(dist)*Math.cos(r),Math.cos(dist)-Math.sin(r)*Math.sin(s));return{lat:180*s/Math.PI,lng:180*l/Math.PI}},mercator:({latitude:t,longitude:e})=>{const n=85.0511287798,a=Math.PI/180;let o={};return o.lon=geo_const.RADIUS_IN_M*e*a,o.lat=Math.max(Math.min(n,t),-n)*a,o.lat=geo_const.RADIUS_IN_M*Math.log(Math.tan(Math.PI/4+o.lat/2)),o}}},function(t,e){t.exports={humanTime:t=>{let e=(t/1e3).toFixed(0),n=Math.floor(e/60),a="";return n>59&&(a=Math.floor(n/60),a=a>=10?a:"0"+a,n-=60*a,n=n>=10?n:"0"+n),e=Math.floor(e%60),e=e>=10?e:"0"+e,""!=a?a+":"+n+":"+e:n+":"+e}}},function(t,e){t.exports={GDP_smoother:function(t,e){let n,a,o,r,i,s,l,u,c,M,h,g,f,d,p,m,N,D,b,_=Math.PI/180*.5,I=new Array,P=new Array,x=new Array;if(t.length<3)return t;for(n=t.length,M=360*e/(2*Math.PI*6378137),M*=M,o=0,P[0]=0,x[0]=n-1,a=1;a>0;)if(r=P[a-1],i=x[a-1],a--,i-r>1){for(h=t[i].lon-t[r].lon,g=t[i].lat-t[r].lat,Math.abs(h)>180&&(h=360-Math.abs(h)),h*=Math.cos(_*(t[i].lat+t[r].lat)),f=h*h+g*g,s=r+1,l=r,c=-1;s<i;s++)d=t[s].lon-t[r].lon,p=t[s].lat-t[r].lat,Math.abs(d)>180&&(d=360-Math.abs(d)),d*=Math.cos(_*(t[s].lat+t[r].lat)),m=d*d+p*p,N=t[s].lon-t[i].lon,D=t[s].lat-t[i].lat,Math.abs(N)>180&&(N=360-Math.abs(N)),N*=Math.cos(_*(t[s].lat+t[i].lat)),b=N*N+D*D,u=m>=f+b?b:b>=f+m?m:(d*g-p*h)*(d*g-p*h)/f,u>c&&(l=s,c=u);c<M?(I[o]=r,o++):(a++,P[a-1]=l,x[a-1]=i,a++,P[a-1]=r,x[a-1]=l)}else I[o]=r,o++;I[o]=n-1,o++;let y=new Array;for(let e=0;e<o;e++)y.push(t[I[e]]);return y}}}])}));
  //# sourceMappingURL=geo.min.js.map