@deck.gl/geo-layers 9.0.0-beta.1 → 9.0.0-beta.10

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 (262) hide show
  1. package/dist/dist.dev.js +2574 -5077
  2. package/dist/geo-cell-layer/GeoCellLayer.js +51 -0
  3. package/{typed → dist}/geohash-layer/geohash-layer.d.ts +1 -1
  4. package/dist/geohash-layer/geohash-layer.d.ts.map +1 -0
  5. package/dist/geohash-layer/geohash-layer.js +19 -0
  6. package/dist/geohash-layer/geohash-utils.js +50 -0
  7. package/dist/great-circle-layer/great-circle-layer.js +12 -0
  8. package/{typed → dist}/h3-layers/h3-cluster-layer.d.ts +1 -1
  9. package/dist/h3-layers/h3-cluster-layer.d.ts.map +1 -0
  10. package/dist/h3-layers/h3-cluster-layer.js +47 -0
  11. package/dist/h3-layers/h3-hexagon-layer.js +204 -0
  12. package/dist/h3-layers/h3-utils.js +56 -0
  13. package/dist/index.cjs +3160 -0
  14. package/dist/index.cjs.map +7 -0
  15. package/dist/index.d.ts +31 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +36 -0
  18. package/dist/mesh-layer/mesh-layer-fragment.glsl.d.ts +3 -0
  19. package/{typed → dist}/mesh-layer/mesh-layer-fragment.glsl.d.ts.map +1 -1
  20. package/dist/mesh-layer/mesh-layer-fragment.glsl.js +33 -0
  21. package/dist/mesh-layer/mesh-layer-vertex.glsl.js +63 -0
  22. package/{typed → dist}/mesh-layer/mesh-layer.d.ts.map +1 -1
  23. package/dist/mesh-layer/mesh-layer.js +128 -0
  24. package/{typed → dist}/mvt-layer/coordinate-transform.d.ts +1 -1
  25. package/{typed → dist}/mvt-layer/coordinate-transform.d.ts.map +1 -1
  26. package/dist/mvt-layer/coordinate-transform.js +41 -0
  27. package/dist/mvt-layer/find-index-binary.d.ts +11 -0
  28. package/dist/mvt-layer/find-index-binary.d.ts.map +1 -0
  29. package/dist/mvt-layer/find-index-binary.js +96 -0
  30. package/{typed → dist}/mvt-layer/mvt-layer.d.ts +13 -11
  31. package/dist/mvt-layer/mvt-layer.d.ts.map +1 -0
  32. package/dist/mvt-layer/mvt-layer.js +305 -0
  33. package/{typed → dist}/quadkey-layer/quadkey-layer.d.ts +1 -1
  34. package/dist/quadkey-layer/quadkey-layer.d.ts.map +1 -0
  35. package/dist/quadkey-layer/quadkey-layer.js +22 -0
  36. package/dist/quadkey-layer/quadkey-utils.js +26 -0
  37. package/dist/s2-layer/s2-geometry.js +123 -0
  38. package/{typed → dist}/s2-layer/s2-layer.d.ts +1 -1
  39. package/dist/s2-layer/s2-layer.d.ts.map +1 -0
  40. package/dist/s2-layer/s2-layer.js +38 -0
  41. package/dist/s2-layer/s2-utils.js +87 -0
  42. package/{typed → dist}/terrain-layer/terrain-layer.d.ts +4 -4
  43. package/dist/terrain-layer/terrain-layer.d.ts.map +1 -0
  44. package/dist/terrain-layer/terrain-layer.js +233 -0
  45. package/{typed → dist}/tile-3d-layer/tile-3d-layer.d.ts +15 -1
  46. package/{typed → dist}/tile-3d-layer/tile-3d-layer.d.ts.map +1 -1
  47. package/dist/tile-3d-layer/tile-3d-layer.js +302 -0
  48. package/{typed → dist}/tile-layer/tile-layer.d.ts +14 -5
  49. package/dist/tile-layer/tile-layer.d.ts.map +1 -0
  50. package/dist/tile-layer/tile-layer.js +207 -0
  51. package/dist/tileset-2d/index.d.ts +7 -0
  52. package/dist/tileset-2d/index.d.ts.map +1 -0
  53. package/dist/tileset-2d/index.js +4 -0
  54. package/dist/tileset-2d/memoize.js +41 -0
  55. package/{typed → dist}/tileset-2d/tile-2d-header.d.ts +3 -2
  56. package/dist/tileset-2d/tile-2d-header.d.ts.map +1 -0
  57. package/dist/tileset-2d/tile-2d-header.js +135 -0
  58. package/dist/tileset-2d/tile-2d-traversal.d.ts +4 -0
  59. package/dist/tileset-2d/tile-2d-traversal.d.ts.map +1 -0
  60. package/dist/tileset-2d/tile-2d-traversal.js +182 -0
  61. package/{typed → dist}/tileset-2d/tileset-2d.d.ts +9 -7
  62. package/dist/tileset-2d/tileset-2d.d.ts.map +1 -0
  63. package/dist/tileset-2d/tileset-2d.js +458 -0
  64. package/dist/tileset-2d/types.js +1 -0
  65. package/{typed → dist}/tileset-2d/utils.d.ts +3 -3
  66. package/dist/tileset-2d/utils.d.ts.map +1 -0
  67. package/dist/tileset-2d/utils.js +234 -0
  68. package/{typed → dist}/trips-layer/trips-layer.d.ts +1 -1
  69. package/{typed → dist}/trips-layer/trips-layer.d.ts.map +1 -1
  70. package/dist/trips-layer/trips-layer.js +93 -0
  71. package/dist/wms-layer/utils.js +13 -0
  72. package/dist/wms-layer/wms-layer.js +192 -0
  73. package/dist.min.js +243 -564
  74. package/package.json +30 -23
  75. package/src/index.ts +7 -7
  76. package/src/mesh-layer/mesh-layer-fragment.glsl.ts +1 -9
  77. package/src/mesh-layer/mesh-layer.ts +1 -2
  78. package/src/mvt-layer/coordinate-transform.ts +1 -1
  79. package/src/mvt-layer/find-index-binary.ts +5 -9
  80. package/src/mvt-layer/mvt-layer.ts +36 -25
  81. package/src/terrain-layer/terrain-layer.ts +13 -3
  82. package/src/tile-layer/tile-layer.ts +30 -14
  83. package/src/tileset-2d/tile-2d-header.ts +2 -1
  84. package/src/tileset-2d/tile-2d-traversal.ts +1 -1
  85. package/src/tileset-2d/tileset-2d.ts +14 -7
  86. package/src/tileset-2d/utils.ts +2 -2
  87. package/src/trips-layer/trips-layer.ts +1 -1
  88. package/src/wms-layer/wms-layer.ts +1 -1
  89. package/dist/es5/geo-cell-layer/GeoCellLayer.js +0 -118
  90. package/dist/es5/geo-cell-layer/GeoCellLayer.js.map +0 -1
  91. package/dist/es5/geohash-layer/geohash-layer.js +0 -67
  92. package/dist/es5/geohash-layer/geohash-layer.js.map +0 -1
  93. package/dist/es5/geohash-layer/geohash-utils.js +0 -77
  94. package/dist/es5/geohash-layer/geohash-utils.js.map +0 -1
  95. package/dist/es5/great-circle-layer/great-circle-layer.js +0 -48
  96. package/dist/es5/great-circle-layer/great-circle-layer.js.map +0 -1
  97. package/dist/es5/h3-layers/h3-cluster-layer.js +0 -162
  98. package/dist/es5/h3-layers/h3-cluster-layer.js.map +0 -1
  99. package/dist/es5/h3-layers/h3-hexagon-layer.js +0 -351
  100. package/dist/es5/h3-layers/h3-hexagon-layer.js.map +0 -1
  101. package/dist/es5/h3-layers/h3-utils.js +0 -111
  102. package/dist/es5/h3-layers/h3-utils.js.map +0 -1
  103. package/dist/es5/index.js +0 -132
  104. package/dist/es5/index.js.map +0 -1
  105. package/dist/es5/mesh-layer/mesh-layer-fragment.glsl.js +0 -9
  106. package/dist/es5/mesh-layer/mesh-layer-fragment.glsl.js.map +0 -1
  107. package/dist/es5/mesh-layer/mesh-layer-vertex.glsl.js +0 -9
  108. package/dist/es5/mesh-layer/mesh-layer-vertex.glsl.js.map +0 -1
  109. package/dist/es5/mesh-layer/mesh-layer.js +0 -217
  110. package/dist/es5/mesh-layer/mesh-layer.js.map +0 -1
  111. package/dist/es5/mvt-layer/coordinate-transform.js +0 -83
  112. package/dist/es5/mvt-layer/coordinate-transform.js.map +0 -1
  113. package/dist/es5/mvt-layer/find-index-binary.js +0 -127
  114. package/dist/es5/mvt-layer/find-index-binary.js.map +0 -1
  115. package/dist/es5/mvt-layer/mvt-layer.js +0 -533
  116. package/dist/es5/mvt-layer/mvt-layer.js.map +0 -1
  117. package/dist/es5/quadkey-layer/quadkey-layer.js +0 -72
  118. package/dist/es5/quadkey-layer/quadkey-layer.js.map +0 -1
  119. package/dist/es5/quadkey-layer/quadkey-utils.js +0 -53
  120. package/dist/es5/quadkey-layer/quadkey-utils.js.map +0 -1
  121. package/dist/es5/s2-layer/s2-geometry.js +0 -158
  122. package/dist/es5/s2-layer/s2-geometry.js.map +0 -1
  123. package/dist/es5/s2-layer/s2-layer.js +0 -67
  124. package/dist/es5/s2-layer/s2-layer.js.map +0 -1
  125. package/dist/es5/s2-layer/s2-utils.js +0 -80
  126. package/dist/es5/s2-layer/s2-utils.js.map +0 -1
  127. package/dist/es5/terrain-layer/terrain-layer.js +0 -347
  128. package/dist/es5/terrain-layer/terrain-layer.js.map +0 -1
  129. package/dist/es5/tile-3d-layer/tile-3d-layer.js +0 -511
  130. package/dist/es5/tile-3d-layer/tile-3d-layer.js.map +0 -1
  131. package/dist/es5/tile-layer/tile-layer.js +0 -363
  132. package/dist/es5/tile-layer/tile-layer.js.map +0 -1
  133. package/dist/es5/tileset-2d/index.js +0 -66
  134. package/dist/es5/tileset-2d/index.js.map +0 -1
  135. package/dist/es5/tileset-2d/memoize.js +0 -47
  136. package/dist/es5/tileset-2d/memoize.js.map +0 -1
  137. package/dist/es5/tileset-2d/tile-2d-header.js +0 -250
  138. package/dist/es5/tileset-2d/tile-2d-header.js.map +0 -1
  139. package/dist/es5/tileset-2d/tile-2d-traversal.js +0 -256
  140. package/dist/es5/tileset-2d/tile-2d-traversal.js.map +0 -1
  141. package/dist/es5/tileset-2d/tileset-2d.js +0 -757
  142. package/dist/es5/tileset-2d/tileset-2d.js.map +0 -1
  143. package/dist/es5/tileset-2d/types.js +0 -2
  144. package/dist/es5/tileset-2d/types.js.map +0 -1
  145. package/dist/es5/tileset-2d/utils.js +0 -302
  146. package/dist/es5/tileset-2d/utils.js.map +0 -1
  147. package/dist/es5/trips-layer/trips-layer.js +0 -114
  148. package/dist/es5/trips-layer/trips-layer.js.map +0 -1
  149. package/dist/es5/wms-layer/utils.js +0 -18
  150. package/dist/es5/wms-layer/utils.js.map +0 -1
  151. package/dist/es5/wms-layer/wms-layer.js +0 -376
  152. package/dist/es5/wms-layer/wms-layer.js.map +0 -1
  153. package/dist/esm/geo-cell-layer/GeoCellLayer.js +0 -72
  154. package/dist/esm/geo-cell-layer/GeoCellLayer.js.map +0 -1
  155. package/dist/esm/geohash-layer/geohash-layer.js +0 -26
  156. package/dist/esm/geohash-layer/geohash-layer.js.map +0 -1
  157. package/dist/esm/geohash-layer/geohash-utils.js +0 -56
  158. package/dist/esm/geohash-layer/geohash-utils.js.map +0 -1
  159. package/dist/esm/great-circle-layer/great-circle-layer.js +0 -12
  160. package/dist/esm/great-circle-layer/great-circle-layer.js.map +0 -1
  161. package/dist/esm/h3-layers/h3-cluster-layer.js +0 -79
  162. package/dist/esm/h3-layers/h3-cluster-layer.js.map +0 -1
  163. package/dist/esm/h3-layers/h3-hexagon-layer.js +0 -280
  164. package/dist/esm/h3-layers/h3-hexagon-layer.js.map +0 -1
  165. package/dist/esm/h3-layers/h3-utils.js +0 -54
  166. package/dist/esm/h3-layers/h3-utils.js.map +0 -1
  167. package/dist/esm/index.js +0 -17
  168. package/dist/esm/index.js.map +0 -1
  169. package/dist/esm/mesh-layer/mesh-layer-fragment.glsl.js +0 -56
  170. package/dist/esm/mesh-layer/mesh-layer-fragment.glsl.js.map +0 -1
  171. package/dist/esm/mesh-layer/mesh-layer-vertex.glsl.js +0 -85
  172. package/dist/esm/mesh-layer/mesh-layer-vertex.glsl.js.map +0 -1
  173. package/dist/esm/mesh-layer/mesh-layer.js +0 -178
  174. package/dist/esm/mesh-layer/mesh-layer.js.map +0 -1
  175. package/dist/esm/mvt-layer/coordinate-transform.js +0 -49
  176. package/dist/esm/mvt-layer/coordinate-transform.js.map +0 -1
  177. package/dist/esm/mvt-layer/find-index-binary.js +0 -99
  178. package/dist/esm/mvt-layer/find-index-binary.js.map +0 -1
  179. package/dist/esm/mvt-layer/mvt-layer.js +0 -427
  180. package/dist/esm/mvt-layer/mvt-layer.js.map +0 -1
  181. package/dist/esm/quadkey-layer/quadkey-layer.js +0 -31
  182. package/dist/esm/quadkey-layer/quadkey-layer.js.map +0 -1
  183. package/dist/esm/quadkey-layer/quadkey-utils.js +0 -24
  184. package/dist/esm/quadkey-layer/quadkey-utils.js.map +0 -1
  185. package/dist/esm/s2-layer/s2-geometry.js +0 -126
  186. package/dist/esm/s2-layer/s2-geometry.js.map +0 -1
  187. package/dist/esm/s2-layer/s2-layer.js +0 -26
  188. package/dist/esm/s2-layer/s2-layer.js.map +0 -1
  189. package/dist/esm/s2-layer/s2-utils.js +0 -69
  190. package/dist/esm/s2-layer/s2-utils.js.map +0 -1
  191. package/dist/esm/terrain-layer/terrain-layer.js +0 -292
  192. package/dist/esm/terrain-layer/terrain-layer.js.map +0 -1
  193. package/dist/esm/tile-3d-layer/tile-3d-layer.js +0 -438
  194. package/dist/esm/tile-3d-layer/tile-3d-layer.js.map +0 -1
  195. package/dist/esm/tile-layer/tile-layer.js +0 -299
  196. package/dist/esm/tile-layer/tile-layer.js.map +0 -1
  197. package/dist/esm/tileset-2d/index.js +0 -4
  198. package/dist/esm/tileset-2d/index.js.map +0 -1
  199. package/dist/esm/tileset-2d/memoize.js +0 -40
  200. package/dist/esm/tileset-2d/memoize.js.map +0 -1
  201. package/dist/esm/tileset-2d/tile-2d-header.js +0 -179
  202. package/dist/esm/tileset-2d/tile-2d-header.js.map +0 -1
  203. package/dist/esm/tileset-2d/tile-2d-traversal.js +0 -184
  204. package/dist/esm/tileset-2d/tile-2d-traversal.js.map +0 -1
  205. package/dist/esm/tileset-2d/tileset-2d.js +0 -509
  206. package/dist/esm/tileset-2d/tileset-2d.js.map +0 -1
  207. package/dist/esm/tileset-2d/types.js +0 -2
  208. package/dist/esm/tileset-2d/types.js.map +0 -1
  209. package/dist/esm/tileset-2d/utils.js +0 -233
  210. package/dist/esm/tileset-2d/utils.js.map +0 -1
  211. package/dist/esm/trips-layer/trips-layer.js +0 -88
  212. package/dist/esm/trips-layer/trips-layer.js.map +0 -1
  213. package/dist/esm/wms-layer/utils.js +0 -9
  214. package/dist/esm/wms-layer/utils.js.map +0 -1
  215. package/dist/esm/wms-layer/wms-layer.js +0 -231
  216. package/dist/esm/wms-layer/wms-layer.js.map +0 -1
  217. package/typed/geohash-layer/geohash-layer.d.ts.map +0 -1
  218. package/typed/h3-layers/h3-cluster-layer.d.ts.map +0 -1
  219. package/typed/index.d.ts +0 -31
  220. package/typed/index.d.ts.map +0 -1
  221. package/typed/mesh-layer/mesh-layer-fragment.glsl.d.ts +0 -3
  222. package/typed/mvt-layer/find-index-binary.d.ts +0 -12
  223. package/typed/mvt-layer/find-index-binary.d.ts.map +0 -1
  224. package/typed/mvt-layer/mvt-layer.d.ts.map +0 -1
  225. package/typed/quadkey-layer/quadkey-layer.d.ts.map +0 -1
  226. package/typed/s2-layer/s2-layer.d.ts.map +0 -1
  227. package/typed/terrain-layer/terrain-layer.d.ts.map +0 -1
  228. package/typed/tile-layer/tile-layer.d.ts.map +0 -1
  229. package/typed/tileset-2d/index.d.ts +0 -7
  230. package/typed/tileset-2d/index.d.ts.map +0 -1
  231. package/typed/tileset-2d/tile-2d-header.d.ts.map +0 -1
  232. package/typed/tileset-2d/tile-2d-traversal.d.ts +0 -4
  233. package/typed/tileset-2d/tile-2d-traversal.d.ts.map +0 -1
  234. package/typed/tileset-2d/tileset-2d.d.ts.map +0 -1
  235. package/typed/tileset-2d/utils.d.ts.map +0 -1
  236. /package/{typed → dist}/geo-cell-layer/GeoCellLayer.d.ts +0 -0
  237. /package/{typed → dist}/geo-cell-layer/GeoCellLayer.d.ts.map +0 -0
  238. /package/{typed → dist}/geohash-layer/geohash-utils.d.ts +0 -0
  239. /package/{typed → dist}/geohash-layer/geohash-utils.d.ts.map +0 -0
  240. /package/{typed → dist}/great-circle-layer/great-circle-layer.d.ts +0 -0
  241. /package/{typed → dist}/great-circle-layer/great-circle-layer.d.ts.map +0 -0
  242. /package/{typed → dist}/h3-layers/h3-hexagon-layer.d.ts +0 -0
  243. /package/{typed → dist}/h3-layers/h3-hexagon-layer.d.ts.map +0 -0
  244. /package/{typed → dist}/h3-layers/h3-utils.d.ts +0 -0
  245. /package/{typed → dist}/h3-layers/h3-utils.d.ts.map +0 -0
  246. /package/{typed → dist}/mesh-layer/mesh-layer-vertex.glsl.d.ts +0 -0
  247. /package/{typed → dist}/mesh-layer/mesh-layer-vertex.glsl.d.ts.map +0 -0
  248. /package/{typed → dist}/mesh-layer/mesh-layer.d.ts +0 -0
  249. /package/{typed → dist}/quadkey-layer/quadkey-utils.d.ts +0 -0
  250. /package/{typed → dist}/quadkey-layer/quadkey-utils.d.ts.map +0 -0
  251. /package/{typed → dist}/s2-layer/s2-geometry.d.ts +0 -0
  252. /package/{typed → dist}/s2-layer/s2-geometry.d.ts.map +0 -0
  253. /package/{typed → dist}/s2-layer/s2-utils.d.ts +0 -0
  254. /package/{typed → dist}/s2-layer/s2-utils.d.ts.map +0 -0
  255. /package/{typed → dist}/tileset-2d/memoize.d.ts +0 -0
  256. /package/{typed → dist}/tileset-2d/memoize.d.ts.map +0 -0
  257. /package/{typed → dist}/tileset-2d/types.d.ts +0 -0
  258. /package/{typed → dist}/tileset-2d/types.d.ts.map +0 -0
  259. /package/{typed → dist}/wms-layer/utils.d.ts +0 -0
  260. /package/{typed → dist}/wms-layer/utils.d.ts.map +0 -0
  261. /package/{typed → dist}/wms-layer/wms-layer.d.ts +0 -0
  262. /package/{typed → dist}/wms-layer/wms-layer.d.ts.map +0 -0
