@ogc-maps/storybook-components 0.13.0 → 0.15.0

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 (109) hide show
  1. package/dist/{LayerPanel-SCdJ8948.js → LayerPanel-C6H74vhO.js} +14 -14
  2. package/dist/components/CollectionBrowser/CollectionBrowser.d.ts +3 -1
  3. package/dist/components/CollectionBrowser/CollectionBrowser.d.ts.map +1 -1
  4. package/dist/components/Cql2FilterEditor/Cql2FilterEditor.d.ts +9 -0
  5. package/dist/components/Cql2FilterEditor/Cql2FilterEditor.d.ts.map +1 -0
  6. package/dist/components/Cql2FilterEditor/Cql2Preview.d.ts +6 -0
  7. package/dist/components/Cql2FilterEditor/Cql2Preview.d.ts.map +1 -0
  8. package/dist/components/Cql2FilterEditor/FilterRuleEditor.d.ts +9 -0
  9. package/dist/components/Cql2FilterEditor/FilterRuleEditor.d.ts.map +1 -0
  10. package/dist/components/Cql2FilterEditor/FilterRuleGroupEditor.d.ts +10 -0
  11. package/dist/components/Cql2FilterEditor/FilterRuleGroupEditor.d.ts.map +1 -0
  12. package/dist/components/Cql2FilterEditor/FilterValueInput.d.ts +12 -0
  13. package/dist/components/Cql2FilterEditor/FilterValueInput.d.ts.map +1 -0
  14. package/dist/components/Cql2FilterEditor/index.d.ts +2 -0
  15. package/dist/components/Cql2FilterEditor/index.d.ts.map +1 -0
  16. package/dist/components/Cql2FilterEditor/operatorOptions.d.ts +9 -0
  17. package/dist/components/Cql2FilterEditor/operatorOptions.d.ts.map +1 -0
  18. package/dist/components/Cql2FilterEditor/styles.d.ts +3 -0
  19. package/dist/components/Cql2FilterEditor/styles.d.ts.map +1 -0
  20. package/dist/components/ImageryEditor/ImageryEditor.d.ts +13 -0
  21. package/dist/components/ImageryEditor/ImageryEditor.d.ts.map +1 -0
  22. package/dist/components/ImageryEditor/ImageryList.d.ts +8 -0
  23. package/dist/components/ImageryEditor/ImageryList.d.ts.map +1 -0
  24. package/dist/components/ImageryEditor/index.d.ts +5 -0
  25. package/dist/components/ImageryEditor/index.d.ts.map +1 -0
  26. package/dist/components/ImageryPanel/ImageryPanel.d.ts +10 -0
  27. package/dist/components/ImageryPanel/ImageryPanel.d.ts.map +1 -0
  28. package/dist/components/ImageryPanel/index.d.ts +3 -0
  29. package/dist/components/ImageryPanel/index.d.ts.map +1 -0
  30. package/dist/components/LayerEditor/LayerEditor.d.ts.map +1 -1
  31. package/dist/components/LayerPanel/index.js +1 -1
  32. package/dist/components/QueryPanel/QueryPanel.d.ts +14 -0
  33. package/dist/components/QueryPanel/QueryPanel.d.ts.map +1 -0
  34. package/dist/components/QueryPanel/index.d.ts +3 -0
  35. package/dist/components/QueryPanel/index.d.ts.map +1 -0
  36. package/dist/components/ResultsDrawer/ResultsDrawer.d.ts +18 -4
  37. package/dist/components/ResultsDrawer/ResultsDrawer.d.ts.map +1 -1
  38. package/dist/components/ResultsDrawer/index.d.ts +1 -1
  39. package/dist/components/ResultsDrawer/index.d.ts.map +1 -1
  40. package/dist/components/SelectionPanel/SelectionPanel.d.ts +3 -1
  41. package/dist/components/SelectionPanel/SelectionPanel.d.ts.map +1 -1
  42. package/dist/components/SourceEditor/SourceEditor.d.ts +2 -2
  43. package/dist/components/SourceEditor/SourceEditor.d.ts.map +1 -1
  44. package/dist/components/SourceEditor/SourceList.d.ts.map +1 -1
  45. package/dist/components/StyleEditor/DataDrivenColorEditor.d.ts +2 -2
  46. package/dist/components/StyleEditor/DataDrivenColorEditor.d.ts.map +1 -1
  47. package/dist/components/StyleEditor/PropertyField.d.ts +2 -2
  48. package/dist/components/StyleEditor/PropertyField.d.ts.map +1 -1
  49. package/dist/components/StyleEditor/PropertyGroup.d.ts +2 -2
  50. package/dist/components/StyleEditor/PropertyGroup.d.ts.map +1 -1
  51. package/dist/components/StyleEditor/StyleEditor.d.ts +2 -2
  52. package/dist/components/StyleEditor/StyleEditor.d.ts.map +1 -1
  53. package/dist/components/UIConfigEditor/UIConfigEditor.d.ts.map +1 -1
  54. package/dist/components/index.d.ts +9 -1
  55. package/dist/components/index.d.ts.map +1 -1
  56. package/dist/geo-BXaVaxak.js +9707 -0
  57. package/dist/hooks/index.d.ts +6 -4
  58. package/dist/hooks/index.d.ts.map +1 -1
  59. package/dist/hooks/index.js +68 -52
  60. package/dist/hooks/useExport.d.ts +2 -8
  61. package/dist/hooks/useExport.d.ts.map +1 -1
  62. package/dist/hooks/useOgcCollections.d.ts +3 -2
  63. package/dist/hooks/useOgcCollections.d.ts.map +1 -1
  64. package/dist/hooks/useOgcFeatures.d.ts +2 -2
  65. package/dist/hooks/useOgcFeatures.d.ts.map +1 -1
  66. package/dist/index-CzYEPGO9.js +3571 -0
  67. package/dist/main.js +3182 -1971
  68. package/dist/schemas/config.d.ts +1833 -4763
  69. package/dist/schemas/config.d.ts.map +1 -1
  70. package/dist/schemas/index.d.ts +1 -1
  71. package/dist/schemas/index.d.ts.map +1 -1
  72. package/dist/schemas/index.js +18 -16
  73. package/dist/style.css +1 -1
  74. package/dist/types/index.d.ts +41 -2
  75. package/dist/types/index.d.ts.map +1 -1
  76. package/dist/types/index.js +42 -29
  77. package/dist/useSelection-B1RnQZlj.js +206 -0
  78. package/dist/utils/cql2.d.ts +34 -5
  79. package/dist/utils/cql2.d.ts.map +1 -1
  80. package/dist/utils/exportConverters.d.ts +16 -0
  81. package/dist/utils/exportConverters.d.ts.map +1 -0
  82. package/dist/utils/geo.d.ts +6 -0
  83. package/dist/utils/geo.d.ts.map +1 -1
  84. package/dist/utils/index.d.ts +5 -0
  85. package/dist/utils/index.d.ts.map +1 -1
  86. package/dist/utils/index.js +275 -0
  87. package/dist/utils/ogcApi.d.ts +63 -14
  88. package/dist/utils/ogcApi.d.ts.map +1 -1
  89. package/dist/utils/queryParameters.d.ts +22 -0
  90. package/dist/utils/queryParameters.d.ts.map +1 -0
  91. package/dist/utils/queryableHelpers.d.ts +4 -0
  92. package/dist/utils/queryableHelpers.d.ts.map +1 -1
  93. package/package.json +26 -15
  94. package/dist/components/PropertyDisplayEditor/__tests__/PropertyDisplayEditor.test.d.ts +0 -2
  95. package/dist/components/PropertyDisplayEditor/__tests__/PropertyDisplayEditor.test.d.ts.map +0 -1
  96. package/dist/geo-BxXVSJvJ.js +0 -1133
  97. package/dist/index-CtbLVsqD.js +0 -3011
  98. package/dist/schemas/__tests__/config.test.d.ts +0 -2
  99. package/dist/schemas/__tests__/config.test.d.ts.map +0 -1
  100. package/dist/utils/__tests__/cql2.test.d.ts +0 -2
  101. package/dist/utils/__tests__/cql2.test.d.ts.map +0 -1
  102. package/dist/utils/__tests__/expressionColors.test.d.ts +0 -2
  103. package/dist/utils/__tests__/expressionColors.test.d.ts.map +0 -1
  104. package/dist/utils/__tests__/propertyDisplay.test.d.ts +0 -2
  105. package/dist/utils/__tests__/propertyDisplay.test.d.ts.map +0 -1
  106. package/dist/utils/__tests__/queryableHelpers.test.d.ts +0 -2
  107. package/dist/utils/__tests__/queryableHelpers.test.d.ts.map +0 -1
  108. package/dist/utils/__tests__/wkt.test.d.ts +0 -2
  109. package/dist/utils/__tests__/wkt.test.d.ts.map +0 -1
