Cloudlog/assets/js/leaflet/leaflet.geodesic.js

17 wiersze
14 KiB
JavaScript
Czysty Zwykły widok Historia

/*! Leaflet.Geodesic 2.6.1 - (c) Henry Thasler - https://github.com/henrythasler/Leaflet.Geodesic */
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("leaflet")):"function"==typeof define&&define.amd?define(["exports","leaflet"],n):n(((t="undefined"!=typeof globalThis?globalThis:t||self).L=t.L||{},t.L.geodesic={}),t.L)}(this,(function(t,n){"use strict";function e(t){if(t&&t.__esModule)return t;var n=Object.create(null);return t&&Object.keys(t).forEach((function(e){if("default"!==e){var i=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,i.get?i:{enumerable:!0,get:function(){return t[e]}})}})),n.default=t,Object.freeze(n)}var i=e(n),a=function(t,n){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},a(t,n)};
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function o(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}a(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}var s=function(){return s=Object.assign||function(t){for(var n,e=1,i=arguments.length;e<i;e++)for(var a in n=arguments[e])Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a]);return t},s.apply(this,arguments)};function r(t,n,e){if(e||2===arguments.length)for(var i,a=0,o=n.length;a<o;a++)!i&&a in n||(i||(i=Array.prototype.slice.call(n,0,a)),i[a]=n[a]);return t.concat(i||Array.prototype.slice.call(n))}var l=function(){function t(t){this.options={wrap:!0,steps:3},this.ellipsoid={a:6378137,b:6356752.3142,f:1/298.257223563},this.options=s(s({},this.options),t)}return t.prototype.toRadians=function(t){return t*Math.PI/180},t.prototype.toDegrees=function(t){return 180*t/Math.PI},t.prototype.mod=function(t,n){var e=t%n;return e<0?e+n:e},t.prototype.wrap360=function(t){return 0<=t&&t<360?t:this.mod(t,360)},t.prototype.wrap=function(t,n){return void 0===n&&(n=360),-n<=t&&t<=n?t:this.mod(t+n,2*n)-n},t.prototype.direct=function(t,n,e,i){void 0===i&&(i=100);var a=this.toRadians(t.lat),o=this.toRadians(t.lng),s=this.toRadians(n),r=e,l=1e3*Number.EPSILON,h=this.ellipsoid,c=h.a,p=h.b,u=h.f,g=Math.sin(s),f=Math.cos(s),d=(1-u)*Math.tan(a),M=1/Math.sqrt(1+d*d),L=d*M,y=Math.atan2(d,f),v=M*g,w=1-v*v,b=w*(c*c-p*p)/(p*p),m=1+b/16384*(4096+b*(b*(320-175*b)-768)),O=b/1024*(256+b*(b*(74-47*b)-128)),S=r/(p*m),P=null,R=null,E=null,D=null,x=0;do{E=Math.cos(2*y+S),D=S,S=r/(p*m)+O*(P=Math.sin(S))*(E+O/4*((R=Math.cos(S))*(2*E*E-1)-O/6*E*(4*P*P-3)*(4*E*E-3)))}while(Math.abs(S-D)>l&&++x<i);if(x>=i)throw new EvalError("Direct vincenty formula failed to converge after ".concat(i," iterations \n (start=").concat(t.lat,"/").concat(t.lng,"; bearing=").concat(n,"; distance=").concat(e,")"));var j=L*P-M*R*f,G=Math.atan2(L*R+M*P*f,(1-u)*Math.sqrt(v*v+j*j)),N=u/16*w*(4+u*(4-3*w)),_=o+(Math.atan2(P*g,M*R-L*P*f)-(1-N)*u*v*(S+N*P*(E+N*R*(2*E*E-1)))),T=Math.atan2(v,-j);return{lat:this.toDegrees(G),lng:this.toDegrees(_),bearing:this.wrap360(this.toDegrees(T))}},t.prototype.inverse=function(t,n,e,a){void 0===e&&(e=100),void 0===a&&(a=!0);var o=t,s=n,r=this.toRadians(o.lat),l=this.toRadians(o.lng),h=this.toRadians(s.lat),c=this.toRadians(s.lng),p=Math.PI,u=Number.EPSILON,g=this.ellipsoid,f=g.a,d=g.b,M=g.f,L=c-l,y=(1-M)*Math.tan(r),v=1/Math.sqrt(1+y*y),w=y*v,b=(1-M)*Math.tan(h),m=1/Math.sqrt(1+b*b),O=b*m,S=Math.abs(L)>p/2||Math.abs(h-r)>p/2,P=L,R=null,E=null,D=S?p:0,x=0,j=S?-1:1,G=null,N=1,_=null,T=1,q=null,A=null,C=0;do{if(G=m*(R=Math.sin(P))*(m*R)+(v*O-w*m*(E=Math.cos(P)))*(v*O-w*m*E),Math.abs(G)<u)break;if(j=w*O+v*m*E,A=P,P=L+(1-(q=M/16*(T=1-(_=v*m*R/(x=Math.sqrt(G)))*_)*(4+M*(4-3*T))))*M*_*((D=Math.atan2(x,j))+q*x*((N=0!==T?j-2*w*O/T:0)+q*j*(2*N*N-1))),(S?Math.abs(P)-p:Math.abs(P))>p)throw new EvalError("λ > π")}while(Math.abs(P-A)>1e-12&&++C<e);if(C>=e){if(a)return this.inverse(t,new i.LatLng(n.lat,n.lng-.01),e,a);throw new EvalError("Inverse vincenty formula failed to converge after ".concat(e," iterations \n (start=").concat(t.lat,"/").concat(t.lng,"; dest=").concat(n.lat,"/").concat(n.lng,")"))}var I=T*(f*f-d*d)/(d*d),k=I/1024*(256+I*(I*(74-47*I)-128)),B=d*(1+I/16384*(4096+I*(I*(320-175*I)-768)))*(D-k*x*(N+k/4*(j*(2*N*N-1)-k/6*N*(4*x*x-3)*(4*N*N-3)))),J=Math.abs(G)<u?0:Math.atan2(m*R,v*O-w*m*E),U=Math.abs(G)<u?p:Math.atan2(v*R,-w*m+v*O*E);return{distance:B,initialBearing:Math.abs(B)<u?NaN:this.wrap360(this.toDegrees(J)),finalBearing:Math.abs(B)<u?NaN:this.wrap360(this.toDegrees(U))}},t.prototype.intersection=function(t,n,e,a){var o=this.toRadians(t.lat),s=this.toRadians(t.lng),r=this.toRadians(e.lat),l=this.toRadians(e.lng),h=this.toRadians(n),c=this.toRadians(a),p=r-o,u=l-s,g=Math.PI,f=Number.EPSILON,d=2*Math.asin(Math.sqrt(Math.sin(p/2)*Math.sin(p/2)+Math.cos(o)*Math.cos(r)*Math.sin(u/2)*Math.sin(u/2