package/dist/index.cjs ADDED
@@ -0,0 +1,3160 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+
26
+ // dist/index.js
27
+ var dist_exports = {};
28
+ __export(dist_exports, {
29
+ GeohashLayer: () => GeohashLayer,
30
+ GreatCircleLayer: () => GreatCircleLayer,
31
+ H3ClusterLayer: () => H3ClusterLayer,
32
+ H3HexagonLayer: () => H3HexagonLayer,
33
+ MVTLayer: () => MVTLayer,
34
+ QuadkeyLayer: () => QuadkeyLayer,
35
+ S2Layer: () => S2Layer,
36
+ TerrainLayer: () => TerrainLayer,
37
+ Tile3DLayer: () => Tile3DLayer,
38
+ TileLayer: () => TileLayer,
39
+ TripsLayer: () => TripsLayer,
40
+ _GeoCellLayer: () => GeoCellLayer,
41
+ _Tile2DHeader: () => Tile2DHeader,
42
+ _Tileset2D: () => Tileset2D,
43
+ _WMSLayer: () => WMSLayer,
44
+ _getURLFromTemplate: () => getURLFromTemplate
45
+ });
46
+ module.exports = __toCommonJS(dist_exports);
47
+
48
+ // dist/wms-layer/wms-layer.js
49
+ var import_core = require("@deck.gl/core");
50
+ var import_layers = require("@deck.gl/layers");
51
+ var import_wms = require("@loaders.gl/wms");
52
+
53
+ // dist/wms-layer/utils.js
54
+ var import_web_mercator = require("@math.gl/web-mercator");
55
+ var HALF_EARTH_CIRCUMFERENCE = 6378137 * Math.PI;
56
+ function WGS84ToPseudoMercator(coord) {
57
+ const mercator = (0, import_web_mercator.lngLatToWorld)(coord);
58
+ mercator[0] = (mercator[0] / 256 - 1) * HALF_EARTH_CIRCUMFERENCE;
59
+ mercator[1] = (mercator[1] / 256 - 1) * HALF_EARTH_CIRCUMFERENCE;
60
+ return mercator;
61
+ }
62
+
63
+ // dist/wms-layer/wms-layer.js
64
+ var defaultProps = {
65
+ id: "imagery-layer",
66
+ data: "",
67
+ serviceType: "auto",
68
+ srs: "auto",
69
+ layers: { type: "array", compare: true, value: [] },
70
+ onMetadataLoad: { type: "function", value: () => {
71
+ } },
72
+ onMetadataLoadError: { type: "function", value: console.error },
73
+ onImageLoadStart: { type: "function", value: () => {
74
+ } },
75
+ onImageLoad: { type: "function", value: () => {
76
+ } },
77
+ onImageLoadError: {
78
+ type: "function",
79
+ compare: false,
80
+ value: (requestId, error) => console.error(error, requestId)
81
+ }
82
+ };
83
+ var _WMSLayer = class extends import_core.CompositeLayer {
84
+ get isLoaded() {
85
+ var _a;
86
+ return ((_a = this.state) == null ? void 0 : _a.loadCounter) === 0 && super.isLoaded;
87
+ }
88
+ shouldUpdateState() {
89
+ return true;
90
+ }
91
+ initializeState() {
92
+ this.state._nextRequestId = 0;
93
+ this.state.lastRequestId = -1;
94
+ this.state.loadCounter = 0;
95
+ }
96
+ updateState({ changeFlags, props, oldProps }) {
97
+ const { viewport } = this.context;
98
+ if (changeFlags.dataChanged || props.serviceType !== oldProps.serviceType) {
99
+ this.state.imageSource = this._createImageSource(props);
100
+ this._loadMetadata();
101
+ this.debounce(() => this.loadImage(viewport, "image source changed"), 0);
102
+ } else if (!(0, import_core._deepEqual)(props.layers, oldProps.layers, 1)) {
103
+ this.debounce(() => this.loadImage(viewport, "layers changed"), 0);
104
+ } else if (changeFlags.viewportChanged) {
105
+ this.debounce(() => this.loadImage(viewport, "viewport changed"));
106
+ }
107
+ }
108
+ finalizeState() {
109
+ }
110
+ renderLayers() {
111
+ const { bounds, image, lastRequestParameters } = this.state;
112
+ return image && new import_layers.BitmapLayer({
113
+ ...this.getSubLayerProps({ id: "bitmap" }),
114
+ _imageCoordinateSystem: lastRequestParameters.srs === "EPSG:4326" ? import_core.COORDINATE_SYSTEM.LNGLAT : import_core.COORDINATE_SYSTEM.CARTESIAN,
115
+ bounds,
116
+ image
117
+ });
118
+ }
119
+ async getFeatureInfoText(x, y) {
120
+ var _a, _b;
121
+ const { lastRequestParameters } = this.state;
122
+ if (lastRequestParameters) {
123
+ const featureInfo = await ((_b = (_a = this.state.imageSource).getFeatureInfoText) == null ? void 0 : _b.call(_a, {
124
+ ...lastRequestParameters,
125
+ query_layers: lastRequestParameters.layers,
126
+ x,
127
+ y,
128
+ info_format: "application/vnd.ogc.gml"
129
+ }));
130
+ return featureInfo;
131
+ }
132
+ return "";
133
+ }
134
+ _createImageSource(props) {
135
+ if (props.data instanceof import_wms.ImageSource) {
136
+ return props.data;
137
+ }
138
+ if (typeof props.data === "string") {
139
+ return (0, import_wms.createImageSource)({
140
+ url: props.data,
141
+ loadOptions: props.loadOptions,
142
+ type: props.serviceType
143
+ });
144
+ }
145
+ throw new Error("invalid image source in props.data");
146
+ }
147
+ async _loadMetadata() {
148
+ var _a, _b;
149
+ const { imageSource } = this.state;
150
+ try {
151
+ this.state.loadCounter++;
152
+ const metadata = await imageSource.getMetadata();
153
+ if (this.state.imageSource === imageSource) {
154
+ (_a = this.getCurrentLayer()) == null ? void 0 : _a.props.onMetadataLoad(metadata);
155
+ }
156
+ } catch (error) {
157
+ (_b = this.getCurrentLayer()) == null ? void 0 : _b.props.onMetadataLoadError(error);
158
+ } finally {
159
+ this.state.loadCounter--;
160
+ }
161
+ }
162
+ async loadImage(viewport, reason) {
163
+ var _a, _b;
164
+ const { layers, serviceType } = this.props;
165
+ if (serviceType === "wms" && layers.length === 0) {
166
+ return;
167
+ }
168
+ const bounds = viewport.getBounds();
169
+ const { width, height } = viewport;
170
+ const requestId = this.getRequestId();
171
+ let { srs } = this.props;
172
+ if (srs === "auto") {
173
+ srs = viewport.resolution ? "EPSG:4326" : "EPSG:3857";
174
+ }
175
+ const requestParams = {
176
+ width,
177
+ height,
178
+ boundingBox: [
179
+ [bounds[0], bounds[1]],
180
+ [bounds[2], bounds[3]]
181
+ ],
182
+ layers,
183
+ crs: srs
184
+ };
185
+ if (srs === "EPSG:3857") {
186
+ const min = WGS84ToPseudoMercator([bounds[0], bounds[1]]);
187
+ const max = WGS84ToPseudoMercator([bounds[2], bounds[3]]);
188
+ requestParams.boundingBox = [min, max];
189
+ }
190
+ try {
191
+ this.state.loadCounter++;
192
+ this.props.onImageLoadStart(requestId);
193
+ const image = await this.state.imageSource.getImage(requestParams);
194
+ if (this.state.lastRequestId < requestId) {
195
+ (_a = this.getCurrentLayer()) == null ? void 0 : _a.props.onImageLoad(requestId);
196
+ this.setState({
197
+ image,
198
+ bounds,
199
+ lastRequestParameters: requestParams,
200
+ lastRequestId: requestId
201
+ });
202
+ }
203
+ } catch (error) {
204
+ this.raiseError(error, "Load image");
205
+ (_b = this.getCurrentLayer()) == null ? void 0 : _b.props.onImageLoadError(requestId, error);
206
+ } finally {
207
+ this.state.loadCounter--;
208
+ }
209
+ }
210
+ getRequestId() {
211
+ return this.state._nextRequestId++;
212
+ }
213
+ debounce(fn, ms = 500) {
214
+ clearTimeout(this.state._timeoutId);
215
+ this.state._timeoutId = setTimeout(() => fn(), ms);
216
+ }
217
+ };
218
+ var WMSLayer = _WMSLayer;
219
+ (() => {
220
+ _WMSLayer.layerName = "WMSLayer";
221
+ })();
222
+ (() => {
223
+ _WMSLayer.defaultProps = defaultProps;
224
+ })();
225
+
226
+ // dist/great-circle-layer/great-circle-layer.js
227
+ var import_layers2 = require("@deck.gl/layers");
228
+ var defaultProps2 = {
229
+ getHeight: { type: "accessor", value: 0 },
230
+ greatCircle: true
231
+ };
232
+ var _GreatCircleLayer = class extends import_layers2.ArcLayer {
233
+ };
234
+ var GreatCircleLayer = _GreatCircleLayer;
235
+ (() => {
236
+ _GreatCircleLayer.layerName = "GreatCircleLayer";
237
+ })();
238
+ (() => {
239
+ _GreatCircleLayer.defaultProps = defaultProps2;
240
+ })();
241
+
242
+ // dist/geo-cell-layer/GeoCellLayer.js
243
+ var import_core2 = require("@deck.gl/core");
244
+ var import_layers3 = require("@deck.gl/layers");
245
+ var defaultProps3 = {
246
+ ...import_layers3.PolygonLayer.defaultProps
247
+ };
248
+ var _GeoCellLayer = class extends import_core2.CompositeLayer {
249
+ indexToBounds() {
250
+ return null;
251
+ }
252
+ renderLayers() {
253
+ const { elevationScale, extruded, wireframe, filled, stroked, lineWidthUnits, lineWidthScale, lineWidthMinPixels, lineWidthMaxPixels, lineJointRounded, lineMiterLimit, lineDashJustified, getElevation, getFillColor, getLineColor, getLineWidth } = this.props;
254
+ const { updateTriggers, material, transitions } = this.props;
255
+ const CellLayer = this.getSubLayerClass("cell", import_layers3.PolygonLayer);
256
+ const { updateTriggers: boundsUpdateTriggers, ...boundsProps } = this.indexToBounds() || {};
257
+ return new CellLayer({
258
+ filled,
259
+ wireframe,
260
+ extruded,
261
+ elevationScale,
262
+ stroked,
263
+ lineWidthUnits,
264
+ lineWidthScale,
265
+ lineWidthMinPixels,
266
+ lineWidthMaxPixels,
267
+ lineJointRounded,
268
+ lineMiterLimit,
269
+ lineDashJustified,
270
+ material,
271
+ transitions,
272
+ getElevation,
273
+ getFillColor,
274
+ getLineColor,
275
+ getLineWidth
276
+ }, this.getSubLayerProps({
277
+ id: "cell",
278
+ updateTriggers: updateTriggers && {
279
+ ...boundsUpdateTriggers,
280
+ getElevation: updateTriggers.getElevation,
281
+ getFillColor: updateTriggers.getFillColor,
282
+ getLineColor: updateTriggers.getLineColor,
283
+ getLineWidth: updateTriggers.getLineWidth
284
+ }
285
+ }), boundsProps);
286
+ }
287
+ };
288
+ var GeoCellLayer = _GeoCellLayer;
289
+ (() => {
290
+ _GeoCellLayer.layerName = "GeoCellLayer";
291
+ })();
292
+ (() => {
293
+ _GeoCellLayer.defaultProps = defaultProps3;
294
+ })();
295
+
296
+ // dist/s2-layer/s2-geometry.js
297
+ var import_long = __toESM(require("long"), 1);
298
+ var FACE_BITS = 3;
299
+ var MAX_LEVEL = 30;
300
+ var POS_BITS = 2 * MAX_LEVEL + 1;
301
+ var RADIAN_TO_DEGREE = 180 / Math.PI;
302
+ function IJToST(ij, order, offsets) {
303
+ const maxSize = 1 << order;
304
+ return [(ij[0] + offsets[0]) / maxSize, (ij[1] + offsets[1]) / maxSize];
305
+ }
306
+ function singleSTtoUV(st) {
307
+ if (st >= 0.5) {
308
+ return 1 / 3 * (4 * st * st - 1);
309
+ }
310
+ return 1 / 3 * (1 - 4 * (1 - st) * (1 - st));
311
+ }
312
+ function STToUV(st) {
313
+ return [singleSTtoUV(st[0]), singleSTtoUV(st[1])];
314
+ }
315
+ function FaceUVToXYZ(face, [u, v]) {
316
+ switch (face) {
317
+ case 0:
318
+ return [1, u, v];
319
+ case 1:
320
+ return [-u, 1, v];
321
+ case 2:
322
+ return [-u, -v, 1];
323
+ case 3:
324
+ return [-1, -v, -u];
325
+ case 4:
326
+ return [v, -1, -u];
327
+ case 5:
328
+ return [v, u, -1];
329
+ default:
330
+ throw new Error("Invalid face");
331
+ }
332
+ }
333
+ function XYZToLngLat([x, y, z]) {
334
+ const lat = Math.atan2(z, Math.sqrt(x * x + y * y));
335
+ const lng = Math.atan2(y, x);
336
+ return [lng * RADIAN_TO_DEGREE, lat * RADIAN_TO_DEGREE];
337
+ }
338
+ function toHilbertQuadkey(idS) {
339
+ let bin = import_long.default.fromString(idS, true, 10).toString(2);
340
+ while (bin.length < FACE_BITS + POS_BITS) {
341
+ bin = "0" + bin;
342
+ }
343
+ const lsbIndex = bin.lastIndexOf("1");
344
+ const faceB = bin.substring(0, 3);
345
+ const posB = bin.substring(3, lsbIndex);
346
+ const levelN = posB.length / 2;
347
+ const faceS = import_long.default.fromString(faceB, true, 2).toString(10);
348
+ let posS = import_long.default.fromString(posB, true, 2).toString(4);
349
+ while (posS.length < levelN) {
350
+ posS = "0" + posS;
351
+ }
352
+ return `${faceS}/${posS}`;
353
+ }
354
+ function rotateAndFlipQuadrant(n, point, rx, ry) {
355
+ if (ry === 0) {
356
+ if (rx === 1) {
357
+ point[0] = n - 1 - point[0];
358
+ point[1] = n - 1 - point[1];
359
+ }
360
+ const x = point[0];
361
+ point[0] = point[1];
362
+ point[1] = x;
363
+ }
364
+ }
365
+ function FromHilbertQuadKey(hilbertQuadkey) {
366
+ const parts = hilbertQuadkey.split("/");
367
+ const face = parseInt(parts[0], 10);
368
+ const position = parts[1];
369
+ const maxLevel = position.length;
370
+ const point = [0, 0];
371
+ let level;
372
+ for (let i = maxLevel - 1; i >= 0; i--) {
373
+ level = maxLevel - i;
374
+ const bit = position[i];
375
+ let rx = 0;
376
+ let ry = 0;
377
+ if (bit === "1") {
378
+ ry = 1;
379
+ } else if (bit === "2") {
380
+ rx = 1;
381
+ ry = 1;
382
+ } else if (bit === "3") {
383
+ rx = 1;
384
+ }
385
+ const val = Math.pow(2, level - 1);
386
+ rotateAndFlipQuadrant(val, point, rx, ry);
387
+ point[0] += val * rx;
388
+ point[1] += val * ry;
389
+ }
390
+ if (face % 2 === 1) {
391
+ const t = point[0];
392
+ point[0] = point[1];
393
+ point[1] = t;
394
+ }
395
+ return { face, ij: point, level };
396
+ }
397
+
398
+ // dist/s2-layer/s2-utils.js
399
+ var import_long2 = __toESM(require("long"), 1);
400
+ function getIdFromToken(token) {
401
+ const paddedToken = token.padEnd(16, "0");
402
+ return import_long2.default.fromString(paddedToken, 16);
403
+ }
404
+ var MAX_RESOLUTION = 100;
405
+ function getGeoBounds({ face, ij, level }) {
406
+ const offsets = [
407
+ [0, 0],
408
+ [0, 1],
409
+ [1, 1],
410
+ [1, 0],
411
+ [0, 0]
412
+ ];
413
+ const resolution = Math.max(1, Math.ceil(MAX_RESOLUTION * Math.pow(2, -level)));
414
+ const result = new Float64Array(4 * resolution * 2 + 2);
415
+ let ptIndex = 0;
416
+ let prevLng = 0;
417
+ for (let i = 0; i < 4; i++) {
418
+ const offset = offsets[i].slice(0);
419
+ const nextOffset = offsets[i + 1];
420
+ const stepI = (nextOffset[0] - offset[0]) / resolution;
421
+ const stepJ = (nextOffset[1] - offset[1]) / resolution;
422
+ for (let j = 0; j < resolution; j++) {
423
+ offset[0] += stepI;
424
+ offset[1] += stepJ;
425
+ const st = IJToST(ij, level, offset);
426
+ const uv = STToUV(st);
427
+ const xyz = FaceUVToXYZ(face, uv);
428
+ const lngLat = XYZToLngLat(xyz);
429
+ if (Math.abs(lngLat[1]) > 89.999) {
430
+ lngLat[0] = prevLng;
431
+ }
432
+ const deltaLng = lngLat[0] - prevLng;
433
+ lngLat[0] += deltaLng > 180 ? -360 : deltaLng < -180 ? 360 : 0;
434
+ result[ptIndex++] = lngLat[0];
435
+ result[ptIndex++] = lngLat[1];
436
+ prevLng = lngLat[0];
437
+ }
438
+ }
439
+ result[ptIndex++] = result[0];
440
+ result[ptIndex++] = result[1];
441
+ return result;
442
+ }
443
+ function getS2QuadKey(token) {
444
+ if (typeof token === "string") {
445
+ if (token.indexOf("/") > 0) {
446
+ return token;
447
+ }
448
+ token = getIdFromToken(token);
449
+ }
450
+ return toHilbertQuadkey(token.toString());
451
+ }
452
+ function getS2Polygon(token) {
453
+ const key = getS2QuadKey(token);
454
+ const s2cell = FromHilbertQuadKey(key);
455
+ return getGeoBounds(s2cell);
456
+ }
457
+
458
+ // dist/s2-layer/s2-layer.js
459
+ var defaultProps4 = {
460
+ getS2Token: { type: "accessor", value: (d) => d.token }
461
+ };
462
+ var _S2Layer = class extends GeoCellLayer {
463
+ indexToBounds() {
464
+ const { data, getS2Token } = this.props;
465
+ return {
466
+ data,
467
+ _normalize: false,
468
+ positionFormat: "XY",
469
+ getPolygon: (x, objectInfo) => getS2Polygon(getS2Token(x, objectInfo))
470
+ };
471
+ }
472
+ };
473
+ var S2Layer = _S2Layer;
474
+ (() => {
475
+ _S2Layer.layerName = "S2Layer";
476
+ })();
477
+ (() => {
478
+ _S2Layer.defaultProps = defaultProps4;
479
+ })();
480
+
481
+ // dist/quadkey-layer/quadkey-utils.js
482
+ var import_web_mercator2 = require("@math.gl/web-mercator");
483
+ var TILE_SIZE = 512;
484
+ function quadkeyToWorldBounds(quadkey, coverage) {
485
+ let x = 0;
486
+ let y = 0;
487
+ let mask = 1 << quadkey.length;
488
+ const scale = mask / TILE_SIZE;
489
+ for (let i = 0; i < quadkey.length; i++) {
490
+ mask >>= 1;
491
+ const q = parseInt(quadkey[i]);
492
+ if (q % 2)
493
+ x |= mask;
494
+ if (q > 1)
495
+ y |= mask;
496
+ }
497
+ return [
498
+ [x / scale, TILE_SIZE - y / scale],
499
+ [(x + coverage) / scale, TILE_SIZE - (y + coverage) / scale]
500
+ ];
501
+ }
502
+ function getQuadkeyPolygon(quadkey, coverage = 1) {
503
+ const [topLeft, bottomRight] = quadkeyToWorldBounds(quadkey, coverage);
504
+ const [w, n] = (0, import_web_mercator2.worldToLngLat)(topLeft);
505
+ const [e, s] = (0, import_web_mercator2.worldToLngLat)(bottomRight);
506
+ return [e, n, e, s, w, s, w, n, e, n];
507
+ }
508
+
509
+ // dist/quadkey-layer/quadkey-layer.js
510
+ var defaultProps5 = {
511
+ getQuadkey: { type: "accessor", value: (d) => d.quadkey }
512
+ };
513
+ var _QuadkeyLayer = class extends GeoCellLayer {
514
+ indexToBounds() {
515
+ const { data, extruded, getQuadkey } = this.props;
516
+ const coverage = extruded ? 0.99 : 1;
517
+ return {
518
+ data,
519
+ _normalize: false,
520
+ positionFormat: "XY",
521
+ getPolygon: (x, objectInfo) => getQuadkeyPolygon(getQuadkey(x, objectInfo), coverage),
522
+ updateTriggers: { getPolygon: coverage }
523
+ };
524
+ }
525
+ };
526
+ var QuadkeyLayer = _QuadkeyLayer;
527
+ (() => {
528
+ _QuadkeyLayer.layerName = "QuadkeyLayer";
529
+ })();
530
+ (() => {
531
+ _QuadkeyLayer.defaultProps = defaultProps5;
532
+ })();
533
+
534
+ // dist/tile-layer/tile-layer.js
535
+ var import_core5 = require("@deck.gl/core");
536
+ var import_layers4 = require("@deck.gl/layers");
537
+
538
+ // dist/tileset-2d/tileset-2d.js
539
+ var import_loader_utils = require("@loaders.gl/loader-utils");
540
+ var import_core4 = require("@math.gl/core");
541
+
542
+ // dist/tileset-2d/tile-2d-header.js
543
+ var Tile2DHeader = class {
544
+ constructor(index) {
545
+ this.index = index;
546
+ this.isVisible = false;
547
+ this.isSelected = false;
548
+ this.parent = null;
549
+ this.children = [];
550
+ this.content = null;
551
+ this._loader = void 0;
552
+ this._abortController = null;
553
+ this._loaderId = 0;
554
+ this._isLoaded = false;
555
+ this._isCancelled = false;
556
+ this._needsReload = false;
557
+ }
558
+ get bbox() {
559
+ return this._bbox;
560
+ }
561
+ set bbox(value) {
562
+ if (this._bbox)
563
+ return;
564
+ this._bbox = value;
565
+ if ("west" in value) {
566
+ this.boundingBox = [
567
+ [value.west, value.south],
568
+ [value.east, value.north]
569
+ ];
570
+ } else {
571
+ this.boundingBox = [
572
+ [value.left, value.top],
573
+ [value.right, value.bottom]
574
+ ];
575
+ }
576
+ }
577
+ get data() {
578
+ return this.isLoading && this._loader ? this._loader.then(() => this.data) : this.content;
579
+ }
580
+ get isLoaded() {
581
+ return this._isLoaded && !this._needsReload;
582
+ }
583
+ get isLoading() {
584
+ return Boolean(this._loader) && !this._isCancelled;
585
+ }
586
+ get needsReload() {
587
+ return this._needsReload || this._isCancelled;
588
+ }
589
+ get byteLength() {
590
+ const result = this.content ? this.content.byteLength : 0;
591
+ if (!Number.isFinite(result)) {
592
+ console.error("byteLength not defined in tile data");
593
+ }
594
+ return result;
595
+ }
596
+ async _loadData({ getData, requestScheduler, onLoad, onError }) {
597
+ const { index, id, bbox, userData, zoom } = this;
598
+ const loaderId = this._loaderId;
599
+ this._abortController = new AbortController();
600
+ const { signal } = this._abortController;
601
+ const requestToken = await requestScheduler.scheduleRequest(this, (tile) => {
602
+ return tile.isSelected ? 1 : -1;
603
+ });
604
+ if (!requestToken) {
605
+ this._isCancelled = true;
606
+ return;
607
+ }
608
+ if (this._isCancelled) {
609
+ requestToken.done();
610
+ return;
611
+ }
612
+ let tileData = null;
613
+ let error;
614
+ try {
615
+ tileData = await getData({ index, id, bbox, userData, zoom, signal });
616
+ } catch (err) {
617
+ error = err || true;
618
+ } finally {
619
+ requestToken.done();
620
+ }
621
+ if (loaderId !== this._loaderId) {
622
+ return;
623
+ }
624
+ this._loader = void 0;
625
+ this.content = tileData;
626
+ if (this._isCancelled && !tileData) {
627
+ this._isLoaded = false;
628
+ return;
629
+ }
630
+ this._isLoaded = true;
631
+ this._isCancelled = false;
632
+ if (error) {
633
+ onError(error, this);
634
+ } else {
635
+ onLoad(this);
636
+ }
637
+ }
638
+ loadData(opts) {
639
+ this._isLoaded = false;
640
+ this._isCancelled = false;
641
+ this._needsReload = false;
642
+ this._loaderId++;
643
+ this._loader = this._loadData(opts);
644
+ return this._loader;
645
+ }
646
+ setNeedsReload() {
647
+ if (this.isLoading) {
648
+ this.abort();
649
+ this._loader = void 0;
650
+ }
651
+ this._needsReload = true;
652
+ }
653
+ abort() {
654
+ var _a;
655
+ if (this.isLoaded) {
656
+ return;
657
+ }
658
+ this._isCancelled = true;
659
+ (_a = this._abortController) == null ? void 0 : _a.abort();
660
+ }
661
+ };
662
+
663
+ // dist/tileset-2d/tile-2d-traversal.js
664
+ var import_core3 = require("@deck.gl/core");
665
+ var import_culling = require("@math.gl/culling");
666
+ var import_web_mercator3 = require("@math.gl/web-mercator");
667
+ var TILE_SIZE2 = 512;
668
+ var MAX_MAPS = 3;
669
+ var REF_POINTS_5 = [
670
+ [0.5, 0.5],
671
+ [0, 0],
672
+ [0, 1],
673
+ [1, 0],
674
+ [1, 1]
675
+ ];
676
+ var REF_POINTS_9 = REF_POINTS_5.concat([
677
+ [0, 0.5],
678
+ [0.5, 0],
679
+ [1, 0.5],
680
+ [0.5, 1]
681
+ ]);
682
+ var REF_POINTS_11 = REF_POINTS_9.concat([
683
+ [0.25, 0.5],
684
+ [0.75, 0.5]
685
+ ]);
686
+ var OSMNode = class {
687
+ constructor(x, y, z) {
688
+ this.x = x;
689
+ this.y = y;
690
+ this.z = z;
691
+ }
692
+ get children() {
693
+ if (!this._children) {
694
+ const x = this.x * 2;
695
+ const y = this.y * 2;
696
+ const z = this.z + 1;
697
+ this._children = [
698
+ new OSMNode(x, y, z),
699
+ new OSMNode(x, y + 1, z),
700
+ new OSMNode(x + 1, y, z),
701
+ new OSMNode(x + 1, y + 1, z)
702
+ ];
703
+ }
704
+ return this._children;
705
+ }
706
+ update(params) {
707
+ const { viewport, cullingVolume, elevationBounds, minZ, maxZ, bounds, offset, project } = params;
708
+ const boundingVolume = this.getBoundingVolume(elevationBounds, offset, project);
709
+ if (bounds && !this.insideBounds(bounds)) {
710
+ return false;
711
+ }
712
+ const isInside = cullingVolume.computeVisibility(boundingVolume);
713
+ if (isInside < 0) {
714
+ return false;
715
+ }
716
+ if (!this.childVisible) {
717
+ let { z } = this;
718
+ if (z < maxZ && z >= minZ) {
719
+ const distance = boundingVolume.distanceTo(viewport.cameraPosition) * viewport.scale / viewport.height;
720
+ z += Math.floor(Math.log2(distance));
721
+ }
722
+ if (z >= maxZ) {
723
+ this.selected = true;
724
+ return true;
725
+ }
726
+ }
727
+ this.selected = false;
728
+ this.childVisible = true;
729
+ for (const child of this.children) {
730
+ child.update(params);
731
+ }
732
+ return true;
733
+ }
734
+ getSelected(result = []) {
735
+ if (this.selected) {
736
+ result.push(this);
737
+ }
738
+ if (this._children) {
739
+ for (const node of this._children) {
740
+ node.getSelected(result);
741
+ }
742
+ }
743
+ return result;
744
+ }
745
+ insideBounds([minX, minY, maxX, maxY]) {
746
+ const scale = Math.pow(2, this.z);
747
+ const extent = TILE_SIZE2 / scale;
748
+ return this.x * extent < maxX && this.y * extent < maxY && (this.x + 1) * extent > minX && (this.y + 1) * extent > minY;
749
+ }
750
+ getBoundingVolume(zRange, worldOffset, project) {
751
+ if (project) {
752
+ const refPoints = this.z < 1 ? REF_POINTS_11 : this.z < 2 ? REF_POINTS_9 : REF_POINTS_5;
753
+ const refPointPositions = [];
754
+ for (const p of refPoints) {
755
+ const lngLat = osmTile2lngLat(this.x + p[0], this.y + p[1], this.z);
756
+ lngLat[2] = zRange[0];
757
+ refPointPositions.push(project(lngLat));
758
+ if (zRange[0] !== zRange[1]) {
759
+ lngLat[2] = zRange[1];
760
+ refPointPositions.push(project(lngLat));
761
+ }
762
+ }
763
+ return (0, import_culling.makeOrientedBoundingBoxFromPoints)(refPointPositions);
764
+ }
765
+ const scale = Math.pow(2, this.z);
766
+ const extent = TILE_SIZE2 / scale;
767
+ const originX = this.x * extent + worldOffset * TILE_SIZE2;
768
+ const originY = TILE_SIZE2 - (this.y + 1) * extent;
769
+ return new import_culling.AxisAlignedBoundingBox([originX, originY, zRange[0]], [originX + extent, originY + extent, zRange[1]]);
770
+ }
771
+ };
772
+ function getOSMTileIndices(viewport, maxZ, zRange, bounds) {
773
+ const project = viewport instanceof import_core3._GlobeViewport && viewport.resolution ? viewport.projectPosition : null;
774
+ const planes = Object.values(viewport.getFrustumPlanes()).map(({ normal, distance }) => new import_culling.Plane(normal.clone().negate(), distance));
775
+ const cullingVolume = new import_culling.CullingVolume(planes);
776
+ const unitsPerMeter = viewport.distanceScales.unitsPerMeter[2];
777
+ const elevationMin = zRange && zRange[0] * unitsPerMeter || 0;
778
+ const elevationMax = zRange && zRange[1] * unitsPerMeter || 0;
779
+ const minZ = viewport instanceof import_core3.WebMercatorViewport && viewport.pitch <= 60 ? maxZ : 0;
780
+ if (bounds) {
781
+ const [minLng, minLat, maxLng, maxLat] = bounds;
782
+ const topLeft = (0, import_web_mercator3.lngLatToWorld)([minLng, maxLat]);
783
+ const bottomRight = (0, import_web_mercator3.lngLatToWorld)([maxLng, minLat]);
784
+ bounds = [topLeft[0], TILE_SIZE2 - topLeft[1], bottomRight[0], TILE_SIZE2 - bottomRight[1]];
785
+ }
786
+ const root = new OSMNode(0, 0, 0);
787
+ const traversalParams = {
788
+ viewport,
789
+ project,
790
+ cullingVolume,
791
+ elevationBounds: [elevationMin, elevationMax],
792
+ minZ,
793
+ maxZ,
794
+ bounds,
795
+ offset: 0
796
+ };
797
+ root.update(traversalParams);
798
+ if (viewport instanceof import_core3.WebMercatorViewport && viewport.subViewports && viewport.subViewports.length > 1) {
799
+ traversalParams.offset = -1;
800
+ while (root.update(traversalParams)) {
801
+ if (--traversalParams.offset < -MAX_MAPS) {
802
+ break;
803
+ }
804
+ }
805
+ traversalParams.offset = 1;
806
+ while (root.update(traversalParams)) {
807
+ if (++traversalParams.offset > MAX_MAPS) {
808
+ break;
809
+ }
810
+ }
811
+ }
812
+ return root.getSelected();
813
+ }
814
+
815
+ // dist/tileset-2d/utils.js
816
+ var TILE_SIZE3 = 512;
817
+ var DEFAULT_EXTENT = [-Infinity, -Infinity, Infinity, Infinity];
818
+ var urlType = {
819
+ type: "object",
820
+ value: null,
821
+ validate: (value, propType) => propType.optional && value === null || typeof value === "string" || Array.isArray(value) && value.every((url) => typeof url === "string"),
822
+ equal: (value1, value2) => {
823
+ if (value1 === value2) {
824
+ return true;
825
+ }
826
+ if (!Array.isArray(value1) || !Array.isArray(value2)) {
827
+ return false;
828
+ }
829
+ const len = value1.length;
830
+ if (len !== value2.length) {
831
+ return false;
832
+ }
833
+ for (let i = 0; i < len; i++) {
834
+ if (value1[i] !== value2[i]) {
835
+ return false;
836
+ }
837
+ }
838
+ return true;
839
+ }
840
+ };
841
+ function transformBox(bbox, modelMatrix) {
842
+ const transformedCoords = [
843
+ modelMatrix.transformAsPoint([bbox[0], bbox[1]]),
844
+ modelMatrix.transformAsPoint([bbox[2], bbox[1]]),
845
+ modelMatrix.transformAsPoint([bbox[0], bbox[3]]),
846
+ modelMatrix.transformAsPoint([bbox[2], bbox[3]])
847
+ ];
848
+ const transformedBox = [
849
+ Math.min(...transformedCoords.map((i) => i[0])),
850
+ Math.min(...transformedCoords.map((i) => i[1])),
851
+ Math.max(...transformedCoords.map((i) => i[0])),
852
+ Math.max(...transformedCoords.map((i) => i[1]))
853
+ ];
854
+ return transformedBox;
855
+ }
856
+ function stringHash(s) {
857
+ return Math.abs(s.split("").reduce((a, b) => (a << 5) - a + b.charCodeAt(0) | 0, 0));
858
+ }
859
+ function getURLFromTemplate(template, tile) {
860
+ if (!template || !template.length) {
861
+ return null;
862
+ }
863
+ const { index, id } = tile;
864
+ if (Array.isArray(template)) {
865
+ const i = stringHash(id) % template.length;
866
+ template = template[i];
867
+ }
868
+ let url = template;
869
+ for (const key of Object.keys(index)) {
870
+ const regex = new RegExp(`{${key}}`, "g");
871
+ url = url.replace(regex, String(index[key]));
872
+ }
873
+ if (Number.isInteger(index.y) && Number.isInteger(index.z)) {
874
+ url = url.replace(/\{-y\}/g, String(Math.pow(2, index.z) - index.y - 1));
875
+ }
876
+ return url;
877
+ }
878
+ function getBoundingBox(viewport, zRange, extent) {
879
+ let bounds;
880
+ if (zRange && zRange.length === 2) {
881
+ const [minZ, maxZ] = zRange;
882
+ const bounds0 = viewport.getBounds({ z: minZ });
883
+ const bounds1 = viewport.getBounds({ z: maxZ });
884
+ bounds = [
885
+ Math.min(bounds0[0], bounds1[0]),
886
+ Math.min(bounds0[1], bounds1[1]),
887
+ Math.max(bounds0[2], bounds1[2]),
888
+ Math.max(bounds0[3], bounds1[3])
889
+ ];
890
+ } else {
891
+ bounds = viewport.getBounds();
892
+ }
893
+ if (!viewport.isGeospatial) {
894
+ return [
895
+ Math.max(Math.min(bounds[0], extent[2]), extent[0]),
896
+ Math.max(Math.min(bounds[1], extent[3]), extent[1]),
897
+ Math.min(Math.max(bounds[2], extent[0]), extent[2]),
898
+ Math.min(Math.max(bounds[3], extent[1]), extent[3])
899
+ ];
900
+ }
901
+ return [
902
+ Math.max(bounds[0], extent[0]),
903
+ Math.max(bounds[1], extent[1]),
904
+ Math.min(bounds[2], extent[2]),
905
+ Math.min(bounds[3], extent[3])
906
+ ];
907
+ }
908
+ function getCullBounds({ viewport, z, cullRect }) {
909
+ const subViewports = viewport.subViewports || [viewport];
910
+ return subViewports.map((v) => getCullBoundsInViewport(v, z || 0, cullRect));
911
+ }
912
+ function getCullBoundsInViewport(viewport, z, cullRect) {
913
+ if (!Array.isArray(z)) {
914
+ const x = cullRect.x - viewport.x;
915
+ const y = cullRect.y - viewport.y;
916
+ const { width, height } = cullRect;
917
+ const unprojectOption = { targetZ: z };
918
+ const topLeft = viewport.unproject([x, y], unprojectOption);
919
+ const topRight = viewport.unproject([x + width, y], unprojectOption);
920
+ const bottomLeft = viewport.unproject([x, y + height], unprojectOption);
921
+ const bottomRight = viewport.unproject([x + width, y + height], unprojectOption);
922
+ return [
923
+ Math.min(topLeft[0], topRight[0], bottomLeft[0], bottomRight[0]),
924
+ Math.min(topLeft[1], topRight[1], bottomLeft[1], bottomRight[1]),
925
+ Math.max(topLeft[0], topRight[0], bottomLeft[0], bottomRight[0]),
926
+ Math.max(topLeft[1], topRight[1], bottomLeft[1], bottomRight[1])
927
+ ];
928
+ }
929
+ const bounds0 = getCullBoundsInViewport(viewport, z[0], cullRect);
930
+ const bounds1 = getCullBoundsInViewport(viewport, z[1], cullRect);
931
+ return [
932
+ Math.min(bounds0[0], bounds1[0]),
933
+ Math.min(bounds0[1], bounds1[1]),
934
+ Math.max(bounds0[2], bounds1[2]),
935
+ Math.max(bounds0[3], bounds1[3])
936
+ ];
937
+ }
938
+ function getIndexingCoords(bbox, scale, modelMatrixInverse) {
939
+ if (modelMatrixInverse) {
940
+ const transformedTileIndex = transformBox(bbox, modelMatrixInverse).map((i) => i * scale / TILE_SIZE3);
941
+ return transformedTileIndex;
942
+ }
943
+ return bbox.map((i) => i * scale / TILE_SIZE3);
944
+ }
945
+ function getScale(z, tileSize) {
946
+ return Math.pow(2, z) * TILE_SIZE3 / tileSize;
947
+ }
948
+ function osmTile2lngLat(x, y, z) {
949
+ const scale = getScale(z, TILE_SIZE3);
950
+ const lng = x / scale * 360 - 180;
951
+ const n = Math.PI - 2 * Math.PI * y / scale;
952
+ const lat = 180 / Math.PI * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n)));
953
+ return [lng, lat];
954
+ }
955
+ function tile2XY(x, y, z, tileSize) {
956
+ const scale = getScale(z, tileSize);
957
+ return [x / scale * TILE_SIZE3, y / scale * TILE_SIZE3];
958
+ }
959
+ function tileToBoundingBox(viewport, x, y, z, tileSize = TILE_SIZE3) {
960
+ if (viewport.isGeospatial) {
961
+ const [west, north] = osmTile2lngLat(x, y, z);
962
+ const [east, south] = osmTile2lngLat(x + 1, y + 1, z);
963
+ return { west, north, east, south };
964
+ }
965
+ const [left, top] = tile2XY(x, y, z, tileSize);
966
+ const [right, bottom] = tile2XY(x + 1, y + 1, z, tileSize);
967
+ return { left, top, right, bottom };
968
+ }
969
+ function getIdentityTileIndices(viewport, z, tileSize, extent, modelMatrixInverse) {
970
+ const bbox = getBoundingBox(viewport, null, extent);
971
+ const scale = getScale(z, tileSize);
972
+ const [minX, minY, maxX, maxY] = getIndexingCoords(bbox, scale, modelMatrixInverse);
973
+ const indices = [];
974
+ for (let x = Math.floor(minX); x < maxX; x++) {
975
+ for (let y = Math.floor(minY); y < maxY; y++) {
976
+ indices.push({ x, y, z });
977
+ }
978
+ }
979
+ return indices;
980
+ }
981
+ function getTileIndices({ viewport, maxZoom, minZoom, zRange, extent, tileSize = TILE_SIZE3, modelMatrix, modelMatrixInverse, zoomOffset = 0 }) {
982
+ let z = viewport.isGeospatial ? Math.round(viewport.zoom + Math.log2(TILE_SIZE3 / tileSize)) + zoomOffset : Math.ceil(viewport.zoom) + zoomOffset;
983
+ if (typeof minZoom === "number" && Number.isFinite(minZoom) && z < minZoom) {
984
+ if (!extent) {
985
+ return [];
986
+ }
987
+ z = minZoom;
988
+ }
989
+ if (typeof maxZoom === "number" && Number.isFinite(maxZoom) && z > maxZoom) {
990
+ z = maxZoom;
991
+ }
992
+ let transformedExtent = extent;
993
+ if (modelMatrix && modelMatrixInverse && extent && !viewport.isGeospatial) {
994
+ transformedExtent = transformBox(extent, modelMatrix);
995
+ }
996
+ return viewport.isGeospatial ? getOSMTileIndices(viewport, z, zRange, extent) : getIdentityTileIndices(viewport, z, tileSize, transformedExtent || DEFAULT_EXTENT, modelMatrixInverse);
997
+ }
998
+ function isURLTemplate(s) {
999
+ return /(?=.*{z})(?=.*{x})(?=.*({y}|{-y}))/.test(s);
1000
+ }
1001
+ function isGeoBoundingBox(v) {
1002
+ return Number.isFinite(v.west) && Number.isFinite(v.north) && Number.isFinite(v.east) && Number.isFinite(v.south);
1003
+ }
1004
+
1005
+ // dist/tileset-2d/memoize.js
1006
+ function memoize(compute) {
1007
+ let cachedArgs = {};
1008
+ let cachedResult;
1009
+ return (args) => {
1010
+ for (const key in args) {
1011
+ if (!isEqual(args[key], cachedArgs[key])) {
1012
+ cachedResult = compute(args);
1013
+ cachedArgs = args;
1014
+ break;
1015
+ }
1016
+ }
1017
+ return cachedResult;
1018
+ };
1019
+ }
1020
+ function isEqual(a, b) {
1021
+ if (a === b) {
1022
+ return true;
1023
+ }
1024
+ if (Array.isArray(a)) {
1025
+ const len = a.length;
1026
+ if (!b || b.length !== len) {
1027
+ return false;
1028
+ }
1029
+ for (let i = 0; i < len; i++) {
1030
+ if (a[i] !== b[i]) {
1031
+ return false;
1032
+ }
1033
+ }
1034
+ return true;
1035
+ }
1036
+ return false;
1037
+ }
1038
+
1039
+ // dist/tileset-2d/tileset-2d.js
1040
+ var TILE_STATE_VISITED = 1;
1041
+ var TILE_STATE_VISIBLE = 2;
1042
+ var STRATEGY_NEVER = "never";
1043
+ var STRATEGY_REPLACE = "no-overlap";
1044
+ var STRATEGY_DEFAULT = "best-available";
1045
+ var DEFAULT_CACHE_SCALE = 5;
1046
+ var STRATEGIES = {
1047
+ [STRATEGY_DEFAULT]: updateTileStateDefault,
1048
+ [STRATEGY_REPLACE]: updateTileStateReplace,
1049
+ [STRATEGY_NEVER]: () => {
1050
+ }
1051
+ };
1052
+ var DEFAULT_TILESET2D_PROPS = {
1053
+ extent: null,
1054
+ tileSize: 512,
1055
+ maxZoom: null,
1056
+ minZoom: null,
1057
+ maxCacheSize: null,
1058
+ maxCacheByteSize: null,
1059
+ refinementStrategy: "best-available",
1060
+ zRange: null,
1061
+ maxRequests: 6,
1062
+ debounceTime: 0,
1063
+ zoomOffset: 0,
1064
+ onTileLoad: () => {
1065
+ },
1066
+ onTileUnload: () => {
1067
+ },
1068
+ onTileError: () => {
1069
+ }
1070
+ };
1071
+ var Tileset2D = class {
1072
+ constructor(opts) {
1073
+ this._getCullBounds = memoize(getCullBounds);
1074
+ this.opts = { ...DEFAULT_TILESET2D_PROPS, ...opts };
1075
+ this.setOptions(this.opts);
1076
+ this.onTileLoad = (tile) => {
1077
+ var _a, _b;
1078
+ (_b = (_a = this.opts).onTileLoad) == null ? void 0 : _b.call(_a, tile);
1079
+ if (this.opts.maxCacheByteSize) {
1080
+ this._cacheByteSize += tile.byteLength;
1081
+ this._resizeCache();
1082
+ }
1083
+ };
1084
+ this._requestScheduler = new import_loader_utils.RequestScheduler({
1085
+ throttleRequests: this.opts.maxRequests > 0 || this.opts.debounceTime > 0,
1086
+ maxRequests: this.opts.maxRequests,
1087
+ debounceTime: this.opts.debounceTime
1088
+ });
1089
+ this._cache = /* @__PURE__ */ new Map();
1090
+ this._tiles = [];
1091
+ this._dirty = false;
1092
+ this._cacheByteSize = 0;
1093
+ this._viewport = null;
1094
+ this._zRange = null;
1095
+ this._selectedTiles = null;
1096
+ this._frameNumber = 0;
1097
+ this._modelMatrix = new import_core4.Matrix4();
1098
+ this._modelMatrixInverse = new import_core4.Matrix4();
1099
+ }
1100
+ get tiles() {
1101
+ return this._tiles;
1102
+ }
1103
+ get selectedTiles() {
1104
+ return this._selectedTiles;
1105
+ }
1106
+ get isLoaded() {
1107
+ return this._selectedTiles !== null && this._selectedTiles.every((tile) => tile.isLoaded);
1108
+ }
1109
+ get needsReload() {
1110
+ return this._selectedTiles !== null && this._selectedTiles.some((tile) => tile.needsReload);
1111
+ }
1112
+ setOptions(opts) {
1113
+ Object.assign(this.opts, opts);
1114
+ if (Number.isFinite(opts.maxZoom)) {
1115
+ this._maxZoom = Math.floor(opts.maxZoom);
1116
+ }
1117
+ if (Number.isFinite(opts.minZoom)) {
1118
+ this._minZoom = Math.ceil(opts.minZoom);
1119
+ }
1120
+ }
1121
+ finalize() {
1122
+ for (const tile of this._cache.values()) {
1123
+ if (tile.isLoading) {
1124
+ tile.abort();
1125
+ }
1126
+ }
1127
+ this._cache.clear();
1128
+ this._tiles = [];
1129
+ this._selectedTiles = null;
1130
+ }
1131
+ reloadAll() {
1132
+ for (const id of this._cache.keys()) {
1133
+ const tile = this._cache.get(id);
1134
+ if (!this._selectedTiles || !this._selectedTiles.includes(tile)) {
1135
+ this._cache.delete(id);
1136
+ } else {
1137
+ tile.setNeedsReload();
1138
+ }
1139
+ }
1140
+ }
1141
+ update(viewport, { zRange, modelMatrix } = {
1142
+ zRange: null,
1143
+ modelMatrix: null
1144
+ }) {
1145
+ const modelMatrixAsMatrix4 = modelMatrix ? new import_core4.Matrix4(modelMatrix) : new import_core4.Matrix4();
1146
+ const isModelMatrixNew = !modelMatrixAsMatrix4.equals(this._modelMatrix);
1147
+ if (!this._viewport || !viewport.equals(this._viewport) || !(0, import_core4.equals)(this._zRange, zRange) || isModelMatrixNew) {
1148
+ if (isModelMatrixNew) {
1149
+ this._modelMatrixInverse = modelMatrixAsMatrix4.clone().invert();
1150
+ this._modelMatrix = modelMatrixAsMatrix4;
1151
+ }
1152
+ this._viewport = viewport;
1153
+ this._zRange = zRange;
1154
+ const tileIndices = this.getTileIndices({
1155
+ viewport,
1156
+ maxZoom: this._maxZoom,
1157
+ minZoom: this._minZoom,
1158
+ zRange,
1159
+ modelMatrix: this._modelMatrix,
1160
+ modelMatrixInverse: this._modelMatrixInverse
1161
+ });
1162
+ this._selectedTiles = tileIndices.map((index) => this._getTile(index, true));
1163
+ if (this._dirty) {
1164
+ this._rebuildTree();
1165
+ }
1166
+ } else if (this.needsReload) {
1167
+ this._selectedTiles = this._selectedTiles.map((tile) => this._getTile(tile.index, true));
1168
+ }
1169
+ const changed = this.updateTileStates();
1170
+ this._pruneRequests();
1171
+ if (this._dirty) {
1172
+ this._resizeCache();
1173
+ }
1174
+ if (changed) {
1175
+ this._frameNumber++;
1176
+ }
1177
+ return this._frameNumber;
1178
+ }
1179
+ isTileVisible(tile, cullRect) {
1180
+ if (!tile.isVisible) {
1181
+ return false;
1182
+ }
1183
+ if (cullRect && this._viewport) {
1184
+ const boundsArr = this._getCullBounds({
1185
+ viewport: this._viewport,
1186
+ z: this._zRange,
1187
+ cullRect
1188
+ });
1189
+ const { bbox } = tile;
1190
+ for (const [minX, minY, maxX, maxY] of boundsArr) {
1191
+ let overlaps;
1192
+ if ("west" in bbox) {
1193
+ overlaps = bbox.west < maxX && bbox.east > minX && bbox.south < maxY && bbox.north > minY;
1194
+ } else {
1195
+ const y0 = Math.min(bbox.top, bbox.bottom);
1196
+ const y1 = Math.max(bbox.top, bbox.bottom);
1197
+ overlaps = bbox.left < maxX && bbox.right > minX && y0 < maxY && y1 > minY;
1198
+ }
1199
+ if (overlaps) {
1200
+ return true;
1201
+ }
1202
+ }
1203
+ return false;
1204
+ }
1205
+ return true;
1206
+ }
1207
+ getTileIndices({ viewport, maxZoom, minZoom, zRange, modelMatrix, modelMatrixInverse }) {
1208
+ const { tileSize, extent, zoomOffset } = this.opts;
1209
+ return getTileIndices({
1210
+ viewport,
1211
+ maxZoom,
1212
+ minZoom,
1213
+ zRange,
1214
+ tileSize,
1215
+ extent,
1216
+ modelMatrix,
1217
+ modelMatrixInverse,
1218
+ zoomOffset
1219
+ });
1220
+ }
1221
+ getTileId(index) {
1222
+ return `${index.x}-${index.y}-${index.z}`;
1223
+ }
1224
+ getTileZoom(index) {
1225
+ return index.z;
1226
+ }
1227
+ getTileMetadata(index) {
1228
+ const { tileSize } = this.opts;
1229
+ return { bbox: tileToBoundingBox(this._viewport, index.x, index.y, index.z, tileSize) };
1230
+ }
1231
+ getParentIndex(index) {
1232
+ const x = Math.floor(index.x / 2);
1233
+ const y = Math.floor(index.y / 2);
1234
+ const z = index.z - 1;
1235
+ return { x, y, z };
1236
+ }
1237
+ updateTileStates() {
1238
+ const refinementStrategy = this.opts.refinementStrategy || STRATEGY_DEFAULT;
1239
+ const visibilities = new Array(this._cache.size);
1240
+ let i = 0;
1241
+ for (const tile of this._cache.values()) {
1242
+ visibilities[i++] = tile.isVisible;
1243
+ tile.isSelected = false;
1244
+ tile.isVisible = false;
1245
+ }
1246
+ for (const tile of this._selectedTiles) {
1247
+ tile.isSelected = true;
1248
+ tile.isVisible = true;
1249
+ }
1250
+ (typeof refinementStrategy === "function" ? refinementStrategy : STRATEGIES[refinementStrategy])(Array.from(this._cache.values()));
1251
+ i = 0;
1252
+ for (const tile of this._cache.values()) {
1253
+ if (visibilities[i++] !== tile.isVisible) {
1254
+ return true;
1255
+ }
1256
+ }
1257
+ return false;
1258
+ }
1259
+ _pruneRequests() {
1260
+ const { maxRequests = 0 } = this.opts;
1261
+ const abortCandidates = [];
1262
+ let ongoingRequestCount = 0;
1263
+ for (const tile of this._cache.values()) {
1264
+ if (tile.isLoading) {
1265
+ ongoingRequestCount++;
1266
+ if (!tile.isSelected && !tile.isVisible) {
1267
+ abortCandidates.push(tile);
1268
+ }
1269
+ }
1270
+ }
1271
+ while (maxRequests > 0 && ongoingRequestCount > maxRequests && abortCandidates.length > 0) {
1272
+ const tile = abortCandidates.shift();
1273
+ tile.abort();
1274
+ ongoingRequestCount--;
1275
+ }
1276
+ }
1277
+ _rebuildTree() {
1278
+ const { _cache } = this;
1279
+ for (const tile of _cache.values()) {
1280
+ tile.parent = null;
1281
+ if (tile.children) {
1282
+ tile.children.length = 0;
1283
+ }
1284
+ }
1285
+ for (const tile of _cache.values()) {
1286
+ const parent = this._getNearestAncestor(tile);
1287
+ tile.parent = parent;
1288
+ if (parent == null ? void 0 : parent.children) {
1289
+ parent.children.push(tile);
1290
+ }
1291
+ }
1292
+ }
1293
+ _resizeCache() {
1294
+ var _a, _b;
1295
+ const { _cache, opts } = this;
1296
+ const maxCacheSize = opts.maxCacheSize || (opts.maxCacheByteSize ? Infinity : DEFAULT_CACHE_SCALE * this.selectedTiles.length);
1297
+ const maxCacheByteSize = opts.maxCacheByteSize || Infinity;
1298
+ const overflown = _cache.size > maxCacheSize || this._cacheByteSize > maxCacheByteSize;
1299
+ if (overflown) {
1300
+ for (const [id, tile] of _cache) {
1301
+ if (!tile.isVisible && !tile.isSelected) {
1302
+ this._cacheByteSize -= opts.maxCacheByteSize ? tile.byteLength : 0;
1303
+ _cache.delete(id);
1304
+ (_b = (_a = this.opts).onTileUnload) == null ? void 0 : _b.call(_a, tile);
1305
+ }
1306
+ if (_cache.size <= maxCacheSize && this._cacheByteSize <= maxCacheByteSize) {
1307
+ break;
1308
+ }
1309
+ }
1310
+ this._rebuildTree();
1311
+ this._dirty = true;
1312
+ }
1313
+ if (this._dirty) {
1314
+ this._tiles = Array.from(this._cache.values()).sort((t1, t2) => t1.zoom - t2.zoom);
1315
+ this._dirty = false;
1316
+ }
1317
+ }
1318
+ _getTile(index, create) {
1319
+ const id = this.getTileId(index);
1320
+ let tile = this._cache.get(id);
1321
+ let needsReload = false;
1322
+ if (!tile && create) {
1323
+ tile = new Tile2DHeader(index);
1324
+ Object.assign(tile, this.getTileMetadata(tile.index));
1325
+ Object.assign(tile, { id, zoom: this.getTileZoom(tile.index) });
1326
+ needsReload = true;
1327
+ this._cache.set(id, tile);
1328
+ this._dirty = true;
1329
+ } else if (tile && tile.needsReload) {
1330
+ needsReload = true;
1331
+ }
1332
+ if (tile && needsReload) {
1333
+ tile.loadData({
1334
+ getData: this.opts.getTileData,
1335
+ requestScheduler: this._requestScheduler,
1336
+ onLoad: this.onTileLoad,
1337
+ onError: this.opts.onTileError
1338
+ });
1339
+ }
1340
+ return tile;
1341
+ }
1342
+ _getNearestAncestor(tile) {
1343
+ const { _minZoom = 0 } = this;
1344
+ let index = tile.index;
1345
+ while (this.getTileZoom(index) > _minZoom) {
1346
+ index = this.getParentIndex(index);
1347
+ const parent = this._getTile(index);
1348
+ if (parent) {
1349
+ return parent;
1350
+ }
1351
+ }
1352
+ return null;
1353
+ }
1354
+ };
1355
+ function updateTileStateDefault(allTiles) {
1356
+ for (const tile of allTiles) {
1357
+ tile.state = 0;
1358
+ }
1359
+ for (const tile of allTiles) {
1360
+ if (tile.isSelected && !getPlaceholderInAncestors(tile)) {
1361
+ getPlaceholderInChildren(tile);
1362
+ }
1363
+ }
1364
+ for (const tile of allTiles) {
1365
+ tile.isVisible = Boolean(tile.state & TILE_STATE_VISIBLE);
1366
+ }
1367
+ }
1368
+ function updateTileStateReplace(allTiles) {
1369
+ for (const tile of allTiles) {
1370
+ tile.state = 0;
1371
+ }
1372
+ for (const tile of allTiles) {
1373
+ if (tile.isSelected) {
1374
+ getPlaceholderInAncestors(tile);
1375
+ }
1376
+ }
1377
+ const sortedTiles = Array.from(allTiles).sort((t1, t2) => t1.zoom - t2.zoom);
1378
+ for (const tile of sortedTiles) {
1379
+ tile.isVisible = Boolean(tile.state & TILE_STATE_VISIBLE);
1380
+ if (tile.children && (tile.isVisible || tile.state & TILE_STATE_VISITED)) {
1381
+ for (const child of tile.children) {
1382
+ child.state = TILE_STATE_VISITED;
1383
+ }
1384
+ } else if (tile.isSelected) {
1385
+ getPlaceholderInChildren(tile);
1386
+ }
1387
+ }
1388
+ }
1389
+ function getPlaceholderInAncestors(startTile) {
1390
+ let tile = startTile;
1391
+ while (tile) {
1392
+ if (tile.isLoaded || tile.content) {
1393
+ tile.state |= TILE_STATE_VISIBLE;
1394
+ return true;
1395
+ }
1396
+ tile = tile.parent;
1397
+ }
1398
+ return false;
1399
+ }
1400
+ function getPlaceholderInChildren(tile) {
1401
+ for (const child of tile.children) {
1402
+ if (child.isLoaded || child.content) {
1403
+ child.state |= TILE_STATE_VISIBLE;
1404
+ } else {
1405
+ getPlaceholderInChildren(child);
1406
+ }
1407
+ }
1408
+ }
1409
+
1410
+ // dist/tile-layer/tile-layer.js
1411
+ var defaultProps6 = {
1412
+ TilesetClass: Tileset2D,
1413
+ data: { type: "data", value: [] },
1414
+ dataComparator: urlType.equal,
1415
+ renderSubLayers: { type: "function", value: (props) => new import_layers4.GeoJsonLayer(props) },
1416
+ getTileData: { type: "function", optional: true, value: null },
1417
+ onViewportLoad: { type: "function", optional: true, value: null },
1418
+ onTileLoad: { type: "function", value: (tile) => {
1419
+ } },
1420
+ onTileUnload: { type: "function", value: (tile) => {
1421
+ } },
1422
+ onTileError: { type: "function", value: (err) => console.error(err) },
1423
+ extent: { type: "array", optional: true, value: null, compare: true },
1424
+ tileSize: 512,
1425
+ maxZoom: null,
1426
+ minZoom: 0,
1427
+ maxCacheSize: null,
1428
+ maxCacheByteSize: null,
1429
+ refinementStrategy: STRATEGY_DEFAULT,
1430
+ zRange: null,
1431
+ maxRequests: 6,
1432
+ debounceTime: 0,
1433
+ zoomOffset: 0
1434
+ };
1435
+ var _TileLayer = class extends import_core5.CompositeLayer {
1436
+ initializeState() {
1437
+ this.state = {
1438
+ tileset: null,
1439
+ isLoaded: false
1440
+ };
1441
+ }
1442
+ finalizeState() {
1443
+ var _a, _b;
1444
+ (_b = (_a = this.state) == null ? void 0 : _a.tileset) == null ? void 0 : _b.finalize();
1445
+ }
1446
+ get isLoaded() {
1447
+ var _a, _b, _c;
1448
+ return Boolean((_c = (_b = (_a = this.state) == null ? void 0 : _a.tileset) == null ? void 0 : _b.selectedTiles) == null ? void 0 : _c.every((tile) => tile.isLoaded && tile.layers && tile.layers.every((layer) => layer.isLoaded)));
1449
+ }
1450
+ shouldUpdateState({ changeFlags }) {
1451
+ return changeFlags.somethingChanged;
1452
+ }
1453
+ updateState({ changeFlags }) {
1454
+ let { tileset } = this.state;
1455
+ const propsChanged = changeFlags.propsOrDataChanged || changeFlags.updateTriggersChanged;
1456
+ const dataChanged = changeFlags.dataChanged || changeFlags.updateTriggersChanged && (changeFlags.updateTriggersChanged.all || changeFlags.updateTriggersChanged.getTileData);
1457
+ if (!tileset) {
1458
+ tileset = new this.props.TilesetClass(this._getTilesetOptions());
1459
+ this.setState({ tileset });
1460
+ } else if (propsChanged) {
1461
+ tileset.setOptions(this._getTilesetOptions());
1462
+ if (dataChanged) {
1463
+ tileset.reloadAll();
1464
+ } else {
1465
+ tileset.tiles.forEach((tile) => {
1466
+ tile.layers = null;
1467
+ });
1468
+ }
1469
+ }
1470
+ this._updateTileset();
1471
+ }
1472
+ _getTilesetOptions() {
1473
+ const { tileSize, maxCacheSize, maxCacheByteSize, refinementStrategy, extent, maxZoom, minZoom, maxRequests, debounceTime, zoomOffset } = this.props;
1474
+ return {
1475
+ maxCacheSize,
1476
+ maxCacheByteSize,
1477
+ maxZoom,
1478
+ minZoom,
1479
+ tileSize,
1480
+ refinementStrategy,
1481
+ extent,
1482
+ maxRequests,
1483
+ debounceTime,
1484
+ zoomOffset,
1485
+ getTileData: this.getTileData.bind(this),
1486
+ onTileLoad: this._onTileLoad.bind(this),
1487
+ onTileError: this._onTileError.bind(this),
1488
+ onTileUnload: this._onTileUnload.bind(this)
1489
+ };
1490
+ }
1491
+ _updateTileset() {
1492
+ const tileset = this.state.tileset;
1493
+ const { zRange, modelMatrix } = this.props;
1494
+ const frameNumber = tileset.update(this.context.viewport, { zRange, modelMatrix });
1495
+ const { isLoaded } = tileset;
1496
+ const loadingStateChanged = this.state.isLoaded !== isLoaded;
1497
+ const tilesetChanged = this.state.frameNumber !== frameNumber;
1498
+ if (isLoaded && (loadingStateChanged || tilesetChanged)) {
1499
+ this._onViewportLoad();
1500
+ }
1501
+ if (tilesetChanged) {
1502
+ this.setState({ frameNumber });
1503
+ }
1504
+ this.state.isLoaded = isLoaded;
1505
+ }
1506
+ _onViewportLoad() {
1507
+ const { tileset } = this.state;
1508
+ const { onViewportLoad } = this.props;
1509
+ if (onViewportLoad) {
1510
+ onViewportLoad(tileset.selectedTiles);
1511
+ }
1512
+ }
1513
+ _onTileLoad(tile) {
1514
+ this.props.onTileLoad(tile);
1515
+ tile.layers = null;
1516
+ this.setNeedsUpdate();
1517
+ }
1518
+ _onTileError(error, tile) {
1519
+ this.props.onTileError(error);
1520
+ tile.layers = null;
1521
+ this.setNeedsUpdate();
1522
+ }
1523
+ _onTileUnload(tile) {
1524
+ this.props.onTileUnload(tile);
1525
+ }
1526
+ getTileData(tile) {
1527
+ const { data, getTileData, fetch } = this.props;
1528
+ const { signal } = tile;
1529
+ tile.url = typeof data === "string" || Array.isArray(data) ? getURLFromTemplate(data, tile) : null;
1530
+ if (getTileData) {
1531
+ return getTileData(tile);
1532
+ }
1533
+ if (fetch && tile.url) {
1534
+ return fetch(tile.url, { propName: "data", layer: this, signal });
1535
+ }
1536
+ return null;
1537
+ }
1538
+ renderSubLayers(props) {
1539
+ return this.props.renderSubLayers(props);
1540
+ }
1541
+ getSubLayerPropsByTile(tile) {
1542
+ return null;
1543
+ }
1544
+ getPickingInfo(params) {
1545
+ const sourceTile = params.sourceLayer.props.tile;
1546
+ const info = params.info;
1547
+ if (info.picked) {
1548
+ info.tile = sourceTile;
1549
+ }
1550
+ info.sourceTile = sourceTile;
1551
+ return info;
1552
+ }
1553
+ _updateAutoHighlight(info) {
1554
+ const sourceTile = info.sourceTile;
1555
+ if (sourceTile && sourceTile.layers) {
1556
+ for (const layer of sourceTile.layers) {
1557
+ layer.updateAutoHighlight(info);
1558
+ }
1559
+ }
1560
+ }
1561
+ renderLayers() {
1562
+ return this.state.tileset.tiles.map((tile) => {
1563
+ const subLayerProps = this.getSubLayerPropsByTile(tile);
1564
+ if (!tile.isLoaded && !tile.content) {
1565
+ } else if (!tile.layers) {
1566
+ const layers = this.renderSubLayers({
1567
+ ...this.props,
1568
+ ...this.getSubLayerProps({
1569
+ id: tile.id,
1570
+ updateTriggers: this.props.updateTriggers
1571
+ }),
1572
+ data: tile.content,
1573
+ _offset: 0,
1574
+ tile
1575
+ });
1576
+ tile.layers = (0, import_core5._flatten)(layers, Boolean).map((layer) => layer.clone({
1577
+ tile,
1578
+ ...subLayerProps
1579
+ }));
1580
+ } else if (subLayerProps && tile.layers[0] && Object.keys(subLayerProps).some((propName) => tile.layers[0].props[propName] !== subLayerProps[propName])) {
1581
+ tile.layers = tile.layers.map((layer) => layer.clone(subLayerProps));
1582
+ }
1583
+ return tile.layers;
1584
+ });
1585
+ }
1586
+ filterSubLayer({ layer, cullRect }) {
1587
+ const { tile } = layer.props;
1588
+ return this.state.tileset.isTileVisible(tile, cullRect);
1589
+ }
1590
+ };
1591
+ var TileLayer = _TileLayer;
1592
+ (() => {
1593
+ _TileLayer.defaultProps = defaultProps6;
1594
+ })();
1595
+ (() => {
1596
+ _TileLayer.layerName = "TileLayer";
1597
+ })();
1598
+
1599
+ // dist/trips-layer/trips-layer.js
1600
+ var import_layers5 = require("@deck.gl/layers");
1601
+ var defaultProps7 = {
1602
+ fadeTrail: true,
1603
+ trailLength: { type: "number", value: 120, min: 0 },
1604
+ currentTime: { type: "number", value: 0, min: 0 },
1605
+ getTimestamps: { type: "accessor", value: (d) => d.timestamps }
1606
+ };
1607
+ var _TripsLayer = class extends import_layers5.PathLayer {
1608
+ getShaders() {
1609
+ const shaders = super.getShaders();
1610
+ shaders.inject = {
1611
+ "vs:#decl": `uniform float trailLength;
1612
+ in float instanceTimestamps;
1613
+ in float instanceNextTimestamps;
1614
+ out float vTime;
1615
+ `,
1616
+ "vs:#main-end": `vTime = instanceTimestamps + (instanceNextTimestamps - instanceTimestamps) * vPathPosition.y / vPathLength;
1617
+ `,
1618
+ "fs:#decl": `uniform bool fadeTrail;
1619
+ uniform float trailLength;
1620
+ uniform float currentTime;
1621
+ in float vTime;
1622
+ `,
1623
+ "fs:#main-start": `if(vTime > currentTime || (fadeTrail && (vTime < currentTime - trailLength))) {
1624
+ discard;
1625
+ }
1626
+ `,
1627
+ "fs:DECKGL_FILTER_COLOR": `if(fadeTrail) {
1628
+ color.a *= 1.0 - (currentTime - vTime) / trailLength;
1629
+ }
1630
+ `
1631
+ };
1632
+ return shaders;
1633
+ }
1634
+ initializeState() {
1635
+ super.initializeState();
1636
+ const attributeManager = this.getAttributeManager();
1637
+ attributeManager.addInstanced({
1638
+ timestamps: {
1639
+ size: 1,
1640
+ accessor: "getTimestamps",
1641
+ shaderAttributes: {
1642
+ instanceTimestamps: {
1643
+ vertexOffset: 0
1644
+ },
1645
+ instanceNextTimestamps: {
1646
+ vertexOffset: 1
1647
+ }
1648
+ }
1649
+ }
1650
+ });
1651
+ }
1652
+ draw(params) {
1653
+ const { fadeTrail, trailLength, currentTime } = this.props;
1654
+ params.uniforms = {
1655
+ ...params.uniforms,
1656
+ fadeTrail,
1657
+ trailLength,
1658
+ currentTime
1659
+ };
1660
+ super.draw(params);
1661
+ }
1662
+ };
1663
+ var TripsLayer = _TripsLayer;
1664
+ (() => {
1665
+ _TripsLayer.layerName = "TripsLayer";
1666
+ })();
1667
+ (() => {
1668
+ _TripsLayer.defaultProps = defaultProps7;
1669
+ })();
1670
+
1671
+ // dist/h3-layers/h3-cluster-layer.js
1672
+ var import_h3_js3 = require("h3-js");
1673
+ var import_core8 = require("@deck.gl/core");
1674
+
1675
+ // dist/h3-layers/h3-hexagon-layer.js
1676
+ var import_h3_js2 = require("h3-js");
1677
+ var import_core7 = require("@deck.gl/core");
1678
+ var import_layers6 = require("@deck.gl/layers");
1679
+
1680
+ // dist/h3-layers/h3-utils.js
1681
+ var import_h3_js = require("h3-js");
1682
+ var import_core6 = require("@math.gl/core");
1683
+ function normalizeLongitudes(vertices, refLng) {
1684
+ refLng = refLng === void 0 ? vertices[0][0] : refLng;
1685
+ for (const pt of vertices) {
1686
+ const deltaLng = pt[0] - refLng;
1687
+ if (deltaLng > 180) {
1688
+ pt[0] -= 360;
1689
+ } else if (deltaLng < -180) {
1690
+ pt[0] += 360;
1691
+ }
1692
+ }
1693
+ }
1694
+ function scalePolygon(hexId, vertices, factor) {
1695
+ const [lat, lng] = (0, import_h3_js.cellToLatLng)(hexId);
1696
+ const actualCount = vertices.length;
1697
+ normalizeLongitudes(vertices, lng);
1698
+ const vertexCount = vertices[0] === vertices[actualCount - 1] ? actualCount - 1 : actualCount;
1699
+ for (let i = 0; i < vertexCount; i++) {
1700
+ vertices[i][0] = (0, import_core6.lerp)(lng, vertices[i][0], factor);
1701
+ vertices[i][1] = (0, import_core6.lerp)(lat, vertices[i][1], factor);
1702
+ }
1703
+ }
1704
+ function getHexagonCentroid(getHexagon, object, objectInfo) {
1705
+ const hexagonId = getHexagon(object, objectInfo);
1706
+ const [lat, lng] = (0, import_h3_js.cellToLatLng)(hexagonId);
1707
+ return [lng, lat];
1708
+ }
1709
+ function h3ToPolygon(hexId, coverage = 1) {
1710
+ const vertices = (0, import_h3_js.cellToBoundary)(hexId, true);
1711
+ if (coverage !== 1) {
1712
+ scalePolygon(hexId, vertices, coverage);
1713
+ } else {
1714
+ normalizeLongitudes(vertices);
1715
+ }
1716
+ return vertices;
1717
+ }
1718
+ function flattenPolygon(vertices) {
1719
+ const positions = new Float64Array(vertices.length * 2);
1720
+ let i = 0;
1721
+ for (const pt of vertices) {
1722
+ positions[i++] = pt[0];
1723
+ positions[i++] = pt[1];
1724
+ }
1725
+ return positions;
1726
+ }
1727
+
1728
+ // dist/h3-layers/h3-hexagon-layer.js
1729
+ var UPDATE_THRESHOLD_KM = 10;
1730
+ function mergeTriggers(getHexagon, coverage) {
1731
+ let trigger;
1732
+ if (getHexagon === void 0 || getHexagon === null) {
1733
+ trigger = coverage;
1734
+ } else if (typeof getHexagon === "object") {
1735
+ trigger = { ...getHexagon, coverage };
1736
+ } else {
1737
+ trigger = { getHexagon, coverage };
1738
+ }
1739
+ return trigger;
1740
+ }
1741
+ var defaultProps8 = {
1742
+ ...import_layers6.PolygonLayer.defaultProps,
1743
+ highPrecision: "auto",
1744
+ coverage: { type: "number", min: 0, max: 1, value: 1 },
1745
+ centerHexagon: null,
1746
+ getHexagon: { type: "accessor", value: (x) => x.hexagon },
1747
+ extruded: true
1748
+ };
1749
+ var _H3HexagonLayer = class extends import_core7.CompositeLayer {
1750
+ initializeState() {
1751
+ _H3HexagonLayer._checkH3Lib();
1752
+ this.state = {
1753
+ edgeLengthKM: 0,
1754
+ resolution: -1
1755
+ };
1756
+ }
1757
+ shouldUpdateState({ changeFlags }) {
1758
+ return this._shouldUseHighPrecision() ? changeFlags.propsOrDataChanged : changeFlags.somethingChanged;
1759
+ }
1760
+ updateState({ props, changeFlags }) {
1761
+ if (props.highPrecision !== true && (changeFlags.dataChanged || changeFlags.updateTriggersChanged && changeFlags.updateTriggersChanged.getHexagon)) {
1762
+ const dataProps = this._calculateH3DataProps();
1763
+ this.setState(dataProps);
1764
+ }
1765
+ this._updateVertices(this.context.viewport);
1766
+ }
1767
+ _calculateH3DataProps() {
1768
+ let resolution = -1;
1769
+ let hasPentagon = false;
1770
+ let hasMultipleRes = false;
1771
+ const { iterable, objectInfo } = (0, import_core7.createIterable)(this.props.data);
1772
+ for (const object of iterable) {
1773
+ objectInfo.index++;
1774
+ const hexId = this.props.getHexagon(object, objectInfo);
1775
+ const hexResolution = (0, import_h3_js2.getResolution)(hexId);
1776
+ if (resolution < 0) {
1777
+ resolution = hexResolution;
1778
+ if (!this.props.highPrecision)
1779
+ break;
1780
+ } else if (resolution !== hexResolution) {
1781
+ hasMultipleRes = true;
1782
+ break;
1783
+ }
1784
+ if ((0, import_h3_js2.isPentagon)(hexId)) {
1785
+ hasPentagon = true;
1786
+ break;
1787
+ }
1788
+ }
1789
+ return {
1790
+ resolution,
1791
+ edgeLengthKM: resolution >= 0 ? (0, import_h3_js2.getHexagonEdgeLengthAvg)(resolution, "km") : 0,
1792
+ hasMultipleRes,
1793
+ hasPentagon
1794
+ };
1795
+ }
1796
+ _shouldUseHighPrecision() {
1797
+ if (this.props.highPrecision === "auto") {
1798
+ const { resolution, hasPentagon, hasMultipleRes } = this.state;
1799
+ const { viewport } = this.context;
1800
+ return Boolean(viewport == null ? void 0 : viewport.resolution) || hasMultipleRes || hasPentagon || resolution >= 0 && resolution <= 5;
1801
+ }
1802
+ return this.props.highPrecision;
1803
+ }
1804
+ _updateVertices(viewport) {
1805
+ if (this._shouldUseHighPrecision()) {
1806
+ return;
1807
+ }
1808
+ const { resolution, edgeLengthKM, centerHex } = this.state;
1809
+ if (resolution < 0) {
1810
+ return;
1811
+ }
1812
+ const hex = this.props.centerHexagon || (0, import_h3_js2.latLngToCell)(viewport.latitude, viewport.longitude, resolution);
1813
+ if (centerHex === hex) {
1814
+ return;
1815
+ }
1816
+ if (centerHex) {
1817
+ try {
1818
+ const distance = (0, import_h3_js2.gridDistance)(centerHex, hex);
1819
+ if (distance * edgeLengthKM < UPDATE_THRESHOLD_KM) {
1820
+ return;
1821
+ }
1822
+ } catch {
1823
+ }
1824
+ }
1825
+ const { unitsPerMeter } = viewport.distanceScales;
1826
+ let vertices = h3ToPolygon(hex);
1827
+ const [centerLat, centerLng] = (0, import_h3_js2.cellToLatLng)(hex);
1828
+ const [centerX, centerY] = viewport.projectFlat([centerLng, centerLat]);
1829
+ vertices = vertices.map((p) => {
1830
+ const worldPosition = viewport.projectFlat(p);
1831
+ return [
1832
+ (worldPosition[0] - centerX) / unitsPerMeter[0],
1833
+ (worldPosition[1] - centerY) / unitsPerMeter[1]
1834
+ ];
1835
+ });
1836
+ this.setState({ centerHex: hex, vertices });
1837
+ }
1838
+ renderLayers() {
1839
+ return this._shouldUseHighPrecision() ? this._renderPolygonLayer() : this._renderColumnLayer();
1840
+ }
1841
+ _getForwardProps() {
1842
+ const { elevationScale, material, coverage, extruded, wireframe, stroked, filled, lineWidthUnits, lineWidthScale, lineWidthMinPixels, lineWidthMaxPixels, getFillColor, getElevation, getLineColor, getLineWidth, transitions, updateTriggers } = this.props;
1843
+ return {
1844
+ elevationScale,
1845
+ extruded,
1846
+ coverage,
1847
+ wireframe,
1848
+ stroked,
1849
+ filled,
1850
+ lineWidthUnits,
1851
+ lineWidthScale,
1852
+ lineWidthMinPixels,
1853
+ lineWidthMaxPixels,
1854
+ material,
1855
+ getElevation,
1856
+ getFillColor,
1857
+ getLineColor,
1858
+ getLineWidth,
1859
+ transitions,
1860
+ updateTriggers: {
1861
+ getFillColor: updateTriggers.getFillColor,
1862
+ getElevation: updateTriggers.getElevation,
1863
+ getLineColor: updateTriggers.getLineColor,
1864
+ getLineWidth: updateTriggers.getLineWidth
1865
+ }
1866
+ };
1867
+ }
1868
+ _renderPolygonLayer() {
1869
+ const { data, getHexagon, updateTriggers, coverage } = this.props;
1870
+ const SubLayerClass = this.getSubLayerClass("hexagon-cell-hifi", import_layers6.PolygonLayer);
1871
+ const forwardProps = this._getForwardProps();
1872
+ forwardProps.updateTriggers.getPolygon = mergeTriggers(updateTriggers.getHexagon, coverage);
1873
+ return new SubLayerClass(forwardProps, this.getSubLayerProps({
1874
+ id: "hexagon-cell-hifi",
1875
+ updateTriggers: forwardProps.updateTriggers
1876
+ }), {
1877
+ data,
1878
+ _normalize: false,
1879
+ _windingOrder: "CCW",
1880
+ positionFormat: "XY",
1881
+ getPolygon: (object, objectInfo) => {
1882
+ const hexagonId = getHexagon(object, objectInfo);
1883
+ return flattenPolygon(h3ToPolygon(hexagonId, coverage));
1884
+ }
1885
+ });
1886
+ }
1887
+ _renderColumnLayer() {
1888
+ const { data, getHexagon, updateTriggers } = this.props;
1889
+ const SubLayerClass = this.getSubLayerClass("hexagon-cell", import_layers6.ColumnLayer);
1890
+ const forwardProps = this._getForwardProps();
1891
+ forwardProps.updateTriggers.getPosition = updateTriggers.getHexagon;
1892
+ return new SubLayerClass(forwardProps, this.getSubLayerProps({
1893
+ id: "hexagon-cell",
1894
+ flatShading: true,
1895
+ updateTriggers: forwardProps.updateTriggers
1896
+ }), {
1897
+ data,
1898
+ diskResolution: 6,
1899
+ radius: 1,
1900
+ vertices: this.state.vertices,
1901
+ getPosition: getHexagonCentroid.bind(null, getHexagon)
1902
+ });
1903
+ }
1904
+ };
1905
+ var H3HexagonLayer = _H3HexagonLayer;
1906
+ (() => {
1907
+ _H3HexagonLayer.defaultProps = defaultProps8;
1908
+ })();
1909
+ (() => {
1910
+ _H3HexagonLayer.layerName = "H3HexagonLayer";
1911
+ })();
1912
+ (() => {
1913
+ _H3HexagonLayer._checkH3Lib = () => {
1914
+ };
1915
+ })();
1916
+
1917
+ // dist/h3-layers/h3-cluster-layer.js
1918
+ var defaultProps9 = {
1919
+ getHexagons: { type: "accessor", value: (d) => d.hexagons }
1920
+ };
1921
+ var _H3ClusterLayer = class extends GeoCellLayer {
1922
+ initializeState() {
1923
+ H3HexagonLayer._checkH3Lib();
1924
+ }
1925
+ updateState({ props, changeFlags }) {
1926
+ if (changeFlags.dataChanged || changeFlags.updateTriggersChanged && changeFlags.updateTriggersChanged.getHexagons) {
1927
+ const { data, getHexagons } = props;
1928
+ const polygons = [];
1929
+ const { iterable, objectInfo } = (0, import_core8.createIterable)(data);
1930
+ for (const object of iterable) {
1931
+ objectInfo.index++;
1932
+ const hexagons = getHexagons(object, objectInfo);
1933
+ const multiPolygon = (0, import_h3_js3.cellsToMultiPolygon)(hexagons, true);
1934
+ for (const polygon of multiPolygon) {
1935
+ for (const ring of polygon) {
1936
+ normalizeLongitudes(ring);
1937
+ }
1938
+ polygons.push(this.getSubLayerRow({ polygon }, object, objectInfo.index));
1939
+ }
1940
+ }
1941
+ this.setState({ polygons });
1942
+ }
1943
+ }
1944
+ indexToBounds() {
1945
+ const { getElevation, getFillColor, getLineColor, getLineWidth } = this.props;
1946
+ return {
1947
+ data: this.state.polygons,
1948
+ getPolygon: (d) => d.polygon,
1949
+ getElevation: this.getSubLayerAccessor(getElevation),
1950
+ getFillColor: this.getSubLayerAccessor(getFillColor),
1951
+ getLineColor: this.getSubLayerAccessor(getLineColor),
1952
+ getLineWidth: this.getSubLayerAccessor(getLineWidth)
1953
+ };
1954
+ }
1955
+ };
1956
+ var H3ClusterLayer = _H3ClusterLayer;
1957
+ (() => {
1958
+ _H3ClusterLayer.layerName = "H3ClusterLayer";
1959
+ })();
1960
+ (() => {
1961
+ _H3ClusterLayer.defaultProps = defaultProps9;
1962
+ })();
1963
+
1964
+ // dist/tile-3d-layer/tile-3d-layer.js
1965
+ var import_engine2 = require("@luma.gl/engine");
1966
+ var import_core9 = require("@deck.gl/core");
1967
+ var import_layers7 = require("@deck.gl/layers");
1968
+ var import_mesh_layers2 = require("@deck.gl/mesh-layers");
1969
+
1970
+ // dist/mesh-layer/mesh-layer.js
1971
+ var import_gltf = require("@luma.gl/gltf");
1972
+ var import_shadertools = require("@luma.gl/shadertools");
1973
+ var import_engine = require("@luma.gl/engine");
1974
+ var import_mesh_layers = require("@deck.gl/mesh-layers");
1975
+
1976
+ // dist/mesh-layer/mesh-layer-vertex.glsl.js
1977
+ var mesh_layer_vertex_glsl_default = `#version 300 es
1978
+ #define SHADER_NAME simple-mesh-layer-vs
1979
+ uniform float sizeScale;
1980
+ uniform bool composeModelMatrix;
1981
+ uniform bool pickFeatureIds;
1982
+ in vec3 positions;
1983
+ in vec3 normals;
1984
+ in vec3 colors;
1985
+ in vec2 texCoords;
1986
+ in vec4 uvRegions;
1987
+ in vec3 featureIdsPickingColors;
1988
+ in vec4 instanceColors;
1989
+ in vec3 instancePickingColors;
1990
+ in vec3 instanceModelMatrixCol0;
1991
+ in vec3 instanceModelMatrixCol1;
1992
+ in vec3 instanceModelMatrixCol2;
1993
+ out vec2 vTexCoord;
1994
+ out vec3 cameraPosition;
1995
+ out vec3 normals_commonspace;
1996
+ out vec4 position_commonspace;
1997
+ out vec4 vColor;
1998
+ vec2 applyUVRegion(vec2 uv) {
1999
+ #ifdef HAS_UV_REGIONS
2000
+ return fract(uv) * (uvRegions.zw - uvRegions.xy) + uvRegions.xy;
2001
+ #else
2002
+ return uv;
2003
+ #endif
2004
+ }
2005
+ void main(void) {
2006
+ vec2 uv = applyUVRegion(texCoords);
2007
+ geometry.uv = uv;
2008
+ if (pickFeatureIds) {
2009
+ geometry.pickingColor = featureIdsPickingColors;
2010
+ } else {
2011
+ geometry.pickingColor = instancePickingColors;
2012
+ }
2013
+ mat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2);
2014
+ vTexCoord = uv;
2015
+ cameraPosition = project_uCameraPosition;
2016
+ vColor = vec4(colors * instanceColors.rgb, instanceColors.a);
2017
+ vec3 pos = (instanceModelMatrix * positions) * sizeScale;
2018
+ vec3 projectedPosition = project_position(positions);
2019
+ position_commonspace = vec4(projectedPosition, 1.0);
2020
+ gl_Position = project_common_position_to_clipspace(position_commonspace);
2021
+ geometry.position = position_commonspace;
2022
+ normals_commonspace = project_normal(instanceModelMatrix * normals);
2023
+ geometry.normal = normals_commonspace;
2024
+ DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
2025
+ #ifdef MODULE_PBR
2026
+ pbr_vPosition = geometry.position.xyz;
2027
+ #ifdef HAS_NORMALS
2028
+ pbr_vNormal = geometry.normal;
2029
+ #endif
2030
+ #ifdef HAS_UV
2031
+ pbr_vUV = uv;
2032
+ #else
2033
+ pbr_vUV = vec2(0., 0.);
2034
+ #endif
2035
+ geometry.uv = pbr_vUV;
2036
+ #endif
2037
+ DECKGL_FILTER_COLOR(vColor, geometry);
2038
+ }
2039
+ `;
2040
+
2041
+ // dist/mesh-layer/mesh-layer-fragment.glsl.js
2042
+ var mesh_layer_fragment_glsl_default = `#version 300 es
2043
+ #define SHADER_NAME simple-mesh-layer-fs
2044
+ precision highp float;
2045
+ uniform bool hasTexture;
2046
+ uniform sampler2D sampler;
2047
+ uniform bool flatShading;
2048
+ uniform float opacity;
2049
+ in vec2 vTexCoord;
2050
+ in vec3 cameraPosition;
2051
+ in vec3 normals_commonspace;
2052
+ in vec4 position_commonspace;
2053
+ in vec4 vColor;
2054
+ out vec4 fragColor;
2055
+ void main(void) {
2056
+ #ifdef MODULE_PBR
2057
+ fragColor = vColor * pbr_filterColor(vec4(0));
2058
+ geometry.uv = pbr_vUV;
2059
+ fragColor.a *= opacity;
2060
+ #else
2061
+ geometry.uv = vTexCoord;
2062
+ vec3 normal;
2063
+ if (flatShading) {
2064
+ normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));
2065
+ } else {
2066
+ normal = normals_commonspace;
2067
+ }
2068
+ vec4 color = hasTexture ? texture(sampler, vTexCoord) : vColor;
2069
+ vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);
2070
+ fragColor = vec4(lightColor, color.a * opacity);
2071
+ #endif
2072
+ DECKGL_FILTER_COLOR(fragColor, geometry);
2073
+ }
2074
+ `;
2075
+
2076
+ // dist/mesh-layer/mesh-layer.js
2077
+ function validateGeometryAttributes(attributes) {
2078
+ const positionAttribute = attributes.positions || attributes.POSITION;
2079
+ const vertexCount = positionAttribute.value.length / positionAttribute.size;
2080
+ const hasColorAttribute = attributes.COLOR_0 || attributes.colors;
2081
+ if (!hasColorAttribute) {
2082
+ attributes.colors = {
2083
+ size: 4,
2084
+ value: new Uint8Array(vertexCount * 4).fill(255),
2085
+ normalized: true
2086
+ };
2087
+ }
2088
+ }
2089
+ var defaultProps10 = {
2090
+ pbrMaterial: { type: "object", value: null },
2091
+ featureIds: { type: "array", value: null, optional: true }
2092
+ };
2093
+ var _MeshLayer = class extends import_mesh_layers.SimpleMeshLayer {
2094
+ getShaders() {
2095
+ const shaders = super.getShaders();
2096
+ const modules = shaders.modules;
2097
+ modules.push(import_shadertools.pbr);
2098
+ return { ...shaders, vs: mesh_layer_vertex_glsl_default, fs: mesh_layer_fragment_glsl_default };
2099
+ }
2100
+ initializeState() {
2101
+ const { featureIds } = this.props;
2102
+ super.initializeState();
2103
+ const attributeManager = this.getAttributeManager();
2104
+ if (featureIds) {
2105
+ attributeManager.add({
2106
+ featureIdsPickingColors: {
2107
+ type: "uint8",
2108
+ size: 3,
2109
+ noAlloc: true,
2110
+ update: this.calculateFeatureIdsPickingColors
2111
+ }
2112
+ });
2113
+ }
2114
+ }
2115
+ updateState(params) {
2116
+ super.updateState(params);
2117
+ const { props, oldProps } = params;
2118
+ if (props.pbrMaterial !== oldProps.pbrMaterial) {
2119
+ this.updatePbrMaterialUniforms(props.pbrMaterial);
2120
+ }
2121
+ }
2122
+ draw(opts) {
2123
+ const { featureIds } = this.props;
2124
+ if (!this.state.model) {
2125
+ return;
2126
+ }
2127
+ this.state.model.setUniforms({
2128
+ u_Camera: this.state.model.uniforms.project_uCameraPosition,
2129
+ pickFeatureIds: Boolean(featureIds)
2130
+ });
2131
+ super.draw(opts);
2132
+ }
2133
+ getModel(mesh) {
2134
+ const { id, pbrMaterial } = this.props;
2135
+ const parsedPBRMaterial = this.parseMaterial(pbrMaterial, mesh);
2136
+ this.setState({ parsedPBRMaterial });
2137
+ const shaders = this.getShaders();
2138
+ validateGeometryAttributes(mesh.attributes);
2139
+ const model = new import_engine.Model(this.context.device, {
2140
+ ...this.getShaders(),
2141
+ id,
2142
+ geometry: mesh,
2143
+ bufferLayout: this.getAttributeManager().getBufferLayouts(),
2144
+ defines: {
2145
+ ...shaders.defines,
2146
+ ...parsedPBRMaterial == null ? void 0 : parsedPBRMaterial.defines,
2147
+ HAS_UV_REGIONS: mesh.attributes.uvRegions ? 1 : 0
2148
+ },
2149
+ parameters: parsedPBRMaterial == null ? void 0 : parsedPBRMaterial.parameters,
2150
+ isInstanced: true
2151
+ });
2152
+ return model;
2153
+ }
2154
+ updatePbrMaterialUniforms(pbrMaterial) {
2155
+ const { model } = this.state;
2156
+ if (model) {
2157
+ const { mesh } = this.props;
2158
+ const parsedPBRMaterial = this.parseMaterial(pbrMaterial, mesh);
2159
+ this.setState({ parsedPBRMaterial });
2160
+ model.setBindings(parsedPBRMaterial.bindings);
2161
+ model.setUniforms(parsedPBRMaterial.uniforms);
2162
+ }
2163
+ }
2164
+ parseMaterial(pbrMaterial, mesh) {
2165
+ const unlit = Boolean(pbrMaterial.pbrMetallicRoughness && pbrMaterial.pbrMetallicRoughness.baseColorTexture);
2166
+ return (0, import_gltf.parsePBRMaterial)(this.context.device, { unlit, ...pbrMaterial }, { NORMAL: mesh.attributes.normals, TEXCOORD_0: mesh.attributes.texCoords }, {
2167
+ pbrDebug: false,
2168
+ lights: true,
2169
+ useTangents: false
2170
+ });
2171
+ }
2172
+ calculateFeatureIdsPickingColors(attribute) {
2173
+ const featureIds = this.props.featureIds;
2174
+ const value = new Uint8ClampedArray(featureIds.length * attribute.size);
2175
+ const pickingColor = [];
2176
+ for (let index = 0; index < featureIds.length; index++) {
2177
+ this.encodePickingColor(featureIds[index], pickingColor);
2178
+ value[index * 3] = pickingColor[0];
2179
+ value[index * 3 + 1] = pickingColor[1];
2180
+ value[index * 3 + 2] = pickingColor[2];
2181
+ }
2182
+ attribute.value = value;
2183
+ }
2184
+ finalizeState(context) {
2185
+ var _a;
2186
+ super.finalizeState(context);
2187
+ (_a = this.state.parsedPBRMaterial) == null ? void 0 : _a.generatedTextures.forEach((texture) => texture.destroy());
2188
+ this.setState({ parsedPBRMaterial: null });
2189
+ }
2190
+ };
2191
+ var MeshLayer = _MeshLayer;
2192
+ (() => {
2193
+ _MeshLayer.layerName = "MeshLayer";
2194
+ })();
2195
+ (() => {
2196
+ _MeshLayer.defaultProps = defaultProps10;
2197
+ })();
2198
+
2199
+ // dist/tile-3d-layer/tile-3d-layer.js
2200
+ var import_core10 = require("@loaders.gl/core");
2201
+ var import_tiles = require("@loaders.gl/tiles");
2202
+ var import_d_tiles = require("@loaders.gl/3d-tiles");
2203
+ var SINGLE_DATA = [0];
2204
+ var defaultProps11 = {
2205
+ getPointColor: { type: "accessor", value: [0, 0, 0, 255] },
2206
+ pointSize: 1,
2207
+ data: "",
2208
+ loader: import_d_tiles.Tiles3DLoader,
2209
+ onTilesetLoad: { type: "function", value: (tileset3d) => {
2210
+ } },
2211
+ onTileLoad: { type: "function", value: (tileHeader) => {
2212
+ } },
2213
+ onTileUnload: { type: "function", value: (tileHeader) => {
2214
+ } },
2215
+ onTileError: { type: "function", value: (tile, message, url) => {
2216
+ } },
2217
+ _getMeshColor: { type: "function", value: (tileHeader) => [255, 255, 255] }
2218
+ };
2219
+ var _Tile3DLayer = class extends import_core9.CompositeLayer {
2220
+ initializeState() {
2221
+ if ("onTileLoadFail" in this.props) {
2222
+ import_core9.log.removed("onTileLoadFail", "onTileError")();
2223
+ }
2224
+ this.state = {
2225
+ layerMap: {},
2226
+ tileset3d: null,
2227
+ activeViewports: {},
2228
+ lastUpdatedViewports: null
2229
+ };
2230
+ }
2231
+ get isLoaded() {
2232
+ var _a, _b;
2233
+ return Boolean(((_b = (_a = this.state) == null ? void 0 : _a.tileset3d) == null ? void 0 : _b.isLoaded()) && super.isLoaded);
2234
+ }
2235
+ shouldUpdateState({ changeFlags }) {
2236
+ return changeFlags.somethingChanged;
2237
+ }
2238
+ updateState({ props, oldProps, changeFlags }) {
2239
+ if (props.data && props.data !== oldProps.data) {
2240
+ this._loadTileset(props.data);
2241
+ }
2242
+ if (changeFlags.viewportChanged) {
2243
+ const { activeViewports } = this.state;
2244
+ const viewportsNumber = Object.keys(activeViewports).length;
2245
+ if (viewportsNumber) {
2246
+ this._updateTileset(activeViewports);
2247
+ this.state.lastUpdatedViewports = activeViewports;
2248
+ this.state.activeViewports = {};
2249
+ }
2250
+ }
2251
+ if (changeFlags.propsChanged) {
2252
+ const { layerMap } = this.state;
2253
+ for (const key in layerMap) {
2254
+ layerMap[key].needsUpdate = true;
2255
+ }
2256
+ }
2257
+ }
2258
+ activateViewport(viewport) {
2259
+ const { activeViewports, lastUpdatedViewports } = this.state;
2260
+ this.internalState.viewport = viewport;
2261
+ activeViewports[viewport.id] = viewport;
2262
+ const lastViewport = lastUpdatedViewports == null ? void 0 : lastUpdatedViewports[viewport.id];
2263
+ if (!lastViewport || !viewport.equals(lastViewport)) {
2264
+ this.setChangeFlags({ viewportChanged: true });
2265
+ this.setNeedsUpdate();
2266
+ }
2267
+ }
2268
+ getPickingInfo({ info, sourceLayer }) {
2269
+ const sourceTile = sourceLayer && sourceLayer.props.tile;
2270
+ if (info.picked) {
2271
+ info.object = sourceTile;
2272
+ }
2273
+ info.sourceTile = sourceTile;
2274
+ return info;
2275
+ }
2276
+ filterSubLayer({ layer, viewport }) {
2277
+ const { tile } = layer.props;
2278
+ const { id: viewportId } = viewport;
2279
+ return tile.selected && tile.viewportIds.includes(viewportId);
2280
+ }
2281
+ _updateAutoHighlight(info) {
2282
+ const sourceTile = info.sourceTile;
2283
+ const layerCache = this.state.layerMap[sourceTile == null ? void 0 : sourceTile.id];
2284
+ if (layerCache && layerCache.layer) {
2285
+ layerCache.layer.updateAutoHighlight(info);
2286
+ }
2287
+ }
2288
+ async _loadTileset(tilesetUrl) {
2289
+ const { loadOptions = {} } = this.props;
2290
+ const loaders = this.props.loader || this.props.loaders;
2291
+ const loader = Array.isArray(loaders) ? loaders[0] : loaders;
2292
+ const options = { loadOptions: { ...loadOptions } };
2293
+ let actualTilesetUrl = tilesetUrl;
2294
+ if (loader.preload) {
2295
+ const preloadOptions = await loader.preload(tilesetUrl, loadOptions);
2296
+ if (preloadOptions.url) {
2297
+ actualTilesetUrl = preloadOptions.url;
2298
+ }
2299
+ if (preloadOptions.headers) {
2300
+ options.loadOptions.fetch = {
2301
+ ...options.loadOptions.fetch,
2302
+ headers: preloadOptions.headers
2303
+ };
2304
+ }
2305
+ Object.assign(options, preloadOptions);
2306
+ }
2307
+ const tilesetJson = await (0, import_core10.load)(actualTilesetUrl, loader, options.loadOptions);
2308
+ const tileset3d = new import_tiles.Tileset3D(tilesetJson, {
2309
+ onTileLoad: this._onTileLoad.bind(this),
2310
+ onTileUnload: this._onTileUnload.bind(this),
2311
+ onTileError: this.props.onTileError,
2312
+ ...options
2313
+ });
2314
+ this.setState({
2315
+ tileset3d,
2316
+ layerMap: {}
2317
+ });
2318
+ this._updateTileset(this.state.activeViewports);
2319
+ this.props.onTilesetLoad(tileset3d);
2320
+ }
2321
+ _onTileLoad(tileHeader) {
2322
+ const { lastUpdatedViewports } = this.state;
2323
+ this.props.onTileLoad(tileHeader);
2324
+ this._updateTileset(lastUpdatedViewports);
2325
+ this.setNeedsUpdate();
2326
+ }
2327
+ _onTileUnload(tileHeader) {
2328
+ delete this.state.layerMap[tileHeader.id];
2329
+ this.props.onTileUnload(tileHeader);
2330
+ }
2331
+ _updateTileset(viewports) {
2332
+ if (!viewports) {
2333
+ return;
2334
+ }
2335
+ const { tileset3d } = this.state;
2336
+ const { timeline } = this.context;
2337
+ const viewportsNumber = Object.keys(viewports).length;
2338
+ if (!timeline || !viewportsNumber || !tileset3d) {
2339
+ return;
2340
+ }
2341
+ tileset3d.selectTiles(Object.values(viewports)).then((frameNumber) => {
2342
+ const tilesetChanged = this.state.frameNumber !== frameNumber;
2343
+ if (tilesetChanged) {
2344
+ this.setState({ frameNumber });
2345
+ }
2346
+ });
2347
+ }
2348
+ _getSubLayer(tileHeader, oldLayer) {
2349
+ if (!tileHeader.content) {
2350
+ return null;
2351
+ }
2352
+ switch (tileHeader.type) {
2353
+ case import_tiles.TILE_TYPE.POINTCLOUD:
2354
+ return this._makePointCloudLayer(tileHeader, oldLayer);
2355
+ case import_tiles.TILE_TYPE.SCENEGRAPH:
2356
+ return this._make3DModelLayer(tileHeader);
2357
+ case import_tiles.TILE_TYPE.MESH:
2358
+ return this._makeSimpleMeshLayer(tileHeader, oldLayer);
2359
+ default:
2360
+ throw new Error(`Tile3DLayer: Failed to render layer of type ${tileHeader.content.type}`);
2361
+ }
2362
+ }
2363
+ _makePointCloudLayer(tileHeader, oldLayer) {
2364
+ const { attributes, pointCount, constantRGBA, cartographicOrigin, modelMatrix } = tileHeader.content;
2365
+ const { positions, normals, colors } = attributes;
2366
+ if (!positions) {
2367
+ return null;
2368
+ }
2369
+ const data = oldLayer && oldLayer.props.data || {
2370
+ header: {
2371
+ vertexCount: pointCount
2372
+ },
2373
+ attributes: {
2374
+ POSITION: positions,
2375
+ NORMAL: normals,
2376
+ COLOR_0: colors
2377
+ }
2378
+ };
2379
+ const { pointSize, getPointColor } = this.props;
2380
+ const SubLayerClass = this.getSubLayerClass("pointcloud", import_layers7.PointCloudLayer);
2381
+ return new SubLayerClass({
2382
+ pointSize
2383
+ }, this.getSubLayerProps({
2384
+ id: "pointcloud"
2385
+ }), {
2386
+ id: `${this.id}-pointcloud-${tileHeader.id}`,
2387
+ tile: tileHeader,
2388
+ data,
2389
+ coordinateSystem: import_core9.COORDINATE_SYSTEM.METER_OFFSETS,
2390
+ coordinateOrigin: cartographicOrigin,
2391
+ modelMatrix,
2392
+ getColor: constantRGBA || getPointColor,
2393
+ _offset: 0
2394
+ });
2395
+ }
2396
+ _make3DModelLayer(tileHeader) {
2397
+ const { gltf, instances, cartographicOrigin, modelMatrix } = tileHeader.content;
2398
+ const SubLayerClass = this.getSubLayerClass("scenegraph", import_mesh_layers2.ScenegraphLayer);
2399
+ return new SubLayerClass({
2400
+ _lighting: "pbr"
2401
+ }, this.getSubLayerProps({
2402
+ id: "scenegraph"
2403
+ }), {
2404
+ id: `${this.id}-scenegraph-${tileHeader.id}`,
2405
+ tile: tileHeader,
2406
+ data: instances || SINGLE_DATA,
2407
+ scenegraph: gltf,
2408
+ coordinateSystem: import_core9.COORDINATE_SYSTEM.METER_OFFSETS,
2409
+ coordinateOrigin: cartographicOrigin,
2410
+ modelMatrix,
2411
+ getTransformMatrix: (instance) => instance.modelMatrix,
2412
+ getPosition: [0, 0, 0],
2413
+ _offset: 0
2414
+ });
2415
+ }
2416
+ _makeSimpleMeshLayer(tileHeader, oldLayer) {
2417
+ const content = tileHeader.content;
2418
+ const { attributes, indices, modelMatrix, cartographicOrigin, coordinateSystem = import_core9.COORDINATE_SYSTEM.METER_OFFSETS, material, featureIds } = content;
2419
+ const { _getMeshColor } = this.props;
2420
+ const geometry = oldLayer && oldLayer.props.mesh || new import_engine2.Geometry({
2421
+ topology: "triangle-list",
2422
+ attributes: getMeshGeometry(attributes),
2423
+ indices
2424
+ });
2425
+ const SubLayerClass = this.getSubLayerClass("mesh", MeshLayer);
2426
+ return new SubLayerClass(this.getSubLayerProps({
2427
+ id: "mesh"
2428
+ }), {
2429
+ id: `${this.id}-mesh-${tileHeader.id}`,
2430
+ tile: tileHeader,
2431
+ mesh: geometry,
2432
+ data: SINGLE_DATA,
2433
+ getColor: _getMeshColor(tileHeader),
2434
+ pbrMaterial: material,
2435
+ modelMatrix,
2436
+ coordinateOrigin: cartographicOrigin,
2437
+ coordinateSystem,
2438
+ featureIds,
2439
+ _offset: 0
2440
+ });
2441
+ }
2442
+ renderLayers() {
2443
+ const { tileset3d, layerMap } = this.state;
2444
+ if (!tileset3d) {
2445
+ return null;
2446
+ }
2447
+ return tileset3d.tiles.map((tile) => {
2448
+ const layerCache = layerMap[tile.id] = layerMap[tile.id] || { tile };
2449
+ let { layer } = layerCache;
2450
+ if (tile.selected) {
2451
+ if (!layer) {
2452
+ layer = this._getSubLayer(tile);
2453
+ } else if (layerCache.needsUpdate) {
2454
+ layer = this._getSubLayer(tile, layer);
2455
+ layerCache.needsUpdate = false;
2456
+ }
2457
+ }
2458
+ layerCache.layer = layer;
2459
+ return layer;
2460
+ }).filter(Boolean);
2461
+ }
2462
+ };
2463
+ var Tile3DLayer = _Tile3DLayer;
2464
+ (() => {
2465
+ _Tile3DLayer.defaultProps = defaultProps11;
2466
+ })();
2467
+ (() => {
2468
+ _Tile3DLayer.layerName = "Tile3DLayer";
2469
+ })();
2470
+ function getMeshGeometry(contentAttributes) {
2471
+ const attributes = {};
2472
+ attributes.positions = {
2473
+ ...contentAttributes.positions,
2474
+ value: new Float32Array(contentAttributes.positions.value)
2475
+ };
2476
+ if (contentAttributes.normals) {
2477
+ attributes.normals = contentAttributes.normals;
2478
+ }
2479
+ if (contentAttributes.texCoords) {
2480
+ attributes.texCoords = contentAttributes.texCoords;
2481
+ }
2482
+ if (contentAttributes.colors) {
2483
+ attributes.colors = contentAttributes.colors;
2484
+ }
2485
+ if (contentAttributes.uvRegions) {
2486
+ attributes.uvRegions = contentAttributes.uvRegions;
2487
+ }
2488
+ return attributes;
2489
+ }
2490
+
2491
+ // dist/terrain-layer/terrain-layer.js
2492
+ var import_core11 = require("@deck.gl/core");
2493
+ var import_mesh_layers3 = require("@deck.gl/mesh-layers");
2494
+ var import_core12 = require("@deck.gl/core");
2495
+ var import_terrain = require("@loaders.gl/terrain");
2496
+ var DUMMY_DATA = [1];
2497
+ var defaultProps12 = {
2498
+ ...TileLayer.defaultProps,
2499
+ elevationData: urlType,
2500
+ texture: { ...urlType, optional: true },
2501
+ meshMaxError: { type: "number", value: 4 },
2502
+ bounds: { type: "array", value: null, optional: true, compare: true },
2503
+ color: { type: "color", value: [255, 255, 255] },
2504
+ elevationDecoder: {
2505
+ type: "object",
2506
+ value: {
2507
+ rScaler: 1,
2508
+ gScaler: 0,
2509
+ bScaler: 0,
2510
+ offset: 0
2511
+ }
2512
+ },
2513
+ workerUrl: "",
2514
+ wireframe: false,
2515
+ material: true,
2516
+ loaders: [import_terrain.TerrainWorkerLoader]
2517
+ };
2518
+ function urlTemplateToUpdateTrigger(template) {
2519
+ if (Array.isArray(template)) {
2520
+ return template.join(";");
2521
+ }
2522
+ return template || "";
2523
+ }
2524
+ var _TerrainLayer = class extends import_core11.CompositeLayer {
2525
+ updateState({ props, oldProps }) {
2526
+ const elevationDataChanged = props.elevationData !== oldProps.elevationData;
2527
+ if (elevationDataChanged) {
2528
+ const { elevationData } = props;
2529
+ const isTiled = elevationData && (Array.isArray(elevationData) || elevationData.includes("{x}") && elevationData.includes("{y}"));
2530
+ this.setState({ isTiled });
2531
+ }
2532
+ const shouldReload = elevationDataChanged || props.meshMaxError !== oldProps.meshMaxError || props.elevationDecoder !== oldProps.elevationDecoder || props.bounds !== oldProps.bounds;
2533
+ if (!this.state.isTiled && shouldReload) {
2534
+ const terrain = this.loadTerrain(props);
2535
+ this.setState({ terrain });
2536
+ }
2537
+ if (props.workerUrl) {
2538
+ import_core11.log.removed("workerUrl", "loadOptions.terrain.workerUrl")();
2539
+ }
2540
+ }
2541
+ loadTerrain({ elevationData, bounds, elevationDecoder, meshMaxError, signal }) {
2542
+ if (!elevationData) {
2543
+ return null;
2544
+ }
2545
+ let loadOptions = this.getLoadOptions();
2546
+ loadOptions = {
2547
+ ...loadOptions,
2548
+ terrain: {
2549
+ skirtHeight: this.state.isTiled ? meshMaxError * 2 : 0,
2550
+ ...loadOptions == null ? void 0 : loadOptions.terrain,
2551
+ bounds,
2552
+ meshMaxError,
2553
+ elevationDecoder
2554
+ }
2555
+ };
2556
+ const { fetch } = this.props;
2557
+ return fetch(elevationData, { propName: "elevationData", layer: this, loadOptions, signal });
2558
+ }
2559
+ getTiledTerrainData(tile) {
2560
+ const { elevationData, fetch, texture, elevationDecoder, meshMaxError } = this.props;
2561
+ const { viewport } = this.context;
2562
+ const dataUrl = getURLFromTemplate(elevationData, tile);
2563
+ const textureUrl = texture && getURLFromTemplate(texture, tile);
2564
+ const { signal } = tile;
2565
+ let bottomLeft = [0, 0];
2566
+ let topRight = [0, 0];
2567
+ if (viewport.isGeospatial) {
2568
+ const bbox = tile.bbox;
2569
+ bottomLeft = viewport.projectFlat([bbox.west, bbox.south]);
2570
+ topRight = viewport.projectFlat([bbox.east, bbox.north]);
2571
+ } else {
2572
+ const bbox = tile.bbox;
2573
+ bottomLeft = [bbox.left, bbox.bottom];
2574
+ topRight = [bbox.right, bbox.top];
2575
+ }
2576
+ const bounds = [bottomLeft[0], bottomLeft[1], topRight[0], topRight[1]];
2577
+ const terrain = this.loadTerrain({
2578
+ elevationData: dataUrl,
2579
+ bounds,
2580
+ elevationDecoder,
2581
+ meshMaxError,
2582
+ signal
2583
+ });
2584
+ const surface = textureUrl ? fetch(textureUrl, { propName: "texture", layer: this, loaders: [], signal }).catch((_) => null) : Promise.resolve(null);
2585
+ return Promise.all([terrain, surface]);
2586
+ }
2587
+ renderSubLayers(props) {
2588
+ const SubLayerClass = this.getSubLayerClass("mesh", import_mesh_layers3.SimpleMeshLayer);
2589
+ const { color, wireframe, material } = this.props;
2590
+ const { data } = props;
2591
+ if (!data) {
2592
+ return null;
2593
+ }
2594
+ const [mesh, texture] = data;
2595
+ return new SubLayerClass(props, {
2596
+ data: DUMMY_DATA,
2597
+ mesh,
2598
+ texture,
2599
+ _instanced: false,
2600
+ coordinateSystem: import_core12.COORDINATE_SYSTEM.CARTESIAN,
2601
+ getPosition: (d) => [0, 0, 0],
2602
+ getColor: color,
2603
+ wireframe,
2604
+ material
2605
+ });
2606
+ }
2607
+ onViewportLoad(tiles) {
2608
+ if (!tiles) {
2609
+ return;
2610
+ }
2611
+ const { zRange } = this.state;
2612
+ const ranges = tiles.map((tile) => tile.content).filter(Boolean).map((arr) => {
2613
+ const bounds = arr[0].header.boundingBox;
2614
+ return bounds.map((bound) => bound[2]);
2615
+ });
2616
+ if (ranges.length === 0) {
2617
+ return;
2618
+ }
2619
+ const minZ = Math.min(...ranges.map((x) => x[0]));
2620
+ const maxZ = Math.max(...ranges.map((x) => x[1]));
2621
+ if (!zRange || minZ < zRange[0] || maxZ > zRange[1]) {
2622
+ this.setState({ zRange: [minZ, maxZ] });
2623
+ }
2624
+ }
2625
+ renderLayers() {
2626
+ const { color, material, elevationData, texture, wireframe, meshMaxError, elevationDecoder, tileSize, maxZoom, minZoom, extent, maxRequests, onTileLoad, onTileUnload, onTileError, maxCacheSize, maxCacheByteSize, refinementStrategy } = this.props;
2627
+ if (this.state.isTiled) {
2628
+ return new TileLayer(this.getSubLayerProps({
2629
+ id: "tiles"
2630
+ }), {
2631
+ getTileData: this.getTiledTerrainData.bind(this),
2632
+ renderSubLayers: this.renderSubLayers.bind(this),
2633
+ updateTriggers: {
2634
+ getTileData: {
2635
+ elevationData: urlTemplateToUpdateTrigger(elevationData),
2636
+ texture: urlTemplateToUpdateTrigger(texture),
2637
+ meshMaxError,
2638
+ elevationDecoder
2639
+ }
2640
+ },
2641
+ onViewportLoad: this.onViewportLoad.bind(this),
2642
+ zRange: this.state.zRange || null,
2643
+ tileSize,
2644
+ maxZoom,
2645
+ minZoom,
2646
+ extent,
2647
+ maxRequests,
2648
+ onTileLoad,
2649
+ onTileUnload,
2650
+ onTileError,
2651
+ maxCacheSize,
2652
+ maxCacheByteSize,
2653
+ refinementStrategy
2654
+ });
2655
+ }
2656
+ if (!elevationData) {
2657
+ return null;
2658
+ }
2659
+ const SubLayerClass = this.getSubLayerClass("mesh", import_mesh_layers3.SimpleMeshLayer);
2660
+ return new SubLayerClass(this.getSubLayerProps({
2661
+ id: "mesh"
2662
+ }), {
2663
+ data: DUMMY_DATA,
2664
+ mesh: this.state.terrain,
2665
+ texture,
2666
+ _instanced: false,
2667
+ getPosition: (d) => [0, 0, 0],
2668
+ getColor: color,
2669
+ material,
2670
+ wireframe
2671
+ });
2672
+ }
2673
+ };
2674
+ var TerrainLayer = _TerrainLayer;
2675
+ (() => {
2676
+ _TerrainLayer.defaultProps = defaultProps12;
2677
+ })();
2678
+ (() => {
2679
+ _TerrainLayer.layerName = "TerrainLayer";
2680
+ })();
2681
+
2682
+ // dist/mvt-layer/mvt-layer.js
2683
+ var import_core14 = require("@deck.gl/core");
2684
+ var import_layers8 = require("@deck.gl/layers");
2685
+ var import_extensions = require("@deck.gl/extensions");
2686
+ var import_core15 = require("@math.gl/core");
2687
+ var import_mvt = require("@loaders.gl/mvt");
2688
+ var import_gis = require("@loaders.gl/gis");
2689
+
2690
+ // dist/mvt-layer/coordinate-transform.js
2691
+ var import_core13 = require("@math.gl/core");
2692
+ var availableTransformations = {
2693
+ Point,
2694
+ MultiPoint,
2695
+ LineString,
2696
+ MultiLineString,
2697
+ Polygon,
2698
+ MultiPolygon
2699
+ };
2700
+ function Point([pointX, pointY], [nw, se], viewport) {
2701
+ const x = (0, import_core13.lerp)(nw[0], se[0], pointX);
2702
+ const y = (0, import_core13.lerp)(nw[1], se[1], pointY);
2703
+ return viewport.unprojectFlat([x, y]);
2704
+ }
2705
+ function getPoints(geometry, bbox, viewport) {
2706
+ return geometry.map((g) => Point(g, bbox, viewport));
2707
+ }
2708
+ function MultiPoint(multiPoint, bbox, viewport) {
2709
+ return getPoints(multiPoint, bbox, viewport);
2710
+ }
2711
+ function LineString(line, bbox, viewport) {
2712
+ return getPoints(line, bbox, viewport);
2713
+ }
2714
+ function MultiLineString(multiLineString, bbox, viewport) {
2715
+ return multiLineString.map((lineString) => LineString(lineString, bbox, viewport));
2716
+ }
2717
+ function Polygon(polygon, bbox, viewport) {
2718
+ return polygon.map((polygonRing) => getPoints(polygonRing, bbox, viewport));
2719
+ }
2720
+ function MultiPolygon(multiPolygon, bbox, viewport) {
2721
+ return multiPolygon.map((polygon) => Polygon(polygon, bbox, viewport));
2722
+ }
2723
+ function transform(geometry, bbox, viewport) {
2724
+ const nw = viewport.projectFlat([bbox.west, bbox.north]);
2725
+ const se = viewport.projectFlat([bbox.east, bbox.south]);
2726
+ const projectedBbox = [nw, se];
2727
+ return {
2728
+ ...geometry,
2729
+ coordinates: availableTransformations[geometry.type](geometry.coordinates, projectedBbox, viewport)
2730
+ };
2731
+ }
2732
+
2733
+ // dist/mvt-layer/find-index-binary.js
2734
+ var GEOM_TYPES = ["points", "lines", "polygons"];
2735
+ function findIndexBinary(data, uniqueIdProperty, featureId, layerName) {
2736
+ for (const gt of GEOM_TYPES) {
2737
+ const index = data[gt] && findIndexByType(data[gt], uniqueIdProperty, featureId, layerName);
2738
+ if (index >= 0) {
2739
+ return index;
2740
+ }
2741
+ }
2742
+ return -1;
2743
+ }
2744
+ function findIndexByType(geomData, uniqueIdProperty, featureId, layerName) {
2745
+ const featureIds = geomData.featureIds.value;
2746
+ if (!featureIds.length) {
2747
+ return -1;
2748
+ }
2749
+ let startFeatureIndex = 0;
2750
+ let endFeatureIndex = featureIds[featureIds.length - 1] + 1;
2751
+ if (layerName) {
2752
+ const layerRange = getLayerRange(geomData, layerName);
2753
+ if (layerRange) {
2754
+ startFeatureIndex = layerRange[0];
2755
+ endFeatureIndex = layerRange[1] + 1;
2756
+ } else {
2757
+ return -1;
2758
+ }
2759
+ }
2760
+ let featureIndex = -1;
2761
+ if (uniqueIdProperty in geomData.numericProps) {
2762
+ const vertexIndex = geomData.numericProps[uniqueIdProperty].value.findIndex((x, i) => x === featureId && featureIds[i] >= startFeatureIndex && featureIds[i] < endFeatureIndex);
2763
+ return vertexIndex >= 0 ? geomData.globalFeatureIds.value[vertexIndex] : -1;
2764
+ } else if (uniqueIdProperty) {
2765
+ featureIndex = findIndex(geomData.properties, (elem) => elem[uniqueIdProperty] === featureId, startFeatureIndex, endFeatureIndex);
2766
+ } else if (geomData.fields) {
2767
+ featureIndex = findIndex(geomData.fields, (elem) => elem.id === featureId, startFeatureIndex, endFeatureIndex);
2768
+ }
2769
+ return featureIndex >= 0 ? getGlobalFeatureId(geomData, featureIndex) : -1;
2770
+ }
2771
+ function getLayerRange(geomData, layerName) {
2772
+ if (!geomData.__layers) {
2773
+ const layerNames = {};
2774
+ const { properties } = geomData;
2775
+ for (let i = 0; i < properties.length; i++) {
2776
+ const { layerName: key } = properties[i];
2777
+ if (!key) {
2778
+ } else if (layerNames[key]) {
2779
+ layerNames[key][1] = i;
2780
+ } else {
2781
+ layerNames[key] = [i, i];
2782
+ }
2783
+ }
2784
+ geomData.__layers = layerNames;
2785
+ }
2786
+ return geomData.__layers[layerName];
2787
+ }
2788
+ function getGlobalFeatureId(geomData, featureIndex) {
2789
+ if (!geomData.__ids) {
2790
+ const result = [];
2791
+ const featureIds = geomData.featureIds.value;
2792
+ const globalFeatureIds = geomData.globalFeatureIds.value;
2793
+ for (let i = 0; i < featureIds.length; i++) {
2794
+ result[featureIds[i]] = globalFeatureIds[i];
2795
+ }
2796
+ geomData.__ids = result;
2797
+ }
2798
+ return geomData.__ids[featureIndex];
2799
+ }
2800
+ function findIndex(array, predicate, startIndex, endIndex) {
2801
+ for (let i = startIndex; i < endIndex; i++) {
2802
+ if (predicate(array[i], i)) {
2803
+ return i;
2804
+ }
2805
+ }
2806
+ return -1;
2807
+ }
2808
+
2809
+ // dist/mvt-layer/mvt-layer.js
2810
+ var WORLD_SIZE = 512;
2811
+ var defaultProps13 = {
2812
+ ...import_layers8.GeoJsonLayer.defaultProps,
2813
+ data: urlType,
2814
+ onDataLoad: { type: "function", value: null, optional: true, compare: false },
2815
+ uniqueIdProperty: "",
2816
+ highlightedFeatureId: null,
2817
+ loaders: [import_mvt.MVTWorkerLoader],
2818
+ binary: true
2819
+ };
2820
+ var _MVTLayer = class extends TileLayer {
2821
+ initializeState() {
2822
+ super.initializeState();
2823
+ const binary = this.context.viewport.resolution !== void 0 ? false : this.props.binary;
2824
+ this.setState({
2825
+ binary,
2826
+ data: null,
2827
+ tileJSON: null,
2828
+ hoveredFeatureId: null,
2829
+ hoveredFeatureLayerName: null
2830
+ });
2831
+ }
2832
+ get isLoaded() {
2833
+ var _a;
2834
+ return Boolean(((_a = this.state) == null ? void 0 : _a.data) && super.isLoaded);
2835
+ }
2836
+ updateState({ props, oldProps, context, changeFlags }) {
2837
+ var _a;
2838
+ if (changeFlags.dataChanged) {
2839
+ this._updateTileData();
2840
+ }
2841
+ if ((_a = this.state) == null ? void 0 : _a.data) {
2842
+ super.updateState({ props, oldProps, context, changeFlags });
2843
+ this._setWGS84PropertyForTiles();
2844
+ }
2845
+ const { highlightColor } = props;
2846
+ if (highlightColor !== oldProps.highlightColor && Array.isArray(highlightColor)) {
2847
+ this.setState({ highlightColor });
2848
+ }
2849
+ }
2850
+ async _updateTileData() {
2851
+ let data = this.props.data;
2852
+ let tileJSON = null;
2853
+ if (typeof data === "string" && !isURLTemplate(data)) {
2854
+ const { onDataLoad, fetch } = this.props;
2855
+ this.setState({ data: null, tileJSON: null });
2856
+ try {
2857
+ tileJSON = await fetch(data, { propName: "data", layer: this, loaders: [] });
2858
+ } catch (error) {
2859
+ this.raiseError(error, "loading TileJSON");
2860
+ data = null;
2861
+ }
2862
+ if (onDataLoad) {
2863
+ onDataLoad(tileJSON, { propName: "data", layer: this });
2864
+ }
2865
+ } else if (data && typeof data === "object" && "tilejson" in data) {
2866
+ tileJSON = data;
2867
+ }
2868
+ if (tileJSON) {
2869
+ data = tileJSON.tiles;
2870
+ }
2871
+ this.setState({ data, tileJSON });
2872
+ }
2873
+ _getTilesetOptions() {
2874
+ const opts = super._getTilesetOptions();
2875
+ const tileJSON = this.state.tileJSON;
2876
+ const { minZoom, maxZoom } = this.props;
2877
+ if (tileJSON) {
2878
+ if (Number.isFinite(tileJSON.minzoom) && tileJSON.minzoom > minZoom) {
2879
+ opts.minZoom = tileJSON.minzoom;
2880
+ }
2881
+ if (Number.isFinite(tileJSON.maxzoom) && (!Number.isFinite(maxZoom) || tileJSON.maxzoom < maxZoom)) {
2882
+ opts.maxZoom = tileJSON.maxzoom;
2883
+ }
2884
+ }
2885
+ return opts;
2886
+ }
2887
+ renderLayers() {
2888
+ var _a;
2889
+ if (!((_a = this.state) == null ? void 0 : _a.data))
2890
+ return null;
2891
+ return super.renderLayers();
2892
+ }
2893
+ getTileData(loadProps) {
2894
+ const { data, binary } = this.state;
2895
+ const { index, signal } = loadProps;
2896
+ const url = getURLFromTemplate(data, loadProps);
2897
+ if (!url) {
2898
+ return Promise.reject("Invalid URL");
2899
+ }
2900
+ let loadOptions = this.getLoadOptions();
2901
+ const { fetch } = this.props;
2902
+ loadOptions = {
2903
+ ...loadOptions,
2904
+ mimeType: "application/x-protobuf",
2905
+ mvt: {
2906
+ ...loadOptions == null ? void 0 : loadOptions.mvt,
2907
+ coordinates: this.context.viewport.resolution ? "wgs84" : "local",
2908
+ tileIndex: index
2909
+ },
2910
+ gis: binary ? { format: "binary" } : {}
2911
+ };
2912
+ return fetch(url, { propName: "data", layer: this, loadOptions, signal });
2913
+ }
2914
+ renderSubLayers(props) {
2915
+ const { x, y, z } = props.tile.index;
2916
+ const worldScale = Math.pow(2, z);
2917
+ const xScale = WORLD_SIZE / worldScale;
2918
+ const yScale = -xScale;
2919
+ const xOffset = WORLD_SIZE * x / worldScale;
2920
+ const yOffset = WORLD_SIZE * (1 - y / worldScale);
2921
+ const modelMatrix = new import_core15.Matrix4().scale([xScale, yScale, 1]);
2922
+ props.autoHighlight = false;
2923
+ if (!this.context.viewport.resolution) {
2924
+ props.modelMatrix = modelMatrix;
2925
+ props.coordinateOrigin = [xOffset, yOffset, 0];
2926
+ props.coordinateSystem = import_core14.COORDINATE_SYSTEM.CARTESIAN;
2927
+ props.extensions = [...props.extensions || [], new import_extensions.ClipExtension()];
2928
+ }
2929
+ const subLayers = super.renderSubLayers(props);
2930
+ if (this.state.binary && !(subLayers instanceof import_layers8.GeoJsonLayer)) {
2931
+ import_core14.log.warn("renderSubLayers() must return GeoJsonLayer when using binary:true")();
2932
+ }
2933
+ return subLayers;
2934
+ }
2935
+ _updateAutoHighlight(info) {
2936
+ const { uniqueIdProperty } = this.props;
2937
+ const { hoveredFeatureId, hoveredFeatureLayerName } = this.state;
2938
+ const hoveredFeature = info.object;
2939
+ let newHoveredFeatureId = null;
2940
+ let newHoveredFeatureLayerName = null;
2941
+ if (hoveredFeature) {
2942
+ newHoveredFeatureId = getFeatureUniqueId(hoveredFeature, uniqueIdProperty);
2943
+ newHoveredFeatureLayerName = getFeatureLayerName(hoveredFeature);
2944
+ }
2945
+ let { highlightColor } = this.props;
2946
+ if (typeof highlightColor === "function") {
2947
+ highlightColor = highlightColor(info);
2948
+ }
2949
+ if (hoveredFeatureId !== newHoveredFeatureId || hoveredFeatureLayerName !== newHoveredFeatureLayerName) {
2950
+ this.setState({
2951
+ highlightColor,
2952
+ hoveredFeatureId: newHoveredFeatureId,
2953
+ hoveredFeatureLayerName: newHoveredFeatureLayerName
2954
+ });
2955
+ }
2956
+ }
2957
+ getPickingInfo(params) {
2958
+ const info = super.getPickingInfo(params);
2959
+ const isWGS84 = Boolean(this.context.viewport.resolution);
2960
+ if (this.state.binary && info.index !== -1) {
2961
+ const { data } = params.sourceLayer.props;
2962
+ info.object = (0, import_gis.binaryToGeojson)(data, {
2963
+ globalFeatureId: info.index
2964
+ });
2965
+ }
2966
+ if (info.object && !isWGS84) {
2967
+ info.object = transformTileCoordsToWGS84(
2968
+ info.object,
2969
+ info.tile.bbox,
2970
+ this.context.viewport
2971
+ );
2972
+ }
2973
+ return info;
2974
+ }
2975
+ getSubLayerPropsByTile(tile) {
2976
+ return {
2977
+ highlightedObjectIndex: this.getHighlightedObjectIndex(tile),
2978
+ highlightColor: this.state.highlightColor
2979
+ };
2980
+ }
2981
+ getHighlightedObjectIndex(tile) {
2982
+ const { hoveredFeatureId, hoveredFeatureLayerName, binary } = this.state;
2983
+ const { uniqueIdProperty, highlightedFeatureId } = this.props;
2984
+ const data = tile.content;
2985
+ const isHighlighted = isFeatureIdDefined(highlightedFeatureId);
2986
+ const isFeatureIdPresent = isFeatureIdDefined(hoveredFeatureId) || isHighlighted;
2987
+ if (!isFeatureIdPresent) {
2988
+ return -1;
2989
+ }
2990
+ const featureIdToHighlight = isHighlighted ? highlightedFeatureId : hoveredFeatureId;
2991
+ if (Array.isArray(data)) {
2992
+ return data.findIndex((feature) => {
2993
+ const isMatchingId = getFeatureUniqueId(feature, uniqueIdProperty) === featureIdToHighlight;
2994
+ const isMatchingLayer = isHighlighted || getFeatureLayerName(feature) === hoveredFeatureLayerName;
2995
+ return isMatchingId && isMatchingLayer;
2996
+ });
2997
+ } else if (data && binary) {
2998
+ return findIndexBinary(data, uniqueIdProperty, featureIdToHighlight, isHighlighted ? "" : hoveredFeatureLayerName);
2999
+ }
3000
+ return -1;
3001
+ }
3002
+ _pickObjects(maxObjects) {
3003
+ const { deck, viewport } = this.context;
3004
+ const width = viewport.width;
3005
+ const height = viewport.height;
3006
+ const x = viewport.x;
3007
+ const y = viewport.y;
3008
+ const layerIds = [this.id];
3009
+ return deck.pickObjects({ x, y, width, height, layerIds, maxObjects });
3010
+ }
3011
+ getRenderedFeatures(maxFeatures = null) {
3012
+ const features = this._pickObjects(maxFeatures);
3013
+ const featureCache = /* @__PURE__ */ new Set();
3014
+ const renderedFeatures = [];
3015
+ for (const f of features) {
3016
+ const featureId = getFeatureUniqueId(f.object, this.props.uniqueIdProperty);
3017
+ if (featureId === void 0) {
3018
+ renderedFeatures.push(f.object);
3019
+ } else if (!featureCache.has(featureId)) {
3020
+ featureCache.add(featureId);
3021
+ renderedFeatures.push(f.object);
3022
+ }
3023
+ }
3024
+ return renderedFeatures;
3025
+ }
3026
+ _setWGS84PropertyForTiles() {
3027
+ const propName = "dataInWGS84";
3028
+ const tileset = this.state.tileset;
3029
+ tileset.selectedTiles.forEach((tile) => {
3030
+ if (!tile.hasOwnProperty(propName)) {
3031
+ Object.defineProperty(tile, propName, {
3032
+ get: () => {
3033
+ if (!tile.content) {
3034
+ return null;
3035
+ }
3036
+ if (this.state.binary && Array.isArray(tile.content) && !tile.content.length) {
3037
+ return [];
3038
+ }
3039
+ const { bbox } = tile;
3040
+ if (tile._contentWGS84 === void 0 && isGeoBoundingBox(bbox)) {
3041
+ const content = this.state.binary ? (0, import_gis.binaryToGeojson)(tile.content) : tile.content;
3042
+ tile._contentWGS84 = content.map((feature) => transformTileCoordsToWGS84(feature, bbox, this.context.viewport));
3043
+ }
3044
+ return tile._contentWGS84;
3045
+ }
3046
+ });
3047
+ }
3048
+ });
3049
+ }
3050
+ };
3051
+ var MVTLayer = _MVTLayer;
3052
+ (() => {
3053
+ _MVTLayer.layerName = "MVTLayer";
3054
+ })();
3055
+ (() => {
3056
+ _MVTLayer.defaultProps = defaultProps13;
3057
+ })();
3058
+ function getFeatureUniqueId(feature, uniqueIdProperty) {
3059
+ if (feature.properties && uniqueIdProperty) {
3060
+ return feature.properties[uniqueIdProperty];
3061
+ }
3062
+ if ("id" in feature) {
3063
+ return feature.id;
3064
+ }
3065
+ return void 0;
3066
+ }
3067
+ function getFeatureLayerName(feature) {
3068
+ var _a;
3069
+ return ((_a = feature.properties) == null ? void 0 : _a.layerName) || null;
3070
+ }
3071
+ function isFeatureIdDefined(value) {
3072
+ return value !== void 0 && value !== null && value !== "";
3073
+ }
3074
+ function transformTileCoordsToWGS84(object, bbox, viewport) {
3075
+ const feature = {
3076
+ ...object,
3077
+ geometry: {
3078
+ type: object.geometry.type
3079
+ }
3080
+ };
3081
+ Object.defineProperty(feature.geometry, "coordinates", {
3082
+ get: () => {
3083
+ const wgs84Geom = transform(object.geometry, bbox, viewport);
3084
+ return wgs84Geom.coordinates;
3085
+ }
3086
+ });
3087
+ return feature;
3088
+ }
3089
+
3090
+ // dist/geohash-layer/geohash-utils.js
3091
+ var BASE32_CODES = "0123456789bcdefghjkmnpqrstuvwxyz";
3092
+ var BASE32_CODES_DICT = {};
3093
+ for (let i = 0; i < BASE32_CODES.length; i++) {
3094
+ BASE32_CODES_DICT[BASE32_CODES.charAt(i)] = i;
3095
+ }
3096
+ var MIN_LAT = -90;
3097
+ var MAX_LAT = 90;
3098
+ var MIN_LON = -180;
3099
+ var MAX_LON = 180;
3100
+ function getGeohashBounds(geohash) {
3101
+ let isLon = true;
3102
+ let maxLat = MAX_LAT;
3103
+ let minLat = MIN_LAT;
3104
+ let maxLon = MAX_LON;
3105
+ let minLon = MIN_LON;
3106
+ let mid;
3107
+ let hashValue = 0;
3108
+ for (let i = 0, l = geohash.length; i < l; i++) {
3109
+ const code = geohash[i].toLowerCase();
3110
+ hashValue = BASE32_CODES_DICT[code];
3111
+ for (let bits = 4; bits >= 0; bits--) {
3112
+ const bit = hashValue >> bits & 1;
3113
+ if (isLon) {
3114
+ mid = (maxLon + minLon) / 2;
3115
+ if (bit === 1) {
3116
+ minLon = mid;
3117
+ } else {
3118
+ maxLon = mid;
3119
+ }
3120
+ } else {
3121
+ mid = (maxLat + minLat) / 2;
3122
+ if (bit === 1) {
3123
+ minLat = mid;
3124
+ } else {
3125
+ maxLat = mid;
3126
+ }
3127
+ }
3128
+ isLon = !isLon;
3129
+ }
3130
+ }
3131
+ return [minLat, minLon, maxLat, maxLon];
3132
+ }
3133
+ function getGeohashPolygon(geohash) {
3134
+ const [s, w, n, e] = getGeohashBounds(geohash);
3135
+ return [e, n, e, s, w, s, w, n, e, n];
3136
+ }
3137
+
3138
+ // dist/geohash-layer/geohash-layer.js
3139
+ var defaultProps14 = {
3140
+ getGeohash: { type: "accessor", value: (d) => d.geohash }
3141
+ };
3142
+ var _GeohashLayer = class extends GeoCellLayer {
3143
+ indexToBounds() {
3144
+ const { data, getGeohash } = this.props;
3145
+ return {
3146
+ data,
3147
+ _normalize: false,
3148
+ positionFormat: "XY",
3149
+ getPolygon: (x, objectInfo) => getGeohashPolygon(getGeohash(x, objectInfo))
3150
+ };
3151
+ }
3152
+ };
3153
+ var GeohashLayer = _GeohashLayer;
3154
+ (() => {
3155
+ _GeohashLayer.layerName = "GeohashLayer";
3156
+ })();
3157
+ (() => {
3158
+ _GeohashLayer.defaultProps = defaultProps14;
3159
+ })();
3160
+ //# sourceMappingURL=index.cjs.map