@@ -1,1133 +0,0 @@
1
- import { useState as d, useEffect as N, useCallback as v, useMemo as j } from "react";
2
- var S = 63710088e-1, ne = {
3
- centimeters: S * 100,
4
- centimetres: S * 100,
5
- degrees: 360 / (2 * Math.PI),
6
- feet: S * 3.28084,
7
- inches: S * 39.37,
8
- kilometers: S / 1e3,
9
- kilometres: S / 1e3,
10
- meters: S,
11
- metres: S,
12
- miles: S / 1609.344,
13
- millimeters: S * 1e3,
14
- millimetres: S * 1e3,
15
- nauticalmiles: S / 1852,
16
- radians: 1,
17
- yards: S * 1.0936
18
- };
19
- function T(e, t, n = {}) {
20
- const r = { type: "Feature" };
21
- return (n.id === 0 || n.id) && (r.id = n.id), n.bbox && (r.bbox = n.bbox), r.properties = t || {}, r.geometry = e, r;
22
- }
23
- function re(e, t, n = {}) {
24
- for (const s of e) {
25
- if (s.length < 4)
26
- throw new Error(
27
- "Each LinearRing of a Polygon must have 4 or more Positions."
28
- );
29
- if (s[s.length - 1].length !== s[0].length)
30
- throw new Error("First and last Position are not equivalent.");
31
- for (let i = 0; i < s[s.length - 1].length; i++)
32
- if (s[s.length - 1][i] !== s[0][i])
33
- throw new Error("First and last Position are not equivalent.");
34
- }
35
- return T({
36
- type: "Polygon",
37
- coordinates: e
38
- }, t, n);
39
- }
40
- function Q(e, t, n = {}) {
41
- if (e.length < 2)
42
- throw new Error("coordinates must be an array of two or more positions");
43
- return T({
44
- type: "LineString",
45
- coordinates: e
46
- }, t, n);
47
- }
48
- function se(e, t = "kilometers") {
49
- const n = ne[t];
50
- if (!n)
51
- throw new Error(t + " units is invalid");
52
- return e * n;
53
- }
54
- function R(e) {
55
- return e % 360 * Math.PI / 180;
56
- }
57
- function I(e) {
58
- if (!e)
59
- throw new Error("coord is required");
60
- if (!Array.isArray(e)) {
61
- if (e.type === "Feature" && e.geometry !== null && e.geometry.type === "Point")
62
- return [...e.geometry.coordinates];
63
- if (e.type === "Point")
64
- return [...e.coordinates];
65
- }
66
- if (Array.isArray(e) && e.length >= 2 && !Array.isArray(e[0]) && !Array.isArray(e[1]))
67
- return [...e];
68
- throw new Error("coord must be GeoJSON Point or an Array of numbers");
69
- }
70
- function ie(e, t, n = {}) {
71
- var r = I(e), s = I(t), i = R(s[1] - r[1]), l = R(s[0] - r[0]), o = R(r[1]), a = R(s[1]), c = Math.pow(Math.sin(i / 2), 2) + Math.pow(Math.sin(l / 2), 2) * Math.cos(o) * Math.cos(a);
72
- return se(
73
- 2 * Math.atan2(Math.sqrt(c), Math.sqrt(1 - c)),
74
- n.units
75
- );
76
- }
77
- function B(e, t, n) {
78
- if (e !== null)
79
- for (var r, s, i, l, o, a, c, g = 0, f = 0, u, m = e.type, h = m === "FeatureCollection", p = m === "Feature", b = h ? e.features.length : 1, y = 0; y < b; y++) {
80
- c = h ? (
81
- // @ts-expect-error: Known type conflict
82
- e.features[y].geometry
83
- ) : p ? (
84
- // @ts-expect-error: Known type conflict
85
- e.geometry
86
- ) : e, u = c ? c.type === "GeometryCollection" : !1, o = u ? c.geometries.length : 1;
87
- for (var k = 0; k < o; k++) {
88
- var w = 0, M = 0;
89
- if (l = u ? c.geometries[k] : c, l !== null) {
90
- a = l.coordinates;
91
- var P = l.type;
92
- switch (g = 0, P) {
93
- case null:
94
- break;
95
- case "Point":
96
- if (
97
- // @ts-expect-error: Known type conflict
98
- t(
99
- a,
100
- f,
101
- y,
102
- w,
103
- M
104
- ) === !1
105
- )
106
- return !1;
107
- f++, w++;
108
- break;
109
- case "LineString":
110
- case "MultiPoint":
111
- for (r = 0; r < a.length; r++) {
112
- if (
113
- // @ts-expect-error: Known type conflict
114
- t(
115
- a[r],
116
- f,
117
- y,
118
- w,
119
- M
120
- ) === !1
121
- )
122
- return !1;
123
- f++, P === "MultiPoint" && w++;
124
- }
125
- P === "LineString" && w++;
126
- break;
127
- case "Polygon":
128
- case "MultiLineString":
129
- for (r = 0; r < a.length; r++) {
130
- for (s = 0; s < a[r].length - g; s++) {
131
- if (
132
- // @ts-expect-error: Known type conflict
133
- t(
134
- a[r][s],
135
- f,
136
- y,
137
- w,
138
- M
139
- ) === !1
140
- )
141
- return !1;
142
- f++;
143
- }
144
- P === "MultiLineString" && w++, P === "Polygon" && M++;
145
- }
146
- P === "Polygon" && w++;
147
- break;
148
- case "MultiPolygon":
149
- for (r = 0; r < a.length; r++) {
150
- for (M = 0, s = 0; s < a[r].length; s++) {
151
- for (i = 0; i < a[r][s].length - g; i++) {
152
- if (
153
- // @ts-expect-error: Known type conflict
154
- t(
155
- a[r][s][i],
156
- f,
157
- y,
158
- w,
159
- M
160
- ) === !1
161
- )
162
- return !1;
163
- f++;
164
- }
165
- M++;
166
- }
167
- w++;
168
- }
169
- break;
170
- case "GeometryCollection":
171
- for (r = 0; r < l.geometries.length; r++)
172
- if (
173
- // @ts-expect-error: Known type conflict
174
- B(l.geometries[r], t) === !1
175
- )
176
- return !1;
177
- break;
178
- default:
179
- throw new Error("Unknown Geometry Type");
180
- }
181
- }
182
- }
183
- }
184
- }
185
- function K(e, t) {
186
- var n, r, s, i, l, o, a, c, g, f, u = 0, m = e.type === "FeatureCollection", h = e.type === "Feature", p = m ? e.features.length : 1;
187
- for (n = 0; n < p; n++) {
188
- for (o = m ? (
189
- // @ts-expect-error: Known type conflict
190
- e.features[n].geometry
191
- ) : h ? (
192
- // @ts-expect-error: Known type conflict
193
- e.geometry
194
- ) : e, c = m ? (
195
- // @ts-expect-error: Known type conflict
196
- e.features[n].properties
197
- ) : h ? (
198
- // @ts-expect-error: Known type conflict
199
- e.properties
200
- ) : {}, g = m ? (
201
- // @ts-expect-error: Known type conflict
202
- e.features[n].bbox
203
- ) : h ? (
204
- // @ts-expect-error: Known type conflict
205
- e.bbox
206
- ) : void 0, f = m ? (
207
- // @ts-expect-error: Known type conflict
208
- e.features[n].id
209
- ) : h ? (
210
- // @ts-expect-error: Known type conflict
211
- e.id
212
- ) : void 0, a = o ? o.type === "GeometryCollection" : !1, l = a ? o.geometries.length : 1, s = 0; s < l; s++) {
213
- if (i = a ? o.geometries[s] : o, i === null) {
214
- if (
215
- // @ts-expect-error: Known type conflict
216
- t(
217
- // @ts-expect-error: Known type conflict
218
- null,
219
- u,
220
- c,
221
- g,
222
- f
223
- ) === !1
224
- )
225
- return !1;
226
- continue;
227
- }
228
- switch (i.type) {
229
- case "Point":
230
- case "LineString":
231
- case "MultiPoint":
232
- case "Polygon":
233
- case "MultiLineString":
234
- case "MultiPolygon": {
235
- if (
236
- // @ts-expect-error: Known type conflict
237
- t(
238
- i,
239
- u,
240
- c,
241
- g,
242
- f
243
- ) === !1
244
- )
245
- return !1;
246
- break;
247
- }
248
- case "GeometryCollection": {
249
- for (r = 0; r < i.geometries.length; r++)
250
- if (
251
- // @ts-expect-error: Known type conflict
252
- t(
253
- i.geometries[r],
254
- u,
255
- c,
256
- g,
257
- f
258
- ) === !1
259
- )
260
- return !1;
261
- break;
262
- }
263
- default:
264
- throw new Error("Unknown Geometry Type");
265
- }
266
- }
267
- u++;
268
- }
269
- }
270
- function oe(e, t, n) {
271
- var r = n;
272
- return K(
273
- e,
274
- function(s, i, l, o, a) {
275
- r = t(
276
- // @ts-expect-error: Known type conflict
277
- r,
278
- s,
279
- i,
280
- l,
281
- o,
282
- a
283
- );
284
- }
285
- ), r;
286
- }
287
- function ae(e, t) {
288
- K(e, function(n, r, s, i, l) {
289
- var o = n === null ? null : n.type;
290
- switch (o) {
291
- case null:
292
- case "Point":
293
- case "LineString":
294
- case "Polygon":
295
- return (
296
- // @ts-expect-error: Known type conflict
297
- t(
298
- T(n, s, { bbox: i, id: l }),
299
- r,
300
- 0
301
- ) === !1 ? !1 : void 0
302
- );
303
- }
304
- var a;
305
- switch (o) {
306
- case "MultiPoint":
307
- a = "Point";
308
- break;
309
- case "MultiLineString":
310
- a = "LineString";
311
- break;
312
- case "MultiPolygon":
313
- a = "Polygon";
314
- break;
315
- }
316
- for (
317
- var c = 0;
318
- // @ts-expect-error: Known type conflict
319
- c < n.coordinates.length;
320
- c++
321
- ) {
322
- var g = n.coordinates[c], f = {
323
- type: a,
324
- coordinates: g
325
- };
326
- if (
327
- // @ts-expect-error: Known type conflict
328
- t(T(f, s), r, c) === !1
329
- )
330
- return !1;
331
- }
332
- });
333
- }
334
- function le(e, t) {
335
- ae(e, function(n, r, s) {
336
- var i = 0;
337
- if (n.geometry) {
338
- var l = n.geometry.type;
339
- if (!(l === "Point" || l === "MultiPoint")) {
340
- var o, a = 0, c = 0, g = 0;
341
- if (
342
- // @ts-expect-error: Known type conflict
343
- B(
344
- n,
345
- function(f, u, m, h, p) {
346
- if (
347
- // @ts-expect-error: Known type conflict
348
- o === void 0 || r > a || h > c || p > g
349
- ) {
350
- o = f, a = r, c = h, g = p, i = 0;
351
- return;
352
- }
353
- var b = Q(
354
- // @ts-expect-error: Known type conflict
355
- [o, f],
356
- n.properties
357
- );
358
- if (
359
- // @ts-expect-error: Known type conflict
360
- t(
361
- // @ts-expect-error: Known type conflict
362
- b,
363
- r,
364
- s,
365
- p,
366
- i
367
- ) === !1
368
- )
369
- return !1;
370
- i++, o = f;
371
- }
372
- ) === !1
373
- )
374
- return !1;
375
- }
376
- }
377
- });
378
- }
379
- function ce(e, t, n) {
380
- var r = n, s = !1;
381
- return le(
382
- e,
383
- function(i, l, o, a, c) {
384
- s === !1 && n === void 0 ? r = i : r = t(
385
- r,
386
- // @ts-expect-error: Known type conflict
387
- i,
388
- l,
389
- o,
390
- a,
391
- c
392
- ), s = !0;
393
- }
394
- ), r;
395
- }
396
- function ue(e, t = {}) {
397
- return ce(
398
- e,
399
- (n, r) => {
400
- const s = r.geometry.coordinates;
401
- return n + ie(s[0], s[1], t);
402
- },
403
- 0
404
- );
405
- }
406
- var fe = ue;
407
- function ge(e) {
408
- return oe(
409
- e,
410
- (t, n) => t + he(n),
411
- 0
412
- );
413
- }
414
- function he(e) {
415
- let t = 0, n;
416
- switch (e.type) {
417
- case "Polygon":
418
- return J(e.coordinates);
419
- case "MultiPolygon":
420
- for (n = 0; n < e.coordinates.length; n++)
421
- t += J(e.coordinates[n]);
422
- return t;
423
- case "Point":
424
- case "MultiPoint":
425
- case "LineString":
426
- case "MultiLineString":
427
- return 0;
428
- }
429
- return 0;
430
- }
431
- function J(e) {
432
- let t = 0;
433
- if (e && e.length > 0) {
434
- t += Math.abs(W(e[0]));
435
- for (let n = 1; n < e.length; n++)
436
- t -= Math.abs(W(e[n]));
437
- }
438
- return t;
439
- }
440
- var me = S * S / 2, U = Math.PI / 180;
441
- function W(e) {
442
- const t = e.length - 1;
443
- if (t <= 2) return 0;
444
- let n = 0, r = 0;
445
- for (; r < t; ) {
446
- const s = e[r], i = e[r + 1 === t ? 0 : r + 1], l = e[r + 2 >= t ? (r + 2) % t : r + 2], o = s[0] * U, a = i[1] * U, c = l[0] * U;
447
- n += (c - o) * Math.sin(a), r++;
448
- }
449
- return n * me;
450
- }
451
- var de = ge;
452
- const Ie = {
453
- distance: ["km", "mi", "m", "ft"],
454
- area: ["km2", "mi2", "ha", "acres"]
455
- }, ye = {
456
- km: "km",
457
- mi: "mi",
458
- m: "m",
459
- ft: "ft",
460
- km2: "km²",
461
- mi2: "mi²",
462
- ha: "ha",
463
- acres: "ac"
464
- }, pe = {
465
- km: 1,
466
- mi: 0.621371,
467
- m: 1e3,
468
- ft: 3280.84
469
- }, be = {
470
- km2: 1e-6,
471
- mi2: 3861e-10,
472
- ha: 1e-4,
473
- acres: 247105e-9
474
- };
475
- function Se(e, t = "km") {
476
- if (e.length < 2) return 0;
477
- const n = Q(e);
478
- return fe(n, { units: "kilometers" }) * pe[t];
479
- }
480
- function we(e, t = "km2") {
481
- if (e.length < 3) return 0;
482
- const n = [...e, e[0]], r = re([n]);
483
- return de(r) * be[t];
484
- }
485
- function Me(e, t, n) {
486
- return e === "distance" && t.length >= 2 ? { value: Se(t, n), unit: n } : e === "area" && t.length >= 3 ? { value: we(t, n), unit: n } : null;
487
- }
488
- function ve(e) {
489
- return e === "distance" ? "km" : "km2";
490
- }
491
- function $e(e, t) {
492
- return t.length < 2 ? null : {
493
- type: "Feature",
494
- geometry: e === "area" && t.length >= 3 ? { type: "Polygon", coordinates: [[...t, t[0]]] } : { type: "LineString", coordinates: t },
495
- properties: {}
496
- };
497
- }
498
- function Pe(e) {
499
- return e.length === 0 ? null : {
500
- type: "FeatureCollection",
501
- features: e.map((t) => ({
502
- type: "Feature",
503
- geometry: { type: "Point", coordinates: t },
504
- properties: {}
505
- }))
506
- };
507
- }
508
- function Je(e) {
509
- const { value: t, unit: n } = e, r = ye[n];
510
- return t < 0.01 ? `< 0.01 ${r}` : t < 100 ? `${t.toFixed(2)} ${r}` : t < 1e4 ? `${t.toFixed(1)} ${r}` : `${t.toLocaleString(void 0, { maximumFractionDigits: 0 })} ${r}`;
511
- }
512
- function $(e) {
513
- return e.endsWith("/") ? e.slice(0, -1) : e;
514
- }
515
- async function C(e) {
516
- const t = await fetch(e);
517
- if (!t.ok)
518
- throw new Error(`OGC API request failed: ${t.status} ${t.statusText} (${e})`);
519
- return t.json();
520
- }
521
- async function Ce(e) {
522
- const t = `${$(e)}/collections?f=json`;
523
- return (await C(t)).collections;
524
- }
525
- async function L(e, t, n = {}) {
526
- var l;
527
- const r = $(e), s = new URLSearchParams({ f: "geojson" });
528
- if (n.limit != null && s.set("limit", String(n.limit)), n.offset != null && s.set("offset", String(n.offset)), n.bbox && s.set("bbox", n.bbox.join(",")), (l = n.properties) != null && l.length && s.set("properties", n.properties.join(",")), n.datetime && s.set("datetime", n.datetime), n.cql2Filter)
529
- s.set("filter-lang", "cql2-json"), s.set("filter", JSON.stringify(n.cql2Filter));
530
- else if (n.filter)
531
- for (const [o, a] of Object.entries(n.filter))
532
- s.set(o, String(a));
533
- const i = `${r}/collections/${encodeURIComponent(t)}/items?${s}`;
534
- return C(i);
535
- }
536
- async function We(e, t, n) {
537
- const s = `${$(e)}/collections/${encodeURIComponent(t)}/items/${encodeURIComponent(String(n))}?f=geojson`;
538
- try {
539
- return await C(s);
540
- } catch {
541
- return null;
542
- }
543
- }
544
- async function ke(e, t) {
545
- const r = `${$(e)}/collections/${encodeURIComponent(t)}/queryables?f=schemajson`;
546
- return C(r);
547
- }
548
- async function Le(e, t) {
549
- const r = `${$(e)}/collections/${encodeURIComponent(t)}?f=json`;
550
- return C(r);
551
- }
552
- async function ze(e) {
553
- const t = `${$(e)}/conformance?f=json`;
554
- return C(t);
555
- }
556
- async function Ve(e, t, n = "WebMercatorQuad") {
557
- const r = Ee(e, t, n);
558
- return C(r);
559
- }
560
- async function Qe(e, t, n = {}) {
561
- return (await L(e, t, {
562
- ...n,
563
- limit: 0
564
- })).numberMatched ?? null;
565
- }
566
- function Ee(e, t, n = "WebMercatorQuad") {
567
- return `${$(e)}/collections/${encodeURIComponent(t)}/tiles/${encodeURIComponent(n)}/tilejson.json`;
568
- }
569
- function Be(e, t, n = "WebMercatorQuad") {
570
- return `${$(e)}/collections/${encodeURIComponent(t)}/tiles/${encodeURIComponent(n)}/{z}/{x}/{y}`;
571
- }
572
- function Ke(e, t, n, r = "WebMercatorQuad") {
573
- const i = `${$(e)}/collections/${encodeURIComponent(t)}/tiles/${encodeURIComponent(r)}/{z}/{x}/{y}`;
574
- if (!n || Object.keys(n).length === 0) return i;
575
- const l = new URLSearchParams();
576
- for (const [o, a] of Object.entries(n))
577
- l.set(o, String(a));
578
- return `${i}?${l}`;
579
- }
580
- async function Xe(e, t, n, r) {
581
- const s = r != null && r.query ? { op: "like", args: [{ property: n }, `%${r.query}%`] } : void 0, i = /* @__PURE__ */ new Set(), l = (o) => {
582
- var a;
583
- for (const c of o) {
584
- const g = (a = c.properties) == null ? void 0 : a[n];
585
- g != null && typeof g == "string" && i.add(g);
586
- }
587
- };
588
- if (r != null && r.fetchAll) {
589
- const o = r.maxFeatures ?? 1e4, a = r.limit ?? 500;
590
- let c = 0, g = 0;
591
- for (; g < o; ) {
592
- const f = Math.min(a, o - g), u = await L(e, t, {
593
- properties: [n],
594
- limit: f,
595
- offset: c,
596
- cql2Filter: s
597
- });
598
- if (l(u.features), g += u.features.length, c += u.features.length, u.features.length < f || u.numberMatched != null && c >= u.numberMatched) break;
599
- }
600
- } else {
601
- const o = await L(e, t, {
602
- properties: [n],
603
- limit: (r == null ? void 0 : r.limit) ?? 50,
604
- cql2Filter: s
605
- });
606
- l(o.features);
607
- }
608
- return Array.from(i).sort();
609
- }
610
- function Ye(e, t, n, r = "WebMercatorQuad") {
611
- const i = `${$(e)}/collections/${encodeURIComponent(t)}/tiles/${encodeURIComponent(r)}/{z}/{x}/{y}`;
612
- if (!n) return i;
613
- const l = new URLSearchParams({
614
- "filter-lang": "cql2-json",
615
- filter: JSON.stringify(n)
616
- });
617
- return `${i}?${l}`;
618
- }
619
- function He(e, t) {
620
- return t ? `${e}--${JSON.stringify(t)}` : e;
621
- }
622
- function Ze(e) {
623
- return e.length === 1 ? ["==", ["geometry-type"], e[0]] : ["in", ["geometry-type"], ["literal", e]];
624
- }
625
- function et(e) {
626
- const [t, n] = d([]), [r, s] = d(!1), [i, l] = d(null);
627
- return N(() => {
628
- if (!e) return;
629
- let o = !1;
630
- return s(!0), l(null), Ce(e).then((a) => {
631
- o || n(a);
632
- }).catch((a) => {
633
- o || l(a instanceof Error ? a : new Error(String(a)));
634
- }).finally(() => {
635
- o || s(!1);
636
- }), () => {
637
- o = !0;
638
- };
639
- }, [e]), { collections: t, loading: r, error: i };
640
- }
641
- function tt(e, t) {
642
- const [n, r] = d(null), [s, i] = d(!1), [l, o] = d(null);
643
- return N(() => {
644
- if (!e || !t) return;
645
- let a = !1;
646
- return i(!0), o(null), ke(e, t).then((c) => {
647
- a || r(c);
648
- }).catch((c) => {
649
- a || o(c instanceof Error ? c : new Error(String(c)));
650
- }).finally(() => {
651
- a || i(!1);
652
- }), () => {
653
- a = !0;
654
- };
655
- }, [e, t]), { queryables: n, loading: s, error: l };
656
- }
657
- function nt(e, t, n = {}) {
658
- const [r, s] = d([]), [i, l] = d(!1), [o, a] = d(null), [c, g] = d(!1), f = JSON.stringify(n);
659
- return N(() => {
660
- if (!e || !t) return;
661
- let u = !1;
662
- l(!0), a(null);
663
- const m = JSON.parse(f);
664
- return L(e, t, m).then((h) => {
665
- if (!u) {
666
- s(h.features);
667
- const p = m.limit ?? 10, b = m.offset ?? 0;
668
- h.numberMatched != null ? g(b + h.features.length < h.numberMatched) : g(h.features.length >= p);
669
- }
670
- }).catch((h) => {
671
- u || (a(h instanceof Error ? h : new Error(String(h))), s([]), g(!1));
672
- }).finally(() => {
673
- u || l(!1);
674
- }), () => {
675
- u = !0;
676
- };
677
- }, [e, t, f]), { features: r, loading: i, error: o, hasMore: c };
678
- }
679
- function _(e) {
680
- return `${e[0]} ${e[1]}`;
681
- }
682
- function A(e) {
683
- return e.map(_).join(", ");
684
- }
685
- function X(e) {
686
- if (!e || !e.type) return "";
687
- switch (e.type) {
688
- case "Point":
689
- return `POINT (${_(e.coordinates)})`;
690
- case "MultiPoint":
691
- return `MULTIPOINT (${e.coordinates.map((t) => `(${_(t)})`).join(", ")})`;
692
- case "LineString":
693
- return `LINESTRING (${A(e.coordinates)})`;
694
- case "MultiLineString":
695
- return `MULTILINESTRING (${e.coordinates.map((t) => `(${A(t)})`).join(", ")})`;
696
- case "Polygon":
697
- return `POLYGON (${e.coordinates.map((t) => `(${A(t)})`).join(", ")})`;
698
- case "MultiPolygon":
699
- return `MULTIPOLYGON (${e.coordinates.map((t) => `(${t.map((n) => `(${A(n)})`).join(", ")})`).join(", ")})`;
700
- case "GeometryCollection":
701
- return `GEOMETRYCOLLECTION (${e.geometries.map(X).join(", ")})`;
702
- default:
703
- return "";
704
- }
705
- }
706
- function Y(e, t) {
707
- const n = URL.createObjectURL(e), r = document.createElement("a");
708
- r.href = n, r.download = t, r.style.display = "none", document.body.appendChild(r), r.click(), document.body.removeChild(r), URL.revokeObjectURL(n);
709
- }
710
- function x(e, t) {
711
- return e.includes('"') || e.includes(t) || e.includes(`
712
- `) ? `"${e.replace(/"/g, '""')}"` : e;
713
- }
714
- function Oe(e, t) {
715
- const n = (e.properties ?? {})[t];
716
- return n == null ? "" : typeof n == "object" ? JSON.stringify(n) : String(n);
717
- }
718
- function Fe(e, t = {}) {
719
- const { fields: n, includeGeometry: r = !0, delimiter: s = "," } = t;
720
- if (e.length === 0) return "";
721
- const i = n ?? [...new Set(e.flatMap((a) => Object.keys(a.properties ?? {})))], l = r ? [...i, "geometry"] : i, o = e.map((a) => {
722
- const c = i.map(
723
- (g) => x(Oe(a, g), s)
724
- );
725
- return r && c.push(x(X(a.geometry), s)), c.join(s);
726
- });
727
- return [l.map((a) => x(a, s)).join(s), ...o].join(`
728
- `);
729
- }
730
- function Re(e, t) {
731
- const n = new Blob([e], { type: "text/csv;charset=utf-8;" });
732
- Y(n, t);
733
- }
734
- function rt({
735
- baseUrl: e,
736
- limit: t = 1e3,
737
- csvOptions: n
738
- }) {
739
- const [r, s] = d(!1), [i, l] = d(null);
740
- return { exportCsv: v(
741
- async (a, c = `${a}.csv`, g) => {
742
- s(!0), l(null);
743
- const f = [], u = Math.min(t, 1e3);
744
- let m = 0;
745
- try {
746
- for (; f.length < t; ) {
747
- const p = t - f.length, b = Math.min(u, p), y = await L(e, a, {
748
- limit: b,
749
- offset: m,
750
- cql2Filter: g
751
- });
752
- if (f.push(...y.features), m += y.features.length, y.features.length < b || y.numberMatched != null && m >= y.numberMatched) break;
753
- }
754
- const h = Fe(f, n);
755
- Re(h, c);
756
- } catch (h) {
757
- l(h instanceof Error ? h : new Error(String(h)));
758
- } finally {
759
- s(!1);
760
- }
761
- },
762
- [e, t, n]
763
- ), loading: r, error: i };
764
- }
765
- function st({
766
- baseUrl: e = "",
767
- limit: t = 1e5,
768
- converters: n
769
- }) {
770
- const [r, s] = d(!1), [i, l] = d(null), [o, a] = d(null);
771
- return { runExport: v(
772
- async (g, f, u, m, h) => {
773
- const p = h ?? e, b = n[f];
774
- if (!b) {
775
- a(new Error(`Unknown export format: ${f}`));
776
- return;
777
- }
778
- s(!0), l("Fetching features..."), a(null);
779
- const y = [], k = Math.min(t, 1e3);
780
- let w = 0;
781
- try {
782
- for (; y.length < t; ) {
783
- const P = t - y.length, q = Math.min(k, P), O = await L(p, g, {
784
- limit: q,
785
- offset: w,
786
- cql2Filter: m
787
- });
788
- y.push(...O.features), w += O.features.length;
789
- const F = O.numberMatched;
790
- if (F != null ? l(`Fetching features... (${y.length} of ${F})`) : l(`Fetching features... (${y.length})`), O.features.length < q || F != null && w >= F) break;
791
- }
792
- l("Converting...");
793
- const M = await b(y, g);
794
- Y(M.blob, u);
795
- } catch (M) {
796
- a(M instanceof Error ? M : new Error(String(M)));
797
- } finally {
798
- s(!1), l(null);
799
- }
800
- },
801
- [e, t, n]
802
- ), loading: r, progress: i, error: o };
803
- }
804
- const it = [
805
- { id: "csv", label: "CSV", extension: ".csv", description: "Comma-separated values" },
806
- { id: "geojson", label: "GeoJSON", extension: ".geojson", description: "GeoJSON format" },
807
- { id: "kml", label: "KML", extension: ".kml", description: "Google Earth" },
808
- { id: "shapefile", label: "Shapefile", extension: ".zip", description: "Esri Shapefile" },
809
- { id: "flatgeobuf", label: "FlatGeobuf", extension: ".fgb", description: "FlatGeobuf" },
810
- { id: "geopackage", label: "GeoPackage", extension: ".gpkg", description: "OGC GeoPackage" }
811
- ];
812
- function ot(e, t) {
813
- const [n, r] = d(null), [s, i] = d(!1), [l, o] = d(null);
814
- return N(() => {
815
- if (!e || !t) return;
816
- let a = !1;
817
- return i(!0), o(null), Le(e, t).then((c) => {
818
- a || r(c);
819
- }).catch((c) => {
820
- a || o(c instanceof Error ? c : new Error(String(c)));
821
- }).finally(() => {
822
- a || i(!1);
823
- }), () => {
824
- a = !0;
825
- };
826
- }, [e, t]), { collection: n, loading: s, error: l };
827
- }
828
- function at() {
829
- const [e, t] = d(null), [n, r] = d([]), [s, i] = d("km"), l = j(
830
- () => e ? Me(e, n, s) : null,
831
- [e, n, s]
832
- ), o = j(
833
- () => e ? $e(e, n) : null,
834
- [e, n]
835
- ), a = j(
836
- () => e ? Pe(n) : null,
837
- [e, n]
838
- ), c = v((u) => {
839
- t(u), r([]), u && i(ve(u));
840
- }, []), g = v((u) => {
841
- r((m) => [...m, u]);
842
- }, []), f = v(() => {
843
- r([]);
844
- }, []);
845
- return { mode: e, points: n, unit: s, measurement: l, geometryData: o, pointsData: a, setMode: c, setUnit: i, addPoint: g, clear: f };
846
- }
847
- function D(e) {
848
- return e.id != null ? `${e.layerId}:${e.id}` : `${e.layerId}:${JSON.stringify(e.properties)}`;
849
- }
850
- const z = 1e3;
851
- function lt() {
852
- const [e, t] = d(null), [n, r] = d(null), [s, i] = d([]), l = j(() => s.length === 0 ? null : {
853
- type: "FeatureCollection",
854
- features: s.map((u) => ({
855
- type: "Feature",
856
- properties: u.properties,
857
- geometry: u.geometry
858
- }))
859
- }, [s]), o = v((u) => {
860
- t(u);
861
- }, []), a = v((u) => {
862
- r(u), i([]);
863
- }, []), c = v((u) => {
864
- i((m) => {
865
- const h = new Set(m.map(D)), p = u.filter((y) => !h.has(D(y))), b = [...m, ...p];
866
- return b.length > z ? b.slice(0, z) : b;
867
- });
868
- }, []), g = v((u) => {
869
- i((m) => m.filter((h) => D(h) !== u));
870
- }, []), f = v(() => {
871
- i([]);
872
- }, []);
873
- return {
874
- mode: e,
875
- activeLayerId: n,
876
- features: s,
877
- highlightData: l,
878
- setMode: o,
879
- setActiveLayerId: a,
880
- addFeatures: c,
881
- removeFeature: g,
882
- clearFeatures: f
883
- };
884
- }
885
- function ct(e) {
886
- if (!e) return;
887
- const t = [], n = {};
888
- for (const [r, s] of Object.entries(e))
889
- s.visible !== !1 && (t.push(r), s.label && (n[r] = s.label));
890
- return { fields: t, labels: n };
891
- }
892
- async function ut(e) {
893
- try {
894
- const t = await fetch(e);
895
- if (!t.ok) return null;
896
- const n = await t.json();
897
- return n.sprite ? typeof n.sprite == "string" ? n.sprite : Array.isArray(n.sprite) && n.sprite.length > 0 ? n.sprite[0].url : null : null;
898
- } catch {
899
- return null;
900
- }
901
- }
902
- async function Ae(e) {
903
- try {
904
- const t = await fetch(`${e}.json`);
905
- if (!t.ok) return [];
906
- const n = await t.json();
907
- return Object.keys(n).sort();
908
- } catch {
909
- return [];
910
- }
911
- }
912
- async function ft(e, t) {
913
- const n = await fetch(e);
914
- if (!n.ok) throw new Error(`Failed to fetch style: ${n.status}`);
915
- const r = await n.json();
916
- if (!t.length) return r;
917
- const s = Array.isArray(r.sprite) ? r.sprite : r.sprite ? [{ id: "default", url: r.sprite }] : [], i = new Set(t.map((o) => o.id)), l = [
918
- ...s.filter((o) => !i.has(o.id)),
919
- ...t.map((o) => ({ id: o.id, url: o.url }))
920
- ];
921
- return { ...r, sprite: l };
922
- }
923
- async function Ge(e) {
924
- try {
925
- const t = await fetch(e);
926
- if (!t.ok) return [];
927
- const n = await t.json();
928
- return n.sprite ? typeof n.sprite == "string" ? [{ id: "default", url: n.sprite }] : Array.isArray(n.sprite) ? n.sprite : [] : [];
929
- } catch {
930
- return [];
931
- }
932
- }
933
- async function V(e) {
934
- const t = await Ae(e.url);
935
- return e.id === "default" ? t : t.map((n) => `${e.id}:${n}`);
936
- }
937
- async function gt(e, t = []) {
938
- const n = [];
939
- e && n.push(
940
- Ge(e).then(
941
- (s) => Promise.all(s.map(V)).then((i) => i.flat())
942
- )
943
- );
944
- for (const s of t)
945
- n.push(V(s));
946
- const r = await Promise.all(n);
947
- return [...new Set(r.flat())].sort();
948
- }
949
- function E(e, t) {
950
- return { op: "=", args: [{ property: e }, t] };
951
- }
952
- function ht(e, t) {
953
- return { op: "<>", args: [{ property: e }, t] };
954
- }
955
- function je(e, t) {
956
- return { op: ">", args: [{ property: e }, t] };
957
- }
958
- function H(e, t) {
959
- return { op: ">=", args: [{ property: e }, t] };
960
- }
961
- function Te(e, t) {
962
- return { op: "<", args: [{ property: e }, t] };
963
- }
964
- function Z(e, t) {
965
- return { op: "<=", args: [{ property: e }, t] };
966
- }
967
- function Ne(e, t, n) {
968
- return { op: "and", args: [H(e, t), Z(e, n)] };
969
- }
970
- function mt(e, t) {
971
- return { op: "like", args: [{ property: e }, t] };
972
- }
973
- function dt(e, t) {
974
- return { op: "in", args: [{ property: e }, t] };
975
- }
976
- function yt(e) {
977
- return { op: "isNull", args: [{ property: e }] };
978
- }
979
- function ee(...e) {
980
- const t = e.filter((n) => n != null);
981
- return t.length === 0 ? null : t.length === 1 ? t[0] : { op: "and", args: t };
982
- }
983
- function pt(...e) {
984
- const t = e.filter((n) => n != null);
985
- return t.length === 0 ? null : t.length === 1 ? t[0] : { op: "or", args: t };
986
- }
987
- function bt(e) {
988
- return { op: "not", args: [e] };
989
- }
990
- function Ue(e, t) {
991
- return { op: "t_after", args: [{ property: e }, t] };
992
- }
993
- function xe(e, t) {
994
- return { op: "t_before", args: [{ property: e }, t] };
995
- }
996
- function De(e, t, n) {
997
- const r = "date" in t ? t.date : t.timestamp, s = "date" in n ? n.date : n.timestamp;
998
- return { op: "t_during", args: [{ property: e }, { interval: [r, s] }] };
999
- }
1000
- function St(e, t) {
1001
- return { op: "s_intersects", args: [{ property: e }, t] };
1002
- }
1003
- function wt(e, t) {
1004
- return { op: "s_within", args: [{ property: e }, t] };
1005
- }
1006
- function Mt(e, t, n, r = "meters") {
1007
- return { op: "s_dwithin", args: [{ property: e }, t, n, r] };
1008
- }
1009
- function vt(e) {
1010
- const t = Object.entries(e).filter(([, n]) => n !== void 0 && n !== "").map(([n, r]) => E(n, r));
1011
- return ee(...t);
1012
- }
1013
- function $t(e, t) {
1014
- const n = new Map(t.map((s) => [s.property, s])), r = Object.entries(e).map(([s, i]) => {
1015
- if (i === void 0) return null;
1016
- const l = n.get(s);
1017
- if (typeof i == "string")
1018
- return i === "" ? null : (l == null ? void 0 : l.type) === "datetime" ? E(s, { timestamp: i }) : E(s, i);
1019
- if (typeof i == "number")
1020
- return E(s, i);
1021
- if (typeof i == "object") {
1022
- if ("start" in i || "end" in i) {
1023
- const { start: o, end: a } = i;
1024
- return o && a ? De(s, { timestamp: o }, { timestamp: a }) : o ? Ue(s, { timestamp: o }) : a ? xe(s, { timestamp: a }) : null;
1025
- }
1026
- if ("value" in i && "operator" in i) {
1027
- const { value: o, operator: a } = i;
1028
- if (o == null || String(o) === "") return null;
1029
- switch (a) {
1030
- case "gt":
1031
- return je(s, o);
1032
- case "lt":
1033
- return Te(s, o);
1034
- case "gte":
1035
- return H(s, o);
1036
- case "lte":
1037
- return Z(s, o);
1038
- default:
1039
- return E(s, o);
1040
- }
1041
- }
1042
- if ("min" in i && "max" in i) {
1043
- const { min: o, max: a } = i;
1044
- return o === void 0 || a === void 0 ? null : Ne(s, o, a);
1045
- }
1046
- }
1047
- return null;
1048
- });
1049
- return ee(...r);
1050
- }
1051
- function Pt(e) {
1052
- return JSON.stringify(e);
1053
- }
1054
- function te(e) {
1055
- const t = e.type, n = e.coordinates;
1056
- return t === "Point" ? [n] : t === "MultiPoint" || t === "LineString" ? n : t === "MultiLineString" || t === "Polygon" ? n.flat() : t === "MultiPolygon" ? n.flat(2) : t === "GeometryCollection" ? (e.geometries ?? []).flatMap(te) : [];
1057
- }
1058
- const G = 0.01;
1059
- function Ct(e) {
1060
- const t = te(e);
1061
- if (t.length === 0) return null;
1062
- let n = 1 / 0, r = 1 / 0, s = -1 / 0, i = -1 / 0;
1063
- for (const [l, o] of t)
1064
- l < n && (n = l), l > s && (s = l), o < r && (r = o), o > i && (i = o);
1065
- return n === s && r === i && (n -= G, r -= G, s += G, i += G), [n, r, s, i];
1066
- }
1067
- export {
1068
- ye as $,
1069
- yt as A,
1070
- mt as B,
1071
- Te as C,
1072
- it as D,
1073
- Z as E,
1074
- ht as F,
1075
- bt as G,
1076
- pt as H,
1077
- ct as I,
1078
- ft as J,
1079
- Mt as K,
1080
- St as L,
1081
- wt as M,
1082
- Pt as N,
1083
- Ue as O,
1084
- xe as P,
1085
- De as Q,
1086
- rt as R,
1087
- st as S,
1088
- at as T,
1089
- ot as U,
1090
- et as V,
1091
- nt as W,
1092
- tt as X,
1093
- lt as Y,
1094
- Ie as Z,
1095
- Je as _,
1096
- ee as a,
1097
- $e as a0,
1098
- Pe as a1,
1099
- we as a2,
1100
- Se as a3,
1101
- Me as a4,
1102
- ve as a5,
1103
- Re as a6,
1104
- Ae as a7,
1105
- ut as a8,
1106
- gt as a9,
1107
- D as aa,
1108
- Ct as b,
1109
- Ne as c,
1110
- Ze as d,
1111
- Y as e,
1112
- E as f,
1113
- Fe as g,
1114
- Le as h,
1115
- Ce as i,
1116
- ze as j,
1117
- Xe as k,
1118
- We as l,
1119
- Qe as m,
1120
- L as n,
1121
- ke as o,
1122
- Ve as p,
1123
- vt as q,
1124
- $t as r,
1125
- Ye as s,
1126
- Ke as t,
1127
- Ee as u,
1128
- He as v,
1129
- Be as w,
1130
- je as x,
1131
- H as y,
1132
- dt as z
1133
- };