tangram-core 0.2.0__cp313-cp313-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. tangram_core/App.vue +335 -0
  2. tangram_core/__init__.py +5 -0
  3. tangram_core/__main__.py +141 -0
  4. tangram_core/_core.cp313-win_amd64.pyd +0 -0
  5. tangram_core/_core.pyi +38 -0
  6. tangram_core/api.ts +456 -0
  7. tangram_core/backend.py +335 -0
  8. tangram_core/colour.ts +71 -0
  9. tangram_core/config.py +122 -0
  10. tangram_core/dist-frontend/aggregation-layers.js +521 -0
  11. tangram_core/dist-frontend/aggregation-layers.js.map +1 -0
  12. tangram_core/dist-frontend/assets/_commonjsHelpers-CqkleIqs.js +2 -0
  13. tangram_core/dist-frontend/assets/_commonjsHelpers-CqkleIqs.js.map +1 -0
  14. tangram_core/dist-frontend/assets/array-utils-flat-wyE8tIYR.js +11 -0
  15. tangram_core/dist-frontend/assets/array-utils-flat-wyE8tIYR.js.map +1 -0
  16. tangram_core/dist-frontend/assets/assert-hrfsarFU.js +3 -0
  17. tangram_core/dist-frontend/assets/assert-hrfsarFU.js.map +1 -0
  18. tangram_core/dist-frontend/assets/b612-latin-400-italic-DePNXA0a.woff +0 -0
  19. tangram_core/dist-frontend/assets/b612-latin-400-italic-a-4GLPtl.woff2 +0 -0
  20. tangram_core/dist-frontend/assets/b612-latin-400-normal-CC98FVm_.woff2 +0 -0
  21. tangram_core/dist-frontend/assets/b612-latin-400-normal-JbZ7xwUX.woff +0 -0
  22. tangram_core/dist-frontend/assets/b612-latin-700-normal-B_Snq1wd.woff +0 -0
  23. tangram_core/dist-frontend/assets/b612-latin-700-normal-BinQrnoB.woff2 +0 -0
  24. tangram_core/dist-frontend/assets/clip-extension-DTCP51Ak.js +26 -0
  25. tangram_core/dist-frontend/assets/clip-extension-DTCP51Ak.js.map +1 -0
  26. tangram_core/dist-frontend/assets/color-CUNNsFV-.js +17 -0
  27. tangram_core/dist-frontend/assets/color-CUNNsFV-.js.map +1 -0
  28. tangram_core/dist-frontend/assets/cube-geometry-CzJ_uBWa.js +2 -0
  29. tangram_core/dist-frontend/assets/cube-geometry-CzJ_uBWa.js.map +1 -0
  30. tangram_core/dist-frontend/assets/deep-equal-uriyKJca.js +2 -0
  31. tangram_core/dist-frontend/assets/deep-equal-uriyKJca.js.map +1 -0
  32. tangram_core/dist-frontend/assets/fly-to-interpolator-DlKiy9_S.js +2 -0
  33. tangram_core/dist-frontend/assets/fly-to-interpolator-DlKiy9_S.js.map +1 -0
  34. tangram_core/dist-frontend/assets/geojson-layer-CLhXLxdI.js +1010 -0
  35. tangram_core/dist-frontend/assets/geojson-layer-CLhXLxdI.js.map +1 -0
  36. tangram_core/dist-frontend/assets/globe-view-DKhftlA1.js +94 -0
  37. tangram_core/dist-frontend/assets/globe-view-DKhftlA1.js.map +1 -0
  38. tangram_core/dist-frontend/assets/globe-viewport-CPES4D4P.js +2 -0
  39. tangram_core/dist-frontend/assets/globe-viewport-CPES4D4P.js.map +1 -0
  40. tangram_core/dist-frontend/assets/image-loader-ClbNCMXW.js +2 -0
  41. tangram_core/dist-frontend/assets/image-loader-ClbNCMXW.js.map +1 -0
  42. tangram_core/dist-frontend/assets/inconsolata-latin-400-normal-DTZQ6lD6.woff2 +0 -0
  43. tangram_core/dist-frontend/assets/inconsolata-latin-400-normal-HYADljCo.woff +0 -0
  44. tangram_core/dist-frontend/assets/inconsolata-latin-700-normal-ByjKuJjN.woff2 +0 -0
  45. tangram_core/dist-frontend/assets/inconsolata-latin-700-normal-DzgUY3Rl.woff +0 -0
  46. tangram_core/dist-frontend/assets/inconsolata-latin-ext-400-normal-BaHVOdFB.woff2 +0 -0
  47. tangram_core/dist-frontend/assets/inconsolata-latin-ext-400-normal-yvPjCxxx.woff +0 -0
  48. tangram_core/dist-frontend/assets/inconsolata-latin-ext-700-normal-D0Kpgs_9.woff2 +0 -0
  49. tangram_core/dist-frontend/assets/inconsolata-latin-ext-700-normal-Dlt-daqV.woff +0 -0
  50. tangram_core/dist-frontend/assets/inconsolata-vietnamese-400-normal-ByiM2lek.woff +0 -0
  51. tangram_core/dist-frontend/assets/inconsolata-vietnamese-400-normal-DfC_iMic.woff2 +0 -0
  52. tangram_core/dist-frontend/assets/inconsolata-vietnamese-700-normal-DLCFFAUf.woff +0 -0
  53. tangram_core/dist-frontend/assets/inconsolata-vietnamese-700-normal-DuasYmn8.woff2 +0 -0
  54. tangram_core/dist-frontend/assets/index-UPPakSLR.css +1 -0
  55. tangram_core/dist-frontend/assets/index-r8T0kY2p.js +821 -0
  56. tangram_core/dist-frontend/assets/index-r8T0kY2p.js.map +1 -0
  57. tangram_core/dist-frontend/assets/layer-DO63TrsS.js +555 -0
  58. tangram_core/dist-frontend/assets/layer-DO63TrsS.js.map +1 -0
  59. tangram_core/dist-frontend/assets/layer-extension-CZ3zsHuN.js +2 -0
  60. tangram_core/dist-frontend/assets/layer-extension-CZ3zsHuN.js.map +1 -0
  61. tangram_core/dist-frontend/assets/mesh-layers-BSECKarm.js +1123 -0
  62. tangram_core/dist-frontend/assets/mesh-layers-BSECKarm.js.map +1 -0
  63. tangram_core/dist-frontend/assets/orthographic-viewport-CzZmHDEZ.js +2 -0
  64. tangram_core/dist-frontend/assets/orthographic-viewport-CzZmHDEZ.js.map +1 -0
  65. tangram_core/dist-frontend/assets/pick-layers-pass-xhWsgZtf.js +2 -0
  66. tangram_core/dist-frontend/assets/pick-layers-pass-xhWsgZtf.js.map +1 -0
  67. tangram_core/dist-frontend/assets/project-CrvReKGW.js +760 -0
  68. tangram_core/dist-frontend/assets/project-CrvReKGW.js.map +1 -0
  69. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-400-italic-4qS3_zkX.woff2 +0 -0
  70. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-400-italic-CDK-EZBY.woff +0 -0
  71. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-400-normal-Bgns473E.woff +0 -0
  72. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-400-normal-_T2aQlWs.woff2 +0 -0
  73. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-500-normal-CvEVpWxD.woff +0 -0
  74. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-500-normal-s4PklZE0.woff2 +0 -0
  75. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-700-normal-9RN-Z7cI.woff2 +0 -0
  76. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-700-normal-BGMkBBYx.woff +0 -0
  77. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-400-italic-C7erd-g8.woff +0 -0
  78. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-400-italic-DR5R5TWx.woff2 +0 -0
  79. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-400-normal-DGo1Ayjq.woff2 +0 -0
  80. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-400-normal-WtM1l1qc.woff +0 -0
  81. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-500-normal-C8FNIdXm.woff2 +0 -0
  82. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-500-normal-TLDmfi3Q.woff +0 -0
  83. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-700-normal-CTXjXnze.woff2 +0 -0
  84. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-700-normal-CWPRiRXS.woff +0 -0
  85. tangram_core/dist-frontend/assets/roboto-condensed-greek-400-italic-CR6qj4Z4.woff2 +0 -0
  86. tangram_core/dist-frontend/assets/roboto-condensed-greek-400-italic-DHRaIs10.woff +0 -0
  87. tangram_core/dist-frontend/assets/roboto-condensed-greek-400-normal-D5vBSIyg.woff2 +0 -0
  88. tangram_core/dist-frontend/assets/roboto-condensed-greek-400-normal-FabMgVmk.woff +0 -0
  89. tangram_core/dist-frontend/assets/roboto-condensed-greek-500-normal-BIN62cw9.woff +0 -0
  90. tangram_core/dist-frontend/assets/roboto-condensed-greek-500-normal-Hsn-wDIp.woff2 +0 -0
  91. tangram_core/dist-frontend/assets/roboto-condensed-greek-700-normal-89Up2Xly.woff +0 -0
  92. tangram_core/dist-frontend/assets/roboto-condensed-greek-700-normal-DWMOA2VK.woff2 +0 -0
  93. tangram_core/dist-frontend/assets/roboto-condensed-latin-400-italic-D_BR-3LG.woff2 +0 -0
  94. tangram_core/dist-frontend/assets/roboto-condensed-latin-400-italic-om57GXsO.woff +0 -0
  95. tangram_core/dist-frontend/assets/roboto-condensed-latin-400-normal-BICmKrXV.woff2 +0 -0
  96. tangram_core/dist-frontend/assets/roboto-condensed-latin-400-normal-D2e7XwB1.woff +0 -0
  97. tangram_core/dist-frontend/assets/roboto-condensed-latin-500-normal-3p2daRJW.woff2 +0 -0
  98. tangram_core/dist-frontend/assets/roboto-condensed-latin-500-normal-Dc9bsamC.woff +0 -0
  99. tangram_core/dist-frontend/assets/roboto-condensed-latin-700-normal-BOl6B_hI.woff +0 -0
  100. tangram_core/dist-frontend/assets/roboto-condensed-latin-700-normal-DRbp0YnP.woff2 +0 -0
  101. tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-400-italic-BXrkWnoY.woff +0 -0
  102. tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-400-italic-Bhem1d5z.woff2 +0 -0
  103. tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-400-normal-DT8nEsYA.woff +0 -0
  104. tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-400-normal-OHaX69iP.woff2 +0 -0
  105. tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-500-normal-CcSTXKtO.woff2 +0 -0
  106. tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-500-normal-JgPl2bDS.woff +0 -0
  107. tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-700-normal-B004qtqu.woff2 +0 -0
  108. tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-700-normal-O6H_RRvN.woff +0 -0
  109. tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-400-italic-BwUYFJ2t.woff2 +0 -0
  110. tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-400-italic-DV8QogUk.woff +0 -0
  111. tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-400-normal-0o1laQ-g.woff2 +0 -0
  112. tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-400-normal-CPsdS8_S.woff +0 -0
  113. tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-500-normal-G9shSJ2z.woff +0 -0
  114. tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-500-normal-TFWhjk13.woff2 +0 -0
  115. tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-700-normal-BtNeb9D6.woff +0 -0
  116. tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-700-normal-D35V1G0s.woff2 +0 -0
  117. tangram_core/dist-frontend/assets/shader-BJmsOfPx.js +843 -0
  118. tangram_core/dist-frontend/assets/shader-BJmsOfPx.js.map +1 -0
  119. tangram_core/dist-frontend/assets/solid-polygon-layer-DiarVGxh.js +392 -0
  120. tangram_core/dist-frontend/assets/solid-polygon-layer-DiarVGxh.js.map +1 -0
  121. tangram_core/dist-frontend/assets/tesselator-49Dw9L5A.js +2 -0
  122. tangram_core/dist-frontend/assets/tesselator-49Dw9L5A.js.map +1 -0
  123. tangram_core/dist-frontend/assets/webgl-developer-tools-CZl8qVFg.js +7 -0
  124. tangram_core/dist-frontend/assets/webgl-developer-tools-CZl8qVFg.js.map +1 -0
  125. tangram_core/dist-frontend/assets/webgl-device-BY0-CUP6.js +3 -0
  126. tangram_core/dist-frontend/assets/webgl-device-BY0-CUP6.js.map +1 -0
  127. tangram_core/dist-frontend/assets/widget-BbOeHGj0.js +2 -0
  128. tangram_core/dist-frontend/assets/widget-BbOeHGj0.js.map +1 -0
  129. tangram_core/dist-frontend/core.js +60 -0
  130. tangram_core/dist-frontend/core.js.map +1 -0
  131. tangram_core/dist-frontend/extensions.js +609 -0
  132. tangram_core/dist-frontend/extensions.js.map +1 -0
  133. tangram_core/dist-frontend/favicon.ico +0 -0
  134. tangram_core/dist-frontend/favicon.png +0 -0
  135. tangram_core/dist-frontend/font-awesome.min.css +4 -0
  136. tangram_core/dist-frontend/fonts/FontAwesome.otf +0 -0
  137. tangram_core/dist-frontend/fonts/fontawesome-webfont.eot +0 -0
  138. tangram_core/dist-frontend/fonts/fontawesome-webfont.svg +2671 -0
  139. tangram_core/dist-frontend/fonts/fontawesome-webfont.ttf +0 -0
  140. tangram_core/dist-frontend/fonts/fontawesome-webfont.woff +0 -0
  141. tangram_core/dist-frontend/fonts/fontawesome-webfont.woff2 +0 -0
  142. tangram_core/dist-frontend/geo-layers.js +115 -0
  143. tangram_core/dist-frontend/geo-layers.js.map +1 -0
  144. tangram_core/dist-frontend/index.html +38 -0
  145. tangram_core/dist-frontend/json.js +3 -0
  146. tangram_core/dist-frontend/json.js.map +1 -0
  147. tangram_core/dist-frontend/layers.js +268 -0
  148. tangram_core/dist-frontend/layers.js.map +1 -0
  149. tangram_core/dist-frontend/lit-html.js +7 -0
  150. tangram_core/dist-frontend/lit-html.js.map +1 -0
  151. tangram_core/dist-frontend/mapbox.js +2 -0
  152. tangram_core/dist-frontend/mapbox.js.map +1 -0
  153. tangram_core/dist-frontend/maplibre-gl.js +59 -0
  154. tangram_core/dist-frontend/maplibre-gl.js.map +1 -0
  155. tangram_core/dist-frontend/mesh-layers.js +2 -0
  156. tangram_core/dist-frontend/mesh-layers.js.map +1 -0
  157. tangram_core/dist-frontend/rs1090_wasm.js +813 -0
  158. tangram_core/dist-frontend/rs1090_wasm_bg.wasm +0 -0
  159. tangram_core/dist-frontend/vue.esm-browser.prod.js +13 -0
  160. tangram_core/dist-frontend/widgets.js +3 -0
  161. tangram_core/dist-frontend/widgets.js.map +1 -0
  162. tangram_core/main.ts +16 -0
  163. tangram_core/plugin.py +70 -0
  164. tangram_core/plugin.ts +41 -0
  165. tangram_core/redis.py +89 -0
  166. tangram_core/user.css +114 -0
  167. tangram_core/vite-plugin-tangram.mjs +88 -0
  168. tangram_core-0.2.0.dist-info/METADATA +37 -0
  169. tangram_core-0.2.0.dist-info/RECORD +171 -0
  170. tangram_core-0.2.0.dist-info/WHEEL +4 -0
  171. tangram_core-0.2.0.dist-info/entry_points.txt +2 -0
