@loaders.gl/mvt 4.0.0-alpha.4 → 4.0.0-alpha.6

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 (198) hide show
  1. package/dist/bundle.d.ts +2 -0
  2. package/dist/bundle.d.ts.map +1 -0
  3. package/dist/bundle.js +2 -2
  4. package/dist/dist.min.js +3124 -0
  5. package/dist/es5/bundle.js +6 -0
  6. package/dist/es5/bundle.js.map +1 -0
  7. package/dist/es5/helpers/binary-util-functions.js +82 -0
  8. package/dist/es5/helpers/binary-util-functions.js.map +1 -0
  9. package/dist/es5/helpers/mapbox-util-functions.js +50 -0
  10. package/dist/es5/helpers/mapbox-util-functions.js.map +1 -0
  11. package/dist/es5/index.js +26 -0
  12. package/dist/es5/index.js.map +1 -0
  13. package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js +168 -0
  14. package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js.map +1 -0
  15. package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js +62 -0
  16. package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js.map +1 -0
  17. package/dist/es5/lib/binary-vector-tile/vector-tile.js +28 -0
  18. package/dist/es5/lib/binary-vector-tile/vector-tile.js.map +1 -0
  19. package/dist/es5/lib/geojson-tiler/LICENSE +19 -0
  20. package/dist/es5/lib/geojson-tiler/clip.js +237 -0
  21. package/dist/es5/lib/geojson-tiler/clip.js.map +1 -0
  22. package/dist/es5/lib/geojson-tiler/convert.js +161 -0
  23. package/dist/es5/lib/geojson-tiler/convert.js.map +1 -0
  24. package/dist/es5/lib/geojson-tiler/feature.js +62 -0
  25. package/dist/es5/lib/geojson-tiler/feature.js.map +1 -0
  26. package/dist/es5/lib/geojson-tiler/geojson-tiler.js +186 -0
  27. package/dist/es5/lib/geojson-tiler/geojson-tiler.js.map +1 -0
  28. package/dist/es5/lib/geojson-tiler/simplify.js +52 -0
  29. package/dist/es5/lib/geojson-tiler/simplify.js.map +1 -0
  30. package/dist/es5/lib/geojson-tiler/tile.js +121 -0
  31. package/dist/es5/lib/geojson-tiler/tile.js.map +1 -0
  32. package/dist/es5/lib/geojson-tiler/transform.js +50 -0
  33. package/dist/es5/lib/geojson-tiler/transform.js.map +1 -0
  34. package/dist/es5/lib/geojson-tiler/wrap.js +122 -0
  35. package/dist/es5/lib/geojson-tiler/wrap.js.map +1 -0
  36. package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js +184 -0
  37. package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js.map +1 -0
  38. package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js +62 -0
  39. package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js.map +1 -0
  40. package/dist/es5/lib/mapbox-vector-tile/vector-tile.js +28 -0
  41. package/dist/es5/lib/mapbox-vector-tile/vector-tile.js.map +1 -0
  42. package/dist/es5/lib/parse-mvt.js +143 -0
  43. package/dist/es5/lib/parse-mvt.js.map +1 -0
  44. package/dist/es5/lib/types.js +2 -0
  45. package/dist/es5/lib/types.js.map +1 -0
  46. package/dist/es5/mvt-loader.js +58 -0
  47. package/dist/es5/mvt-loader.js.map +1 -0
  48. package/dist/es5/workers/mvt-worker.js +6 -0
  49. package/dist/es5/workers/mvt-worker.js.map +1 -0
  50. package/dist/esm/bundle.js +4 -0
  51. package/dist/esm/bundle.js.map +1 -0
  52. package/dist/esm/helpers/binary-util-functions.js +73 -0
  53. package/dist/esm/helpers/binary-util-functions.js.map +1 -0
  54. package/dist/esm/helpers/mapbox-util-functions.js +41 -0
  55. package/dist/esm/helpers/mapbox-util-functions.js.map +1 -0
  56. package/dist/esm/index.js +3 -0
  57. package/dist/esm/index.js.map +1 -0
  58. package/dist/esm/lib/binary-vector-tile/LICENSE.txt +31 -0
  59. package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js +136 -0
  60. package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js.map +1 -0
  61. package/dist/esm/lib/binary-vector-tile/vector-tile-layer.js +47 -0
  62. package/dist/esm/lib/binary-vector-tile/vector-tile-layer.js.map +1 -0
  63. package/dist/esm/lib/binary-vector-tile/vector-tile.js +19 -0
  64. package/dist/esm/lib/binary-vector-tile/vector-tile.js.map +1 -0
  65. package/dist/esm/lib/geojson-tiler/LICENSE +19 -0
  66. package/dist/esm/lib/geojson-tiler/clip.js +173 -0
  67. package/dist/esm/lib/geojson-tiler/clip.js.map +1 -0
  68. package/dist/esm/lib/geojson-tiler/convert.js +116 -0
  69. package/dist/esm/lib/geojson-tiler/convert.js.map +1 -0
  70. package/dist/esm/lib/geojson-tiler/feature.js +35 -0
  71. package/dist/esm/lib/geojson-tiler/feature.js.map +1 -0
  72. package/dist/esm/lib/geojson-tiler/geojson-tiler.js +171 -0
  73. package/dist/esm/lib/geojson-tiler/geojson-tiler.js.map +1 -0
  74. package/dist/esm/lib/geojson-tiler/simplify.js +46 -0
  75. package/dist/esm/lib/geojson-tiler/simplify.js.map +1 -0
  76. package/dist/esm/lib/geojson-tiler/tile.js +103 -0
  77. package/dist/esm/lib/geojson-tiler/tile.js.map +1 -0
  78. package/dist/esm/lib/geojson-tiler/transform.js +32 -0
  79. package/dist/esm/lib/geojson-tiler/transform.js.map +1 -0
  80. package/dist/esm/lib/geojson-tiler/wrap.js +67 -0
  81. package/dist/esm/lib/geojson-tiler/wrap.js.map +1 -0
  82. package/dist/esm/lib/mapbox-vector-tile/LICENSE.txt +31 -0
  83. package/dist/esm/lib/mapbox-vector-tile/vector-tile-feature.js +163 -0
  84. package/dist/esm/lib/mapbox-vector-tile/vector-tile-feature.js.map +1 -0
  85. package/dist/esm/lib/mapbox-vector-tile/vector-tile-layer.js +47 -0
  86. package/dist/esm/lib/mapbox-vector-tile/vector-tile-layer.js.map +1 -0
  87. package/dist/esm/lib/mapbox-vector-tile/vector-tile.js +19 -0
  88. package/dist/esm/lib/mapbox-vector-tile/vector-tile.js.map +1 -0
  89. package/dist/esm/lib/parse-mvt.js +138 -0
  90. package/dist/esm/lib/parse-mvt.js.map +1 -0
  91. package/dist/esm/lib/types.js +2 -0
  92. package/dist/esm/lib/types.js.map +1 -0
  93. package/dist/esm/mvt-loader.js +29 -0
  94. package/dist/esm/mvt-loader.js.map +1 -0
  95. package/dist/esm/workers/mvt-worker.js +4 -0
  96. package/dist/esm/workers/mvt-worker.js.map +1 -0
  97. package/dist/helpers/binary-util-functions.d.ts +35 -0
  98. package/dist/helpers/binary-util-functions.d.ts.map +1 -0
  99. package/dist/helpers/binary-util-functions.js +111 -74
  100. package/dist/helpers/mapbox-util-functions.d.ts +29 -0
  101. package/dist/helpers/mapbox-util-functions.d.ts.map +1 -0
  102. package/dist/helpers/mapbox-util-functions.js +78 -45
  103. package/dist/index.d.ts +4 -0
  104. package/dist/index.d.ts.map +1 -0
  105. package/dist/index.js +9 -2
  106. package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts +41 -0
  107. package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts.map +1 -0
  108. package/dist/lib/binary-vector-tile/vector-tile-feature.js +142 -142
  109. package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts +23 -0
  110. package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts.map +1 -0
  111. package/dist/lib/binary-vector-tile/vector-tile-layer.js +85 -58
  112. package/dist/lib/binary-vector-tile/vector-tile.d.ts +9 -0
  113. package/dist/lib/binary-vector-tile/vector-tile.d.ts.map +1 -0
  114. package/dist/lib/binary-vector-tile/vector-tile.js +25 -19
  115. package/dist/lib/geojson-tiler/clip.d.ts +16 -0
  116. package/dist/lib/geojson-tiler/clip.d.ts.map +1 -0
  117. package/dist/lib/geojson-tiler/clip.js +209 -0
  118. package/dist/lib/geojson-tiler/convert.d.ts +10 -0
  119. package/dist/lib/geojson-tiler/convert.d.ts.map +1 -0
  120. package/dist/lib/geojson-tiler/convert.js +134 -0
  121. package/dist/lib/geojson-tiler/feature.d.ts +3 -0
  122. package/dist/lib/geojson-tiler/feature.d.ts.map +1 -0
  123. package/dist/lib/geojson-tiler/feature.js +46 -0
  124. package/dist/lib/geojson-tiler/geojson-tiler.d.ts +44 -0
  125. package/dist/lib/geojson-tiler/geojson-tiler.d.ts.map +1 -0
  126. package/dist/lib/geojson-tiler/geojson-tiler.js +210 -0
  127. package/dist/lib/geojson-tiler/simplify.d.ts +10 -0
  128. package/dist/lib/geojson-tiler/simplify.d.ts.map +1 -0
  129. package/dist/lib/geojson-tiler/simplify.js +68 -0
  130. package/dist/lib/geojson-tiler/tile.d.ts +38 -0
  131. package/dist/lib/geojson-tiler/tile.d.ts.map +1 -0
  132. package/dist/lib/geojson-tiler/tile.js +125 -0
  133. package/dist/lib/geojson-tiler/transform.d.ts +7 -0
  134. package/dist/lib/geojson-tiler/transform.d.ts.map +1 -0
  135. package/dist/lib/geojson-tiler/transform.js +43 -0
  136. package/dist/lib/geojson-tiler/wrap.d.ts +17 -0
  137. package/dist/lib/geojson-tiler/wrap.d.ts.map +1 -0
  138. package/dist/lib/geojson-tiler/wrap.js +86 -0
  139. package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts +27 -0
  140. package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts.map +1 -0
  141. package/dist/lib/mapbox-vector-tile/vector-tile-feature.js +161 -193
  142. package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts +20 -0
  143. package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts.map +1 -0
  144. package/dist/lib/mapbox-vector-tile/vector-tile-layer.js +83 -58
  145. package/dist/lib/mapbox-vector-tile/vector-tile.d.ts +9 -0
  146. package/dist/lib/mapbox-vector-tile/vector-tile.d.ts.map +1 -0
  147. package/dist/lib/mapbox-vector-tile/vector-tile.js +25 -19
  148. package/dist/lib/parse-mvt.d.ts +14 -0
  149. package/dist/lib/parse-mvt.d.ts.map +1 -0
  150. package/dist/lib/parse-mvt.js +149 -98
  151. package/dist/lib/types.d.ts +69 -0
  152. package/dist/lib/types.d.ts.map +1 -0
  153. package/dist/lib/types.js +2 -2
  154. package/dist/mvt-loader.d.ts +10 -0
  155. package/dist/mvt-loader.d.ts.map +1 -0
  156. package/dist/mvt-loader.js +43 -22
  157. package/dist/mvt-worker.js +845 -766
  158. package/dist/workers/mvt-worker.d.ts +2 -0
  159. package/dist/workers/mvt-worker.d.ts.map +1 -0
  160. package/dist/workers/mvt-worker.js +5 -4
  161. package/package.json +10 -9
  162. package/src/helpers/binary-util-functions.ts +9 -7
  163. package/src/helpers/mapbox-util-functions.ts +2 -2
  164. package/src/index.ts +7 -0
  165. package/src/lib/binary-vector-tile/vector-tile-feature.ts +42 -45
  166. package/src/lib/binary-vector-tile/vector-tile-layer.ts +4 -4
  167. package/src/lib/geojson-tiler/LICENSE +19 -0
  168. package/src/lib/geojson-tiler/clip.ts +248 -0
  169. package/src/lib/geojson-tiler/convert.ts +158 -0
  170. package/src/lib/geojson-tiler/feature.ts +45 -0
  171. package/src/lib/geojson-tiler/geojson-tiler.ts +281 -0
  172. package/src/lib/geojson-tiler/simplify.ts +77 -0
  173. package/src/lib/geojson-tiler/tile.ts +185 -0
  174. package/src/lib/geojson-tiler/transform.ts +55 -0
  175. package/src/lib/geojson-tiler/wrap.ts +108 -0
  176. package/src/lib/mapbox-vector-tile/vector-tile-feature.ts +4 -4
  177. package/src/lib/parse-mvt.ts +138 -93
  178. package/src/lib/types.ts +49 -72
  179. package/src/mvt-loader.ts +13 -9
  180. package/dist/bundle.js.map +0 -1
  181. package/dist/helpers/binary-util-functions.js.map +0 -1
  182. package/dist/helpers/mapbox-util-functions.js.map +0 -1
  183. package/dist/index.js.map +0 -1
  184. package/dist/lib/binary-vector-tile/features-to-binary.js +0 -327
  185. package/dist/lib/binary-vector-tile/features-to-binary.js.map +0 -1
  186. package/dist/lib/binary-vector-tile/vector-tile-feature.js.map +0 -1
  187. package/dist/lib/binary-vector-tile/vector-tile-layer.js.map +0 -1
  188. package/dist/lib/binary-vector-tile/vector-tile.js.map +0 -1
  189. package/dist/lib/mapbox-vector-tile/vector-tile-feature.js.map +0 -1
  190. package/dist/lib/mapbox-vector-tile/vector-tile-layer.js.map +0 -1
  191. package/dist/lib/mapbox-vector-tile/vector-tile.js.map +0 -1
  192. package/dist/lib/parse-mvt.js.map +0 -1
  193. package/dist/lib/types.js.map +0 -1
  194. package/dist/mvt-loader.js.map +0 -1
  195. package/dist/workers/mvt-worker.js.map +0 -1
  196. package/src/lib/binary-vector-tile/features-to-binary.ts +0 -518
  197. /package/dist/{lib → es5/lib}/binary-vector-tile/LICENSE.txt +0 -0
  198. /package/dist/{lib → es5/lib}/mapbox-vector-tile/LICENSE.txt +0 -0
