UNPKG

@deck.gl/layers

Version:
373 lines (307 loc) 195 kB
(function webpackUniversalModuleDefinition(root, factory) { if (typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if (typeof define === 'function' && define.amd) define([], factory); else if (typeof exports === 'object') exports['deck'] = factory(); else root['deck'] = factory();})(globalThis, function () { "use strict";var __exports__=(()=>{var Lc=Object.create;var qt=Object.defineProperty;var Ac=Object.getOwnPropertyDescriptor;var Ic=Object.getOwnPropertyNames;var Tc=Object.getPrototypeOf,Ec=Object.prototype.hasOwnProperty;var G=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Rc=(e,r)=>{for(var t in r)qt(e,t,{get:r[t],enumerable:!0})},Xt=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of Ic(r))!Ec.call(e,i)&&i!==t&&qt(e,i,{get:()=>r[i],enumerable:!(n=Ac(r,i))||n.enumerable});return e},ye=(e,r,t)=>(Xt(e,r,"default"),t&&Xt(t,r,"default")),g=(e,r,t)=>(t=e!=null?Lc(Tc(e)):{},Xt(r||!e||!e.__esModule?qt(t,"default",{value:e,enumerable:!0}):t,e)),zc=e=>Xt(qt({},"__esModule",{value:!0}),e);var D=G((Ep,ui)=>{ui.exports=globalThis.deck});var N=G((zp,vi)=>{function Fc(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}vi.exports=Fc});var B=G((Fp,gi)=>{function di(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function kc(e,r,t){return r&&di(e.prototype,r),t&&di(e,t),e}gi.exports=kc});var se=G((kp,hi)=>{function Dc(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}hi.exports=Dc});var V=G((Dp,un)=>{function fn(e){return un.exports=fn=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},fn(e)}un.exports=fn});var yi=G((jp,mi)=>{var jc=V();function Nc(e,r){for(;!Object.prototype.hasOwnProperty.call(e,r)&&(e=jc(e),e!==null););return e}mi.exports=Nc});var X=G((Np,Qt)=>{var Wc=yi();function Jt(e,r,t){return typeof Reflect<"u"&&Reflect.get?Qt.exports=Jt=Reflect.get:Qt.exports=Jt=function(i,o,a){var s=Wc(i,o);if(s){var l=Object.getOwnPropertyDescriptor(s,o);return l.get?l.get.call(a):l.value}},Jt(e,r,t||e)}Qt.exports=Jt});var xi=G((Wp,vn)=>{function pn(e,r){return vn.exports=pn=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},pn(e,r)}vn.exports=pn});var $=G((Up,Pi)=>{var Uc=xi();function Bc(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),r&&Uc(e,r)}Pi.exports=Bc});var _i=G((Bp,tr)=>{function er(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?tr.exports=er=function(t){return typeof t}:tr.exports=er=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},er(e)}tr.exports=er});var Y=G((Gp,Si)=>{var Gc=_i(),Zc=se();function Vc(e,r){return r&&(Gc(r)==="object"||typeof r=="function")?r:Zc(e)}Si.exports=Vc});var j=G((Zp,Mi)=>{function Hc(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}Mi.exports=Hc});var q=G((Vp,Ci)=>{Ci.exports=globalThis.luma});var Fi=G((qp,zi)=>{function Xc(e){if(Array.isArray(e))return e}zi.exports=Xc});var Di=G((Jp,ki)=>{function qc(e,r){if(Symbol.iterator in Object(e)||Object.prototype.toString.call(e)==="[object Arguments]"){var t=[],n=!0,i=!1,o=void 0;try{for(var a=e[Symbol.iterator](),s;!(n=(s=a.next()).done)&&(t.push(s.value),!(r&&t.length===r));n=!0);}catch(l){i=!0,o=l}finally{try{!n&&a.return!=null&&a.return()}finally{if(i)throw o}}return t}}ki.exports=qc});var Ni=G((Qp,ji)=>{function Jc(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}ji.exports=Jc});var or=G((ev,Wi)=>{var Qc=Fi(),ef=Di(),tf=Ni();function rf(e,r){return Qc(e)||ef(e,r)||tf()}Wi.exports=rf});var _o=G((ig,Po)=>{Po.exports=globalThis.loaders});var Ms=G((Ph,Xn)=>{"use strict";Xn.exports=jr;Xn.exports.default=jr;function jr(e,r,t){t=t||2;var n=r&&r.length,i=n?r[0]*t:e.length,o=Ps(e,0,i,t,!0),a=[];if(!o||o.next===o.prev)return a;var s,l,c,f,u,p,v;if(n&&(o=xu(e,r,o,t)),e.length>80*t){s=c=e[0],l=f=e[1];for(var d=t;d<i;d+=t)u=e[d],p=e[d+1],u<s&&(s=u),p<l&&(l=p),u>c&&(c=u),p>f&&(f=p);v=Math.max(c-s,f-l),v=v!==0?32767/v:0}return Rt(o,a,t,s,l,v,0),a}function Ps(e,r,t,n,i){var o,a;if(i===Kn(e,r,t,n)>0)for(o=r;o<t;o+=n)a=xs(o,e[o],e[o+1],a);else for(o=t-n;o>=r;o-=n)a=xs(o,e[o],e[o+1],a);return a&&Nr(a,a.next)&&(Ft(a),a=a.next),a}function ze(e,r){if(!e)return e;r||(r=e);var t=e,n;do if(n=!1,!t.steiner&&(Nr(t,t.next)||U(t.prev,t,t.next)===0)){if(Ft(t),t=r=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==r);return r}function Rt(e,r,t,n,i,o,a){if(e){!a&&o&&Cu(e,n,i,o);for(var s=e,l,c;e.prev!==e.next;){if(l=e.prev,c=e.next,o?hu(e,n,i,o):gu(e)){r.push(l.i/t|0),r.push(e.i/t|0),r.push(c.i/t|0),Ft(e),e=c.next,s=c.next;continue}if(e=c,e===s){a?a===1?(e=mu(ze(e),r,t),Rt(e,r,t,n,i,o,2)):a===2&&yu(e,r,t,n,i,o):Rt(ze(e),r,t,n,i,o,1);break}}}}function gu(e){var r=e.prev,t=e,n=e.next;if(U(r,t,n)>=0)return!1;for(var i=r.x,o=t.x,a=n.x,s=r.y,l=t.y,c=n.y,f=i<o?i<a?i:a:o<a?o:a,u=s<l?s<c?s:c:l<c?l:c,p=i>o?i>a?i:a:o>a?o:a,v=s>l?s>c?s:c:l>c?l:c,d=n.next;d!==r;){if(d.x>=f&&d.x<=p&&d.y>=u&&d.y<=v&&qe(i,s,o,l,a,c,d.x,d.y)&&U(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}function hu(e,r,t,n){var i=e.prev,o=e,a=e.next;if(U(i,o,a)>=0)return!1;for(var s=i.x,l=o.x,c=a.x,f=i.y,u=o.y,p=a.y,v=s<l?s<c?s:c:l<c?l:c,d=f<u?f<p?f:p:u<p?u:p,m=s>l?s>c?s:c:l>c?l:c,y=f>u?f>p?f:p:u>p?u:p,x=$n(v,d,r,t,n),S=$n(m,y,r,t,n),h=e.prevZ,P=e.nextZ;h&&h.z>=x&&P&&P.z<=S;){if(h.x>=v&&h.x<=m&&h.y>=d&&h.y<=y&&h!==i&&h!==a&&qe(s,f,l,u,c,p,h.x,h.y)&&U(h.prev,h,h.next)>=0||(h=h.prevZ,P.x>=v&&P.x<=m&&P.y>=d&&P.y<=y&&P!==i&&P!==a&&qe(s,f,l,u,c,p,P.x,P.y)&&U(P.prev,P,P.next)>=0))return!1;P=P.nextZ}for(;h&&h.z>=x;){if(h.x>=v&&h.x<=m&&h.y>=d&&h.y<=y&&h!==i&&h!==a&&qe(s,f,l,u,c,p,h.x,h.y)&&U(h.prev,h,h.next)>=0)return!1;h=h.prevZ}for(;P&&P.z<=S;){if(P.x>=v&&P.x<=m&&P.y>=d&&P.y<=y&&P!==i&&P!==a&&qe(s,f,l,u,c,p,P.x,P.y)&&U(P.prev,P,P.next)>=0)return!1;P=P.nextZ}return!0}function mu(e,r,t){var n=e;do{var i=n.prev,o=n.next.next;!Nr(i,o)&&_s(i,n,n.next,o)&&zt(i,o)&&zt(o,i)&&(r.push(i.i/t|0),r.push(n.i/t|0),r.push(o.i/t|0),Ft(n),Ft(n.next),n=e=o),n=n.next}while(n!==e);return ze(n)}function yu(e,r,t,n,i,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&Ou(a,s)){var l=Ss(a,s);a=ze(a,a.next),l=ze(l,l.next),Rt(a,r,t,n,i,o,0),Rt(l,r,t,n,i,o,0);return}s=s.next}a=a.next}while(a!==e)}function xu(e,r,t,n){var i=[],o,a,s,l,c;for(o=0,a=r.length;o<a;o++)s=r[o]*n,l=o<a-1?r[o+1]*n:e.length,c=Ps(e,s,l,n,!1),c===c.next&&(c.steiner=!0),i.push(wu(c));for(i.sort(Pu),o=0;o<i.length;o++)t=_u(i[o],t);return t}function Pu(e,r){return e.x-r.x}function _u(e,r){var t=Su(e,r);if(!t)return r;var n=Ss(t,e);return ze(n,n.next),ze(t,t.next)}function Su(e,r){var t=r,n=e.x,i=e.y,o=-1/0,a;do{if(i<=t.y&&i>=t.next.y&&t.next.y!==t.y){var s=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(s<=n&&s>o&&(o=s,a=t.x<t.next.x?t:t.next,s===n))return a}t=t.next}while(t!==r);if(!a)return null;var l=a,c=a.x,f=a.y,u=1/0,p;t=a;do n>=t.x&&t.x>=c&&n!==t.x&&qe(i<f?n:o,i,c,f,i<f?o:n,i,t.x,t.y)&&(p=Math.abs(i-t.y)/(n-t.x),zt(t,e)&&(p<u||p===u&&(t.x>a.x||t.x===a.x&&Mu(a,t)))&&(a=t,u=p)),t=t.next;while(t!==l);return a}function Mu(e,r){return U(e.prev,e,r.prev)<0&&U(r.next,e,e.next)<0}function Cu(e,r,t,n){var i=e;do i.z===0&&(i.z=$n(i.x,i.y,r,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,bu(i)}function bu(e){var r,t,n,i,o,a,s,l,c=1;do{for(t=e,e=null,o=null,a=0;t;){for(a++,n=t,s=0,r=0;r<c&&(s++,n=n.nextZ,!!n);r++);for(l=c;s>0||l>0&&n;)s!==0&&(l===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,s--):(i=n,n=n.nextZ,l--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;t=n}o.nextZ=null,c*=2}while(a>1);return e}function $n(e,r,t,n,i){return e=(e-t)*i|0,r=(r-n)*i|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e|r<<1}function wu(e){var r=e,t=e;do(r.x<t.x||r.x===t.x&&r.y<t.y)&&(t=r),r=r.next;while(r!==e);return t}function qe(e,r,t,n,i,o,a,s){return(i-a)*(r-s)>=(e-a)*(o-s)&&(e-a)*(n-s)>=(t-a)*(r-s)&&(t-a)*(o-s)>=(i-a)*(n-s)}function Ou(e,r){return e.next.i!==r.i&&e.prev.i!==r.i&&!Lu(e,r)&&(zt(e,r)&&zt(r,e)&&Au(e,r)&&(U(e.prev,e,r.prev)||U(e,r.prev,r))||Nr(e,r)&&U(e.prev,e,e.next)>0&&U(r.prev,r,r.next)>0)}function U(e,r,t){return(r.y-e.y)*(t.x-r.x)-(r.x-e.x)*(t.y-r.y)}function Nr(e,r){return e.x===r.x&&e.y===r.y}function _s(e,r,t,n){var i=Dr(U(e,r,t)),o=Dr(U(e,r,n)),a=Dr(U(t,n,e)),s=Dr(U(t,n,r));return!!(i!==o&&a!==s||i===0&&kr(e,t,r)||o===0&&kr(e,n,r)||a===0&&kr(t,e,n)||s===0&&kr(t,r,n))}function kr(e,r,t){return r.x<=Math.max(e.x,t.x)&&r.x>=Math.min(e.x,t.x)&&r.y<=Math.max(e.y,t.y)&&r.y>=Math.min(e.y,t.y)}function Dr(e){return e>0?1:e<0?-1:0}function Lu(e,r){var t=e;do{if(t.i!==e.i&&t.next.i!==e.i&&t.i!==r.i&&t.next.i!==r.i&&_s(t,t.next,e,r))return!0;t=t.next}while(t!==e);return!1}function zt(e,r){return U(e.prev,e,e.next)<0?U(e,r,e.next)>=0&&U(e,e.prev,r)>=0:U(e,r,e.prev)<0||U(e,e.next,r)<0}function Au(e,r){var t=e,n=!1,i=(e.x+r.x)/2,o=(e.y+r.y)/2;do t.y>o!=t.next.y>o&&t.next.y!==t.y&&i<(t.next.x-t.x)*(o-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==e);return n}function Ss(e,r){var t=new Yn(e.i,e.x,e.y),n=new Yn(r.i,r.x,r.y),i=e.next,o=r.prev;return e.next=r,r.prev=e,t.next=i,i.prev=t,n.next=t,t.prev=n,o.next=n,n.prev=o,n}function xs(e,r,t,n){var i=new Yn(e,r,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Ft(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Yn(e,r,t){this.i=e,this.x=r,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}jr.deviation=function(e,r,t,n){var i=r&&r.length,o=i?r[0]*t:e.length,a=Math.abs(Kn(e,0,o,t));if(i)for(var s=0,l=r.length;s<l;s++){var c=r[s]*t,f=s<l-1?r[s+1]*t:e.length;a-=Math.abs(Kn(e,c,f,t))}var u=0;for(s=0;s<n.length;s+=3){var p=n[s]*t,v=n[s+1]*t,d=n[s+2]*t;u+=Math.abs((e[p]-e[d])*(e[v+1]-e[p+1])-(e[p]-e[v])*(e[d+1]-e[p+1]))}return a===0&&u===0?0:Math.abs((u-a)/a)};function Kn(e,r,t,n){for(var i=0,o=r,a=t-n;o<t;o+=n)i+=(e[a]-e[o])*(e[o+1]+e[a+1]),a=o;return i}jr.flatten=function(e){for(var r=e[0][0].length,t={vertices:[],holes:[],dimensions:r},n=0,i=0;i<e.length;i++){for(var o=0;o<e[i].length;o++)for(var a=0;a<r;a++)t.vertices.push(e[i][o][a]);i>0&&(n+=e[i-1].length,t.holes.push(n))}return t}});var sl=G((Wh,al)=>{function Ku(e,r){if(e==null)return{};var t={},n=Object.keys(e),i,o;for(o=0;o<n.length;o++)i=n[o],!(r.indexOf(i)>=0)&&(t[i]=e[i]);return t}al.exports=Ku});var cl=G((Uh,ll)=>{var Xu=sl();function qu(e,r){if(e==null)return{};var t=Xu(e,r),n,i;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)n=o[i],!(r.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(t[n]=e[n])}return t}ll.exports=qu});var Yt={};Rc(Yt,{ArcLayer:()=>ir,BitmapLayer:()=>mr,ColumnLayer:()=>Xe,GeoJsonLayer:()=>nn,GridCellLayer:()=>Rr,IconLayer:()=>_e,LineLayer:()=>Sr,PathLayer:()=>Oe,PointCloudLayer:()=>br,PolygonLayer:()=>Hr,ScatterplotLayer:()=>Ye,SolidPolygonLayer:()=>Ae,TextLayer:()=>it,_MultiIconLayer:()=>tt,_TextBackgroundLayer:()=>rt});var ae={},pi=g(D());ye(ae,g(D()));if(!pi.Layer)throw new Error("@deck.gl/core is not found");ye(Yt,ae);var Ai=g(N()),Ii=g(B()),Ti=g(se()),dn=g(X()),Ei=g($()),Ri=g(Y()),st=g(V()),lt=g(j()),xe=g(D()),nr=g(q());var bi=`#define SHADER_NAME arc-layer-vertex-shader attribute vec3 positions; attribute vec4 instanceSourceColors; attribute vec4 instanceTargetColors; attribute vec3 instanceSourcePositions; attribute vec3 instanceSourcePositions64Low; attribute vec3 instanceTargetPositions; attribute vec3 instanceTargetPositions64Low; attribute vec3 instancePickingColors; attribute float instanceWidths; attribute float instanceHeights; attribute float instanceTilts; uniform bool greatCircle; uniform bool useShortestPath; uniform float numSegments; uniform float opacity; uniform float widthScale; uniform float widthMinPixels; uniform float widthMaxPixels; uniform int widthUnits; varying vec4 vColor; varying vec2 uv; varying float isValid; float paraboloid(float distance, float sourceZ, float targetZ, float ratio) { float deltaZ = targetZ - sourceZ; float dh = distance * instanceHeights; if (dh == 0.0) { return sourceZ + deltaZ * ratio; } float unitZ = deltaZ / dh; float p2 = unitZ * unitZ + 1.0; float dir = step(deltaZ, 0.0); float z0 = mix(sourceZ, targetZ, dir); float r = mix(ratio, 1.0 - ratio, dir); return sqrt(r * (p2 - r)) * dh + z0; } vec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction, float width) { vec2 dir_screenspace = normalize(line_clipspace * project_uViewportSize); dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x); return dir_screenspace * offset_direction * width / 2.0; } float getSegmentRatio(float index) { return smoothstep(0.0, 1.0, index / (numSegments - 1.0)); } vec3 interpolateFlat(vec3 source, vec3 target, float segmentRatio) { float distance = length(source.xy - target.xy); float z = paraboloid(distance, source.z, target.z, segmentRatio); float tiltAngle = radians(instanceTilts); vec2 tiltDirection = normalize(target.xy - source.xy); vec2 tilt = vec2(-tiltDirection.y, tiltDirection.x) * z * sin(tiltAngle); return vec3( mix(source.xy, target.xy, segmentRatio) + tilt, z * cos(tiltAngle) ); } float getAngularDist (vec2 source, vec2 target) { vec2 sourceRadians = radians(source); vec2 targetRadians = radians(target); vec2 sin_half_delta = sin((sourceRadians - targetRadians) / 2.0); vec2 shd_sq = sin_half_delta * sin_half_delta; float a = shd_sq.y + cos(sourceRadians.y) * cos(targetRadians.y) * shd_sq.x; return 2.0 * asin(sqrt(a)); } vec3 interpolateGreatCircle(vec3 source, vec3 target, vec3 source3D, vec3 target3D, float angularDist, float t) { vec2 lngLat; if(abs(angularDist - PI) < 0.001) { lngLat = (1.0 - t) * source.xy + t * target.xy; } else { float a = sin((1.0 - t) * angularDist); float b = sin(t * angularDist); vec3 p = source3D.yxz * a + target3D.yxz * b; lngLat = degrees(vec2(atan(p.y, -p.x), atan(p.z, length(p.xy)))); } float z = paraboloid(angularDist * EARTH_RADIUS, source.z, target.z, t); return vec3(lngLat, z); } void main(void) { geometry.worldPosition = instanceSourcePositions; geometry.worldPositionAlt = instanceTargetPositions; float segmentIndex = positions.x; float segmentRatio = getSegmentRatio(segmentIndex); float prevSegmentRatio = getSegmentRatio(max(0.0, segmentIndex - 1.0)); float nextSegmentRatio = getSegmentRatio(min(numSegments - 1.0, segmentIndex + 1.0)); float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0)); isValid = 1.0; uv = vec2(segmentRatio, positions.y); geometry.uv = uv; geometry.pickingColor = instancePickingColors; vec4 curr; vec4 next; vec3 source; vec3 target; if ((greatCircle || project_uProjectionMode == PROJECTION_MODE_GLOBE) && project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT) { source = project_globe_(vec3(instanceSourcePositions.xy, 0.0)); target = project_globe_(vec3(instanceTargetPositions.xy, 0.0)); float angularDist = getAngularDist(instanceSourcePositions.xy, instanceTargetPositions.xy); vec3 prevPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, prevSegmentRatio); vec3 currPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, segmentRatio); vec3 nextPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, nextSegmentRatio); if (abs(currPos.x - prevPos.x) > 180.0) { indexDir = -1.0; isValid = 0.0; } else if (abs(currPos.x - nextPos.x) > 180.0) { indexDir = 1.0; isValid = 0.0; } nextPos = indexDir < 0.0 ? prevPos : nextPos; nextSegmentRatio = indexDir < 0.0 ? prevSegmentRatio : nextSegmentRatio; if (isValid == 0.0) { nextPos.x += nextPos.x > 0.0 ? -360.0 : 360.0; float t = ((currPos.x > 0.0 ? 180.0 : -180.0) - currPos.x) / (nextPos.x - currPos.x); currPos = mix(currPos, nextPos, t); segmentRatio = mix(segmentRatio, nextSegmentRatio, t); } vec3 currPos64Low = mix(instanceSourcePositions64Low, instanceTargetPositions64Low, segmentRatio); vec3 nextPos64Low = mix(instanceSourcePositions64Low, instanceTargetPositions64Low, nextSegmentRatio); curr = project_position_to_clipspace(currPos, currPos64Low, vec3(0.0), geometry.position); next = project_position_to_clipspace(nextPos, nextPos64Low, vec3(0.0)); } else { vec3 source_world = instanceSourcePositions; vec3 target_world = instanceTargetPositions; if (useShortestPath) { source_world.x = mod(source_world.x + 180., 360.0) - 180.; target_world.x = mod(target_world.x + 180., 360.0) - 180.; float deltaLng = target_world.x - source_world.x; if (deltaLng > 180.) target_world.x -= 360.; if (deltaLng < -180.) source_world.x -= 360.; } source = project_position(source_world, instanceSourcePositions64Low); target = project_position(target_world, instanceTargetPositions64Low); float antiMeridianX = 0.0; if (useShortestPath) { if (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) { antiMeridianX = -(project_uCoordinateOrigin.x + 180.) / 360. * TILE_SIZE; } float thresholdRatio = (antiMeridianX - source.x) / (target.x - source.x); if (prevSegmentRatio <= thresholdRatio && nextSegmentRatio > thresholdRatio) { isValid = 0.0; indexDir = sign(segmentRatio - thresholdRatio); segmentRatio = thresholdRatio; } } nextSegmentRatio = indexDir < 0.0 ? prevSegmentRatio : nextSegmentRatio; vec3 currPos = interpolateFlat(source, target, segmentRatio); vec3 nextPos = interpolateFlat(source, target, nextSegmentRatio); if (useShortestPath) { if (nextPos.x < antiMeridianX) { currPos.x += TILE_SIZE; nextPos.x += TILE_SIZE; } } curr = project_common_position_to_clipspace(vec4(currPos, 1.0)); next = project_common_position_to_clipspace(vec4(nextPos, 1.0)); geometry.position = vec4(currPos, 1.0); } float widthPixels = clamp( project_size_to_pixel(instanceWidths * widthScale, widthUnits), widthMinPixels, widthMaxPixels ); vec3 offset = vec3( getExtrusionOffset((next.xy - curr.xy) * indexDir, positions.y, widthPixels), 0.0); DECKGL_FILTER_SIZE(offset, geometry); DECKGL_FILTER_GL_POSITION(curr, geometry); gl_Position = curr + vec4(project_pixel_size_to_clipspace(offset.xy), 0.0, 0.0); vec4 color = mix(instanceSourceColors, instanceTargetColors, segmentRatio); vColor = vec4(color.rgb, color.a * opacity); DECKGL_FILTER_COLOR(vColor, geometry); } `;var wi=`#define SHADER_NAME arc-layer-fragment-shader precision highp float; varying vec4 vColor; varying vec2 uv; varying float isValid; void main(void) { if (isValid == 0.0) { discard; } gl_FragColor = vColor; geometry.uv = uv; DECKGL_FILTER_COLOR(gl_FragColor, geometry); } `;function Oi(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),t.push.apply(t,n)}return t}function Li(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?Oi(Object(t),!0).forEach(function(n){(0,lt.default)(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Oi(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function $c(e){var r=Yc();return function(){var n=(0,st.default)(e),i;if(r){var o=(0,st.default)(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return(0,Ri.default)(this,i)}}function Yc(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var rr=[0,0,0,255],Kc={getSourcePosition:{type:"accessor",value:function(r){return r.sourcePosition}},getTargetPosition:{type:"accessor",value:function(r){return r.targetPosition}},getSourceColor:{type:"accessor",value:rr},getTargetColor:{type:"accessor",value:rr},getWidth:{type:"accessor",value:1},getHeight:{type:"accessor",value:1},getTilt:{type:"accessor",value:0},greatCircle:!1,widthUnits:"pixels",widthScale:{type:"number",value:1,min:0},widthMinPixels:{type:"number",value:0,min:0},widthMaxPixels:{type:"number",value:Number.MAX_SAFE_INTEGER,min:0}},ir=function(e){(0,Ei.default)(t,e);var r=$c(t);function t(){var n;(0,Ai.default)(this,t);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return n=r.call.apply(r,[this].concat(o)),(0,lt.default)((0,Ti.default)(n),"state",void 0),n}return(0,Ii.default)(t,[{key:"getBounds",value:function(){var i;return(i=this.getAttributeManager())===null||i===void 0?void 0:i.getBounds(["instanceSourcePositions","instanceTargetPositions"])}},{key:"getShaders",value:function(){return(0,dn.default)((0,st.default)(t.prototype),"getShaders",this).call(this,{vs:bi,fs:wi,modules:[xe.project32,xe.picking]})}},{key:"wrapLongitude",get:function(){return!1}},{key:"initializeState",value:function(){var i=this.getAttributeManager();i.addInstanced({instanceSourcePositions:{size:3,type:5130,fp64:this.use64bitPositions(),transition:!0,accessor:"getSourcePosition"},instanceTargetPositions:{size:3,type:5130,fp64:this.use64bitPositions(),transition:!0,accessor:"getTargetPosition"},instanceSourceColors:{size:this.props.colorFormat.length,type:5121,normalized:!0,transition:!0,accessor:"getSourceColor",defaultValue:rr},instanceTargetColors:{size:this.props.colorFormat.length,type:5121,normalized:!0,transition:!0,accessor:"getTargetColor",defaultValue:rr},instanceWidths:{size:1,transition:!0,accessor:"getWidth",defaultValue:1},instanceHeights:{size:1,transition:!0,accessor:"getHeight",defaultValue:1},instanceTilts:{size:1,transition:!0,accessor:"getTilt",defaultValue:0}})}},{key:"updateState",value:function(i){if((0,dn.default)((0,st.default)(t.prototype),"updateState",this).call(this,i),i.changeFlags.extensionsChanged){var o,a=this.context.gl;(o=this.state.model)===null||o===void 0||o.delete(),this.state.model=this._getModel(a),this.getAttributeManager().invalidateAll()}}},{key:"draw",value:function(i){var o=i.uniforms,a=this.props,s=a.widthUnits,l=a.widthScale,c=a.widthMinPixels,f=a.widthMaxPixels,u=a.greatCircle,p=a.wrapLongitude;this.state.model.setUniforms(o).setUniforms({greatCircle:u,widthUnits:xe.UNIT[s],widthScale:l,widthMinPixels:c,widthMaxPixels:f,useShortestPath:p}).draw()}},{key:"_getModel",value:function(i){for(var o=[],a=50,s=0;s<a;s++)o=o.concat([s,1,0,s,-1,0]);var l=new nr.Model(i,Li(Li({},this.getShaders()),{},{id:this.props.id,geometry:new nr.Geometry({drawMode:5,attributes:{positions:new Float32Array(o)}}),isInstanced:!0}));return l.setUniforms({numSegments:a}),l}}]),t}(xe.Layer);(0,lt.default)(ir,"layerName","ArcLayer");(0,lt.default)(ir,"defaultProps",Kc);var uo=g(or()),po=g(N()),vo=g(B()),go=g(se()),Rn=g(X()),ho=g($()),mo=g(Y()),gt=g(V()),ht=g(j()),oe=g(D()),hr=g(q());function Ne(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function gn(e){if(Array.isArray(e))return Ne(e)}function hn(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function ct(e,r){if(e){if(typeof e=="string")return Ne(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Ne(e,r)}}function mn(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function We(e){return gn(e)||hn(e)||ct(e)||mn()}function yn(e){if(Array.isArray(e))return e}function xn(e,r){var t=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(t!=null){var n=[],i=!0,o=!1,a,s;try{for(t=t.call(e);!(i=(a=t.next()).done)&&(n.push(a.value),!(r&&n.length===r));i=!0);}catch(l){o=!0,s=l}finally{try{!i&&t.return!=null&&t.return()}finally{if(o)throw s}}return n}}function Pn(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function K(e,r){return yn(e)||xn(e,r)||ct(e,r)||Pn()}function _n(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function Ui(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function Sn(e,r,t){return r&&Ui(e.prototype,r),t&&Ui(e,t),e}function F(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var H=1e-6,le=typeof Float32Array<"u"?Float32Array:Array;var Cv=Math.PI/180;Math.hypot||(Math.hypot=function(){for(var e=0,r=arguments.length;r--;)e+=arguments[r]*arguments[r];return Math.sqrt(e)});function nf(){var e=new le(4);return le!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function Gi(e,r,t){return e[0]=r[0]*t,e[1]=r[1]*t,e[2]=r[2]*t,e[3]=r[3]*t,e}function Zi(e,r,t){var n=r[0],i=r[1],o=r[2],a=r[3];return e[0]=t[0]*n+t[4]*i+t[8]*o+t[12]*a,e[1]=t[1]*n+t[5]*i+t[9]*o+t[13]*a,e[2]=t[2]*n+t[6]*i+t[10]*o+t[14]*a,e[3]=t[3]*n+t[7]*i+t[11]*o+t[15]*a,e}var bv=function(){var e=nf();return function(r,t,n,i,o,a){var s,l;for(t||(t=4),n||(n=0),i?l=Math.min(i*t+n,r.length):l=r.length,s=n;s<l;s+=t)e[0]=r[s],e[1]=r[s+1],e[2]=r[s+2],e[3]=r[s+3],o(e,e,a),r[s]=e[0],r[s+1]=e[1],r[s+2]=e[2],r[s+3]=e[3];return r}}();function Ue(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Pe(e,r){var t=Zi([],r,e);return Gi(t,t,1/t[3]),t}function ft(e,r,t){return e<r?r:e>t?t:e}function of(e){return Math.log(e)*Math.LOG2E}var sr=Math.log2||of;function Vi(e,r){var t=r[0],n=r[1],i=r[2],o=r[3],a=r[4],s=r[5],l=r[6],c=r[7],f=r[8],u=r[9],p=r[10],v=r[11],d=r[12],m=r[13],y=r[14],x=r[15],S=t*s-n*a,h=t*l-i*a,P=t*c-o*a,_=n*l-i*s,M=n*c-o*s,C=i*c-o*l,b=f*m-u*d,O=f*y-p*d,I=f*x-v*d,A=u*y-p*m,L=u*x-v*m,T=p*x-v*y,w=S*T-h*L+P*A+_*I-M*O+C*b;return w?(w=1/w,e[0]=(s*T-l*L+c*A)*w,e[1]=(i*L-n*T-o*A)*w,e[2]=(m*C-y*M+x*_)*w,e[3]=(p*M-u*C-v*_)*w,e[4]=(l*I-a*T-c*O)*w,e[5]=(t*T-i*I+o*O)*w,e[6]=(y*P-d*C-x*h)*w,e[7]=(f*C-p*P+v*h)*w,e[8]=(a*L-s*I+c*b)*w,e[9]=(n*I-t*L-o*b)*w,e[10]=(d*M-m*P+x*S)*w,e[11]=(u*P-f*M-v*S)*w,e[12]=(s*O-a*A-l*b)*w,e[13]=(t*A-n*O+i*b)*w,e[14]=(m*h-d*_-y*S)*w,e[15]=(f*_-u*h+p*S)*w,e):null}function lr(e,r,t){var n=r[0],i=r[1],o=r[2],a=r[3],s=r[4],l=r[5],c=r[6],f=r[7],u=r[8],p=r[9],v=r[10],d=r[11],m=r[12],y=r[13],x=r[14],S=r[15],h=t[0],P=t[1],_=t[2],M=t[3];return e[0]=h*n+P*s+_*u+M*m,e[1]=h*i+P*l+_*p+M*y,e[2]=h*o+P*c+_*v+M*x,e[3]=h*a+P*f+_*d+M*S,h=t[4],P=t[5],_=t[6],M=t[7],e[4]=h*n+P*s+_*u+M*m,e[5]=h*i+P*l+_*p+M*y,e[6]=h*o+P*c+_*v+M*x,e[7]=h*a+P*f+_*d+M*S,h=t[8],P=t[9],_=t[10],M=t[11],e[8]=h*n+P*s+_*u+M*m,e[9]=h*i+P*l+_*p+M*y,e[10]=h*o+P*c+_*v+M*x,e[11]=h*a+P*f+_*d+M*S,h=t[12],P=t[13],_=t[14],M=t[15],e[12]=h*n+P*s+_*u+M*m,e[13]=h*i+P*l+_*p+M*y,e[14]=h*o+P*c+_*v+M*x,e[15]=h*a+P*f+_*d+M*S,e}function ut(e,r,t){var n=t[0],i=t[1],o=t[2],a,s,l,c,f,u,p,v,d,m,y,x;return r===e?(e[12]=r[0]*n+r[4]*i+r[8]*o+r[12],e[13]=r[1]*n+r[5]*i+r[9]*o+r[13],e[14]=r[2]*n+r[6]*i+r[10]*o+r[14],e[15]=r[3]*n+r[7]*i+r[11]*o+r[15]):(a=r[0],s=r[1],l=r[2],c=r[3],f=r[4],u=r[5],p=r[6],v=r[7],d=r[8],m=r[9],y=r[10],x=r[11],e[0]=a,e[1]=s,e[2]=l,e[3]=c,e[4]=f,e[5]=u,e[6]=p,e[7]=v,e[8]=d,e[9]=m,e[10]=y,e[11]=x,e[12]=a*n+f*i+d*o+r[12],e[13]=s*n+u*i+m*o+r[13],e[14]=l*n+p*i+y*o+r[14],e[15]=c*n+v*i+x*o+r[15]),e}function cr(e,r,t){var n=t[0],i=t[1],o=t[2];return e[0]=r[0]*n,e[1]=r[1]*n,e[2]=r[2]*n,e[3]=r[3]*n,e[4]=r[4]*i,e[5]=r[5]*i,e[6]=r[6]*i,e[7]=r[7]*i,e[8]=r[8]*o,e[9]=r[9]*o,e[10]=r[10]*o,e[11]=r[11]*o,e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],e}function Hi(e,r,t){var n=Math.sin(t),i=Math.cos(t),o=r[4],a=r[5],s=r[6],l=r[7],c=r[8],f=r[9],u=r[10],p=r[11];return r!==e&&(e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15]),e[4]=o*i+c*n,e[5]=a*i+f*n,e[6]=s*i+u*n,e[7]=l*i+p*n,e[8]=c*i-o*n,e[9]=f*i-a*n,e[10]=u*i-s*n,e[11]=p*i-l*n,e}function $i(e,r,t){var n=Math.sin(t),i=Math.cos(t),o=r[0],a=r[1],s=r[2],l=r[3],c=r[4],f=r[5],u=r[6],p=r[7];return r!==e&&(e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15]),e[0]=o*i+c*n,e[1]=a*i+f*n,e[2]=s*i+u*n,e[3]=l*i+p*n,e[4]=c*i-o*n,e[5]=f*i-a*n,e[6]=u*i-s*n,e[7]=p*i-l*n,e}function af(e,r,t,n,i){var o=1/Math.tan(r/2),a;return e[0]=o/t,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,i!=null&&i!==1/0?(a=1/(n-i),e[10]=(i+n)*a,e[14]=2*i*n*a):(e[10]=-1,e[14]=-2*n),e}var Yi=af;function Mn(e,r){var t=e[0],n=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],c=e[7],f=e[8],u=e[9],p=e[10],v=e[11],d=e[12],m=e[13],y=e[14],x=e[15],S=r[0],h=r[1],P=r[2],_=r[3],M=r[4],C=r[5],b=r[6],O=r[7],I=r[8],A=r[9],L=r[10],T=r[11],w=r[12],R=r[13],Z=r[14],k=r[15];return Math.abs(t-S)<=H*Math.max(1,Math.abs(t),Math.abs(S))&&Math.abs(n-h)<=H*Math.max(1,Math.abs(n),Math.abs(h))&&Math.abs(i-P)<=H*Math.max(1,Math.abs(i),Math.abs(P))&&Math.abs(o-_)<=H*Math.max(1,Math.abs(o),Math.abs(_))&&Math.abs(a-M)<=H*Math.max(1,Math.abs(a),Math.abs(M))&&Math.abs(s-C)<=H*Math.max(1,Math.abs(s),Math.abs(C))&&Math.abs(l-b)<=H*Math.max(1,Math.abs(l),Math.abs(b))&&Math.abs(c-O)<=H*Math.max(1,Math.abs(c),Math.abs(O))&&Math.abs(f-I)<=H*Math.max(1,Math.abs(f),Math.abs(I))&&Math.abs(u-A)<=H*Math.max(1,Math.abs(u),Math.abs(A))&&Math.abs(p-L)<=H*Math.max(1,Math.abs(p),Math.abs(L))&&Math.abs(v-T)<=H*Math.max(1,Math.abs(v),Math.abs(T))&&Math.abs(d-w)<=H*Math.max(1,Math.abs(d),Math.abs(w))&&Math.abs(m-R)<=H*Math.max(1,Math.abs(m),Math.abs(R))&&Math.abs(y-Z)<=H*Math.max(1,Math.abs(y),Math.abs(Z))&&Math.abs(x-k)<=H*Math.max(1,Math.abs(x),Math.abs(k))}function sf(){var e=new le(2);return le!=Float32Array&&(e[0]=0,e[1]=0),e}function Cn(e,r,t){return e[0]=r[0]+t[0],e[1]=r[1]+t[1],e}function Xi(e,r){return e[0]=-r[0],e[1]=-r[1],e}function fr(e,r,t,n){var i=r[0],o=r[1];return e[0]=i+n*(t[0]-i),e[1]=o+n*(t[1]-o),e}var Av=function(){var e=sf();return function(r,t,n,i,o,a){var s,l;for(t||(t=2),n||(n=0),i?l=Math.min(i*t+n,r.length):l=r.length,s=n;s<l;s+=t)e[0]=r[s],e[1]=r[s+1],o(e,e,a),r[s]=e[0],r[s+1]=e[1];return r}}();function lf(){var e=new le(3);return le!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function qi(e,r,t){return e[0]=r[0]+t[0],e[1]=r[1]+t[1],e[2]=r[2]+t[2],e}function cf(e,r,t){return e[0]=r[0]*t[0],e[1]=r[1]*t[1],e[2]=r[2]*t[2],e}function Ji(e,r){return e[0]=-r[0],e[1]=-r[1],e[2]=-r[2],e}var Qi=cf;var Iv=function(){var e=lf();return function(r,t,n,i,o,a){var s,l;for(t||(t=3),n||(n=0),i?l=Math.min(i*t+n,r.length):l=r.length,s=n;s<l;s+=t)e[0]=r[s],e[1]=r[s+1],e[2]=r[s+2],o(e,e,a),r[s]=e[0],r[s+1]=e[1],r[s+2]=e[2];return r}}();function re(e,r){if(!e)throw new Error(r||"@math.gl/web-mercator: assertion failed.")}var ne=Math.PI,ro=ne/4,ce=ne/180,wn=180/ne,pt=512,to=4003e4,Ge=85.051129,On=1.5;function ur(e){return Math.pow(2,e)}function Q(e){var r=K(e,2),t=r[0],n=r[1];re(Number.isFinite(t)),re(Number.isFinite(n)&&n>=-90&&n<=90,"invalid latitude");var i=t*ce,o=n*ce,a=pt*(i+ne)/(2*ne),s=pt*(ne+Math.log(Math.tan(ro+o*.5)))/(2*ne);return[a,s]}function ie(e){var r=K(e,2),t=r[0],n=r[1],i=t/pt*(2*ne)-ne,o=2*(Math.atan(Math.exp(n/pt*(2*ne)-ne))-ro);return[i*wn,o*wn]}function Ln(e){var r=e.latitude,t=e.longitude,n=e.highPrecision,i=n===void 0?!1:n;re(Number.isFinite(r)&&Number.isFinite(t));var o=pt,a=Math.cos(r*ce),s=o/360,l=s/a,c=o/to/a,f={unitsPerMeter:[c,c,c],metersPerUnit:[1/c,1/c,1/c],unitsPerDegree:[s,l,c],degreesPerUnit:[1/s,1/l,1/c]};if(i){var u=ce*Math.tan(r*ce)/a,p=s*u/2,v=o/to*u,d=v/l*c;f.unitsPerDegree2=[0,p,v],f.unitsPerMeter2=[d,0,d]}return f}function An(e){var r=e.height,t=e.pitch,n=e.bearing,i=e.altitude,o=e.scale,a=e.center,s=Ue();ut(s,s,[0,0,-i]),Hi(s,s,-t*ce),$i(s,s,n*ce);var l=o/r;return cr(s,s,[l,l,l]),a&&ut(s,s,Ji([],a)),s}function no(e){var r=e.width,t=e.height,n=e.altitude,i=e.pitch,o=i===void 0?0:i,a=e.offset,s=e.center,l=e.scale,c=e.nearZMultiplier,f=c===void 0?1:c,u=e.farZMultiplier,p=u===void 0?1:u,v=e.fovy,d=v===void 0?Be(On):v;n!==void 0&&(d=Be(n));var m=d*ce,y=o*ce,x=pr(d),S=x;s&&(S+=s[2]*l/Math.cos(y)/t);var h=m*(.5+(a?a[1]:0)/t),P=Math.sin(h)*S/Math.sin(ft(Math.PI/2-y-h,.01,Math.PI-.01)),_=Math.sin(y)*P+S,M=S*10,C=Math.min(_*p,M);return{fov:m,aspect:r/t,focalDistance:x,near:f,far:C}}function In(e){var r=no(e),t=r.fov,n=r.aspect,i=r.near,o=r.far,a=Yi([],t,n,i,o);return a}function Be(e){return 2*Math.atan(.5/e)*wn}function pr(e){return .5/Math.tan(.5*e*ce)}function Tn(e,r){var t=K(e,3),n=t[0],i=t[1],o=t[2],a=o===void 0?0:o;return re(Number.isFinite(n)&&Number.isFinite(i)&&Number.isFinite(a)),Pe(r,[n,i,a,1])}function vr(e,r){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,n=K(e,3),i=n[0],o=n[1],a=n[2];if(re(Number.isFinite(i)&&Number.isFinite(o),"invalid pixel coordinate"),Number.isFinite(a)){var s=Pe(r,[i,o,a,1]);return s}var l=Pe(r,[i,o,0,1]),c=Pe(r,[i,o,1,1]),f=l[2],u=c[2],p=f===u?0:((t||0)-f)/(u-f);return fr([],l,c,p)}function dr(e){var r=e.width,t=e.height,n=e.bounds,i=e.minExtent,o=i===void 0?0:i,a=e.maxZoom,s=a===void 0?24:a,l=e.offset,c=l===void 0?[0,0]:l,f=K(n,2),u=K(f[0],2),p=u[0],v=u[1],d=K(f[1],2),m=d[0],y=d[1],x=ff(e.padding),S=Q([p,ft(y,-Ge,Ge)]),h=Q([m,ft(v,-Ge,Ge)]),P=[Math.max(Math.abs(h[0]-S[0]),o),Math.max(Math.abs(h[1]-S[1]),o)],_=[r-x.left-x.right-Math.abs(c[0])*2,t-x.top-x.bottom-Math.abs(c[1])*2];re(_[0]>0&&_[1]>0);var M=_[0]/P[0],C=_[1]/P[1],b=(x.right-x.left)/2/M,O=(x.bottom-x.top)/2/C,I=[(h[0]+S[0])/2+b,(h[1]+S[1])/2+O],A=ie(I),L=Math.min(s,sr(Math.abs(Math.min(M,C))));return re(Number.isFinite(L)),{longitude:A[0],latitude:A[1],zoom:L}}function ff(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return typeof e=="number"?{top:e,bottom:e,left:e,right:e}:(re(Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&Number.isFinite(e.left)&&Number.isFinite(e.right)),e)}var io=Math.PI/180;function gr(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=e.width,n=e.height,i=e.unproject,o={targetZ:r},a=i([0,n],o),s=i([t,n],o),l,c,f=e.fovy?.5*e.fovy*io:Math.atan(.5/e.altitude),u=(90-e.pitch)*io;return f>u-.01?(l=oo(e,0,r),c=oo(e,t,r)):(l=i([0,0],o),c=i([t,0],o)),[a,s,c,l]}function oo(e,r,t){var n=e.pixelUnprojectionMatrix,i=Pe(n,[r,0,1,1]),o=Pe(n,[r,e.height,1,1]),a=t*e.distanceScales.unitsPerMeter[2],s=(a-i[2])/(o[2]-i[2]),l=fr([],i,o,s),c=ie(l);return c.push(t),c}var ao=function(){function e(){var r=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{width:1,height:1};_n(this,e),F(this,"latitude",void 0),F(this,"longitude",void 0),F(this,"zoom",void 0),F(this,"pitch",void 0),F(this,"bearing",void 0),F(this,"altitude",void 0),F(this,"fovy",void 0),F(this,"meterOffset",void 0),F(this,"center",void 0),F(this,"width",void 0),F(this,"height",void 0),F(this,"scale",void 0),F(this,"distanceScales",void 0),F(this,"viewMatrix",void 0),F(this,"projectionMatrix",void 0),F(this,"viewProjectionMatrix",void 0),F(this,"pixelProjectionMatrix",void 0),F(this,"pixelUnprojectionMatrix",void 0),F(this,"equals",function(L){return L instanceof e?L.width===r.width&&L.height===r.height&&Mn(L.projectionMatrix,r.projectionMatrix)&&Mn(L.viewMatrix,r.viewMatrix):!1}),F(this,"project",function(L){var T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},w=T.topLeft,R=w===void 0?!0:w,Z=r.projectPosition(L),k=Tn(Z,r.pixelProjectionMatrix),E=K(k,2),z=E[0],ve=E[1],de=R?ve:r.height-ve;return L.length===2?[z,de]:[z,de,k[2]]}),F(this,"unproject",function(L){var T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},w=T.topLeft,R=w===void 0?!0:w,Z=T.targetZ,k=Z===void 0?void 0:Z,E=K(L,3),z=E[0],ve=E[1],de=E[2],Kt=R?ve:r.height-ve,on=k&&k*r.distanceScales.unitsPerMeter[2],fi=vr([z,Kt,de],r.pixelUnprojectionMatrix,on),an=r.unprojectPosition(fi),sn=K(an,3),ln=sn[0],cn=sn[1],Oc=sn[2];return Number.isFinite(de)?[ln,cn,Oc]:Number.isFinite(k)?[ln,cn,k]:[ln,cn]}),F(this,"projectPosition",function(L){var T=Q(L),w=K(T,2),R=w[0],Z=w[1],k=(L[2]||0)*r.distanceScales.unitsPerMeter[2];return[R,Z,k]}),F(this,"unprojectPosition",function(L){var T=ie(L),w=K(T,2),R=w[0],Z=w[1],k=(L[2]||0)*r.distanceScales.metersPerUnit[2];return[R,Z,k]});var n=t.width,i=t.height,o=t.altitude,a=o===void 0?null:o,s=t.fovy,l=s===void 0?null:s,c=t.latitude,f=c===void 0?0:c,u=t.longitude,p=u===void 0?0:u,v=t.zoom,d=v===void 0?0:v,m=t.pitch,y=m===void 0?0:m,x=t.bearing,S=x===void 0?0:x,h=t.position,P=h===void 0?null:h,_=t.nearZMultiplier,M=_===void 0?.02:_,C=t.farZMultiplier,b=C===void 0?1.01:C;n=n||1,i=i||1,l===null&&a===null?(a=On,l=Be(a)):l===null?l=Be(a):a===null&&(a=pr(l));var O=ur(d);a=Math.max(.75,a);var I=Ln({longitude:p,latitude:f}),A=Q([p,f]);A.push(0),P&&qi(A,A,Qi([],P,I.unitsPerMeter)),this.projectionMatrix=In({width:n,height:i,scale:O,center:A,pitch:y,fovy:l,nearZMultiplier:M,farZMultiplier:b}),this.viewMatrix=An({height:i,scale:O,center:A,pitch:y,bearing:S,altitude:a}),this.width=n,this.height=i,this.scale=O,this.latitude=f,this.longitude=p,this.zoom=d,this.pitch=y,this.bearing=S,this.altitude=a,this.fovy=l,this.center=A,this.meterOffset=P||[0,0,0],this.distanceScales=I,this._initMatrices(),Object.freeze(this)}return Sn(e,[{key:"_initMatrices",value:function(){var t=this.width,n=this.height,i=this.projectionMatrix,o=this.viewMatrix,a=Ue();lr(a,a,i),lr(a,a,o),this.viewProjectionMatrix=a;var s=Ue();cr(s,s,[t/2,-n/2,1]),ut(s,s,[1,-1,0]),lr(s,s,a);var l=Vi(Ue(),s);if(!l)throw new Error("Pixel project matrix not invertible");this.pixelProjectionMatrix=s,this.pixelUnprojectionMatrix=l}},{key:"projectFlat",value:function(t){return Q(t)}},{key:"unprojectFlat",value:function(t){return ie(t)}},{key:"getMapCenterByLngLatPosition",value:function(t){var n=t.lngLat,i=t.pos,o=vr(i,this.pixelUnprojectionMatrix),a=Q(n),s=Cn([],a,Xi([],o)),l=Cn([],this.center,s);return ie(l)}},{key:"fitBounds",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=this.width,o=this.height,a=dr(Object.assign({width:i,height:o,bounds:t},n)),s=a.longitude,l=a.latitude,c=a.zoom;return new e({width:i,height:o,longitude:s,latitude:l,zoom:c})}},{key:"getBounds",value:function(t){var n=this.getBoundingRegion(t),i=Math.min.apply(Math,We(n.map(function(l){return l[0]}))),o=Math.max.apply(Math,We(n.map(function(l){return l[0]}))),a=Math.min.apply(Math,We(n.map(function(l){return l[1]}))),s=Math.max.apply(Math,We(n.map(function(l){return l[1]})));return[[i,a],[o,s]]}},{key:"getBoundingRegion",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return gr(this,t.z||0)}},{key:"getLocationAtPoint",value:function(t){var n=t.lngLat,i=t.pos;return this.getMapCenterByLngLatPosition({lngLat:n,pos:i})}}]),e}();var wd=1/Math.PI*180,Od=1/180*Math.PI,vt={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0};function Ze(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Ve(e,r,t){return Ze(e)?e.map(function(n,i){return Ve(n,r[i],t)}):t*r+(1-t)*e}function He(e,r,t){var n=vt.EPSILON;t&&(vt.EPSILON=t);try{if(e===r)return!0;if(Ze(e)&&Ze(r)){if(e.length!==r.length)return!1;for(var i=0;i<e.length;++i)if(!He(e[i],r[i]))return!1;return!0}return e&&e.equals?e.equals(r):r&&r.equals?r.equals(e):typeof e=="number"&&typeof r=="number"?Math.abs(e-r)<=vt.EPSILON*Math.max(1,Math.abs(e),Math.abs(r)):!1}finally{vt.EPSILON=n}}var pf=new Uint16Array([0,2,1,0,3,2]),vf=new Float32Array([0,1,0,0,1,0,1,1]);function En(e,r){if(!r)return df(e);for(var t=Math.max(Math.abs(e[0][0]-e[3][0]),Math.abs(e[1][0]-e[2][0])),n=Math.max(Math.abs(e[1][1]-e[0][1]),Math.abs(e[2][1]-e[3][1])),i=Math.ceil(t/r)+1,o=Math.ceil(n/r)+1,a=(i-1)*(o-1)*6,s=new Uint32Array(a),l=new Float32Array(i*o*2),c=new Float64Array(i*o*3),f=0,u=0,p=0;p<i;p++)for(var v=p/(i-1),d=0;d<o;d++){var m=d/(o-1),y=gf(e,v,m);c[f*3+0]=y[0],c[f*3+1]=y[1],c[f*3+2]=y[2]||0,l[f*2+0]=v,l[f*2+1]=1-m,p>0&&d>0&&(s[u++]=f-o,s[u++]=f-o-1,s[u++]=f-1,s[u++]=f-o,s[u++]=f-1,s[u++]=f),f++}return{vertexCount:a,positions:c,indices:s,texCoords:l}}function df(e){for(var r=new Float64Array(12),t=0;t<e.length;t++)r[t*3+0]=e[t][0],r[t*3+1]=e[t][1],r[t*3+2]=e[t][2]||0;return{vertexCount:6,positions:r,indices:pf,texCoords:vf}}function gf(e,r,t){return Ve(Ve(e[0],e[1],t),Ve(e[3],e[2],t),r)}var so=` #define SHADER_NAME bitmap-layer-vertex-shader attribute vec2 texCoords; attribute vec3 positions; attribute vec3 positions64Low; varying vec2 vTexCoord; varying vec2 vTexPos; uniform float coordinateConversion; const vec3 pickingColor = vec3(1.0, 0.0, 0.0); void main(void) { geometry.worldPosition = positions; geometry.uv = texCoords; geometry.pickingColor = pickingColor; gl_Position = project_position_to_clipspace(positions, positions64Low, vec3(0.0), geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); vTexCoord = texCoords; if (coordinateConversion < -0.5) { vTexPos = geometry.position.xy + project_uCommonOrigin.xy; } else if (coordinateConversion > 0.5) { vTexPos = geometry.worldPosition.xy; } vec4 color = vec4(0.0); DECKGL_FILTER_COLOR(color, geometry); } `;var hf=` vec3 packUVsIntoRGB(vec2 uv) { // Extract the top 8 bits. We want values to be truncated down so we can add a fraction vec2 uv8bit = floor(uv * 256.); // Calculate the normalized remainders of u and v parts that do not fit into 8 bits // Scale and clamp to 0-1 range vec2 uvFraction = fract(uv * 256.); vec2 uvFraction4bit = floor(uvFraction * 16.); // Remainder can be encoded in blue channel, encode as 4 bits for pixel coordinates float fractions = uvFraction4bit.x + uvFraction4bit.y * 16.; return vec3(uv8bit, fractions) / 255.; } `,lo=` #define SHADER_NAME bitmap-layer-fragment-shader #ifdef GL_ES precision highp float; #endif uniform sampler2D bitmapTexture; varying vec2 vTexCoord; varying vec2 vTexPos; uniform float desaturate; uniform vec4 transparentColor; uniform vec3 tintColor; uniform float opacity; uniform float coordinateConversion; uniform vec4 bounds; /* projection utils */ const float TILE_SIZE = 512.0; const float PI = 3.1415926536; const float WORLD_SCALE = TILE_SIZE / PI / 2.0; // from degrees to Web Mercator vec2 lnglat_to_mercator(vec2 lnglat) { float x = lnglat.x; float y = clamp(lnglat.y, -89.9, 89.9); return vec2( radians(x) + PI, PI + log(tan(PI * 0.25 + radians(y) * 0.5)) ) * WORLD_SCALE; } // from Web Mercator to degrees vec2 mercator_to_lnglat(vec2 xy) { xy /= WORLD_SCALE; return degrees(vec2( xy.x - PI, atan(exp(xy.y - PI)) * 2.0 - PI * 0.5 )); } /* End projection utils */ // apply desaturation vec3 color_desaturate(vec3 color) { float luminance = (color.r + color.g + color.b) * 0.333333333; return mix(color, vec3(luminance), desaturate); } // apply tint vec3 color_tint(vec3 color) { return color * tintColor; } // blend with background color vec4 apply_opacity(vec3 color, float alpha) { if (transparentColor.a == 0.0) { return vec4(color, alpha); } float blendedAlpha = alpha + transparentColor.a * (1.0 - alpha); float highLightRatio = alpha / blendedAlpha; vec3 blendedRGB = mix(transparentColor.rgb, color, highLightRatio); return vec4(blendedRGB, blendedAlpha); } vec2 getUV(vec2 pos) { return vec2( (pos.x - bounds[0]) / (bounds[2] - bounds[0]), (pos.y - bounds[3]) / (bounds[1] - bounds[3]) ); } `.concat(hf,` void main(void) { vec2 uv = vTexCoord; if (coordinateConversion < -0.5) { vec2 lnglat = mercator_to_lnglat(vTexPos); uv = getUV(lnglat); } else if (coordinateConversion > 0.5) { vec2 commonPos = lnglat_to_mercator(vTexPos); uv = getUV(commonPos); } vec4 bitmapColor = texture2D(bitmapTexture, uv); gl_FragColor = apply_opacity(color_tint(color_desaturate(bitmapColor.rgb)), bitmapColor.a * opacity); geometry.uv = uv; DECKGL_FILTER_COLOR(gl_FragColor, geometry); if (picking_uActive && !picking_uAttribute) { // Since instance information is not used, we can use picking color for pixel index gl_FragColor.rgb = packUVsIntoRGB(uv); } } `);function co(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),t.push.apply(t,n)}return t}function dt(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?co(Object(t),!0).forEach(function(n){(0,ht.default)(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):co(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function mf(e){var r=yf();return function(){var n=(0,gt.default)(e),i;if(r){var o=(0,gt.default)(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return(0,mo.default)(this,i)}}function yf(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var xf={image:{type:"image",value:null,async:!0},bounds:{type:"array",value:[1,0,0,1],compare:!0},_imageCoordinateSystem:oe.COORDINATE_SYSTEM.DEFAULT,desaturate:{type:"number",min:0,max:1,value:0},transparentColor:{type:"color",value:[0,0,0,0]},tintColor:{type:"color",value:[255,255,255]},textureParameters:{type:"object",ignore:!0}},mr=function(e){(0,ho.default)(t,e);var r=mf(t);function t(){var n;(0,po.default)(this,t);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return n=r.call.apply(r,[this].concat(o)),(0,ht.default)((0,go.default)(n),"state",void 0),n}return(0,vo.default)(t,[{key:"getShaders",value:function(){return(0,Rn.default)((0,gt.default)(t.prototype),"getShaders",this).call(this,{vs:so,fs:lo,modules:[oe.project32,oe.picking]})}},{key:"initializeState",value:function(){var i=this,o=this.getAttributeManager();o.remove(["instancePickingColors"]);var a=!0;o.add({indices:{size:1,isIndexed:!0,update:function(l){return l.value=i.state.mesh.indices},noAlloc:a},positions:{size:3,type:5130,fp64:this.use64bitPositions(),update:function(l){return l.value=i.state.mesh.positions},noAlloc:a},texCoords:{size:2,update:function(l){return l.value=i.state.mesh.texCoords},noAlloc:a}})}},{key:"updateState",value:function(i){var o=i.props,a=i.oldProps,s=i.changeFlags,l=this.getAttributeManager();if(s.extensionsChanged){var c,f=this.context.gl;(c=this.state.model)===null||c===void 0||c.delete(),this.state.model=this._getModel(f),l.invalidateAll()}if(o.bounds!==a.bounds){var u=this.state.mesh,p=this._createMesh();this.state.model.setVertexCount(p.vertexCount);for(var v in p)u&&u[v]!==p[v]&&l.invalidate(v);this.setState(dt({mesh:p},this._getCoordinateUniforms()))}else o._imageCoordinateSystem!==a._imageCoordinateSystem&&this.setState(this._getCoordinateUniforms())}},{key:"getPickingInfo",value:function(i){var o=this.props.image,a=i.info;if(!a.color||!o)return a.bitmap=null,a;var s=o,l=s.width,c=s.height;a.index=0;var f=Pf(a.color),u=[Math.floor(f[0]*l),Math.floor(f[1]*c)];return a.bitmap={size:{width:l,height:c},uv:f,pixel:u},a}},{key:"disablePickingIndex",value:function(){this.setState({disablePicking:!0})}},{key:"restorePickingColors",value:function(){this.setState({disablePicking:!1})}},{key:"_updateAutoHighlight",value:function(i){(0,Rn.default)((0,gt.default)(t.prototype),"_updateAutoHighlight",this).call(this,dt(dt({},i),{},{color:this.encodePickingColor(0)}))}},{key:"_createMesh",value:function(){var i=this.props.bounds,o=i;return fo(i)&&(o=[[i[0],i[1]],[i[0],i[3]],[i[2],i[3]],[i[2],i[1]]]),En(o,this.context.viewport.resolution)}},{key:"_getModel",value:function(i){return i?new hr.Model(i,dt(dt({},this.getShaders()),{},{id:this.props.id,geometry:new hr.Geometry({drawMode:4,vertexCount:6}),isInstanced:!1})):null}},{key:"draw",value:function(i){var o=i.uniforms,a=i.moduleParameters,s=this.state,l=s.model,c=s.coordinateConversion,f=s.bounds,u=s.disablePicking,p=this.props,v=p.image,d=p.desaturate,m=p.transparentColor,y=p.tintColor;a.pickingActive&&u||v&&l&&l.setUniforms(o).setUniforms({bitmapTexture:v,desaturate:d,transparentColor:m.map(function(x){return x/255}),tintColor:y.slice(0,3).map(function(x){return x/255}),coordinateConversion:c,bounds:f}).draw()}},{key:"_getCoordinateUniforms",value:function(){var i=oe.COORDINATE_SYSTEM.LNGLAT,o=oe.COORDINATE_SYSTEM.CARTESIAN,a=oe.COORDINATE_SYSTEM.DEFAULT,s=this.props._imageCoordinateSystem;if(s!==a){var l=this.props.bounds;if(!fo(l))throw new Error("_imageCoordinateSystem only supports rectangular bounds");var c=this.context.viewport.resolution?i:o;if(s=s===i?i:o,s===i&&c===o)return{coordinateConversion:-1,bounds:l};if(s===o&&c===i){var f=Q([l[0],l[1]]),u=Q([l[2],l[3]]);return{coordinateConversion:1,bounds:[f[0],f[1],u[0],u[1]]}}}return{coordinateConversion:0,bounds:[0,0,0,0]}}}]),t}(oe.Layer);(0,ht.default)(mr,"layerName","BitmapLayer");(0,ht.default)(mr,"defaultProps",xf);function Pf(e){var r=(0,uo.default)(e,3),t=r[0],n=r[1],i=r[2],o=(i&240)/256,a=(i&15)/16