@@ -0,0 +1,1010 @@
1
+ import{L as E,p as z,d as O,c as te,G as K}from"./layer-DO63TrsS.js";import{U as w,u as X,O as we,m as ae,x as T}from"./deep-equal-uriyKJca.js";import{M as F}from"./shader-BJmsOfPx.js";import{c as Ee}from"./color-CUNNsFV-.js";import{g as Ye,C as ie}from"./tesselator-49Dw9L5A.js";import{n as Je,S as ze,P as Oe}from"./solid-polygon-layer-DiarVGxh.js";import{l as Qe}from"./webgl-developer-tools-CZl8qVFg.js";const le=`uniform arcUniforms {
2
+ bool greatCircle;
3
+ bool useShortestPath;
4
+ float numSegments;
5
+ float widthScale;
6
+ float widthMinPixels;
7
+ float widthMaxPixels;
8
+ highp int widthUnits;
9
+ } arc;
10
+ `,et={name:"arc",vs:le,fs:le,uniformTypes:{greatCircle:"f32",useShortestPath:"f32",numSegments:"f32",widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",widthUnits:"i32"}},tt=`#version 300 es
11
+ #define SHADER_NAME arc-layer-vertex-shader
12
+ in vec4 instanceSourceColors;
13
+ in vec4 instanceTargetColors;
14
+ in vec3 instanceSourcePositions;
15
+ in vec3 instanceSourcePositions64Low;
16
+ in vec3 instanceTargetPositions;
17
+ in vec3 instanceTargetPositions64Low;
18
+ in vec3 instancePickingColors;
19
+ in float instanceWidths;
20
+ in float instanceHeights;
21
+ in float instanceTilts;
22
+ out vec4 vColor;
23
+ out vec2 uv;
24
+ out float isValid;
25
+ float paraboloid(float distance, float sourceZ, float targetZ, float ratio) {
26
+ float deltaZ = targetZ - sourceZ;
27
+ float dh = distance * instanceHeights;
28
+ if (dh == 0.0) {
29
+ return sourceZ + deltaZ * ratio;
30
+ }
31
+ float unitZ = deltaZ / dh;
32
+ float p2 = unitZ * unitZ + 1.0;
33
+ float dir = step(deltaZ, 0.0);
34
+ float z0 = mix(sourceZ, targetZ, dir);
35
+ float r = mix(ratio, 1.0 - ratio, dir);
36
+ return sqrt(r * (p2 - r)) * dh + z0;
37
+ }
38
+ vec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction, float width) {
39
+ vec2 dir_screenspace = normalize(line_clipspace * project.viewportSize);
40
+ dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);
41
+ return dir_screenspace * offset_direction * width / 2.0;
42
+ }
43
+ float getSegmentRatio(float index) {
44
+ return smoothstep(0.0, 1.0, index / (arc.numSegments - 1.0));
45
+ }
46
+ vec3 interpolateFlat(vec3 source, vec3 target, float segmentRatio) {
47
+ float distance = length(source.xy - target.xy);
48
+ float z = paraboloid(distance, source.z, target.z, segmentRatio);
49
+ float tiltAngle = radians(instanceTilts);
50
+ vec2 tiltDirection = normalize(target.xy - source.xy);
51
+ vec2 tilt = vec2(-tiltDirection.y, tiltDirection.x) * z * sin(tiltAngle);
52
+ return vec3(
53
+ mix(source.xy, target.xy, segmentRatio) + tilt,
54
+ z * cos(tiltAngle)
55
+ );
56
+ }
57
+ float getAngularDist (vec2 source, vec2 target) {
58
+ vec2 sourceRadians = radians(source);
59
+ vec2 targetRadians = radians(target);
60
+ vec2 sin_half_delta = sin((sourceRadians - targetRadians) / 2.0);
61
+ vec2 shd_sq = sin_half_delta * sin_half_delta;
62
+ float a = shd_sq.y + cos(sourceRadians.y) * cos(targetRadians.y) * shd_sq.x;
63
+ return 2.0 * asin(sqrt(a));
64
+ }
65
+ vec3 interpolateGreatCircle(vec3 source, vec3 target, vec3 source3D, vec3 target3D, float angularDist, float t) {
66
+ vec2 lngLat;
67
+ if(abs(angularDist - PI) < 0.001) {
68
+ lngLat = (1.0 - t) * source.xy + t * target.xy;
69
+ } else {
70
+ float a = sin((1.0 - t) * angularDist);
71
+ float b = sin(t * angularDist);
72
+ vec3 p = source3D.yxz * a + target3D.yxz * b;
73
+ lngLat = degrees(vec2(atan(p.y, -p.x), atan(p.z, length(p.xy))));
74
+ }
75
+ float z = paraboloid(angularDist * EARTH_RADIUS, source.z, target.z, t);
76
+ return vec3(lngLat, z);
77
+ }
78
+ void main(void) {
79
+ geometry.worldPosition = instanceSourcePositions;
80
+ geometry.worldPositionAlt = instanceTargetPositions;
81
+ float segmentIndex = float(gl_VertexID / 2);
82
+ float segmentSide = mod(float(gl_VertexID), 2.) == 0. ? -1. : 1.;
83
+ float segmentRatio = getSegmentRatio(segmentIndex);
84
+ float prevSegmentRatio = getSegmentRatio(max(0.0, segmentIndex - 1.0));
85
+ float nextSegmentRatio = getSegmentRatio(min(arc.numSegments - 1.0, segmentIndex + 1.0));
86
+ float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));
87
+ isValid = 1.0;
88
+ uv = vec2(segmentRatio, segmentSide);
89
+ geometry.uv = uv;
90
+ geometry.pickingColor = instancePickingColors;
91
+ vec4 curr;
92
+ vec4 next;
93
+ vec3 source;
94
+ vec3 target;
95
+ if ((arc.greatCircle || project.projectionMode == PROJECTION_MODE_GLOBE) && project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
96
+ source = project_globe_(vec3(instanceSourcePositions.xy, 0.0));
97
+ target = project_globe_(vec3(instanceTargetPositions.xy, 0.0));
98
+ float angularDist = getAngularDist(instanceSourcePositions.xy, instanceTargetPositions.xy);
99
+ vec3 prevPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, prevSegmentRatio);
100
+ vec3 currPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, segmentRatio);
101
+ vec3 nextPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, nextSegmentRatio);
102
+ if (abs(currPos.x - prevPos.x) > 180.0) {
103
+ indexDir = -1.0;
104
+ isValid = 0.0;
105
+ } else if (abs(currPos.x - nextPos.x) > 180.0) {
106
+ indexDir = 1.0;
107
+ isValid = 0.0;
108
+ }
109
+ nextPos = indexDir < 0.0 ? prevPos : nextPos;
110
+ nextSegmentRatio = indexDir < 0.0 ? prevSegmentRatio : nextSegmentRatio;
111
+ if (isValid == 0.0) {
112
+ nextPos.x += nextPos.x > 0.0 ? -360.0 : 360.0;
113
+ float t = ((currPos.x > 0.0 ? 180.0 : -180.0) - currPos.x) / (nextPos.x - currPos.x);
114
+ currPos = mix(currPos, nextPos, t);
115
+ segmentRatio = mix(segmentRatio, nextSegmentRatio, t);
116
+ }
117
+ vec3 currPos64Low = mix(instanceSourcePositions64Low, instanceTargetPositions64Low, segmentRatio);
118
+ vec3 nextPos64Low = mix(instanceSourcePositions64Low, instanceTargetPositions64Low, nextSegmentRatio);
119
+ curr = project_position_to_clipspace(currPos, currPos64Low, vec3(0.0), geometry.position);
120
+ next = project_position_to_clipspace(nextPos, nextPos64Low, vec3(0.0));
121
+ } else {
122
+ vec3 source_world = instanceSourcePositions;
123
+ vec3 target_world = instanceTargetPositions;
124
+ if (arc.useShortestPath) {
125
+ source_world.x = mod(source_world.x + 180., 360.0) - 180.;
126
+ target_world.x = mod(target_world.x + 180., 360.0) - 180.;
127
+ float deltaLng = target_world.x - source_world.x;
128
+ if (deltaLng > 180.) target_world.x -= 360.;
129
+ if (deltaLng < -180.) source_world.x -= 360.;
130
+ }
131
+ source = project_position(source_world, instanceSourcePositions64Low);
132
+ target = project_position(target_world, instanceTargetPositions64Low);
133
+ float antiMeridianX = 0.0;
134
+ if (arc.useShortestPath) {
135
+ if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {
136
+ antiMeridianX = -(project.coordinateOrigin.x + 180.) / 360. * TILE_SIZE;
137
+ }
138
+ float thresholdRatio = (antiMeridianX - source.x) / (target.x - source.x);
139
+ if (prevSegmentRatio <= thresholdRatio && nextSegmentRatio > thresholdRatio) {
140
+ isValid = 0.0;
141
+ indexDir = sign(segmentRatio - thresholdRatio);
142
+ segmentRatio = thresholdRatio;
143
+ }
144
+ }
145
+ nextSegmentRatio = indexDir < 0.0 ? prevSegmentRatio : nextSegmentRatio;
146
+ vec3 currPos = interpolateFlat(source, target, segmentRatio);
147
+ vec3 nextPos = interpolateFlat(source, target, nextSegmentRatio);
148
+ if (arc.useShortestPath) {
149
+ if (nextPos.x < antiMeridianX) {
150
+ currPos.x += TILE_SIZE;
151
+ nextPos.x += TILE_SIZE;
152
+ }
153
+ }
154
+ curr = project_common_position_to_clipspace(vec4(currPos, 1.0));
155
+ next = project_common_position_to_clipspace(vec4(nextPos, 1.0));
156
+ geometry.position = vec4(currPos, 1.0);
157
+ }
158
+ float widthPixels = clamp(
159
+ project_size_to_pixel(instanceWidths * arc.widthScale, arc.widthUnits),
160
+ arc.widthMinPixels, arc.widthMaxPixels
161
+ );
162
+ vec3 offset = vec3(
163
+ getExtrusionOffset((next.xy - curr.xy) * indexDir, segmentSide, widthPixels),
164
+ 0.0);
165
+ DECKGL_FILTER_SIZE(offset, geometry);
166
+ DECKGL_FILTER_GL_POSITION(curr, geometry);
167
+ gl_Position = curr + vec4(project_pixel_size_to_clipspace(offset.xy), 0.0, 0.0);
168
+ vec4 color = mix(instanceSourceColors, instanceTargetColors, segmentRatio);
169
+ vColor = vec4(color.rgb, color.a * layer.opacity);
170
+ DECKGL_FILTER_COLOR(vColor, geometry);
171
+ }
172
+ `,it=`#version 300 es
173
+ #define SHADER_NAME arc-layer-fragment-shader
174
+ precision highp float;
175
+ in vec4 vColor;
176
+ in vec2 uv;
177
+ in float isValid;
178
+ out vec4 fragColor;
179
+ void main(void) {
180
+ if (isValid == 0.0) {
181
+ discard;
182
+ }
183
+ fragColor = vColor;
184
+ geometry.uv = uv;
185
+ DECKGL_FILTER_COLOR(fragColor, geometry);
186
+ }
187
+ `,H=[0,0,0,255],ot={getSourcePosition:{type:"accessor",value:n=>n.sourcePosition},getTargetPosition:{type:"accessor",value:n=>n.targetPosition},getSourceColor:{type:"accessor",value:H},getTargetColor:{type:"accessor",value:H},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}};class Fe extends E{getBounds(){return this.getAttributeManager()?.getBounds(["instanceSourcePositions","instanceTargetPositions"])}getShaders(){return super.getShaders({vs:tt,fs:it,modules:[z,O,et]})}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:H},instanceTargetColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getTargetColor",defaultValue:H},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(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){const{widthUnits:t,widthScale:i,widthMinPixels:o,widthMaxPixels:s,greatCircle:r,wrapLongitude:a,numSegments:l}=this.props,c={numSegments:l,widthUnits:w[t],widthScale:i,widthMinPixels:o,widthMaxPixels:s,greatCircle:r,useShortestPath:a},d=this.state.model;d.shaderInputs.setProps({arc:c}),d.setVertexCount(l*2),d.draw(this.context.renderPass)}_getModel(){return new F(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),topology:"triangle-strip",isInstanced:!0})}}Fe.layerName="ArcLayer";Fe.defaultProps=ot;const st=new Uint32Array([0,2,1,0,3,2]),nt=new Float32Array([0,1,0,0,1,0,1,1]);function rt(n,e){if(!e)return at(n);const t=Math.max(Math.abs(n[0][0]-n[3][0]),Math.abs(n[1][0]-n[2][0])),i=Math.max(Math.abs(n[1][1]-n[0][1]),Math.abs(n[2][1]-n[3][1])),o=Math.ceil(t/e)+1,s=Math.ceil(i/e)+1,r=(o-1)*(s-1)*6,a=new Uint32Array(r),l=new Float32Array(o*s*2),c=new Float64Array(o*s*3);let d=0,g=0;for(let u=0;u<o;u++){const p=u/(o-1);for(let f=0;f<s;f++){const y=f/(s-1),h=lt(n,p,y);c[d*3+0]=h[0],c[d*3+1]=h[1],c[d*3+2]=h[2]||0,l[d*2+0]=p,l[d*2+1]=1-y,u>0&&f>0&&(a[g++]=d-s,a[g++]=d-s-1,a[g++]=d-1,a[g++]=d-s,a[g++]=d-1,a[g++]=d),d++}}return{vertexCount:r,positions:c,indices:a,texCoords:l}}function at(n){const e=new Float64Array(12);for(let t=0;t<n.length;t++)e[t*3+0]=n[t][0],e[t*3+1]=n[t][1],e[t*3+2]=n[t][2]||0;return{vertexCount:6,positions:e,indices:st,texCoords:nt}}function lt(n,e,t){return X(X(n[0],n[1],t),X(n[3],n[2],t),e)}const ce=`uniform bitmapUniforms {
188
+ vec4 bounds;
189
+ float coordinateConversion;
190
+ float desaturate;
191
+ vec3 tintColor;
192
+ vec4 transparentColor;
193
+ } bitmap;
194
+ `,ct={name:"bitmap",vs:ce,fs:ce,uniformTypes:{bounds:"vec4<f32>",coordinateConversion:"f32",desaturate:"f32",tintColor:"vec3<f32>",transparentColor:"vec4<f32>"}},dt=`#version 300 es
195
+ #define SHADER_NAME bitmap-layer-vertex-shader
196
+
197
+ in vec2 texCoords;
198
+ in vec3 positions;
199
+ in vec3 positions64Low;
200
+
201
+ out vec2 vTexCoord;
202
+ out vec2 vTexPos;
203
+
204
+ const vec3 pickingColor = vec3(1.0, 0.0, 0.0);
205
+
206
+ void main(void) {
207
+ geometry.worldPosition = positions;
208
+ geometry.uv = texCoords;
209
+ geometry.pickingColor = pickingColor;
210
+
211
+ gl_Position = project_position_to_clipspace(positions, positions64Low, vec3(0.0), geometry.position);
212
+ DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
213
+
214
+ vTexCoord = texCoords;
215
+
216
+ if (bitmap.coordinateConversion < -0.5) {
217
+ vTexPos = geometry.position.xy + project.commonOrigin.xy;
218
+ } else if (bitmap.coordinateConversion > 0.5) {
219
+ vTexPos = geometry.worldPosition.xy;
220
+ }
221
+
222
+ vec4 color = vec4(0.0);
223
+ DECKGL_FILTER_COLOR(color, geometry);
224
+ }
225
+ `,gt=`
226
+ vec3 packUVsIntoRGB(vec2 uv) {
227
+ // Extract the top 8 bits. We want values to be truncated down so we can add a fraction
228
+ vec2 uv8bit = floor(uv * 256.);
229
+
230
+ // Calculate the normalized remainders of u and v parts that do not fit into 8 bits
231
+ // Scale and clamp to 0-1 range
232
+ vec2 uvFraction = fract(uv * 256.);
233
+ vec2 uvFraction4bit = floor(uvFraction * 16.);
234
+
235
+ // Remainder can be encoded in blue channel, encode as 4 bits for pixel coordinates
236
+ float fractions = uvFraction4bit.x + uvFraction4bit.y * 16.;
237
+
238
+ return vec3(uv8bit, fractions) / 255.;
239
+ }
240
+ `,ut=`#version 300 es
241
+ #define SHADER_NAME bitmap-layer-fragment-shader
242
+
243
+ #ifdef GL_ES
244
+ precision highp float;
245
+ #endif
246
+
247
+ uniform sampler2D bitmapTexture;
248
+
249
+ in vec2 vTexCoord;
250
+ in vec2 vTexPos;
251
+
252
+ out vec4 fragColor;
253
+
254
+ /* projection utils */
255
+ const float TILE_SIZE = 512.0;
256
+ const float PI = 3.1415926536;
257
+ const float WORLD_SCALE = TILE_SIZE / PI / 2.0;
258
+
259
+ // from degrees to Web Mercator
260
+ vec2 lnglat_to_mercator(vec2 lnglat) {
261
+ float x = lnglat.x;
262
+ float y = clamp(lnglat.y, -89.9, 89.9);
263
+ return vec2(
264
+ radians(x) + PI,
265
+ PI + log(tan(PI * 0.25 + radians(y) * 0.5))
266
+ ) * WORLD_SCALE;
267
+ }
268
+
269
+ // from Web Mercator to degrees
270
+ vec2 mercator_to_lnglat(vec2 xy) {
271
+ xy /= WORLD_SCALE;
272
+ return degrees(vec2(
273
+ xy.x - PI,
274
+ atan(exp(xy.y - PI)) * 2.0 - PI * 0.5
275
+ ));
276
+ }
277
+ /* End projection utils */
278
+
279
+ // apply desaturation
280
+ vec3 color_desaturate(vec3 color) {
281
+ float luminance = (color.r + color.g + color.b) * 0.333333333;
282
+ return mix(color, vec3(luminance), bitmap.desaturate);
283
+ }
284
+
285
+ // apply tint
286
+ vec3 color_tint(vec3 color) {
287
+ return color * bitmap.tintColor;
288
+ }
289
+
290
+ // blend with background color
291
+ vec4 apply_opacity(vec3 color, float alpha) {
292
+ if (bitmap.transparentColor.a == 0.0) {
293
+ return vec4(color, alpha);
294
+ }
295
+ float blendedAlpha = alpha + bitmap.transparentColor.a * (1.0 - alpha);
296
+ float highLightRatio = alpha / blendedAlpha;
297
+ vec3 blendedRGB = mix(bitmap.transparentColor.rgb, color, highLightRatio);
298
+ return vec4(blendedRGB, blendedAlpha);
299
+ }
300
+
301
+ vec2 getUV(vec2 pos) {
302
+ return vec2(
303
+ (pos.x - bitmap.bounds[0]) / (bitmap.bounds[2] - bitmap.bounds[0]),
304
+ (pos.y - bitmap.bounds[3]) / (bitmap.bounds[1] - bitmap.bounds[3])
305
+ );
306
+ }
307
+
308
+ ${gt}
309
+
310
+ void main(void) {
311
+ vec2 uv = vTexCoord;
312
+ if (bitmap.coordinateConversion < -0.5) {
313
+ vec2 lnglat = mercator_to_lnglat(vTexPos);
314
+ uv = getUV(lnglat);
315
+ } else if (bitmap.coordinateConversion > 0.5) {
316
+ vec2 commonPos = lnglat_to_mercator(vTexPos);
317
+ uv = getUV(commonPos);
318
+ }
319
+ vec4 bitmapColor = texture(bitmapTexture, uv);
320
+
321
+ fragColor = apply_opacity(color_tint(color_desaturate(bitmapColor.rgb)), bitmapColor.a * layer.opacity);
322
+
323
+ geometry.uv = uv;
324
+ DECKGL_FILTER_COLOR(fragColor, geometry);
325
+
326
+ if (bool(picking.isActive) && !bool(picking.isAttribute)) {
327
+ // Since instance information is not used, we can use picking color for pixel index
328
+ fragColor.rgb = packUVsIntoRGB(uv);
329
+ }
330
+ }
331
+ `,pt={image:{type:"image",value:null,async:!0},bounds:{type:"array",value:[1,0,0,1],compare:!0},_imageCoordinateSystem:we.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}};class ke extends E{getShaders(){return super.getShaders({vs:dt,fs:ut,modules:[z,O,ct]})}initializeState(){const e=this.getAttributeManager();e.remove(["instancePickingColors"]);const t=!0;e.add({indices:{size:1,isIndexed:!0,update:i=>i.value=this.state.mesh.indices,noAlloc:t},positions:{size:3,type:"float64",fp64:this.use64bitPositions(),update:i=>i.value=this.state.mesh.positions,noAlloc:t},texCoords:{size:2,update:i=>i.value=this.state.mesh.texCoords,noAlloc:t}})}updateState({props:e,oldProps:t,changeFlags:i}){const o=this.getAttributeManager();if(i.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),o.invalidateAll()),e.bounds!==t.bounds){const s=this.state.mesh,r=this._createMesh();this.state.model.setVertexCount(r.vertexCount);for(const a in r)s&&s[a]!==r[a]&&o.invalidate(a);this.setState({mesh:r,...this._getCoordinateUniforms()})}else e._imageCoordinateSystem!==t._imageCoordinateSystem&&this.setState(this._getCoordinateUniforms())}getPickingInfo(e){const{image:t}=this.props,i=e.info;if(!i.color||!t)return i.bitmap=null,i;const{width:o,height:s}=t;i.index=0;const r=ft(i.color);return i.bitmap={size:{width:o,height:s},uv:r,pixel:[Math.floor(r[0]*o),Math.floor(r[1]*s)]},i}disablePickingIndex(){this.setState({disablePicking:!0})}restorePickingColors(){this.setState({disablePicking:!1})}_updateAutoHighlight(e){super._updateAutoHighlight({...e,color:this.encodePickingColor(0)})}_createMesh(){const{bounds:e}=this.props;let t=e;return de(e)&&(t=[[e[0],e[1]],[e[0],e[3]],[e[2],e[3]],[e[2],e[1]]]),rt(t,this.context.viewport.resolution)}_getModel(){return new F(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),topology:"triangle-list",isInstanced:!1})}draw(e){const{shaderModuleProps:t}=e,{model:i,coordinateConversion:o,bounds:s,disablePicking:r}=this.state,{image:a,desaturate:l,transparentColor:c,tintColor:d}=this.props;if(!(t.picking.isActive&&r)&&a&&i){const g={bitmapTexture:a,bounds:s,coordinateConversion:o,desaturate:l,tintColor:d.slice(0,3).map(u=>u/255),transparentColor:c.map(u=>u/255)};i.shaderInputs.setProps({bitmap:g}),i.draw(this.context.renderPass)}}_getCoordinateUniforms(){const{LNGLAT:e,CARTESIAN:t,DEFAULT:i}=we;let{_imageCoordinateSystem:o}=this.props;if(o!==i){const{bounds:s}=this.props;if(!de(s))throw new Error("_imageCoordinateSystem only supports rectangular bounds");const r=this.context.viewport.resolution?e:t;if(o=o===e?e:t,o===e&&r===t)return{coordinateConversion:-1,bounds:s};if(o===t&&r===e){const a=ae([s[0],s[1]]),l=ae([s[2],s[3]]);return{coordinateConversion:1,bounds:[a[0],a[1],l[0],l[1]]}}}return{coordinateConversion:0,bounds:[0,0,0,0]}}}ke.layerName="BitmapLayer";ke.defaultProps=pt;function ft(n){const[e,t,i]=n,o=(i&240)/256,s=(i&15)/16;return[(e+s)/256,(t+o)/256]}function de(n){return Number.isFinite(n[0])}const ge=`uniform iconUniforms {
332
+ float sizeScale;
333
+ vec2 iconsTextureDim;
334
+ float sizeBasis;
335
+ float sizeMinPixels;
336
+ float sizeMaxPixels;
337
+ bool billboard;
338
+ highp int sizeUnits;
339
+ float alphaCutoff;
340
+ } icon;
341
+ `,ht={name:"icon",vs:ge,fs:ge,uniformTypes:{sizeScale:"f32",iconsTextureDim:"vec2<f32>",sizeBasis:"f32",sizeMinPixels:"f32",sizeMaxPixels:"f32",billboard:"f32",sizeUnits:"i32",alphaCutoff:"f32"}},yt=`#version 300 es
342
+ #define SHADER_NAME icon-layer-vertex-shader
343
+ in vec2 positions;
344
+ in vec3 instancePositions;
345
+ in vec3 instancePositions64Low;
346
+ in float instanceSizes;
347
+ in float instanceAngles;
348
+ in vec4 instanceColors;
349
+ in vec3 instancePickingColors;
350
+ in vec4 instanceIconFrames;
351
+ in float instanceColorModes;
352
+ in vec2 instanceOffsets;
353
+ in vec2 instancePixelOffset;
354
+ out float vColorMode;
355
+ out vec4 vColor;
356
+ out vec2 vTextureCoords;
357
+ out vec2 uv;
358
+ vec2 rotate_by_angle(vec2 vertex, float angle) {
359
+ float angle_radian = angle * PI / 180.0;
360
+ float cos_angle = cos(angle_radian);
361
+ float sin_angle = sin(angle_radian);
362
+ mat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle);
363
+ return rotationMatrix * vertex;
364
+ }
365
+ void main(void) {
366
+ geometry.worldPosition = instancePositions;
367
+ geometry.uv = positions;
368
+ geometry.pickingColor = instancePickingColors;
369
+ uv = positions;
370
+ vec2 iconSize = instanceIconFrames.zw;
371
+ float sizePixels = clamp(
372
+ project_size_to_pixel(instanceSizes * icon.sizeScale, icon.sizeUnits),
373
+ icon.sizeMinPixels, icon.sizeMaxPixels
374
+ );
375
+ float iconConstraint = icon.sizeBasis == 0.0 ? iconSize.x : iconSize.y;
376
+ float instanceScale = iconConstraint == 0.0 ? 0.0 : sizePixels / iconConstraint;
377
+ vec2 pixelOffset = positions / 2.0 * iconSize + instanceOffsets;
378
+ pixelOffset = rotate_by_angle(pixelOffset, instanceAngles) * instanceScale;
379
+ pixelOffset += instancePixelOffset;
380
+ pixelOffset.y *= -1.0;
381
+ if (icon.billboard) {
382
+ gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);
383
+ DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
384
+ vec3 offset = vec3(pixelOffset, 0.0);
385
+ DECKGL_FILTER_SIZE(offset, geometry);
386
+ gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);
387
+ } else {
388
+ vec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0);
389
+ DECKGL_FILTER_SIZE(offset_common, geometry);
390
+ gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position);
391
+ DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
392
+ }
393
+ vTextureCoords = mix(
394
+ instanceIconFrames.xy,
395
+ instanceIconFrames.xy + iconSize,
396
+ (positions.xy + 1.0) / 2.0
397
+ ) / icon.iconsTextureDim;
398
+ vColor = instanceColors;
399
+ DECKGL_FILTER_COLOR(vColor, geometry);
400
+ vColorMode = instanceColorModes;
401
+ }
402
+ `,mt=`#version 300 es
403
+ #define SHADER_NAME icon-layer-fragment-shader
404
+ precision highp float;
405
+ uniform sampler2D iconsTexture;
406
+ in float vColorMode;
407
+ in vec4 vColor;
408
+ in vec2 vTextureCoords;
409
+ in vec2 uv;
410
+ out vec4 fragColor;
411
+ void main(void) {
412
+ geometry.uv = uv;
413
+ vec4 texColor = texture(iconsTexture, vTextureCoords);
414
+ vec3 color = mix(texColor.rgb, vColor.rgb, vColorMode);
415
+ float a = texColor.a * layer.opacity * vColor.a;
416
+ if (a < icon.alphaCutoff) {
417
+ discard;
418
+ }
419
+ fragColor = vec4(color, a);
420
+ DECKGL_FILTER_COLOR(fragColor, geometry);
421
+ }
422
+ `,vt=1024,xt=4,ue=()=>{},pe={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},Pt={x:0,y:0,width:0,height:0};function Ct(n){return Math.pow(2,Math.ceil(Math.log2(n)))}function _t(n,e,t,i){const o=Math.min(t/e.width,i/e.height),s=Math.floor(e.width*o),r=Math.floor(e.height*o);return o===1?{image:e,width:s,height:r}:(n.canvas.height=r,n.canvas.width=s,n.clearRect(0,0,s,r),n.drawImage(e,0,0,e.width,e.height,0,0,s,r),{image:n.canvas,width:s,height:r})}function B(n){return n&&(n.id||n.url)}function Lt(n,e,t,i){const{width:o,height:s,device:r}=n,a=r.createTexture({format:"rgba8unorm",width:e,height:t,sampler:i,mipLevels:r.getMipLevelCount(e,t)}),l=r.createCommandEncoder();return l.copyTextureToTexture({sourceTexture:n,destinationTexture:a,width:o,height:s}),l.finish(),a.generateMipmapsWebGL(),n.destroy(),a}function fe(n,e,t){for(let i=0;i<e.length;i++){const{icon:o,xOffset:s}=e[i],r=B(o);n[r]={...o,x:s,y:t}}}function bt({icons:n,buffer:e,mapping:t={},xOffset:i=0,yOffset:o=0,rowHeight:s=0,canvasWidth:r}){let a=[];for(let l=0;l<n.length;l++){const c=n[l],d=B(c);if(!t[d]){const{height:g,width:u}=c;i+u+e>r&&(fe(t,a,o),i=0,o=s+o+e,s=0,a=[]),a.push({icon:c,xOffset:i}),i=i+u+e,s=Math.max(s,g)}}return a.length>0&&fe(t,a,o),{mapping:t,rowHeight:s,xOffset:i,yOffset:o,canvasWidth:r,canvasHeight:Ct(s+o+e)}}function St(n,e,t){if(!n||!e)return null;t=t||{};const i={},{iterable:o,objectInfo:s}=te(n);for(const r of o){s.index++;const a=e(r,s),l=B(a);if(!a)throw new Error("Icon is missing.");if(!a.url)throw new Error("Icon url is missing.");!i[l]&&(!t[l]||a.url!==t[l].url)&&(i[l]={...a,source:r,sourceIndex:s.index})}return i}class Tt{constructor(e,{onUpdate:t=ue,onError:i=ue}){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=xt,this._canvasWidth=vt,this._canvasHeight=0,this._canvas=null,this.device=e,this.onUpdate=t,this.onError=i}finalize(){this._texture?.delete()}getTexture(){return this._texture||this._externalTexture}getIconMapping(e){const t=this._autoPacking?B(e):e;return this._mapping[t]||Pt}setProps({loadOptions:e,autoPacking:t,iconAtlas:i,iconMapping:o,textureParameters:s}){e&&(this._loadOptions=e),t!==void 0&&(this._autoPacking=t),o&&(this._mapping=o),i&&(this._texture?.delete(),this._texture=null,this._externalTexture=i),s&&(this._samplerParameters=s)}get isLoaded(){return this._pendingCount===0}packIcons(e,t){if(!this._autoPacking||typeof document>"u")return;const i=Object.values(St(e,t,this._mapping)||{});if(i.length>0){const{mapping:o,xOffset:s,yOffset:r,rowHeight:a,canvasHeight:l}=bt({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=o,this._xOffset=s,this._yOffset=r,this._canvasHeight=l,this._texture||(this._texture=this.device.createTexture({format:"rgba8unorm",data:null,width:this._canvasWidth,height:this._canvasHeight,sampler:this._samplerParameters||pe,mipLevels:this.device.getMipLevelCount(this._canvasWidth,this._canvasHeight)})),this._texture.height!==this._canvasHeight&&(this._texture=Lt(this._texture,this._canvasWidth,this._canvasHeight,this._samplerParameters||pe)),this.onUpdate(),this._canvas=this._canvas||document.createElement("canvas"),this._loadIcons(i),this._texture?.generateMipmapsWebGL()}}_loadIcons(e){const t=this._canvas.getContext("2d",{willReadFrequently:!0});for(const i of e)this._pendingCount++,Qe(i.url,this._loadOptions).then(o=>{const s=B(i),r=this._mapping[s],{x:a,y:l,width:c,height:d}=r,{image:g,width:u,height:p}=_t(t,o,c,d);this._texture?.copyExternalImage({image:g,x:a+(c-u)/2,y:l+(d-p)/2,width:u,height:p}),r.width=u,r.height=p,this._texture?.generateMipmapsWebGL(),this.onUpdate()}).catch(o=>{this.onError({url:i.url,source:i.source,sourceIndex:i.sourceIndex,loadOptions:this._loadOptions,error:o})}).finally(()=>{this._pendingCount--})}}const We=[0,0,0,255],Rt={iconAtlas:{type:"image",value:null,async:!0},iconMapping:{type:"object",value:{},async:!0},sizeScale:{type:"number",value:1,min:0},billboard:!0,sizeUnits:"pixels",sizeBasis:"height",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:n=>n.position},getIcon:{type:"accessor",value:n=>n.icon},getColor:{type:"accessor",value:We},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}};class Z extends E{getShaders(){return super.getShaders({vs:yt,fs:mt,modules:[z,O,ht]})}initializeState(){this.state={iconManager:new Tt(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:We},instanceAngles:{size:1,transition:!0,accessor:"getAngle"},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset"}})}updateState(e){super.updateState(e);const{props:t,oldProps:i,changeFlags:o}=e,s=this.getAttributeManager(),{iconAtlas:r,iconMapping:a,data:l,getIcon:c,textureParameters:d}=t,{iconManager:g}=this.state;if(typeof r=="string")return;const u=r||this.internalState.isAsyncPropLoading("iconAtlas");g.setProps({loadOptions:t.loadOptions,autoPacking:!u,iconAtlas:r,iconMapping:u?a:null,textureParameters:d}),u?i.iconMapping!==t.iconMapping&&s.invalidate("getIcon"):(o.dataChanged||o.updateTriggersChanged&&(o.updateTriggersChanged.all||o.updateTriggersChanged.getIcon))&&g.packIcons(l,c),o.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),s.invalidateAll())}get isLoaded(){return super.isLoaded&&this.state.iconManager.isLoaded}finalizeState(e){super.finalizeState(e),this.state.iconManager.finalize()}draw({uniforms:e}){const{sizeScale:t,sizeBasis:i,sizeMinPixels:o,sizeMaxPixels:s,sizeUnits:r,billboard:a,alphaCutoff:l}=this.props,{iconManager:c}=this.state,d=c.getTexture();if(d){const g=this.state.model,u={iconsTexture:d,iconsTextureDim:[d.width,d.height],sizeUnits:w[r],sizeScale:t,sizeBasis:i==="height"?1:0,sizeMinPixels:o,sizeMaxPixels:s,billboard:a,alphaCutoff:l};g.shaderInputs.setProps({icon:u}),g.draw(this.context.renderPass)}}_getModel(){const e=[-1,-1,1,-1,-1,1,1,1];return new F(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new K({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array(e)}}}),isInstanced:!0})}_onUpdate(){this.setNeedsRedraw()}_onError(e){const t=this.getCurrentLayer()?.props.onIconError;t?t(e):T.error(e.error.message)()}getInstanceOffset(e){const{width:t,height:i,anchorX:o=t/2,anchorY:s=i/2}=this.state.iconManager.getIconMapping(e);return[t/2-o,i/2-s]}getInstanceColorMode(e){return this.state.iconManager.getIconMapping(e).mask?1:0}getInstanceIconFrame(e){const{x:t,y:i,width:o,height:s}=this.state.iconManager.getIconMapping(e);return[t,i,o,s]}}Z.defaultProps=Rt;Z.layerName="IconLayer";const It=`struct PointCloudUniforms {
423
+ radiusPixels: f32,
424
+ sizeUnits: i32,
425
+ };
426
+
427
+ @group(0) @binding(3)
428
+ var<uniform> pointCloud: PointCloudUniforms;
429
+ `,he=`uniform pointCloudUniforms {
430
+ float radiusPixels;
431
+ highp int sizeUnits;
432
+ } pointCloud;
433
+ `,Mt={name:"pointCloud",source:It,vs:he,fs:he,uniformTypes:{radiusPixels:"f32",sizeUnits:"i32"}},At=`#version 300 es
434
+ #define SHADER_NAME point-cloud-layer-vertex-shader
435
+ in vec3 positions;
436
+ in vec3 instanceNormals;
437
+ in vec4 instanceColors;
438
+ in vec3 instancePositions;
439
+ in vec3 instancePositions64Low;
440
+ in vec3 instancePickingColors;
441
+ out vec4 vColor;
442
+ out vec2 unitPosition;
443
+ void main(void) {
444
+ geometry.worldPosition = instancePositions;
445
+ geometry.normal = project_normal(instanceNormals);
446
+ unitPosition = positions.xy;
447
+ geometry.uv = unitPosition;
448
+ geometry.pickingColor = instancePickingColors;
449
+ vec3 offset = vec3(positions.xy * project_size_to_pixel(pointCloud.radiusPixels, pointCloud.sizeUnits), 0.0);
450
+ DECKGL_FILTER_SIZE(offset, geometry);
451
+ gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.), geometry.position);
452
+ DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
453
+ gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);
454
+ vec3 lightColor = lighting_getLightColor(instanceColors.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);
455
+ vColor = vec4(lightColor, instanceColors.a * layer.opacity);
456
+ DECKGL_FILTER_COLOR(vColor, geometry);
457
+ }
458
+ `,wt=`#version 300 es
459
+ #define SHADER_NAME point-cloud-layer-fragment-shader
460
+ precision highp float;
461
+ in vec4 vColor;
462
+ in vec2 unitPosition;
463
+ out vec4 fragColor;
464
+ void main(void) {
465
+ geometry.uv = unitPosition.xy;
466
+ float distToCenter = length(unitPosition);
467
+ if (distToCenter > 1.0) {
468
+ discard;
469
+ }
470
+ fragColor = vColor;
471
+ DECKGL_FILTER_COLOR(fragColor, geometry);
472
+ }
473
+ `,Et=`struct ConstantAttributes {
474
+ instanceNormals: vec3<f32>,
475
+ instanceColors: vec4<f32>,
476
+ instancePositions: vec3<f32>,
477
+ instancePositions64Low: vec3<f32>,
478
+ instancePickingColors: vec3<f32>
479
+ };
480
+
481
+ const constants = ConstantAttributes(
482
+ vec3<f32>(1.0, 0.0, 0.0),
483
+ vec4<f32>(0.0, 0.0, 0.0, 1.0),
484
+ vec3<f32>(0.0),
485
+ vec3<f32>(0.0),
486
+ vec3<f32>(0.0)
487
+ );
488
+
489
+ struct Attributes {
490
+ @builtin(instance_index) instanceIndex : u32,
491
+ @builtin(vertex_index) vertexIndex : u32,
492
+ @location(0) positions: vec3<f32>,
493
+ @location(1) instancePositions: vec3<f32>,
494
+ @location(2) instancePositions64Low: vec3<f32>,
495
+ @location(3) instanceNormals: vec3<f32>,
496
+ @location(4) instanceColors: vec4<f32>,
497
+ @location(5) instancePickingColors: vec3<f32>
498
+ };
499
+
500
+ struct Varyings {
501
+ @builtin(position) position: vec4<f32>,
502
+ @location(0) vColor: vec4<f32>,
503
+ @location(1) unitPosition: vec2<f32>,
504
+ };
505
+
506
+ @vertex
507
+ fn vertexMain(attributes: Attributes) -> Varyings {
508
+ var varyings: Varyings;
509
+
510
+ // var geometry: Geometry;
511
+ // geometry.worldPosition = instancePositions;
512
+ // geometry.normal = project_normal(instanceNormals);
513
+
514
+ // position on the containing square in [-1, 1] space
515
+ varyings.unitPosition = attributes.positions.xy;
516
+ geometry.uv = varyings.unitPosition;
517
+ geometry.pickingColor = attributes.instancePickingColors;
518
+
519
+ // Find the center of the point and add the current vertex
520
+ let offset = vec3<f32>(attributes.positions.xy * project_unit_size_to_pixel(pointCloud.radiusPixels, pointCloud.sizeUnits), 0.0);
521
+ // DECKGL_FILTER_SIZE(offset, geometry);
522
+
523
+ varyings.position = project_position_to_clipspace(attributes.instancePositions, attributes.instancePositions64Low, vec3<f32>(0.0)); // TODO , geometry.position);
524
+ // DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
525
+ let clipPixels = project_pixel_size_to_clipspace(offset.xy);
526
+ varyings.position.x += clipPixels.x;
527
+ varyings.position.y += clipPixels.y;
528
+
529
+ // Apply lighting
530
+ let lightColor = lighting_getLightColor2(attributes.instanceColors.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal);
531
+
532
+ // Apply opacity to instance color, or return instance picking color
533
+ varyings.vColor = vec4(lightColor, attributes.instanceColors.a * color.opacity);
534
+ // DECKGL_FILTER_COLOR(vColor, geometry);
535
+
536
+ return varyings;
537
+ }
538
+
539
+ @fragment
540
+ fn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {
541
+ // var geometry: Geometry;
542
+ // geometry.uv = unitPosition.xy;
543
+
544
+ let distToCenter = length(varyings.unitPosition);
545
+ if (distToCenter > 1.0) {
546
+ discard;
547
+ }
548
+
549
+ var fragColor: vec4<f32>;
550
+
551
+ fragColor = varyings.vColor;
552
+ // DECKGL_FILTER_COLOR(fragColor, geometry);
553
+
554
+ // Apply premultiplied alpha as required by transparent canvas
555
+ fragColor = deckgl_premultiplied_alpha(fragColor);
556
+
557
+ return fragColor;
558
+ }
559
+ `,De=[0,0,0,255],Be=[0,0,1],zt={sizeUnits:"pixels",pointSize:{type:"number",min:0,value:10},getPosition:{type:"accessor",value:n=>n.position},getNormal:{type:"accessor",value:Be},getColor:{type:"accessor",value:De},material:!0,radiusPixels:{deprecatedFor:"pointSize"}};function Ot(n){const{header:e,attributes:t}=n;if(!(!e||!t)&&(n.length=e.vertexCount,t.POSITION&&(t.instancePositions=t.POSITION),t.NORMAL&&(t.instanceNormals=t.NORMAL),t.COLOR_0)){const{size:i,value:o}=t.COLOR_0;t.instanceColors={size:i,type:"unorm8",value:o}}}class Ue extends E{getShaders(){return super.getShaders({vs:At,fs:wt,source:Et,modules:[z,Ee,Ye,O,Mt]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceNormals:{size:3,transition:!0,accessor:"getNormal",defaultValue:Be},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:De}})}updateState(e){const{changeFlags:t,props:i}=e;super.updateState(e),t.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll()),t.dataChanged&&Ot(i.data)}draw({uniforms:e}){const{pointSize:t,sizeUnits:i}=this.props,o=this.state.model,s={sizeUnits:w[i],radiusPixels:t};o.shaderInputs.setProps({pointCloud:s}),this.context.device.type==="webgpu"&&(o.instanceCount=this.props.data.length),o.draw(this.context.renderPass)}_getModel(){const e=this.context.device.type==="webgpu"?{depthWriteEnabled:!0,depthCompare:"less-equal"}:void 0,t=[];for(let i=0;i<3;i++){const o=i/3*Math.PI*2;t.push(Math.cos(o)*2,Math.sin(o)*2,0)}return new F(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new K({topology:"triangle-list",attributes:{positions:new Float32Array(t)}}),parameters:e,isInstanced:!0})}}Ue.layerName="PointCloudLayer";Ue.defaultProps=zt;const ye=`uniform scatterplotUniforms {
560
+ float radiusScale;
561
+ float radiusMinPixels;
562
+ float radiusMaxPixels;
563
+ float lineWidthScale;
564
+ float lineWidthMinPixels;
565
+ float lineWidthMaxPixels;
566
+ float stroked;
567
+ float filled;
568
+ bool antialiasing;
569
+ bool billboard;
570
+ highp int radiusUnits;
571
+ highp int lineWidthUnits;
572
+ } scatterplot;
573
+ `,Ft={name:"scatterplot",vs:ye,fs:ye,source:"",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"}},kt=`#version 300 es
574
+ #define SHADER_NAME scatterplot-layer-vertex-shader
575
+ in vec3 positions;
576
+ in vec3 instancePositions;
577
+ in vec3 instancePositions64Low;
578
+ in float instanceRadius;
579
+ in float instanceLineWidths;
580
+ in vec4 instanceFillColors;
581
+ in vec4 instanceLineColors;
582
+ in vec3 instancePickingColors;
583
+ out vec4 vFillColor;
584
+ out vec4 vLineColor;
585
+ out vec2 unitPosition;
586
+ out float innerUnitRadius;
587
+ out float outerRadiusPixels;
588
+ void main(void) {
589
+ geometry.worldPosition = instancePositions;
590
+ outerRadiusPixels = clamp(
591
+ project_size_to_pixel(scatterplot.radiusScale * instanceRadius, scatterplot.radiusUnits),
592
+ scatterplot.radiusMinPixels, scatterplot.radiusMaxPixels
593
+ );
594
+ float lineWidthPixels = clamp(
595
+ project_size_to_pixel(scatterplot.lineWidthScale * instanceLineWidths, scatterplot.lineWidthUnits),
596
+ scatterplot.lineWidthMinPixels, scatterplot.lineWidthMaxPixels
597
+ );
598
+ outerRadiusPixels += scatterplot.stroked * lineWidthPixels / 2.0;
599
+ float edgePadding = scatterplot.antialiasing ? (outerRadiusPixels + SMOOTH_EDGE_RADIUS) / outerRadiusPixels : 1.0;
600
+ unitPosition = edgePadding * positions.xy;
601
+ geometry.uv = unitPosition;
602
+ geometry.pickingColor = instancePickingColors;
603
+ innerUnitRadius = 1.0 - scatterplot.stroked * lineWidthPixels / outerRadiusPixels;
604
+ if (scatterplot.billboard) {
605
+ gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);
606
+ DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
607
+ vec3 offset = edgePadding * positions * outerRadiusPixels;
608
+ DECKGL_FILTER_SIZE(offset, geometry);
609
+ gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);
610
+ } else {
611
+ vec3 offset = edgePadding * positions * project_pixel_size(outerRadiusPixels);
612
+ DECKGL_FILTER_SIZE(offset, geometry);
613
+ gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset, geometry.position);
614
+ DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
615
+ }
616
+ vFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * layer.opacity);
617
+ DECKGL_FILTER_COLOR(vFillColor, geometry);
618
+ vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * layer.opacity);
619
+ DECKGL_FILTER_COLOR(vLineColor, geometry);
620
+ }
621
+ `,Wt=`#version 300 es
622
+ #define SHADER_NAME scatterplot-layer-fragment-shader
623
+ precision highp float;
624
+ in vec4 vFillColor;
625
+ in vec4 vLineColor;
626
+ in vec2 unitPosition;
627
+ in float innerUnitRadius;
628
+ in float outerRadiusPixels;
629
+ out vec4 fragColor;
630
+ void main(void) {
631
+ geometry.uv = unitPosition;
632
+ float distToCenter = length(unitPosition) * outerRadiusPixels;
633
+ float inCircle = scatterplot.antialiasing ?
634
+ smoothedge(distToCenter, outerRadiusPixels) :
635
+ step(distToCenter, outerRadiusPixels);
636
+ if (inCircle == 0.0) {
637
+ discard;
638
+ }
639
+ if (scatterplot.stroked > 0.5) {
640
+ float isLine = scatterplot.antialiasing ?
641
+ smoothedge(innerUnitRadius * outerRadiusPixels, distToCenter) :
642
+ step(innerUnitRadius * outerRadiusPixels, distToCenter);
643
+ if (scatterplot.filled > 0.5) {
644
+ fragColor = mix(vFillColor, vLineColor, isLine);
645
+ } else {
646
+ if (isLine == 0.0) {
647
+ discard;
648
+ }
649
+ fragColor = vec4(vLineColor.rgb, vLineColor.a * isLine);
650
+ }
651
+ } else if (scatterplot.filled < 0.5) {
652
+ discard;
653
+ } else {
654
+ fragColor = vFillColor;
655
+ }
656
+ fragColor.a *= inCircle;
657
+ DECKGL_FILTER_COLOR(fragColor, geometry);
658
+ }
659
+ `,Dt=`// Main shaders
660
+
661
+ struct ScatterplotUniforms {
662
+ radiusScale: f32,
663
+ radiusMinPixels: f32,
664
+ radiusMaxPixels: f32,
665
+ lineWidthScale: f32,
666
+ lineWidthMinPixels: f32,
667
+ lineWidthMaxPixels: f32,
668
+ stroked: f32,
669
+ filled: i32,
670
+ antialiasing: i32,
671
+ billboard: i32,
672
+ radiusUnits: i32,
673
+ lineWidthUnits: i32,
674
+ };
675
+
676
+ struct ConstantAttributeUniforms {
677
+ instancePositions: vec3<f32>,
678
+ instancePositions64Low: vec3<f32>,
679
+ instanceRadius: f32,
680
+ instanceLineWidths: f32,
681
+ instanceFillColors: vec4<f32>,
682
+ instanceLineColors: vec4<f32>,
683
+ instancePickingColors: vec3<f32>,
684
+
685
+ instancePositionsConstant: i32,
686
+ instancePositions64LowConstant: i32,
687
+ instanceRadiusConstant: i32,
688
+ instanceLineWidthsConstant: i32,
689
+ instanceFillColorsConstant: i32,
690
+ instanceLineColorsConstant: i32,
691
+ instancePickingColorsConstant: i32
692
+ };
693
+
694
+ @group(0) @binding(2) var<uniform> scatterplot: ScatterplotUniforms;
695
+
696
+ struct ConstantAttributes {
697
+ instancePositions: vec3<f32>,
698
+ instancePositions64Low: vec3<f32>,
699
+ instanceRadius: f32,
700
+ instanceLineWidths: f32,
701
+ instanceFillColors: vec4<f32>,
702
+ instanceLineColors: vec4<f32>,
703
+ instancePickingColors: vec3<f32>
704
+ };
705
+
706
+ const constants = ConstantAttributes(
707
+ vec3<f32>(0.0),
708
+ vec3<f32>(0.0),
709
+ 0.0,
710
+ 0.0,
711
+ vec4<f32>(0.0, 0.0, 0.0, 1.0),
712
+ vec4<f32>(0.0, 0.0, 0.0, 1.0),
713
+ vec3<f32>(0.0)
714
+ );
715
+
716
+ struct Attributes {
717
+ @builtin(instance_index) instanceIndex : u32,
718
+ @builtin(vertex_index) vertexIndex : u32,
719
+ @location(0) positions: vec3<f32>,
720
+ @location(1) instancePositions: vec3<f32>,
721
+ @location(2) instancePositions64Low: vec3<f32>,
722
+ @location(3) instanceRadius: f32,
723
+ @location(4) instanceLineWidths: f32,
724
+ @location(5) instanceFillColors: vec4<f32>,
725
+ @location(6) instanceLineColors: vec4<f32>,
726
+ @location(7) instancePickingColors: vec3<f32>
727
+ };
728
+
729
+ struct Varyings {
730
+ @builtin(position) position: vec4<f32>,
731
+ @location(0) vFillColor: vec4<f32>,
732
+ @location(1) vLineColor: vec4<f32>,
733
+ @location(2) unitPosition: vec2<f32>,
734
+ @location(3) innerUnitRadius: f32,
735
+ @location(4) outerRadiusPixels: f32,
736
+ };
737
+
738
+ @vertex
739
+ fn vertexMain(attributes: Attributes) -> Varyings {
740
+ var varyings: Varyings;
741
+
742
+ // Draw an inline geometry constant array clip space triangle to verify that rendering works.
743
+ // var positions = array<vec2<f32>, 3>(vec2(0.0, 0.5), vec2(-0.5, -0.5), vec2(0.5, -0.5));
744
+ // if (attributes.instanceIndex == 0) {
745
+ // varyings.position = vec4<f32>(positions[attributes.vertexIndex], 0.0, 1.0);
746
+ // return varyings;
747
+ // }
748
+
749
+ // var geometry: Geometry;
750
+ // geometry.worldPosition = instancePositions;
751
+
752
+ // Multiply out radius and clamp to limits
753
+ varyings.outerRadiusPixels = clamp(
754
+ project_unit_size_to_pixel(scatterplot.radiusScale * attributes.instanceRadius, scatterplot.radiusUnits),
755
+ scatterplot.radiusMinPixels, scatterplot.radiusMaxPixels
756
+ );
757
+
758
+ // Multiply out line width and clamp to limits
759
+ let lineWidthPixels = clamp(
760
+ project_unit_size_to_pixel(scatterplot.lineWidthScale * attributes.instanceLineWidths, scatterplot.lineWidthUnits),
761
+ scatterplot.lineWidthMinPixels, scatterplot.lineWidthMaxPixels
762
+ );
763
+
764
+ // outer radius needs to offset by half stroke width
765
+ varyings.outerRadiusPixels += scatterplot.stroked * lineWidthPixels / 2.0;
766
+ // Expand geometry to accommodate edge smoothing
767
+ let edgePadding = select(
768
+ (varyings.outerRadiusPixels + SMOOTH_EDGE_RADIUS) / varyings.outerRadiusPixels,
769
+ 1.0,
770
+ scatterplot.antialiasing != 0
771
+ );
772
+
773
+ // position on the containing square in [-1, 1] space
774
+ varyings.unitPosition = edgePadding * attributes.positions.xy;
775
+ geometry.uv = varyings.unitPosition;
776
+ geometry.pickingColor = attributes.instancePickingColors;
777
+
778
+ varyings.innerUnitRadius = 1.0 - scatterplot.stroked * lineWidthPixels / varyings.outerRadiusPixels;
779
+
780
+ if (scatterplot.billboard != 0) {
781
+ varyings.position = project_position_to_clipspace(attributes.instancePositions, attributes.instancePositions64Low, vec3<f32>(0.0)); // TODO , geometry.position);
782
+ // DECKGL_FILTER_GL_POSITION(varyings.position, geometry);
783
+ let offset = attributes.positions; // * edgePadding * varyings.outerRadiusPixels;
784
+ // DECKGL_FILTER_SIZE(offset, geometry);
785
+ let clipPixels = project_pixel_size_to_clipspace(offset.xy);
786
+ varyings.position.x = clipPixels.x;
787
+ varyings.position.y = clipPixels.y;
788
+ } else {
789
+ let offset = edgePadding * attributes.positions * project_pixel_size_float(varyings.outerRadiusPixels);
790
+ // DECKGL_FILTER_SIZE(offset, geometry);
791
+ varyings.position = project_position_to_clipspace(attributes.instancePositions, attributes.instancePositions64Low, offset); // TODO , geometry.position);
792
+ // DECKGL_FILTER_GL_POSITION(varyings.position, geometry);
793
+ }
794
+
795
+ // Apply opacity to instance color, or return instance picking color
796
+ varyings.vFillColor = vec4<f32>(attributes.instanceFillColors.rgb, attributes.instanceFillColors.a * color.opacity);
797
+ // DECKGL_FILTER_COLOR(varyings.vFillColor, geometry);
798
+ varyings.vLineColor = vec4<f32>(attributes.instanceLineColors.rgb, attributes.instanceLineColors.a * color.opacity);
799
+ // DECKGL_FILTER_COLOR(varyings.vLineColor, geometry);
800
+
801
+ return varyings;
802
+ }
803
+
804
+ @fragment
805
+ fn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {
806
+ // var geometry: Geometry;
807
+ // geometry.uv = unitPosition;
808
+
809
+ let distToCenter = length(varyings.unitPosition) * varyings.outerRadiusPixels;
810
+ let inCircle = select(
811
+ smoothedge(distToCenter, varyings.outerRadiusPixels),
812
+ step(distToCenter, varyings.outerRadiusPixels),
813
+ scatterplot.antialiasing != 0
814
+ );
815
+
816
+ if (inCircle == 0.0) {
817
+ discard;
818
+ }
819
+
820
+ var fragColor: vec4<f32>;
821
+
822
+ if (scatterplot.stroked != 0) {
823
+ let isLine = select(
824
+ smoothedge(varyings.innerUnitRadius * varyings.outerRadiusPixels, distToCenter),
825
+ step(varyings.innerUnitRadius * varyings.outerRadiusPixels, distToCenter),
826
+ scatterplot.antialiasing != 0
827
+ );
828
+
829
+ if (scatterplot.filled != 0) {
830
+ fragColor = mix(varyings.vFillColor, varyings.vLineColor, isLine);
831
+ } else {
832
+ if (isLine == 0.0) {
833
+ discard;
834
+ }
835
+ fragColor = vec4<f32>(varyings.vLineColor.rgb, varyings.vLineColor.a * isLine);
836
+ }
837
+ } else if (scatterplot.filled == 0) {
838
+ discard;
839
+ } else {
840
+ fragColor = varyings.vFillColor;
841
+ }
842
+
843
+ fragColor.a *= inCircle;
844
+ // DECKGL_FILTER_COLOR(fragColor, geometry);
845
+
846
+ // Apply premultiplied alpha as required by transparent canvas
847
+ fragColor = deckgl_premultiplied_alpha(fragColor);
848
+
849
+ return fragColor;
850
+ // return vec4<f32>(0, 0, 1, 1);
851
+ }
852
+ `,me=[0,0,0,255],Bt={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:n=>n.position},getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:me},getLineColor:{type:"accessor",value:me},getLineWidth:{type:"accessor",value:1},strokeWidth:{deprecatedFor:"getLineWidth"},outline:{deprecatedFor:"stroked"},getColor:{deprecatedFor:["getFillColor","getLineColor"]}};class oe extends E{getShaders(){return super.getShaders({vs:kt,fs:Wt,source:Dt,modules:[z,Ee,O,Ft]})}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(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){const{radiusUnits:t,radiusScale:i,radiusMinPixels:o,radiusMaxPixels:s,stroked:r,filled:a,billboard:l,antialiasing:c,lineWidthUnits:d,lineWidthScale:g,lineWidthMinPixels:u,lineWidthMaxPixels:p}=this.props,f={stroked:r,filled:a,billboard:l,antialiasing:c,radiusUnits:w[t],radiusScale:i,radiusMinPixels:o,radiusMaxPixels:s,lineWidthUnits:w[d],lineWidthScale:g,lineWidthMinPixels:u,lineWidthMaxPixels:p},y=this.state.model;y.shaderInputs.setProps({scatterplot:f}),this.context.device.type==="webgpu"&&(y.instanceCount=this.props.data.length),y.draw(this.context.renderPass)}_getModel(){const e=this.context.device.type==="webgpu"?{depthWriteEnabled:!0,depthCompare:"less-equal"}:void 0,t=[-1,-1,0,1,-1,0,-1,1,0,1,1,0];return new F(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new K({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(t)}}}),isInstanced:!0,parameters:e})}}oe.defaultProps=Bt;oe.layerName="ScatterplotLayer";function Ge({data:n,getIndex:e,dataRange:t,replace:i}){const{startRow:o=0,endRow:s=1/0}=t,r=n.length;let a=r,l=r;for(let u=0;u<r;u++){const p=e(n[u]);if(a>u&&p>=o&&(a=u),p>=s){l=u;break}}let c=a;const g=l-a!==i.length?n.slice(l):void 0;for(let u=0;u<i.length;u++)n[c++]=i[u];if(g){for(let u=0;u<g.length;u++)n[c++]=g[u];n.length=c}return{startRow:a,endRow:a+i.length}}const Ne=[0,0,0,255],Ut=[0,0,0,255],Gt={stroked:!0,filled:!0,extruded:!1,elevationScale:1,wireframe:!1,_normalize:!0,_windingOrder:"CW",lineWidthUnits:"meters",lineWidthScale:1,lineWidthMinPixels:0,lineWidthMaxPixels:Number.MAX_SAFE_INTEGER,lineJointRounded:!1,lineMiterLimit:4,getPolygon:{type:"accessor",value:n=>n.polygon},getFillColor:{type:"accessor",value:Ut},getLineColor:{type:"accessor",value:Ne},getLineWidth:{type:"accessor",value:1},getElevation:{type:"accessor",value:1e3},material:!0};class je extends ie{initializeState(){this.state={paths:[],pathsDiff:null},this.props.getLineDashArray&&T.removed("getLineDashArray","PathStyleExtension")()}updateState({changeFlags:e}){const t=e.dataChanged||e.updateTriggersChanged&&(e.updateTriggersChanged.all||e.updateTriggersChanged.getPolygon);if(t&&Array.isArray(e.dataChanged)){const i=this.state.paths.slice(),o=e.dataChanged.map(s=>Ge({data:i,getIndex:r=>r.__source.index,dataRange:s,replace:this._getPaths(s)}));this.setState({paths:i,pathsDiff:o})}else t&&this.setState({paths:this._getPaths(),pathsDiff:null})}_getPaths(e={}){const{data:t,getPolygon:i,positionFormat:o,_normalize:s}=this.props,r=[],a=o==="XY"?2:3,{startRow:l,endRow:c}=e,{iterable:d,objectInfo:g}=te(t,l,c);for(const u of d){g.index++;let p=i(u,g);s&&(p=Je(p,a));const{holeIndices:f}=p,y=p.positions||p;if(f)for(let h=0;h<=f.length;h++){const m=y.slice(f[h-1]||0,f[h]||y.length);r.push(this.getSubLayerRow({path:m},u,g.index))}else r.push(this.getSubLayerRow({path:y},u,g.index))}return r}renderLayers(){const{data:e,_dataDiff:t,stroked:i,filled:o,extruded:s,wireframe:r,_normalize:a,_windingOrder:l,elevationScale:c,transitions:d,positionFormat:g}=this.props,{lineWidthUnits:u,lineWidthScale:p,lineWidthMinPixels:f,lineWidthMaxPixels:y,lineJointRounded:h,lineMiterLimit:m,lineDashJustified:L}=this.props,{getFillColor:C,getLineColor:S,getLineWidth:x,getLineDashArray:v,getElevation:I,getPolygon:R,updateTriggers:_,material:U}=this.props,{paths:M,pathsDiff:k}=this.state,b=this.getSubLayerClass("fill",ze),P=this.getSubLayerClass("stroke",Oe),G=this.shouldRenderSubLayer("fill",M)&&new b({_dataDiff:t,extruded:s,elevationScale:c,filled:o,wireframe:r,_normalize:a,_windingOrder:l,getElevation:I,getFillColor:C,getLineColor:s&&r?S:Ne,material:U,transitions:d},this.getSubLayerProps({id:"fill",updateTriggers:_&&{getPolygon:_.getPolygon,getElevation:_.getElevation,getFillColor:_.getFillColor,lineColors:s&&r,getLineColor:_.getLineColor}}),{data:e,positionFormat:g,getPolygon:R}),q=!s&&i&&this.shouldRenderSubLayer("stroke",M)&&new P({_dataDiff:k&&(()=>k),widthUnits:u,widthScale:p,widthMinPixels:f,widthMaxPixels:y,jointRounded:h,miterLimit:m,dashJustified:L,_pathType:"loop",transitions:d&&{getWidth:d.getLineWidth,getColor:d.getLineColor,getPath:d.getPolygon},getColor:this.getSubLayerAccessor(S),getWidth:this.getSubLayerAccessor(x),getDashArray:this.getSubLayerAccessor(v)},this.getSubLayerProps({id:"stroke",updateTriggers:_&&{getWidth:_.getLineWidth,getColor:_.getLineColor,getDashArray:_.getLineDashArray}}),{data:M,positionFormat:g,getPath:Xe=>Xe.path});return[!s&&G,q,s&&G]}}je.layerName="PolygonLayer";je.defaultProps=Gt;function Nt(n,e){if(!n)return null;const t="startIndices"in n?n.startIndices[e]:e,i=n.featureIds.value[t];return t!==-1?jt(n,i,t):null}function jt(n,e,t){const i={properties:{...n.properties[e]}};for(const o in n.numericProps)i.properties[o]=n.numericProps[o].value[t];return i}function $t(n,e){const t={points:null,lines:null,polygons:null};for(const i in t){const o=n[i].globalFeatureIds.value;t[i]=new Uint8ClampedArray(o.length*4);const s=[];for(let r=0;r<o.length;r++)e(o[r],s),t[i][r*4+0]=s[0],t[i][r*4+1]=s[1],t[i][r*4+2]=s[2],t[i][r*4+3]=255}return t}const ve=`uniform sdfUniforms {
853
+ float gamma;
854
+ bool enabled;
855
+ float buffer;
856
+ float outlineBuffer;
857
+ vec4 outlineColor;
858
+ } sdf;
859
+ `,Ht={name:"sdf",vs:ve,fs:ve,uniformTypes:{gamma:"f32",enabled:"f32",buffer:"f32",outlineBuffer:"f32",outlineColor:"vec4<f32>"}},Vt=`#version 300 es
860
+ #define SHADER_NAME multi-icon-layer-fragment-shader
861
+ precision highp float;
862
+ uniform sampler2D iconsTexture;
863
+ in vec4 vColor;
864
+ in vec2 vTextureCoords;
865
+ in vec2 uv;
866
+ out vec4 fragColor;
867
+ void main(void) {
868
+ geometry.uv = uv;
869
+ if (!bool(picking.isActive)) {
870
+ float alpha = texture(iconsTexture, vTextureCoords).a;
871
+ vec4 color = vColor;
872
+ if (sdf.enabled) {
873
+ float distance = alpha;
874
+ alpha = smoothstep(sdf.buffer - sdf.gamma, sdf.buffer + sdf.gamma, distance);
875
+ if (sdf.outlineBuffer > 0.0) {
876
+ float inFill = alpha;
877
+ float inBorder = smoothstep(sdf.outlineBuffer - sdf.gamma, sdf.outlineBuffer + sdf.gamma, distance);
878
+ color = mix(sdf.outlineColor, vColor, inFill);
879
+ alpha = inBorder;
880
+ }
881
+ }
882
+ float a = alpha * color.a;
883
+ if (a < icon.alphaCutoff) {
884
+ discard;
885
+ }
886
+ fragColor = vec4(color.rgb, a * layer.opacity);
887
+ }
888
+ DECKGL_FILTER_COLOR(fragColor, geometry);
889
+ }
890
+ `,Y=192/256,xe=[],Kt={getIconOffsets:{type:"accessor",value:n=>n.offsets},alphaCutoff:.001,smoothing:.1,outlineWidth:0,outlineColor:{type:"color",value:[0,0,0,255]}};class se extends Z{getShaders(){const e=super.getShaders();return{...e,modules:[...e.modules,Ht],fs:Vt}}initializeState(){super.initializeState(),this.getAttributeManager().addInstanced({instanceOffsets:{size:2,accessor:"getIconOffsets"},instancePickingColors:{type:"uint8",size:3,accessor:(t,{index:i,target:o})=>this.encodePickingColor(i,o)}})}updateState(e){super.updateState(e);const{props:t,oldProps:i}=e;let{outlineColor:o}=t;o!==i.outlineColor&&(o=o.map(s=>s/255),o[3]=Number.isFinite(o[3])?o[3]:1,this.setState({outlineColor:o})),!t.sdf&&t.outlineWidth&&T.warn(`${this.id}: fontSettings.sdf is required to render outline`)()}draw(e){const{sdf:t,smoothing:i,outlineWidth:o}=this.props,{outlineColor:s}=this.state,r=o?Math.max(i,Y*(1-o)):-1,a=this.state.model,l={buffer:Y,outlineBuffer:r,gamma:i,enabled:!!t,outlineColor:s};if(a.shaderInputs.setProps({sdf:l}),super.draw(e),t&&o){const{iconManager:c}=this.state;c.getTexture()&&(a.shaderInputs.setProps({sdf:{...l,outlineBuffer:Y}}),a.draw(this.context.renderPass))}}getInstanceOffset(e){return e?Array.from(e).flatMap(t=>super.getInstanceOffset(t)):xe}getInstanceColorMode(e){return 1}getInstanceIconFrame(e){return e?Array.from(e).flatMap(t=>super.getInstanceIconFrame(t)):xe}}se.defaultProps=Kt;se.layerName="MultiIconLayer";const D=1e20;class Zt{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:o=.25,fontFamily:s="sans-serif",fontWeight:r="normal",fontStyle:a="normal",lang:l=null}={}){this.buffer=t,this.cutoff=o,this.radius=i,this.lang=l;const c=this.size=e+t*4,d=this._createCanvas(c),g=this.ctx=d.getContext("2d",{willReadFrequently:!0});g.font=`${a} ${r} ${e}px ${s}`,g.textBaseline="alphabetic",g.textAlign="left",g.fillStyle="black",this.gridOuter=new Float64Array(c*c),this.gridInner=new Float64Array(c*c),this.f=new Float64Array(c),this.z=new Float64Array(c+1),this.v=new Uint16Array(c)}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:o,actualBoundingBoxLeft:s,actualBoundingBoxRight:r}=this.ctx.measureText(e),a=Math.ceil(i),l=0,c=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(r-s))),d=Math.min(this.size-this.buffer,a+Math.ceil(o)),g=c+2*this.buffer,u=d+2*this.buffer,p=Math.max(g*u,0),f=new Uint8ClampedArray(p),y={data:f,width:g,height:u,glyphWidth:c,glyphHeight:d,glyphTop:a,glyphLeft:l,glyphAdvance:t};if(c===0||d===0)return y;const{ctx:h,buffer:m,gridInner:L,gridOuter:C}=this;this.lang&&(h.lang=this.lang),h.clearRect(m,m,c,d),h.fillText(e,m,m+a);const S=h.getImageData(m,m,c,d);C.fill(D,0,p),L.fill(0,0,p);for(let x=0;x<d;x++)for(let v=0;v<c;v++){const I=S.data[4*(x*c+v)+3]/255;if(I===0)continue;const R=(x+m)*g+v+m;if(I===1)C[R]=0,L[R]=D;else{const _=.5-I;C[R]=_>0?_*_:0,L[R]=_<0?_*_:0}}Pe(C,0,0,g,u,g,this.f,this.v,this.z),Pe(L,m,m,c,d,g,this.f,this.v,this.z);for(let x=0;x<p;x++){const v=Math.sqrt(C[x])-Math.sqrt(L[x]);f[x]=Math.round(255-255*(v/this.radius+this.cutoff))}return y}}function Pe(n,e,t,i,o,s,r,a,l){for(let c=e;c<e+i;c++)Ce(n,t*s+c,s,o,r,a,l);for(let c=t;c<t+o;c++)Ce(n,c*s+e,1,i,r,a,l)}function Ce(n,e,t,i,o,s,r){s[0]=0,r[0]=-D,r[1]=D,o[0]=n[e];for(let a=1,l=0,c=0;a<i;a++){o[a]=n[e+a*t];const d=a*a;do{const g=s[l];c=(o[a]-o[g]+d-g*g)/(a-g)/2}while(c<=r[l]&&--l>-1);l++,s[l]=a,r[l]=c,r[l+1]=D}for(let a=0,l=0;a<i;a++){for(;r[l+1]<a;)l++;const c=s[l],d=a-c;n[e+a*t]=o[c]+d*d}}const qt=32,Xt=[];function Yt(n){return Math.pow(2,Math.ceil(Math.log2(n)))}function Jt({characterSet:n,getFontWidth:e,fontHeight:t,buffer:i,maxCanvasWidth:o,mapping:s={},xOffset:r=0,yOffset:a=0}){let l=0,c=r;const d=t+i*2;for(const g of n)if(!s[g]){const u=e(g);c+u+i*2>o&&(c=0,l++),s[g]={x:c+i,y:a+l*d+i,width:u,height:d,layoutWidth:u,layoutHeight:t},c+=u+i*2}return{mapping:s,xOffset:c,yOffset:a+l*d,canvasHeight:Yt(a+(l+1)*d)}}function $e(n,e,t,i){let o=0;for(let s=e;s<t;s++){const r=n[s];o+=i[r]?.layoutWidth||0}return o}function He(n,e,t,i,o,s){let r=e,a=0;for(let l=e;l<t;l++){const c=$e(n,l,l+1,o);a+c>i&&(r<l&&s.push(l),r=l,a=0),a+=c}return a}function Qt(n,e,t,i,o,s){let r=e,a=e,l=e,c=0;for(let d=e;d<t;d++)if((n[d]===" "||n[d+1]===" "||d+1===t)&&(l=d+1),l>a){let g=$e(n,a,l,o);c+g>i&&(r<a&&(s.push(a),r=a,c=0),g>i&&(g=He(n,a,l,i,o,s),r=s[s.length-1])),a=l,c+=g}return c}function ei(n,e,t,i,o=0,s){s===void 0&&(s=n.length);const r=[];return e==="break-all"?He(n,o,s,t,i,r):Qt(n,o,s,t,i,r),r}function ti(n,e,t,i,o,s){let r=0,a=0;for(let l=e;l<t;l++){const c=n[l],d=i[c];d?(a||(a=d.layoutHeight),o[l]=r+d.layoutWidth/2,r+=d.layoutWidth):(T.warn(`Missing character: ${c} (${c.codePointAt(0)})`)(),o[l]=r,r+=qt)}s[0]=r,s[1]=a}function ii(n,e,t,i,o){const s=Array.from(n),r=s.length,a=new Array(r),l=new Array(r),c=new Array(r),d=(t==="break-word"||t==="break-all")&&isFinite(i)&&i>0,g=[0,0],u=[0,0];let p=0,f=0,y=0;for(let h=0;h<=r;h++){const m=s[h];if((m===`
891
+ `||h===r)&&(y=h),y>f){const L=d?ei(s,t,i,o,f,y):Xt;for(let C=0;C<=L.length;C++){const S=C===0?f:L[C-1],x=C<L.length?L[C]:y;ti(s,S,x,o,a,u);for(let v=S;v<x;v++){const I=s[v],R=o[I]?.layoutOffsetY||0;l[v]=p+u[1]/2+R,c[v]=u[0]}p=p+u[1]*e,g[0]=Math.max(g[0],u[0])}f=y}m===`
892
+ `&&(a[f]=0,l[f]=0,c[f]=0,f++)}return g[1]=p,{x:a,y:l,rowWidth:c,size:g}}function oi({value:n,length:e,stride:t,offset:i,startIndices:o,characterSet:s}){const r=n.BYTES_PER_ELEMENT,a=t?t/r:1,l=i?i/r:0,c=o[e]||Math.ceil((n.length-l)/a),d=s&&new Set,g=new Array(e);let u=n;if(a>1||l>0){const p=n.constructor;u=new p(c);for(let f=0;f<c;f++)u[f]=n[f*a+l]}for(let p=0;p<e;p++){const f=o[p],y=o[p+1]||c,h=u.subarray(f,y);g[p]=String.fromCodePoint.apply(null,h),d&&h.forEach(d.add,d)}if(d)for(const p of d)s.add(String.fromCodePoint(p));return{texts:g,characterCount:c}}class Ve{constructor(e=5){this._cache={},this._order=[],this.limit=e}get(e){const t=this._cache[e];return t&&(this._deleteOrder(e),this._appendOrder(e)),t}set(e,t){this._cache[e]?(this.delete(e),this._cache[e]=t,this._appendOrder(e)):(Object.keys(this._cache).length===this.limit&&this.delete(this._order[0]),this._cache[e]=t,this._appendOrder(e))}delete(e){this._cache[e]&&(delete this._cache[e],this._deleteOrder(e))}_deleteOrder(e){const t=this._order.indexOf(e);t>=0&&this._order.splice(t,1)}_appendOrder(e){this._order.push(e)}}function si(){const n=[];for(let e=32;e<128;e++)n.push(String.fromCharCode(e));return n}const A={fontFamily:"Monaco, monospace",fontWeight:"normal",characterSet:si(),fontSize:64,buffer:4,sdf:!1,cutoff:.25,radius:12,smoothing:.1},_e=1024,Le=.9,be=1.2,Ke=3;let V=new Ve(Ke);function ni(n,e){let t;typeof e=="string"?t=new Set(Array.from(e)):t=new Set(e);const i=V.get(n);if(!i)return t;for(const o in i.mapping)t.has(o)&&t.delete(o);return t}function ri(n,e){for(let t=0;t<n.length;t++)e.data[4*t+3]=n[t]}function Se(n,e,t,i){n.font=`${i} ${t}px ${e}`,n.fillStyle="#000",n.textBaseline="alphabetic",n.textAlign="left"}function ai(n){T.assert(Number.isFinite(n)&&n>=Ke,"Invalid cache limit"),V=new Ve(n)}class li{constructor(){this.props={...A}}get atlas(){return this._atlas}get mapping(){return this._atlas&&this._atlas.mapping}get scale(){const{fontSize:e,buffer:t}=this.props;return(e*be+t*2)/e}setProps(e={}){Object.assign(this.props,e),this._key=this._getKey();const t=ni(this._key,this.props.characterSet),i=V.get(this._key);if(i&&t.size===0){this._atlas!==i&&(this._atlas=i);return}const o=this._generateFontAtlas(t,i);this._atlas=o,V.set(this._key,o)}_generateFontAtlas(e,t){const{fontFamily:i,fontWeight:o,fontSize:s,buffer:r,sdf:a,radius:l,cutoff:c}=this.props;let d=t&&t.data;d||(d=document.createElement("canvas"),d.width=_e);const g=d.getContext("2d",{willReadFrequently:!0});Se(g,i,s,o);const{mapping:u,canvasHeight:p,xOffset:f,yOffset:y}=Jt({getFontWidth:h=>g.measureText(h).width,fontHeight:s*be,buffer:r,characterSet:e,maxCanvasWidth:_e,...t&&{mapping:t.mapping,xOffset:t.xOffset,yOffset:t.yOffset}});if(d.height!==p){const h=g.getImageData(0,0,d.width,d.height);d.height=p,g.putImageData(h,0,0)}if(Se(g,i,s,o),a){const h=new Zt({fontSize:s,buffer:r,radius:l,cutoff:c,fontFamily:i,fontWeight:`${o}`});for(const m of e){const{data:L,width:C,height:S,glyphTop:x}=h.draw(m);u[m].width=C,u[m].layoutOffsetY=s*Le-x;const v=g.createImageData(C,S);ri(L,v),g.putImageData(v,u[m].x,u[m].y)}}else for(const h of e)g.fillText(h,u[h].x,u[h].y+r+s*Le);return{xOffset:f,yOffset:y,mapping:u,data:d,width:d.width,height:d.height}}_getKey(){const{fontFamily:e,fontWeight:t,fontSize:i,buffer:o,sdf:s,radius:r,cutoff:a}=this.props;return s?`${e} ${t} ${i} ${o} ${r} ${a}`:`${e} ${t} ${i} ${o}`}}const Te=`uniform textBackgroundUniforms {
893
+ bool billboard;
894
+ float sizeScale;
895
+ float sizeMinPixels;
896
+ float sizeMaxPixels;
897
+ vec4 borderRadius;
898
+ vec4 padding;
899
+ highp int sizeUnits;
900
+ bool stroked;
901
+ } textBackground;
902
+ `,ci={name:"textBackground",vs:Te,fs:Te,uniformTypes:{billboard:"f32",sizeScale:"f32",sizeMinPixels:"f32",sizeMaxPixels:"f32",borderRadius:"vec4<f32>",padding:"vec4<f32>",sizeUnits:"i32",stroked:"f32"}},di=`#version 300 es
903
+ #define SHADER_NAME text-background-layer-vertex-shader
904
+ in vec2 positions;
905
+ in vec3 instancePositions;
906
+ in vec3 instancePositions64Low;
907
+ in vec4 instanceRects;
908
+ in float instanceSizes;
909
+ in float instanceAngles;
910
+ in vec2 instancePixelOffsets;
911
+ in float instanceLineWidths;
912
+ in vec4 instanceFillColors;
913
+ in vec4 instanceLineColors;
914
+ in vec3 instancePickingColors;
915
+ out vec4 vFillColor;
916
+ out vec4 vLineColor;
917
+ out float vLineWidth;
918
+ out vec2 uv;
919
+ out vec2 dimensions;
920
+ vec2 rotate_by_angle(vec2 vertex, float angle) {
921
+ float angle_radian = radians(angle);
922
+ float cos_angle = cos(angle_radian);
923
+ float sin_angle = sin(angle_radian);
924
+ mat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle);
925
+ return rotationMatrix * vertex;
926
+ }
927
+ void main(void) {
928
+ geometry.worldPosition = instancePositions;
929
+ geometry.uv = positions;
930
+ geometry.pickingColor = instancePickingColors;
931
+ uv = positions;
932
+ vLineWidth = instanceLineWidths;
933
+ float sizePixels = clamp(
934
+ project_size_to_pixel(instanceSizes * textBackground.sizeScale, textBackground.sizeUnits),
935
+ textBackground.sizeMinPixels, textBackground.sizeMaxPixels
936
+ );
937
+ dimensions = instanceRects.zw * sizePixels + textBackground.padding.xy + textBackground.padding.zw;
938
+ vec2 pixelOffset = (positions * instanceRects.zw + instanceRects.xy) * sizePixels + mix(-textBackground.padding.xy, textBackground.padding.zw, positions);
939
+ pixelOffset = rotate_by_angle(pixelOffset, instanceAngles);
940
+ pixelOffset += instancePixelOffsets;
941
+ pixelOffset.y *= -1.0;
942
+ if (textBackground.billboard) {
943
+ gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);
944
+ DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
945
+ vec3 offset = vec3(pixelOffset, 0.0);
946
+ DECKGL_FILTER_SIZE(offset, geometry);
947
+ gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);
948
+ } else {
949
+ vec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0);
950
+ DECKGL_FILTER_SIZE(offset_common, geometry);
951
+ gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position);
952
+ DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
953
+ }
954
+ vFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * layer.opacity);
955
+ DECKGL_FILTER_COLOR(vFillColor, geometry);
956
+ vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * layer.opacity);
957
+ DECKGL_FILTER_COLOR(vLineColor, geometry);
958
+ }
959
+ `,gi=`#version 300 es
960
+ #define SHADER_NAME text-background-layer-fragment-shader
961
+ precision highp float;
962
+ in vec4 vFillColor;
963
+ in vec4 vLineColor;
964
+ in float vLineWidth;
965
+ in vec2 uv;
966
+ in vec2 dimensions;
967
+ out vec4 fragColor;
968
+ float round_rect(vec2 p, vec2 size, vec4 radii) {
969
+ vec2 pixelPositionCB = (p - 0.5) * size;
970
+ vec2 sizeCB = size * 0.5;
971
+ float maxBorderRadius = min(size.x, size.y) * 0.5;
972
+ vec4 borderRadius = vec4(min(radii, maxBorderRadius));
973
+ borderRadius.xy =
974
+ (pixelPositionCB.x > 0.0) ? borderRadius.xy : borderRadius.zw;
975
+ borderRadius.x = (pixelPositionCB.y > 0.0) ? borderRadius.x : borderRadius.y;
976
+ vec2 q = abs(pixelPositionCB) - sizeCB + borderRadius.x;
977
+ return -(min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - borderRadius.x);
978
+ }
979
+ float rect(vec2 p, vec2 size) {
980
+ vec2 pixelPosition = p * size;
981
+ return min(min(pixelPosition.x, size.x - pixelPosition.x),
982
+ min(pixelPosition.y, size.y - pixelPosition.y));
983
+ }
984
+ vec4 get_stroked_fragColor(float dist) {
985
+ float isBorder = smoothedge(dist, vLineWidth);
986
+ return mix(vFillColor, vLineColor, isBorder);
987
+ }
988
+ void main(void) {
989
+ geometry.uv = uv;
990
+ if (textBackground.borderRadius != vec4(0.0)) {
991
+ float distToEdge = round_rect(uv, dimensions, textBackground.borderRadius);
992
+ if (textBackground.stroked) {
993
+ fragColor = get_stroked_fragColor(distToEdge);
994
+ } else {
995
+ fragColor = vFillColor;
996
+ }
997
+ float shapeAlpha = smoothedge(-distToEdge, 0.0);
998
+ fragColor.a *= shapeAlpha;
999
+ } else {
1000
+ if (textBackground.stroked) {
1001
+ float distToEdge = rect(uv, dimensions);
1002
+ fragColor = get_stroked_fragColor(distToEdge);
1003
+ } else {
1004
+ fragColor = vFillColor;
1005
+ }
1006
+ }
1007
+ DECKGL_FILTER_COLOR(fragColor, geometry);
1008
+ }
1009
+ `,ui={billboard:!0,sizeScale:1,sizeUnits:"pixels",sizeMinPixels:0,sizeMaxPixels:Number.MAX_SAFE_INTEGER,borderRadius:{type:"object",value:0},padding:{type:"array",value:[0,0,0,0]},getPosition:{type:"accessor",value:n=>n.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}};class ne extends E{getShaders(){return super.getShaders({vs:di,fs:gi,modules:[z,O,ci]})}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(e){super.updateState(e);const{changeFlags:t}=e;t.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){const{billboard:t,sizeScale:i,sizeUnits:o,sizeMinPixels:s,sizeMaxPixels:r,getLineWidth:a}=this.props;let{padding:l,borderRadius:c}=this.props;l.length<4&&(l=[l[0],l[1],l[0],l[1]]),Array.isArray(c)||(c=[c,c,c,c]);const d=this.state.model,g={billboard:t,stroked:!!a,borderRadius:c,padding:l,sizeUnits:w[o],sizeScale:i,sizeMinPixels:s,sizeMaxPixels:r};d.shaderInputs.setProps({textBackground:g}),d.draw(this.context.renderPass)}_getModel(){const e=[0,0,1,0,0,1,1,1];return new F(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new K({topology:"triangle-strip",vertexCount:4,attributes:{positions:{size:2,value:new Float32Array(e)}}}),isInstanced:!0})}}ne.defaultProps=ui;ne.layerName="TextBackgroundLayer";const Re={start:1,middle:0,end:-1},Ie={top:1,center:0,bottom:-1},J=[0,0,0,255],pi=1,fi={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:J},getBorderWidth:{type:"accessor",value:0},backgroundBorderRadius:{type:"object",value:0},backgroundPadding:{type:"array",value:[0,0,0,0]},characterSet:{type:"object",value:A.characterSet},fontFamily:A.fontFamily,fontWeight:A.fontWeight,lineHeight:pi,outlineWidth:{type:"number",value:0,min:0},outlineColor:{type:"color",value:J},fontSettings:{type:"object",value:{},compare:1},wordBreak:"break-word",maxWidth:{type:"number",value:-1},getText:{type:"accessor",value:n=>n.text},getPosition:{type:"accessor",value:n=>n.position},getColor:{type:"accessor",value:J},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"]}};class re extends ie{constructor(){super(...arguments),this.getBoundingRect=(e,t)=>{let{size:[i,o]}=this.transformParagraph(e,t);const{fontSize:s}=this.state.fontAtlasManager.props;i/=s,o/=s;const{getTextAnchor:r,getAlignmentBaseline:a}=this.props,l=Re[typeof r=="function"?r(e,t):r],c=Ie[typeof a=="function"?a(e,t):a];return[(l-1)*i/2,(c-1)*o/2,i,o]},this.getIconOffsets=(e,t)=>{const{getTextAnchor:i,getAlignmentBaseline:o}=this.props,{x:s,y:r,rowWidth:a,size:[l,c]}=this.transformParagraph(e,t),d=Re[typeof i=="function"?i(e,t):i],g=Ie[typeof o=="function"?o(e,t):o],u=s.length,p=new Array(u*2);let f=0;for(let y=0;y<u;y++){const h=(1-d)*(l-a[y])/2;p[f++]=(d-1)*l/2+h+s[y],p[f++]=(g-1)*c/2+r[y]}return p}}initializeState(){this.state={styleVersion:0,fontAtlasManager:new li},this.props.maxWidth>0&&T.once(1,"v8.9 breaking change: TextLayer maxWidth is now relative to text size")()}updateState(e){const{props:t,oldProps:i,changeFlags:o}=e;(o.dataChanged||o.updateTriggersChanged&&(o.updateTriggersChanged.all||o.updateTriggersChanged.getText))&&this._updateText(),(this._updateFontAtlas()||t.lineHeight!==i.lineHeight||t.wordBreak!==i.wordBreak||t.maxWidth!==i.maxWidth)&&this.setState({styleVersion:this.state.styleVersion+1})}getPickingInfo({info:e}){return e.object=e.index>=0?this.props.data[e.index]:null,e}_updateFontAtlas(){const{fontSettings:e,fontFamily:t,fontWeight:i}=this.props,{fontAtlasManager:o,characterSet:s}=this.state,r={...e,characterSet:s,fontFamily:t,fontWeight:i};if(!o.mapping)return o.setProps(r),!0;for(const a in r)if(r[a]!==o.props[a])return o.setProps(r),!0;return!1}_updateText(){const{data:e,characterSet:t}=this.props,i=e.attributes?.getText;let{getText:o}=this.props,s=e.startIndices,r;const a=t==="auto"&&new Set;if(i&&s){const{texts:l,characterCount:c}=oi({...ArrayBuffer.isView(i)?{value:i}:i,length:e.length,startIndices:s,characterSet:a});r=c,o=(d,{index:g})=>l[g]}else{const{iterable:l,objectInfo:c}=te(e);s=[0],r=0;for(const d of l){c.index++;const g=Array.from(o(d,c)||"");a&&g.forEach(a.add,a),r+=g.length,s.push(r)}}this.setState({getText:o,startIndices:s,numInstances:r,characterSet:a||t})}transformParagraph(e,t){const{fontAtlasManager:i}=this.state,o=i.mapping,s=this.state.getText,{wordBreak:r,lineHeight:a,maxWidth:l}=this.props,c=s(e,t)||"";return ii(c,a,r,l*i.props.fontSize,o)}renderLayers(){const{startIndices:e,numInstances:t,getText:i,fontAtlasManager:{scale:o,atlas:s,mapping:r},styleVersion:a}=this.state,{data:l,_dataDiff:c,getPosition:d,getColor:g,getSize:u,getAngle:p,getPixelOffset:f,getBackgroundColor:y,getBorderColor:h,getBorderWidth:m,backgroundBorderRadius:L,backgroundPadding:C,background:S,billboard:x,fontSettings:v,outlineWidth:I,outlineColor:R,sizeScale:_,sizeUnits:U,sizeMinPixels:M,sizeMaxPixels:k,transitions:b,updateTriggers:P}=this.props,G=this.getSubLayerClass("characters",se),q=this.getSubLayerClass("background",ne);return[S&&new q({getFillColor:y,getLineColor:h,getLineWidth:m,borderRadius:L,padding:C,getPosition:d,getSize:u,getAngle:p,getPixelOffset:f,billboard:x,sizeScale:_,sizeUnits:U,sizeMinPixels:M,sizeMaxPixels:k,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:P.getPosition,getAngle:P.getAngle,getSize:P.getSize,getFillColor:P.getBackgroundColor,getLineColor:P.getBorderColor,getLineWidth:P.getBorderWidth,getPixelOffset:P.getPixelOffset,getBoundingRect:{getText:P.getText,getTextAnchor:P.getTextAnchor,getAlignmentBaseline:P.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 G({sdf:v.sdf,smoothing:Number.isFinite(v.smoothing)?v.smoothing:A.smoothing,outlineWidth:I/(v.radius||A.radius),outlineColor:R,iconAtlas:s,iconMapping:r,getPosition:d,getColor:g,getSize:u,getAngle:p,getPixelOffset:f,billboard:x,sizeScale:_*o,sizeUnits:U,sizeMinPixels:M*o,sizeMaxPixels:k*o,transitions:b&&{getPosition:b.getPosition,getAngle:b.getAngle,getColor:b.getColor,getSize:b.getSize,getPixelOffset:b.getPixelOffset}},this.getSubLayerProps({id:"characters",updateTriggers:{all:P.getText,getPosition:P.getPosition,getAngle:P.getAngle,getColor:P.getColor,getSize:P.getSize,getPixelOffset:P.getPixelOffset,getIconOffsets:{getTextAnchor:P.getTextAnchor,getAlignmentBaseline:P.getAlignmentBaseline,styleVersion:a}}}),{data:l,_dataDiff:c,startIndices:e,numInstances:t,getIconOffsets:this.getIconOffsets,getIcon:i})]}static set fontAtlasCacheLimit(e){ai(e)}}re.defaultProps=fi;re.layerName="TextLayer";const j={circle:{type:oe,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:Z,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:re,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"}}},$={type:Oe,props:{lineWidthUnits:"widthUnits",lineWidthScale:"widthScale",lineWidthMinPixels:"widthMinPixels",lineWidthMaxPixels:"widthMaxPixels",lineJointRounded:"jointRounded",lineCapRounded:"capRounded",lineMiterLimit:"miterLimit",lineBillboard:"billboard",getLineColor:"getColor",getLineWidth:"getWidth"}},ee={type:ze,props:{extruded:"extruded",filled:"filled",wireframe:"wireframe",elevationScale:"elevationScale",material:"material",_full3d:"_full3d",getElevation:"getElevation",getFillColor:"getFillColor",getLineColor:"getLineColor"}};function W({type:n,props:e}){const t={};for(const i in e)t[i]=n.defaultProps[e[i]];return t}function Q(n,e){const{transitions:t,updateTriggers:i}=n.props,o={updateTriggers:{},transitions:t&&{getPosition:t.geometry}};for(const s in e){const r=e[s];let a=n.props[s];s.startsWith("get")&&(a=n.getSubLayerAccessor(a),o.updateTriggers[r]=i[s],t&&(o.transitions[r]=t[s])),o[r]=a}return o}function hi(n){if(Array.isArray(n))return n;switch(T.assert(n.type,"GeoJSON does not have type"),n.type){case"Feature":return[n];case"FeatureCollection":return T.assert(Array.isArray(n.features),"GeoJSON does not have features array"),n.features;default:return[{geometry:n}]}}function Me(n,e,t={}){const i={pointFeatures:[],lineFeatures:[],polygonFeatures:[],polygonOutlineFeatures:[]},{startRow:o=0,endRow:s=n.length}=t;for(let r=o;r<s;r++){const a=n[r],{geometry:l}=a;if(l)if(l.type==="GeometryCollection"){T.assert(Array.isArray(l.geometries),"GeoJSON does not have geometries array");const{geometries:c}=l;for(let d=0;d<c.length;d++){const g=c[d];Ae(g,i,e,a,r)}}else Ae(l,i,e,a,r)}return i}function Ae(n,e,t,i,o){const{type:s,coordinates:r}=n,{pointFeatures:a,lineFeatures:l,polygonFeatures:c,polygonOutlineFeatures:d}=e;if(!mi(s,r)){T.warn(`${s} coordinates are malformed`)();return}switch(s){case"Point":a.push(t({geometry:n},i,o));break;case"MultiPoint":r.forEach(g=>{a.push(t({geometry:{type:"Point",coordinates:g}},i,o))});break;case"LineString":l.push(t({geometry:n},i,o));break;case"MultiLineString":r.forEach(g=>{l.push(t({geometry:{type:"LineString",coordinates:g}},i,o))});break;case"Polygon":c.push(t({geometry:n},i,o)),r.forEach(g=>{d.push(t({geometry:{type:"LineString",coordinates:g}},i,o))});break;case"MultiPolygon":r.forEach(g=>{c.push(t({geometry:{type:"Polygon",coordinates:g}},i,o)),g.forEach(u=>{d.push(t({geometry:{type:"LineString",coordinates:u}},i,o))})});break}}const yi={Point:1,MultiPoint:2,LineString:2,MultiLineString:3,Polygon:3,MultiPolygon:4};function mi(n,e){let t=yi[n];for(T.assert(t,`Unknown GeoJSON type ${n}`);e&&--t>0;)e=e[0];return e&&Number.isFinite(e[0])}function Ze(){return{points:{},lines:{},polygons:{},polygonsOutline:{}}}function N(n){return n.geometry.coordinates}function vi(n,e){const t=Ze(),{pointFeatures:i,lineFeatures:o,polygonFeatures:s,polygonOutlineFeatures:r}=n;return t.points.data=i,t.points._dataDiff=e.pointFeatures&&(()=>e.pointFeatures),t.points.getPosition=N,t.lines.data=o,t.lines._dataDiff=e.lineFeatures&&(()=>e.lineFeatures),t.lines.getPath=N,t.polygons.data=s,t.polygons._dataDiff=e.polygonFeatures&&(()=>e.polygonFeatures),t.polygons.getPolygon=N,t.polygonsOutline.data=r,t.polygonsOutline._dataDiff=e.polygonOutlineFeatures&&(()=>e.polygonOutlineFeatures),t.polygonsOutline.getPath=N,t}function xi(n,e){const t=Ze(),{points:i,lines:o,polygons:s}=n,r=$t(n,e);t.points.data={length:i.positions.value.length/i.positions.size,attributes:{...i.attributes,getPosition:i.positions,instancePickingColors:{size:4,value:r.points}},properties:i.properties,numericProps:i.numericProps,featureIds:i.featureIds},t.lines.data={length:o.pathIndices.value.length-1,startIndices:o.pathIndices.value,attributes:{...o.attributes,getPath:o.positions,instancePickingColors:{size:4,value:r.lines}},properties:o.properties,numericProps:o.numericProps,featureIds:o.featureIds},t.lines._pathType="open";const a=s.positions.value.length/s.positions.size,l=Array(a).fill(1);for(const c of s.primitivePolygonIndices.value)l[c-1]=0;return t.polygons.data={length:s.polygonIndices.value.length-1,startIndices:s.polygonIndices.value,attributes:{...s.attributes,getPolygon:s.positions,instanceVertexValid:{size:1,value:new Uint16Array(l)},pickingColors:{size:4,value:r.polygons}},properties:s.properties,numericProps:s.numericProps,featureIds:s.featureIds},t.polygons._normalize=!1,s.triangles&&(t.polygons.data.attributes.indices=s.triangles.value),t.polygonsOutline.data={length:s.primitivePolygonIndices.value.length-1,startIndices:s.primitivePolygonIndices.value,attributes:{...s.attributes,getPath:s.positions,instancePickingColors:{size:4,value:r.polygons}},properties:s.properties,numericProps:s.numericProps,featureIds:s.featureIds},t.polygonsOutline._pathType="open",t}const Pi=["points","linestrings","polygons"],Ci={...W(j.circle),...W(j.icon),...W(j.text),...W($),...W(ee),stroked:!0,filled:!0,extruded:!1,wireframe:!1,_full3d:!1,iconAtlas:{type:"object",value:null},iconMapping:{type:"object",value:{}},getIcon:{type:"accessor",value:n=>n.properties.icon},getText:{type:"accessor",value:n=>n.properties.text},pointType:"circle",getRadius:{deprecatedFor:"getPointRadius"}};class qe extends ie{initializeState(){this.state={layerProps:{},features:{},featuresDiff:{}}}updateState({props:e,changeFlags:t}){if(!t.dataChanged)return;const{data:i}=this.props,o=i&&"points"in i&&"polygons"in i&&"lines"in i;this.setState({binary:o}),o?this._updateStateBinary({props:e,changeFlags:t}):this._updateStateJSON({props:e,changeFlags:t})}_updateStateBinary({props:e,changeFlags:t}){const i=xi(e.data,this.encodePickingColor);this.setState({layerProps:i})}_updateStateJSON({props:e,changeFlags:t}){const i=hi(e.data),o=this.getSubLayerRow.bind(this);let s={};const r={};if(Array.isArray(t.dataChanged)){const l=this.state.features;for(const c in l)s[c]=l[c].slice(),r[c]=[];for(const c of t.dataChanged){const d=Me(i,o,c);for(const g in l)r[g].push(Ge({data:s[g],getIndex:u=>u.__source.index,dataRange:c,replace:d[g]}))}}else s=Me(i,o);const a=vi(s,r);this.setState({features:s,featuresDiff:r,layerProps:a})}getPickingInfo(e){const t=super.getPickingInfo(e),{index:i,sourceLayer:o}=t;return t.featureType=Pi.find(s=>o.id.startsWith(`${this.id}-${s}-`)),i>=0&&o.id.startsWith(`${this.id}-points-text`)&&this.state.binary&&(t.index=this.props.data.points.globalFeatureIds.value[i]),t}_updateAutoHighlight(e){const t=`${this.id}-points-`,i=e.featureType==="points";for(const o of this.getSubLayers())o.id.startsWith(t)===i&&o.updateAutoHighlight(e)}_renderPolygonLayer(){const{extruded:e,wireframe:t}=this.props,{layerProps:i}=this.state,o="polygons-fill",s=this.shouldRenderSubLayer(o,i.polygons?.data)&&this.getSubLayerClass(o,ee.type);if(s){const r=Q(this,ee.props),a=e&&t;return a||delete r.getLineColor,r.updateTriggers.lineColors=a,new s(r,this.getSubLayerProps({id:o,updateTriggers:r.updateTriggers}),i.polygons)}return null}_renderLineLayers(){const{extruded:e,stroked:t}=this.props,{layerProps:i}=this.state,o="polygons-stroke",s="linestrings",r=!e&&t&&this.shouldRenderSubLayer(o,i.polygonsOutline?.data)&&this.getSubLayerClass(o,$.type),a=this.shouldRenderSubLayer(s,i.lines?.data)&&this.getSubLayerClass(s,$.type);if(r||a){const l=Q(this,$.props);return[r&&new r(l,this.getSubLayerProps({id:o,updateTriggers:l.updateTriggers}),i.polygonsOutline),a&&new a(l,this.getSubLayerProps({id:s,updateTriggers:l.updateTriggers}),i.lines)]}return null}_renderPointLayers(){const{pointType:e}=this.props,{layerProps:t,binary:i}=this.state;let{highlightedObjectIndex:o}=this.props;!i&&Number.isFinite(o)&&(o=t.points.data.findIndex(a=>a.__source.index===o));const s=new Set(e.split("+")),r=[];for(const a of s){const l=`points-${a}`,c=j[a],d=c&&this.shouldRenderSubLayer(l,t.points?.data)&&this.getSubLayerClass(l,c.type);if(d){const g=Q(this,c.props);let u=t.points;if(a==="text"&&i){const{instancePickingColors:p,...f}=u.data.attributes;u={...u,data:{...u.data,attributes:f}}}r.push(new d(g,this.getSubLayerProps({id:l,updateTriggers:g.updateTriggers,highlightedObjectIndex:o}),u))}}return r}renderLayers(){const{extruded:e}=this.props,t=this._renderPolygonLayer(),i=this._renderLineLayers(),o=this._renderPointLayers();return[!e&&t,i,o,e&&t]}getSubLayerAccessor(e){const{binary:t}=this.state;return!t||typeof e!="function"?super.getSubLayerAccessor(e):(i,o)=>{const{data:s,index:r}=o,a=Nt(s,r);return e(a,o)}}}qe.layerName="GeoJsonLayer";qe.defaultProps=Ci;export{Fe as A,ke as B,qe as G,Z as I,se as M,Ue as P,oe as S,re as T,je as a,ne as b};
1010
+ //# sourceMappingURL=geojson-layer-CLhXLxdI.js.map