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