@@ -0,0 +1,3124 @@
1
+ (() => {
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 __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
9
+ var __esm = (fn, res) => function __init() {
10
+ return fn && (res = (0, fn[Object.keys(fn)[0]])(fn = 0)), res;
11
+ };
12
+ var __commonJS = (cb, mod) => function __require() {
13
+ return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
14
+ };
15
+ var __export = (target, all) => {
16
+ __markAsModule(target);
17
+ for (var name in all)
18
+ __defProp(target, name, { get: all[name], enumerable: true });
19
+ };
20
+ var __reExport = (target, module, desc) => {
21
+ if (module && typeof module === "object" || typeof module === "function") {
22
+ for (let key of __getOwnPropNames(module))
23
+ if (!__hasOwnProp.call(target, key) && key !== "default")
24
+ __defProp(target, key, { get: () => module[key], enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable });
25
+ }
26
+ return target;
27
+ };
28
+ var __toModule = (module) => {
29
+ return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
30
+ };
31
+
32
+ // ../../node_modules/@babel/runtime/helpers/esm/typeof.js
33
+ var init_typeof = __esm({
34
+ "../../node_modules/@babel/runtime/helpers/esm/typeof.js"() {
35
+ }
36
+ });
37
+
38
+ // ../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
39
+ var init_toPrimitive = __esm({
40
+ "../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js"() {
41
+ init_typeof();
42
+ }
43
+ });
44
+
45
+ // ../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
46
+ var init_toPropertyKey = __esm({
47
+ "../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js"() {
48
+ init_typeof();
49
+ init_toPrimitive();
50
+ }
51
+ });
52
+
53
+ // ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
54
+ var init_defineProperty = __esm({
55
+ "../../node_modules/@babel/runtime/helpers/esm/defineProperty.js"() {
56
+ init_toPropertyKey();
57
+ }
58
+ });
59
+
60
+ // ../../node_modules/@math.gl/polygon/dist/esm/polygon-utils.js
61
+ function getPolygonSignedArea(points, options = {}) {
62
+ const {
63
+ start = 0,
64
+ end = points.length
65
+ } = options;
66
+ const dim = options.size || 2;
67
+ let area2 = 0;
68
+ for (let i2 = start, j = end - dim; i2 < end; i2 += dim) {
69
+ area2 += (points[i2] - points[j]) * (points[i2 + 1] + points[j + 1]);
70
+ j = i2;
71
+ }
72
+ return area2 / 2;
73
+ }
74
+ var init_polygon_utils = __esm({
75
+ "../../node_modules/@math.gl/polygon/dist/esm/polygon-utils.js"() {
76
+ }
77
+ });
78
+
79
+ // ../../node_modules/@math.gl/polygon/dist/esm/polygon.js
80
+ var init_polygon = __esm({
81
+ "../../node_modules/@math.gl/polygon/dist/esm/polygon.js"() {
82
+ init_defineProperty();
83
+ init_polygon_utils();
84
+ }
85
+ });
86
+
87
+ // ../../node_modules/@math.gl/polygon/dist/esm/earcut.js
88
+ function earcut(positions, holeIndices, dim = 2, areas) {
89
+ const hasHoles = holeIndices && holeIndices.length;
90
+ const outerLen = hasHoles ? holeIndices[0] * dim : positions.length;
91
+ let outerNode = linkedList(positions, 0, outerLen, dim, true, areas && areas[0]);
92
+ const triangles = [];
93
+ if (!outerNode || outerNode.next === outerNode.prev)
94
+ return triangles;
95
+ let invSize;
96
+ let maxX;
97
+ let maxY;
98
+ let minX;
99
+ let minY;
100
+ let x2;
101
+ let y2;
102
+ if (hasHoles)
103
+ outerNode = eliminateHoles(positions, holeIndices, outerNode, dim, areas);
104
+ if (positions.length > 80 * dim) {
105
+ minX = maxX = positions[0];
106
+ minY = maxY = positions[1];
107
+ for (let i2 = dim; i2 < outerLen; i2 += dim) {
108
+ x2 = positions[i2];
109
+ y2 = positions[i2 + 1];
110
+ if (x2 < minX)
111
+ minX = x2;
112
+ if (y2 < minY)
113
+ minY = y2;
114
+ if (x2 > maxX)
115
+ maxX = x2;
116
+ if (y2 > maxY)
117
+ maxY = y2;
118
+ }
119
+ invSize = Math.max(maxX - minX, maxY - minY);
120
+ invSize = invSize !== 0 ? 1 / invSize : 0;
121
+ }
122
+ earcutLinked(outerNode, triangles, dim, minX, minY, invSize);
123
+ return triangles;
124
+ }
125
+ function linkedList(data, start, end, dim, clockwise, area2) {
126
+ let i2;
127
+ let last;
128
+ if (area2 === void 0) {
129
+ area2 = getPolygonSignedArea(data, {
130
+ start,
131
+ end,
132
+ size: dim
133
+ });
134
+ }
135
+ if (clockwise === area2 < 0) {
136
+ for (i2 = start; i2 < end; i2 += dim)
137
+ last = insertNode(i2, data[i2], data[i2 + 1], last);
138
+ } else {
139
+ for (i2 = end - dim; i2 >= start; i2 -= dim)
140
+ last = insertNode(i2, data[i2], data[i2 + 1], last);
141
+ }
142
+ if (last && equals(last, last.next)) {
143
+ removeNode(last);
144
+ last = last.next;
145
+ }
146
+ return last;
147
+ }
148
+ function filterPoints(start, end) {
149
+ if (!start)
150
+ return start;
151
+ if (!end)
152
+ end = start;
153
+ let p = start;
154
+ let again;
155
+ do {
156
+ again = false;
157
+ if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
158
+ removeNode(p);
159
+ p = end = p.prev;
160
+ if (p === p.next)
161
+ break;
162
+ again = true;
163
+ } else {
164
+ p = p.next;
165
+ }
166
+ } while (again || p !== end);
167
+ return end;
168
+ }
169
+ function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {
170
+ if (!ear)
171
+ return;
172
+ if (!pass && invSize)
173
+ indexCurve(ear, minX, minY, invSize);
174
+ let stop = ear;
175
+ let prev;
176
+ let next;
177
+ while (ear.prev !== ear.next) {
178
+ prev = ear.prev;
179
+ next = ear.next;
180
+ if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
181
+ triangles.push(prev.i / dim);
182
+ triangles.push(ear.i / dim);
183
+ triangles.push(next.i / dim);
184
+ removeNode(ear);
185
+ ear = next.next;
186
+ stop = next.next;
187
+ continue;
188
+ }
189
+ ear = next;
190
+ if (ear === stop) {
191
+ if (!pass) {
192
+ earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);
193
+ } else if (pass === 1) {
194
+ ear = cureLocalIntersections(filterPoints(ear), triangles, dim);
195
+ earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);
196
+ } else if (pass === 2) {
197
+ splitEarcut(ear, triangles, dim, minX, minY, invSize);
198
+ }
199
+ break;
200
+ }
201
+ }
202
+ }
203
+ function isEar(ear) {
204
+ const a = ear.prev;
205
+ const b = ear;
206
+ const c = ear.next;
207
+ if (area(a, b, c) >= 0)
208
+ return false;
209
+ let p = ear.next.next;
210
+ while (p !== ear.prev) {
211
+ if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0)
212
+ return false;
213
+ p = p.next;
214
+ }
215
+ return true;
216
+ }
217
+ function isEarHashed(ear, minX, minY, invSize) {
218
+ const a = ear.prev;
219
+ const b = ear;
220
+ const c = ear.next;
221
+ if (area(a, b, c) >= 0)
222
+ return false;
223
+ const minTX = a.x < b.x ? a.x < c.x ? a.x : c.x : b.x < c.x ? b.x : c.x;
224
+ const minTY = a.y < b.y ? a.y < c.y ? a.y : c.y : b.y < c.y ? b.y : c.y;
225
+ const maxTX = a.x > b.x ? a.x > c.x ? a.x : c.x : b.x > c.x ? b.x : c.x;
226
+ const maxTY = a.y > b.y ? a.y > c.y ? a.y : c.y : b.y > c.y ? b.y : c.y;
227
+ const minZ = zOrder(minTX, minTY, minX, minY, invSize);
228
+ const maxZ = zOrder(maxTX, maxTY, minX, minY, invSize);
229
+ let p = ear.prevZ;
230
+ let n = ear.nextZ;
231
+ while (p && p.z >= minZ && n && n.z <= maxZ) {
232
+ if (p !== ear.prev && p !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0)
233
+ return false;
234
+ p = p.prevZ;
235
+ if (n !== ear.prev && n !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) && area(n.prev, n, n.next) >= 0)
236
+ return false;
237
+ n = n.nextZ;
238
+ }
239
+ while (p && p.z >= minZ) {
240
+ if (p !== ear.prev && p !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0)
241
+ return false;
242
+ p = p.prevZ;
243
+ }
244
+ while (n && n.z <= maxZ) {
245
+ if (n !== ear.prev && n !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) && area(n.prev, n, n.next) >= 0)
246
+ return false;
247
+ n = n.nextZ;
248
+ }
249
+ return true;
250
+ }
251
+ function cureLocalIntersections(start, triangles, dim) {
252
+ let p = start;
253
+ do {
254
+ const a = p.prev;
255
+ const b = p.next.next;
256
+ if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {
257
+ triangles.push(a.i / dim);
258
+ triangles.push(p.i / dim);
259
+ triangles.push(b.i / dim);
260
+ removeNode(p);
261
+ removeNode(p.next);
262
+ p = start = b;
263
+ }
264
+ p = p.next;
265
+ } while (p !== start);
266
+ return filterPoints(p);
267
+ }
268
+ function splitEarcut(start, triangles, dim, minX, minY, invSize) {
269
+ let a = start;
270
+ do {
271
+ let b = a.next.next;
272
+ while (b !== a.prev) {
273
+ if (a.i !== b.i && isValidDiagonal(a, b)) {
274
+ let c = splitPolygon(a, b);
275
+ a = filterPoints(a, a.next);
276
+ c = filterPoints(c, c.next);
277
+ earcutLinked(a, triangles, dim, minX, minY, invSize);
278
+ earcutLinked(c, triangles, dim, minX, minY, invSize);
279
+ return;
280
+ }
281
+ b = b.next;
282
+ }
283
+ a = a.next;
284
+ } while (a !== start);
285
+ }
286
+ function eliminateHoles(data, holeIndices, outerNode, dim, areas) {
287
+ const queue = [];
288
+ let i2;
289
+ let len;
290
+ let start;
291
+ let end;
292
+ let list;
293
+ for (i2 = 0, len = holeIndices.length; i2 < len; i2++) {
294
+ start = holeIndices[i2] * dim;
295
+ end = i2 < len - 1 ? holeIndices[i2 + 1] * dim : data.length;
296
+ list = linkedList(data, start, end, dim, false, areas && areas[i2 + 1]);
297
+ if (list === list.next)
298
+ list.steiner = true;
299
+ queue.push(getLeftmost(list));
300
+ }
301
+ queue.sort(compareX);
302
+ for (i2 = 0; i2 < queue.length; i2++) {
303
+ eliminateHole(queue[i2], outerNode);
304
+ outerNode = filterPoints(outerNode, outerNode.next);
305
+ }
306
+ return outerNode;
307
+ }
308
+ function compareX(a, b) {
309
+ return a.x - b.x;
310
+ }
311
+ function eliminateHole(hole, outerNode) {
312
+ outerNode = findHoleBridge(hole, outerNode);
313
+ if (outerNode) {
314
+ const b = splitPolygon(outerNode, hole);
315
+ filterPoints(outerNode, outerNode.next);
316
+ filterPoints(b, b.next);
317
+ }
318
+ }
319
+ function findHoleBridge(hole, outerNode) {
320
+ let p = outerNode;
321
+ const hx = hole.x;
322
+ const hy = hole.y;
323
+ let qx = -Infinity;
324
+ let m;
325
+ do {
326
+ if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
327
+ const x2 = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
328
+ if (x2 <= hx && x2 > qx) {
329
+ qx = x2;
330
+ if (x2 === hx) {
331
+ if (hy === p.y)
332
+ return p;
333
+ if (hy === p.next.y)
334
+ return p.next;
335
+ }
336
+ m = p.x < p.next.x ? p : p.next;
337
+ }
338
+ }
339
+ p = p.next;
340
+ } while (p !== outerNode);
341
+ if (!m)
342
+ return null;
343
+ if (hx === qx)
344
+ return m;
345
+ const stop = m;
346
+ const mx = m.x;
347
+ const my = m.y;
348
+ let tanMin = Infinity;
349
+ let tan;
350
+ p = m;
351
+ do {
352
+ if (hx >= p.x && p.x >= mx && hx !== p.x && pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {
353
+ tan = Math.abs(hy - p.y) / (hx - p.x);
354
+ if (locallyInside(p, hole) && (tan < tanMin || tan === tanMin && (p.x > m.x || p.x === m.x && sectorContainsSector(m, p)))) {
355
+ m = p;
356
+ tanMin = tan;
357
+ }
358
+ }
359
+ p = p.next;
360
+ } while (p !== stop);
361
+ return m;
362
+ }
363
+ function sectorContainsSector(m, p) {
364
+ return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;
365
+ }
366
+ function indexCurve(start, minX, minY, invSize) {
367
+ let p = start;
368
+ do {
369
+ if (p.z === null)
370
+ p.z = zOrder(p.x, p.y, minX, minY, invSize);
371
+ p.prevZ = p.prev;
372
+ p.nextZ = p.next;
373
+ p = p.next;
374
+ } while (p !== start);
375
+ p.prevZ.nextZ = null;
376
+ p.prevZ = null;
377
+ sortLinked(p);
378
+ }
379
+ function sortLinked(list) {
380
+ let e;
381
+ let i2;
382
+ let inSize = 1;
383
+ let numMerges;
384
+ let p;
385
+ let pSize;
386
+ let q;
387
+ let qSize;
388
+ let tail;
389
+ do {
390
+ p = list;
391
+ list = null;
392
+ tail = null;
393
+ numMerges = 0;
394
+ while (p) {
395
+ numMerges++;
396
+ q = p;
397
+ pSize = 0;
398
+ for (i2 = 0; i2 < inSize; i2++) {
399
+ pSize++;
400
+ q = q.nextZ;
401
+ if (!q)
402
+ break;
403
+ }
404
+ qSize = inSize;
405
+ while (pSize > 0 || qSize > 0 && q) {
406
+ if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {
407
+ e = p;
408
+ p = p.nextZ;
409
+ pSize--;
410
+ } else {
411
+ e = q;
412
+ q = q.nextZ;
413
+ qSize--;
414
+ }
415
+ if (tail)
416
+ tail.nextZ = e;
417
+ else
418
+ list = e;
419
+ e.prevZ = tail;
420
+ tail = e;
421
+ }
422
+ p = q;
423
+ }
424
+ tail.nextZ = null;
425
+ inSize *= 2;
426
+ } while (numMerges > 1);
427
+ return list;
428
+ }
429
+ function zOrder(x2, y2, minX, minY, invSize) {
430
+ x2 = 32767 * (x2 - minX) * invSize;
431
+ y2 = 32767 * (y2 - minY) * invSize;
432
+ x2 = (x2 | x2 << 8) & 16711935;
433
+ x2 = (x2 | x2 << 4) & 252645135;
434
+ x2 = (x2 | x2 << 2) & 858993459;
435
+ x2 = (x2 | x2 << 1) & 1431655765;
436
+ y2 = (y2 | y2 << 8) & 16711935;
437
+ y2 = (y2 | y2 << 4) & 252645135;
438
+ y2 = (y2 | y2 << 2) & 858993459;
439
+ y2 = (y2 | y2 << 1) & 1431655765;
440
+ return x2 | y2 << 1;
441
+ }
442
+ function getLeftmost(start) {
443
+ let p = start;
444
+ let leftmost = start;
445
+ do {
446
+ if (p.x < leftmost.x || p.x === leftmost.x && p.y < leftmost.y)
447
+ leftmost = p;
448
+ p = p.next;
449
+ } while (p !== start);
450
+ return leftmost;
451
+ }
452
+ function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
453
+ return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 && (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 && (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0;
454
+ }
455
+ function isValidDiagonal(a, b) {
456
+ return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && (area(a.prev, a, b.prev) || area(a, b.prev, b)) || equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0);
457
+ }
458
+ function area(p, q, r) {
459
+ return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
460
+ }
461
+ function equals(p1, p2) {
462
+ return p1.x === p2.x && p1.y === p2.y;
463
+ }
464
+ function intersects(p1, q1, p2, q2) {
465
+ const o1 = sign(area(p1, q1, p2));
466
+ const o2 = sign(area(p1, q1, q2));
467
+ const o3 = sign(area(p2, q2, p1));
468
+ const o4 = sign(area(p2, q2, q1));
469
+ if (o1 !== o2 && o3 !== o4)
470
+ return true;
471
+ if (o1 === 0 && onSegment(p1, p2, q1))
472
+ return true;
473
+ if (o2 === 0 && onSegment(p1, q2, q1))
474
+ return true;
475
+ if (o3 === 0 && onSegment(p2, p1, q2))
476
+ return true;
477
+ if (o4 === 0 && onSegment(p2, q1, q2))
478
+ return true;
479
+ return false;
480
+ }
481
+ function onSegment(p, q, r) {
482
+ return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);
483
+ }
484
+ function sign(num) {
485
+ return num > 0 ? 1 : num < 0 ? -1 : 0;
486
+ }
487
+ function intersectsPolygon(a, b) {
488
+ let p = a;
489
+ do {
490
+ if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && intersects(p, p.next, a, b))
491
+ return true;
492
+ p = p.next;
493
+ } while (p !== a);
494
+ return false;
495
+ }
496
+ function locallyInside(a, b) {
497
+ return area(a.prev, a, a.next) < 0 ? area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 : area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;
498
+ }
499
+ function middleInside(a, b) {
500
+ let p = a;
501
+ let inside = false;
502
+ const px = (a.x + b.x) / 2;
503
+ const py = (a.y + b.y) / 2;
504
+ do {
505
+ if (p.y > py !== p.next.y > py && p.next.y !== p.y && px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x)
506
+ inside = !inside;
507
+ p = p.next;
508
+ } while (p !== a);
509
+ return inside;
510
+ }
511
+ function splitPolygon(a, b) {
512
+ const a2 = new Node(a.i, a.x, a.y);
513
+ const b2 = new Node(b.i, b.x, b.y);
514
+ const an = a.next;
515
+ const bp = b.prev;
516
+ a.next = b;
517
+ b.prev = a;
518
+ a2.next = an;
519
+ an.prev = a2;
520
+ b2.next = a2;
521
+ a2.prev = b2;
522
+ bp.next = b2;
523
+ b2.prev = bp;
524
+ return b2;
525
+ }
526
+ function insertNode(i2, x2, y2, last) {
527
+ const p = new Node(i2, x2, y2);
528
+ if (!last) {
529
+ p.prev = p;
530
+ p.next = p;
531
+ } else {
532
+ p.next = last.next;
533
+ p.prev = last;
534
+ last.next.prev = p;
535
+ last.next = p;
536
+ }
537
+ return p;
538
+ }
539
+ function removeNode(p) {
540
+ p.next.prev = p.prev;
541
+ p.prev.next = p.next;
542
+ if (p.prevZ)
543
+ p.prevZ.nextZ = p.nextZ;
544
+ if (p.nextZ)
545
+ p.nextZ.prevZ = p.prevZ;
546
+ }
547
+ function Node(i2, x2, y2) {
548
+ this.i = i2;
549
+ this.x = x2;
550
+ this.y = y2;
551
+ this.prev = null;
552
+ this.next = null;
553
+ this.z = null;
554
+ this.prevZ = null;
555
+ this.nextZ = null;
556
+ this.steiner = false;
557
+ }
558
+ var init_earcut = __esm({
559
+ "../../node_modules/@math.gl/polygon/dist/esm/earcut.js"() {
560
+ init_polygon_utils();
561
+ }
562
+ });
563
+
564
+ // ../../node_modules/@math.gl/polygon/dist/esm/utils.js
565
+ var init_utils = __esm({
566
+ "../../node_modules/@math.gl/polygon/dist/esm/utils.js"() {
567
+ }
568
+ });
569
+
570
+ // ../../node_modules/@math.gl/polygon/dist/esm/lineclip.js
571
+ var init_lineclip = __esm({
572
+ "../../node_modules/@math.gl/polygon/dist/esm/lineclip.js"() {
573
+ init_utils();
574
+ }
575
+ });
576
+
577
+ // ../../node_modules/@math.gl/polygon/dist/esm/cut-by-grid.js
578
+ var init_cut_by_grid = __esm({
579
+ "../../node_modules/@math.gl/polygon/dist/esm/cut-by-grid.js"() {
580
+ init_lineclip();
581
+ init_utils();
582
+ }
583
+ });
584
+
585
+ // ../../node_modules/@math.gl/polygon/dist/esm/cut-by-mercator-bounds.js
586
+ var init_cut_by_mercator_bounds = __esm({
587
+ "../../node_modules/@math.gl/polygon/dist/esm/cut-by-mercator-bounds.js"() {
588
+ init_cut_by_grid();
589
+ init_utils();
590
+ }
591
+ });
592
+
593
+ // ../../node_modules/@math.gl/polygon/dist/esm/index.js
594
+ var init_esm = __esm({
595
+ "../../node_modules/@math.gl/polygon/dist/esm/index.js"() {
596
+ init_polygon();
597
+ init_polygon_utils();
598
+ init_earcut();
599
+ init_lineclip();
600
+ init_cut_by_grid();
601
+ init_cut_by_mercator_bounds();
602
+ init_polygon();
603
+ }
604
+ });
605
+
606
+ // ../gis/src/lib/flat-geojson-to-binary.ts
607
+ function flatGeojsonToBinary(features, geometryInfo, options) {
608
+ const propArrayTypes = extractNumericPropTypes(features);
609
+ const numericPropKeys = Object.keys(propArrayTypes).filter((k) => propArrayTypes[k] !== Array);
610
+ return fillArrays(features, {
611
+ propArrayTypes,
612
+ ...geometryInfo
613
+ }, {
614
+ numericPropKeys: options && options.numericPropKeys || numericPropKeys,
615
+ PositionDataType: options ? options.PositionDataType : Float32Array
616
+ });
617
+ }
618
+ function extractNumericPropTypes(features) {
619
+ const propArrayTypes = {};
620
+ for (const feature of features) {
621
+ if (feature.properties) {
622
+ for (const key in feature.properties) {
623
+ const val = feature.properties[key];
624
+ propArrayTypes[key] = deduceArrayType(val, propArrayTypes[key]);
625
+ }
626
+ }
627
+ }
628
+ return propArrayTypes;
629
+ }
630
+ function fillArrays(features, geometryInfo, options) {
631
+ const {
632
+ pointPositionsCount,
633
+ pointFeaturesCount,
634
+ linePositionsCount,
635
+ linePathsCount,
636
+ lineFeaturesCount,
637
+ polygonPositionsCount,
638
+ polygonObjectsCount,
639
+ polygonRingsCount,
640
+ polygonFeaturesCount,
641
+ propArrayTypes,
642
+ coordLength
643
+ } = geometryInfo;
644
+ const { numericPropKeys = [], PositionDataType = Float32Array } = options;
645
+ const hasGlobalId = features[0] && "id" in features[0];
646
+ const GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;
647
+ const points = {
648
+ type: "Point",
649
+ positions: new PositionDataType(pointPositionsCount * coordLength),
650
+ globalFeatureIds: new GlobalFeatureIdsDataType(pointPositionsCount),
651
+ featureIds: pointFeaturesCount > 65535 ? new Uint32Array(pointPositionsCount) : new Uint16Array(pointPositionsCount),
652
+ numericProps: {},
653
+ properties: [],
654
+ fields: []
655
+ };
656
+ const lines = {
657
+ type: "LineString",
658
+ pathIndices: linePositionsCount > 65535 ? new Uint32Array(linePathsCount + 1) : new Uint16Array(linePathsCount + 1),
659
+ positions: new PositionDataType(linePositionsCount * coordLength),
660
+ globalFeatureIds: new GlobalFeatureIdsDataType(linePositionsCount),
661
+ featureIds: lineFeaturesCount > 65535 ? new Uint32Array(linePositionsCount) : new Uint16Array(linePositionsCount),
662
+ numericProps: {},
663
+ properties: [],
664
+ fields: []
665
+ };
666
+ const polygons = {
667
+ type: "Polygon",
668
+ polygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonObjectsCount + 1) : new Uint16Array(polygonObjectsCount + 1),
669
+ primitivePolygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonRingsCount + 1) : new Uint16Array(polygonRingsCount + 1),
670
+ positions: new PositionDataType(polygonPositionsCount * coordLength),
671
+ triangles: [],
672
+ globalFeatureIds: new GlobalFeatureIdsDataType(polygonPositionsCount),
673
+ featureIds: polygonFeaturesCount > 65535 ? new Uint32Array(polygonPositionsCount) : new Uint16Array(polygonPositionsCount),
674
+ numericProps: {},
675
+ properties: [],
676
+ fields: []
677
+ };
678
+ for (const object of [points, lines, polygons]) {
679
+ for (const propName of numericPropKeys) {
680
+ const T = propArrayTypes[propName];
681
+ object.numericProps[propName] = new T(object.positions.length / coordLength);
682
+ }
683
+ }
684
+ lines.pathIndices[linePathsCount] = linePositionsCount;
685
+ polygons.polygonIndices[polygonObjectsCount] = polygonPositionsCount;
686
+ polygons.primitivePolygonIndices[polygonRingsCount] = polygonPositionsCount;
687
+ const indexMap = {
688
+ pointPosition: 0,
689
+ pointFeature: 0,
690
+ linePosition: 0,
691
+ linePath: 0,
692
+ lineFeature: 0,
693
+ polygonPosition: 0,
694
+ polygonObject: 0,
695
+ polygonRing: 0,
696
+ polygonFeature: 0,
697
+ feature: 0
698
+ };
699
+ for (const feature of features) {
700
+ const geometry = feature.geometry;
701
+ const properties = feature.properties || {};
702
+ switch (geometry.type) {
703
+ case "Point":
704
+ handlePoint(geometry, points, indexMap, coordLength, properties);
705
+ points.properties.push(keepStringProperties(properties, numericPropKeys));
706
+ if (hasGlobalId) {
707
+ points.fields.push({ id: feature.id });
708
+ }
709
+ indexMap.pointFeature++;
710
+ break;
711
+ case "LineString":
712
+ handleLineString(geometry, lines, indexMap, coordLength, properties);
713
+ lines.properties.push(keepStringProperties(properties, numericPropKeys));
714
+ if (hasGlobalId) {
715
+ lines.fields.push({ id: feature.id });
716
+ }
717
+ indexMap.lineFeature++;
718
+ break;
719
+ case "Polygon":
720
+ handlePolygon(geometry, polygons, indexMap, coordLength, properties);
721
+ polygons.properties.push(keepStringProperties(properties, numericPropKeys));
722
+ if (hasGlobalId) {
723
+ polygons.fields.push({ id: feature.id });
724
+ }
725
+ indexMap.polygonFeature++;
726
+ break;
727
+ default:
728
+ throw new Error("Invalid geometry type");
729
+ }
730
+ indexMap.feature++;
731
+ }
732
+ return makeAccessorObjects(points, lines, polygons, coordLength);
733
+ }
734
+ function handlePoint(geometry, points, indexMap, coordLength, properties) {
735
+ points.positions.set(geometry.data, indexMap.pointPosition * coordLength);
736
+ const nPositions = geometry.data.length / coordLength;
737
+ fillNumericProperties(points, properties, indexMap.pointPosition, nPositions);
738
+ points.globalFeatureIds.fill(indexMap.feature, indexMap.pointPosition, indexMap.pointPosition + nPositions);
739
+ points.featureIds.fill(indexMap.pointFeature, indexMap.pointPosition, indexMap.pointPosition + nPositions);
740
+ indexMap.pointPosition += nPositions;
741
+ }
742
+ function handleLineString(geometry, lines, indexMap, coordLength, properties) {
743
+ lines.positions.set(geometry.data, indexMap.linePosition * coordLength);
744
+ const nPositions = geometry.data.length / coordLength;
745
+ fillNumericProperties(lines, properties, indexMap.linePosition, nPositions);
746
+ lines.globalFeatureIds.fill(indexMap.feature, indexMap.linePosition, indexMap.linePosition + nPositions);
747
+ lines.featureIds.fill(indexMap.lineFeature, indexMap.linePosition, indexMap.linePosition + nPositions);
748
+ for (let i2 = 0, il = geometry.indices.length; i2 < il; ++i2) {
749
+ const start = geometry.indices[i2];
750
+ const end = i2 === il - 1 ? geometry.data.length : geometry.indices[i2 + 1];
751
+ lines.pathIndices[indexMap.linePath++] = indexMap.linePosition;
752
+ indexMap.linePosition += (end - start) / coordLength;
753
+ }
754
+ }
755
+ function handlePolygon(geometry, polygons, indexMap, coordLength, properties) {
756
+ polygons.positions.set(geometry.data, indexMap.polygonPosition * coordLength);
757
+ const nPositions = geometry.data.length / coordLength;
758
+ fillNumericProperties(polygons, properties, indexMap.polygonPosition, nPositions);
759
+ polygons.globalFeatureIds.fill(indexMap.feature, indexMap.polygonPosition, indexMap.polygonPosition + nPositions);
760
+ polygons.featureIds.fill(indexMap.polygonFeature, indexMap.polygonPosition, indexMap.polygonPosition + nPositions);
761
+ for (let l = 0, ll = geometry.indices.length; l < ll; ++l) {
762
+ const startPosition = indexMap.polygonPosition;
763
+ polygons.polygonIndices[indexMap.polygonObject++] = startPosition;
764
+ const areas = geometry.areas[l];
765
+ const indices = geometry.indices[l];
766
+ const nextIndices = geometry.indices[l + 1];
767
+ for (let i2 = 0, il = indices.length; i2 < il; ++i2) {
768
+ const start = indices[i2];
769
+ const end = i2 === il - 1 ? nextIndices === void 0 ? geometry.data.length : nextIndices[0] : indices[i2 + 1];
770
+ polygons.primitivePolygonIndices[indexMap.polygonRing++] = indexMap.polygonPosition;
771
+ indexMap.polygonPosition += (end - start) / coordLength;
772
+ }
773
+ const endPosition = indexMap.polygonPosition;
774
+ triangulatePolygon(polygons, areas, indices, { startPosition, endPosition, coordLength });
775
+ }
776
+ }
777
+ function triangulatePolygon(polygons, areas, indices, {
778
+ startPosition,
779
+ endPosition,
780
+ coordLength
781
+ }) {
782
+ const start = startPosition * coordLength;
783
+ const end = endPosition * coordLength;
784
+ const polygonPositions = polygons.positions.subarray(start, end);
785
+ const offset = indices[0];
786
+ const holes = indices.slice(1).map((n) => (n - offset) / coordLength);
787
+ const triangles = earcut(polygonPositions, holes, coordLength, areas);
788
+ for (let t = 0, tl = triangles.length; t < tl; ++t) {
789
+ polygons.triangles.push(startPosition + triangles[t]);
790
+ }
791
+ }
792
+ function wrapProps(obj, size) {
793
+ const returnObj = {};
794
+ for (const key in obj) {
795
+ returnObj[key] = { value: obj[key], size };
796
+ }
797
+ return returnObj;
798
+ }
799
+ function makeAccessorObjects(points, lines, polygons, coordLength) {
800
+ return {
801
+ points: {
802
+ ...points,
803
+ positions: { value: points.positions, size: coordLength },
804
+ globalFeatureIds: { value: points.globalFeatureIds, size: 1 },
805
+ featureIds: { value: points.featureIds, size: 1 },
806
+ numericProps: wrapProps(points.numericProps, 1)
807
+ },
808
+ lines: {
809
+ ...lines,
810
+ positions: { value: lines.positions, size: coordLength },
811
+ pathIndices: { value: lines.pathIndices, size: 1 },
812
+ globalFeatureIds: { value: lines.globalFeatureIds, size: 1 },
813
+ featureIds: { value: lines.featureIds, size: 1 },
814
+ numericProps: wrapProps(lines.numericProps, 1)
815
+ },
816
+ polygons: {
817
+ ...polygons,
818
+ positions: { value: polygons.positions, size: coordLength },
819
+ polygonIndices: { value: polygons.polygonIndices, size: 1 },
820
+ primitivePolygonIndices: { value: polygons.primitivePolygonIndices, size: 1 },
821
+ triangles: { value: new Uint32Array(polygons.triangles), size: 1 },
822
+ globalFeatureIds: { value: polygons.globalFeatureIds, size: 1 },
823
+ featureIds: { value: polygons.featureIds, size: 1 },
824
+ numericProps: wrapProps(polygons.numericProps, 1)
825
+ }
826
+ };
827
+ }
828
+ function fillNumericProperties(object, properties, index, length2) {
829
+ for (const numericPropName in object.numericProps) {
830
+ if (numericPropName in properties) {
831
+ const value = properties[numericPropName];
832
+ object.numericProps[numericPropName].fill(value, index, index + length2);
833
+ }
834
+ }
835
+ }
836
+ function keepStringProperties(properties, numericKeys) {
837
+ const props = {};
838
+ for (const key in properties) {
839
+ if (!numericKeys.includes(key)) {
840
+ props[key] = properties[key];
841
+ }
842
+ }
843
+ return props;
844
+ }
845
+ function deduceArrayType(x2, constructor) {
846
+ if (constructor === Array || !Number.isFinite(x2)) {
847
+ return Array;
848
+ }
849
+ return constructor === Float64Array || Math.fround(x2) !== x2 ? Float64Array : Float32Array;
850
+ }
851
+ var init_flat_geojson_to_binary = __esm({
852
+ "../gis/src/lib/flat-geojson-to-binary.ts"() {
853
+ init_esm();
854
+ }
855
+ });
856
+
857
+ // ../gis/src/index.ts
858
+ var init_src = __esm({
859
+ "../gis/src/index.ts"() {
860
+ init_flat_geojson_to_binary();
861
+ }
862
+ });
863
+
864
+ // ../../node_modules/ieee754/index.js
865
+ var require_ieee754 = __commonJS({
866
+ "../../node_modules/ieee754/index.js"(exports) {
867
+ exports.read = function(buffer, offset, isLE, mLen, nBytes) {
868
+ var e, m;
869
+ var eLen = nBytes * 8 - mLen - 1;
870
+ var eMax = (1 << eLen) - 1;
871
+ var eBias = eMax >> 1;
872
+ var nBits = -7;
873
+ var i2 = isLE ? nBytes - 1 : 0;
874
+ var d = isLE ? -1 : 1;
875
+ var s = buffer[offset + i2];
876
+ i2 += d;
877
+ e = s & (1 << -nBits) - 1;
878
+ s >>= -nBits;
879
+ nBits += eLen;
880
+ for (; nBits > 0; e = e * 256 + buffer[offset + i2], i2 += d, nBits -= 8) {
881
+ }
882
+ m = e & (1 << -nBits) - 1;
883
+ e >>= -nBits;
884
+ nBits += mLen;
885
+ for (; nBits > 0; m = m * 256 + buffer[offset + i2], i2 += d, nBits -= 8) {
886
+ }
887
+ if (e === 0) {
888
+ e = 1 - eBias;
889
+ } else if (e === eMax) {
890
+ return m ? NaN : (s ? -1 : 1) * Infinity;
891
+ } else {
892
+ m = m + Math.pow(2, mLen);
893
+ e = e - eBias;
894
+ }
895
+ return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
896
+ };
897
+ exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
898
+ var e, m, c;
899
+ var eLen = nBytes * 8 - mLen - 1;
900
+ var eMax = (1 << eLen) - 1;
901
+ var eBias = eMax >> 1;
902
+ var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
903
+ var i2 = isLE ? 0 : nBytes - 1;
904
+ var d = isLE ? 1 : -1;
905
+ var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
906
+ value = Math.abs(value);
907
+ if (isNaN(value) || value === Infinity) {
908
+ m = isNaN(value) ? 1 : 0;
909
+ e = eMax;
910
+ } else {
911
+ e = Math.floor(Math.log(value) / Math.LN2);
912
+ if (value * (c = Math.pow(2, -e)) < 1) {
913
+ e--;
914
+ c *= 2;
915
+ }
916
+ if (e + eBias >= 1) {
917
+ value += rt / c;
918
+ } else {
919
+ value += rt * Math.pow(2, 1 - eBias);
920
+ }
921
+ if (value * c >= 2) {
922
+ e++;
923
+ c /= 2;
924
+ }
925
+ if (e + eBias >= eMax) {
926
+ m = 0;
927
+ e = eMax;
928
+ } else if (e + eBias >= 1) {
929
+ m = (value * c - 1) * Math.pow(2, mLen);
930
+ e = e + eBias;
931
+ } else {
932
+ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
933
+ e = 0;
934
+ }
935
+ }
936
+ for (; mLen >= 8; buffer[offset + i2] = m & 255, i2 += d, m /= 256, mLen -= 8) {
937
+ }
938
+ e = e << mLen | m;
939
+ eLen += mLen;
940
+ for (; eLen > 0; buffer[offset + i2] = e & 255, i2 += d, e /= 256, eLen -= 8) {
941
+ }
942
+ buffer[offset + i2 - d] |= s * 128;
943
+ };
944
+ }
945
+ });
946
+
947
+ // ../../node_modules/pbf/index.js
948
+ var require_pbf = __commonJS({
949
+ "../../node_modules/pbf/index.js"(exports, module) {
950
+ "use strict";
951
+ module.exports = Pbf;
952
+ var ieee754 = require_ieee754();
953
+ function Pbf(buf) {
954
+ this.buf = ArrayBuffer.isView && ArrayBuffer.isView(buf) ? buf : new Uint8Array(buf || 0);
955
+ this.pos = 0;
956
+ this.type = 0;
957
+ this.length = this.buf.length;
958
+ }
959
+ Pbf.Varint = 0;
960
+ Pbf.Fixed64 = 1;
961
+ Pbf.Bytes = 2;
962
+ Pbf.Fixed32 = 5;
963
+ var SHIFT_LEFT_32 = (1 << 16) * (1 << 16);
964
+ var SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32;
965
+ var TEXT_DECODER_MIN_LENGTH = 12;
966
+ var utf8TextDecoder = typeof TextDecoder === "undefined" ? null : new TextDecoder("utf8");
967
+ Pbf.prototype = {
968
+ destroy: function() {
969
+ this.buf = null;
970
+ },
971
+ readFields: function(readField, result, end) {
972
+ end = end || this.length;
973
+ while (this.pos < end) {
974
+ var val = this.readVarint(), tag = val >> 3, startPos = this.pos;
975
+ this.type = val & 7;
976
+ readField(tag, result, this);
977
+ if (this.pos === startPos)
978
+ this.skip(val);
979
+ }
980
+ return result;
981
+ },
982
+ readMessage: function(readField, result) {
983
+ return this.readFields(readField, result, this.readVarint() + this.pos);
984
+ },
985
+ readFixed32: function() {
986
+ var val = readUInt32(this.buf, this.pos);
987
+ this.pos += 4;
988
+ return val;
989
+ },
990
+ readSFixed32: function() {
991
+ var val = readInt32(this.buf, this.pos);
992
+ this.pos += 4;
993
+ return val;
994
+ },
995
+ readFixed64: function() {
996
+ var val = readUInt32(this.buf, this.pos) + readUInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;
997
+ this.pos += 8;
998
+ return val;
999
+ },
1000
+ readSFixed64: function() {
1001
+ var val = readUInt32(this.buf, this.pos) + readInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;
1002
+ this.pos += 8;
1003
+ return val;
1004
+ },
1005
+ readFloat: function() {
1006
+ var val = ieee754.read(this.buf, this.pos, true, 23, 4);
1007
+ this.pos += 4;
1008
+ return val;
1009
+ },
1010
+ readDouble: function() {
1011
+ var val = ieee754.read(this.buf, this.pos, true, 52, 8);
1012
+ this.pos += 8;
1013
+ return val;
1014
+ },
1015
+ readVarint: function(isSigned) {
1016
+ var buf = this.buf, val, b;
1017
+ b = buf[this.pos++];
1018
+ val = b & 127;
1019
+ if (b < 128)
1020
+ return val;
1021
+ b = buf[this.pos++];
1022
+ val |= (b & 127) << 7;
1023
+ if (b < 128)
1024
+ return val;
1025
+ b = buf[this.pos++];
1026
+ val |= (b & 127) << 14;
1027
+ if (b < 128)
1028
+ return val;
1029
+ b = buf[this.pos++];
1030
+ val |= (b & 127) << 21;
1031
+ if (b < 128)
1032
+ return val;
1033
+ b = buf[this.pos];
1034
+ val |= (b & 15) << 28;
1035
+ return readVarintRemainder(val, isSigned, this);
1036
+ },
1037
+ readVarint64: function() {
1038
+ return this.readVarint(true);
1039
+ },
1040
+ readSVarint: function() {
1041
+ var num = this.readVarint();
1042
+ return num % 2 === 1 ? (num + 1) / -2 : num / 2;
1043
+ },
1044
+ readBoolean: function() {
1045
+ return Boolean(this.readVarint());
1046
+ },
1047
+ readString: function() {
1048
+ var end = this.readVarint() + this.pos;
1049
+ var pos = this.pos;
1050
+ this.pos = end;
1051
+ if (end - pos >= TEXT_DECODER_MIN_LENGTH && utf8TextDecoder) {
1052
+ return readUtf8TextDecoder(this.buf, pos, end);
1053
+ }
1054
+ return readUtf8(this.buf, pos, end);
1055
+ },
1056
+ readBytes: function() {
1057
+ var end = this.readVarint() + this.pos, buffer = this.buf.subarray(this.pos, end);
1058
+ this.pos = end;
1059
+ return buffer;
1060
+ },
1061
+ readPackedVarint: function(arr, isSigned) {
1062
+ if (this.type !== Pbf.Bytes)
1063
+ return arr.push(this.readVarint(isSigned));
1064
+ var end = readPackedEnd(this);
1065
+ arr = arr || [];
1066
+ while (this.pos < end)
1067
+ arr.push(this.readVarint(isSigned));
1068
+ return arr;
1069
+ },
1070
+ readPackedSVarint: function(arr) {
1071
+ if (this.type !== Pbf.Bytes)
1072
+ return arr.push(this.readSVarint());
1073
+ var end = readPackedEnd(this);
1074
+ arr = arr || [];
1075
+ while (this.pos < end)
1076
+ arr.push(this.readSVarint());
1077
+ return arr;
1078
+ },
1079
+ readPackedBoolean: function(arr) {
1080
+ if (this.type !== Pbf.Bytes)
1081
+ return arr.push(this.readBoolean());
1082
+ var end = readPackedEnd(this);
1083
+ arr = arr || [];
1084
+ while (this.pos < end)
1085
+ arr.push(this.readBoolean());
1086
+ return arr;
1087
+ },
1088
+ readPackedFloat: function(arr) {
1089
+ if (this.type !== Pbf.Bytes)
1090
+ return arr.push(this.readFloat());
1091
+ var end = readPackedEnd(this);
1092
+ arr = arr || [];
1093
+ while (this.pos < end)
1094
+ arr.push(this.readFloat());
1095
+ return arr;
1096
+ },
1097
+ readPackedDouble: function(arr) {
1098
+ if (this.type !== Pbf.Bytes)
1099
+ return arr.push(this.readDouble());
1100
+ var end = readPackedEnd(this);
1101
+ arr = arr || [];
1102
+ while (this.pos < end)
1103
+ arr.push(this.readDouble());
1104
+ return arr;
1105
+ },
1106
+ readPackedFixed32: function(arr) {
1107
+ if (this.type !== Pbf.Bytes)
1108
+ return arr.push(this.readFixed32());
1109
+ var end = readPackedEnd(this);
1110
+ arr = arr || [];
1111
+ while (this.pos < end)
1112
+ arr.push(this.readFixed32());
1113
+ return arr;
1114
+ },
1115
+ readPackedSFixed32: function(arr) {
1116
+ if (this.type !== Pbf.Bytes)
1117
+ return arr.push(this.readSFixed32());
1118
+ var end = readPackedEnd(this);
1119
+ arr = arr || [];
1120
+ while (this.pos < end)
1121
+ arr.push(this.readSFixed32());
1122
+ return arr;
1123
+ },
1124
+ readPackedFixed64: function(arr) {
1125
+ if (this.type !== Pbf.Bytes)
1126
+ return arr.push(this.readFixed64());
1127
+ var end = readPackedEnd(this);
1128
+ arr = arr || [];
1129
+ while (this.pos < end)
1130
+ arr.push(this.readFixed64());
1131
+ return arr;
1132
+ },
1133
+ readPackedSFixed64: function(arr) {
1134
+ if (this.type !== Pbf.Bytes)
1135
+ return arr.push(this.readSFixed64());
1136
+ var end = readPackedEnd(this);
1137
+ arr = arr || [];
1138
+ while (this.pos < end)
1139
+ arr.push(this.readSFixed64());
1140
+ return arr;
1141
+ },
1142
+ skip: function(val) {
1143
+ var type = val & 7;
1144
+ if (type === Pbf.Varint)
1145
+ while (this.buf[this.pos++] > 127) {
1146
+ }
1147
+ else if (type === Pbf.Bytes)
1148
+ this.pos = this.readVarint() + this.pos;
1149
+ else if (type === Pbf.Fixed32)
1150
+ this.pos += 4;
1151
+ else if (type === Pbf.Fixed64)
1152
+ this.pos += 8;
1153
+ else
1154
+ throw new Error("Unimplemented type: " + type);
1155
+ },
1156
+ writeTag: function(tag, type) {
1157
+ this.writeVarint(tag << 3 | type);
1158
+ },
1159
+ realloc: function(min) {
1160
+ var length2 = this.length || 16;
1161
+ while (length2 < this.pos + min)
1162
+ length2 *= 2;
1163
+ if (length2 !== this.length) {
1164
+ var buf = new Uint8Array(length2);
1165
+ buf.set(this.buf);
1166
+ this.buf = buf;
1167
+ this.length = length2;
1168
+ }
1169
+ },
1170
+ finish: function() {
1171
+ this.length = this.pos;
1172
+ this.pos = 0;
1173
+ return this.buf.subarray(0, this.length);
1174
+ },
1175
+ writeFixed32: function(val) {
1176
+ this.realloc(4);
1177
+ writeInt32(this.buf, val, this.pos);
1178
+ this.pos += 4;
1179
+ },
1180
+ writeSFixed32: function(val) {
1181
+ this.realloc(4);
1182
+ writeInt32(this.buf, val, this.pos);
1183
+ this.pos += 4;
1184
+ },
1185
+ writeFixed64: function(val) {
1186
+ this.realloc(8);
1187
+ writeInt32(this.buf, val & -1, this.pos);
1188
+ writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);
1189
+ this.pos += 8;
1190
+ },
1191
+ writeSFixed64: function(val) {
1192
+ this.realloc(8);
1193
+ writeInt32(this.buf, val & -1, this.pos);
1194
+ writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);
1195
+ this.pos += 8;
1196
+ },
1197
+ writeVarint: function(val) {
1198
+ val = +val || 0;
1199
+ if (val > 268435455 || val < 0) {
1200
+ writeBigVarint(val, this);
1201
+ return;
1202
+ }
1203
+ this.realloc(4);
1204
+ this.buf[this.pos++] = val & 127 | (val > 127 ? 128 : 0);
1205
+ if (val <= 127)
1206
+ return;
1207
+ this.buf[this.pos++] = (val >>>= 7) & 127 | (val > 127 ? 128 : 0);
1208
+ if (val <= 127)
1209
+ return;
1210
+ this.buf[this.pos++] = (val >>>= 7) & 127 | (val > 127 ? 128 : 0);
1211
+ if (val <= 127)
1212
+ return;
1213
+ this.buf[this.pos++] = val >>> 7 & 127;
1214
+ },
1215
+ writeSVarint: function(val) {
1216
+ this.writeVarint(val < 0 ? -val * 2 - 1 : val * 2);
1217
+ },
1218
+ writeBoolean: function(val) {
1219
+ this.writeVarint(Boolean(val));
1220
+ },
1221
+ writeString: function(str) {
1222
+ str = String(str);
1223
+ this.realloc(str.length * 4);
1224
+ this.pos++;
1225
+ var startPos = this.pos;
1226
+ this.pos = writeUtf8(this.buf, str, this.pos);
1227
+ var len = this.pos - startPos;
1228
+ if (len >= 128)
1229
+ makeRoomForExtraLength(startPos, len, this);
1230
+ this.pos = startPos - 1;
1231
+ this.writeVarint(len);
1232
+ this.pos += len;
1233
+ },
1234
+ writeFloat: function(val) {
1235
+ this.realloc(4);
1236
+ ieee754.write(this.buf, val, this.pos, true, 23, 4);
1237
+ this.pos += 4;
1238
+ },
1239
+ writeDouble: function(val) {
1240
+ this.realloc(8);
1241
+ ieee754.write(this.buf, val, this.pos, true, 52, 8);
1242
+ this.pos += 8;
1243
+ },
1244
+ writeBytes: function(buffer) {
1245
+ var len = buffer.length;
1246
+ this.writeVarint(len);
1247
+ this.realloc(len);
1248
+ for (var i2 = 0; i2 < len; i2++)
1249
+ this.buf[this.pos++] = buffer[i2];
1250
+ },
1251
+ writeRawMessage: function(fn, obj) {
1252
+ this.pos++;
1253
+ var startPos = this.pos;
1254
+ fn(obj, this);
1255
+ var len = this.pos - startPos;
1256
+ if (len >= 128)
1257
+ makeRoomForExtraLength(startPos, len, this);
1258
+ this.pos = startPos - 1;
1259
+ this.writeVarint(len);
1260
+ this.pos += len;
1261
+ },
1262
+ writeMessage: function(tag, fn, obj) {
1263
+ this.writeTag(tag, Pbf.Bytes);
1264
+ this.writeRawMessage(fn, obj);
1265
+ },
1266
+ writePackedVarint: function(tag, arr) {
1267
+ if (arr.length)
1268
+ this.writeMessage(tag, writePackedVarint, arr);
1269
+ },
1270
+ writePackedSVarint: function(tag, arr) {
1271
+ if (arr.length)
1272
+ this.writeMessage(tag, writePackedSVarint, arr);
1273
+ },
1274
+ writePackedBoolean: function(tag, arr) {
1275
+ if (arr.length)
1276
+ this.writeMessage(tag, writePackedBoolean, arr);
1277
+ },
1278
+ writePackedFloat: function(tag, arr) {
1279
+ if (arr.length)
1280
+ this.writeMessage(tag, writePackedFloat, arr);
1281
+ },
1282
+ writePackedDouble: function(tag, arr) {
1283
+ if (arr.length)
1284
+ this.writeMessage(tag, writePackedDouble, arr);
1285
+ },
1286
+ writePackedFixed32: function(tag, arr) {
1287
+ if (arr.length)
1288
+ this.writeMessage(tag, writePackedFixed32, arr);
1289
+ },
1290
+ writePackedSFixed32: function(tag, arr) {
1291
+ if (arr.length)
1292
+ this.writeMessage(tag, writePackedSFixed32, arr);
1293
+ },
1294
+ writePackedFixed64: function(tag, arr) {
1295
+ if (arr.length)
1296
+ this.writeMessage(tag, writePackedFixed64, arr);
1297
+ },
1298
+ writePackedSFixed64: function(tag, arr) {
1299
+ if (arr.length)
1300
+ this.writeMessage(tag, writePackedSFixed64, arr);
1301
+ },
1302
+ writeBytesField: function(tag, buffer) {
1303
+ this.writeTag(tag, Pbf.Bytes);
1304
+ this.writeBytes(buffer);
1305
+ },
1306
+ writeFixed32Field: function(tag, val) {
1307
+ this.writeTag(tag, Pbf.Fixed32);
1308
+ this.writeFixed32(val);
1309
+ },
1310
+ writeSFixed32Field: function(tag, val) {
1311
+ this.writeTag(tag, Pbf.Fixed32);
1312
+ this.writeSFixed32(val);
1313
+ },
1314
+ writeFixed64Field: function(tag, val) {
1315
+ this.writeTag(tag, Pbf.Fixed64);
1316
+ this.writeFixed64(val);
1317
+ },
1318
+ writeSFixed64Field: function(tag, val) {
1319
+ this.writeTag(tag, Pbf.Fixed64);
1320
+ this.writeSFixed64(val);
1321
+ },
1322
+ writeVarintField: function(tag, val) {
1323
+ this.writeTag(tag, Pbf.Varint);
1324
+ this.writeVarint(val);
1325
+ },
1326
+ writeSVarintField: function(tag, val) {
1327
+ this.writeTag(tag, Pbf.Varint);
1328
+ this.writeSVarint(val);
1329
+ },
1330
+ writeStringField: function(tag, str) {
1331
+ this.writeTag(tag, Pbf.Bytes);
1332
+ this.writeString(str);
1333
+ },
1334
+ writeFloatField: function(tag, val) {
1335
+ this.writeTag(tag, Pbf.Fixed32);
1336
+ this.writeFloat(val);
1337
+ },
1338
+ writeDoubleField: function(tag, val) {
1339
+ this.writeTag(tag, Pbf.Fixed64);
1340
+ this.writeDouble(val);
1341
+ },
1342
+ writeBooleanField: function(tag, val) {
1343
+ this.writeVarintField(tag, Boolean(val));
1344
+ }
1345
+ };
1346
+ function readVarintRemainder(l, s, p) {
1347
+ var buf = p.buf, h, b;
1348
+ b = buf[p.pos++];
1349
+ h = (b & 112) >> 4;
1350
+ if (b < 128)
1351
+ return toNum(l, h, s);
1352
+ b = buf[p.pos++];
1353
+ h |= (b & 127) << 3;
1354
+ if (b < 128)
1355
+ return toNum(l, h, s);
1356
+ b = buf[p.pos++];
1357
+ h |= (b & 127) << 10;
1358
+ if (b < 128)
1359
+ return toNum(l, h, s);
1360
+ b = buf[p.pos++];
1361
+ h |= (b & 127) << 17;
1362
+ if (b < 128)
1363
+ return toNum(l, h, s);
1364
+ b = buf[p.pos++];
1365
+ h |= (b & 127) << 24;
1366
+ if (b < 128)
1367
+ return toNum(l, h, s);
1368
+ b = buf[p.pos++];
1369
+ h |= (b & 1) << 31;
1370
+ if (b < 128)
1371
+ return toNum(l, h, s);
1372
+ throw new Error("Expected varint not more than 10 bytes");
1373
+ }
1374
+ function readPackedEnd(pbf) {
1375
+ return pbf.type === Pbf.Bytes ? pbf.readVarint() + pbf.pos : pbf.pos + 1;
1376
+ }
1377
+ function toNum(low, high, isSigned) {
1378
+ if (isSigned) {
1379
+ return high * 4294967296 + (low >>> 0);
1380
+ }
1381
+ return (high >>> 0) * 4294967296 + (low >>> 0);
1382
+ }
1383
+ function writeBigVarint(val, pbf) {
1384
+ var low, high;
1385
+ if (val >= 0) {
1386
+ low = val % 4294967296 | 0;
1387
+ high = val / 4294967296 | 0;
1388
+ } else {
1389
+ low = ~(-val % 4294967296);
1390
+ high = ~(-val / 4294967296);
1391
+ if (low ^ 4294967295) {
1392
+ low = low + 1 | 0;
1393
+ } else {
1394
+ low = 0;
1395
+ high = high + 1 | 0;
1396
+ }
1397
+ }
1398
+ if (val >= 18446744073709552e3 || val < -18446744073709552e3) {
1399
+ throw new Error("Given varint doesn't fit into 10 bytes");
1400
+ }
1401
+ pbf.realloc(10);
1402
+ writeBigVarintLow(low, high, pbf);
1403
+ writeBigVarintHigh(high, pbf);
1404
+ }
1405
+ function writeBigVarintLow(low, high, pbf) {
1406
+ pbf.buf[pbf.pos++] = low & 127 | 128;
1407
+ low >>>= 7;
1408
+ pbf.buf[pbf.pos++] = low & 127 | 128;
1409
+ low >>>= 7;
1410
+ pbf.buf[pbf.pos++] = low & 127 | 128;
1411
+ low >>>= 7;
1412
+ pbf.buf[pbf.pos++] = low & 127 | 128;
1413
+ low >>>= 7;
1414
+ pbf.buf[pbf.pos] = low & 127;
1415
+ }
1416
+ function writeBigVarintHigh(high, pbf) {
1417
+ var lsb = (high & 7) << 4;
1418
+ pbf.buf[pbf.pos++] |= lsb | ((high >>>= 3) ? 128 : 0);
1419
+ if (!high)
1420
+ return;
1421
+ pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
1422
+ if (!high)
1423
+ return;
1424
+ pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
1425
+ if (!high)
1426
+ return;
1427
+ pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
1428
+ if (!high)
1429
+ return;
1430
+ pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
1431
+ if (!high)
1432
+ return;
1433
+ pbf.buf[pbf.pos++] = high & 127;
1434
+ }
1435
+ function makeRoomForExtraLength(startPos, len, pbf) {
1436
+ var extraLen = len <= 16383 ? 1 : len <= 2097151 ? 2 : len <= 268435455 ? 3 : Math.floor(Math.log(len) / (Math.LN2 * 7));
1437
+ pbf.realloc(extraLen);
1438
+ for (var i2 = pbf.pos - 1; i2 >= startPos; i2--)
1439
+ pbf.buf[i2 + extraLen] = pbf.buf[i2];
1440
+ }
1441
+ function writePackedVarint(arr, pbf) {
1442
+ for (var i2 = 0; i2 < arr.length; i2++)
1443
+ pbf.writeVarint(arr[i2]);
1444
+ }
1445
+ function writePackedSVarint(arr, pbf) {
1446
+ for (var i2 = 0; i2 < arr.length; i2++)
1447
+ pbf.writeSVarint(arr[i2]);
1448
+ }
1449
+ function writePackedFloat(arr, pbf) {
1450
+ for (var i2 = 0; i2 < arr.length; i2++)
1451
+ pbf.writeFloat(arr[i2]);
1452
+ }
1453
+ function writePackedDouble(arr, pbf) {
1454
+ for (var i2 = 0; i2 < arr.length; i2++)
1455
+ pbf.writeDouble(arr[i2]);
1456
+ }
1457
+ function writePackedBoolean(arr, pbf) {
1458
+ for (var i2 = 0; i2 < arr.length; i2++)
1459
+ pbf.writeBoolean(arr[i2]);
1460
+ }
1461
+ function writePackedFixed32(arr, pbf) {
1462
+ for (var i2 = 0; i2 < arr.length; i2++)
1463
+ pbf.writeFixed32(arr[i2]);
1464
+ }
1465
+ function writePackedSFixed32(arr, pbf) {
1466
+ for (var i2 = 0; i2 < arr.length; i2++)
1467
+ pbf.writeSFixed32(arr[i2]);
1468
+ }
1469
+ function writePackedFixed64(arr, pbf) {
1470
+ for (var i2 = 0; i2 < arr.length; i2++)
1471
+ pbf.writeFixed64(arr[i2]);
1472
+ }
1473
+ function writePackedSFixed64(arr, pbf) {
1474
+ for (var i2 = 0; i2 < arr.length; i2++)
1475
+ pbf.writeSFixed64(arr[i2]);
1476
+ }
1477
+ function readUInt32(buf, pos) {
1478
+ return (buf[pos] | buf[pos + 1] << 8 | buf[pos + 2] << 16) + buf[pos + 3] * 16777216;
1479
+ }
1480
+ function writeInt32(buf, val, pos) {
1481
+ buf[pos] = val;
1482
+ buf[pos + 1] = val >>> 8;
1483
+ buf[pos + 2] = val >>> 16;
1484
+ buf[pos + 3] = val >>> 24;
1485
+ }
1486
+ function readInt32(buf, pos) {
1487
+ return (buf[pos] | buf[pos + 1] << 8 | buf[pos + 2] << 16) + (buf[pos + 3] << 24);
1488
+ }
1489
+ function readUtf8(buf, pos, end) {
1490
+ var str = "";
1491
+ var i2 = pos;
1492
+ while (i2 < end) {
1493
+ var b0 = buf[i2];
1494
+ var c = null;
1495
+ var bytesPerSequence = b0 > 239 ? 4 : b0 > 223 ? 3 : b0 > 191 ? 2 : 1;
1496
+ if (i2 + bytesPerSequence > end)
1497
+ break;
1498
+ var b1, b2, b3;
1499
+ if (bytesPerSequence === 1) {
1500
+ if (b0 < 128) {
1501
+ c = b0;
1502
+ }
1503
+ } else if (bytesPerSequence === 2) {
1504
+ b1 = buf[i2 + 1];
1505
+ if ((b1 & 192) === 128) {
1506
+ c = (b0 & 31) << 6 | b1 & 63;
1507
+ if (c <= 127) {
1508
+ c = null;
1509
+ }
1510
+ }
1511
+ } else if (bytesPerSequence === 3) {
1512
+ b1 = buf[i2 + 1];
1513
+ b2 = buf[i2 + 2];
1514
+ if ((b1 & 192) === 128 && (b2 & 192) === 128) {
1515
+ c = (b0 & 15) << 12 | (b1 & 63) << 6 | b2 & 63;
1516
+ if (c <= 2047 || c >= 55296 && c <= 57343) {
1517
+ c = null;
1518
+ }
1519
+ }
1520
+ } else if (bytesPerSequence === 4) {
1521
+ b1 = buf[i2 + 1];
1522
+ b2 = buf[i2 + 2];
1523
+ b3 = buf[i2 + 3];
1524
+ if ((b1 & 192) === 128 && (b2 & 192) === 128 && (b3 & 192) === 128) {
1525
+ c = (b0 & 15) << 18 | (b1 & 63) << 12 | (b2 & 63) << 6 | b3 & 63;
1526
+ if (c <= 65535 || c >= 1114112) {
1527
+ c = null;
1528
+ }
1529
+ }
1530
+ }
1531
+ if (c === null) {
1532
+ c = 65533;
1533
+ bytesPerSequence = 1;
1534
+ } else if (c > 65535) {
1535
+ c -= 65536;
1536
+ str += String.fromCharCode(c >>> 10 & 1023 | 55296);
1537
+ c = 56320 | c & 1023;
1538
+ }
1539
+ str += String.fromCharCode(c);
1540
+ i2 += bytesPerSequence;
1541
+ }
1542
+ return str;
1543
+ }
1544
+ function readUtf8TextDecoder(buf, pos, end) {
1545
+ return utf8TextDecoder.decode(buf.subarray(pos, end));
1546
+ }
1547
+ function writeUtf8(buf, str, pos) {
1548
+ for (var i2 = 0, c, lead; i2 < str.length; i2++) {
1549
+ c = str.charCodeAt(i2);
1550
+ if (c > 55295 && c < 57344) {
1551
+ if (lead) {
1552
+ if (c < 56320) {
1553
+ buf[pos++] = 239;
1554
+ buf[pos++] = 191;
1555
+ buf[pos++] = 189;
1556
+ lead = c;
1557
+ continue;
1558
+ } else {
1559
+ c = lead - 55296 << 10 | c - 56320 | 65536;
1560
+ lead = null;
1561
+ }
1562
+ } else {
1563
+ if (c > 56319 || i2 + 1 === str.length) {
1564
+ buf[pos++] = 239;
1565
+ buf[pos++] = 191;
1566
+ buf[pos++] = 189;
1567
+ } else {
1568
+ lead = c;
1569
+ }
1570
+ continue;
1571
+ }
1572
+ } else if (lead) {
1573
+ buf[pos++] = 239;
1574
+ buf[pos++] = 191;
1575
+ buf[pos++] = 189;
1576
+ lead = null;
1577
+ }
1578
+ if (c < 128) {
1579
+ buf[pos++] = c;
1580
+ } else {
1581
+ if (c < 2048) {
1582
+ buf[pos++] = c >> 6 | 192;
1583
+ } else {
1584
+ if (c < 65536) {
1585
+ buf[pos++] = c >> 12 | 224;
1586
+ } else {
1587
+ buf[pos++] = c >> 18 | 240;
1588
+ buf[pos++] = c >> 12 & 63 | 128;
1589
+ }
1590
+ buf[pos++] = c >> 6 & 63 | 128;
1591
+ }
1592
+ buf[pos++] = c & 63 | 128;
1593
+ }
1594
+ }
1595
+ return pos;
1596
+ }
1597
+ }
1598
+ });
1599
+
1600
+ // src/helpers/mapbox-util-functions.ts
1601
+ function classifyRings(rings) {
1602
+ const len = rings.length;
1603
+ if (len <= 1)
1604
+ return [rings];
1605
+ const polygons = [];
1606
+ let polygon;
1607
+ let ccw;
1608
+ for (let i2 = 0; i2 < len; i2++) {
1609
+ const area2 = signedArea(rings[i2]);
1610
+ if (area2 === 0)
1611
+ continue;
1612
+ if (ccw === void 0)
1613
+ ccw = area2 < 0;
1614
+ if (ccw === area2 < 0) {
1615
+ if (polygon)
1616
+ polygons.push(polygon);
1617
+ polygon = [rings[i2]];
1618
+ } else if (polygon)
1619
+ polygon.push(rings[i2]);
1620
+ }
1621
+ if (polygon)
1622
+ polygons.push(polygon);
1623
+ return polygons;
1624
+ }
1625
+ function signedArea(ring) {
1626
+ let sum = 0;
1627
+ for (let i2 = 0, j = ring.length - 1, p1, p2; i2 < ring.length; j = i2++) {
1628
+ p1 = ring[i2];
1629
+ p2 = ring[j];
1630
+ sum += (p2[0] - p1[0]) * (p1[1] + p2[1]);
1631
+ }
1632
+ return sum;
1633
+ }
1634
+ function readFeature(tag, feature, pbf) {
1635
+ if (feature && pbf) {
1636
+ if (tag === 1)
1637
+ feature.id = pbf.readVarint();
1638
+ else if (tag === 2)
1639
+ readTag(pbf, feature);
1640
+ else if (tag === 3)
1641
+ feature.type = pbf.readVarint();
1642
+ else if (tag === 4)
1643
+ feature._geometry = pbf.pos;
1644
+ }
1645
+ }
1646
+ function readTag(pbf, feature) {
1647
+ const end = pbf.readVarint() + pbf.pos;
1648
+ while (pbf.pos < end) {
1649
+ const key = feature._keys[pbf.readVarint()];
1650
+ const value = feature._values[pbf.readVarint()];
1651
+ feature.properties[key] = value;
1652
+ }
1653
+ }
1654
+ var init_mapbox_util_functions = __esm({
1655
+ "src/helpers/mapbox-util-functions.ts"() {
1656
+ }
1657
+ });
1658
+
1659
+ // src/lib/mapbox-vector-tile/vector-tile-feature.ts
1660
+ var VectorTileFeature;
1661
+ var init_vector_tile_feature = __esm({
1662
+ "src/lib/mapbox-vector-tile/vector-tile-feature.ts"() {
1663
+ init_mapbox_util_functions();
1664
+ VectorTileFeature = class {
1665
+ static get types() {
1666
+ return ["Unknown", "Point", "LineString", "Polygon"];
1667
+ }
1668
+ constructor(pbf, end, extent, keys, values) {
1669
+ this.properties = {};
1670
+ this.extent = extent;
1671
+ this.type = 0;
1672
+ this.id = null;
1673
+ this._pbf = pbf;
1674
+ this._geometry = -1;
1675
+ this._keys = keys;
1676
+ this._values = values;
1677
+ pbf.readFields(readFeature, this, end);
1678
+ }
1679
+ loadGeometry() {
1680
+ const pbf = this._pbf;
1681
+ pbf.pos = this._geometry;
1682
+ const end = pbf.readVarint() + pbf.pos;
1683
+ let cmd2 = 1;
1684
+ let length2 = 0;
1685
+ let x2 = 0;
1686
+ let y2 = 0;
1687
+ const lines = [];
1688
+ let line;
1689
+ while (pbf.pos < end) {
1690
+ if (length2 <= 0) {
1691
+ const cmdLen2 = pbf.readVarint();
1692
+ cmd2 = cmdLen2 & 7;
1693
+ length2 = cmdLen2 >> 3;
1694
+ }
1695
+ length2--;
1696
+ if (cmd2 === 1 || cmd2 === 2) {
1697
+ x2 += pbf.readSVarint();
1698
+ y2 += pbf.readSVarint();
1699
+ if (cmd2 === 1) {
1700
+ if (line)
1701
+ lines.push(line);
1702
+ line = [];
1703
+ }
1704
+ if (line)
1705
+ line.push([x2, y2]);
1706
+ } else if (cmd2 === 7) {
1707
+ if (line) {
1708
+ line.push(line[0].slice());
1709
+ }
1710
+ } else {
1711
+ throw new Error(`unknown command ${cmd2}`);
1712
+ }
1713
+ }
1714
+ if (line)
1715
+ lines.push(line);
1716
+ return lines;
1717
+ }
1718
+ bbox() {
1719
+ const pbf = this._pbf;
1720
+ pbf.pos = this._geometry;
1721
+ const end = pbf.readVarint() + pbf.pos;
1722
+ let cmd2 = 1;
1723
+ let length2 = 0;
1724
+ let x2 = 0;
1725
+ let y2 = 0;
1726
+ let x1 = Infinity;
1727
+ let x22 = -Infinity;
1728
+ let y1 = Infinity;
1729
+ let y22 = -Infinity;
1730
+ while (pbf.pos < end) {
1731
+ if (length2 <= 0) {
1732
+ const cmdLen2 = pbf.readVarint();
1733
+ cmd2 = cmdLen2 & 7;
1734
+ length2 = cmdLen2 >> 3;
1735
+ }
1736
+ length2--;
1737
+ if (cmd2 === 1 || cmd2 === 2) {
1738
+ x2 += pbf.readSVarint();
1739
+ y2 += pbf.readSVarint();
1740
+ if (x2 < x1)
1741
+ x1 = x2;
1742
+ if (x2 > x22)
1743
+ x22 = x2;
1744
+ if (y2 < y1)
1745
+ y1 = y2;
1746
+ if (y2 > y22)
1747
+ y22 = y2;
1748
+ } else if (cmd2 !== 7) {
1749
+ throw new Error(`unknown command ${cmd2}`);
1750
+ }
1751
+ }
1752
+ return [x1, y1, x22, y22];
1753
+ }
1754
+ _toGeoJSON(transform) {
1755
+ let coords = this.loadGeometry();
1756
+ let type = VectorTileFeature.types[this.type];
1757
+ let i2;
1758
+ let j;
1759
+ switch (this.type) {
1760
+ case 1:
1761
+ const points = [];
1762
+ for (i2 = 0; i2 < coords.length; i2++) {
1763
+ points[i2] = coords[i2][0];
1764
+ }
1765
+ coords = points;
1766
+ transform(coords, this);
1767
+ break;
1768
+ case 2:
1769
+ for (i2 = 0; i2 < coords.length; i2++) {
1770
+ transform(coords[i2], this);
1771
+ }
1772
+ break;
1773
+ case 3:
1774
+ coords = classifyRings(coords);
1775
+ for (i2 = 0; i2 < coords.length; i2++) {
1776
+ for (j = 0; j < coords[i2].length; j++) {
1777
+ transform(coords[i2][j], this);
1778
+ }
1779
+ }
1780
+ break;
1781
+ }
1782
+ if (coords.length === 1) {
1783
+ coords = coords[0];
1784
+ } else {
1785
+ type = `Multi${type}`;
1786
+ }
1787
+ const result = {
1788
+ type: "Feature",
1789
+ geometry: {
1790
+ type,
1791
+ coordinates: coords
1792
+ },
1793
+ properties: this.properties
1794
+ };
1795
+ if (this.id !== null) {
1796
+ result.id = this.id;
1797
+ }
1798
+ return result;
1799
+ }
1800
+ toGeoJSON(options) {
1801
+ if (typeof options === "function") {
1802
+ return this._toGeoJSON(options);
1803
+ }
1804
+ const { x: x2, y: y2, z } = options;
1805
+ const size = this.extent * Math.pow(2, z);
1806
+ const x0 = this.extent * x2;
1807
+ const y0 = this.extent * y2;
1808
+ function project2(line) {
1809
+ for (let j = 0; j < line.length; j++) {
1810
+ const p = line[j];
1811
+ p[0] = (p[0] + x0) * 360 / size - 180;
1812
+ const y22 = 180 - (p[1] + y0) * 360 / size;
1813
+ p[1] = 360 / Math.PI * Math.atan(Math.exp(y22 * Math.PI / 180)) - 90;
1814
+ }
1815
+ }
1816
+ return this._toGeoJSON(project2);
1817
+ }
1818
+ };
1819
+ }
1820
+ });
1821
+
1822
+ // src/lib/mapbox-vector-tile/vector-tile-layer.ts
1823
+ function readLayer(tag, layer, pbf) {
1824
+ if (layer && pbf) {
1825
+ if (tag === 15)
1826
+ layer.version = pbf.readVarint();
1827
+ else if (tag === 1)
1828
+ layer.name = pbf.readString();
1829
+ else if (tag === 5)
1830
+ layer.extent = pbf.readVarint();
1831
+ else if (tag === 2)
1832
+ layer._features.push(pbf.pos);
1833
+ else if (tag === 3)
1834
+ layer._keys.push(pbf.readString());
1835
+ else if (tag === 4)
1836
+ layer._values.push(readValueMessage(pbf));
1837
+ }
1838
+ }
1839
+ function readValueMessage(pbf) {
1840
+ let value = null;
1841
+ const end = pbf.readVarint() + pbf.pos;
1842
+ while (pbf.pos < end) {
1843
+ const tag = pbf.readVarint() >> 3;
1844
+ value = tag === 1 ? pbf.readString() : tag === 2 ? pbf.readFloat() : tag === 3 ? pbf.readDouble() : tag === 4 ? pbf.readVarint64() : tag === 5 ? pbf.readVarint() : tag === 6 ? pbf.readSVarint() : tag === 7 ? pbf.readBoolean() : null;
1845
+ }
1846
+ return value;
1847
+ }
1848
+ var VectorTileLayer;
1849
+ var init_vector_tile_layer = __esm({
1850
+ "src/lib/mapbox-vector-tile/vector-tile-layer.ts"() {
1851
+ init_vector_tile_feature();
1852
+ VectorTileLayer = class {
1853
+ constructor(pbf, end) {
1854
+ this.version = 1;
1855
+ this.name = "";
1856
+ this.extent = 4096;
1857
+ this.length = 0;
1858
+ this._pbf = pbf;
1859
+ this._keys = [];
1860
+ this._values = [];
1861
+ this._features = [];
1862
+ pbf.readFields(readLayer, this, end);
1863
+ this.length = this._features.length;
1864
+ }
1865
+ feature(i2) {
1866
+ if (i2 < 0 || i2 >= this._features.length) {
1867
+ throw new Error("feature index out of bounds");
1868
+ }
1869
+ this._pbf.pos = this._features[i2];
1870
+ const end = this._pbf.readVarint() + this._pbf.pos;
1871
+ return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values);
1872
+ }
1873
+ };
1874
+ }
1875
+ });
1876
+
1877
+ // src/lib/mapbox-vector-tile/vector-tile.ts
1878
+ function readTile(tag, layers, pbf) {
1879
+ if (tag === 3) {
1880
+ if (pbf) {
1881
+ const layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos);
1882
+ if (layer.length && layers) {
1883
+ layers[layer.name] = layer;
1884
+ }
1885
+ }
1886
+ }
1887
+ }
1888
+ var VectorTile;
1889
+ var init_vector_tile = __esm({
1890
+ "src/lib/mapbox-vector-tile/vector-tile.ts"() {
1891
+ init_vector_tile_layer();
1892
+ VectorTile = class {
1893
+ constructor(pbf, end) {
1894
+ this.layers = pbf.readFields(readTile, {}, end);
1895
+ }
1896
+ };
1897
+ }
1898
+ });
1899
+
1900
+ // src/helpers/binary-util-functions.ts
1901
+ function classifyRings2(geom) {
1902
+ const len = geom.indices.length;
1903
+ const type = "Polygon";
1904
+ if (len <= 1) {
1905
+ return {
1906
+ type,
1907
+ data: geom.data,
1908
+ areas: [[getPolygonSignedArea(geom.data)]],
1909
+ indices: [geom.indices]
1910
+ };
1911
+ }
1912
+ const areas = [];
1913
+ const polygons = [];
1914
+ let ringAreas = [];
1915
+ let polygon = [];
1916
+ let ccw;
1917
+ let offset = 0;
1918
+ for (let endIndex, i2 = 0, startIndex; i2 < len; i2++) {
1919
+ startIndex = geom.indices[i2] - offset;
1920
+ endIndex = geom.indices[i2 + 1] - offset || geom.data.length;
1921
+ const shape = geom.data.slice(startIndex, endIndex);
1922
+ const area2 = getPolygonSignedArea(shape);
1923
+ if (area2 === 0) {
1924
+ const before = geom.data.slice(0, startIndex);
1925
+ const after = geom.data.slice(endIndex);
1926
+ geom.data = before.concat(after);
1927
+ offset += endIndex - startIndex;
1928
+ continue;
1929
+ }
1930
+ if (ccw === void 0)
1931
+ ccw = area2 < 0;
1932
+ if (ccw === area2 < 0) {
1933
+ if (polygon.length) {
1934
+ areas.push(ringAreas);
1935
+ polygons.push(polygon);
1936
+ }
1937
+ polygon = [startIndex];
1938
+ ringAreas = [area2];
1939
+ } else {
1940
+ ringAreas.push(area2);
1941
+ polygon.push(startIndex);
1942
+ }
1943
+ }
1944
+ if (ringAreas)
1945
+ areas.push(ringAreas);
1946
+ if (polygon.length)
1947
+ polygons.push(polygon);
1948
+ return { type, areas, indices: polygons, data: geom.data };
1949
+ }
1950
+ function project(data, x0, y0, size) {
1951
+ for (let j = 0, jl = data.length; j < jl; j += 2) {
1952
+ data[j] = (data[j] + x0) * 360 / size - 180;
1953
+ const y2 = 180 - (data[j + 1] + y0) * 360 / size;
1954
+ data[j + 1] = 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
1955
+ }
1956
+ }
1957
+ function readFeature2(tag, feature, pbf) {
1958
+ if (feature && pbf) {
1959
+ if (tag === 1)
1960
+ feature.id = pbf.readVarint();
1961
+ else if (tag === 2)
1962
+ readTag2(pbf, feature);
1963
+ else if (tag === 3)
1964
+ feature.type = pbf.readVarint();
1965
+ else if (tag === 4)
1966
+ feature._geometry = pbf.pos;
1967
+ }
1968
+ }
1969
+ function readTag2(pbf, feature) {
1970
+ const end = pbf.readVarint() + pbf.pos;
1971
+ while (pbf.pos < end) {
1972
+ const key = feature._keys[pbf.readVarint()];
1973
+ const value = feature._values[pbf.readVarint()];
1974
+ feature.properties[key] = value;
1975
+ }
1976
+ }
1977
+ var init_binary_util_functions = __esm({
1978
+ "src/helpers/binary-util-functions.ts"() {
1979
+ init_esm();
1980
+ }
1981
+ });
1982
+
1983
+ // src/lib/binary-vector-tile/vector-tile-feature.ts
1984
+ var endPos, cmd, cmdLen, length, x, y, i, VectorTileFeature2;
1985
+ var init_vector_tile_feature2 = __esm({
1986
+ "src/lib/binary-vector-tile/vector-tile-feature.ts"() {
1987
+ init_binary_util_functions();
1988
+ VectorTileFeature2 = class {
1989
+ constructor(pbf, end, extent, keys, values, geometryInfo) {
1990
+ this.properties = {};
1991
+ this.extent = extent;
1992
+ this.type = 0;
1993
+ this.id = null;
1994
+ this._pbf = pbf;
1995
+ this._geometry = -1;
1996
+ this._keys = keys;
1997
+ this._values = values;
1998
+ this._geometryInfo = geometryInfo;
1999
+ pbf.readFields(readFeature2, this, end);
2000
+ }
2001
+ loadGeometry() {
2002
+ const pbf = this._pbf;
2003
+ pbf.pos = this._geometry;
2004
+ endPos = pbf.readVarint() + pbf.pos;
2005
+ cmd = 1;
2006
+ length = 0;
2007
+ x = 0;
2008
+ y = 0;
2009
+ i = 0;
2010
+ const indices = [];
2011
+ const data = [];
2012
+ while (pbf.pos < endPos) {
2013
+ if (length <= 0) {
2014
+ cmdLen = pbf.readVarint();
2015
+ cmd = cmdLen & 7;
2016
+ length = cmdLen >> 3;
2017
+ }
2018
+ length--;
2019
+ if (cmd === 1 || cmd === 2) {
2020
+ x += pbf.readSVarint();
2021
+ y += pbf.readSVarint();
2022
+ if (cmd === 1) {
2023
+ indices.push(i);
2024
+ }
2025
+ data.push(x, y);
2026
+ i += 2;
2027
+ } else if (cmd === 7) {
2028
+ if (i > 0) {
2029
+ const start = indices[indices.length - 1];
2030
+ data.push(data[start], data[start + 1]);
2031
+ i += 2;
2032
+ }
2033
+ } else {
2034
+ throw new Error(`unknown command ${cmd}`);
2035
+ }
2036
+ }
2037
+ return { data, indices };
2038
+ }
2039
+ _toBinaryCoordinates(transform) {
2040
+ const geom = this.loadGeometry();
2041
+ let geometry;
2042
+ transform(geom.data, this);
2043
+ const coordLength = 2;
2044
+ switch (this.type) {
2045
+ case 1:
2046
+ this._geometryInfo.pointFeaturesCount++;
2047
+ this._geometryInfo.pointPositionsCount += geom.indices.length;
2048
+ geometry = { type: "Point", ...geom };
2049
+ break;
2050
+ case 2:
2051
+ this._geometryInfo.lineFeaturesCount++;
2052
+ this._geometryInfo.linePathsCount += geom.indices.length;
2053
+ this._geometryInfo.linePositionsCount += geom.data.length / coordLength;
2054
+ geometry = { type: "LineString", ...geom };
2055
+ break;
2056
+ case 3:
2057
+ geometry = classifyRings2(geom);
2058
+ this._geometryInfo.polygonFeaturesCount++;
2059
+ this._geometryInfo.polygonObjectsCount += geometry.indices.length;
2060
+ for (const indices of geometry.indices) {
2061
+ this._geometryInfo.polygonRingsCount += indices.length;
2062
+ }
2063
+ this._geometryInfo.polygonPositionsCount += geometry.data.length / coordLength;
2064
+ break;
2065
+ default:
2066
+ throw new Error(`Invalid geometry type: ${this.type}`);
2067
+ }
2068
+ const result = { type: "Feature", geometry, properties: this.properties };
2069
+ if (this.id !== null) {
2070
+ result.id = this.id;
2071
+ }
2072
+ return result;
2073
+ }
2074
+ toBinaryCoordinates(options) {
2075
+ if (typeof options === "function") {
2076
+ return this._toBinaryCoordinates(options);
2077
+ }
2078
+ const { x: x2, y: y2, z } = options;
2079
+ const size = this.extent * Math.pow(2, z);
2080
+ const x0 = this.extent * x2;
2081
+ const y0 = this.extent * y2;
2082
+ return this._toBinaryCoordinates((data) => project(data, x0, y0, size));
2083
+ }
2084
+ };
2085
+ }
2086
+ });
2087
+
2088
+ // src/lib/binary-vector-tile/vector-tile-layer.ts
2089
+ function readLayer2(tag, layer, pbf) {
2090
+ if (layer && pbf) {
2091
+ if (tag === 15)
2092
+ layer.version = pbf.readVarint();
2093
+ else if (tag === 1)
2094
+ layer.name = pbf.readString();
2095
+ else if (tag === 5)
2096
+ layer.extent = pbf.readVarint();
2097
+ else if (tag === 2)
2098
+ layer._features.push(pbf.pos);
2099
+ else if (tag === 3)
2100
+ layer._keys.push(pbf.readString());
2101
+ else if (tag === 4)
2102
+ layer._values.push(readValueMessage2(pbf));
2103
+ }
2104
+ }
2105
+ function readValueMessage2(pbf) {
2106
+ let value = null;
2107
+ const end = pbf.readVarint() + pbf.pos;
2108
+ while (pbf.pos < end) {
2109
+ const tag = pbf.readVarint() >> 3;
2110
+ value = tag === 1 ? pbf.readString() : tag === 2 ? pbf.readFloat() : tag === 3 ? pbf.readDouble() : tag === 4 ? pbf.readVarint64() : tag === 5 ? pbf.readVarint() : tag === 6 ? pbf.readSVarint() : tag === 7 ? pbf.readBoolean() : null;
2111
+ }
2112
+ return value;
2113
+ }
2114
+ var VectorTileLayer2;
2115
+ var init_vector_tile_layer2 = __esm({
2116
+ "src/lib/binary-vector-tile/vector-tile-layer.ts"() {
2117
+ init_vector_tile_feature2();
2118
+ VectorTileLayer2 = class {
2119
+ constructor(pbf, end) {
2120
+ this.version = 1;
2121
+ this.name = "";
2122
+ this.extent = 4096;
2123
+ this.length = 0;
2124
+ this._pbf = pbf;
2125
+ this._keys = [];
2126
+ this._values = [];
2127
+ this._features = [];
2128
+ pbf.readFields(readLayer2, this, end);
2129
+ this.length = this._features.length;
2130
+ }
2131
+ feature(i2, geometryInfo) {
2132
+ if (i2 < 0 || i2 >= this._features.length) {
2133
+ throw new Error("feature index out of bounds");
2134
+ }
2135
+ this._pbf.pos = this._features[i2];
2136
+ const end = this._pbf.readVarint() + this._pbf.pos;
2137
+ return new VectorTileFeature2(this._pbf, end, this.extent, this._keys, this._values, geometryInfo);
2138
+ }
2139
+ };
2140
+ }
2141
+ });
2142
+
2143
+ // src/lib/binary-vector-tile/vector-tile.ts
2144
+ function readTile2(tag, layers, pbf) {
2145
+ if (tag === 3) {
2146
+ if (pbf) {
2147
+ const layer = new VectorTileLayer2(pbf, pbf.readVarint() + pbf.pos);
2148
+ if (layer.length && layers) {
2149
+ layers[layer.name] = layer;
2150
+ }
2151
+ }
2152
+ }
2153
+ }
2154
+ var VectorTile2;
2155
+ var init_vector_tile2 = __esm({
2156
+ "src/lib/binary-vector-tile/vector-tile.ts"() {
2157
+ init_vector_tile_layer2();
2158
+ VectorTile2 = class {
2159
+ constructor(pbf, end) {
2160
+ this.layers = pbf.readFields(readTile2, {}, end);
2161
+ }
2162
+ };
2163
+ }
2164
+ });
2165
+
2166
+ // src/lib/parse-mvt.ts
2167
+ function parseMVT(arrayBuffer, options) {
2168
+ const mvtOptions = normalizeOptions(options);
2169
+ const shape = options?.gis?.format || options?.mvt?.shape;
2170
+ switch (shape) {
2171
+ case "columnar-table":
2172
+ return { shape: "columnar-table", data: parseToBinary(arrayBuffer, mvtOptions) };
2173
+ case "geojson-row-table": {
2174
+ const table = {
2175
+ shape: "geojson-row-table",
2176
+ data: parseToGeojson(arrayBuffer, mvtOptions)
2177
+ };
2178
+ return table;
2179
+ }
2180
+ case "geojson":
2181
+ return parseToGeojson(arrayBuffer, mvtOptions);
2182
+ case "binary-geometry":
2183
+ return parseToBinary(arrayBuffer, mvtOptions);
2184
+ case "binary":
2185
+ return parseToBinary(arrayBuffer, mvtOptions);
2186
+ default:
2187
+ throw new Error(shape);
2188
+ }
2189
+ }
2190
+ function parseToBinary(arrayBuffer, options) {
2191
+ const [flatGeoJsonFeatures, geometryInfo] = parseToFlatGeoJson(arrayBuffer, options);
2192
+ const binaryData = flatGeojsonToBinary(flatGeoJsonFeatures, geometryInfo);
2193
+ binaryData.byteLength = arrayBuffer.byteLength;
2194
+ return binaryData;
2195
+ }
2196
+ function parseToFlatGeoJson(arrayBuffer, options) {
2197
+ const features = [];
2198
+ const geometryInfo = {
2199
+ coordLength: 2,
2200
+ pointPositionsCount: 0,
2201
+ pointFeaturesCount: 0,
2202
+ linePositionsCount: 0,
2203
+ linePathsCount: 0,
2204
+ lineFeaturesCount: 0,
2205
+ polygonPositionsCount: 0,
2206
+ polygonObjectsCount: 0,
2207
+ polygonRingsCount: 0,
2208
+ polygonFeaturesCount: 0
2209
+ };
2210
+ if (arrayBuffer.byteLength <= 0) {
2211
+ return [features, geometryInfo];
2212
+ }
2213
+ const tile = new VectorTile2(new import_pbf.default(arrayBuffer));
2214
+ const selectedLayers = options && Array.isArray(options.layers) ? options.layers : Object.keys(tile.layers);
2215
+ selectedLayers.forEach((layerName) => {
2216
+ const vectorTileLayer = tile.layers[layerName];
2217
+ if (!vectorTileLayer) {
2218
+ return;
2219
+ }
2220
+ for (let i2 = 0; i2 < vectorTileLayer.length; i2++) {
2221
+ const vectorTileFeature = vectorTileLayer.feature(i2, geometryInfo);
2222
+ const decodedFeature = getDecodedFeatureBinary(vectorTileFeature, options, layerName);
2223
+ features.push(decodedFeature);
2224
+ }
2225
+ });
2226
+ return [features, geometryInfo];
2227
+ }
2228
+ function parseToGeojson(arrayBuffer, options) {
2229
+ if (arrayBuffer.byteLength <= 0) {
2230
+ return [];
2231
+ }
2232
+ const features = [];
2233
+ const tile = new VectorTile(new import_pbf.default(arrayBuffer));
2234
+ const selectedLayers = Array.isArray(options.layers) ? options.layers : Object.keys(tile.layers);
2235
+ selectedLayers.forEach((layerName) => {
2236
+ const vectorTileLayer = tile.layers[layerName];
2237
+ if (!vectorTileLayer) {
2238
+ return;
2239
+ }
2240
+ for (let i2 = 0; i2 < vectorTileLayer.length; i2++) {
2241
+ const vectorTileFeature = vectorTileLayer.feature(i2);
2242
+ const decodedFeature = getDecodedFeature(vectorTileFeature, options, layerName);
2243
+ features.push(decodedFeature);
2244
+ }
2245
+ });
2246
+ return features;
2247
+ }
2248
+ function normalizeOptions(options) {
2249
+ if (!options?.mvt) {
2250
+ throw new Error("mvt options required");
2251
+ }
2252
+ const wgs84Coordinates = options.mvt?.coordinates === "wgs84";
2253
+ const { tileIndex } = options.mvt;
2254
+ const hasTileIndex = tileIndex && Number.isFinite(tileIndex.x) && Number.isFinite(tileIndex.y) && Number.isFinite(tileIndex.z);
2255
+ if (wgs84Coordinates && !hasTileIndex) {
2256
+ throw new Error("MVT Loader: WGS84 coordinates need tileIndex property");
2257
+ }
2258
+ return options.mvt;
2259
+ }
2260
+ function getDecodedFeature(feature, options, layerName) {
2261
+ const decodedFeature = feature.toGeoJSON(options.coordinates === "wgs84" ? options.tileIndex : transformToLocalCoordinates);
2262
+ if (options.layerProperty) {
2263
+ decodedFeature.properties[options.layerProperty] = layerName;
2264
+ }
2265
+ return decodedFeature;
2266
+ }
2267
+ function getDecodedFeatureBinary(feature, options, layerName) {
2268
+ const decodedFeature = feature.toBinaryCoordinates(options.coordinates === "wgs84" ? options.tileIndex : transformToLocalCoordinatesBinary);
2269
+ if (options.layerProperty && decodedFeature.properties) {
2270
+ decodedFeature.properties[options.layerProperty] = layerName;
2271
+ }
2272
+ return decodedFeature;
2273
+ }
2274
+ function transformToLocalCoordinates(line, feature) {
2275
+ const { extent } = feature;
2276
+ for (let i2 = 0; i2 < line.length; i2++) {
2277
+ const p = line[i2];
2278
+ p[0] /= extent;
2279
+ p[1] /= extent;
2280
+ }
2281
+ }
2282
+ function transformToLocalCoordinatesBinary(data, feature) {
2283
+ const { extent } = feature;
2284
+ for (let i2 = 0, il = data.length; i2 < il; ++i2) {
2285
+ data[i2] /= extent;
2286
+ }
2287
+ }
2288
+ var import_pbf;
2289
+ var init_parse_mvt = __esm({
2290
+ "src/lib/parse-mvt.ts"() {
2291
+ init_src();
2292
+ import_pbf = __toModule(require_pbf());
2293
+ init_vector_tile();
2294
+ init_vector_tile2();
2295
+ }
2296
+ });
2297
+
2298
+ // src/mvt-loader.ts
2299
+ var VERSION, DEFAULT_MVT_LOADER_OPTIONS, MVTWorkerLoader, MVTLoader;
2300
+ var init_mvt_loader = __esm({
2301
+ "src/mvt-loader.ts"() {
2302
+ init_parse_mvt();
2303
+ VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
2304
+ DEFAULT_MVT_LOADER_OPTIONS = {
2305
+ mvt: {
2306
+ shape: "geojson",
2307
+ coordinates: "local",
2308
+ layerProperty: "layerName",
2309
+ layers: void 0,
2310
+ tileIndex: null
2311
+ }
2312
+ };
2313
+ MVTWorkerLoader = {
2314
+ name: "Mapbox Vector Tile",
2315
+ id: "mvt",
2316
+ module: "mvt",
2317
+ version: VERSION,
2318
+ extensions: ["mvt", "pbf"],
2319
+ mimeTypes: [
2320
+ "application/vnd.mapbox-vector-tile",
2321
+ "application/x-protobuf"
2322
+ ],
2323
+ worker: true,
2324
+ category: "geometry",
2325
+ options: DEFAULT_MVT_LOADER_OPTIONS
2326
+ };
2327
+ MVTLoader = {
2328
+ ...MVTWorkerLoader,
2329
+ parse: async (arrayBuffer, options) => parseMVT(arrayBuffer, options),
2330
+ parseSync: parseMVT,
2331
+ binary: true
2332
+ };
2333
+ }
2334
+ });
2335
+
2336
+ // src/lib/geojson-tiler/simplify.ts
2337
+ function simplify(coords, first, last, sqTolerance) {
2338
+ let maxSqDist = sqTolerance;
2339
+ const mid = last - first >> 1;
2340
+ let minPosToMid = last - first;
2341
+ let index;
2342
+ const ax = coords[first];
2343
+ const ay = coords[first + 1];
2344
+ const bx = coords[last];
2345
+ const by = coords[last + 1];
2346
+ for (let i2 = first + 3; i2 < last; i2 += 3) {
2347
+ const d = getSqSegDist(coords[i2], coords[i2 + 1], ax, ay, bx, by);
2348
+ if (d > maxSqDist) {
2349
+ index = i2;
2350
+ maxSqDist = d;
2351
+ } else if (d === maxSqDist) {
2352
+ const posToMid = Math.abs(i2 - mid);
2353
+ if (posToMid < minPosToMid) {
2354
+ index = i2;
2355
+ minPosToMid = posToMid;
2356
+ }
2357
+ }
2358
+ }
2359
+ if (maxSqDist > sqTolerance) {
2360
+ if (index - first > 3)
2361
+ simplify(coords, first, index, sqTolerance);
2362
+ coords[index + 2] = maxSqDist;
2363
+ if (last - index > 3)
2364
+ simplify(coords, index, last, sqTolerance);
2365
+ }
2366
+ }
2367
+ function getSqSegDist(px, py, x2, y2, bx, by) {
2368
+ let dx = bx - x2;
2369
+ let dy = by - y2;
2370
+ if (dx !== 0 || dy !== 0) {
2371
+ const t = ((px - x2) * dx + (py - y2) * dy) / (dx * dx + dy * dy);
2372
+ if (t > 1) {
2373
+ x2 = bx;
2374
+ y2 = by;
2375
+ } else if (t > 0) {
2376
+ x2 += dx * t;
2377
+ y2 += dy * t;
2378
+ }
2379
+ }
2380
+ dx = px - x2;
2381
+ dy = py - y2;
2382
+ return dx * dx + dy * dy;
2383
+ }
2384
+ var init_simplify = __esm({
2385
+ "src/lib/geojson-tiler/simplify.ts"() {
2386
+ }
2387
+ });
2388
+
2389
+ // src/lib/geojson-tiler/feature.ts
2390
+ function createFeature(id, type, geom, tags) {
2391
+ const feature = {
2392
+ id: id == null ? null : id,
2393
+ type,
2394
+ geometry: geom,
2395
+ tags,
2396
+ minX: Infinity,
2397
+ minY: Infinity,
2398
+ maxX: -Infinity,
2399
+ maxY: -Infinity
2400
+ };
2401
+ if (type === "Point" || type === "MultiPoint" || type === "LineString") {
2402
+ calcLineBBox(feature, geom);
2403
+ } else if (type === "Polygon") {
2404
+ calcLineBBox(feature, geom[0]);
2405
+ } else if (type === "MultiLineString") {
2406
+ for (const line of geom) {
2407
+ calcLineBBox(feature, line);
2408
+ }
2409
+ } else if (type === "MultiPolygon") {
2410
+ for (const polygon of geom) {
2411
+ calcLineBBox(feature, polygon[0]);
2412
+ }
2413
+ }
2414
+ return feature;
2415
+ }
2416
+ function calcLineBBox(feature, geom) {
2417
+ for (let i2 = 0; i2 < geom.length; i2 += 3) {
2418
+ feature.minX = Math.min(feature.minX, geom[i2]);
2419
+ feature.minY = Math.min(feature.minY, geom[i2 + 1]);
2420
+ feature.maxX = Math.max(feature.maxX, geom[i2]);
2421
+ feature.maxY = Math.max(feature.maxY, geom[i2 + 1]);
2422
+ }
2423
+ }
2424
+ var init_feature = __esm({
2425
+ "src/lib/geojson-tiler/feature.ts"() {
2426
+ }
2427
+ });
2428
+
2429
+ // src/lib/geojson-tiler/convert.ts
2430
+ function convert(data, options) {
2431
+ const features = [];
2432
+ if (data.type === "FeatureCollection") {
2433
+ for (let i2 = 0; i2 < data.features.length; i2++) {
2434
+ convertFeature(features, data.features[i2], options, i2);
2435
+ }
2436
+ } else if (data.type === "Feature") {
2437
+ convertFeature(features, data, options);
2438
+ } else {
2439
+ convertFeature(features, { geometry: data }, options);
2440
+ }
2441
+ return features;
2442
+ }
2443
+ function convertFeature(features, geojson, options, index) {
2444
+ if (!geojson.geometry) {
2445
+ return;
2446
+ }
2447
+ const coords = geojson.geometry.coordinates;
2448
+ const type = geojson.geometry.type;
2449
+ const tolerance = Math.pow(options.tolerance / ((1 << options.maxZoom) * options.extent), 2);
2450
+ let geometry = [];
2451
+ let id = geojson.id;
2452
+ if (options.promoteId) {
2453
+ id = geojson.properties[options.promoteId];
2454
+ } else if (options.generateId) {
2455
+ id = index || 0;
2456
+ }
2457
+ if (type === "Point") {
2458
+ convertPoint(coords, geometry);
2459
+ } else if (type === "MultiPoint") {
2460
+ for (const p of coords) {
2461
+ convertPoint(p, geometry);
2462
+ }
2463
+ } else if (type === "LineString") {
2464
+ convertLine(coords, geometry, tolerance, false);
2465
+ } else if (type === "MultiLineString") {
2466
+ if (options.lineMetrics) {
2467
+ for (const line of coords) {
2468
+ geometry = [];
2469
+ convertLine(line, geometry, tolerance, false);
2470
+ features.push(createFeature(id, "LineString", geometry, geojson.properties));
2471
+ }
2472
+ return;
2473
+ } else {
2474
+ convertLines(coords, geometry, tolerance, false);
2475
+ }
2476
+ } else if (type === "Polygon") {
2477
+ convertLines(coords, geometry, tolerance, true);
2478
+ } else if (type === "MultiPolygon") {
2479
+ for (const polygon of coords) {
2480
+ const newPolygon = [];
2481
+ convertLines(polygon, newPolygon, tolerance, true);
2482
+ geometry.push(newPolygon);
2483
+ }
2484
+ } else if (type === "GeometryCollection") {
2485
+ for (const singleGeometry of geojson.geometry.geometries) {
2486
+ convertFeature(features, {
2487
+ id,
2488
+ geometry: singleGeometry,
2489
+ properties: geojson.properties
2490
+ }, options, index);
2491
+ }
2492
+ return;
2493
+ } else {
2494
+ throw new Error("Input data is not a valid GeoJSON object.");
2495
+ }
2496
+ features.push(createFeature(id, type, geometry, geojson.properties));
2497
+ }
2498
+ function convertPoint(coords, out) {
2499
+ out.push(projectX(coords[0]), projectY(coords[1]), 0);
2500
+ }
2501
+ function convertLine(ring, out, tolerance, isPolygon) {
2502
+ let x0, y0;
2503
+ let size = 0;
2504
+ for (let j = 0; j < ring.length; j++) {
2505
+ const x2 = projectX(ring[j][0]);
2506
+ const y2 = projectY(ring[j][1]);
2507
+ out.push(x2, y2, 0);
2508
+ if (j > 0) {
2509
+ if (isPolygon) {
2510
+ size += (x0 * y2 - x2 * y0) / 2;
2511
+ } else {
2512
+ size += Math.sqrt(Math.pow(x2 - x0, 2) + Math.pow(y2 - y0, 2));
2513
+ }
2514
+ }
2515
+ x0 = x2;
2516
+ y0 = y2;
2517
+ }
2518
+ const last = out.length - 3;
2519
+ out[2] = 1;
2520
+ simplify(out, 0, last, tolerance);
2521
+ out[last + 2] = 1;
2522
+ out.size = Math.abs(size);
2523
+ out.start = 0;
2524
+ out.end = out.size;
2525
+ }
2526
+ function convertLines(rings, out, tolerance, isPolygon) {
2527
+ for (let i2 = 0; i2 < rings.length; i2++) {
2528
+ const geom = [];
2529
+ convertLine(rings[i2], geom, tolerance, isPolygon);
2530
+ out.push(geom);
2531
+ }
2532
+ }
2533
+ function projectX(x2) {
2534
+ return x2 / 360 + 0.5;
2535
+ }
2536
+ function projectY(y2) {
2537
+ const sin = Math.sin(y2 * Math.PI / 180);
2538
+ const y22 = 0.5 - 0.25 * Math.log((1 + sin) / (1 - sin)) / Math.PI;
2539
+ return y22 < 0 ? 0 : y22 > 1 ? 1 : y22;
2540
+ }
2541
+ var init_convert = __esm({
2542
+ "src/lib/geojson-tiler/convert.ts"() {
2543
+ init_simplify();
2544
+ init_feature();
2545
+ }
2546
+ });
2547
+
2548
+ // src/lib/geojson-tiler/clip.ts
2549
+ function clip(features, scale, k1, k2, axis, minAll, maxAll, options) {
2550
+ k1 /= scale;
2551
+ k2 /= scale;
2552
+ if (minAll >= k1 && maxAll < k2) {
2553
+ return features;
2554
+ } else if (maxAll < k1 || minAll >= k2) {
2555
+ return null;
2556
+ }
2557
+ const clipped = [];
2558
+ for (const feature of features) {
2559
+ const geometry = feature.geometry;
2560
+ let type = feature.type;
2561
+ const min = axis === 0 ? feature.minX : feature.minY;
2562
+ const max = axis === 0 ? feature.maxX : feature.maxY;
2563
+ if (min >= k1 && max < k2) {
2564
+ clipped.push(feature);
2565
+ continue;
2566
+ } else if (max < k1 || min >= k2) {
2567
+ continue;
2568
+ }
2569
+ let newGeometry = [];
2570
+ if (type === "Point" || type === "MultiPoint") {
2571
+ clipPoints(geometry, newGeometry, k1, k2, axis);
2572
+ } else if (type === "LineString") {
2573
+ clipLine(geometry, newGeometry, k1, k2, axis, false, options.lineMetrics);
2574
+ } else if (type === "MultiLineString") {
2575
+ clipLines(geometry, newGeometry, k1, k2, axis, false);
2576
+ } else if (type === "Polygon") {
2577
+ clipLines(geometry, newGeometry, k1, k2, axis, true);
2578
+ } else if (type === "MultiPolygon") {
2579
+ for (const polygon of geometry) {
2580
+ const newPolygon = [];
2581
+ clipLines(polygon, newPolygon, k1, k2, axis, true);
2582
+ if (newPolygon.length) {
2583
+ newGeometry.push(newPolygon);
2584
+ }
2585
+ }
2586
+ }
2587
+ if (newGeometry.length) {
2588
+ if (options.lineMetrics && type === "LineString") {
2589
+ for (const line of newGeometry) {
2590
+ clipped.push(createFeature(feature.id, type, line, feature.tags));
2591
+ }
2592
+ continue;
2593
+ }
2594
+ if (type === "LineString" || type === "MultiLineString") {
2595
+ if (newGeometry.length === 1) {
2596
+ type = "LineString";
2597
+ newGeometry = newGeometry[0];
2598
+ } else {
2599
+ type = "MultiLineString";
2600
+ }
2601
+ }
2602
+ if (type === "Point" || type === "MultiPoint") {
2603
+ type = newGeometry.length === 3 ? "Point" : "MultiPoint";
2604
+ }
2605
+ clipped.push(createFeature(feature.id, type, newGeometry, feature.tags));
2606
+ }
2607
+ }
2608
+ return clipped.length ? clipped : null;
2609
+ }
2610
+ function clipPoints(geom, newGeom, k1, k2, axis) {
2611
+ for (let i2 = 0; i2 < geom.length; i2 += 3) {
2612
+ const a = geom[i2 + axis];
2613
+ if (a >= k1 && a <= k2) {
2614
+ addPoint(newGeom, geom[i2], geom[i2 + 1], geom[i2 + 2]);
2615
+ }
2616
+ }
2617
+ }
2618
+ function clipLine(geom, newGeom, k1, k2, axis, isPolygon, trackMetrics) {
2619
+ let slice = newSlice(geom);
2620
+ const intersect2 = axis === 0 ? intersectX : intersectY;
2621
+ let len = geom.start;
2622
+ let segLen;
2623
+ let t;
2624
+ for (let i2 = 0; i2 < geom.length - 3; i2 += 3) {
2625
+ const ax2 = geom[i2];
2626
+ const ay2 = geom[i2 + 1];
2627
+ const az2 = geom[i2 + 2];
2628
+ const bx = geom[i2 + 3];
2629
+ const by = geom[i2 + 4];
2630
+ const a2 = axis === 0 ? ax2 : ay2;
2631
+ const b = axis === 0 ? bx : by;
2632
+ let exited = false;
2633
+ if (trackMetrics) {
2634
+ segLen = Math.sqrt(Math.pow(ax2 - bx, 2) + Math.pow(ay2 - by, 2));
2635
+ }
2636
+ if (a2 < k1) {
2637
+ if (b > k1) {
2638
+ t = intersect2(slice, ax2, ay2, bx, by, k1);
2639
+ if (trackMetrics) {
2640
+ slice.start = len + segLen * t;
2641
+ }
2642
+ }
2643
+ } else if (a2 > k2) {
2644
+ if (b < k2) {
2645
+ t = intersect2(slice, ax2, ay2, bx, by, k2);
2646
+ if (trackMetrics) {
2647
+ slice.start = len + segLen * t;
2648
+ }
2649
+ }
2650
+ } else {
2651
+ addPoint(slice, ax2, ay2, az2);
2652
+ }
2653
+ if (b < k1 && a2 >= k1) {
2654
+ t = intersect2(slice, ax2, ay2, bx, by, k1);
2655
+ exited = true;
2656
+ }
2657
+ if (b > k2 && a2 <= k2) {
2658
+ t = intersect2(slice, ax2, ay2, bx, by, k2);
2659
+ exited = true;
2660
+ }
2661
+ if (!isPolygon && exited) {
2662
+ if (trackMetrics) {
2663
+ slice.end = len + segLen * t;
2664
+ }
2665
+ newGeom.push(slice);
2666
+ slice = newSlice(geom);
2667
+ }
2668
+ if (trackMetrics) {
2669
+ len += segLen;
2670
+ }
2671
+ }
2672
+ let last = geom.length - 3;
2673
+ const ax = geom[last];
2674
+ const ay = geom[last + 1];
2675
+ const az = geom[last + 2];
2676
+ const a = axis === 0 ? ax : ay;
2677
+ if (a >= k1 && a <= k2)
2678
+ addPoint(slice, ax, ay, az);
2679
+ last = slice.length - 3;
2680
+ if (isPolygon && last >= 3 && (slice[last] !== slice[0] || slice[last + 1] !== slice[1])) {
2681
+ addPoint(slice, slice[0], slice[1], slice[2]);
2682
+ }
2683
+ if (slice.length) {
2684
+ newGeom.push(slice);
2685
+ }
2686
+ }
2687
+ function newSlice(line) {
2688
+ const slice = [];
2689
+ slice.size = line.size;
2690
+ slice.start = line.start;
2691
+ slice.end = line.end;
2692
+ return slice;
2693
+ }
2694
+ function clipLines(geom, newGeom, k1, k2, axis, isPolygon) {
2695
+ for (const line of geom) {
2696
+ clipLine(line, newGeom, k1, k2, axis, isPolygon, false);
2697
+ }
2698
+ }
2699
+ function addPoint(out, x2, y2, z) {
2700
+ out.push(x2, y2, z);
2701
+ }
2702
+ function intersectX(out, ax, ay, bx, by, x2) {
2703
+ const t = (x2 - ax) / (bx - ax);
2704
+ addPoint(out, x2, ay + (by - ay) * t, 1);
2705
+ return t;
2706
+ }
2707
+ function intersectY(out, ax, ay, bx, by, y2) {
2708
+ const t = (y2 - ay) / (by - ay);
2709
+ addPoint(out, ax + (bx - ax) * t, y2, 1);
2710
+ return t;
2711
+ }
2712
+ var init_clip = __esm({
2713
+ "src/lib/geojson-tiler/clip.ts"() {
2714
+ init_feature();
2715
+ }
2716
+ });
2717
+
2718
+ // src/lib/geojson-tiler/wrap.ts
2719
+ function wrap(features, options) {
2720
+ const buffer = options.buffer / options.extent;
2721
+ let merged = features;
2722
+ const left = clip(features, 1, -1 - buffer, buffer, 0, -1, 2, options);
2723
+ const right = clip(features, 1, 1 - buffer, 2 + buffer, 0, -1, 2, options);
2724
+ if (left || right) {
2725
+ merged = clip(features, 1, -buffer, 1 + buffer, 0, -1, 2, options) || [];
2726
+ if (left) {
2727
+ merged = shiftFeatureCoords(left, 1).concat(merged);
2728
+ }
2729
+ if (right) {
2730
+ merged = merged.concat(shiftFeatureCoords(right, -1));
2731
+ }
2732
+ }
2733
+ return merged;
2734
+ }
2735
+ function shiftFeatureCoords(features, offset) {
2736
+ const newFeatures = [];
2737
+ for (let i2 = 0; i2 < features.length; i2++) {
2738
+ const feature = features[i2];
2739
+ const type = feature.type;
2740
+ let newGeometry;
2741
+ if (type === "Point" || type === "MultiPoint" || type === "LineString") {
2742
+ newGeometry = shiftCoords(feature.geometry, offset);
2743
+ } else if (type === "MultiLineString" || type === "Polygon") {
2744
+ newGeometry = [];
2745
+ for (const line of feature.geometry) {
2746
+ newGeometry.push(shiftCoords(line, offset));
2747
+ }
2748
+ } else if (type === "MultiPolygon") {
2749
+ newGeometry = [];
2750
+ for (const polygon of feature.geometry) {
2751
+ const newPolygon = [];
2752
+ for (const line of polygon) {
2753
+ newPolygon.push(shiftCoords(line, offset));
2754
+ }
2755
+ newGeometry.push(newPolygon);
2756
+ }
2757
+ }
2758
+ newFeatures.push(createFeature(feature.id, type, newGeometry, feature.tags));
2759
+ }
2760
+ return newFeatures;
2761
+ }
2762
+ function shiftCoords(points, offset) {
2763
+ const newPoints = [];
2764
+ newPoints.size = points.size;
2765
+ if (points.start !== void 0) {
2766
+ newPoints.start = points.start;
2767
+ newPoints.end = points.end;
2768
+ }
2769
+ for (let i2 = 0; i2 < points.length; i2 += 3) {
2770
+ newPoints.push(points[i2] + offset, points[i2 + 1], points[i2 + 2]);
2771
+ }
2772
+ return newPoints;
2773
+ }
2774
+ var init_wrap = __esm({
2775
+ "src/lib/geojson-tiler/wrap.ts"() {
2776
+ init_clip();
2777
+ init_feature();
2778
+ }
2779
+ });
2780
+
2781
+ // src/lib/geojson-tiler/transform.ts
2782
+ function transformTile(tile, extent) {
2783
+ if (tile.transformed) {
2784
+ return tile;
2785
+ }
2786
+ const z2 = 1 << tile.z;
2787
+ const tx = tile.x;
2788
+ const ty = tile.y;
2789
+ for (const feature of tile.features) {
2790
+ const geom = feature.geometry;
2791
+ const type = feature.type;
2792
+ feature.geometry = [];
2793
+ if (type === 1) {
2794
+ for (let j = 0; j < geom.length; j += 2) {
2795
+ feature.geometry.push(transformPoint(geom[j], geom[j + 1], extent, z2, tx, ty));
2796
+ }
2797
+ } else {
2798
+ for (let j = 0; j < geom.length; j++) {
2799
+ const ring = [];
2800
+ for (let k = 0; k < geom[j].length; k += 2) {
2801
+ ring.push(transformPoint(geom[j][k], geom[j][k + 1], extent, z2, tx, ty));
2802
+ }
2803
+ feature.geometry.push(ring);
2804
+ }
2805
+ }
2806
+ }
2807
+ tile.transformed = true;
2808
+ return tile;
2809
+ }
2810
+ function transformPoint(x2, y2, extent, z2, tx, ty) {
2811
+ return [Math.round(extent * (x2 * z2 - tx)), Math.round(extent * (y2 * z2 - ty))];
2812
+ }
2813
+ var init_transform = __esm({
2814
+ "src/lib/geojson-tiler/transform.ts"() {
2815
+ }
2816
+ });
2817
+
2818
+ // src/lib/geojson-tiler/tile.ts
2819
+ function createTile(features, z, tx, ty, options) {
2820
+ const tolerance = z === options.maxZoom ? 0 : options.tolerance / ((1 << z) * options.extent);
2821
+ const tile = {
2822
+ features: [],
2823
+ numPoints: 0,
2824
+ numSimplified: 0,
2825
+ numFeatures: features.length,
2826
+ source: null,
2827
+ x: tx,
2828
+ y: ty,
2829
+ z,
2830
+ transformed: false,
2831
+ minX: 2,
2832
+ minY: 1,
2833
+ maxX: -1,
2834
+ maxY: 0
2835
+ };
2836
+ for (const feature of features) {
2837
+ addFeature(tile, feature, tolerance, options);
2838
+ }
2839
+ return tile;
2840
+ }
2841
+ function addFeature(tile, feature, tolerance, options) {
2842
+ const geom = feature.geometry;
2843
+ const type = feature.type;
2844
+ const simplified = [];
2845
+ tile.minX = Math.min(tile.minX, feature.minX);
2846
+ tile.minY = Math.min(tile.minY, feature.minY);
2847
+ tile.maxX = Math.max(tile.maxX, feature.maxX);
2848
+ tile.maxY = Math.max(tile.maxY, feature.maxY);
2849
+ if (type === "Point" || type === "MultiPoint") {
2850
+ for (let i2 = 0; i2 < geom.length; i2 += 3) {
2851
+ simplified.push(geom[i2], geom[i2 + 1]);
2852
+ tile.numPoints++;
2853
+ tile.numSimplified++;
2854
+ }
2855
+ } else if (type === "LineString") {
2856
+ addLine(simplified, geom, tile, tolerance, false, false);
2857
+ } else if (type === "MultiLineString" || type === "Polygon") {
2858
+ for (let i2 = 0; i2 < geom.length; i2++) {
2859
+ addLine(simplified, geom[i2], tile, tolerance, type === "Polygon", i2 === 0);
2860
+ }
2861
+ } else if (type === "MultiPolygon") {
2862
+ for (let k = 0; k < geom.length; k++) {
2863
+ const polygon = geom[k];
2864
+ for (let i2 = 0; i2 < polygon.length; i2++) {
2865
+ addLine(simplified, polygon[i2], tile, tolerance, true, i2 === 0);
2866
+ }
2867
+ }
2868
+ }
2869
+ if (simplified.length) {
2870
+ let tags = feature.tags || null;
2871
+ if (type === "LineString" && options.lineMetrics) {
2872
+ tags = {};
2873
+ for (const key in feature.tags)
2874
+ tags[key] = feature.tags[key];
2875
+ tags.mapbox_clip_start = geom.start / geom.size;
2876
+ tags.mapbox_clip_end = geom.end / geom.size;
2877
+ }
2878
+ const tileFeature = {
2879
+ geometry: simplified,
2880
+ type: type === "Polygon" || type === "MultiPolygon" ? 3 : type === "LineString" || type === "MultiLineString" ? 2 : 1,
2881
+ tags
2882
+ };
2883
+ if (feature.id !== null) {
2884
+ tileFeature.id = feature.id;
2885
+ }
2886
+ tile.features.push(tileFeature);
2887
+ }
2888
+ }
2889
+ function addLine(result, geom, tile, tolerance, isPolygon, isOuter) {
2890
+ const sqTolerance = tolerance * tolerance;
2891
+ if (tolerance > 0 && geom.size < (isPolygon ? sqTolerance : tolerance)) {
2892
+ tile.numPoints += geom.length / 3;
2893
+ return;
2894
+ }
2895
+ const ring = [];
2896
+ for (let i2 = 0; i2 < geom.length; i2 += 3) {
2897
+ if (tolerance === 0 || geom[i2 + 2] > sqTolerance) {
2898
+ tile.numSimplified++;
2899
+ ring.push(geom[i2], geom[i2 + 1]);
2900
+ }
2901
+ tile.numPoints++;
2902
+ }
2903
+ if (isPolygon)
2904
+ rewind(ring, isOuter);
2905
+ result.push(ring);
2906
+ }
2907
+ function rewind(ring, clockwise) {
2908
+ let area2 = 0;
2909
+ for (let i2 = 0, j = ring.length - 2; i2 < ring.length; j = i2, i2 += 2) {
2910
+ area2 += (ring[i2] - ring[j]) * (ring[i2 + 1] + ring[j + 1]);
2911
+ }
2912
+ if (area2 > 0 === clockwise) {
2913
+ for (let i2 = 0, len = ring.length; i2 < len / 2; i2 += 2) {
2914
+ const x2 = ring[i2];
2915
+ const y2 = ring[i2 + 1];
2916
+ ring[i2] = ring[len - 2 - i2];
2917
+ ring[i2 + 1] = ring[len - 1 - i2];
2918
+ ring[len - 2 - i2] = x2;
2919
+ ring[len - 1 - i2] = y2;
2920
+ }
2921
+ }
2922
+ }
2923
+ var init_tile = __esm({
2924
+ "src/lib/geojson-tiler/tile.ts"() {
2925
+ }
2926
+ });
2927
+
2928
+ // src/lib/geojson-tiler/geojson-tiler.ts
2929
+ function toID(z, x2, y2) {
2930
+ return ((1 << z) * y2 + x2) * 32 + z;
2931
+ }
2932
+ var DEFAULT_OPTIONS, GeoJSONTiler;
2933
+ var init_geojson_tiler = __esm({
2934
+ "src/lib/geojson-tiler/geojson-tiler.ts"() {
2935
+ init_convert();
2936
+ init_clip();
2937
+ init_wrap();
2938
+ init_transform();
2939
+ init_tile();
2940
+ DEFAULT_OPTIONS = {
2941
+ maxZoom: 14,
2942
+ indexMaxZoom: 5,
2943
+ indexMaxPoints: 1e5,
2944
+ tolerance: 3,
2945
+ extent: 4096,
2946
+ buffer: 64,
2947
+ lineMetrics: false,
2948
+ promoteId: void 0,
2949
+ generateId: false,
2950
+ debug: 0
2951
+ };
2952
+ GeoJSONTiler = class {
2953
+ constructor(data, options) {
2954
+ this.tiles = {};
2955
+ this.tileCoords = [];
2956
+ this.stats = {};
2957
+ this.total = 0;
2958
+ this.options = { ...DEFAULT_OPTIONS, ...options };
2959
+ options = this.options;
2960
+ const debug = options.debug;
2961
+ if (debug)
2962
+ console.time("preprocess data");
2963
+ if (this.options.maxZoom < 0 || this.options.maxZoom > 24) {
2964
+ throw new Error("maxZoom should be in the 0-24 range");
2965
+ }
2966
+ if (options.promoteId && this.options.generateId) {
2967
+ throw new Error("promoteId and generateId cannot be used together.");
2968
+ }
2969
+ let features = convert(data, options);
2970
+ if (debug) {
2971
+ console.timeEnd("preprocess data");
2972
+ console.log("index: maxZoom: %d, maxPoints: %d", options.indexMaxZoom, options.indexMaxPoints);
2973
+ console.time("generate tiles");
2974
+ }
2975
+ features = wrap(features, this.options);
2976
+ if (features.length) {
2977
+ this.splitTile(features, 0, 0, 0);
2978
+ }
2979
+ if (debug) {
2980
+ if (features.length) {
2981
+ console.log("features: %d, points: %d", this.tiles[0].numFeatures, this.tiles[0].numPoints);
2982
+ }
2983
+ console.timeEnd("generate tiles");
2984
+ console.log("tiles generated:", this.total, JSON.stringify(this.stats));
2985
+ }
2986
+ }
2987
+ getTile(z, x2, y2) {
2988
+ const { extent, debug } = this.options;
2989
+ if (z < 0 || z > 24) {
2990
+ return null;
2991
+ }
2992
+ const z2 = 1 << z;
2993
+ x2 = x2 + z2 & z2 - 1;
2994
+ const id = toID(z, x2, y2);
2995
+ if (this.tiles[id]) {
2996
+ return transformTile(this.tiles[id], extent);
2997
+ }
2998
+ if (debug > 1)
2999
+ console.log("drilling down to z%d-%d-%d", z, x2, y2);
3000
+ let z0 = z;
3001
+ let x0 = x2;
3002
+ let y0 = y2;
3003
+ let parent;
3004
+ while (!parent && z0 > 0) {
3005
+ z0--;
3006
+ x0 = x0 >> 1;
3007
+ y0 = y0 >> 1;
3008
+ parent = this.tiles[toID(z0, x0, y0)];
3009
+ }
3010
+ if (!parent || !parent.source) {
3011
+ return null;
3012
+ }
3013
+ if (debug > 1) {
3014
+ console.log("found parent tile z%d-%d-%d", z0, x0, y0);
3015
+ console.time("drilling down");
3016
+ }
3017
+ this.splitTile(parent.source, z0, x0, y0, z, x2, y2);
3018
+ if (debug > 1) {
3019
+ console.timeEnd("drilling down");
3020
+ }
3021
+ return this.tiles[id] ? transformTile(this.tiles[id], extent) : null;
3022
+ }
3023
+ splitTile(features, z, x2, y2, cz, cx, cy) {
3024
+ const stack = [features, z, x2, y2];
3025
+ const options = this.options;
3026
+ const debug = options.debug;
3027
+ while (stack.length) {
3028
+ y2 = stack.pop();
3029
+ x2 = stack.pop();
3030
+ z = stack.pop();
3031
+ features = stack.pop();
3032
+ const z2 = 1 << z;
3033
+ const id = toID(z, x2, y2);
3034
+ let tile = this.tiles[id];
3035
+ if (!tile) {
3036
+ if (debug > 1) {
3037
+ console.time("creation");
3038
+ }
3039
+ tile = this.tiles[id] = createTile(features, z, x2, y2, options);
3040
+ this.tileCoords.push({ z, x: x2, y: y2 });
3041
+ if (debug) {
3042
+ if (debug > 1) {
3043
+ console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)", z, x2, y2, tile.numFeatures, tile.numPoints, tile.numSimplified);
3044
+ console.timeEnd("creation");
3045
+ }
3046
+ const key = `z${z}`;
3047
+ this.stats[key] = (this.stats[key] || 0) + 1;
3048
+ this.total++;
3049
+ }
3050
+ }
3051
+ tile.source = features;
3052
+ if (cz === void 0) {
3053
+ if (z === options.indexMaxZoom || tile.numPoints <= options.indexMaxPoints)
3054
+ continue;
3055
+ } else if (z === options.maxZoom || z === cz) {
3056
+ continue;
3057
+ } else if (cz !== void 0) {
3058
+ const zoomSteps = cz - z;
3059
+ if (x2 !== cx >> zoomSteps || y2 !== cy >> zoomSteps)
3060
+ continue;
3061
+ }
3062
+ tile.source = null;
3063
+ if (features.length === 0)
3064
+ continue;
3065
+ if (debug > 1)
3066
+ console.time("clipping");
3067
+ const k1 = 0.5 * options.buffer / options.extent;
3068
+ const k2 = 0.5 - k1;
3069
+ const k3 = 0.5 + k1;
3070
+ const k4 = 1 + k1;
3071
+ let tl = null;
3072
+ let bl = null;
3073
+ let tr = null;
3074
+ let br = null;
3075
+ let left = clip(features, z2, x2 - k1, x2 + k3, 0, tile.minX, tile.maxX, options);
3076
+ let right = clip(features, z2, x2 + k2, x2 + k4, 0, tile.minX, tile.maxX, options);
3077
+ features = null;
3078
+ if (left) {
3079
+ tl = clip(left, z2, y2 - k1, y2 + k3, 1, tile.minY, tile.maxY, options);
3080
+ bl = clip(left, z2, y2 + k2, y2 + k4, 1, tile.minY, tile.maxY, options);
3081
+ left = null;
3082
+ }
3083
+ if (right) {
3084
+ tr = clip(right, z2, y2 - k1, y2 + k3, 1, tile.minY, tile.maxY, options);
3085
+ br = clip(right, z2, y2 + k2, y2 + k4, 1, tile.minY, tile.maxY, options);
3086
+ right = null;
3087
+ }
3088
+ if (debug > 1)
3089
+ console.timeEnd("clipping");
3090
+ stack.push(tl || [], z + 1, x2 * 2, y2 * 2);
3091
+ stack.push(bl || [], z + 1, x2 * 2, y2 * 2 + 1);
3092
+ stack.push(tr || [], z + 1, x2 * 2 + 1, y2 * 2);
3093
+ stack.push(br || [], z + 1, x2 * 2 + 1, y2 * 2 + 1);
3094
+ }
3095
+ }
3096
+ };
3097
+ }
3098
+ });
3099
+
3100
+ // src/index.ts
3101
+ var src_exports = {};
3102
+ __export(src_exports, {
3103
+ GeoJSONTiler: () => GeoJSONTiler,
3104
+ MVTLoader: () => MVTLoader,
3105
+ MVTWorkerLoader: () => MVTWorkerLoader
3106
+ });
3107
+ var init_src2 = __esm({
3108
+ "src/index.ts"() {
3109
+ init_mvt_loader();
3110
+ init_geojson_tiler();
3111
+ }
3112
+ });
3113
+
3114
+ // src/bundle.ts
3115
+ var require_bundle = __commonJS({
3116
+ "src/bundle.ts"(exports, module) {
3117
+ var moduleExports = (init_src2(), src_exports);
3118
+ globalThis.loaders = globalThis.loaders || {};
3119
+ module.exports = Object.assign(globalThis.loaders, moduleExports);
3120
+ }
3121
+ });
3122
+ require_bundle();
3123
+ })();
3124
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */