(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 On=Object.create;var Qt=Object.defineProperty;var Rn=Object.getOwnPropertyDescriptor;var Fn=Object.getOwnPropertyNames;var Dn=Object.getPrototypeOf,Nn=Object.prototype.hasOwnProperty;var pt=(o,t)=>()=>(t||o((t={exports:{}}).exports,t),t.exports),kn=(o,t)=>{for(var e in t)Qt(o,e,{get:t[e],enumerable:!0})},qt=(o,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Fn(t))!Nn.call(o,n)&&n!==e&&Qt(o,n,{get:()=>t[n],enumerable:!(i=Rn(t,n))||i.enumerable});return o},U=(o,t,e)=>(qt(o,t,"default"),e&&qt(e,t,"default")),P=(o,t,e)=>(e=o!=null?On(Dn(o)):{},qt(t||!o||!o.__esModule?Qt(e,"default",{value:o,enumerable:!0}):e,o)),Un=o=>qt(Qt({},"__esModule",{value:!0}),o);var L=pt((Os,Xe)=>{Xe.exports=globalThis.deck});var I=pt((Fs,Ye)=>{Ye.exports=globalThis.luma});var _o=pt((pl,Po)=>{Po.exports=globalThis.loaders});var Do=pt((bl,Fo)=>{Fo.exports=globalThis.luma});var Ai=pt((su,je)=>{"use strict";je.exports=he;je.exports.default=he;function he(o,t,e){e=e||2;var i=t&&t.length,n=i?t[0]*e:o.length,r=Ti(o,0,n,e,!0),s=[];if(!r||r.next===r.prev)return s;var a,l,c,u,f,g,d;if(i&&(r=$r(o,t,r,e)),o.length>80*e){a=c=o[0],l=u=o[1];for(var p=e;pc&&(c=f),g>u&&(u=g);d=Math.max(c-a,u-l),d=d!==0?32767/d:0}return Rt(r,s,e,a,l,d,0),s}function Ti(o,t,e,i,n){var r,s;if(n===Be(o,t,e,i)>0)for(r=t;r=t;r-=i)s=Mi(r,o[r],o[r+1],s);return s&&me(s,s.next)&&(Dt(s),s=s.next),s}function q(o,t){if(!o)return o;t||(t=o);var e=o,i;do if(i=!1,!e.steiner&&(me(e,e.next)||S(e.prev,e,e.next)===0)){if(Dt(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function Rt(o,t,e,i,n,r,s){if(o){!s&&r&&ts(o,i,n,r);for(var a=o,l,c;o.prev!==o.next;){if(l=o.prev,c=o.next,r?Zr(o,i,n,r):Hr(o)){t.push(l.i/e|0),t.push(o.i/e|0),t.push(c.i/e|0),Dt(o),o=c.next,a=c.next;continue}if(o=c,o===a){s?s===1?(o=Kr(q(o),t,e),Rt(o,t,e,i,n,r,2)):s===2&&Xr(o,t,e,i,n,r):Rt(q(o),t,e,i,n,r,1);break}}}}function Hr(o){var t=o.prev,e=o,i=o.next;if(S(t,e,i)>=0)return!1;for(var n=t.x,r=e.x,s=i.x,a=t.y,l=e.y,c=i.y,u=nr?n>s?n:s:r>s?r:s,d=a>l?a>c?a:c:l>c?l:c,p=i.next;p!==t;){if(p.x>=u&&p.x<=g&&p.y>=f&&p.y<=d&&st(n,a,r,l,s,c,p.x,p.y)&&S(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Zr(o,t,e,i){var n=o.prev,r=o,s=o.next;if(S(n,r,s)>=0)return!1;for(var a=n.x,l=r.x,c=s.x,u=n.y,f=r.y,g=s.y,d=al?a>c?a:c:l>c?l:c,m=u>f?u>g?u:g:f>g?f:g,y=Ge(d,p,t,e,i),_=Ge(h,m,t,e,i),x=o.prevZ,v=o.nextZ;x&&x.z>=y&&v&&v.z<=_;){if(x.x>=d&&x.x<=h&&x.y>=p&&x.y<=m&&x!==n&&x!==s&&st(a,u,l,f,c,g,x.x,x.y)&&S(x.prev,x,x.next)>=0||(x=x.prevZ,v.x>=d&&v.x<=h&&v.y>=p&&v.y<=m&&v!==n&&v!==s&&st(a,u,l,f,c,g,v.x,v.y)&&S(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;x&&x.z>=y;){if(x.x>=d&&x.x<=h&&x.y>=p&&x.y<=m&&x!==n&&x!==s&&st(a,u,l,f,c,g,x.x,x.y)&&S(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;v&&v.z<=_;){if(v.x>=d&&v.x<=h&&v.y>=p&&v.y<=m&&v!==n&&v!==s&&st(a,u,l,f,c,g,v.x,v.y)&&S(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Kr(o,t,e){var i=o;do{var n=i.prev,r=i.next.next;!me(n,r)&&bi(n,i,i.next,r)&&Ft(n,r)&&Ft(r,n)&&(t.push(n.i/e|0),t.push(i.i/e|0),t.push(r.i/e|0),Dt(i),Dt(i.next),i=o=r),i=i.next}while(i!==o);return q(i)}function Xr(o,t,e,i,n,r){var s=o;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&is(s,a)){var l=Ii(s,a);s=q(s,s.next),l=q(l,l.next),Rt(s,t,e,i,n,r,0),Rt(l,t,e,i,n,r,0);return}a=a.next}s=s.next}while(s!==o)}function $r(o,t,e,i){var n=[],r,s,a,l,c;for(r=0,s=t.length;r=e.next.y&&e.next.y!==e.y){var a=e.x+(n-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(a<=i&&a>r&&(r=a,s=e.x=e.x&&e.x>=c&&i!==e.x&&st(ns.x||e.x===s.x&&Qr(s,e)))&&(s=e,f=g)),e=e.next;while(e!==l);return s}function Qr(o,t){return S(o.prev,o,t.prev)<0&&S(t.next,o,o.next)<0}function ts(o,t,e,i){var n=o;do n.z===0&&(n.z=Ge(n.x,n.y,t,e,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==o);n.prevZ.nextZ=null,n.prevZ=null,es(n)}function es(o){var t,e,i,n,r,s,a,l,c=1;do{for(e=o,o=null,r=null,s=0;e;){for(s++,i=e,a=0,t=0;t0||l>0&&i;)a!==0&&(l===0||!i||e.z<=i.z)?(n=e,e=e.nextZ,a--):(n=i,i=i.nextZ,l--),r?r.nextZ=n:o=n,n.prevZ=r,r=n;e=i}r.nextZ=null,c*=2}while(s>1);return o}function Ge(o,t,e,i,n){return o=(o-e)*n|0,t=(t-i)*n|0,o=(o|o<<8)&16711935,o=(o|o<<4)&252645135,o=(o|o<<2)&858993459,o=(o|o<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,o|t<<1}function os(o){var t=o,e=o;do(t.x=(o-s)*(r-a)&&(o-s)*(i-a)>=(e-s)*(t-a)&&(e-s)*(r-a)>=(n-s)*(i-a)}function is(o,t){return o.next.i!==t.i&&o.prev.i!==t.i&&!ns(o,t)&&(Ft(o,t)&&Ft(t,o)&&rs(o,t)&&(S(o.prev,o,t.prev)||S(o,t.prev,t))||me(o,t)&&S(o.prev,o,o.next)>0&&S(t.prev,t,t.next)>0)}function S(o,t,e){return(t.y-o.y)*(e.x-t.x)-(t.x-o.x)*(e.y-t.y)}function me(o,t){return o.x===t.x&&o.y===t.y}function bi(o,t,e,i){var n=pe(S(o,t,e)),r=pe(S(o,t,i)),s=pe(S(e,i,o)),a=pe(S(e,i,t));return!!(n!==r&&s!==a||n===0&&de(o,e,t)||r===0&&de(o,i,t)||s===0&&de(e,o,i)||a===0&&de(e,t,i))}function de(o,t,e){return t.x<=Math.max(o.x,e.x)&&t.x>=Math.min(o.x,e.x)&&t.y<=Math.max(o.y,e.y)&&t.y>=Math.min(o.y,e.y)}function pe(o){return o>0?1:o<0?-1:0}function ns(o,t){var e=o;do{if(e.i!==o.i&&e.next.i!==o.i&&e.i!==t.i&&e.next.i!==t.i&&bi(e,e.next,o,t))return!0;e=e.next}while(e!==o);return!1}function Ft(o,t){return S(o.prev,o,o.next)<0?S(o,t,o.next)>=0&&S(o,o.prev,t)>=0:S(o,t,o.prev)<0||S(o,o.next,t)<0}function rs(o,t){var e=o,i=!1,n=(o.x+t.x)/2,r=(o.y+t.y)/2;do e.y>r!=e.next.y>r&&e.next.y!==e.y&&n<(e.next.x-e.x)*(r-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==o);return i}function Ii(o,t){var e=new We(o.i,o.x,o.y),i=new We(t.i,t.x,t.y),n=o.next,r=t.prev;return o.next=t,t.prev=o,e.next=n,n.prev=e,i.next=e,e.prev=i,r.next=i,i.prev=r,i}function Mi(o,t,e,i){var n=new We(o,t,e);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function Dt(o){o.next.prev=o.prev,o.prev.next=o.next,o.prevZ&&(o.prevZ.nextZ=o.nextZ),o.nextZ&&(o.nextZ.prevZ=o.prevZ)}function We(o,t,e){this.i=o,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}he.deviation=function(o,t,e,i){var n=t&&t.length,r=n?t[0]*e:o.length,s=Math.abs(Be(o,0,r,e));if(n)for(var a=0,l=t.length;a0&&(i+=o[n-1].length,e.holes.push(i))}return e}});var $t={};kn($t,{ArcLayer:()=>oo,BitmapLayer:()=>ho,ColumnLayer:()=>ge,GeoJsonLayer:()=>An,GridCellLayer:()=>hi,IconLayer:()=>it,LineLayer:()=>Ro,PathLayer:()=>rt,PointCloudLayer:()=>Ko,PolygonLayer:()=>Zi,ScatterplotLayer:()=>ae,SolidPolygonLayer:()=>lt,TextLayer:()=>Me,_MultiIconLayer:()=>Le,_TextBackgroundLayer:()=>we});var z={},$e=P(L(),1);U(z,P(L(),1));if(!$e.Layer)throw new Error("@deck.gl/core is not found");U($t,z);var G=P(L(),1),eo=P(I(),1);var Je=`uniform arcUniforms { bool greatCircle; bool useShortestPath; float numSegments; float widthScale; float widthMinPixels; float widthMaxPixels; highp int widthUnits; } arc; `,qe={name:"arc",vs:Je,fs:Je,uniformTypes:{greatCircle:"f32",useShortestPath:"f32",numSegments:"f32",widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",widthUnits:"i32"}};var Qe=`#version 300 es #define SHADER_NAME arc-layer-vertex-shader in vec4 instanceSourceColors; in vec4 instanceTargetColors; in vec3 instanceSourcePositions; in vec3 instanceSourcePositions64Low; in vec3 instanceTargetPositions; in vec3 instanceTargetPositions64Low; in vec3 instancePickingColors; in float instanceWidths; in float instanceHeights; in float instanceTilts; out vec4 vColor; out vec2 uv; out 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.viewportSize); 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 / (arc.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 = float(gl_VertexID / 2); float segmentSide = mod(float(gl_VertexID), 2.) == 0. ? -1. : 1.; float segmentRatio = getSegmentRatio(segmentIndex); float prevSegmentRatio = getSegmentRatio(max(0.0, segmentIndex - 1.0)); float nextSegmentRatio = getSegmentRatio(min(arc.numSegments - 1.0, segmentIndex + 1.0)); float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0)); isValid = 1.0; uv = vec2(segmentRatio, segmentSide); geometry.uv = uv; geometry.pickingColor = instancePickingColors; vec4 curr; vec4 next; vec3 source; vec3 target; if ((arc.greatCircle || project.projectionMode == PROJECTION_MODE_GLOBE) && project.coordinateSystem == 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 (arc.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 (arc.useShortestPath) { if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) { antiMeridianX = -(project.coordinateOrigin.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 (arc.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 * arc.widthScale, arc.widthUnits), arc.widthMinPixels, arc.widthMaxPixels ); vec3 offset = vec3( getExtrusionOffset((next.xy - curr.xy) * indexDir, segmentSide, 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 * layer.opacity); DECKGL_FILTER_COLOR(vColor, geometry); } `;var to=`#version 300 es #define SHADER_NAME arc-layer-fragment-shader precision highp float; in vec4 vColor; in vec2 uv; in float isValid; out vec4 fragColor; void main(void) { if (isValid == 0.0) { discard; } fragColor = vColor; geometry.uv = uv; DECKGL_FILTER_COLOR(fragColor, geometry); } `;var te=[0,0,0,255],Gn={getSourcePosition:{type:"accessor",value:o=>o.sourcePosition},getTargetPosition:{type:"accessor",value:o=>o.targetPosition},getSourceColor:{type:"accessor",value:te},getTargetColor:{type:"accessor",value:te},getWidth:{type:"accessor",value:1},getHeight:{type:"accessor",value:1},getTilt:{type:"accessor",value:0},greatCircle:!1,numSegments:{type:"number",value:50,min: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}},ht=class extends G.Layer{getBounds(){return this.getAttributeManager()?.getBounds(["instanceSourcePositions","instanceTargetPositions"])}getShaders(){return super.getShaders({vs:Qe,fs:to,modules:[G.project32,G.picking,qe]})}get wrapLongitude(){return!1}initializeState(){this.getAttributeManager().addInstanced({instanceSourcePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getSourcePosition"},instanceTargetPositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getTargetPosition"},instanceSourceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getSourceColor",defaultValue:te},instanceTargetColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getTargetColor",defaultValue:te},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}})}updateState(t){super.updateState(t),t.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:t}){let{widthUnits:e,widthScale:i,widthMinPixels:n,widthMaxPixels:r,greatCircle:s,wrapLongitude:a,numSegments:l}=this.props,c={numSegments:l,widthUnits:G.UNIT[e],widthScale:i,widthMinPixels:n,widthMaxPixels:r,greatCircle:s,useShortestPath:a},u=this.state.model;u.shaderInputs.setProps({arc:c}),u.setVertexCount(l*2),u.draw(this.context.renderPass)}_getModel(){return new eo.Model(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),topology:"triangle-strip",isInstanced:!0})}};ht.layerName="ArcLayer";ht.defaultProps=Gn;var oo=ht;var D=P(L(),1),po=P(I(),1);var js=1/Math.PI*180,Vs=1/180*Math.PI,Wn={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...Wn}};var Bn=globalThis.mathgl.config;function io(o){return Array.isArray(o)||ArrayBuffer.isView(o)&&!(o instanceof DataView)}function ot(o,t,e){return io(o)?o.map((i,n)=>ot(i,t[n],e)):e*t+(1-e)*o}function ee(o,t){if(!o)throw new Error(t||"@math.gl/web-mercator: assertion failed.")}var X=Math.PI,Zn=X/4,no=X/180,ha=180/X,ro=512;function $(o){let[t,e]=o;ee(Number.isFinite(t)),ee(Number.isFinite(e)&&e>=-90&&e<=90,"invalid latitude");let i=t*no,n=e*no,r=ro*(i+X)/(2*X),s=ro*(X+Math.log(Math.tan(Zn+n*.5)))/(2*X);return[r,s]}var La=Math.PI/180;var rr=new Uint32Array([0,2,1,0,3,2]),sr=new Float32Array([0,1,0,0,1,0,1,1]);function Ee(o,t){if(!t)return ar(o);let e=Math.max(Math.abs(o[0][0]-o[3][0]),Math.abs(o[1][0]-o[2][0])),i=Math.max(Math.abs(o[1][1]-o[0][1]),Math.abs(o[2][1]-o[3][1])),n=Math.ceil(e/t)+1,r=Math.ceil(i/t)+1,s=(n-1)*(r-1)*6,a=new Uint32Array(s),l=new Float32Array(n*r*2),c=new Float64Array(n*r*3),u=0,f=0;for(let g=0;g0&&p>0&&(a[f++]=u-r,a[f++]=u-r-1,a[f++]=u-1,a[f++]=u-r,a[f++]=u-1,a[f++]=u),u++}}return{vertexCount:s,positions:c,indices:a,texCoords:l}}function ar(o){let t=new Float64Array(12);for(let e=0;e",coordinateConversion:"f32",desaturate:"f32",tintColor:"vec3",transparentColor:"vec4"}};var uo=`#version 300 es #define SHADER_NAME bitmap-layer-vertex-shader in vec2 texCoords; in vec3 positions; in vec3 positions64Low; out vec2 vTexCoord; out vec2 vTexPos; 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 (bitmap.coordinateConversion < -0.5) { vTexPos = geometry.position.xy + project.commonOrigin.xy; } else if (bitmap.coordinateConversion > 0.5) { vTexPos = geometry.worldPosition.xy; } vec4 color = vec4(0.0); DECKGL_FILTER_COLOR(color, geometry); } `;var cr=` 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.; } `,fo=`#version 300 es #define SHADER_NAME bitmap-layer-fragment-shader #ifdef GL_ES precision highp float; #endif uniform sampler2D bitmapTexture; in vec2 vTexCoord; in vec2 vTexPos; out vec4 fragColor; /* 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), bitmap.desaturate); } // apply tint vec3 color_tint(vec3 color) { return color * bitmap.tintColor; } // blend with background color vec4 apply_opacity(vec3 color, float alpha) { if (bitmap.transparentColor.a == 0.0) { return vec4(color, alpha); } float blendedAlpha = alpha + bitmap.transparentColor.a * (1.0 - alpha); float highLightRatio = alpha / blendedAlpha; vec3 blendedRGB = mix(bitmap.transparentColor.rgb, color, highLightRatio); return vec4(blendedRGB, blendedAlpha); } vec2 getUV(vec2 pos) { return vec2( (pos.x - bitmap.bounds[0]) / (bitmap.bounds[2] - bitmap.bounds[0]), (pos.y - bitmap.bounds[3]) / (bitmap.bounds[1] - bitmap.bounds[3]) ); } ${cr} void main(void) { vec2 uv = vTexCoord; if (bitmap.coordinateConversion < -0.5) { vec2 lnglat = mercator_to_lnglat(vTexPos); uv = getUV(lnglat); } else if (bitmap.coordinateConversion > 0.5) { vec2 commonPos = lnglat_to_mercator(vTexPos); uv = getUV(commonPos); } vec4 bitmapColor = texture(bitmapTexture, uv); fragColor = apply_opacity(color_tint(color_desaturate(bitmapColor.rgb)), bitmapColor.a * layer.opacity); geometry.uv = uv; DECKGL_FILTER_COLOR(fragColor, geometry); if (bool(picking.isActive) && !bool(picking.isAttribute)) { // Since instance information is not used, we can use picking color for pixel index fragColor.rgb = packUVsIntoRGB(uv); } } `;var ur={image:{type:"image",value:null,async:!0},bounds:{type:"array",value:[1,0,0,1],compare:!0},_imageCoordinateSystem:D.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,value:null}},xt=class extends D.Layer{getShaders(){return super.getShaders({vs:uo,fs:fo,modules:[D.project32,D.picking,co]})}initializeState(){let t=this.getAttributeManager();t.remove(["instancePickingColors"]);let e=!0;t.add({indices:{size:1,isIndexed:!0,update:i=>i.value=this.state.mesh.indices,noAlloc:e},positions:{size:3,type:"float64",fp64:this.use64bitPositions(),update:i=>i.value=this.state.mesh.positions,noAlloc:e},texCoords:{size:2,update:i=>i.value=this.state.mesh.texCoords,noAlloc:e}})}updateState({props:t,oldProps:e,changeFlags:i}){let n=this.getAttributeManager();if(i.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),n.invalidateAll()),t.bounds!==e.bounds){let r=this.state.mesh,s=this._createMesh();this.state.model.setVertexCount(s.vertexCount);for(let a in s)r&&r[a]!==s[a]&&n.invalidate(a);this.setState({mesh:s,...this._getCoordinateUniforms()})}else t._imageCoordinateSystem!==e._imageCoordinateSystem&&this.setState(this._getCoordinateUniforms())}getPickingInfo(t){let{image:e}=this.props,i=t.info;if(!i.color||!e)return i.bitmap=null,i;let{width:n,height:r}=e;i.index=0;let s=fr(i.color);return i.bitmap={size:{width:n,height:r},uv:s,pixel:[Math.floor(s[0]*n),Math.floor(s[1]*r)]},i}disablePickingIndex(){this.setState({disablePicking:!0})}restorePickingColors(){this.setState({disablePicking:!1})}_updateAutoHighlight(t){super._updateAutoHighlight({...t,color:this.encodePickingColor(0)})}_createMesh(){let{bounds:t}=this.props,e=t;return go(t)&&(e=[[t[0],t[1]],[t[0],t[3]],[t[2],t[3]],[t[2],t[1]]]),Ee(e,this.context.viewport.resolution)}_getModel(){return new po.Model(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),topology:"triangle-list",isInstanced:!1})}draw(t){let{shaderModuleProps:e}=t,{model:i,coordinateConversion:n,bounds:r,disablePicking:s}=this.state,{image:a,desaturate:l,transparentColor:c,tintColor:u}=this.props;if(!(e.picking.isActive&&s)&&a&&i){let f={bitmapTexture:a,bounds:r,coordinateConversion:n,desaturate:l,tintColor:u.slice(0,3).map(g=>g/255),transparentColor:c.map(g=>g/255)};i.shaderInputs.setProps({bitmap:f}),i.draw(this.context.renderPass)}}_getCoordinateUniforms(){let{LNGLAT:t,CARTESIAN:e,DEFAULT:i}=D.COORDINATE_SYSTEM,{_imageCoordinateSystem:n}=this.props;if(n!==i){let{bounds:r}=this.props;if(!go(r))throw new Error("_imageCoordinateSystem only supports rectangular bounds");let s=this.context.viewport.resolution?t:e;if(n=n===t?t:e,n===t&&s===e)return{coordinateConversion:-1,bounds:r};if(n===e&&s===t){let a=$([r[0],r[1]]),l=$([r[2],r[3]]);return{coordinateConversion:1,bounds:[a[0],a[1],l[0],l[1]]}}}return{coordinateConversion:0,bounds:[0,0,0,0]}}};xt.layerName="BitmapLayer";xt.defaultProps=ur;var ho=xt;function fr(o){let[t,e,i]=o,n=(i&240)/256,r=(i&15)/16;return[(t+r)/256,(e+n)/256]}function go(o){return Number.isFinite(o[0])}var O=P(L(),1),oe=P(I(),1);var mo=`uniform iconUniforms { float sizeScale; vec2 iconsTextureDim; float sizeMinPixels; float sizeMaxPixels; bool billboard; highp int sizeUnits; float alphaCutoff; } icon; `,xo={name:"icon",vs:mo,fs:mo,uniformTypes:{sizeScale:"f32",iconsTextureDim:"vec2",sizeMinPixels:"f32",sizeMaxPixels:"f32",billboard:"f32",sizeUnits:"i32",alphaCutoff:"f32"}};var yo=`#version 300 es #define SHADER_NAME icon-layer-vertex-shader in vec2 positions; in vec3 instancePositions; in vec3 instancePositions64Low; in float instanceSizes; in float instanceAngles; in vec4 instanceColors; in vec3 instancePickingColors; in vec4 instanceIconFrames; in float instanceColorModes; in vec2 instanceOffsets; in vec2 instancePixelOffset; out float vColorMode; out vec4 vColor; out vec2 vTextureCoords; out vec2 uv; vec2 rotate_by_angle(vec2 vertex, float angle) { float angle_radian = angle * PI / 180.0; float cos_angle = cos(angle_radian); float sin_angle = sin(angle_radian); mat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle); return rotationMatrix * vertex; } void main(void) { geometry.worldPosition = instancePositions; geometry.uv = positions; geometry.pickingColor = instancePickingColors; uv = positions; vec2 iconSize = instanceIconFrames.zw; float sizePixels = clamp( project_size_to_pixel(instanceSizes * icon.sizeScale, icon.sizeUnits), icon.sizeMinPixels, icon.sizeMaxPixels ); float instanceScale = iconSize.y == 0.0 ? 0.0 : sizePixels / iconSize.y; vec2 pixelOffset = positions / 2.0 * iconSize + instanceOffsets; pixelOffset = rotate_by_angle(pixelOffset, instanceAngles) * instanceScale; pixelOffset += instancePixelOffset; pixelOffset.y *= -1.0; if (icon.billboard) { gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); vec3 offset = vec3(pixelOffset, 0.0); DECKGL_FILTER_SIZE(offset, geometry); gl_Position.xy += project_pixel_size_to_clipspace(offset.xy); } else { vec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0); DECKGL_FILTER_SIZE(offset_common, geometry); gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); } vTextureCoords = mix( instanceIconFrames.xy, instanceIconFrames.xy + iconSize, (positions.xy + 1.0) / 2.0 ) / icon.iconsTextureDim; vColor = instanceColors; DECKGL_FILTER_COLOR(vColor, geometry); vColorMode = instanceColorModes; } `;var vo=`#version 300 es #define SHADER_NAME icon-layer-fragment-shader precision highp float; uniform sampler2D iconsTexture; in float vColorMode; in vec4 vColor; in vec2 vTextureCoords; in vec2 uv; out vec4 fragColor; void main(void) { geometry.uv = uv; vec4 texColor = texture(iconsTexture, vTextureCoords); vec3 color = mix(texColor.rgb, vColor.rgb, vColorMode); float a = texColor.a * layer.opacity * vColor.a; if (a < icon.alphaCutoff) { discard; } fragColor = vec4(color, a); DECKGL_FILTER_COLOR(fragColor, geometry); } `;var wo=P(_o(),1),Mo=P(L(),1),gr=1024,dr=4,Co=()=>{},Lo={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},pr={x:0,y:0,width:0,height:0};function hr(o){return Math.pow(2,Math.ceil(Math.log2(o)))}function mr(o,t,e,i){let n=Math.min(e/t.width,i/t.height),r=Math.floor(t.width*n),s=Math.floor(t.height*n);return n===1?{image:t,width:r,height:s}:(o.canvas.height=s,o.canvas.width=r,o.clearRect(0,0,r,s),o.drawImage(t,0,0,t.width,t.height,0,0,r,s),{image:o.canvas,width:r,height:s})}function yt(o){return o&&(o.id||o.url)}function xr(o,t,e,i){let{width:n,height:r,device:s}=o,a=s.createTexture({format:"rgba8unorm",width:t,height:e,sampler:i,mipmaps:!0}),l=s.createCommandEncoder();return l.copyTextureToTexture({sourceTexture:o,destinationTexture:a,width:n,height:r}),l.finish(),o.destroy(),a}function So(o,t,e){for(let i=0;is&&(So(e,a,n),i=0,n=r+n+t,r=0,a=[]),a.push({icon:c,xOffset:i}),i=i+g+t,r=Math.max(r,f)}}return a.length>0&&So(e,a,n),{mapping:e,rowHeight:r,xOffset:i,yOffset:n,canvasWidth:s,canvasHeight:hr(r+n+t)}}function vr(o,t,e){if(!o||!t)return null;e=e||{};let i={},{iterable:n,objectInfo:r}=(0,Mo.createIterable)(o);for(let s of n){r.index++;let a=t(s,r),l=yt(a);if(!a)throw new Error("Icon is missing.");if(!a.url)throw new Error("Icon url is missing.");!i[l]&&(!e[l]||a.url!==e[l].url)&&(i[l]={...a,source:s,sourceIndex:r.index})}return i}var vt=class{constructor(t,{onUpdate:e=Co,onError:i=Co}){this._loadOptions=null,this._texture=null,this._externalTexture=null,this._mapping={},this._samplerParameters=null,this._pendingCount=0,this._autoPacking=!1,this._xOffset=0,this._yOffset=0,this._rowHeight=0,this._buffer=dr,this._canvasWidth=gr,this._canvasHeight=0,this._canvas=null,this.device=t,this.onUpdate=e,this.onError=i}finalize(){this._texture?.delete()}getTexture(){return this._texture||this._externalTexture}getIconMapping(t){let e=this._autoPacking?yt(t):t;return this._mapping[e]||pr}setProps({loadOptions:t,autoPacking:e,iconAtlas:i,iconMapping:n,textureParameters:r}){t&&(this._loadOptions=t),e!==void 0&&(this._autoPacking=e),n&&(this._mapping=n),i&&(this._texture?.delete(),this._texture=null,this._externalTexture=i),r&&(this._samplerParameters=r)}get isLoaded(){return this._pendingCount===0}packIcons(t,e){if(!this._autoPacking||typeof document>"u")return;let i=Object.values(vr(t,e,this._mapping)||{});if(i.length>0){let{mapping:n,xOffset:r,yOffset:s,rowHeight:a,canvasHeight:l}=yr({icons:i,buffer:this._buffer,canvasWidth:this._canvasWidth,mapping:this._mapping,rowHeight:this._rowHeight,xOffset:this._xOffset,yOffset:this._yOffset});this._rowHeight=a,this._mapping=n,this._xOffset=r,this._yOffset=s,this._canvasHeight=l,this._texture||(this._texture=this.device.createTexture({format:"rgba8unorm",width:this._canvasWidth,height:this._canvasHeight,sampler:this._samplerParameters||Lo,mipmaps:!0})),this._texture.height!==this._canvasHeight&&(this._texture=xr(this._texture,this._canvasWidth,this._canvasHeight,this._samplerParameters||Lo)),this.onUpdate(),this._canvas=this._canvas||document.createElement("canvas"),this._loadIcons(i)}}_loadIcons(t){let e=this._canvas.getContext("2d",{willReadFrequently:!0});for(let i of t)this._pendingCount++,(0,wo.load)(i.url,this._loadOptions).then(n=>{let r=yt(i),s=this._mapping[r],{x:a,y:l,width:c,height:u}=s,{image:f,width:g,height:d}=mr(e,n,c,u);this._texture?.copyExternalImage({image:f,x:a+(c-g)/2,y:l+(u-d)/2,width:g,height:d}),s.width=g,s.height=d,this._texture.generateMipmap(),this.onUpdate()}).catch(n=>{this.onError({url:i.url,source:i.source,sourceIndex:i.sourceIndex,loadOptions:this._loadOptions,error:n})}).finally(()=>{this._pendingCount--})}};var To=[0,0,0,255],Pr={iconAtlas:{type:"image",value:null,async:!0},iconMapping:{type:"object",value:{},async:!0},sizeScale:{type:"number",value:1,min:0},billboard:!0,sizeUnits:"pixels",sizeMinPixels:{type:"number",min:0,value:0},sizeMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},alphaCutoff:{type:"number",value:.05,min:0,max:1},getPosition:{type:"accessor",value:o=>o.position},getIcon:{type:"accessor",value:o=>o.icon},getColor:{type:"accessor",value:To},getSize:{type:"accessor",value:1},getAngle:{type:"accessor",value:0},getPixelOffset:{type:"accessor",value:[0,0]},onIconError:{type:"function",value:null,optional:!0},textureParameters:{type:"object",ignore:!0,value:null}},Pt=class extends O.Layer{getShaders(){return super.getShaders({vs:yo,fs:vo,modules:[O.project32,O.picking,xo]})}initializeState(){this.state={iconManager:new vt(this.context.device,{onUpdate:this._onUpdate.bind(this),onError:this._onError.bind(this)})},this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceSizes:{size:1,transition:!0,accessor:"getSize",defaultValue:1},instanceOffsets:{size:2,accessor:"getIcon",transform:this.getInstanceOffset},instanceIconFrames:{size:4,accessor:"getIcon",transform:this.getInstanceIconFrame},instanceColorModes:{size:1,type:"uint8",accessor:"getIcon",transform:this.getInstanceColorMode},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:To},instanceAngles:{size:1,transition:!0,accessor:"getAngle"},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset"}})}updateState(t){super.updateState(t);let{props:e,oldProps:i,changeFlags:n}=t,r=this.getAttributeManager(),{iconAtlas:s,iconMapping:a,data:l,getIcon:c,textureParameters:u}=e,{iconManager:f}=this.state;if(typeof s=="string")return;let g=s||this.internalState.isAsyncPropLoading("iconAtlas");f.setProps({loadOptions:e.loadOptions,autoPacking:!g,iconAtlas:s,iconMapping:g?a:null,textureParameters:u}),g?i.iconMapping!==e.iconMapping&&r.invalidate("getIcon"):(n.dataChanged||n.updateTriggersChanged&&(n.updateTriggersChanged.all||n.updateTriggersChanged.getIcon))&&f.packIcons(l,c),n.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),r.invalidateAll())}get isLoaded(){return super.isLoaded&&this.state.iconManager.isLoaded}finalizeState(t){super.finalizeState(t),this.state.iconManager.finalize()}draw({uniforms:t}){let{sizeScale:e,sizeMinPixels:i,sizeMaxPixels:n,sizeUnits:r,billboard:s,alphaCutoff:a}=this.props,{iconManager:l}=this.state,c=l.getTexture();if(c){let u=this.state.model,f={iconsTexture:c,iconsTextureDim:[c.width,c.height],sizeUnits:O.UNIT[r],sizeScale:e,sizeMinPixels:i,sizeMaxPixels:n,billboard:s,alphaCutoff:a};u.shaderInputs.setProps({icon:f}),u.draw(this.context.renderPass)}}_getModel(){let t=[-1,-1,1,-1,-1,1,1,1];return new oe.Model(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new oe.Geometry({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array(t)}}}),isInstanced:!0})}_onUpdate(){this.setNeedsRedraw()}_onError(t){let e=this.getCurrentLayer()?.props.onIconError;e?e(t):O.log.error(t.error.message)()}getInstanceOffset(t){let{width:e,height:i,anchorX:n=e/2,anchorY:r=i/2}=this.state.iconManager.getIconMapping(t);return[e/2-n,i/2-r]}getInstanceColorMode(t){return this.state.iconManager.getIconMapping(t).mask?1:0}getInstanceIconFrame(t){let{x:e,y:i,width:n,height:r}=this.state.iconManager.getIconMapping(t);return[e,i,n,r]}};Pt.defaultProps=Pr;Pt.layerName="IconLayer";var it=Pt;var W=P(L(),1),zo=P(I(),1),Oo=P(I(),1);var bo=`uniform lineUniforms { float widthScale; float widthMinPixels; float widthMaxPixels; float useShortestPath; highp int widthUnits; } line; `,Io={name:"line",vs:bo,fs:bo,uniformTypes:{widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",useShortestPath:"f32",widthUnits:"i32"}};var Ao=`#version 300 es #define SHADER_NAME line-layer-vertex-shader in vec3 positions; in vec3 instanceSourcePositions; in vec3 instanceTargetPositions; in vec3 instanceSourcePositions64Low; in vec3 instanceTargetPositions64Low; in vec4 instanceColors; in vec3 instancePickingColors; in float instanceWidths; out vec4 vColor; out vec2 uv; vec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction, float width) { vec2 dir_screenspace = normalize(line_clipspace * project.viewportSize); dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x); return dir_screenspace * offset_direction * width / 2.0; } vec3 splitLine(vec3 a, vec3 b, float x) { float t = (x - a.x) / (b.x - a.x); return vec3(x, mix(a.yz, b.yz, t)); } void main(void) { geometry.worldPosition = instanceSourcePositions; geometry.worldPositionAlt = instanceTargetPositions; vec3 source_world = instanceSourcePositions; vec3 target_world = instanceTargetPositions; vec3 source_world_64low = instanceSourcePositions64Low; vec3 target_world_64low = instanceTargetPositions64Low; if (line.useShortestPath > 0.5 || line.useShortestPath < -0.5) { 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 * line.useShortestPath > 180.) { source_world.x += 360. * line.useShortestPath; source_world = splitLine(source_world, target_world, 180. * line.useShortestPath); source_world_64low = vec3(0.0); } else if (deltaLng * line.useShortestPath < -180.) { target_world.x += 360. * line.useShortestPath; target_world = splitLine(source_world, target_world, 180. * line.useShortestPath); target_world_64low = vec3(0.0); } else if (line.useShortestPath < 0.) { gl_Position = vec4(0.); return; } } vec4 source_commonspace; vec4 target_commonspace; vec4 source = project_position_to_clipspace(source_world, source_world_64low, vec3(0.), source_commonspace); vec4 target = project_position_to_clipspace(target_world, target_world_64low, vec3(0.), target_commonspace); float segmentIndex = positions.x; vec4 p = mix(source, target, segmentIndex); geometry.position = mix(source_commonspace, target_commonspace, segmentIndex); uv = positions.xy; geometry.uv = uv; geometry.pickingColor = instancePickingColors; float widthPixels = clamp( project_size_to_pixel(instanceWidths * line.widthScale, line.widthUnits), line.widthMinPixels, line.widthMaxPixels ); vec3 offset = vec3( getExtrusionOffset(target.xy - source.xy, positions.y, widthPixels), 0.0); DECKGL_FILTER_SIZE(offset, geometry); DECKGL_FILTER_GL_POSITION(p, geometry); gl_Position = p + vec4(project_pixel_size_to_clipspace(offset.xy), 0.0, 0.0); vColor = vec4(instanceColors.rgb, instanceColors.a * layer.opacity); DECKGL_FILTER_COLOR(vColor, geometry); } `;var Eo=`#version 300 es #define SHADER_NAME line-layer-fragment-shader precision highp float; in vec4 vColor; in vec2 uv; out vec4 fragColor; void main(void) { geometry.uv = uv; fragColor = vColor; DECKGL_FILTER_COLOR(fragColor, geometry); } `;var _r=[0,0,0,255],Cr={getSourcePosition:{type:"accessor",value:o=>o.sourcePosition},getTargetPosition:{type:"accessor",value:o=>o.targetPosition},getColor:{type:"accessor",value:_r},getWidth:{type:"accessor",value: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}},_t=class extends W.Layer{getBounds(){return this.getAttributeManager()?.getBounds(["instanceSourcePositions","instanceTargetPositions"])}getShaders(){return super.getShaders({vs:Ao,fs:Eo,modules:[W.project32,W.picking,Io]})}get wrapLongitude(){return!1}initializeState(){this.getAttributeManager().addInstanced({instanceSourcePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getSourcePosition"},instanceTargetPositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getTargetPosition"},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:[0,0,0,255]},instanceWidths:{size:1,transition:!0,accessor:"getWidth",defaultValue:1}})}updateState(t){super.updateState(t),t.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:t}){let{widthUnits:e,widthScale:i,widthMinPixels:n,widthMaxPixels:r,wrapLongitude:s}=this.props,a=this.state.model,l={widthUnits:W.UNIT[e],widthScale:i,widthMinPixels:n,widthMaxPixels:r,useShortestPath:s?1:0};a.shaderInputs.setProps({line:l}),a.draw(this.context.renderPass),s&&(a.shaderInputs.setProps({line:{...l,useShortestPath:-1}}),a.draw(this.context.renderPass))}_getModel(){let t=[0,-1,0,0,1,0,1,-1,0,1,1,0];return new Oo.Model(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new zo.Geometry({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(t)}}}),isInstanced:!0})}};_t.layerName="LineLayer";_t.defaultProps=Cr;var Ro=_t;var j=P(L(),1),se=P(I(),1);var ko=P(Do(),1);var ze=`precision highp int; // #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX)) struct AmbientLight { vec3 color; }; struct PointLight { vec3 color; vec3 position; vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential }; struct DirectionalLight { vec3 color; vec3 direction; }; uniform lightingUniforms { int enabled; int lightType; int directionalLightCount; int pointLightCount; vec3 ambientColor; vec3 lightColor0; vec3 lightPosition0; vec3 lightDirection0; vec3 lightAttenuation0; vec3 lightColor1; vec3 lightPosition1; vec3 lightDirection1; vec3 lightAttenuation1; vec3 lightColor2; vec3 lightPosition2; vec3 lightDirection2; vec3 lightAttenuation2; } lighting; PointLight lighting_getPointLight(int index) { switch (index) { case 0: return PointLight(lighting.lightColor0, lighting.lightPosition0, lighting.lightAttenuation0); case 1: return PointLight(lighting.lightColor1, lighting.lightPosition1, lighting.lightAttenuation1); case 2: default: return PointLight(lighting.lightColor2, lighting.lightPosition2, lighting.lightAttenuation2); } } DirectionalLight lighting_getDirectionalLight(int index) { switch (index) { case 0: return DirectionalLight(lighting.lightColor0, lighting.lightDirection0); case 1: return DirectionalLight(lighting.lightColor1, lighting.lightDirection1); case 2: default: return DirectionalLight(lighting.lightColor2, lighting.lightDirection2); } } float getPointLightAttenuation(PointLight pointLight, float distance) { return pointLight.attenuation.x + pointLight.attenuation.y * distance + pointLight.attenuation.z * distance * distance; } // #endif `;var No=`// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX)) struct AmbientLight { color: vec3, }; struct PointLight { color: vec3, position: vec3, attenuation: vec3, // 2nd order x:Constant-y:Linear-z:Exponential }; struct DirectionalLight { color: vec3, direction: vec3, }; struct lightingUniforms { enabled: i32, poightCount: i32, directionalLightCount: i32, ambientColor: vec3, // TODO - support multiple lights by uncommenting arrays below lightType: i32, lightColor: vec3, lightDirection: vec3, lightPosition: vec3, lightAttenuation: vec3, // AmbientLight ambientLight; // PointLight pointLight[MAX_LIGHTS]; // DirectionalLight directionalLight[MAX_LIGHTS]; }; // Binding 0:1 is reserved for lighting (Note: could go into separate bind group as it is stable across draw calls) @binding(1) @group(0) var lighting : lightingUniforms; fn lighting_getPointLight(index: i32) -> PointLight { return PointLight(lighting.lightColor, lighting.lightPosition, lighting.lightAttenuation); } fn lighting_getDirectionalLight(index: i32) -> DirectionalLight { return DirectionalLight(lighting.lightColor, lighting.lightDirection); } fn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 { return pointLight.attenuation.x + pointLight.attenuation.y * distance + pointLight.attenuation.z * distance * distance; } `;var Uo=3,Lr=255,Ct;(function(o){o[o.POINT=0]="POINT",o[o.DIRECTIONAL=1]="DIRECTIONAL"})(Ct||(Ct={}));var Y={props:{},uniforms:{},name:"lighting",defines:{MAX_LIGHTS:Uo},uniformTypes:{enabled:"i32",lightType:"i32",directionalLightCount:"i32",pointLightCount:"i32",ambientLightColor:"vec3",lightColor0:"vec3",lightPosition0:"vec3",lightDirection0:"vec3",lightAttenuation0:"vec3",lightColor1:"vec3",lightPosition1:"vec3",lightDirection1:"vec3",lightAttenuation1:"vec3",lightColor2:"vec3",lightPosition2:"vec3",lightDirection2:"vec3",lightAttenuation2:"vec3"},defaultUniforms:{enabled:1,lightType:Ct.POINT,directionalLightCount:0,pointLightCount:0,ambientLightColor:[.1,.1,.1],lightColor0:[1,1,1],lightPosition0:[1,1,2],lightDirection0:[1,1,1],lightAttenuation0:[1,0,0],lightColor1:[1,1,1],lightPosition1:[1,1,2],lightDirection1:[1,1,1],lightAttenuation1:[1,0,0],lightColor2:[1,1,1],lightPosition2:[1,1,2],lightDirection2:[1,1,1],lightAttenuation2:[1,0,0]},source:No,vs:ze,fs:ze,getUniforms:Sr};function Sr(o,t={}){if(o=o&&{...o},!o)return{...Y.defaultUniforms};o.lights&&(o={...o,...Mr(o.lights),lights:void 0});let{ambientLight:e,pointLights:i,directionalLights:n}=o||{};if(!(e||i&&i.length>0||n&&n.length>0))return{...Y.defaultUniforms,enabled:0};let s={...Y.defaultUniforms,...t,...wr({ambientLight:e,pointLights:i,directionalLights:n})};return o.enabled!==void 0&&(s.enabled=o.enabled?1:0),s}function wr({ambientLight:o,pointLights:t=[],directionalLights:e=[]}){let i={};i.ambientLightColor=Oe(o);let n=0;for(let r of t){i.lightType=Ct.POINT;let s=n;i[`lightColor${s}`]=Oe(r),i[`lightPosition${s}`]=r.position,i[`lightAttenuation${s}`]=r.attenuation||[1,0,0],n++}for(let r of e){i.lightType=Ct.DIRECTIONAL;let s=n;i[`lightColor${s}`]=Oe(r),i[`lightDirection${s}`]=r.direction,n++}return n>Uo&&ko.log.warn("MAX_LIGHTS exceeded")(),i.directionalLightCount=e.length,i.pointLightCount=t.length,i}function Mr(o){let t={pointLights:[],directionalLights:[]};for(let e of o||[])switch(e.type){case"ambient":t.ambientLight=e;break;case"directional":t.directionalLights?.push(e);break;case"point":t.pointLights?.push(e);break;default:}return t}function Oe(o={}){let{color:t=[0,0,0],intensity:e=1}=o;return t.map(i=>i*e/Lr)}var ie=`uniform phongMaterialUniforms { uniform float ambient; uniform float diffuse; uniform float shininess; uniform vec3 specularColor; } material; `,ne=`uniform phongMaterialUniforms { uniform float ambient; uniform float diffuse; uniform float shininess; uniform vec3 specularColor; } material; vec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) { vec3 halfway_direction = normalize(light_direction + view_direction); float lambertian = dot(light_direction, normal_worldspace); float specular = 0.0; if (lambertian > 0.0) { float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0); specular = pow(specular_angle, material.shininess); } lambertian = max(lambertian, 0.0); return (lambertian * material.diffuse * surfaceColor + specular * material.specularColor) * color; } vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) { vec3 lightColor = surfaceColor; if (lighting.enabled == 0) { return lightColor; } vec3 view_direction = normalize(cameraPosition - position_worldspace); lightColor = material.ambient * surfaceColor * lighting.ambientColor; for (int i = 0; i < lighting.pointLightCount; i++) { PointLight pointLight = lighting_getPointLight(i); vec3 light_position_worldspace = pointLight.position; vec3 light_direction = normalize(light_position_worldspace - position_worldspace); float light_attenuation = getPointLightAttenuation(pointLight, distance(light_position_worldspace, position_worldspace)); lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color / light_attenuation); } int totalLights = min(MAX_LIGHTS, lighting.pointLightCount + lighting.directionalLightCount); for (int i = lighting.pointLightCount; i < totalLights; i++) { DirectionalLight directionalLight = lighting_getDirectionalLight(i); lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color); } return lightColor; } `;var B={props:{},name:"gouraudMaterial",vs:ne.replace("phongMaterial","gouraudMaterial"),fs:ie.replace("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:1},dependencies:[Y],uniformTypes:{ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3"},defaultUniforms:{ambient:.35,diffuse:.6,shininess:32,specularColor:[.15,.15,.15]},getUniforms(o){let t={...o};return t.specularColor&&(t.specularColor=t.specularColor.map(e=>e/255)),{...B.defaultUniforms,...t}}};var Go=`struct phongMaterialUniforms { ambient: f32, diffuse: f32, shininess: f32, specularColor: vec3, }; @binding(2) @group(0) var material : phongMaterialUniforms; fn lighting_getLightColor(surfaceColor: vec3, light_direction: vec3, view_direction: vec3, normal_worldspace: vec3, color: vec3) -> vec3 { let halfway_direction: vec3 = normalize(light_direction + view_direction); var lambertian: f32 = dot(light_direction, normal_worldspace); var specular: f32 = 0.0; if (lambertian > 0.0) { let specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0); specular = pow(specular_angle, material.shininess); } lambertian = max(lambertian, 0.0); return (lambertian * material.diffuse * surfaceColor + specular * material.specularColor) * color; } fn lighting_getLightColor2(surfaceColor: vec3, cameraPosition: vec3, position_worldspace: vec3, normal_worldspace: vec3) -> vec3 { var lightColor: vec3 = surfaceColor; if (lighting.enabled == 0) { return lightColor; } let view_direction: vec3 = normalize(cameraPosition - position_worldspace); lightColor = material.ambient * surfaceColor * lighting.ambientColor; if (lighting.lightType == 0) { let pointLight: PointLight = lighting_getPointLight(0); let light_position_worldspace: vec3 = pointLight.position; let light_direction: vec3 = normalize(light_position_worldspace - position_worldspace); lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color); } else if (lighting.lightType == 1) { var directionalLight: DirectionalLight = lighting_getDirectionalLight(0); lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color); } return lightColor; /* for (int i = 0; i < MAX_LIGHTS; i++) { if (i >= lighting.pointLightCount) { break; } PointLight pointLight = lighting.pointLight[i]; vec3 light_position_worldspace = pointLight.position; vec3 light_direction = normalize(light_position_worldspace - position_worldspace); lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color); } for (int i = 0; i < MAX_LIGHTS; i++) { if (i >= lighting.directionalLightCount) { break; } DirectionalLight directionalLight = lighting.directionalLight[i]; lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color); } */ } fn lighting_getSpecularLightColor(cameraPosition: vec3, position_worldspace: vec3, normal_worldspace: vec3) -> vec3{ var lightColor = vec3(0, 0, 0); let surfaceColor = vec3(0, 0, 0); if (lighting.enabled == 0) { let view_direction = normalize(cameraPosition - position_worldspace); switch (lighting.lightType) { case 0, default: { let pointLight: PointLight = lighting_getPointLight(0); let light_position_worldspace: vec3 = pointLight.position; let light_direction: vec3 = normalize(light_position_worldspace - position_worldspace); lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color); } case 1: { let directionalLight: DirectionalLight = lighting_getDirectionalLight(0); lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color); } } } return lightColor; } `;var re={name:"phongMaterial",dependencies:[Y],source:Go,vs:ie,fs:ne,defines:{LIGHTING_FRAGMENT:1},uniformTypes:{ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3"},defaultUniforms:{ambient:.35,diffuse:.6,shininess:32,specularColor:[.15,.15,.15]},getUniforms(o){let t={...o};return t.specularColor&&(t.specularColor=t.specularColor.map(e=>e/255)),{...re.defaultUniforms,...t}}};var Wo=`uniform pointCloudUniforms { float radiusPixels; highp int sizeUnits; } pointCloud; `,Bo={name:"pointCloud",vs:Wo,fs:Wo,uniformTypes:{radiusPixels:"f32",sizeUnits:"i32"}};var jo=`#version 300 es #define SHADER_NAME point-cloud-layer-vertex-shader in vec3 positions; in vec3 instanceNormals; in vec4 instanceColors; in vec3 instancePositions; in vec3 instancePositions64Low; in vec3 instancePickingColors; out vec4 vColor; out vec2 unitPosition; void main(void) { geometry.worldPosition = instancePositions; geometry.normal = project_normal(instanceNormals); unitPosition = positions.xy; geometry.uv = unitPosition; geometry.pickingColor = instancePickingColors; vec3 offset = vec3(positions.xy * project_size_to_pixel(pointCloud.radiusPixels, pointCloud.sizeUnits), 0.0); DECKGL_FILTER_SIZE(offset, geometry); gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.), geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); gl_Position.xy += project_pixel_size_to_clipspace(offset.xy); vec3 lightColor = lighting_getLightColor(instanceColors.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal); vColor = vec4(lightColor, instanceColors.a * layer.opacity); DECKGL_FILTER_COLOR(vColor, geometry); } `;var Vo=`#version 300 es #define SHADER_NAME point-cloud-layer-fragment-shader precision highp float; in vec4 vColor; in vec2 unitPosition; out vec4 fragColor; void main(void) { geometry.uv = unitPosition.xy; float distToCenter = length(unitPosition); if (distToCenter > 1.0) { discard; } fragColor = vColor; DECKGL_FILTER_COLOR(fragColor, geometry); } `;var Ho=[0,0,0,255],Zo=[0,0,1],Tr={sizeUnits:"pixels",pointSize:{type:"number",min:0,value:10},getPosition:{type:"accessor",value:o=>o.position},getNormal:{type:"accessor",value:Zo},getColor:{type:"accessor",value:Ho},material:!0,radiusPixels:{deprecatedFor:"pointSize"}};function br(o){let{header:t,attributes:e}=o;if(!(!t||!e)&&(o.length=t.vertexCount,e.POSITION&&(e.instancePositions=e.POSITION),e.NORMAL&&(e.instanceNormals=e.NORMAL),e.COLOR_0)){let{size:i,value:n}=e.COLOR_0;e.instanceColors={size:i,type:"unorm8",value:n}}}var Lt=class extends j.Layer{getShaders(){return super.getShaders({vs:jo,fs:Vo,modules:[j.project32,B,j.picking,Bo]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceNormals:{size:3,transition:!0,accessor:"getNormal",defaultValue:Zo},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:Ho}})}updateState(t){let{changeFlags:e,props:i}=t;super.updateState(t),e.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll()),e.dataChanged&&br(i.data)}draw({uniforms:t}){let{pointSize:e,sizeUnits:i}=this.props,n=this.state.model,r={sizeUnits:j.UNIT[i],radiusPixels:e};n.shaderInputs.setProps({pointCloud:r}),n.draw(this.context.renderPass)}_getModel(){let t=[];for(let e=0;e<3;e++){let i=e/3*Math.PI*2;t.push(Math.cos(i)*2,Math.sin(i)*2,0)}return new se.Model(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new se.Geometry({topology:"triangle-list",attributes:{positions:new Float32Array(t)}}),isInstanced:!0})}};Lt.layerName="PointCloudLayer";Lt.defaultProps=Tr;var Ko=Lt;var N=P(L(),1),Qo=P(I(),1),ti=P(I(),1);var Xo=`uniform scatterplotUniforms { float radiusScale; float radiusMinPixels; float radiusMaxPixels; float lineWidthScale; float lineWidthMinPixels; float lineWidthMaxPixels; float stroked; bool filled; bool antialiasing; bool billboard; highp int radiusUnits; highp int lineWidthUnits; } scatterplot; `,$o={name:"scatterplot",vs:Xo,fs:Xo,uniformTypes:{radiusScale:"f32",radiusMinPixels:"f32",radiusMaxPixels:"f32",lineWidthScale:"f32",lineWidthMinPixels:"f32",lineWidthMaxPixels:"f32",stroked:"f32",filled:"f32",antialiasing:"f32",billboard:"f32",radiusUnits:"i32",lineWidthUnits:"i32"}};var Yo=`#version 300 es #define SHADER_NAME scatterplot-layer-vertex-shader in vec3 positions; in vec3 instancePositions; in vec3 instancePositions64Low; in float instanceRadius; in float instanceLineWidths; in vec4 instanceFillColors; in vec4 instanceLineColors; in vec3 instancePickingColors; out vec4 vFillColor; out vec4 vLineColor; out vec2 unitPosition; out float innerUnitRadius; out float outerRadiusPixels; void main(void) { geometry.worldPosition = instancePositions; outerRadiusPixels = clamp( project_size_to_pixel(scatterplot.radiusScale * instanceRadius, scatterplot.radiusUnits), scatterplot.radiusMinPixels, scatterplot.radiusMaxPixels ); float lineWidthPixels = clamp( project_size_to_pixel(scatterplot.lineWidthScale * instanceLineWidths, scatterplot.lineWidthUnits), scatterplot.lineWidthMinPixels, scatterplot.lineWidthMaxPixels ); outerRadiusPixels += scatterplot.stroked * lineWidthPixels / 2.0; float edgePadding = scatterplot.antialiasing ? (outerRadiusPixels + SMOOTH_EDGE_RADIUS) / outerRadiusPixels : 1.0; unitPosition = edgePadding * positions.xy; geometry.uv = unitPosition; geometry.pickingColor = instancePickingColors; innerUnitRadius = 1.0 - scatterplot.stroked * lineWidthPixels / outerRadiusPixels; if (scatterplot.billboard) { gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); vec3 offset = edgePadding * positions * outerRadiusPixels; DECKGL_FILTER_SIZE(offset, geometry); gl_Position.xy += project_pixel_size_to_clipspace(offset.xy); } else { vec3 offset = edgePadding * positions * project_pixel_size(outerRadiusPixels); DECKGL_FILTER_SIZE(offset, geometry); gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset, geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); } vFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * layer.opacity); DECKGL_FILTER_COLOR(vFillColor, geometry); vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * layer.opacity); DECKGL_FILTER_COLOR(vLineColor, geometry); } `;var Jo=`#version 300 es #define SHADER_NAME scatterplot-layer-fragment-shader precision highp float; in vec4 vFillColor; in vec4 vLineColor; in vec2 unitPosition; in float innerUnitRadius; in float outerRadiusPixels; out vec4 fragColor; void main(void) { geometry.uv = unitPosition; float distToCenter = length(unitPosition) * outerRadiusPixels; float inCircle = scatterplot.antialiasing ? smoothedge(distToCenter, outerRadiusPixels) : step(distToCenter, outerRadiusPixels); if (inCircle == 0.0) { discard; } if (scatterplot.stroked > 0.5) { float isLine = scatterplot.antialiasing ? smoothedge(innerUnitRadius * outerRadiusPixels, distToCenter) : step(innerUnitRadius * outerRadiusPixels, distToCenter); if (scatterplot.filled) { fragColor = mix(vFillColor, vLineColor, isLine); } else { if (isLine == 0.0) { discard; } fragColor = vec4(vLineColor.rgb, vLineColor.a * isLine); } } else if (scatterplot.filled == false) { discard; } else { fragColor = vFillColor; } fragColor.a *= inCircle; DECKGL_FILTER_COLOR(fragColor, geometry); } `;var qo=[0,0,0,255],Ir={radiusUnits:"meters",radiusScale:{type:"number",min:0,value:1},radiusMinPixels:{type:"number",min:0,value:0},radiusMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},lineWidthUnits:"meters",lineWidthScale:{type:"number",min:0,value:1},lineWidthMinPixels:{type:"number",min:0,value:0},lineWidthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},stroked:!1,filled:!0,billboard:!1,antialiasing:!0,getPosition:{type:"accessor",value:o=>o.position},getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:qo},getLineColor:{type:"accessor",value:qo},getLineWidth:{type:"accessor",value:1},strokeWidth:{deprecatedFor:"getLineWidth"},outline:{deprecatedFor:"stroked"},getColor:{deprecatedFor:["getFillColor","getLineColor"]}},St=class extends N.Layer{getShaders(){return super.getShaders({vs:Yo,fs:Jo,modules:[N.project32,N.picking,$o]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceRadius:{size:1,transition:!0,accessor:"getRadius",defaultValue:1},instanceFillColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255]},instanceLineColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1}})}updateState(t){super.updateState(t),t.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:t}){let{radiusUnits:e,radiusScale:i,radiusMinPixels:n,radiusMaxPixels:r,stroked:s,filled:a,billboard:l,antialiasing:c,lineWidthUnits:u,lineWidthScale:f,lineWidthMinPixels:g,lineWidthMaxPixels:d}=this.props,p={stroked:s,filled:a,billboard:l,antialiasing:c,radiusUnits:N.UNIT[e],radiusScale:i,radiusMinPixels:n,radiusMaxPixels:r,lineWidthUnits:N.UNIT[u],lineWidthScale:f,lineWidthMinPixels:g,lineWidthMaxPixels:d},h=this.state.model;h.shaderInputs.setProps({scatterplot:p}),h.draw(this.context.renderPass)}_getModel(){let t=[-1,-1,0,1,-1,0,-1,1,0,1,1,0];return new ti.Model(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Qo.Geometry({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(t)}}}),isInstanced:!0})}};St.defaultProps=Ir;St.layerName="ScatterplotLayer";var ae=St;var k=P(L(),1);var Ne=P(I(),1);var ai=P(L(),1),li=P(I(),1);var nt={CLOCKWISE:1,COUNTER_CLOCKWISE:-1};function J(o,t,e={}){return ei(o,e)!==t?(Ar(o,e),!0):!1}function ei(o,t={}){return Math.sign(le(o,t))}var Re={x:0,y:1,z:2};function le(o,t={}){let{start:e=0,end:i=o.length,plane:n="xy"}=t,r=t.size||2,s=0,a=Re[n[0]],l=Re[n[1]];for(let c=e,u=i-r;c0){let n=!0;for(let r=0;rt[2]&&(e|=2),o[1]t[3]&&(e|=8),e}function Tt(o,t){let{size:e=2,broken:i=!1,gridResolution:n=10,gridOffset:r=[0,0],startIndex:s=0,endIndex:a=o.length}=t||{},l=(a-s)/e,c=[],u=[c],f=V(o,0,e,s),g,d,p=ni(f,n,r,[]),h=[];A(c,f);for(let m=1;me&&(c=[],u.push(c),A(c,f)),d=Mt(g,p)}A(c,g),wt(f,g)}return i?u:u[0]}var oi=0,zr=1;function bt(o,t=null,e){if(!o.length)return[];let{size:i=2,gridResolution:n=10,gridOffset:r=[0,0],edgeTypes:s=!1}=e||{},a=[],l=[{pos:o,types:s?new Array(o.length/i).fill(zr):null,holes:t||[]}],c=[[],[]],u=[];for(;l.length;){let{pos:f,types:g,holes:d}=l.shift();Rr(f,i,d[0]||f.length,c),u=ni(c[0],n,r,u);let p=Mt(c[1],u);if(p){let h=ii(f,g,i,0,d[0]||f.length,u,p),m={pos:h[0].pos,types:h[0].types,holes:[]},y={pos:h[1].pos,types:h[1].types,holes:[]};l.push(m,y);for(let _=0;_=0?(A(c,d)&&f.push(h),v+=p):f.length&&(f[f.length-1]=oi),wt(m,d),y=p,_=h;return[x?{pos:l,types:t&&u}:null,v?{pos:c,types:t&&f}:null]}function ni(o,t,e,i){let n=Math.floor((o[0]-e[0])/t)*t+e[0],r=Math.floor((o[1]-e[1])/t)*t+e[1];return i[0]=n,i[1]=r,i[2]=n+t,i[3]=r+t,i}function Or(o,t,e){e&8?(o[1]+=t,o[3]+=t):e&4?(o[1]-=t,o[3]-=t):e&2?(o[0]+=t,o[2]+=t):e&1&&(o[0]-=t,o[2]-=t)}function Rr(o,t,e,i){let n=1/0,r=-1/0,s=1/0,a=-1/0;for(let l=0;lr?c:r,s=ua?u:a}return i[0][0]=n,i[0][1]=s,i[1][0]=r,i[1][1]=a,i}function ue(o,t){for(let e=0;en&&(n=a,r=s-1)}return r}function Nr(o,t,e,i,n=Fr){let r=o[e],s=o[i-t];if(Math.abs(r-s)>180){let a=V(o,0,t,e);a[0]+=Math.round((s-r)/360)*360,A(o,a),a[1]=Math.sign(a[1])*n,A(o,a),a[0]=r,A(o,a)}}function ri(o,t,e,i){let n=o[0],r;for(let s=e;s180||a<-180)&&(r-=Math.round(a/360)*360),o[s]=n=r}}function si(o,t){let e,i=o.length/t;for(let r=0;r=i),n=n.flatMap(d=>[d[0],d[1]]),J(n,nt.COUNTER_CLOCKWISE));let r=e>0,s=i+1,a=r?s*3+1:i,l=Math.PI*2/i,c=new Uint16Array(r?i*3*2:0),u=new Float32Array(a*3),f=new Float32Array(a*3),g=0;if(r){for(let d=0;d",extruded:"f32",stroked:"f32",isStroke:"f32",coverage:"f32",elevationScale:"f32",edgeDistance:"f32",widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",radiusUnits:"i32",widthUnits:"i32"}};var fi=`#version 300 es #define SHADER_NAME column-layer-vertex-shader in vec3 positions; in vec3 normals; in vec3 instancePositions; in float instanceElevations; in vec3 instancePositions64Low; in vec4 instanceFillColors; in vec4 instanceLineColors; in float instanceStrokeWidths; in vec3 instancePickingColors; out vec4 vColor; #ifdef FLAT_SHADING out vec3 cameraPosition; out vec4 position_commonspace; #endif void main(void) { geometry.worldPosition = instancePositions; vec4 color = column.isStroke ? instanceLineColors : instanceFillColors; mat2 rotationMatrix = mat2(cos(column.angle), sin(column.angle), -sin(column.angle), cos(column.angle)); float elevation = 0.0; float strokeOffsetRatio = 1.0; if (column.extruded) { elevation = instanceElevations * (positions.z + 1.0) / 2.0 * column.elevationScale; } else if (column.stroked) { float widthPixels = clamp( project_size_to_pixel(instanceStrokeWidths * column.widthScale, column.widthUnits), column.widthMinPixels, column.widthMaxPixels) / 2.0; float halfOffset = project_pixel_size(widthPixels) / project_size(column.edgeDistance * column.coverage * column.radius); if (column.isStroke) { strokeOffsetRatio -= sign(positions.z) * halfOffset; } else { strokeOffsetRatio -= halfOffset; } } float shouldRender = float(color.a > 0.0 && instanceElevations >= 0.0); float dotRadius = column.radius * column.coverage * shouldRender; geometry.pickingColor = instancePickingColors; vec3 centroidPosition = vec3(instancePositions.xy, instancePositions.z + elevation); vec3 centroidPosition64Low = instancePositions64Low; vec2 offset = (rotationMatrix * positions.xy * strokeOffsetRatio + column.offset) * dotRadius; if (column.radiusUnits == UNIT_METERS) { offset = project_size(offset); } vec3 pos = vec3(offset, 0.); DECKGL_FILTER_SIZE(pos, geometry); gl_Position = project_position_to_clipspace(centroidPosition, centroidPosition64Low, pos, geometry.position); geometry.normal = project_normal(vec3(rotationMatrix * normals.xy, normals.z)); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); if (column.extruded && !column.isStroke) { #ifdef FLAT_SHADING cameraPosition = project.cameraPosition; position_commonspace = geometry.position; vColor = vec4(color.rgb, color.a * layer.opacity); #else vec3 lightColor = lighting_getLightColor(color.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal); vColor = vec4(lightColor, color.a * layer.opacity); #endif } else { vColor = vec4(color.rgb, color.a * layer.opacity); } DECKGL_FILTER_COLOR(vColor, geometry); } `;var gi=`#version 300 es #define SHADER_NAME column-layer-fragment-shader precision highp float; out vec4 fragColor; in vec4 vColor; #ifdef FLAT_SHADING in vec3 cameraPosition; in vec4 position_commonspace; #endif void main(void) { fragColor = vColor; geometry.uv = vec2(0.); #ifdef FLAT_SHADING if (column.extruded && !column.isStroke && !bool(picking.isActive)) { vec3 normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz))); fragColor.rgb = lighting_getLightColor(vColor.rgb, cameraPosition, position_commonspace.xyz, normal); } #endif DECKGL_FILTER_COLOR(fragColor, geometry); } `;var fe=[0,0,0,255],Gr={diskResolution:{type:"number",min:4,value:20},vertices:null,radius:{type:"number",min:0,value:1e3},angle:{type:"number",value:0},offset:{type:"array",value:[0,0]},coverage:{type:"number",min:0,max:1,value:1},elevationScale:{type:"number",min:0,value:1},radiusUnits:"meters",lineWidthUnits:"meters",lineWidthScale:1,lineWidthMinPixels:0,lineWidthMaxPixels:Number.MAX_SAFE_INTEGER,extruded:!0,wireframe:!1,filled:!0,stroked:!1,flatShading:!1,getPosition:{type:"accessor",value:o=>o.position},getFillColor:{type:"accessor",value:fe},getLineColor:{type:"accessor",value:fe},getLineWidth:{type:"accessor",value:1},getElevation:{type:"accessor",value:1e3},material:!0,getColor:{deprecatedFor:["getFillColor","getLineColor"]}},At=class extends k.Layer{getShaders(){let t={},{flatShading:e}=this.props;return e&&(t.FLAT_SHADING=1),super.getShaders({vs:fi,fs:gi,defines:t,modules:[k.project32,e?re:B,k.picking,ui]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceElevations:{size:1,transition:!0,accessor:"getElevation"},instanceFillColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getFillColor",defaultValue:fe},instanceLineColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getLineColor",defaultValue:fe},instanceStrokeWidths:{size:1,accessor:"getLineWidth",transition:!0}})}updateState(t){super.updateState(t);let{props:e,oldProps:i,changeFlags:n}=t,r=n.extensionsChanged||e.flatShading!==i.flatShading;r&&(this.state.models?.forEach(a=>a.destroy()),this.setState(this._getModels()),this.getAttributeManager().invalidateAll());let s=this.getNumInstances();this.state.fillModel.setInstanceCount(s),this.state.wireframeModel.setInstanceCount(s),(r||e.diskResolution!==i.diskResolution||e.vertices!==i.vertices||(e.extruded||e.stroked)!==(i.extruded||i.stroked))&&this._updateGeometry(e)}getGeometry(t,e,i){let n=new It({radius:1,height:i?2:0,vertices:e,nradial:t}),r=0;if(e)for(let s=0;s=t.length&&(e+=1-t.length/n);let r=e*n;return i[0]=t[r],i[1]=t[r+1],i[2]=n===3&&t[r+2]||0,i}isClosed(t){if(!this.normalize)return Boolean(this.opts.loop);let{positionSize:e}=this,i=t.length-e;return t[0]===t[i]&&t[1]===t[i+1]&&(e===2||t[2]===t[i+2])}};function xi(o){return Array.isArray(o[0])}var vi=`uniform pathUniforms { float widthScale; float widthMinPixels; float widthMaxPixels; float jointType; float capType; float miterLimit; bool billboard; highp int widthUnits; } path; `,Pi={name:"path",vs:vi,fs:vi,uniformTypes:{widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",jointType:"f32",capType:"f32",miterLimit:"f32",billboard:"f32",widthUnits:"i32"}};var _i=`#version 300 es #define SHADER_NAME path-layer-vertex-shader in vec2 positions; in float instanceTypes; in vec3 instanceStartPositions; in vec3 instanceEndPositions; in vec3 instanceLeftPositions; in vec3 instanceRightPositions; in vec3 instanceLeftPositions64Low; in vec3 instanceStartPositions64Low; in vec3 instanceEndPositions64Low; in vec3 instanceRightPositions64Low; in float instanceStrokeWidths; in vec4 instanceColors; in vec3 instancePickingColors; uniform float opacity; out vec4 vColor; out vec2 vCornerOffset; out float vMiterLength; out vec2 vPathPosition; out float vPathLength; out float vJointType; const float EPSILON = 0.001; const vec3 ZERO_OFFSET = vec3(0.0); float flipIfTrue(bool flag) { return -(float(flag) * 2. - 1.); } vec3 getLineJoinOffset( vec3 prevPoint, vec3 currPoint, vec3 nextPoint, vec2 width ) { bool isEnd = positions.x > 0.0; float sideOfPath = positions.y; float isJoint = float(sideOfPath == 0.0); vec3 deltaA3 = (currPoint - prevPoint); vec3 deltaB3 = (nextPoint - currPoint); mat3 rotationMatrix; bool needsRotation = !path.billboard && project_needs_rotation(currPoint, rotationMatrix); if (needsRotation) { deltaA3 = deltaA3 * rotationMatrix; deltaB3 = deltaB3 * rotationMatrix; } vec2 deltaA = deltaA3.xy / width; vec2 deltaB = deltaB3.xy / width; float lenA = length(deltaA); float lenB = length(deltaB); vec2 dirA = lenA > 0. ? normalize(deltaA) : vec2(0.0, 0.0); vec2 dirB = lenB > 0. ? normalize(deltaB) : vec2(0.0, 0.0); vec2 perpA = vec2(-dirA.y, dirA.x); vec2 perpB = vec2(-dirB.y, dirB.x); vec2 tangent = dirA + dirB; tangent = length(tangent) > 0. ? normalize(tangent) : perpA; vec2 miterVec = vec2(-tangent.y, tangent.x); vec2 dir = isEnd ? dirA : dirB; vec2 perp = isEnd ? perpA : perpB; float L = isEnd ? lenA : lenB; float sinHalfA = abs(dot(miterVec, perp)); float cosHalfA = abs(dot(dirA, miterVec)); float turnDirection = flipIfTrue(dirA.x * dirB.y >= dirA.y * dirB.x); float cornerPosition = sideOfPath * turnDirection; float miterSize = 1.0 / max(sinHalfA, EPSILON); miterSize = mix( min(miterSize, max(lenA, lenB) / max(cosHalfA, EPSILON)), miterSize, step(0.0, cornerPosition) ); vec2 offsetVec = mix(miterVec * miterSize, perp, step(0.5, cornerPosition)) * (sideOfPath + isJoint * turnDirection); bool isStartCap = lenA == 0.0 || (!isEnd && (instanceTypes == 1.0 || instanceTypes == 3.0)); bool isEndCap = lenB == 0.0 || (isEnd && (instanceTypes == 2.0 || instanceTypes == 3.0)); bool isCap = isStartCap || isEndCap; if (isCap) { offsetVec = mix(perp * sideOfPath, dir * path.capType * 4.0 * flipIfTrue(isStartCap), isJoint); vJointType = path.capType; } else { vJointType = path.jointType; } vPathLength = L; vCornerOffset = offsetVec; vMiterLength = dot(vCornerOffset, miterVec * turnDirection); vMiterLength = isCap ? isJoint : vMiterLength; vec2 offsetFromStartOfPath = vCornerOffset + deltaA * float(isEnd); vPathPosition = vec2( dot(offsetFromStartOfPath, perp), dot(offsetFromStartOfPath, dir) ); geometry.uv = vPathPosition; float isValid = step(instanceTypes, 3.5); vec3 offset = vec3(offsetVec * width * isValid, 0.0); if (needsRotation) { offset = rotationMatrix * offset; } return offset; } void clipLine(inout vec4 position, vec4 refPosition) { if (position.w < EPSILON) { float r = (EPSILON - refPosition.w) / (position.w - refPosition.w); position = refPosition + (position - refPosition) * r; } } void main() { geometry.pickingColor = instancePickingColors; vColor = vec4(instanceColors.rgb, instanceColors.a * layer.opacity); float isEnd = positions.x; vec3 prevPosition = mix(instanceLeftPositions, instanceStartPositions, isEnd); vec3 prevPosition64Low = mix(instanceLeftPositions64Low, instanceStartPositions64Low, isEnd); vec3 currPosition = mix(instanceStartPositions, instanceEndPositions, isEnd); vec3 currPosition64Low = mix(instanceStartPositions64Low, instanceEndPositions64Low, isEnd); vec3 nextPosition = mix(instanceEndPositions, instanceRightPositions, isEnd); vec3 nextPosition64Low = mix(instanceEndPositions64Low, instanceRightPositions64Low, isEnd); geometry.worldPosition = currPosition; vec2 widthPixels = vec2(clamp( project_size_to_pixel(instanceStrokeWidths * path.widthScale, path.widthUnits), path.widthMinPixels, path.widthMaxPixels) / 2.0); vec3 width; if (path.billboard) { vec4 prevPositionScreen = project_position_to_clipspace(prevPosition, prevPosition64Low, ZERO_OFFSET); vec4 currPositionScreen = project_position_to_clipspace(currPosition, currPosition64Low, ZERO_OFFSET, geometry.position); vec4 nextPositionScreen = project_position_to_clipspace(nextPosition, nextPosition64Low, ZERO_OFFSET); clipLine(prevPositionScreen, currPositionScreen); clipLine(nextPositionScreen, currPositionScreen); clipLine(currPositionScreen, mix(nextPositionScreen, prevPositionScreen, isEnd)); width = vec3(widthPixels, 0.0); DECKGL_FILTER_SIZE(width, geometry); vec3 offset = getLineJoinOffset( prevPositionScreen.xyz / prevPositionScreen.w, currPositionScreen.xyz / currPositionScreen.w, nextPositionScreen.xyz / nextPositionScreen.w, project_pixel_size_to_clipspace(width.xy) ); DECKGL_FILTER_GL_POSITION(currPositionScreen, geometry); gl_Position = vec4(currPositionScreen.xyz + offset * currPositionScreen.w, currPositionScreen.w); } else { prevPosition = project_position(prevPosition, prevPosition64Low); currPosition = project_position(currPosition, currPosition64Low); nextPosition = project_position(nextPosition, nextPosition64Low); width = vec3(project_pixel_size(widthPixels), 0.0); DECKGL_FILTER_SIZE(width, geometry); vec3 offset = getLineJoinOffset(prevPosition, currPosition, nextPosition, width.xy); geometry.position = vec4(currPosition + offset, 1.0); gl_Position = project_common_position_to_clipspace(geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); } DECKGL_FILTER_COLOR(vColor, geometry); } `;var Ci=`#version 300 es #define SHADER_NAME path-layer-fragment-shader precision highp float; in vec4 vColor; in vec2 vCornerOffset; in float vMiterLength; in vec2 vPathPosition; in float vPathLength; in float vJointType; out vec4 fragColor; void main(void) { geometry.uv = vPathPosition; if (vPathPosition.y < 0.0 || vPathPosition.y > vPathLength) { if (vJointType > 0.5 && length(vCornerOffset) > 1.0) { discard; } if (vJointType < 0.5 && vMiterLength > path.miterLimit + 1.0) { discard; } } fragColor = vColor; DECKGL_FILTER_COLOR(fragColor, geometry); } `;var wi=[0,0,0,255],Vr={widthUnits:"meters",widthScale:{type:"number",min:0,value:1},widthMinPixels:{type:"number",min:0,value:0},widthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},jointRounded:!1,capRounded:!1,miterLimit:{type:"number",min:0,value:4},billboard:!1,_pathType:null,getPath:{type:"accessor",value:o=>o.path},getColor:{type:"accessor",value:wi},getWidth:{type:"accessor",value:1},rounded:{deprecatedFor:["jointRounded","capRounded"]}},Ue={enter:(o,t)=>t.length?t.subarray(t.length-o.length):o},Ot=class extends H.Layer{getShaders(){return super.getShaders({vs:_i,fs:Ci,modules:[H.project32,H.picking,Pi]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){this.getAttributeManager().addInstanced({vertexPositions:{size:3,vertexOffset:1,type:"float64",fp64:this.use64bitPositions(),transition:Ue,accessor:"getPath",update:this.calculatePositions,noAlloc:!0,shaderAttributes:{instanceLeftPositions:{vertexOffset:0},instanceStartPositions:{vertexOffset:1},instanceEndPositions:{vertexOffset:2},instanceRightPositions:{vertexOffset:3}}},instanceTypes:{size:1,type:"uint8",update:this.calculateSegmentTypes,noAlloc:!0},instanceStrokeWidths:{size:1,accessor:"getWidth",transition:Ue,defaultValue:1},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",accessor:"getColor",transition:Ue,defaultValue:wi},instancePickingColors:{size:4,type:"uint8",accessor:(i,{index:n,target:r})=>this.encodePickingColor(i&&i.__source?i.__source.index:n,r)}}),this.setState({pathTesselator:new zt({fp64:this.use64bitPositions()})})}updateState(t){super.updateState(t);let{props:e,changeFlags:i}=t,n=this.getAttributeManager();if(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getPath)){let{pathTesselator:s}=this.state,a=e.data.attributes||{};s.updateGeometry({data:e.data,geometryBuffer:a.getPath,buffers:a,normalize:!e._pathType,loop:e._pathType==="loop",getGeometry:e.getPath,positionFormat:e.positionFormat,wrapLongitude:e.wrapLongitude,resolution:this.context.viewport.resolution,dataChanged:i.dataChanged}),this.setState({numInstances:s.instanceCount,startIndices:s.vertexStarts}),i.dataChanged||n.invalidateAll()}i.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),n.invalidateAll())}getPickingInfo(t){let e=super.getPickingInfo(t),{index:i}=e,n=this.props.data;return n[0]&&n[0].__source&&(e.object=n.find(r=>r.__source.index===i)),e}disablePickingIndex(t){let e=this.props.data;if(e[0]&&e[0].__source)for(let i=0;i=1&&o[0].length>=2&&Number.isFinite(o[0][0])}function cs(o){let t=o[0],e=o[o.length-1];return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function us(o,t,e,i){for(let n=0;na/t));let r=at(o),s=i&&t===3;if(e){let a=r.length;r=r.slice();let l=[];for(let c=0;cl&&a>c||(l>c?(e||(r=r.slice()),Ri(r,0,2,1)):(e||(r=r.slice()),Ri(r,2,0,1)))}return(0,Fi.default)(r,n,t)}var Ui=P(L(),1);var kt=class extends Ui.Tesselator{constructor(t){let{fp64:e,IndexType:i=Uint32Array}=t;super({...t,attributes:{positions:{size:3,type:e?Float64Array:Float32Array},vertexValid:{type:Uint16Array,size:1},indices:{type:i,size:1}}})}get(t){let{attributes:e}=this;return t==="indices"?e.indices&&e.indices.subarray(0,this.vertexCount):e[t]}updateGeometry(t){super.updateGeometry(t);let e=this.buffers.indices;if(e)this.vertexCount=(e.value||e).length;else if(this.data&&!this.getGeometry)throw new Error("missing indices buffer")}normalizeGeometry(t){if(this.normalize){let e=ye(t,this.positionSize);return this.opts.resolution?bt(at(e),Nt(e),{size:this.positionSize,gridResolution:this.opts.resolution,edgeTypes:!0}):this.opts.wrapLongitude?De(at(e),Nt(e),{size:this.positionSize,maxLatitude:86,edgeTypes:!0}):e}return t}getGeometrySize(t){if(ki(t)){let e=0;for(let i of t)e+=this.getGeometrySize(i);return e}return at(t).length/this.positionSize}getGeometryFromBuffer(t){return this.normalize||!this.buffers.indices?super.getGeometryFromBuffer(t):null}updateGeometryAttributes(t,e){if(t&&ki(t))for(let i of t){let n=this.getGeometrySize(i);e.geometrySize=n,this.updateGeometryAttributes(i,e),e.vertexStart+=n,e.indexStart=this.indexStarts[e.geometryIndex+1]}else{let i=t;this._updateIndices(i,e),this._updatePositions(i,e),this._updateVertexValid(i,e)}}_updateIndices(t,{geometryIndex:e,vertexStart:i,indexStart:n}){let{attributes:r,indexStarts:s,typedArrayManager:a}=this,l=r.indices;if(!l||!t)return;let c=n,u=Di(t,this.positionSize,this.opts.preproject,this.opts.full3d);l=a.allocate(l,n+u.length,{copy:!0});for(let f=0;f2?s[l*r+2]:0;n[a*3]=c,n[a*3+1]=u,n[a*3+2]=f}}_updateVertexValid(t,{vertexStart:e,geometrySize:i}){let{positionSize:n}=this,r=this.attributes.vertexValid,s=t&&Nt(t);if(t&&t.edgeTypes?r.set(t.edgeTypes,e):r.fill(1,e,e+i),s)for(let a=0;a0&&!Number.isFinite(o[0])}var Gi=`uniform solidPolygonUniforms { bool extruded; bool isWireframe; float elevationScale; } solidPolygon; `,Wi={name:"solidPolygon",vs:Gi,fs:Gi,uniformTypes:{extruded:"f32",isWireframe:"f32",elevationScale:"f32"}};var ve=`in vec4 fillColors; in vec4 lineColors; in vec3 pickingColors; out vec4 vColor; struct PolygonProps { vec3 positions; vec3 positions64Low; vec3 normal; float elevations; }; vec3 project_offset_normal(vec3 vector) { if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT || project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSETS) { return normalize(vector * project.commonUnitsPerWorldUnit); } return project_normal(vector); } void calculatePosition(PolygonProps props) { vec3 pos = props.positions; vec3 pos64Low = props.positions64Low; vec3 normal = props.normal; vec4 colors = solidPolygon.isWireframe ? lineColors : fillColors; geometry.worldPosition = props.positions; geometry.pickingColor = pickingColors; if (solidPolygon.extruded) { pos.z += props.elevations * solidPolygon.elevationScale; } gl_Position = project_position_to_clipspace(pos, pos64Low, vec3(0.), geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); if (solidPolygon.extruded) { #ifdef IS_SIDE_VERTEX normal = project_offset_normal(normal); #else normal = project_normal(normal); #endif geometry.normal = normal; vec3 lightColor = lighting_getLightColor(colors.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal); vColor = vec4(lightColor, colors.a * layer.opacity); } else { vColor = vec4(colors.rgb, colors.a * layer.opacity); } DECKGL_FILTER_COLOR(vColor, geometry); } `;var Bi=`#version 300 es #define SHADER_NAME solid-polygon-layer-vertex-shader in vec3 vertexPositions; in vec3 vertexPositions64Low; in float elevations; ${ve} void main(void) { PolygonProps props; props.positions = vertexPositions; props.positions64Low = vertexPositions64Low; props.elevations = elevations; props.normal = vec3(0.0, 0.0, 1.0); calculatePosition(props); } `;var ji=`#version 300 es #define SHADER_NAME solid-polygon-layer-vertex-shader-side #define IS_SIDE_VERTEX in vec2 positions; in vec3 vertexPositions; in vec3 nextVertexPositions; in vec3 vertexPositions64Low; in vec3 nextVertexPositions64Low; in float elevations; in float instanceVertexValid; ${ve} void main(void) { if(instanceVertexValid < 0.5){ gl_Position = vec4(0.); return; } PolygonProps props; vec3 pos; vec3 pos64Low; vec3 nextPos; vec3 nextPos64Low; #if RING_WINDING_ORDER_CW == 1 pos = vertexPositions; pos64Low = vertexPositions64Low; nextPos = nextVertexPositions; nextPos64Low = nextVertexPositions64Low; #else pos = nextVertexPositions; pos64Low = nextVertexPositions64Low; nextPos = vertexPositions; nextPos64Low = vertexPositions64Low; #endif props.positions = mix(pos, nextPos, positions.x); props.positions64Low = mix(pos64Low, nextPos64Low, positions.x); props.normal = vec3( pos.y - nextPos.y + (pos64Low.y - nextPos64Low.y), nextPos.x - pos.x + (nextPos64Low.x - pos64Low.x), 0.0); props.elevations = elevations * positions.y; calculatePosition(props); } `;var Vi=`#version 300 es #define SHADER_NAME solid-polygon-layer-fragment-shader precision highp float; in vec4 vColor; out vec4 fragColor; void main(void) { fragColor = vColor; geometry.uv = vec2(0.); DECKGL_FILTER_COLOR(fragColor, geometry); } `;var _e=[0,0,0,255],fs={filled:!0,extruded:!1,wireframe:!1,_normalize:!0,_windingOrder:"CW",_full3d:!1,elevationScale:{type:"number",min:0,value:1},getPolygon:{type:"accessor",value:o=>o.polygon},getElevation:{type:"accessor",value:1e3},getFillColor:{type:"accessor",value:_e},getLineColor:{type:"accessor",value:_e},material:!0},Pe={enter:(o,t)=>t.length?t.subarray(t.length-o.length):o},Ut=class extends R.Layer{getShaders(t){return super.getShaders({vs:t==="top"?Bi:ji,fs:Vi,defines:{RING_WINDING_ORDER_CW:!this.props._normalize&&this.props._windingOrder==="CCW"?0:1},modules:[R.project32,B,R.picking,Wi]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){let{viewport:t}=this.context,{coordinateSystem:e}=this.props,{_full3d:i}=this.props;t.isGeospatial&&e===R.COORDINATE_SYSTEM.DEFAULT&&(e=R.COORDINATE_SYSTEM.LNGLAT);let n;e===R.COORDINATE_SYSTEM.LNGLAT&&(i?n=t.projectPosition.bind(t):n=t.projectFlat.bind(t)),this.setState({numInstances:0,polygonTesselator:new kt({preproject:n,fp64:this.use64bitPositions(),IndexType:Uint32Array})});let r=this.getAttributeManager(),s=!0;r.remove(["instancePickingColors"]),r.add({indices:{size:1,isIndexed:!0,update:this.calculateIndices,noAlloc:s},vertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:Pe,accessor:"getPolygon",update:this.calculatePositions,noAlloc:s,shaderAttributes:{nextVertexPositions:{vertexOffset:1}}},instanceVertexValid:{size:1,type:"uint16",stepMode:"instance",update:this.calculateVertexValid,noAlloc:s},elevations:{size:1,stepMode:"dynamic",transition:Pe,accessor:"getElevation"},fillColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:Pe,accessor:"getFillColor",defaultValue:_e},lineColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:Pe,accessor:"getLineColor",defaultValue:_e},pickingColors:{size:4,type:"uint8",stepMode:"dynamic",accessor:(a,{index:l,target:c})=>this.encodePickingColor(a&&a.__source?a.__source.index:l,c)}})}getPickingInfo(t){let e=super.getPickingInfo(t),{index:i}=e,n=this.props.data;return n[0]&&n[0].__source&&(e.object=n.find(r=>r.__source.index===i)),e}disablePickingIndex(t){let e=this.props.data;if(e[0]&&e[0].__source)for(let i=0;ia.destroy()),this.setState(this._getModels()),r.invalidateAll())}updateGeometry({props:t,oldProps:e,changeFlags:i}){if(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getPolygon)){let{polygonTesselator:r}=this.state,s=t.data.attributes||{};r.updateGeometry({data:t.data,normalize:t._normalize,geometryBuffer:s.getPolygon,buffers:s,getGeometry:t.getPolygon,positionFormat:t.positionFormat,wrapLongitude:t.wrapLongitude,resolution:this.context.viewport.resolution,fp64:this.use64bitPositions(),dataChanged:i.dataChanged,full3d:t._full3d}),this.setState({numInstances:r.instanceCount,startIndices:r.vertexStarts}),i.dataChanged||this.getAttributeManager().invalidateAll()}}_getModels(){let{id:t,filled:e,extruded:i}=this.props,n,r,s;if(e){let a=this.getShaders("top");a.defines.NON_INSTANCED_MODEL=1;let l=this.getAttributeManager().getBufferLayouts({isInstanced:!1});n=new Q.Model(this.context.device,{...a,id:`${t}-top`,topology:"triangle-list",bufferLayout:l,isIndexed:!0,userData:{excludeAttributes:{instanceVertexValid:!0}}})}if(i){let a=this.getAttributeManager().getBufferLayouts({isInstanced:!0});r=new Q.Model(this.context.device,{...this.getShaders("side"),id:`${t}-side`,bufferLayout:a,geometry:new Q.Geometry({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,1,1,0,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}}),s=new Q.Model(this.context.device,{...this.getShaders("side"),id:`${t}-wireframe`,bufferLayout:a,geometry:new Q.Geometry({topology:"line-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,0,1,1,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}})}return{models:[r,s,n].filter(Boolean),topModel:n,sideModel:r,wireframeModel:s}}calculateIndices(t){let{polygonTesselator:e}=this.state;t.startIndices=e.indexStarts,t.value=e.get("indices")}calculatePositions(t){let{polygonTesselator:e}=this.state;t.startIndices=e.vertexStarts,t.value=e.get("positions")}calculateVertexValid(t){t.value=this.state.polygonTesselator.get("vertexValid")}};Ut.defaultProps=fs;Ut.layerName="SolidPolygonLayer";var lt=Ut;function Ce({data:o,getIndex:t,dataRange:e,replace:i}){let{startRow:n=0,endRow:r=1/0}=e,s=o.length,a=s,l=s;for(let g=0;gg&&d>=n&&(a=g),d>=r){l=g;break}}let c=a,f=l-a!==i.length?o.slice(l):void 0;for(let g=0;go.polygon},getFillColor:{type:"accessor",value:gs},getLineColor:{type:"accessor",value:Hi},getLineWidth:{type:"accessor",value:1},getElevation:{type:"accessor",value:1e3},material:!0},Gt=class extends ct.CompositeLayer{initializeState(){this.state={paths:[],pathsDiff:null},this.props.getLineDashArray&&ct.log.removed("getLineDashArray","PathStyleExtension")()}updateState({changeFlags:t}){let e=t.dataChanged||t.updateTriggersChanged&&(t.updateTriggersChanged.all||t.updateTriggersChanged.getPolygon);if(e&&Array.isArray(t.dataChanged)){let i=this.state.paths.slice(),n=t.dataChanged.map(r=>Ce({data:i,getIndex:s=>s.__source.index,dataRange:r,replace:this._getPaths(r)}));this.setState({paths:i,pathsDiff:n})}else e&&this.setState({paths:this._getPaths(),pathsDiff:null})}_getPaths(t={}){let{data:e,getPolygon:i,positionFormat:n,_normalize:r}=this.props,s=[],a=n==="XY"?2:3,{startRow:l,endRow:c}=t,{iterable:u,objectInfo:f}=(0,ct.createIterable)(e,l,c);for(let g of u){f.index++;let d=i(g,f);r&&(d=ye(d,a));let{holeIndices:p}=d,h=d.positions||d;if(p)for(let m=0;m<=p.length;m++){let y=h.slice(p[m-1]||0,p[m]||h.length);s.push(this.getSubLayerRow({path:y},g,f.index))}else s.push(this.getSubLayerRow({path:h},g,f.index))}return s}renderLayers(){let{data:t,_dataDiff:e,stroked:i,filled:n,extruded:r,wireframe:s,_normalize:a,_windingOrder:l,elevationScale:c,transitions:u,positionFormat:f}=this.props,{lineWidthUnits:g,lineWidthScale:d,lineWidthMinPixels:p,lineWidthMaxPixels:h,lineJointRounded:m,lineMiterLimit:y,lineDashJustified:_}=this.props,{getFillColor:x,getLineColor:v,getLineWidth:C,getLineDashArray:M,getElevation:F,getPolygon:E,updateTriggers:T,material:Yt}=this.props,{paths:et,pathsDiff:b}=this.state,w=this.getSubLayerClass("fill",lt),Ae=this.getSubLayerClass("stroke",rt),Jt=this.shouldRenderSubLayer("fill",et)&&new w({_dataDiff:e,extruded:r,elevationScale:c,filled:n,wireframe:s,_normalize:a,_windingOrder:l,getElevation:F,getFillColor:x,getLineColor:r&&s?v:Hi,material:Yt,transitions:u},this.getSubLayerProps({id:"fill",updateTriggers:T&&{getPolygon:T.getPolygon,getElevation:T.getElevation,getFillColor:T.getFillColor,lineColors:r&&s,getLineColor:T.getLineColor}}),{data:t,positionFormat:f,getPolygon:E}),En=!r&&i&&this.shouldRenderSubLayer("stroke",et)&&new Ae({_dataDiff:b&&(()=>b),widthUnits:g,widthScale:d,widthMinPixels:p,widthMaxPixels:h,jointRounded:m,miterLimit:y,dashJustified:_,_pathType:"loop",transitions:u&&{getWidth:u.getLineWidth,getColor:u.getLineColor,getPath:u.getPolygon},getColor:this.getSubLayerAccessor(v),getWidth:this.getSubLayerAccessor(C),getDashArray:this.getSubLayerAccessor(M)},this.getSubLayerProps({id:"stroke",updateTriggers:T&&{getWidth:T.getLineWidth,getColor:T.getLineColor,getDashArray:T.getLineDashArray}}),{data:et,positionFormat:f,getPath:zn=>zn.path});return[!r&&Jt,En,r&&Jt]}};Gt.layerName="PolygonLayer";Gt.defaultProps=ds;var Zi=Gt;var In=P(L(),1);function Ki(o,t){if(!o)return null;let e="startIndices"in o?o.startIndices[t]:t,i=o.featureIds.value[e];return e!==-1?ps(o,i,e):null}function ps(o,t,e){let i={properties:{...o.properties[t]}};for(let n in o.numericProps)i.properties[n]=o.numericProps[n].value[e];return i}function Xi(o,t){let e={points:null,lines:null,polygons:null};for(let i in e){let n=o[i].globalFeatureIds.value;e[i]=new Uint8ClampedArray(n.length*4);let r=[];for(let s=0;s"}};var Ji=`#version 300 es #define SHADER_NAME multi-icon-layer-fragment-shader precision highp float; uniform sampler2D iconsTexture; in vec4 vColor; in vec2 vTextureCoords; in vec2 uv; out vec4 fragColor; void main(void) { geometry.uv = uv; if (!bool(picking.isActive)) { float alpha = texture(iconsTexture, vTextureCoords).a; vec4 color = vColor; if (sdf.enabled) { float distance = alpha; alpha = smoothstep(sdf.buffer - sdf.gamma, sdf.buffer + sdf.gamma, distance); if (sdf.outlineBuffer > 0.0) { float inFill = alpha; float inBorder = smoothstep(sdf.outlineBuffer - sdf.gamma, sdf.outlineBuffer + sdf.gamma, distance); color = mix(sdf.outlineColor, vColor, inFill); alpha = inBorder; } } float a = alpha * color.a; if (a < icon.alphaCutoff) { discard; } fragColor = vec4(color.rgb, a * layer.opacity); } DECKGL_FILTER_COLOR(fragColor, geometry); } `;var He=192/256,qi=[],hs={getIconOffsets:{type:"accessor",value:o=>o.offsets},alphaCutoff:.001,smoothing:.1,outlineWidth:0,outlineColor:{type:"color",value:[0,0,0,255]}},Wt=class extends it{getShaders(){let t=super.getShaders();return{...t,modules:[...t.modules,Yi],fs:Ji}}initializeState(){super.initializeState(),this.getAttributeManager().addInstanced({instanceOffsets:{size:2,accessor:"getIconOffsets"},instancePickingColors:{type:"uint8",size:3,accessor:(e,{index:i,target:n})=>this.encodePickingColor(i,n)}})}updateState(t){super.updateState(t);let{props:e,oldProps:i}=t,{outlineColor:n}=e;n!==i.outlineColor&&(n=n.map(r=>r/255),n[3]=Number.isFinite(n[3])?n[3]:1,this.setState({outlineColor:n})),!e.sdf&&e.outlineWidth&&Qi.log.warn(`${this.id}: fontSettings.sdf is required to render outline`)()}draw(t){let{sdf:e,smoothing:i,outlineWidth:n}=this.props,{outlineColor:r}=this.state,s=n?Math.max(i,He*(1-n)):-1,a=this.state.model,l={buffer:He,outlineBuffer:s,gamma:i,enabled:Boolean(e),outlineColor:r};if(a.shaderInputs.setProps({sdf:l}),super.draw(t),e&&n){let{iconManager:c}=this.state;c.getTexture()&&(a.shaderInputs.setProps({sdf:{...l,outlineBuffer:He}}),a.draw(this.context.renderPass))}}getInstanceOffset(t){return t?Array.from(t).flatMap(e=>super.getInstanceOffset(e)):qi}getInstanceColorMode(t){return 1}getInstanceIconFrame(t){return t?Array.from(t).flatMap(e=>super.getInstanceIconFrame(e)):qi}};Wt.defaultProps=hs;Wt.layerName="MultiIconLayer";var Le=Wt;var Bt=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:s="normal",fontStyle:a="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;let l=this.size=t+e*4,c=this._createCanvas(l),u=this.ctx=c.getContext("2d",{willReadFrequently:!0});u.font=`${a} ${s} ${t}px ${r}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l)}_createCanvas(t){let e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){let{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:s}=this.ctx.measureText(t),a=Math.ceil(i),l=0,c=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(s-r))),u=Math.min(this.size-this.buffer,a+Math.ceil(n)),f=c+2*this.buffer,g=u+2*this.buffer,d=Math.max(f*g,0),p=new Uint8ClampedArray(d),h={data:p,width:f,height:g,glyphWidth:c,glyphHeight:u,glyphTop:a,glyphLeft:l,glyphAdvance:e};if(c===0||u===0)return h;let{ctx:m,buffer:y,gridInner:_,gridOuter:x}=this;m.clearRect(y,y,c,u),m.fillText(t,y,y+a);let v=m.getImageData(y,y,c,u);x.fill(1e20,0,d),_.fill(0,0,d);for(let C=0;C0?T*T:0,_[E]=T<0?T*T:0}}tn(x,0,0,f,g,f,this.f,this.v,this.z),tn(_,y,y,c,u,f,this.f,this.v,this.z);for(let C=0;C-1);l++,r[l]=a,s[l]=c,s[l+1]=1e20}for(let a=0,l=0;an&&(c=0,l++),r[f]={x:c+i,y:a+l*u+i,width:g,height:u,layoutWidth:g,layoutHeight:e},c+=g+i*2}return{mapping:r,xOffset:c,yOffset:a+l*u,canvasHeight:ys(a+(l+1)*u)}}function rn(o,t,e,i){let n=0;for(let r=t;ri&&(sa){let f=rn(o,a,l,n);c+f>i&&(si&&(f=sn(o,a,l,i,n,r),s=r[r.length-1])),a=l,c+=f}return c}function Ps(o,t,e,i,n=0,r){r===void 0&&(r=o.length);let s=[];return t==="break-all"?sn(o,n,r,e,i,s):vs(o,n,r,e,i,s),s}function _s(o,t,e,i,n,r){let s=0,a=0;for(let l=t;l0,f=[0,0],g=[0,0],d=0,p=0,h=0;for(let m=0;m<=s;m++){let y=r[m];if((y===` `||m===s)&&(h=m),h>p){let _=u?Ps(r,e,i,n,p,h):xs;for(let x=0;x<=_.length;x++){let v=x===0?p:_[x-1],C=x<_.length?_[x]:h;_s(r,v,C,n,a,g);for(let M=v;M1||l>0){let d=o.constructor;g=new d(c);for(let p=0;p=0&&this._order.splice(e,1)}_appendOrder(t){this._order.push(t)}};function Cs(){let o=[];for(let t=32;t<128;t++)o.push(String.fromCharCode(t));return o}var tt={fontFamily:"Monaco, monospace",fontWeight:"normal",characterSet:Cs(),fontSize:64,buffer:4,sdf:!1,cutoff:.25,radius:12,smoothing:.1},cn=1024,un=.9,fn=1.2,pn=3,Se=new ut(pn);function Ls(o,t){let e;typeof t=="string"?e=new Set(Array.from(t)):e=new Set(t);let i=Se.get(o);if(!i)return e;for(let n in i.mapping)e.has(n)&&e.delete(n);return e}function Ss(o,t){for(let e=0;e=pn,"Invalid cache limit"),Se=new ut(o)}var jt=class{constructor(){this.props={...tt}}get atlas(){return this._atlas}get mapping(){return this._atlas&&this._atlas.mapping}get scale(){let{fontSize:t,buffer:e}=this.props;return(t*fn+e*2)/t}setProps(t={}){Object.assign(this.props,t),this._key=this._getKey();let e=Ls(this._key,this.props.characterSet),i=Se.get(this._key);if(i&&e.size===0){this._atlas!==i&&(this._atlas=i);return}let n=this._generateFontAtlas(e,i);this._atlas=n,Se.set(this._key,n)}_generateFontAtlas(t,e){let{fontFamily:i,fontWeight:n,fontSize:r,buffer:s,sdf:a,radius:l,cutoff:c}=this.props,u=e&&e.data;u||(u=document.createElement("canvas"),u.width=cn);let f=u.getContext("2d",{willReadFrequently:!0});gn(f,i,r,n);let{mapping:g,canvasHeight:d,xOffset:p,yOffset:h}=nn({getFontWidth:m=>f.measureText(m).width,fontHeight:r*fn,buffer:s,characterSet:t,maxCanvasWidth:cn,...e&&{mapping:e.mapping,xOffset:e.xOffset,yOffset:e.yOffset}});if(u.height!==d){let m=f.getImageData(0,0,u.width,u.height);u.height=d,f.putImageData(m,0,0)}if(gn(f,i,r,n),a){let m=new Bt({fontSize:r,buffer:s,radius:l,cutoff:c,fontFamily:i,fontWeight:`${n}`});for(let y of t){let{data:_,width:x,height:v,glyphTop:C}=m.draw(y);g[y].width=x,g[y].layoutOffsetY=r*un-C;let M=f.createImageData(x,v);Ss(_,M),f.putImageData(M,g[y].x,g[y].y)}}else for(let m of t)f.fillText(m,g[m].x,g[m].y+s+r*un);return{xOffset:p,yOffset:h,mapping:g,data:u,width:u.width,height:u.height}}_getKey(){let{fontFamily:t,fontWeight:e,fontSize:i,buffer:n,sdf:r,radius:s,cutoff:a}=this.props;return r?`${t} ${e} ${i} ${n} ${s} ${a}`:`${t} ${e} ${i} ${n}`}};var K=P(L(),1),Pn=P(I(),1),_n=P(I(),1);var mn=`uniform textBackgroundUniforms { bool billboard; float sizeScale; float sizeMinPixels; float sizeMaxPixels; vec4 padding; highp int sizeUnits; bool stroked; } textBackground; `,xn={name:"textBackground",vs:mn,fs:mn,uniformTypes:{billboard:"f32",sizeScale:"f32",sizeMinPixels:"f32",sizeMaxPixels:"f32",padding:"vec4",sizeUnits:"i32",stroked:"f32"}};var yn=`#version 300 es #define SHADER_NAME text-background-layer-vertex-shader in vec2 positions; in vec3 instancePositions; in vec3 instancePositions64Low; in vec4 instanceRects; in float instanceSizes; in float instanceAngles; in vec2 instancePixelOffsets; in float instanceLineWidths; in vec4 instanceFillColors; in vec4 instanceLineColors; in vec3 instancePickingColors; out vec4 vFillColor; out vec4 vLineColor; out float vLineWidth; out vec2 uv; out vec2 dimensions; vec2 rotate_by_angle(vec2 vertex, float angle) { float angle_radian = radians(angle); float cos_angle = cos(angle_radian); float sin_angle = sin(angle_radian); mat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle); return rotationMatrix * vertex; } void main(void) { geometry.worldPosition = instancePositions; geometry.uv = positions; geometry.pickingColor = instancePickingColors; uv = positions; vLineWidth = instanceLineWidths; float sizePixels = clamp( project_size_to_pixel(instanceSizes * textBackground.sizeScale, textBackground.sizeUnits), textBackground.sizeMinPixels, textBackground.sizeMaxPixels ); dimensions = instanceRects.zw * sizePixels + textBackground.padding.xy + textBackground.padding.zw; vec2 pixelOffset = (positions * instanceRects.zw + instanceRects.xy) * sizePixels + mix(-textBackground.padding.xy, textBackground.padding.zw, positions); pixelOffset = rotate_by_angle(pixelOffset, instanceAngles); pixelOffset += instancePixelOffsets; pixelOffset.y *= -1.0; if (textBackground.billboard) { gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); vec3 offset = vec3(pixelOffset, 0.0); DECKGL_FILTER_SIZE(offset, geometry); gl_Position.xy += project_pixel_size_to_clipspace(offset.xy); } else { vec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0); DECKGL_FILTER_SIZE(offset_common, geometry); gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); } vFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * layer.opacity); DECKGL_FILTER_COLOR(vFillColor, geometry); vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * layer.opacity); DECKGL_FILTER_COLOR(vLineColor, geometry); } `;var vn=`#version 300 es #define SHADER_NAME text-background-layer-fragment-shader precision highp float; in vec4 vFillColor; in vec4 vLineColor; in float vLineWidth; in vec2 uv; in vec2 dimensions; out vec4 fragColor; void main(void) { geometry.uv = uv; vec2 pixelPosition = uv * dimensions; if (textBackground.stroked) { float distToEdge = min( min(pixelPosition.x, dimensions.x - pixelPosition.x), min(pixelPosition.y, dimensions.y - pixelPosition.y) ); float isBorder = smoothedge(distToEdge, vLineWidth); fragColor = mix(vFillColor, vLineColor, isBorder); } else { fragColor = vFillColor; } DECKGL_FILTER_COLOR(fragColor, geometry); } `;var ws={billboard:!0,sizeScale:1,sizeUnits:"pixels",sizeMinPixels:0,sizeMaxPixels:Number.MAX_SAFE_INTEGER,padding:{type:"array",value:[0,0,0,0]},getPosition:{type:"accessor",value:o=>o.position},getSize:{type:"accessor",value:1},getAngle:{type:"accessor",value:0},getPixelOffset:{type:"accessor",value:[0,0]},getBoundingRect:{type:"accessor",value:[0,0,0,0]},getFillColor:{type:"accessor",value:[0,0,0,255]},getLineColor:{type:"accessor",value:[0,0,0,255]},getLineWidth:{type:"accessor",value:1}},Vt=class extends K.Layer{getShaders(){return super.getShaders({vs:yn,fs:vn,modules:[K.project32,K.picking,xn]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceSizes:{size:1,transition:!0,accessor:"getSize",defaultValue:1},instanceAngles:{size:1,transition:!0,accessor:"getAngle"},instanceRects:{size:4,accessor:"getBoundingRect"},instancePixelOffsets:{size:2,transition:!0,accessor:"getPixelOffset"},instanceFillColors:{size:4,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255]},instanceLineColors:{size:4,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1}})}updateState(t){super.updateState(t);let{changeFlags:e}=t;e.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:t}){let{billboard:e,sizeScale:i,sizeUnits:n,sizeMinPixels:r,sizeMaxPixels:s,getLineWidth:a}=this.props,{padding:l}=this.props;l.length<4&&(l=[l[0],l[1],l[0],l[1]]);let c=this.state.model,u={billboard:e,stroked:Boolean(a),padding:l,sizeUnits:K.UNIT[n],sizeScale:i,sizeMinPixels:r,sizeMaxPixels:s};c.shaderInputs.setProps({textBackground:u}),c.draw(this.context.renderPass)}_getModel(){let t=[0,0,1,0,0,1,1,1];return new _n.Model(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Pn.Geometry({topology:"triangle-strip",vertexCount:4,attributes:{positions:{size:2,value:new Float32Array(t)}}}),isInstanced:!0})}};Vt.defaultProps=ws;Vt.layerName="TextBackgroundLayer";var we=Vt;var Cn={start:1,middle:0,end:-1},Ln={top:1,center:0,bottom:-1},Ze=[0,0,0,255],Ms=1,Ts={billboard:!0,sizeScale:1,sizeUnits:"pixels",sizeMinPixels:0,sizeMaxPixels:Number.MAX_SAFE_INTEGER,background:!1,getBackgroundColor:{type:"accessor",value:[255,255,255,255]},getBorderColor:{type:"accessor",value:Ze},getBorderWidth:{type:"accessor",value:0},backgroundPadding:{type:"array",value:[0,0,0,0]},characterSet:{type:"object",value:tt.characterSet},fontFamily:tt.fontFamily,fontWeight:tt.fontWeight,lineHeight:Ms,outlineWidth:{type:"number",value:0,min:0},outlineColor:{type:"color",value:Ze},fontSettings:{type:"object",value:{},compare:1},wordBreak:"break-word",maxWidth:{type:"number",value:-1},getText:{type:"accessor",value:o=>o.text},getPosition:{type:"accessor",value:o=>o.position},getColor:{type:"accessor",value:Ze},getSize:{type:"accessor",value:32},getAngle:{type:"accessor",value:0},getTextAnchor:{type:"accessor",value:"middle"},getAlignmentBaseline:{type:"accessor",value:"center"},getPixelOffset:{type:"accessor",value:[0,0]},backgroundColor:{deprecatedFor:["background","getBackgroundColor"]}},Ht=class extends ft.CompositeLayer{constructor(){super(...arguments),this.getBoundingRect=(t,e)=>{let{size:[i,n]}=this.transformParagraph(t,e),{fontSize:r}=this.state.fontAtlasManager.props;i/=r,n/=r;let{getTextAnchor:s,getAlignmentBaseline:a}=this.props,l=Cn[typeof s=="function"?s(t,e):s],c=Ln[typeof a=="function"?a(t,e):a];return[(l-1)*i/2,(c-1)*n/2,i,n]},this.getIconOffsets=(t,e)=>{let{getTextAnchor:i,getAlignmentBaseline:n}=this.props,{x:r,y:s,rowWidth:a,size:[l,c]}=this.transformParagraph(t,e),u=Cn[typeof i=="function"?i(t,e):i],f=Ln[typeof n=="function"?n(t,e):n],g=r.length,d=new Array(g*2),p=0;for(let h=0;h0&&ft.log.warn("v8.9 breaking change: TextLayer maxWidth is now relative to text size")()}updateState(t){let{props:e,oldProps:i,changeFlags:n}=t;(n.dataChanged||n.updateTriggersChanged&&(n.updateTriggersChanged.all||n.updateTriggersChanged.getText))&&this._updateText(),(this._updateFontAtlas()||e.lineHeight!==i.lineHeight||e.wordBreak!==i.wordBreak||e.maxWidth!==i.maxWidth)&&this.setState({styleVersion:this.state.styleVersion+1})}getPickingInfo({info:t}){return t.object=t.index>=0?this.props.data[t.index]:null,t}_updateFontAtlas(){let{fontSettings:t,fontFamily:e,fontWeight:i}=this.props,{fontAtlasManager:n,characterSet:r}=this.state,s={...t,characterSet:r,fontFamily:e,fontWeight:i};if(!n.mapping)return n.setProps(s),!0;for(let a in s)if(s[a]!==n.props[a])return n.setProps(s),!0;return!1}_updateText(){let{data:t,characterSet:e}=this.props,i=t.attributes?.getText,{getText:n}=this.props,r=t.startIndices,s,a=e==="auto"&&new Set;if(i&&r){let{texts:l,characterCount:c}=ln({...ArrayBuffer.isView(i)?{value:i}:i,length:t.length,startIndices:r,characterSet:a});s=c,n=(u,{index:f})=>l[f]}else{let{iterable:l,objectInfo:c}=(0,ft.createIterable)(t);r=[0],s=0;for(let u of l){c.index++;let f=Array.from(n(u,c)||"");a&&f.forEach(a.add,a),s+=f.length,r.push(s)}}this.setState({getText:n,startIndices:r,numInstances:s,characterSet:a||e})}transformParagraph(t,e){let{fontAtlasManager:i}=this.state,n=i.mapping,r=this.state.getText,{wordBreak:s,lineHeight:a,maxWidth:l}=this.props,c=r(t,e)||"";return an(c,a,s,l*i.props.fontSize,n)}renderLayers(){let{startIndices:t,numInstances:e,getText:i,fontAtlasManager:{scale:n,atlas:r,mapping:s},styleVersion:a}=this.state,{data:l,_dataDiff:c,getPosition:u,getColor:f,getSize:g,getAngle:d,getPixelOffset:p,getBackgroundColor:h,getBorderColor:m,getBorderWidth:y,backgroundPadding:_,background:x,billboard:v,fontSettings:C,outlineWidth:M,outlineColor:F,sizeScale:E,sizeUnits:T,sizeMinPixels:Yt,sizeMaxPixels:et,transitions:b,updateTriggers:w}=this.props,Ae=this.getSubLayerClass("characters",Le),Jt=this.getSubLayerClass("background",we);return[x&&new Jt({getFillColor:h,getLineColor:m,getLineWidth:y,padding:_,getPosition:u,getSize:g,getAngle:d,getPixelOffset:p,billboard:v,sizeScale:E,sizeUnits:T,sizeMinPixels:Yt,sizeMaxPixels:et,transitions:b&&{getPosition:b.getPosition,getAngle:b.getAngle,getSize:b.getSize,getFillColor:b.getBackgroundColor,getLineColor:b.getBorderColor,getLineWidth:b.getBorderWidth,getPixelOffset:b.getPixelOffset}},this.getSubLayerProps({id:"background",updateTriggers:{getPosition:w.getPosition,getAngle:w.getAngle,getSize:w.getSize,getFillColor:w.getBackgroundColor,getLineColor:w.getBorderColor,getLineWidth:w.getBorderWidth,getPixelOffset:w.getPixelOffset,getBoundingRect:{getText:w.getText,getTextAnchor:w.getTextAnchor,getAlignmentBaseline:w.getAlignmentBaseline,styleVersion:a}}}),{data:l.attributes&&l.attributes.background?{length:l.length,attributes:l.attributes.background}:l,_dataDiff:c,autoHighlight:!1,getBoundingRect:this.getBoundingRect}),new Ae({sdf:C.sdf,smoothing:Number.isFinite(C.smoothing)?C.smoothing:tt.smoothing,outlineWidth:M/(C.radius||tt.radius),outlineColor:F,iconAtlas:r,iconMapping:s,getPosition:u,getColor:f,getSize:g,getAngle:d,getPixelOffset:p,billboard:v,sizeScale:E*n,sizeUnits:T,sizeMinPixels:Yt*n,sizeMaxPixels:et*n,transitions:b&&{getPosition:b.getPosition,getAngle:b.getAngle,getColor:b.getColor,getSize:b.getSize,getPixelOffset:b.getPixelOffset}},this.getSubLayerProps({id:"characters",updateTriggers:{all:w.getText,getPosition:w.getPosition,getAngle:w.getAngle,getColor:w.getColor,getSize:w.getSize,getPixelOffset:w.getPixelOffset,getIconOffsets:{getTextAnchor:w.getTextAnchor,getAlignmentBaseline:w.getAlignmentBaseline,styleVersion:a}}}),{data:l,_dataDiff:c,startIndices:t,numInstances:e,getIconOffsets:this.getIconOffsets,getIcon:i})]}static set fontAtlasCacheLimit(t){hn(t)}};Ht.defaultProps=Ts;Ht.layerName="TextLayer";var Me=Ht;var Zt={circle:{type:ae,props:{filled:"filled",stroked:"stroked",lineWidthMaxPixels:"lineWidthMaxPixels",lineWidthMinPixels:"lineWidthMinPixels",lineWidthScale:"lineWidthScale",lineWidthUnits:"lineWidthUnits",pointRadiusMaxPixels:"radiusMaxPixels",pointRadiusMinPixels:"radiusMinPixels",pointRadiusScale:"radiusScale",pointRadiusUnits:"radiusUnits",pointAntialiasing:"antialiasing",pointBillboard:"billboard",getFillColor:"getFillColor",getLineColor:"getLineColor",getLineWidth:"getLineWidth",getPointRadius:"getRadius"}},icon:{type:it,props:{iconAtlas:"iconAtlas",iconMapping:"iconMapping",iconSizeMaxPixels:"sizeMaxPixels",iconSizeMinPixels:"sizeMinPixels",iconSizeScale:"sizeScale",iconSizeUnits:"sizeUnits",iconAlphaCutoff:"alphaCutoff",iconBillboard:"billboard",getIcon:"getIcon",getIconAngle:"getAngle",getIconColor:"getColor",getIconPixelOffset:"getPixelOffset",getIconSize:"getSize"}},text:{type:Me,props:{textSizeMaxPixels:"sizeMaxPixels",textSizeMinPixels:"sizeMinPixels",textSizeScale:"sizeScale",textSizeUnits:"sizeUnits",textBackground:"background",textBackgroundPadding:"backgroundPadding",textFontFamily:"fontFamily",textFontWeight:"fontWeight",textLineHeight:"lineHeight",textMaxWidth:"maxWidth",textOutlineColor:"outlineColor",textOutlineWidth:"outlineWidth",textWordBreak:"wordBreak",textCharacterSet:"characterSet",textBillboard:"billboard",textFontSettings:"fontSettings",getText:"getText",getTextAngle:"getAngle",getTextColor:"getColor",getTextPixelOffset:"getPixelOffset",getTextSize:"getSize",getTextAnchor:"getTextAnchor",getTextAlignmentBaseline:"getAlignmentBaseline",getTextBackgroundColor:"getBackgroundColor",getTextBorderColor:"getBorderColor",getTextBorderWidth:"getBorderWidth"}}},Kt={type:rt,props:{lineWidthUnits:"widthUnits",lineWidthScale:"widthScale",lineWidthMinPixels:"widthMinPixels",lineWidthMaxPixels:"widthMaxPixels",lineJointRounded:"jointRounded",lineCapRounded:"capRounded",lineMiterLimit:"miterLimit",lineBillboard:"billboard",getLineColor:"getColor",getLineWidth:"getWidth"}},Te={type:lt,props:{extruded:"extruded",filled:"filled",wireframe:"wireframe",elevationScale:"elevationScale",material:"material",_full3d:"_full3d",getElevation:"getElevation",getFillColor:"getFillColor",getLineColor:"getLineColor"}};function gt({type:o,props:t}){let e={};for(let i in t)e[i]=o.defaultProps[t[i]];return e}function be(o,t){let{transitions:e,updateTriggers:i}=o.props,n={updateTriggers:{},transitions:e&&{getPosition:e.geometry}};for(let r in t){let s=t[r],a=o.props[r];r.startsWith("get")&&(a=o.getSubLayerAccessor(a),n.updateTriggers[s]=i[r],e&&(n.transitions[s]=e[r])),n[s]=a}return n}var dt=P(L(),1);function wn(o){if(Array.isArray(o))return o;switch(dt.log.assert(o.type,"GeoJSON does not have type"),o.type){case"Feature":return[o];case"FeatureCollection":return dt.log.assert(Array.isArray(o.features),"GeoJSON does not have features array"),o.features;default:return[{geometry:o}]}}function Ke(o,t,e={}){let i={pointFeatures:[],lineFeatures:[],polygonFeatures:[],polygonOutlineFeatures:[]},{startRow:n=0,endRow:r=o.length}=e;for(let s=n;s{a.push(e({geometry:{type:"Point",coordinates:f}},i,n))});break;case"LineString":l.push(e({geometry:o},i,n));break;case"MultiLineString":s.forEach(f=>{l.push(e({geometry:{type:"LineString",coordinates:f}},i,n))});break;case"Polygon":c.push(e({geometry:o},i,n)),s.forEach(f=>{u.push(e({geometry:{type:"LineString",coordinates:f}},i,n))});break;case"MultiPolygon":s.forEach(f=>{c.push(e({geometry:{type:"Polygon",coordinates:f}},i,n)),f.forEach(g=>{u.push(e({geometry:{type:"LineString",coordinates:g}},i,n))})});break;default:}}var bs={Point:1,MultiPoint:2,LineString:2,MultiLineString:3,Polygon:3,MultiPolygon:4};function Is(o,t){let e=bs[o];for(dt.log.assert(e,`Unknown GeoJSON type ${o}`);t&&--e>0;)t=t[0];return t&&Number.isFinite(t[0])}function Mn(){return{points:{},lines:{},polygons:{},polygonsOutline:{}}}function Ie(o){return o.geometry.coordinates}function Tn(o,t){let e=Mn(),{pointFeatures:i,lineFeatures:n,polygonFeatures:r,polygonOutlineFeatures:s}=o;return e.points.data=i,e.points._dataDiff=t.pointFeatures&&(()=>t.pointFeatures),e.points.getPosition=Ie,e.lines.data=n,e.lines._dataDiff=t.lineFeatures&&(()=>t.lineFeatures),e.lines.getPath=Ie,e.polygons.data=r,e.polygons._dataDiff=t.polygonFeatures&&(()=>t.polygonFeatures),e.polygons.getPolygon=Ie,e.polygonsOutline.data=s,e.polygonsOutline._dataDiff=t.polygonOutlineFeatures&&(()=>t.polygonOutlineFeatures),e.polygonsOutline.getPath=Ie,e}function bn(o,t){let e=Mn(),{points:i,lines:n,polygons:r}=o,s=Xi(o,t);return e.points.data={length:i.positions.value.length/i.positions.size,attributes:{...i.attributes,getPosition:i.positions,instancePickingColors:{size:4,value:s.points}},properties:i.properties,numericProps:i.numericProps,featureIds:i.featureIds},e.lines.data={length:n.pathIndices.value.length-1,startIndices:n.pathIndices.value,attributes:{...n.attributes,getPath:n.positions,instancePickingColors:{size:4,value:s.lines}},properties:n.properties,numericProps:n.numericProps,featureIds:n.featureIds},e.lines._pathType="open",e.polygons.data={length:r.polygonIndices.value.length-1,startIndices:r.polygonIndices.value,attributes:{...r.attributes,getPolygon:r.positions,pickingColors:{size:4,value:s.polygons}},properties:r.properties,numericProps:r.numericProps,featureIds:r.featureIds},e.polygons._normalize=!1,r.triangles&&(e.polygons.data.attributes.indices=r.triangles.value),e.polygonsOutline.data={length:r.primitivePolygonIndices.value.length-1,startIndices:r.primitivePolygonIndices.value,attributes:{...r.attributes,getPath:r.positions,instancePickingColors:{size:4,value:s.polygons}},properties:r.properties,numericProps:r.numericProps,featureIds:r.featureIds},e.polygonsOutline._pathType="open",e}var As=["points","linestrings","polygons"],Es={...gt(Zt.circle),...gt(Zt.icon),...gt(Zt.text),...gt(Kt),...gt(Te),stroked:!0,filled:!0,extruded:!1,wireframe:!1,_full3d:!1,iconAtlas:{type:"object",value:null},iconMapping:{type:"object",value:{}},getIcon:{type:"accessor",value:o=>o.properties.icon},getText:{type:"accessor",value:o=>o.properties.text},pointType:"circle",getRadius:{deprecatedFor:"getPointRadius"}},Xt=class extends In.CompositeLayer{initializeState(){this.state={layerProps:{},features:{},featuresDiff:{}}}updateState({props:t,changeFlags:e}){if(!e.dataChanged)return;let{data:i}=this.props,n=i&&"points"in i&&"polygons"in i&&"lines"in i;this.setState({binary:n}),n?this._updateStateBinary({props:t,changeFlags:e}):this._updateStateJSON({props:t,changeFlags:e})}_updateStateBinary({props:t,changeFlags:e}){let i=bn(t.data,this.encodePickingColor);this.setState({layerProps:i})}_updateStateJSON({props:t,changeFlags:e}){let i=wn(t.data),n=this.getSubLayerRow.bind(this),r={},s={};if(Array.isArray(e.dataChanged)){let l=this.state.features;for(let c in l)r[c]=l[c].slice(),s[c]=[];for(let c of e.dataChanged){let u=Ke(i,n,c);for(let f in l)s[f].push(Ce({data:r[f],getIndex:g=>g.__source.index,dataRange:c,replace:u[f]}))}}else r=Ke(i,n);let a=Tn(r,s);this.setState({features:r,featuresDiff:s,layerProps:a})}getPickingInfo(t){let e=super.getPickingInfo(t),{index:i,sourceLayer:n}=e;return e.featureType=As.find(r=>n.id.startsWith(`${this.id}-${r}-`)),i>=0&&n.id.startsWith(`${this.id}-points-text`)&&this.state.binary&&(e.index=this.props.data.points.globalFeatureIds.value[i]),e}_updateAutoHighlight(t){let e=`${this.id}-points-`,i=t.featureType==="points";for(let n of this.getSubLayers())n.id.startsWith(e)===i&&n.updateAutoHighlight(t)}_renderPolygonLayer(){let{extruded:t,wireframe:e}=this.props,{layerProps:i}=this.state,n="polygons-fill",r=this.shouldRenderSubLayer(n,i.polygons?.data)&&this.getSubLayerClass(n,Te.type);if(r){let s=be(this,Te.props),a=t&&e;return a||delete s.getLineColor,s.updateTriggers.lineColors=a,new r(s,this.getSubLayerProps({id:n,updateTriggers:s.updateTriggers}),i.polygons)}return null}_renderLineLayers(){let{extruded:t,stroked:e}=this.props,{layerProps:i}=this.state,n="polygons-stroke",r="linestrings",s=!t&&e&&this.shouldRenderSubLayer(n,i.polygonsOutline?.data)&&this.getSubLayerClass(n,Kt.type),a=this.shouldRenderSubLayer(r,i.lines?.data)&&this.getSubLayerClass(r,Kt.type);if(s||a){let l=be(this,Kt.props);return[s&&new s(l,this.getSubLayerProps({id:n,updateTriggers:l.updateTriggers}),i.polygonsOutline),a&&new a(l,this.getSubLayerProps({id:r,updateTriggers:l.updateTriggers}),i.lines)]}return null}_renderPointLayers(){let{pointType:t}=this.props,{layerProps:e,binary:i}=this.state,{highlightedObjectIndex:n}=this.props;!i&&Number.isFinite(n)&&(n=e.points.data.findIndex(a=>a.__source.index===n));let r=new Set(t.split("+")),s=[];for(let a of r){let l=`points-${a}`,c=Zt[a],u=c&&this.shouldRenderSubLayer(l,e.points?.data)&&this.getSubLayerClass(l,c.type);if(u){let f=be(this,c.props),g=e.points;if(a==="text"&&i){let{instancePickingColors:d,...p}=g.data.attributes;g={...g,data:{...g.data,attributes:p}}}s.push(new u(f,this.getSubLayerProps({id:l,updateTriggers:f.updateTriggers,highlightedObjectIndex:n}),g))}}return s}renderLayers(){let{extruded:t}=this.props,e=this._renderPolygonLayer(),i=this._renderLineLayers(),n=this._renderPointLayers();return[!t&&e,i,n,t&&e]}getSubLayerAccessor(t){let{binary:e}=this.state;return!e||typeof t!="function"?super.getSubLayerAccessor(t):(i,n)=>{let{data:r,index:s}=n,a=Ki(r,s);return t(a,n)}}};Xt.layerName="GeoJsonLayer";Xt.defaultProps=Es;var An=Xt;return Un($t);})(); return __exports__; });