@3clear/basegis 0.1.6 → 0.1.7
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/README.md +55 -17
- package/dist/assets.js +5 -5
- package/dist/basegis.js +3409 -2945
- package/dist/{basemap.config-Bs1PwVYt.js → basemap.config-CtXrS74D.js} +22 -17
- package/dist/layers.js +23 -23
- package/dist/methods.js +1007 -983
- package/package.json +1 -1
package/dist/methods.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { e as f, s as
|
|
2
|
-
import
|
|
3
|
-
function
|
|
1
|
+
import { e as f, s as g, v as Qe, m as re, n as pe, W as ne, R as F } from "./WindDataGrid-B1KZflZc.js";
|
|
2
|
+
import et from "axios";
|
|
3
|
+
function H(r = {}) {
|
|
4
4
|
return Array.isArray(r) || Array.isArray(r == null ? void 0 : r.features) ? { contours: r } : r || {};
|
|
5
5
|
}
|
|
6
|
-
function
|
|
7
|
-
const e =
|
|
6
|
+
function Se(r = {}) {
|
|
7
|
+
const e = H(r);
|
|
8
8
|
return ["contours", "isolines", "isoline", "lines", "data", "items", "centers"].some(
|
|
9
9
|
(t) => Object.prototype.hasOwnProperty.call(e, t)
|
|
10
10
|
);
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function tt(r) {
|
|
13
13
|
return !!(r && typeof r.getEngineType == "function" && typeof r.getMapInstance == "function" && typeof r.upsertContourLayer == "function" && typeof r.updateContourLayer == "function" && typeof r.showContourLayer == "function" && typeof r.hideContourLayer == "function" && typeof r.removeContourLayer == "function" && typeof r.clearContourLayer == "function" && typeof r.getContourLayerState == "function");
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function rt(r = {}) {
|
|
16
16
|
const { mapCore: e, baseGIS: t, ...n } = r;
|
|
17
17
|
return n;
|
|
18
18
|
}
|
|
19
|
-
class
|
|
19
|
+
class nt {
|
|
20
20
|
constructor(e = {}) {
|
|
21
|
-
const t =
|
|
21
|
+
const t = rt(e), n = t.contourLayerId || t.layerId || t.id || "contour-default";
|
|
22
22
|
this.options = {
|
|
23
23
|
layerId: n,
|
|
24
24
|
visible: t.visible ?? !0
|
|
@@ -41,7 +41,7 @@ class et {
|
|
|
41
41
|
}
|
|
42
42
|
mount(e) {
|
|
43
43
|
var t, n;
|
|
44
|
-
return
|
|
44
|
+
return tt(e) ? (this.baseGIS = e, g(
|
|
45
45
|
{ engineType: ((n = (t = this.baseGIS).getEngineType) == null ? void 0 : n.call(t)) || "unknown" },
|
|
46
46
|
"ContourLayerController mounted with BaseGIS."
|
|
47
47
|
)) : f(
|
|
@@ -51,7 +51,7 @@ class et {
|
|
|
51
51
|
}
|
|
52
52
|
resolveBaseGIS() {
|
|
53
53
|
var e, t;
|
|
54
|
-
return this.baseGIS ? (t = (e = this.baseGIS).getMapInstance) != null && t.call(e) ?
|
|
54
|
+
return this.baseGIS ? (t = (e = this.baseGIS).getMapInstance) != null && t.call(e) ? g(null, "BaseGIS is ready.") : f(
|
|
55
55
|
"Map instance is not ready. Please call mapCore.init() first.",
|
|
56
56
|
"NOT_INITIALIZED"
|
|
57
57
|
) : f("ContourLayerController has not been mounted.", "NOT_MOUNTED");
|
|
@@ -61,7 +61,7 @@ class et {
|
|
|
61
61
|
return typeof e == "string" && e ? e : (e == null ? void 0 : e.contourLayerId) || (e == null ? void 0 : e.layerId) || (e == null ? void 0 : e.id) || ((t = this.currentPayload) == null ? void 0 : t.layerId) || this.options.layerId;
|
|
62
62
|
}
|
|
63
63
|
buildPayload(e = {}) {
|
|
64
|
-
const t =
|
|
64
|
+
const t = H(e), n = this.getLayerId(t);
|
|
65
65
|
return {
|
|
66
66
|
...this.defaultPayload,
|
|
67
67
|
...t,
|
|
@@ -78,21 +78,21 @@ class et {
|
|
|
78
78
|
}, typeof t.visible == "boolean" && (this.visible = t.visible));
|
|
79
79
|
}
|
|
80
80
|
async load(e = {}, t = {}) {
|
|
81
|
-
var
|
|
81
|
+
var o;
|
|
82
82
|
const n = this.resolveBaseGIS();
|
|
83
83
|
if (!n.success)
|
|
84
84
|
return n;
|
|
85
85
|
const s = this.buildPayload({
|
|
86
|
-
...
|
|
87
|
-
...
|
|
86
|
+
...H(e),
|
|
87
|
+
...H(t)
|
|
88
88
|
});
|
|
89
|
-
if (!
|
|
89
|
+
if (!Se(s))
|
|
90
90
|
return f(
|
|
91
91
|
"Contour layer requires contours, isolines, lines, data, items or centers.",
|
|
92
92
|
"INVALID_CONTOUR_SOURCE"
|
|
93
93
|
);
|
|
94
94
|
const i = await this.baseGIS.upsertContourLayer(s);
|
|
95
|
-
return i.success && (this.currentPayload = s, this.visible = s.visible !== !1, this.layerType = ((
|
|
95
|
+
return i.success && (this.currentPayload = s, this.visible = s.visible !== !1, this.layerType = ((o = i == null ? void 0 : i.data) == null ? void 0 : o.layerType) || this.layerType, this.syncStateFromResult(i)), i;
|
|
96
96
|
}
|
|
97
97
|
upsert(e = {}, t = {}) {
|
|
98
98
|
return this.load(e, t);
|
|
@@ -104,9 +104,9 @@ class et {
|
|
|
104
104
|
return t;
|
|
105
105
|
const n = {
|
|
106
106
|
...this.currentPayload || this.defaultPayload,
|
|
107
|
-
...
|
|
107
|
+
...H(e)
|
|
108
108
|
};
|
|
109
|
-
if (!this.currentPayload && !
|
|
109
|
+
if (!this.currentPayload && !Se(n))
|
|
110
110
|
return f("Contour layer has not been loaded.", "NOT_LOADED");
|
|
111
111
|
const s = await this.baseGIS.updateContourLayer(n);
|
|
112
112
|
return s.success && (this.currentPayload = n, this.visible = n.visible !== !1, this.layerType = ((i = s == null ? void 0 : s.data) == null ? void 0 : i.layerType) || this.layerType, this.syncStateFromResult(s)), s;
|
|
@@ -177,7 +177,7 @@ class et {
|
|
|
177
177
|
labelCount: 0,
|
|
178
178
|
visible: !1,
|
|
179
179
|
destroyed: !0
|
|
180
|
-
},
|
|
180
|
+
}, g(null, "Contour layer controller destroyed (local state only).");
|
|
181
181
|
const n = this.baseGIS.removeContourLayer({
|
|
182
182
|
...e,
|
|
183
183
|
layerId: this.getLayerId(e)
|
|
@@ -193,35 +193,41 @@ class et {
|
|
|
193
193
|
labelCount: 0,
|
|
194
194
|
visible: !1,
|
|
195
195
|
destroyed: !0
|
|
196
|
-
}, n.success ?
|
|
196
|
+
}, n.success ? g(null, "Contour layer controller destroyed.") : n;
|
|
197
197
|
}
|
|
198
198
|
removeLayer(e = {}) {
|
|
199
199
|
return this.destroy(e);
|
|
200
200
|
}
|
|
201
201
|
getState() {
|
|
202
|
-
var e, t, n, s, i,
|
|
202
|
+
var e, t, n, s, i, o, a;
|
|
203
203
|
if ((t = (e = this.baseGIS) == null ? void 0 : e.getMapInstance) != null && t.call(e) && this.currentPayload) {
|
|
204
|
-
const
|
|
204
|
+
const l = (s = (n = this.baseGIS).getContourLayerState) == null ? void 0 : s.call(n, {
|
|
205
205
|
layerId: this.currentPayload.layerId || this.options.layerId
|
|
206
206
|
});
|
|
207
|
-
|
|
207
|
+
l != null && l.success && this.syncStateFromResult(l);
|
|
208
208
|
}
|
|
209
209
|
return {
|
|
210
210
|
mounted: !!this.baseGIS,
|
|
211
|
-
engineType: ((
|
|
211
|
+
engineType: ((o = (i = this.baseGIS) == null ? void 0 : i.getEngineType) == null ? void 0 : o.call(i)) || "unknown",
|
|
212
212
|
layerType: this.layerType,
|
|
213
213
|
visible: this.visible,
|
|
214
|
-
layerId: ((
|
|
214
|
+
layerId: ((a = this.currentPayload) == null ? void 0 : a.layerId) || this.options.layerId,
|
|
215
215
|
payload: this.currentPayload,
|
|
216
216
|
...this.currentState
|
|
217
217
|
};
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
|
-
function
|
|
220
|
+
function D(r, e = 0) {
|
|
221
221
|
const t = Number(r);
|
|
222
222
|
return Number.isFinite(t) ? t : e;
|
|
223
223
|
}
|
|
224
|
-
function
|
|
224
|
+
function ve(r) {
|
|
225
|
+
return r != null && String(r).trim() !== "";
|
|
226
|
+
}
|
|
227
|
+
function Pe(r, e, t = "") {
|
|
228
|
+
return ve(r) ? r : ve(e) ? e : t;
|
|
229
|
+
}
|
|
230
|
+
function Le(r, e = {
|
|
225
231
|
startLon: 73,
|
|
226
232
|
startLat: 18,
|
|
227
233
|
endLon: 135,
|
|
@@ -229,16 +235,16 @@ function Se(r, e = {
|
|
|
229
235
|
}) {
|
|
230
236
|
const t = r && typeof r == "object" ? r : e;
|
|
231
237
|
return {
|
|
232
|
-
startLon:
|
|
233
|
-
startLat:
|
|
234
|
-
endLon:
|
|
235
|
-
endLat:
|
|
238
|
+
startLon: D(t.startLon, e.startLon),
|
|
239
|
+
startLat: D(t.startLat, e.startLat),
|
|
240
|
+
endLon: D(t.endLon, e.endLon),
|
|
241
|
+
endLat: D(t.endLat, e.endLat)
|
|
236
242
|
};
|
|
237
243
|
}
|
|
238
|
-
function
|
|
244
|
+
function st(r) {
|
|
239
245
|
return !!(r && typeof r.getEngineType == "function" && typeof r.getMapInstance == "function" && typeof r.upsertGridLayer == "function" && typeof r.showGridLayer == "function" && typeof r.hideGridLayer == "function" && typeof r.removeGridLayer == "function");
|
|
240
246
|
}
|
|
241
|
-
function
|
|
247
|
+
function it(r = {}) {
|
|
242
248
|
return !!(r.tifUrl || r.imageUrl || r.grayImageUrl || r.imageGridData);
|
|
243
249
|
}
|
|
244
250
|
class $r {
|
|
@@ -246,18 +252,23 @@ class $r {
|
|
|
246
252
|
this.options = {
|
|
247
253
|
visible: e.visible ?? !0,
|
|
248
254
|
layerId: e.layerId || "grid-layer-default",
|
|
249
|
-
defaultArea:
|
|
250
|
-
gridTotal:
|
|
251
|
-
tileSize:
|
|
252
|
-
decimalPlaces:
|
|
255
|
+
defaultArea: Le(e.defaultArea),
|
|
256
|
+
gridTotal: D(e.gridTotal, 4),
|
|
257
|
+
tileSize: D(e.tileSize, 512),
|
|
258
|
+
decimalPlaces: D(e.decimalPlaces, 2),
|
|
253
259
|
showLabel: !!e.showLabel,
|
|
254
260
|
showProbe: !!e.showProbe,
|
|
255
|
-
colorize: e.colorize || null
|
|
261
|
+
colorize: e.colorize || null,
|
|
262
|
+
// 控制器级配置属于当前图层的显式覆盖;BaseGIS 全局默认由主入口另行注入。
|
|
263
|
+
sourceProjectionCrs: Pe(
|
|
264
|
+
e.sourceProjectionCrs,
|
|
265
|
+
e.sourceProjection
|
|
266
|
+
)
|
|
256
267
|
}, this.baseGIS = null, this.visible = this.options.visible, this.layerType = "unknown", this.currentPayload = null, (e.mapCore || e.baseGIS) && this.mount(e.mapCore || e.baseGIS);
|
|
257
268
|
}
|
|
258
269
|
mount(e) {
|
|
259
270
|
var t, n;
|
|
260
|
-
return
|
|
271
|
+
return st(e) ? (this.baseGIS = e, g(
|
|
261
272
|
{ engineType: ((n = (t = this.baseGIS).getEngineType) == null ? void 0 : n.call(t)) || "unknown" },
|
|
262
273
|
"GridLayerController mounted with BaseGIS."
|
|
263
274
|
)) : f(
|
|
@@ -267,7 +278,7 @@ class $r {
|
|
|
267
278
|
}
|
|
268
279
|
resolveBaseGIS() {
|
|
269
280
|
var e, t;
|
|
270
|
-
return this.baseGIS ? (t = (e = this.baseGIS).getMapInstance) != null && t.call(e) ?
|
|
281
|
+
return this.baseGIS ? (t = (e = this.baseGIS).getMapInstance) != null && t.call(e) ? g(null, "BaseGIS is ready.") : f(
|
|
271
282
|
"Map instance is not ready. Please call mapCore.init() first.",
|
|
272
283
|
"NOT_INITIALIZED"
|
|
273
284
|
) : f("GridLayerController has not been mounted.", "NOT_MOUNTED");
|
|
@@ -277,17 +288,26 @@ class $r {
|
|
|
277
288
|
return typeof e == "string" && e ? e : (e == null ? void 0 : e.layerId) || (e == null ? void 0 : e.gridLayerId) || ((t = this.currentPayload) == null ? void 0 : t.layerId) || this.options.layerId;
|
|
278
289
|
}
|
|
279
290
|
buildPayload(e = {}) {
|
|
280
|
-
const t = e.imageUrl || e.grayImageUrl || e.imageGridData, n = e.area ?
|
|
291
|
+
const t = e.imageUrl || e.grayImageUrl || e.imageGridData, n = e.area ? Le(e.area, this.options.defaultArea) : t ? this.options.defaultArea : void 0, s = Pe(
|
|
292
|
+
e.sourceProjectionCrs,
|
|
293
|
+
e.sourceProjection,
|
|
294
|
+
this.options.sourceProjectionCrs
|
|
295
|
+
);
|
|
281
296
|
return {
|
|
282
297
|
...e,
|
|
283
298
|
layerId: this.getLayerId(e),
|
|
284
299
|
area: n,
|
|
285
|
-
gridTotal:
|
|
286
|
-
tileSize:
|
|
287
|
-
decimalPlaces:
|
|
300
|
+
gridTotal: D(e.gridTotal, this.options.gridTotal),
|
|
301
|
+
tileSize: D(e.tileSize, this.options.tileSize),
|
|
302
|
+
decimalPlaces: D(e.decimalPlaces, this.options.decimalPlaces),
|
|
288
303
|
showLabel: typeof e.showLabel == "boolean" ? e.showLabel : this.options.showLabel,
|
|
289
304
|
showProbe: typeof e.showProbe == "boolean" ? e.showProbe : this.options.showProbe,
|
|
290
305
|
colorize: e.colorize || this.options.colorize,
|
|
306
|
+
...s ? {
|
|
307
|
+
sourceProjectionCrs: s,
|
|
308
|
+
// 兼容尚在使用 sourceProjection 的调用和适配层。
|
|
309
|
+
sourceProjection: s
|
|
310
|
+
} : {},
|
|
291
311
|
visible: typeof e.visible == "boolean" ? e.visible : this.visible
|
|
292
312
|
};
|
|
293
313
|
}
|
|
@@ -296,7 +316,7 @@ class $r {
|
|
|
296
316
|
const t = this.resolveBaseGIS();
|
|
297
317
|
if (!t.success)
|
|
298
318
|
return t;
|
|
299
|
-
if (!
|
|
319
|
+
if (!it(e))
|
|
300
320
|
return f(
|
|
301
321
|
"Grid layer requires tifUrl, imageUrl, grayImageUrl or imageGridData.",
|
|
302
322
|
"INVALID_GRID_SOURCE"
|
|
@@ -350,11 +370,11 @@ class $r {
|
|
|
350
370
|
}
|
|
351
371
|
destroy(e = {}) {
|
|
352
372
|
if (!this.resolveBaseGIS().success)
|
|
353
|
-
return this.currentPayload = null, this.layerType = "unknown",
|
|
373
|
+
return this.currentPayload = null, this.layerType = "unknown", g(null, "Grid layer controller destroyed (local state only).");
|
|
354
374
|
const n = this.baseGIS.removeGridLayer({
|
|
355
375
|
layerId: this.getLayerId(e)
|
|
356
376
|
});
|
|
357
|
-
return this.currentPayload = null, this.layerType = "unknown", n.success ?
|
|
377
|
+
return this.currentPayload = null, this.layerType = "unknown", n.success ? g(null, "Grid layer controller destroyed.") : n;
|
|
358
378
|
}
|
|
359
379
|
getState() {
|
|
360
380
|
var e, t, n;
|
|
@@ -368,14 +388,17 @@ class $r {
|
|
|
368
388
|
};
|
|
369
389
|
}
|
|
370
390
|
}
|
|
371
|
-
const V = /* @__PURE__ */ new Map(), nt = {
|
|
372
|
-
maxSize: 12
|
|
373
|
-
};
|
|
374
391
|
function E(r, e = 0) {
|
|
375
392
|
const t = Number(r);
|
|
376
393
|
return Number.isFinite(t) ? t : e;
|
|
377
394
|
}
|
|
378
|
-
function
|
|
395
|
+
function Ce(r) {
|
|
396
|
+
return r != null && String(r).trim() !== "";
|
|
397
|
+
}
|
|
398
|
+
function we(r, e, t = "") {
|
|
399
|
+
return Ce(r) ? r : Ce(e) ? e : t;
|
|
400
|
+
}
|
|
401
|
+
function Te(r) {
|
|
379
402
|
if (Array.isArray(r) && r.length >= 2) {
|
|
380
403
|
const e = Number(r[0]), t = Number(r[1]);
|
|
381
404
|
return Number.isFinite(e) && Number.isFinite(t) ? { lat: e, lng: t } : null;
|
|
@@ -386,7 +409,7 @@ function Le(r) {
|
|
|
386
409
|
}
|
|
387
410
|
return null;
|
|
388
411
|
}
|
|
389
|
-
function
|
|
412
|
+
function ce(r) {
|
|
390
413
|
if (!r) return null;
|
|
391
414
|
if (typeof r.getWest == "function" && typeof r.getSouth == "function" && typeof r.getEast == "function" && typeof r.getNorth == "function")
|
|
392
415
|
return {
|
|
@@ -403,7 +426,7 @@ function he(r) {
|
|
|
403
426
|
endLon: r[2],
|
|
404
427
|
endLat: r[3]
|
|
405
428
|
};
|
|
406
|
-
const e =
|
|
429
|
+
const e = Te(r[0]), t = Te(r[1]);
|
|
407
430
|
if (e && t)
|
|
408
431
|
return {
|
|
409
432
|
startLon: e.lng,
|
|
@@ -414,11 +437,11 @@ function he(r) {
|
|
|
414
437
|
}
|
|
415
438
|
if (r && typeof r == "object") {
|
|
416
439
|
if (r.area) {
|
|
417
|
-
const e =
|
|
440
|
+
const e = ce(r.area);
|
|
418
441
|
if (e) return e;
|
|
419
442
|
}
|
|
420
443
|
if (r._southWest && r._northEast)
|
|
421
|
-
return
|
|
444
|
+
return ce([r._southWest, r._northEast]);
|
|
422
445
|
if (["west", "south", "east", "north"].every(
|
|
423
446
|
(e) => Number.isFinite(Number(r[e]))
|
|
424
447
|
))
|
|
@@ -435,8 +458,8 @@ function he(r) {
|
|
|
435
458
|
}
|
|
436
459
|
return null;
|
|
437
460
|
}
|
|
438
|
-
function
|
|
439
|
-
const e =
|
|
461
|
+
function Ge(r) {
|
|
462
|
+
const e = ce(r);
|
|
440
463
|
if (!e) return null;
|
|
441
464
|
const t = Number(e.startLon), n = Number(e.startLat), s = Number(e.endLon), i = Number(e.endLat);
|
|
442
465
|
return [t, n, s, i].every(Number.isFinite) ? {
|
|
@@ -446,141 +469,33 @@ function z(r) {
|
|
|
446
469
|
endLat: Math.max(n, i)
|
|
447
470
|
} : null;
|
|
448
471
|
}
|
|
449
|
-
function
|
|
472
|
+
function he(r, e = {
|
|
450
473
|
startLon: 73,
|
|
451
474
|
startLat: 18,
|
|
452
475
|
endLon: 135,
|
|
453
476
|
endLat: 54
|
|
454
477
|
}) {
|
|
455
|
-
const t =
|
|
478
|
+
const t = Ge(e) || {
|
|
456
479
|
startLon: 73,
|
|
457
480
|
startLat: 18,
|
|
458
481
|
endLon: 135,
|
|
459
482
|
endLat: 54
|
|
460
|
-
}, n =
|
|
483
|
+
}, n = Ge(r) || t, s = E(n.startLon, t.startLon), i = E(n.startLat, t.startLat), o = E(n.endLon, t.endLon), a = E(n.endLat, t.endLat);
|
|
461
484
|
return {
|
|
462
|
-
startLon: Math.min(s,
|
|
463
|
-
startLat: Math.min(i,
|
|
464
|
-
endLon: Math.max(s,
|
|
465
|
-
endLat: Math.max(i,
|
|
466
|
-
};
|
|
467
|
-
}
|
|
468
|
-
function st() {
|
|
469
|
-
return typeof window < "u" && typeof document < "u";
|
|
470
|
-
}
|
|
471
|
-
function it(r) {
|
|
472
|
-
return `${r || ""}`.toUpperCase() === "EPSG:3857";
|
|
473
|
-
}
|
|
474
|
-
function J(r, e = "EPSG:4326") {
|
|
475
|
-
return `${r || e}`.toUpperCase();
|
|
476
|
-
}
|
|
477
|
-
function ge(r) {
|
|
478
|
-
const e = z(r);
|
|
479
|
-
return e ? [e.startLon, e.startLat, e.endLon, e.endLat].every((t) => Math.abs(Number(t)) <= 180) : !1;
|
|
480
|
-
}
|
|
481
|
-
function de(r, e) {
|
|
482
|
-
const t = 85.0511287798066, n = Math.min(Math.max(Number(r), -t), t), s = Number(e), i = 6378137, a = i * s * Math.PI / 180, o = i * Math.log(Math.tan(Math.PI / 4 + n * Math.PI / 360));
|
|
483
|
-
return { x: a, y: o };
|
|
484
|
-
}
|
|
485
|
-
function ve(r, e) {
|
|
486
|
-
const n = Number(r) / 6378137 * 180 / Math.PI;
|
|
487
|
-
return { lat: (2 * Math.atan(Math.exp(Number(e) / 6378137)) - Math.PI / 2) * 180 / Math.PI, lng: n };
|
|
488
|
-
}
|
|
489
|
-
function at(r) {
|
|
490
|
-
const e = z(r);
|
|
491
|
-
if (!e) return null;
|
|
492
|
-
const t = de(e.startLat, e.startLon), n = de(e.endLat, e.endLon);
|
|
493
|
-
return {
|
|
494
|
-
startLon: t.x,
|
|
495
|
-
startLat: t.y,
|
|
496
|
-
endLon: n.x,
|
|
497
|
-
endLat: n.y
|
|
498
|
-
};
|
|
499
|
-
}
|
|
500
|
-
function fe(r) {
|
|
501
|
-
const e = z(r);
|
|
502
|
-
if (!e) return null;
|
|
503
|
-
if (ge(e)) return e;
|
|
504
|
-
const t = ve(e.startLon, e.startLat), n = ve(e.endLon, e.endLat);
|
|
505
|
-
return {
|
|
506
|
-
startLon: t.lng,
|
|
507
|
-
startLat: t.lat,
|
|
508
|
-
endLon: n.lng,
|
|
509
|
-
endLat: n.lat
|
|
510
|
-
};
|
|
511
|
-
}
|
|
512
|
-
function ot(r) {
|
|
513
|
-
return new Promise((e, t) => {
|
|
514
|
-
const n = new Image();
|
|
515
|
-
n.crossOrigin = "anonymous", n.onload = () => e(n), n.onerror = () => t(new Error(`图片加载失败:${r}`)), n.src = r;
|
|
516
|
-
});
|
|
517
|
-
}
|
|
518
|
-
function lt(r, e, t) {
|
|
519
|
-
const n = z(t) || {};
|
|
520
|
-
return [
|
|
521
|
-
r,
|
|
522
|
-
e,
|
|
523
|
-
n.startLon,
|
|
524
|
-
n.startLat,
|
|
525
|
-
n.endLon,
|
|
526
|
-
n.endLat
|
|
527
|
-
].join("|");
|
|
528
|
-
}
|
|
529
|
-
function ut(r, e) {
|
|
530
|
-
if (!(!r || !e))
|
|
531
|
-
for (V.has(r) && V.delete(r), V.set(r, e); V.size > nt.maxSize; ) {
|
|
532
|
-
const t = V.keys().next().value;
|
|
533
|
-
V.delete(t);
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
async function ct(r, e) {
|
|
537
|
-
const t = z(e), n = fe(t);
|
|
538
|
-
if (!st() || !t || !n || ge(t))
|
|
539
|
-
return r;
|
|
540
|
-
const s = await ot(r), i = s.naturalWidth || s.width, a = s.naturalHeight || s.height, o = document.createElement("canvas");
|
|
541
|
-
o.width = i, o.height = a;
|
|
542
|
-
const u = o.getContext("2d", { willReadFrequently: !0 });
|
|
543
|
-
u.drawImage(s, 0, 0, i, a);
|
|
544
|
-
const l = u.getImageData(0, 0, i, a), c = document.createElement("canvas");
|
|
545
|
-
c.width = i, c.height = a;
|
|
546
|
-
const h = c.getContext("2d", { willReadFrequently: !0 }), y = h.createImageData(i, a), d = l.data, I = y.data, b = Math.min(Number(t.startLat), Number(t.endLat)), S = Math.max(Number(t.startLat), Number(t.endLat)), g = S - b;
|
|
547
|
-
if (!Number.isFinite(g) || g === 0)
|
|
548
|
-
return r;
|
|
549
|
-
for (let L = 0; L < a; L += 1) {
|
|
550
|
-
const p = n.endLat - (n.endLat - n.startLat) * L / Math.max(a - 1, 1), P = de(p, 0), T = Math.round((S - P.y) / g * (a - 1)), N = Math.min(Math.max(T, 0), a - 1) * i * 4, A = L * i * 4;
|
|
551
|
-
I.set(d.subarray(N, N + i * 4), A);
|
|
552
|
-
}
|
|
553
|
-
return h.putImageData(y, 0, 0), c.toDataURL("image/png");
|
|
554
|
-
}
|
|
555
|
-
async function Pe(r) {
|
|
556
|
-
const e = J(r == null ? void 0 : r.sourceProjection, ""), t = J(r == null ? void 0 : r.targetProjection);
|
|
557
|
-
if (!(r != null && r.imageUrl) || !it(e) || e === t)
|
|
558
|
-
return r;
|
|
559
|
-
const n = r.sourceArea || r.area, s = lt(r.imageUrl, `${e}_${t}`, n);
|
|
560
|
-
if (V.has(s))
|
|
561
|
-
return {
|
|
562
|
-
...r,
|
|
563
|
-
imageUrl: V.get(s),
|
|
564
|
-
area: X(fe(n) || r.area, r.area)
|
|
565
|
-
};
|
|
566
|
-
const i = fe(n) || r.area;
|
|
567
|
-
let a = null;
|
|
568
|
-
ge(n) ? a = at(n) : a = z(n);
|
|
569
|
-
const o = await ct(r.imageUrl, a);
|
|
570
|
-
return ut(s, o), {
|
|
571
|
-
...r,
|
|
572
|
-
imageUrl: o,
|
|
573
|
-
area: X(i, r.area)
|
|
485
|
+
startLon: Math.min(s, o),
|
|
486
|
+
startLat: Math.min(i, a),
|
|
487
|
+
endLon: Math.max(s, o),
|
|
488
|
+
endLat: Math.max(i, a)
|
|
574
489
|
};
|
|
575
490
|
}
|
|
576
|
-
function
|
|
491
|
+
function Me(r = {}, e = 0, t = void 0) {
|
|
577
492
|
return {
|
|
578
493
|
id: (r == null ? void 0 : r.id) || `image-${e}`,
|
|
579
494
|
name: (r == null ? void 0 : r.name) || `Image ${e + 1}`,
|
|
580
495
|
imageUrl: (r == null ? void 0 : r.imageUrl) || "",
|
|
581
496
|
tifUrl: (r == null ? void 0 : r.tifUrl) || "",
|
|
582
497
|
description: (r == null ? void 0 : r.description) || "",
|
|
583
|
-
area:
|
|
498
|
+
area: he(r == null ? void 0 : r.area, t),
|
|
584
499
|
opacity: r == null ? void 0 : r.opacity,
|
|
585
500
|
zIndex: r == null ? void 0 : r.zIndex,
|
|
586
501
|
isSplit: r == null ? void 0 : r.isSplit,
|
|
@@ -603,12 +518,11 @@ function we(r = {}, e = 0, t = void 0) {
|
|
|
603
518
|
gridTotal: r == null ? void 0 : r.gridTotal,
|
|
604
519
|
tileSize: r == null ? void 0 : r.tileSize,
|
|
605
520
|
decimalPlaces: r == null ? void 0 : r.decimalPlaces,
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
sourceArea: r == null ? void 0 : r.sourceArea
|
|
521
|
+
sourceProjectionCrs: r == null ? void 0 : r.sourceProjectionCrs,
|
|
522
|
+
sourceProjection: r == null ? void 0 : r.sourceProjection
|
|
609
523
|
};
|
|
610
524
|
}
|
|
611
|
-
function
|
|
525
|
+
function ot(r) {
|
|
612
526
|
return !!(r && typeof r.getEngineType == "function" && typeof r.getMapInstance == "function" && typeof r.upsertImageLayer == "function" && typeof r.showImageLayer == "function" && typeof r.hideImageLayer == "function" && typeof r.removeImageLayer == "function");
|
|
613
527
|
}
|
|
614
528
|
class kr {
|
|
@@ -617,12 +531,18 @@ class kr {
|
|
|
617
531
|
visible: e.visible ?? !0,
|
|
618
532
|
opacity: E(e.opacity, 0.85),
|
|
619
533
|
zIndex: E(e.zIndex, 650),
|
|
620
|
-
defaultArea:
|
|
534
|
+
defaultArea: he(e.defaultArea),
|
|
621
535
|
gridTotal: E(e.gridTotal, 4),
|
|
622
536
|
tileSize: E(e.tileSize, 512),
|
|
623
537
|
decimalPlaces: E(e.decimalPlaces, 2),
|
|
624
538
|
imageSourceType: e.imageSourceType || "color",
|
|
625
539
|
colorize: e.colorize || null,
|
|
540
|
+
// 控制器级配置属于当前图层的显式覆盖;不填时才由
|
|
541
|
+
// BaseGIS 默认值或 GeoTIFF GeoKey 决定。
|
|
542
|
+
sourceProjectionCrs: we(
|
|
543
|
+
e.sourceProjectionCrs,
|
|
544
|
+
e.sourceProjection
|
|
545
|
+
),
|
|
626
546
|
layerId: e.layerId || "image-layer-default"
|
|
627
547
|
}, this.baseGIS = null, this.items = [], this.activeIndex = -1, this.visible = this.options.visible, this.layerType = "unknown", this.currentPayload = null, this._operationRequestId = 0, (e.mapCore || e.baseGIS) && this.mount(e.mapCore || e.baseGIS);
|
|
628
548
|
}
|
|
@@ -632,7 +552,7 @@ class kr {
|
|
|
632
552
|
*/
|
|
633
553
|
mount(e) {
|
|
634
554
|
var t, n;
|
|
635
|
-
return
|
|
555
|
+
return ot(e) ? (this._operationRequestId += 1, this.baseGIS = e, g(
|
|
636
556
|
{ engineType: ((n = (t = this.baseGIS).getEngineType) == null ? void 0 : n.call(t)) || "unknown" },
|
|
637
557
|
"ImageLayerController mounted with BaseGIS."
|
|
638
558
|
)) : f(
|
|
@@ -642,7 +562,7 @@ class kr {
|
|
|
642
562
|
}
|
|
643
563
|
resolveBaseGIS() {
|
|
644
564
|
var e, t;
|
|
645
|
-
return this.baseGIS ? (t = (e = this.baseGIS).getMapInstance) != null && t.call(e) ?
|
|
565
|
+
return this.baseGIS ? (t = (e = this.baseGIS).getMapInstance) != null && t.call(e) ? g(null, "BaseGIS is ready.") : f(
|
|
646
566
|
"Map instance is not ready. Please call mapCore.init() first.",
|
|
647
567
|
"NOT_INITIALIZED"
|
|
648
568
|
) : f("ImageLayerController has not been mounted.", "NOT_MOUNTED");
|
|
@@ -650,20 +570,16 @@ class kr {
|
|
|
650
570
|
getLayerId(e = {}) {
|
|
651
571
|
return typeof e == "string" && e ? e : (e == null ? void 0 : e.layerId) || this.options.layerId;
|
|
652
572
|
}
|
|
653
|
-
/* 获取图片图层目标投影 */
|
|
654
|
-
getTargetProjectionFn(e = {}) {
|
|
655
|
-
var s, i, a, o, u, l, c, h, y;
|
|
656
|
-
if (e.targetProjection)
|
|
657
|
-
return J(e.targetProjection);
|
|
658
|
-
const t = (i = (s = this.baseGIS) == null ? void 0 : s.getMapInstance) == null ? void 0 : i.call(s), n = ((o = (a = t == null ? void 0 : t.options) == null ? void 0 : a.crs) == null ? void 0 : o.code) || ((c = (l = (u = t == null ? void 0 : t.options) == null ? void 0 : u.crs) == null ? void 0 : l.options) == null ? void 0 : c.code);
|
|
659
|
-
return n ? J(n) : (((y = (h = this.baseGIS) == null ? void 0 : h.getEngineType) == null ? void 0 : y.call(h)) === "leaflet", "EPSG:4326");
|
|
660
|
-
}
|
|
661
573
|
buildLayerPayload(e, t = {}) {
|
|
574
|
+
const s = we(
|
|
575
|
+
e.sourceProjectionCrs,
|
|
576
|
+
e.sourceProjection
|
|
577
|
+
) || this.options.sourceProjectionCrs;
|
|
662
578
|
return {
|
|
663
579
|
layerId: this.getLayerId(t),
|
|
664
580
|
imageUrl: e.imageUrl,
|
|
665
581
|
tifUrl: e.tifUrl,
|
|
666
|
-
area:
|
|
582
|
+
area: he(e.area, this.options.defaultArea),
|
|
667
583
|
isSplit: !!e.isSplit,
|
|
668
584
|
imageSourceType: e.imageSourceType || this.options.imageSourceType,
|
|
669
585
|
isGrayImage: e.isGrayImage,
|
|
@@ -677,6 +593,9 @@ class kr {
|
|
|
677
593
|
type: e.type,
|
|
678
594
|
colorStops: e.colorStops,
|
|
679
595
|
colors: e.colors,
|
|
596
|
+
sourceProjectionCrs: s,
|
|
597
|
+
// 暂时同步旧字段,保证尚未升级的引擎适配层和已有业务调用继续工作。
|
|
598
|
+
sourceProjection: s,
|
|
680
599
|
showProbe: e.showProbe,
|
|
681
600
|
enableProbe: e.enableProbe,
|
|
682
601
|
showMouseProbe: e.showMouseProbe,
|
|
@@ -696,7 +615,7 @@ class kr {
|
|
|
696
615
|
async load(e = [], t = {}) {
|
|
697
616
|
if (!Array.isArray(e) || e.length === 0)
|
|
698
617
|
return f("Image list is empty.", "INVALID_ITEMS");
|
|
699
|
-
const n = e.map((i,
|
|
618
|
+
const n = e.map((i, o) => Me(i, o, this.options.defaultArea)).filter((i) => i.imageUrl || i.tifUrl);
|
|
700
619
|
if (n.length === 0)
|
|
701
620
|
return f("No valid imageUrl or tifUrl found in items.", "INVALID_ITEMS");
|
|
702
621
|
this.items = n, typeof t.visible == "boolean" && (this.visible = t.visible);
|
|
@@ -708,26 +627,23 @@ class kr {
|
|
|
708
627
|
* target 可传索引数字,也可传图片 id。
|
|
709
628
|
*/
|
|
710
629
|
async switchTo(e) {
|
|
711
|
-
var l,
|
|
630
|
+
var l, u;
|
|
712
631
|
const t = this.resolveBaseGIS();
|
|
713
632
|
if (!t.success)
|
|
714
633
|
return t;
|
|
715
634
|
if (!Array.isArray(this.items) || this.items.length === 0)
|
|
716
635
|
return f("Image list has not been loaded.", "NOT_LOADED");
|
|
717
636
|
let n = -1;
|
|
718
|
-
if (typeof e == "number" ? n = e : typeof e == "string" && (n = this.items.findIndex((
|
|
637
|
+
if (typeof e == "number" ? n = e : typeof e == "string" && (n = this.items.findIndex((c) => c.id === e)), n < 0 || n >= this.items.length)
|
|
719
638
|
return f(`Invalid image target "${e}".`, "INVALID_TARGET");
|
|
720
|
-
const s = this.items[n], i = await
|
|
721
|
-
|
|
722
|
-
targetProjection: this.getTargetProjectionFn(s)
|
|
723
|
-
}), a = this.buildLayerPayload(i), o = ++this._operationRequestId, u = await this.baseGIS.upsertImageLayer(a);
|
|
724
|
-
return o !== this._operationRequestId || (l = u == null ? void 0 : u.data) != null && l.stale ? m(
|
|
639
|
+
const s = this.items[n], i = this.buildLayerPayload(s), o = ++this._operationRequestId, a = await this.baseGIS.upsertImageLayer(i);
|
|
640
|
+
return o !== this._operationRequestId || (l = a == null ? void 0 : a.data) != null && l.stale ? g(
|
|
725
641
|
{ stale: !0, ignored: !0 },
|
|
726
642
|
`Image switch to "${s.name}" was superseded.`
|
|
727
|
-
) :
|
|
728
|
-
{ activeIndex: n, activeItem:
|
|
729
|
-
`Image switched to "${
|
|
730
|
-
)) :
|
|
643
|
+
) : a.success ? (this.activeIndex = n, this.layerType = ((u = a == null ? void 0 : a.data) == null ? void 0 : u.layerType) || this.layerType, this.currentPayload = i, g(
|
|
644
|
+
{ activeIndex: n, activeItem: s },
|
|
645
|
+
`Image switched to "${s.name}".`
|
|
646
|
+
)) : a;
|
|
731
647
|
}
|
|
732
648
|
/**
|
|
733
649
|
* 更新当前图片图层数据。
|
|
@@ -736,15 +652,14 @@ class kr {
|
|
|
736
652
|
* 与 load(items) 不同,update(payload) 不要求维护图片数组,也不表达 next / prev 两态。
|
|
737
653
|
*/
|
|
738
654
|
async update(e = {}) {
|
|
739
|
-
var
|
|
655
|
+
var u, c;
|
|
740
656
|
const t = this.resolveBaseGIS();
|
|
741
657
|
if (!t.success)
|
|
742
658
|
return t;
|
|
743
|
-
const n = this.items[this.activeIndex] || {}, s = this.activeIndex >= 0 ? this.activeIndex : 0, i =
|
|
659
|
+
const n = this.items[this.activeIndex] || {}, s = this.activeIndex >= 0 ? this.activeIndex : 0, i = Me(
|
|
744
660
|
{
|
|
745
661
|
...n,
|
|
746
|
-
...e
|
|
747
|
-
targetProjection: this.getTargetProjectionFn(e)
|
|
662
|
+
...e
|
|
748
663
|
},
|
|
749
664
|
s,
|
|
750
665
|
this.options.defaultArea
|
|
@@ -752,16 +667,16 @@ class kr {
|
|
|
752
667
|
if (!i.imageUrl && !i.tifUrl)
|
|
753
668
|
return f("Image layer update requires imageUrl or tifUrl.", "INVALID_ITEM");
|
|
754
669
|
typeof e.visible == "boolean" && (this.visible = e.visible);
|
|
755
|
-
const
|
|
756
|
-
return
|
|
670
|
+
const o = this.buildLayerPayload(i, e), a = ++this._operationRequestId, l = await this.baseGIS.upsertImageLayer(o);
|
|
671
|
+
return a !== this._operationRequestId || (u = l == null ? void 0 : l.data) != null && u.stale ? g(
|
|
757
672
|
{ stale: !0, ignored: !0 },
|
|
758
673
|
`Image layer update "${i.name}" was superseded.`
|
|
759
|
-
) : l.success ? (this.items.length === 0 ? (this.items = [
|
|
674
|
+
) : l.success ? (this.items.length === 0 ? (this.items = [i], this.activeIndex = 0) : (this.items.splice(s, 1, i), this.activeIndex = s), this.layerType = ((c = l == null ? void 0 : l.data) == null ? void 0 : c.layerType) || this.layerType, this.currentPayload = o, g(
|
|
760
675
|
{
|
|
761
676
|
activeIndex: this.activeIndex,
|
|
762
|
-
activeItem:
|
|
677
|
+
activeItem: i
|
|
763
678
|
},
|
|
764
|
-
`Image layer updated: "${
|
|
679
|
+
`Image layer updated: "${i.name}".`
|
|
765
680
|
)) : l;
|
|
766
681
|
}
|
|
767
682
|
async next() {
|
|
@@ -800,11 +715,11 @@ class kr {
|
|
|
800
715
|
*/
|
|
801
716
|
destroy(e = {}) {
|
|
802
717
|
if (this._operationRequestId += 1, !this.resolveBaseGIS().success)
|
|
803
|
-
return this.items = [], this.activeIndex = -1, this.layerType = "unknown", this.currentPayload = null,
|
|
718
|
+
return this.items = [], this.activeIndex = -1, this.layerType = "unknown", this.currentPayload = null, g(null, "Image layer controller destroyed (local state only).");
|
|
804
719
|
const n = this.baseGIS.removeImageLayer({
|
|
805
720
|
layerId: this.getLayerId(e)
|
|
806
721
|
});
|
|
807
|
-
return this.items = [], this.activeIndex = -1, this.layerType = "unknown", this.currentPayload = null, n.success ?
|
|
722
|
+
return this.items = [], this.activeIndex = -1, this.layerType = "unknown", this.currentPayload = null, n.success ? g(null, "Image layer controller destroyed.") : n;
|
|
808
723
|
}
|
|
809
724
|
getState() {
|
|
810
725
|
var e, t;
|
|
@@ -820,79 +735,79 @@ class kr {
|
|
|
820
735
|
};
|
|
821
736
|
}
|
|
822
737
|
}
|
|
823
|
-
const
|
|
738
|
+
const at = {
|
|
824
739
|
color: "#2f80ff",
|
|
825
740
|
width: 3,
|
|
826
741
|
opacity: 1,
|
|
827
742
|
pattern: "solid",
|
|
828
743
|
dashLength: 12,
|
|
829
744
|
gapLength: 8
|
|
830
|
-
},
|
|
745
|
+
}, lt = {
|
|
831
746
|
enabled: !1,
|
|
832
747
|
mode: "reveal",
|
|
833
748
|
durationMs: 1e4,
|
|
834
749
|
autoplay: !0,
|
|
835
750
|
loop: !1
|
|
836
751
|
};
|
|
837
|
-
function
|
|
752
|
+
function Z(r, e) {
|
|
838
753
|
return Object.prototype.hasOwnProperty.call(r || {}, e);
|
|
839
754
|
}
|
|
840
|
-
function
|
|
755
|
+
function N(r) {
|
|
841
756
|
return !!(r && typeof r == "object" && !Array.isArray(r));
|
|
842
757
|
}
|
|
843
|
-
function
|
|
844
|
-
return Array.isArray(r) ? { lines: r } :
|
|
758
|
+
function W(r = {}) {
|
|
759
|
+
return Array.isArray(r) ? { lines: r } : N(r) ? r : {};
|
|
845
760
|
}
|
|
846
|
-
function
|
|
847
|
-
if (!
|
|
761
|
+
function ut(r, e) {
|
|
762
|
+
if (!N(e))
|
|
848
763
|
return e;
|
|
849
|
-
const t =
|
|
764
|
+
const t = N(r) ? r : {};
|
|
850
765
|
return {
|
|
851
766
|
...t,
|
|
852
767
|
...e,
|
|
853
|
-
flow:
|
|
854
|
-
...
|
|
768
|
+
flow: N(e.flow) ? {
|
|
769
|
+
...N(t.flow) ? t.flow : {},
|
|
855
770
|
...e.flow
|
|
856
771
|
} : e.flow ?? t.flow
|
|
857
772
|
};
|
|
858
773
|
}
|
|
859
|
-
function
|
|
860
|
-
if (!
|
|
861
|
-
return { ...
|
|
774
|
+
function We(r = {}, e = {}) {
|
|
775
|
+
if (!N(e))
|
|
776
|
+
return { ...N(r) ? r : {} };
|
|
862
777
|
const t = {
|
|
863
|
-
...
|
|
778
|
+
...N(r) ? r : {},
|
|
864
779
|
...e
|
|
865
780
|
};
|
|
866
|
-
return
|
|
781
|
+
return Z(e, "color") && (t.color = ut(r == null ? void 0 : r.color, e.color)), t.weight !== void 0 && !Z(e, "width") && (t.width = t.weight), t;
|
|
867
782
|
}
|
|
868
|
-
function
|
|
869
|
-
return
|
|
870
|
-
...
|
|
783
|
+
function Ye(r = {}, e = {}) {
|
|
784
|
+
return N(e) ? {
|
|
785
|
+
...N(r) ? r : {},
|
|
871
786
|
...e,
|
|
872
|
-
icon:
|
|
873
|
-
...
|
|
787
|
+
icon: N(e.icon) ? {
|
|
788
|
+
...N(r == null ? void 0 : r.icon) ? r.icon : {},
|
|
874
789
|
...e.icon
|
|
875
790
|
} : e.icon ?? (r == null ? void 0 : r.icon)
|
|
876
|
-
} : { ...
|
|
791
|
+
} : { ...N(r) ? r : {} };
|
|
877
792
|
}
|
|
878
|
-
function
|
|
879
|
-
const t =
|
|
793
|
+
function se(r = {}, e = {}) {
|
|
794
|
+
const t = W(r), n = W(e), s = {
|
|
880
795
|
...t,
|
|
881
796
|
...n
|
|
882
797
|
};
|
|
883
|
-
return s.style =
|
|
798
|
+
return s.style = We(t.style, Z(n, "style") ? n.style : {}), s.animation = Ye(
|
|
884
799
|
t.animation,
|
|
885
|
-
|
|
800
|
+
Z(n, "animation") ? n.animation : {}
|
|
886
801
|
), s;
|
|
887
802
|
}
|
|
888
|
-
function
|
|
803
|
+
function ct(r = {}) {
|
|
889
804
|
const { mapCore: e, baseGIS: t, ...n } = r;
|
|
890
805
|
return n;
|
|
891
806
|
}
|
|
892
|
-
function
|
|
807
|
+
function ht(r, e = "style.color") {
|
|
893
808
|
if (typeof r == "string" && r.trim())
|
|
894
809
|
return "";
|
|
895
|
-
if (!
|
|
810
|
+
if (!N(r) || r.type !== "gradient")
|
|
896
811
|
return `${e} must be a CSS color string or a gradient object.`;
|
|
897
812
|
if (!Array.isArray(r.stops) || r.stops.length < 2)
|
|
898
813
|
return `${e}.stops requires at least two gradient stops.`;
|
|
@@ -905,7 +820,7 @@ function gt(r, e = "style.color") {
|
|
|
905
820
|
return `${e}.stops[${n}].color must be a CSS color string.`;
|
|
906
821
|
t = i;
|
|
907
822
|
}
|
|
908
|
-
if (
|
|
823
|
+
if (N(r.flow) && r.flow.enabled === !0) {
|
|
909
824
|
const n = Number(r.flow.durationMs ?? 2400);
|
|
910
825
|
if (!Number.isFinite(n) || n <= 0)
|
|
911
826
|
return `${e}.flow.durationMs must be greater than 0.`;
|
|
@@ -914,17 +829,17 @@ function gt(r, e = "style.color") {
|
|
|
914
829
|
}
|
|
915
830
|
return "";
|
|
916
831
|
}
|
|
917
|
-
function
|
|
918
|
-
if (!
|
|
832
|
+
function He(r = {}, e = "style") {
|
|
833
|
+
if (!N(r))
|
|
919
834
|
return `${e} must be an object.`;
|
|
920
835
|
if (r.pattern !== void 0 && !["solid", "dashed"].includes(r.pattern))
|
|
921
836
|
return `${e}.pattern must be "solid" or "dashed".`;
|
|
922
837
|
for (const t of ["width", "dashLength", "gapLength"])
|
|
923
838
|
if (r[t] !== void 0 && (!Number.isFinite(Number(r[t])) || Number(r[t]) <= 0))
|
|
924
839
|
return `${e}.${t} must be greater than 0.`;
|
|
925
|
-
return r.opacity !== void 0 && (!Number.isFinite(Number(r.opacity)) || Number(r.opacity) < 0 || Number(r.opacity) > 1) ? `${e}.opacity must be between 0 and 1.` : r.color === void 0 ? "" :
|
|
840
|
+
return r.opacity !== void 0 && (!Number.isFinite(Number(r.opacity)) || Number(r.opacity) < 0 || Number(r.opacity) > 1) ? `${e}.opacity must be between 0 and 1.` : r.color === void 0 ? "" : ht(r.color, `${e}.color`);
|
|
926
841
|
}
|
|
927
|
-
function
|
|
842
|
+
function dt(r) {
|
|
928
843
|
if (!Array.isArray(r) || r.length === 0)
|
|
929
844
|
return "Line layer requires a non-empty lines array.";
|
|
930
845
|
const e = /* @__PURE__ */ new Set();
|
|
@@ -937,18 +852,18 @@ function mt(r) {
|
|
|
937
852
|
if (e.add(String(s)), !Array.isArray(n.positions) || n.positions.length < 2)
|
|
938
853
|
return `lines[${t}].positions requires at least two coordinates.`;
|
|
939
854
|
for (let i = 0; i < n.positions.length; i += 1) {
|
|
940
|
-
const
|
|
941
|
-
if (!Array.isArray(
|
|
855
|
+
const o = n.positions[i], a = Number(o == null ? void 0 : o[0]), l = Number(o == null ? void 0 : o[1]), u = (o == null ? void 0 : o.length) > 2 ? Number(o[2]) : 0;
|
|
856
|
+
if (!Array.isArray(o) || !Number.isFinite(a) || !Number.isFinite(l) || l < -90 || l > 90 || !Number.isFinite(u))
|
|
942
857
|
return `lines[${t}].positions[${i}] must be [longitude, latitude, height?].`;
|
|
943
858
|
}
|
|
944
859
|
if (n.style !== void 0) {
|
|
945
|
-
const i =
|
|
860
|
+
const i = He(n.style, `lines[${t}].style`);
|
|
946
861
|
if (i) return i;
|
|
947
862
|
}
|
|
948
863
|
}
|
|
949
864
|
return "";
|
|
950
865
|
}
|
|
951
|
-
function
|
|
866
|
+
function ft(r = {}, e = []) {
|
|
952
867
|
if (!(r != null && r.enabled))
|
|
953
868
|
return "";
|
|
954
869
|
if (r.mode !== void 0 && r.mode !== "reveal")
|
|
@@ -959,7 +874,7 @@ function bt(r = {}, e = []) {
|
|
|
959
874
|
if (!r.lineId || !e.some((n) => String(n.id) === String(r.lineId)))
|
|
960
875
|
return "animation.lineId must match an existing line id.";
|
|
961
876
|
if (r.icon !== void 0 && r.icon !== null) {
|
|
962
|
-
if (!
|
|
877
|
+
if (!N(r.icon))
|
|
963
878
|
return "animation.icon must be an object.";
|
|
964
879
|
if (r.icon.url !== void 0 && typeof r.icon.url != "string")
|
|
965
880
|
return "animation.icon.url must be a string.";
|
|
@@ -968,7 +883,7 @@ function bt(r = {}, e = []) {
|
|
|
968
883
|
}
|
|
969
884
|
return "";
|
|
970
885
|
}
|
|
971
|
-
function
|
|
886
|
+
function ie(r = {}) {
|
|
972
887
|
var e, t;
|
|
973
888
|
return !((e = r.animation) != null && e.enabled) || r.animation.lineId || ((t = r.lines) == null ? void 0 : t.length) !== 1 ? r : {
|
|
974
889
|
...r,
|
|
@@ -978,28 +893,28 @@ function se(r = {}) {
|
|
|
978
893
|
}
|
|
979
894
|
};
|
|
980
895
|
}
|
|
981
|
-
function
|
|
982
|
-
const e =
|
|
896
|
+
function Ne(r = {}) {
|
|
897
|
+
const e = dt(r.lines);
|
|
983
898
|
if (e) return e;
|
|
984
899
|
for (const n of r.lines) {
|
|
985
|
-
const s =
|
|
900
|
+
const s = Qe(n, r);
|
|
986
901
|
if (s) return s;
|
|
987
902
|
}
|
|
988
|
-
const t =
|
|
989
|
-
return t ||
|
|
903
|
+
const t = He(r.style);
|
|
904
|
+
return t || ft(r.animation, r.lines);
|
|
990
905
|
}
|
|
991
|
-
function
|
|
906
|
+
function yt(r) {
|
|
992
907
|
return !!(r && typeof r.getEngineType == "function" && typeof r.getMapInstance == "function" && typeof r.upsertLineLayer == "function" && typeof r.updateLineLayer == "function" && typeof r.showLineLayer == "function" && typeof r.hideLineLayer == "function" && typeof r.clearLineLayer == "function" && typeof r.removeLineLayer == "function" && typeof r.getLineLayerState == "function" && typeof r.playLineAnimation == "function" && typeof r.pauseLineAnimation == "function" && typeof r.restartLineAnimation == "function");
|
|
993
908
|
}
|
|
994
909
|
class Wr {
|
|
995
910
|
constructor(e = {}) {
|
|
996
|
-
const t =
|
|
997
|
-
this.baseGIS = null, this.visible = t.visible !== !1, this.layerType = "unknown", this.defaultPayload =
|
|
911
|
+
const t = ct(e), n = t.lineLayerId || t.layerId || t.id || "line-default";
|
|
912
|
+
this.baseGIS = null, this.visible = t.visible !== !1, this.layerType = "unknown", this.defaultPayload = ie({
|
|
998
913
|
...t,
|
|
999
914
|
layerId: n,
|
|
1000
915
|
visible: this.visible,
|
|
1001
|
-
style:
|
|
1002
|
-
animation:
|
|
916
|
+
style: We(at, t.style || {}),
|
|
917
|
+
animation: Ye(lt, t.animation || {})
|
|
1003
918
|
}), this.currentPayload = null, this.currentState = {
|
|
1004
919
|
layerId: n,
|
|
1005
920
|
visible: this.visible,
|
|
@@ -1014,7 +929,7 @@ class Wr {
|
|
|
1014
929
|
}
|
|
1015
930
|
mount(e) {
|
|
1016
931
|
var t;
|
|
1017
|
-
return
|
|
932
|
+
return yt(e) ? (this.baseGIS = e, g(
|
|
1018
933
|
{ engineType: ((t = e.getEngineType) == null ? void 0 : t.call(e)) || "unknown" },
|
|
1019
934
|
"LineLayerController mounted with BaseGIS."
|
|
1020
935
|
)) : f(
|
|
@@ -1024,7 +939,7 @@ class Wr {
|
|
|
1024
939
|
}
|
|
1025
940
|
resolveBaseGIS() {
|
|
1026
941
|
var e, t;
|
|
1027
|
-
return this.baseGIS ? (t = (e = this.baseGIS).getMapInstance) != null && t.call(e) ?
|
|
942
|
+
return this.baseGIS ? (t = (e = this.baseGIS).getMapInstance) != null && t.call(e) ? g(null, "BaseGIS is ready.") : f(
|
|
1028
943
|
"Map instance is not ready. Please call mapCore.init() first.",
|
|
1029
944
|
"NOT_INITIALIZED"
|
|
1030
945
|
) : f("LineLayerController has not been mounted.", "NOT_MOUNTED");
|
|
@@ -1034,44 +949,44 @@ class Wr {
|
|
|
1034
949
|
return typeof e == "string" || typeof e == "number" ? String(e) : e.lineLayerId || e.layerId || e.id || ((t = this.currentPayload) == null ? void 0 : t.layerId) || this.defaultPayload.layerId;
|
|
1035
950
|
}
|
|
1036
951
|
buildPayload(e = {}) {
|
|
1037
|
-
const t =
|
|
1038
|
-
return n.layerId = this.getLayerId(n), n.visible =
|
|
952
|
+
const t = W(e), n = se(this.defaultPayload, t);
|
|
953
|
+
return n.layerId = this.getLayerId(n), n.visible = Z(t, "visible") ? t.visible !== !1 : this.visible, ie(n);
|
|
1039
954
|
}
|
|
1040
955
|
syncStateFromResult(e) {
|
|
1041
|
-
var s, i,
|
|
956
|
+
var s, i, o, a;
|
|
1042
957
|
const t = ((s = e == null ? void 0 : e.data) == null ? void 0 : s.state) || (e == null ? void 0 : e.data);
|
|
1043
958
|
if (!t || typeof t != "object") return;
|
|
1044
|
-
const n = (
|
|
1045
|
-
this.layerType = ((
|
|
959
|
+
const n = (o = (i = this.baseGIS) == null ? void 0 : i.getEngineType) == null ? void 0 : o.call(i);
|
|
960
|
+
this.layerType = ((a = e == null ? void 0 : e.data) == null ? void 0 : a.layerType) || (this.currentPayload && ["cesium", "leaflet"].includes(n) ? `${n}-line-layer` : this.layerType), this.currentState = {
|
|
1046
961
|
...this.currentState,
|
|
1047
962
|
...t
|
|
1048
963
|
}, typeof t.visible == "boolean" && (this.visible = t.visible);
|
|
1049
964
|
}
|
|
1050
965
|
async load(e = {}, t = {}) {
|
|
1051
|
-
var
|
|
966
|
+
var a;
|
|
1052
967
|
const n = this.resolveBaseGIS();
|
|
1053
968
|
if (!n.success) return n;
|
|
1054
969
|
const s = this.buildPayload(
|
|
1055
|
-
|
|
1056
|
-
), i =
|
|
970
|
+
se(W(e), W(t))
|
|
971
|
+
), i = Ne(s);
|
|
1057
972
|
if (i)
|
|
1058
973
|
return f(i, "INVALID_LINE_LAYER_PAYLOAD");
|
|
1059
|
-
const
|
|
1060
|
-
return
|
|
974
|
+
const o = await this.baseGIS.upsertLineLayer(s);
|
|
975
|
+
return o.success && (this.currentPayload = s, this.visible = s.visible !== !1, this.layerType = ((a = o == null ? void 0 : o.data) == null ? void 0 : a.layerType) || this.layerType, this.syncStateFromResult(o)), o;
|
|
1061
976
|
}
|
|
1062
977
|
async update(e = {}) {
|
|
1063
|
-
var
|
|
978
|
+
var o;
|
|
1064
979
|
const t = this.resolveBaseGIS();
|
|
1065
980
|
if (!t.success) return t;
|
|
1066
981
|
if (!this.currentPayload)
|
|
1067
982
|
return f("Line layer has not been loaded.", "NOT_LOADED");
|
|
1068
|
-
const n =
|
|
1069
|
-
|
|
1070
|
-
), s =
|
|
983
|
+
const n = ie(
|
|
984
|
+
se(this.currentPayload, W(e))
|
|
985
|
+
), s = Ne(n);
|
|
1071
986
|
if (s)
|
|
1072
987
|
return f(s, "INVALID_LINE_LAYER_PAYLOAD");
|
|
1073
988
|
const i = await this.baseGIS.updateLineLayer(n);
|
|
1074
|
-
return i.success && (this.currentPayload = n, this.visible = n.visible !== !1, this.layerType = ((
|
|
989
|
+
return i.success && (this.currentPayload = n, this.visible = n.visible !== !1, this.layerType = ((o = i == null ? void 0 : i.data) == null ? void 0 : o.layerType) || this.layerType, this.syncStateFromResult(i)), i;
|
|
1075
990
|
}
|
|
1076
991
|
show(e = {}) {
|
|
1077
992
|
const t = this.resolveBaseGIS();
|
|
@@ -1168,22 +1083,22 @@ class Wr {
|
|
|
1168
1083
|
}
|
|
1169
1084
|
destroy(e = {}) {
|
|
1170
1085
|
if (!this.resolveBaseGIS().success)
|
|
1171
|
-
return this.resetLocalState(),
|
|
1086
|
+
return this.resetLocalState(), g(null, "Line layer controller destroyed (local state only).");
|
|
1172
1087
|
const n = this.baseGIS.removeLineLayer({
|
|
1173
1088
|
...e,
|
|
1174
1089
|
layerId: this.getLayerId(e)
|
|
1175
1090
|
});
|
|
1176
|
-
return this.resetLocalState(), n.success ?
|
|
1091
|
+
return this.resetLocalState(), n.success ? g(null, "Line layer controller destroyed.") : n;
|
|
1177
1092
|
}
|
|
1178
1093
|
getState() {
|
|
1179
|
-
var e, t, n, s, i,
|
|
1094
|
+
var e, t, n, s, i, o;
|
|
1180
1095
|
if ((t = (e = this.baseGIS) == null ? void 0 : e.getMapInstance) != null && t.call(e) && this.currentPayload) {
|
|
1181
|
-
const
|
|
1182
|
-
|
|
1096
|
+
const a = (s = (n = this.baseGIS).getLineLayerState) == null ? void 0 : s.call(n, { layerId: this.getLayerId() });
|
|
1097
|
+
a != null && a.success && this.syncStateFromResult(a);
|
|
1183
1098
|
}
|
|
1184
1099
|
return {
|
|
1185
1100
|
mounted: !!this.baseGIS,
|
|
1186
|
-
engineType: ((
|
|
1101
|
+
engineType: ((o = (i = this.baseGIS) == null ? void 0 : i.getEngineType) == null ? void 0 : o.call(i)) || "unknown",
|
|
1187
1102
|
layerType: this.layerType,
|
|
1188
1103
|
layerId: this.getLayerId(),
|
|
1189
1104
|
visible: this.visible,
|
|
@@ -1192,23 +1107,23 @@ class Wr {
|
|
|
1192
1107
|
};
|
|
1193
1108
|
}
|
|
1194
1109
|
}
|
|
1195
|
-
const
|
|
1110
|
+
const qe = ["all", "leader", "group"], Xe = ["auto", "view", "bounds"];
|
|
1196
1111
|
function M(r) {
|
|
1197
1112
|
return r == null ? "" : String(r).trim();
|
|
1198
1113
|
}
|
|
1199
|
-
function
|
|
1200
|
-
return
|
|
1114
|
+
function It(r) {
|
|
1115
|
+
return qe.includes(r) ? r : "all";
|
|
1201
1116
|
}
|
|
1202
|
-
function
|
|
1203
|
-
return
|
|
1117
|
+
function oe(r) {
|
|
1118
|
+
return Xe.includes(r) ? r : "auto";
|
|
1204
1119
|
}
|
|
1205
|
-
function
|
|
1120
|
+
function mt(r) {
|
|
1206
1121
|
return !!(r && typeof r.getMapInstance == "function" && typeof r.getEngineType == "function" && typeof r.getViewState == "function" && typeof r.onViewChange == "function" && typeof r.setInitialView == "function" && typeof r.fitViewBounds == "function" && typeof r.zoomIn == "function" && typeof r.zoomOut == "function" && typeof r.resetView == "function" && typeof r.resize == "function");
|
|
1207
1122
|
}
|
|
1208
|
-
function
|
|
1123
|
+
function Ee(r) {
|
|
1209
1124
|
return Number.isFinite(Number(r));
|
|
1210
1125
|
}
|
|
1211
|
-
function
|
|
1126
|
+
function Ae(r, e) {
|
|
1212
1127
|
const t = r.filter((s) => {
|
|
1213
1128
|
var i;
|
|
1214
1129
|
return !((i = s.result) != null && i.success);
|
|
@@ -1218,22 +1133,22 @@ function Me(r, e) {
|
|
|
1218
1133
|
failed: t.length,
|
|
1219
1134
|
results: r
|
|
1220
1135
|
};
|
|
1221
|
-
return t.length === 0 ?
|
|
1136
|
+
return t.length === 0 ? g(n, e) : f(`${e} ${t.length} map(s) failed.`, "MAP_VIEW_LINK_PARTIAL_FAILED", n);
|
|
1222
1137
|
}
|
|
1223
1138
|
class Yr {
|
|
1224
1139
|
constructor(e = {}) {
|
|
1225
|
-
this.enabled = e.enabled !== !1, this.realtime = e.realtime !== !1, this.mode =
|
|
1140
|
+
this.enabled = e.enabled !== !1, this.realtime = e.realtime !== !1, this.mode = It(e.mode), this.strategy = oe(e.strategy), this.leaderId = M(e.leaderId), this.activeMapId = M(e.activeMapId || e.leaderId), this.suppressionMs = Math.max(Number(e.suppressionMs) || 220, 32), this.endDelay = Math.max(Number(e.endDelay) || 80, 0);
|
|
1226
1141
|
const t = Number(e.syncInterval);
|
|
1227
1142
|
this.syncInterval = Number.isFinite(t) ? Math.max(t, 0) : 32, this.onStateChange = typeof e.onStateChange == "function" ? e.onStateChange : null, this.entries = /* @__PURE__ */ new Map(), this.suppressedUntil = /* @__PURE__ */ new Map(), this.pendingSourceId = "", this.frameHandle = null, this.frameType = "", this.lastSourceId = "", this.lastSyncedAt = 0, this.lastRealtimeSyncAt = 0, this.interactionSourceId = "", this.sourceReleaseTimer = null, this.destroyed = !1;
|
|
1228
1143
|
}
|
|
1229
1144
|
registerMap(e, t, n = {}) {
|
|
1230
|
-
var
|
|
1145
|
+
var l, u;
|
|
1231
1146
|
if (this.destroyed)
|
|
1232
1147
|
return f("MapViewLinkController has been destroyed.", "CONTROLLER_DESTROYED");
|
|
1233
1148
|
const s = M(e);
|
|
1234
1149
|
if (!s)
|
|
1235
1150
|
return f("Map id is required.", "INVALID_MAP_ID");
|
|
1236
|
-
if (!
|
|
1151
|
+
if (!mt(t))
|
|
1237
1152
|
return f("registerMap requires an initialized BaseGIS instance.", "INVALID_MAP_INSTANCE");
|
|
1238
1153
|
if (!t.getMapInstance())
|
|
1239
1154
|
return f(
|
|
@@ -1246,14 +1161,14 @@ class Yr {
|
|
|
1246
1161
|
`Map id "${s}" is already registered. Pass replace:true to replace it.`,
|
|
1247
1162
|
"MAP_ALREADY_REGISTERED"
|
|
1248
1163
|
);
|
|
1249
|
-
i && ((
|
|
1250
|
-
const
|
|
1164
|
+
i && ((l = i.offViewChange) == null || l.call(i), this.entries.delete(s));
|
|
1165
|
+
const o = {
|
|
1251
1166
|
id: s,
|
|
1252
1167
|
mapCore: t,
|
|
1253
1168
|
group: M(n.group) || "default",
|
|
1254
1169
|
enabled: n.enabled !== !1,
|
|
1255
1170
|
offViewChange: null
|
|
1256
|
-
},
|
|
1171
|
+
}, a = t.onViewChange({
|
|
1257
1172
|
endDelay: this.endDelay,
|
|
1258
1173
|
// Cesium 的 camera.changed 默认按变化比例触发,无法满足多屏平滑联动。
|
|
1259
1174
|
// 由适配器在用户交互期间逐帧检测,本控制器再通过 syncInterval 合并写入。
|
|
@@ -1262,10 +1177,10 @@ class Yr {
|
|
|
1262
1177
|
onChange: () => this.handleViewChange(s),
|
|
1263
1178
|
onEnd: () => this.handleViewEnd(s)
|
|
1264
1179
|
});
|
|
1265
|
-
return
|
|
1180
|
+
return a != null && a.success ? (o.offViewChange = (u = a.data) == null ? void 0 : u.off, this.entries.set(s, o), this.leaderId || (this.leaderId = s), this.activeMapId || (this.activeMapId = s), this.notifyStateChange("register"), g(
|
|
1266
1181
|
{ id: s, mapCore: t, state: this.getState() },
|
|
1267
1182
|
`Map "${s}" registered for view linking.`
|
|
1268
|
-
)) :
|
|
1183
|
+
)) : a || f(`Failed to listen to map "${s}".`, "LISTENER_FAILED");
|
|
1269
1184
|
}
|
|
1270
1185
|
unregisterMap(e) {
|
|
1271
1186
|
var i;
|
|
@@ -1274,7 +1189,7 @@ class Yr {
|
|
|
1274
1189
|
return f(`Map "${t}" is not registered.`, "MAP_NOT_REGISTERED");
|
|
1275
1190
|
(i = n.offViewChange) == null || i.call(n), this.entries.delete(t), this.suppressedUntil.delete(t);
|
|
1276
1191
|
const s = this.entries.keys().next().value || "";
|
|
1277
|
-
return this.leaderId === t && (this.leaderId = s), this.activeMapId === t && (this.activeMapId = this.leaderId || s), this.pendingSourceId === t && this.cancelPendingSync(), this.interactionSourceId === t && this.releaseInteractionSource(t, 0), this.notifyStateChange("unregister"),
|
|
1192
|
+
return this.leaderId === t && (this.leaderId = s), this.activeMapId === t && (this.activeMapId = this.leaderId || s), this.pendingSourceId === t && this.cancelPendingSync(), this.interactionSourceId === t && this.releaseInteractionSource(t, 0), this.notifyStateChange("unregister"), g(
|
|
1278
1193
|
{ id: t, mapCore: n.mapCore, state: this.getState() },
|
|
1279
1194
|
`Map "${t}" unregistered. The BaseGIS instance was not destroyed.`
|
|
1280
1195
|
);
|
|
@@ -1317,16 +1232,16 @@ class Yr {
|
|
|
1317
1232
|
}
|
|
1318
1233
|
setLeader(e) {
|
|
1319
1234
|
const t = M(e);
|
|
1320
|
-
return this.entries.has(t) ? (this.leaderId = t, this.activeMapId = t, this.notifyStateChange("leader"),
|
|
1235
|
+
return this.entries.has(t) ? (this.leaderId = t, this.activeMapId = t, this.notifyStateChange("leader"), g({ leaderId: t, mapCore: this.getMap(t) }, "View link leader updated.")) : f(`Map "${t}" is not registered.`, "MAP_NOT_REGISTERED");
|
|
1321
1236
|
}
|
|
1322
1237
|
setMode(e) {
|
|
1323
|
-
return
|
|
1238
|
+
return qe.includes(e) ? (this.mode = e, this.notifyStateChange("mode"), g({ mode: e }, "View link mode updated.")) : f("Link mode must be all, leader or group.", "INVALID_LINK_MODE");
|
|
1324
1239
|
}
|
|
1325
1240
|
setStrategy(e) {
|
|
1326
|
-
return
|
|
1241
|
+
return Xe.includes(e) ? (this.strategy = e, this.notifyStateChange("strategy"), g({ strategy: e }, "View link strategy updated.")) : f("Link strategy must be auto, view or bounds.", "INVALID_LINK_STRATEGY");
|
|
1327
1242
|
}
|
|
1328
1243
|
setEnabled(e) {
|
|
1329
|
-
return this.enabled = !!e, this.enabled || (this.cancelPendingSync(), this.releaseInteractionSource("", 0)), this.notifyStateChange("enabled"),
|
|
1244
|
+
return this.enabled = !!e, this.enabled || (this.cancelPendingSync(), this.releaseInteractionSource("", 0)), this.notifyStateChange("enabled"), g({ enabled: this.enabled }, `View linking ${this.enabled ? "enabled" : "disabled"}.`);
|
|
1330
1245
|
}
|
|
1331
1246
|
pause() {
|
|
1332
1247
|
return this.setEnabled(!1);
|
|
@@ -1335,15 +1250,15 @@ class Yr {
|
|
|
1335
1250
|
return this.setEnabled(!0);
|
|
1336
1251
|
}
|
|
1337
1252
|
setRealtime(e) {
|
|
1338
|
-
return this.realtime = !!e, this.realtime || this.cancelPendingSync(), this.notifyStateChange("realtime"),
|
|
1253
|
+
return this.realtime = !!e, this.realtime || this.cancelPendingSync(), this.notifyStateChange("realtime"), g({ realtime: this.realtime }, "Realtime view linking updated.");
|
|
1339
1254
|
}
|
|
1340
1255
|
setMapGroup(e, t) {
|
|
1341
1256
|
const n = this.entries.get(M(e));
|
|
1342
|
-
return n ? (n.group = M(t) || "default", this.notifyStateChange("group"),
|
|
1257
|
+
return n ? (n.group = M(t) || "default", this.notifyStateChange("group"), g({ id: n.id, group: n.group }, "Map view link group updated.")) : f(`Map "${M(e)}" is not registered.`, "MAP_NOT_REGISTERED");
|
|
1343
1258
|
}
|
|
1344
1259
|
setMapEnabled(e, t) {
|
|
1345
1260
|
const n = this.entries.get(M(e));
|
|
1346
|
-
return n ? (n.enabled = !!t, this.notifyStateChange("map-enabled"),
|
|
1261
|
+
return n ? (n.enabled = !!t, this.notifyStateChange("map-enabled"), g({ id: n.id, enabled: n.enabled }, "Map view linking state updated.")) : f(`Map "${M(e)}" is not registered.`, "MAP_NOT_REGISTERED");
|
|
1347
1262
|
}
|
|
1348
1263
|
handleViewStart(e) {
|
|
1349
1264
|
this.canUseAsSource(e) && (this.clearSourceReleaseTimer(), this.interactionSourceId = e, this.activeMapId = e);
|
|
@@ -1402,25 +1317,25 @@ class Yr {
|
|
|
1402
1317
|
return f(`Map "${n}" is not registered.`, "MAP_NOT_REGISTERED");
|
|
1403
1318
|
if (!t.force && !this.canUseAsSource(n))
|
|
1404
1319
|
return f(`Map "${n}" cannot currently control linked maps.`, "LINK_SOURCE_DISABLED");
|
|
1405
|
-
const i = this.resolveTargets(s),
|
|
1320
|
+
const i = this.resolveTargets(s), o = oe(t.strategy || this.strategy), a = ((y = (h = s.mapCore).getEngineType) == null ? void 0 : y.call(h)) || "unknown", l = o === "bounds" || o === "auto" && i.some((d) => {
|
|
1406
1321
|
var I, b;
|
|
1407
|
-
return (((b = (I = d.mapCore).getEngineType) == null ? void 0 : b.call(I)) || "unknown") !==
|
|
1408
|
-
}),
|
|
1409
|
-
if (!(
|
|
1410
|
-
return
|
|
1322
|
+
return (((b = (I = d.mapCore).getEngineType) == null ? void 0 : b.call(I)) || "unknown") !== a;
|
|
1323
|
+
}), u = s.mapCore.getViewState({ includeBounds: l });
|
|
1324
|
+
if (!(u != null && u.success) || !u.data)
|
|
1325
|
+
return u || f(`Map "${n}" view state is unavailable.`, "VIEW_STATE_FAILED");
|
|
1411
1326
|
const c = i.map((d) => ({
|
|
1412
1327
|
id: d.id,
|
|
1413
|
-
result: this.applyViewState(d,
|
|
1328
|
+
result: this.applyViewState(d, u.data, t)
|
|
1414
1329
|
}));
|
|
1415
|
-
return this.lastSourceId = n, this.lastSyncedAt = Date.now(),
|
|
1330
|
+
return this.lastSourceId = n, this.lastSyncedAt = Date.now(), Ae(c, `View synchronized from map "${n}".`);
|
|
1416
1331
|
}
|
|
1417
1332
|
applyViewState(e, t, n = {}) {
|
|
1418
|
-
var
|
|
1419
|
-
const s =
|
|
1420
|
-
return this.suppressedUntil.set(e.id, Date.now() + this.suppressionMs), s !== "bounds" && Array.isArray(t.center) && (
|
|
1421
|
-
center:
|
|
1422
|
-
...
|
|
1423
|
-
...
|
|
1333
|
+
var u, c;
|
|
1334
|
+
const s = oe(n.strategy || this.strategy), i = ((c = (u = e.mapCore).getEngineType) == null ? void 0 : c.call(u)) || "unknown", o = t.engineType === i, a = o && i === "leaflet" && Ee(t.zoom), l = o && i === "cesium" && Ee(t.height);
|
|
1335
|
+
return this.suppressedUntil.set(e.id, Date.now() + this.suppressionMs), s !== "bounds" && Array.isArray(t.center) && (a || l) ? e.mapCore.setInitialView({
|
|
1336
|
+
center: l && Array.isArray(t.cameraPosition) ? t.cameraPosition : t.center,
|
|
1337
|
+
...a ? { zoom: Number(t.zoom) } : {},
|
|
1338
|
+
...l ? {
|
|
1424
1339
|
height: Number(t.height),
|
|
1425
1340
|
heading: t.heading,
|
|
1426
1341
|
pitch: t.pitch,
|
|
@@ -1478,7 +1393,7 @@ class Yr {
|
|
|
1478
1393
|
id: s.id,
|
|
1479
1394
|
result: e(s)
|
|
1480
1395
|
}));
|
|
1481
|
-
return
|
|
1396
|
+
return Ae(n, t);
|
|
1482
1397
|
}
|
|
1483
1398
|
getState() {
|
|
1484
1399
|
return {
|
|
@@ -1515,25 +1430,25 @@ class Yr {
|
|
|
1515
1430
|
return this.cancelPendingSync(), this.releaseInteractionSource("", 0), this.entries.forEach((e) => {
|
|
1516
1431
|
var t;
|
|
1517
1432
|
return (t = e.offViewChange) == null ? void 0 : t.call(e);
|
|
1518
|
-
}), this.entries.clear(), this.suppressedUntil.clear(), this.leaderId = "", this.activeMapId = "", this.lastSourceId = "", this.lastSyncedAt = 0, this.lastRealtimeSyncAt = 0, this.notifyStateChange("clear"),
|
|
1433
|
+
}), this.entries.clear(), this.suppressedUntil.clear(), this.leaderId = "", this.activeMapId = "", this.lastSourceId = "", this.lastSyncedAt = 0, this.lastRealtimeSyncAt = 0, this.notifyStateChange("clear"), g(null, "All maps unregistered. BaseGIS instances were not destroyed.");
|
|
1519
1434
|
}
|
|
1520
1435
|
destroy() {
|
|
1521
|
-
return this.destroyed ?
|
|
1436
|
+
return this.destroyed ? g(null, "MapViewLinkController is already destroyed.") : (this.clear(), this.destroyed = !0, this.onStateChange = null, g(null, "MapViewLinkController destroyed. BaseGIS instances were not destroyed."));
|
|
1522
1437
|
}
|
|
1523
1438
|
}
|
|
1524
|
-
function
|
|
1439
|
+
function gt(r = {}) {
|
|
1525
1440
|
const { mapCore: e, baseGIS: t, ...n } = r || {};
|
|
1526
1441
|
return n;
|
|
1527
1442
|
}
|
|
1528
|
-
function
|
|
1443
|
+
function bt(r, e) {
|
|
1529
1444
|
return Object.prototype.hasOwnProperty.call(r || {}, e);
|
|
1530
1445
|
}
|
|
1531
|
-
function
|
|
1446
|
+
function pt(r) {
|
|
1532
1447
|
return !!(r && typeof r.getEngineType == "function" && typeof r.getMapInstance == "function" && typeof r.upsertTyphoonPathLayer == "function" && typeof r.updateTyphoonPathLayer == "function" && typeof r.showTyphoonPathLayer == "function" && typeof r.hideTyphoonPathLayer == "function" && typeof r.clearTyphoonPathLayer == "function" && typeof r.removeTyphoonPathLayer == "function" && typeof r.getTyphoonPathLayerState == "function" && typeof r.playTyphoonPath == "function" && typeof r.pauseTyphoonPath == "function" && typeof r.restartTyphoonPath == "function" && typeof r.seekTyphoonPath == "function" && typeof r.flyToTyphoonPath == "function");
|
|
1533
1448
|
}
|
|
1534
1449
|
class Hr {
|
|
1535
1450
|
constructor(e = {}) {
|
|
1536
|
-
const t =
|
|
1451
|
+
const t = gt(e), n = t.typhoonPathLayerId || t.layerId || t.id || "typhoon-path-default";
|
|
1537
1452
|
this.baseGIS = null, this.visible = t.visible !== !1, this.layerType = "unknown", this.defaultPayload = {
|
|
1538
1453
|
...t,
|
|
1539
1454
|
layerId: n,
|
|
@@ -1554,7 +1469,7 @@ class Hr {
|
|
|
1554
1469
|
}
|
|
1555
1470
|
mount(e) {
|
|
1556
1471
|
var t;
|
|
1557
|
-
return
|
|
1472
|
+
return pt(e) ? (this.baseGIS = e, g(
|
|
1558
1473
|
{ engineType: ((t = e.getEngineType) == null ? void 0 : t.call(e)) || "unknown" },
|
|
1559
1474
|
"TyphoonPathController mounted with BaseGIS."
|
|
1560
1475
|
)) : f(
|
|
@@ -1564,7 +1479,7 @@ class Hr {
|
|
|
1564
1479
|
}
|
|
1565
1480
|
resolveBaseGIS() {
|
|
1566
1481
|
var e, t;
|
|
1567
|
-
return this.baseGIS ? (t = (e = this.baseGIS).getMapInstance) != null && t.call(e) ?
|
|
1482
|
+
return this.baseGIS ? (t = (e = this.baseGIS).getMapInstance) != null && t.call(e) ? g(null, "BaseGIS is ready.") : f(
|
|
1568
1483
|
"Map instance is not ready. Please call mapCore.init() first.",
|
|
1569
1484
|
"NOT_INITIALIZED"
|
|
1570
1485
|
) : f("TyphoonPathController has not been mounted.", "NOT_MOUNTED");
|
|
@@ -1574,15 +1489,15 @@ class Hr {
|
|
|
1574
1489
|
return String(typeof e == "string" || typeof e == "number" ? e : e.typhoonPathLayerId || e.layerId || e.id || ((t = this.currentPayload) == null ? void 0 : t.layerId) || this.defaultPayload.layerId);
|
|
1575
1490
|
}
|
|
1576
1491
|
buildPayload(e = {}, t = {}) {
|
|
1577
|
-
const n =
|
|
1578
|
-
return s.layerId = this.getLayerId(s), s.visible =
|
|
1492
|
+
const n = re(e, t), s = re(this.defaultPayload, n);
|
|
1493
|
+
return s.layerId = this.getLayerId(s), s.visible = bt(n, "visible") ? n.visible !== !1 : this.visible, pe(s);
|
|
1579
1494
|
}
|
|
1580
1495
|
syncStateFromResult(e) {
|
|
1581
|
-
var s, i,
|
|
1496
|
+
var s, i, o, a;
|
|
1582
1497
|
const t = ((s = e == null ? void 0 : e.data) == null ? void 0 : s.state) || (e == null ? void 0 : e.data);
|
|
1583
1498
|
if (!t || typeof t != "object") return;
|
|
1584
|
-
const n = (
|
|
1585
|
-
this.layerType = ((
|
|
1499
|
+
const n = (o = (i = this.baseGIS) == null ? void 0 : i.getEngineType) == null ? void 0 : o.call(i);
|
|
1500
|
+
this.layerType = ((a = e == null ? void 0 : e.data) == null ? void 0 : a.layerType) || (this.currentPayload && ["cesium", "leaflet"].includes(n) ? `${n}-typhoon-path-layer` : this.layerType), this.currentState = {
|
|
1586
1501
|
...this.currentState,
|
|
1587
1502
|
...t
|
|
1588
1503
|
}, typeof t.visible == "boolean" && (this.visible = t.visible);
|
|
@@ -1593,8 +1508,8 @@ class Hr {
|
|
|
1593
1508
|
let s;
|
|
1594
1509
|
try {
|
|
1595
1510
|
s = this.buildPayload(e, t);
|
|
1596
|
-
} catch (
|
|
1597
|
-
return f((
|
|
1511
|
+
} catch (o) {
|
|
1512
|
+
return f((o == null ? void 0 : o.message) || "Invalid typhoon path payload.", "INVALID_TYPHOON_PATH_PAYLOAD");
|
|
1598
1513
|
}
|
|
1599
1514
|
const i = await this.baseGIS.upsertTyphoonPathLayer(s);
|
|
1600
1515
|
return i.success && (this.currentPayload = s, this.visible = s.visible !== !1, this.syncStateFromResult(i)), i;
|
|
@@ -1606,8 +1521,8 @@ class Hr {
|
|
|
1606
1521
|
return f("Typhoon path has not been loaded.", "NOT_LOADED");
|
|
1607
1522
|
let n;
|
|
1608
1523
|
try {
|
|
1609
|
-
n =
|
|
1610
|
-
|
|
1524
|
+
n = pe(
|
|
1525
|
+
re(this.currentPayload, e)
|
|
1611
1526
|
);
|
|
1612
1527
|
} catch (i) {
|
|
1613
1528
|
return f((i == null ? void 0 : i.message) || "Invalid typhoon path payload.", "INVALID_TYPHOON_PATH_PAYLOAD");
|
|
@@ -1668,7 +1583,7 @@ class Hr {
|
|
|
1668
1583
|
}, this.syncStateFromResult(n)), n;
|
|
1669
1584
|
}
|
|
1670
1585
|
seek(e) {
|
|
1671
|
-
var i,
|
|
1586
|
+
var i, o, a;
|
|
1672
1587
|
const t = this.resolveBaseGIS();
|
|
1673
1588
|
if (!t.success) return t;
|
|
1674
1589
|
const n = typeof e == "number" ? { index: e } : e || {}, s = this.baseGIS.seekTyphoonPath({
|
|
@@ -1676,10 +1591,10 @@ class Hr {
|
|
|
1676
1591
|
layerId: this.getLayerId(n)
|
|
1677
1592
|
});
|
|
1678
1593
|
if (s.success && this.currentPayload) {
|
|
1679
|
-
const
|
|
1680
|
-
Number.isInteger(
|
|
1594
|
+
const l = ((o = (i = s == null ? void 0 : s.data) == null ? void 0 : i.state) == null ? void 0 : o.currentIndex) ?? ((a = s == null ? void 0 : s.data) == null ? void 0 : a.currentIndex);
|
|
1595
|
+
Number.isInteger(l) && (this.currentPayload = {
|
|
1681
1596
|
...this.currentPayload,
|
|
1682
|
-
playback: { ...this.currentPayload.playback, currentIndex:
|
|
1597
|
+
playback: { ...this.currentPayload.playback, currentIndex: l }
|
|
1683
1598
|
}), this.syncStateFromResult(s);
|
|
1684
1599
|
}
|
|
1685
1600
|
return s;
|
|
@@ -1714,22 +1629,22 @@ class Hr {
|
|
|
1714
1629
|
}
|
|
1715
1630
|
destroy(e = {}) {
|
|
1716
1631
|
if (!this.resolveBaseGIS().success)
|
|
1717
|
-
return this.resetLocalState(),
|
|
1632
|
+
return this.resetLocalState(), g(null, "Typhoon path controller destroyed (local state only).");
|
|
1718
1633
|
const n = this.baseGIS.removeTyphoonPathLayer({
|
|
1719
1634
|
...e,
|
|
1720
1635
|
layerId: this.getLayerId(e)
|
|
1721
1636
|
});
|
|
1722
|
-
return this.resetLocalState(), n.success ?
|
|
1637
|
+
return this.resetLocalState(), n.success ? g(null, "Typhoon path controller destroyed.") : n;
|
|
1723
1638
|
}
|
|
1724
1639
|
getState() {
|
|
1725
|
-
var e, t, n, s, i,
|
|
1640
|
+
var e, t, n, s, i, o;
|
|
1726
1641
|
if ((t = (e = this.baseGIS) == null ? void 0 : e.getMapInstance) != null && t.call(e) && this.currentPayload) {
|
|
1727
|
-
const
|
|
1728
|
-
|
|
1642
|
+
const a = (s = (n = this.baseGIS).getTyphoonPathLayerState) == null ? void 0 : s.call(n, { layerId: this.getLayerId() });
|
|
1643
|
+
a != null && a.success && this.syncStateFromResult(a);
|
|
1729
1644
|
}
|
|
1730
1645
|
return {
|
|
1731
1646
|
mounted: !!this.baseGIS,
|
|
1732
|
-
engineType: ((
|
|
1647
|
+
engineType: ((o = (i = this.baseGIS) == null ? void 0 : i.getEngineType) == null ? void 0 : o.call(i)) || "unknown",
|
|
1733
1648
|
layerType: this.layerType,
|
|
1734
1649
|
layerId: this.getLayerId(),
|
|
1735
1650
|
visible: this.visible,
|
|
@@ -1738,25 +1653,25 @@ class Hr {
|
|
|
1738
1653
|
};
|
|
1739
1654
|
}
|
|
1740
1655
|
}
|
|
1741
|
-
function
|
|
1656
|
+
function q(r = {}) {
|
|
1742
1657
|
return Array.isArray(r) || Array.isArray(r == null ? void 0 : r.features) ? { points: r } : r || {};
|
|
1743
1658
|
}
|
|
1744
|
-
function
|
|
1745
|
-
const e =
|
|
1659
|
+
function Re(r = {}) {
|
|
1660
|
+
const e = q(r);
|
|
1746
1661
|
return ["points", "data", "items"].some(
|
|
1747
1662
|
(t) => Object.prototype.hasOwnProperty.call(e, t)
|
|
1748
1663
|
);
|
|
1749
1664
|
}
|
|
1750
|
-
function
|
|
1665
|
+
function St(r) {
|
|
1751
1666
|
return !!(r && typeof r.getEngineType == "function" && typeof r.getMapInstance == "function" && typeof r.upsertPointClusterLayer == "function" && typeof r.showPointClusterLayer == "function" && typeof r.hidePointClusterLayer == "function" && typeof r.removePointClusterLayer == "function" && typeof r.clearPointClusterLayer == "function" && typeof r.getPointClusterLayerState == "function");
|
|
1752
1667
|
}
|
|
1753
|
-
function
|
|
1668
|
+
function vt(r = {}) {
|
|
1754
1669
|
const e = { ...r };
|
|
1755
1670
|
return delete e.mapCore, delete e.baseGIS, e;
|
|
1756
1671
|
}
|
|
1757
1672
|
class qr {
|
|
1758
1673
|
constructor(e = {}) {
|
|
1759
|
-
const t =
|
|
1674
|
+
const t = vt(e), n = t.pointClusterLayerId || t.clusterLayerId || t.layerId || t.id || "point-cluster-default";
|
|
1760
1675
|
this.options = {
|
|
1761
1676
|
layerId: n,
|
|
1762
1677
|
visible: t.visible ?? !0,
|
|
@@ -1782,7 +1697,7 @@ class qr {
|
|
|
1782
1697
|
}
|
|
1783
1698
|
mount(e) {
|
|
1784
1699
|
var t, n;
|
|
1785
|
-
return
|
|
1700
|
+
return St(e) ? (this.baseGIS = e, g(
|
|
1786
1701
|
{ engineType: ((n = (t = this.baseGIS).getEngineType) == null ? void 0 : n.call(t)) || "unknown" },
|
|
1787
1702
|
"PointClusterController mounted with BaseGIS."
|
|
1788
1703
|
)) : f(
|
|
@@ -1792,7 +1707,7 @@ class qr {
|
|
|
1792
1707
|
}
|
|
1793
1708
|
resolveBaseGIS() {
|
|
1794
1709
|
var e, t;
|
|
1795
|
-
return this.baseGIS ? (t = (e = this.baseGIS).getMapInstance) != null && t.call(e) ?
|
|
1710
|
+
return this.baseGIS ? (t = (e = this.baseGIS).getMapInstance) != null && t.call(e) ? g(null, "BaseGIS is ready.") : f(
|
|
1796
1711
|
"Map instance is not ready. Please call mapCore.init() first.",
|
|
1797
1712
|
"NOT_INITIALIZED"
|
|
1798
1713
|
) : f("PointClusterController has not been mounted.", "NOT_MOUNTED");
|
|
@@ -1802,7 +1717,7 @@ class qr {
|
|
|
1802
1717
|
return (typeof e == "string" || typeof e == "number") && e !== "" ? String(e) : (e == null ? void 0 : e.pointClusterLayerId) || (e == null ? void 0 : e.clusterLayerId) || (e == null ? void 0 : e.layerId) || (e == null ? void 0 : e.id) || ((t = this.currentPayload) == null ? void 0 : t.layerId) || this.options.layerId;
|
|
1803
1718
|
}
|
|
1804
1719
|
buildPayload(e = {}) {
|
|
1805
|
-
const t =
|
|
1720
|
+
const t = q(e);
|
|
1806
1721
|
return {
|
|
1807
1722
|
...this.defaultPayload,
|
|
1808
1723
|
...t,
|
|
@@ -1819,21 +1734,21 @@ class qr {
|
|
|
1819
1734
|
}, typeof t.visible == "boolean" && (this.visible = t.visible));
|
|
1820
1735
|
}
|
|
1821
1736
|
async load(e = {}, t = {}) {
|
|
1822
|
-
var
|
|
1737
|
+
var o;
|
|
1823
1738
|
const n = this.resolveBaseGIS();
|
|
1824
1739
|
if (!n.success)
|
|
1825
1740
|
return n;
|
|
1826
1741
|
const s = this.buildPayload({
|
|
1827
|
-
...
|
|
1828
|
-
...
|
|
1742
|
+
...q(e),
|
|
1743
|
+
...q(t)
|
|
1829
1744
|
});
|
|
1830
|
-
if (!
|
|
1745
|
+
if (!Re(s))
|
|
1831
1746
|
return f(
|
|
1832
1747
|
"Point cluster layer requires points, data or items.",
|
|
1833
1748
|
"INVALID_POINT_SOURCE"
|
|
1834
1749
|
);
|
|
1835
1750
|
const i = await this.baseGIS.upsertPointClusterLayer(s);
|
|
1836
|
-
return i.success && (this.currentPayload = s, this.visible = s.visible !== !1, this.layerType = ((
|
|
1751
|
+
return i.success && (this.currentPayload = s, this.visible = s.visible !== !1, this.layerType = ((o = i == null ? void 0 : i.data) == null ? void 0 : o.layerType) || this.layerType, this.syncStateFromResult(i)), i;
|
|
1837
1752
|
}
|
|
1838
1753
|
upsert(e = {}, t = {}) {
|
|
1839
1754
|
return this.load(e, t);
|
|
@@ -1841,9 +1756,9 @@ class qr {
|
|
|
1841
1756
|
update(e = {}) {
|
|
1842
1757
|
const t = {
|
|
1843
1758
|
...this.currentPayload || this.defaultPayload,
|
|
1844
|
-
...
|
|
1759
|
+
...q(e)
|
|
1845
1760
|
};
|
|
1846
|
-
return !this.currentPayload && !
|
|
1761
|
+
return !this.currentPayload && !Re(t) ? f("Point cluster layer has not been loaded.", "NOT_LOADED") : this.load(t);
|
|
1847
1762
|
}
|
|
1848
1763
|
setConfig(e = {}) {
|
|
1849
1764
|
return this.update(e);
|
|
@@ -1898,12 +1813,12 @@ class qr {
|
|
|
1898
1813
|
}
|
|
1899
1814
|
destroy(e = {}) {
|
|
1900
1815
|
if (!this.resolveBaseGIS().success)
|
|
1901
|
-
return this.resetLocalState(),
|
|
1816
|
+
return this.resetLocalState(), g(null, "Point cluster layer controller destroyed (local state only).");
|
|
1902
1817
|
const n = this.baseGIS.removePointClusterLayer({
|
|
1903
1818
|
...e,
|
|
1904
1819
|
layerId: this.getLayerId(e)
|
|
1905
1820
|
});
|
|
1906
|
-
return this.resetLocalState(), n.success ?
|
|
1821
|
+
return this.resetLocalState(), n.success ? g(null, "Point cluster layer controller destroyed.") : n;
|
|
1907
1822
|
}
|
|
1908
1823
|
resetLocalState() {
|
|
1909
1824
|
this.currentPayload = null, this.layerType = "unknown", this.currentState = {
|
|
@@ -1922,43 +1837,43 @@ class qr {
|
|
|
1922
1837
|
return this.destroy(e);
|
|
1923
1838
|
}
|
|
1924
1839
|
getState() {
|
|
1925
|
-
var e, t, n, s, i,
|
|
1840
|
+
var e, t, n, s, i, o, a;
|
|
1926
1841
|
if ((t = (e = this.baseGIS) == null ? void 0 : e.getMapInstance) != null && t.call(e) && this.currentPayload) {
|
|
1927
|
-
const
|
|
1842
|
+
const l = (s = (n = this.baseGIS).getPointClusterLayerState) == null ? void 0 : s.call(n, {
|
|
1928
1843
|
layerId: this.currentPayload.layerId || this.options.layerId
|
|
1929
1844
|
});
|
|
1930
|
-
|
|
1845
|
+
l != null && l.success && this.syncStateFromResult(l);
|
|
1931
1846
|
}
|
|
1932
1847
|
return {
|
|
1933
1848
|
mounted: !!this.baseGIS,
|
|
1934
|
-
engineType: ((
|
|
1849
|
+
engineType: ((o = (i = this.baseGIS) == null ? void 0 : i.getEngineType) == null ? void 0 : o.call(i)) || "unknown",
|
|
1935
1850
|
layerType: this.layerType,
|
|
1936
1851
|
visible: this.visible,
|
|
1937
|
-
layerId: ((
|
|
1852
|
+
layerId: ((a = this.currentPayload) == null ? void 0 : a.layerId) || this.options.layerId,
|
|
1938
1853
|
payload: this.currentPayload,
|
|
1939
1854
|
...this.currentState
|
|
1940
1855
|
};
|
|
1941
1856
|
}
|
|
1942
1857
|
}
|
|
1943
|
-
function
|
|
1858
|
+
function X(r = {}) {
|
|
1944
1859
|
return Array.isArray(r) || Array.isArray(r == null ? void 0 : r.features) ? { points: r } : r || {};
|
|
1945
1860
|
}
|
|
1946
|
-
function
|
|
1947
|
-
const e =
|
|
1861
|
+
function xe(r = {}) {
|
|
1862
|
+
const e = X(r);
|
|
1948
1863
|
return ["points", "data", "items"].some(
|
|
1949
1864
|
(t) => Object.prototype.hasOwnProperty.call(e, t)
|
|
1950
1865
|
);
|
|
1951
1866
|
}
|
|
1952
|
-
function
|
|
1867
|
+
function Pt(r) {
|
|
1953
1868
|
return !!(r && typeof r.getEngineType == "function" && typeof r.getMapInstance == "function" && typeof r.upsertPointDensityLayer == "function" && typeof r.showPointDensityLayer == "function" && typeof r.hidePointDensityLayer == "function" && typeof r.removePointDensityLayer == "function" && typeof r.clearPointDensityLayer == "function" && typeof r.getPointDensityLayerState == "function");
|
|
1954
1869
|
}
|
|
1955
|
-
function
|
|
1870
|
+
function Lt(r = {}) {
|
|
1956
1871
|
const e = { ...r };
|
|
1957
1872
|
return delete e.mapCore, delete e.baseGIS, e;
|
|
1958
1873
|
}
|
|
1959
1874
|
class Xr {
|
|
1960
1875
|
constructor(e = {}) {
|
|
1961
|
-
const t =
|
|
1876
|
+
const t = Lt(e), n = t.pointDensityLayerId || t.densityLayerId || t.layerId || t.id || "point-density-default";
|
|
1962
1877
|
this.options = {
|
|
1963
1878
|
layerId: n,
|
|
1964
1879
|
visible: t.visible ?? !0,
|
|
@@ -1980,7 +1895,7 @@ class Xr {
|
|
|
1980
1895
|
}
|
|
1981
1896
|
mount(e) {
|
|
1982
1897
|
var t, n;
|
|
1983
|
-
return
|
|
1898
|
+
return Pt(e) ? (this.baseGIS = e, g(
|
|
1984
1899
|
{ engineType: ((n = (t = this.baseGIS).getEngineType) == null ? void 0 : n.call(t)) || "unknown" },
|
|
1985
1900
|
"PointDensityController mounted with BaseGIS."
|
|
1986
1901
|
)) : f(
|
|
@@ -1990,7 +1905,7 @@ class Xr {
|
|
|
1990
1905
|
}
|
|
1991
1906
|
resolveBaseGIS() {
|
|
1992
1907
|
var e, t;
|
|
1993
|
-
return this.baseGIS ? (t = (e = this.baseGIS).getMapInstance) != null && t.call(e) ?
|
|
1908
|
+
return this.baseGIS ? (t = (e = this.baseGIS).getMapInstance) != null && t.call(e) ? g(null, "BaseGIS is ready.") : f(
|
|
1994
1909
|
"Map instance is not ready. Please call mapCore.init() first.",
|
|
1995
1910
|
"NOT_INITIALIZED"
|
|
1996
1911
|
) : f("PointDensityController has not been mounted.", "NOT_MOUNTED");
|
|
@@ -2000,7 +1915,7 @@ class Xr {
|
|
|
2000
1915
|
return typeof e == "string" && e ? e : (e == null ? void 0 : e.pointDensityLayerId) || (e == null ? void 0 : e.densityLayerId) || (e == null ? void 0 : e.layerId) || (e == null ? void 0 : e.id) || ((t = this.currentPayload) == null ? void 0 : t.layerId) || this.options.layerId;
|
|
2001
1916
|
}
|
|
2002
1917
|
buildPayload(e = {}) {
|
|
2003
|
-
const t =
|
|
1918
|
+
const t = X(e), n = this.getLayerId(t);
|
|
2004
1919
|
return {
|
|
2005
1920
|
...this.defaultPayload,
|
|
2006
1921
|
...t,
|
|
@@ -2017,21 +1932,21 @@ class Xr {
|
|
|
2017
1932
|
}, typeof t.visible == "boolean" && (this.visible = t.visible));
|
|
2018
1933
|
}
|
|
2019
1934
|
async load(e = {}, t = {}) {
|
|
2020
|
-
var
|
|
1935
|
+
var l;
|
|
2021
1936
|
const n = this.resolveBaseGIS();
|
|
2022
1937
|
if (!n.success)
|
|
2023
1938
|
return n;
|
|
2024
|
-
const s =
|
|
1939
|
+
const s = X(e), i = X(t), o = this.buildPayload({
|
|
2025
1940
|
...s,
|
|
2026
1941
|
...i
|
|
2027
1942
|
});
|
|
2028
|
-
if (!
|
|
1943
|
+
if (!xe(o))
|
|
2029
1944
|
return f(
|
|
2030
1945
|
"Point density layer requires points, data or items.",
|
|
2031
1946
|
"INVALID_POINT_SOURCE"
|
|
2032
1947
|
);
|
|
2033
|
-
const
|
|
2034
|
-
return
|
|
1948
|
+
const a = await this.baseGIS.upsertPointDensityLayer(o);
|
|
1949
|
+
return a.success && (this.currentPayload = o, this.visible = o.visible !== !1, this.layerType = ((l = a == null ? void 0 : a.data) == null ? void 0 : l.layerType) || this.layerType, this.syncStateFromResult(a)), a;
|
|
2035
1950
|
}
|
|
2036
1951
|
upsert(e = {}, t = {}) {
|
|
2037
1952
|
return this.load(e, t);
|
|
@@ -2039,9 +1954,9 @@ class Xr {
|
|
|
2039
1954
|
async update(e = {}) {
|
|
2040
1955
|
const t = {
|
|
2041
1956
|
...this.currentPayload || this.defaultPayload,
|
|
2042
|
-
...
|
|
1957
|
+
...X(e)
|
|
2043
1958
|
};
|
|
2044
|
-
return !this.currentPayload && !
|
|
1959
|
+
return !this.currentPayload && !xe(t) ? f("Point density layer has not been loaded.", "NOT_LOADED") : this.load(t);
|
|
2045
1960
|
}
|
|
2046
1961
|
setConfig(e = {}) {
|
|
2047
1962
|
return this.update(e);
|
|
@@ -2103,7 +2018,7 @@ class Xr {
|
|
|
2103
2018
|
hiddenCount: 0,
|
|
2104
2019
|
gridCount: 0,
|
|
2105
2020
|
destroyed: !0
|
|
2106
|
-
},
|
|
2021
|
+
}, g(null, "Point density layer controller destroyed (local state only).");
|
|
2107
2022
|
const n = this.baseGIS.removePointDensityLayer({
|
|
2108
2023
|
...e,
|
|
2109
2024
|
layerId: this.getLayerId(e)
|
|
@@ -2115,56 +2030,56 @@ class Xr {
|
|
|
2115
2030
|
hiddenCount: 0,
|
|
2116
2031
|
gridCount: 0,
|
|
2117
2032
|
destroyed: !0
|
|
2118
|
-
}, n.success ?
|
|
2033
|
+
}, n.success ? g(null, "Point density layer controller destroyed.") : n;
|
|
2119
2034
|
}
|
|
2120
2035
|
removeLayer(e = {}) {
|
|
2121
2036
|
return this.destroy(e);
|
|
2122
2037
|
}
|
|
2123
2038
|
getState() {
|
|
2124
|
-
var e, t, n, s, i,
|
|
2039
|
+
var e, t, n, s, i, o, a;
|
|
2125
2040
|
if ((t = (e = this.baseGIS) == null ? void 0 : e.getMapInstance) != null && t.call(e) && this.currentPayload) {
|
|
2126
|
-
const
|
|
2041
|
+
const l = (s = (n = this.baseGIS).getPointDensityLayerState) == null ? void 0 : s.call(n, {
|
|
2127
2042
|
layerId: this.currentPayload.layerId || this.options.layerId
|
|
2128
2043
|
});
|
|
2129
|
-
|
|
2044
|
+
l != null && l.success && this.syncStateFromResult(l);
|
|
2130
2045
|
}
|
|
2131
2046
|
return {
|
|
2132
2047
|
mounted: !!this.baseGIS,
|
|
2133
|
-
engineType: ((
|
|
2048
|
+
engineType: ((o = (i = this.baseGIS) == null ? void 0 : i.getEngineType) == null ? void 0 : o.call(i)) || "unknown",
|
|
2134
2049
|
layerType: this.layerType,
|
|
2135
2050
|
visible: this.visible,
|
|
2136
|
-
layerId: ((
|
|
2051
|
+
layerId: ((a = this.currentPayload) == null ? void 0 : a.layerId) || this.options.layerId,
|
|
2137
2052
|
payload: this.currentPayload,
|
|
2138
2053
|
...this.currentState
|
|
2139
2054
|
};
|
|
2140
2055
|
}
|
|
2141
2056
|
}
|
|
2142
|
-
function
|
|
2057
|
+
function K(r = {}) {
|
|
2143
2058
|
return Array.isArray(r) || Array.isArray(r == null ? void 0 : r.features) ? { points: r } : r || {};
|
|
2144
2059
|
}
|
|
2145
|
-
function
|
|
2146
|
-
const e =
|
|
2060
|
+
function De(r = {}) {
|
|
2061
|
+
const e = K(r);
|
|
2147
2062
|
return ["points", "data", "items"].some(
|
|
2148
2063
|
(t) => Object.prototype.hasOwnProperty.call(e, t)
|
|
2149
2064
|
);
|
|
2150
2065
|
}
|
|
2151
|
-
function
|
|
2066
|
+
function Ct(r) {
|
|
2152
2067
|
return !!(r && typeof r.getEngineType == "function" && typeof r.getMapInstance == "function" && typeof r.upsertPointLargeLayer == "function" && typeof r.showPointLargeLayer == "function" && typeof r.hidePointLargeLayer == "function" && typeof r.removePointLargeLayer == "function" && typeof r.setPointLargeHighlight == "function" && typeof r.clearPointLargeHighlight == "function" && typeof r.removePointLargePoint == "function" && typeof r.clearPointLargeLayer == "function");
|
|
2153
2068
|
}
|
|
2154
|
-
function
|
|
2069
|
+
function Fe(r, e = {}) {
|
|
2155
2070
|
return r && typeof r == "object" && !Array.isArray(r) ? r.pointId ?? r.highlightId ?? r.key ?? r.id : r ?? e.pointId ?? e.highlightId ?? e.key ?? e.id;
|
|
2156
2071
|
}
|
|
2157
|
-
function
|
|
2072
|
+
function wt(r, e = "id", t = "") {
|
|
2158
2073
|
var n, s;
|
|
2159
2074
|
return !r || typeof r != "object" || Array.isArray(r) ? t : r[e] ?? ((n = r.properties) == null ? void 0 : n[e]) ?? r.id ?? ((s = r.properties) == null ? void 0 : s.id) ?? t;
|
|
2160
2075
|
}
|
|
2161
|
-
function
|
|
2076
|
+
function Tt(r = {}) {
|
|
2162
2077
|
const { mapCore: e, baseGIS: t, ...n } = r;
|
|
2163
2078
|
return n;
|
|
2164
2079
|
}
|
|
2165
2080
|
class Kr {
|
|
2166
2081
|
constructor(e = {}) {
|
|
2167
|
-
const t =
|
|
2082
|
+
const t = Tt(e), n = t.pointLargeLayerId || t.largeLayerId || t.layerId || t.id || "point-large-default";
|
|
2168
2083
|
this.options = {
|
|
2169
2084
|
layerId: n,
|
|
2170
2085
|
visible: t.visible ?? !0,
|
|
@@ -2185,7 +2100,7 @@ class Kr {
|
|
|
2185
2100
|
}
|
|
2186
2101
|
mount(e) {
|
|
2187
2102
|
var t, n;
|
|
2188
|
-
return
|
|
2103
|
+
return Ct(e) ? (this.baseGIS = e, g(
|
|
2189
2104
|
{ engineType: ((n = (t = this.baseGIS).getEngineType) == null ? void 0 : n.call(t)) || "unknown" },
|
|
2190
2105
|
"PointLargeLayerController mounted with BaseGIS."
|
|
2191
2106
|
)) : f(
|
|
@@ -2195,7 +2110,7 @@ class Kr {
|
|
|
2195
2110
|
}
|
|
2196
2111
|
resolveBaseGIS() {
|
|
2197
2112
|
var e, t;
|
|
2198
|
-
return this.baseGIS ? (t = (e = this.baseGIS).getMapInstance) != null && t.call(e) ?
|
|
2113
|
+
return this.baseGIS ? (t = (e = this.baseGIS).getMapInstance) != null && t.call(e) ? g(null, "BaseGIS is ready.") : f(
|
|
2199
2114
|
"Map instance is not ready. Please call mapCore.init() first.",
|
|
2200
2115
|
"NOT_INITIALIZED"
|
|
2201
2116
|
) : f("PointLargeLayerController has not been mounted.", "NOT_MOUNTED");
|
|
@@ -2206,7 +2121,7 @@ class Kr {
|
|
|
2206
2121
|
return typeof e == "string" && e ? e : (e == null ? void 0 : e.pointLargeLayerId) || (e == null ? void 0 : e.largeLayerId) || (e == null ? void 0 : e.layerId) || (n ? e == null ? void 0 : e.id : "") || ((s = this.currentPayload) == null ? void 0 : s.layerId) || this.options.layerId;
|
|
2207
2122
|
}
|
|
2208
2123
|
buildPayload(e = {}) {
|
|
2209
|
-
const t =
|
|
2124
|
+
const t = K(e), n = this.getLayerId(t);
|
|
2210
2125
|
return {
|
|
2211
2126
|
...this.defaultPayload,
|
|
2212
2127
|
...t,
|
|
@@ -2227,21 +2142,21 @@ class Kr {
|
|
|
2227
2142
|
* 支持 load(points, options) 或 load({ points, ...options }) 两种调用方式。
|
|
2228
2143
|
*/
|
|
2229
2144
|
async load(e = {}, t = {}) {
|
|
2230
|
-
var
|
|
2145
|
+
var l;
|
|
2231
2146
|
const n = this.resolveBaseGIS();
|
|
2232
2147
|
if (!n.success)
|
|
2233
2148
|
return n;
|
|
2234
|
-
const s =
|
|
2149
|
+
const s = K(e), i = K(t), o = this.buildPayload({
|
|
2235
2150
|
...s,
|
|
2236
2151
|
...i
|
|
2237
2152
|
});
|
|
2238
|
-
if (!
|
|
2153
|
+
if (!De(o))
|
|
2239
2154
|
return f(
|
|
2240
2155
|
"Point large layer requires points, data or items.",
|
|
2241
2156
|
"INVALID_POINT_SOURCE"
|
|
2242
2157
|
);
|
|
2243
|
-
const
|
|
2244
|
-
return
|
|
2158
|
+
const a = await this.baseGIS.upsertPointLargeLayer(o);
|
|
2159
|
+
return a.success && (this.currentPayload = o, this.visible = o.visible !== !1, this.layerType = ((l = a == null ? void 0 : a.data) == null ? void 0 : l.layerType) || this.layerType, this.syncStateFromResult(a)), a;
|
|
2245
2160
|
}
|
|
2246
2161
|
upsert(e = {}, t = {}) {
|
|
2247
2162
|
return this.load(e, t);
|
|
@@ -2249,9 +2164,9 @@ class Kr {
|
|
|
2249
2164
|
async update(e = {}) {
|
|
2250
2165
|
const t = {
|
|
2251
2166
|
...this.currentPayload || this.defaultPayload,
|
|
2252
|
-
...
|
|
2167
|
+
...K(e)
|
|
2253
2168
|
};
|
|
2254
|
-
return !this.currentPayload && !
|
|
2169
|
+
return !this.currentPayload && !De(t) ? f("Point large layer has not been loaded.", "NOT_LOADED") : this.load(t);
|
|
2255
2170
|
}
|
|
2256
2171
|
show(e = {}) {
|
|
2257
2172
|
const t = this.resolveBaseGIS();
|
|
@@ -2280,15 +2195,15 @@ class Kr {
|
|
|
2280
2195
|
const n = this.resolveBaseGIS();
|
|
2281
2196
|
if (!n.success)
|
|
2282
2197
|
return n;
|
|
2283
|
-
const s = e && typeof e == "object" && !Array.isArray(e) ? e : t, i =
|
|
2198
|
+
const s = e && typeof e == "object" && !Array.isArray(e) ? e : t, i = Fe(e, s);
|
|
2284
2199
|
if (i == null || i === "")
|
|
2285
2200
|
return f("Point id is required when setting highlight.", "INVALID_POINT_ID");
|
|
2286
|
-
const
|
|
2201
|
+
const o = this.baseGIS.setPointLargeHighlight({
|
|
2287
2202
|
...s,
|
|
2288
2203
|
layerId: this.getLayerId(s, { allowId: !1 }),
|
|
2289
2204
|
pointId: i
|
|
2290
2205
|
});
|
|
2291
|
-
return
|
|
2206
|
+
return o.success && this.syncStateFromResult(o), o;
|
|
2292
2207
|
}
|
|
2293
2208
|
highlight(e, t = {}) {
|
|
2294
2209
|
return this.setHighlight(e, t);
|
|
@@ -2316,8 +2231,8 @@ class Kr {
|
|
|
2316
2231
|
this.currentPayload = {
|
|
2317
2232
|
...this.currentPayload,
|
|
2318
2233
|
points: this.currentPayload.points.filter((s, i) => {
|
|
2319
|
-
const
|
|
2320
|
-
return !n.has(String(
|
|
2234
|
+
const o = wt(s, t, i);
|
|
2235
|
+
return !n.has(String(o));
|
|
2321
2236
|
})
|
|
2322
2237
|
};
|
|
2323
2238
|
}
|
|
@@ -2325,15 +2240,15 @@ class Kr {
|
|
|
2325
2240
|
const n = this.resolveBaseGIS();
|
|
2326
2241
|
if (!n.success)
|
|
2327
2242
|
return n;
|
|
2328
|
-
const s = e && typeof e == "object" && !Array.isArray(e) ? e : t, i =
|
|
2243
|
+
const s = e && typeof e == "object" && !Array.isArray(e) ? e : t, i = Fe(e, s);
|
|
2329
2244
|
if (i == null || i === "")
|
|
2330
2245
|
return f("Point id is required when removing point.", "INVALID_POINT_ID");
|
|
2331
|
-
const
|
|
2246
|
+
const o = this.baseGIS.removePointLargePoint({
|
|
2332
2247
|
...s,
|
|
2333
2248
|
layerId: this.getLayerId(s, { allowId: !1 }),
|
|
2334
2249
|
pointId: i
|
|
2335
2250
|
});
|
|
2336
|
-
return
|
|
2251
|
+
return o.success && (this.removeCachedPoints([i]), this.syncStateFromResult(o)), o;
|
|
2337
2252
|
}
|
|
2338
2253
|
deletePoint(e, t = {}) {
|
|
2339
2254
|
return this.removePoint(e, t);
|
|
@@ -2398,7 +2313,7 @@ class Kr {
|
|
|
2398
2313
|
renderedCount: 0,
|
|
2399
2314
|
building: !1,
|
|
2400
2315
|
destroyed: !0
|
|
2401
|
-
},
|
|
2316
|
+
}, g(null, "Point large layer controller destroyed (local state only).");
|
|
2402
2317
|
const n = this.baseGIS.removePointLargeLayer({
|
|
2403
2318
|
...e,
|
|
2404
2319
|
layerId: this.getLayerId(e)
|
|
@@ -2409,37 +2324,37 @@ class Kr {
|
|
|
2409
2324
|
renderedCount: 0,
|
|
2410
2325
|
building: !1,
|
|
2411
2326
|
destroyed: !0
|
|
2412
|
-
}, n.success ?
|
|
2327
|
+
}, n.success ? g(null, "Point large layer controller destroyed.") : n;
|
|
2413
2328
|
}
|
|
2414
2329
|
removeLayer(e = {}) {
|
|
2415
2330
|
return this.destroy(e);
|
|
2416
2331
|
}
|
|
2417
2332
|
getState() {
|
|
2418
|
-
var e, t, n, s, i,
|
|
2333
|
+
var e, t, n, s, i, o, a;
|
|
2419
2334
|
if ((t = (e = this.baseGIS) == null ? void 0 : e.getMapInstance) != null && t.call(e) && this.currentPayload) {
|
|
2420
|
-
const
|
|
2335
|
+
const l = (s = (n = this.baseGIS).getPointLargeLayerState) == null ? void 0 : s.call(n, {
|
|
2421
2336
|
layerId: this.currentPayload.layerId || this.options.layerId
|
|
2422
2337
|
});
|
|
2423
|
-
|
|
2338
|
+
l != null && l.success && this.syncStateFromResult(l);
|
|
2424
2339
|
}
|
|
2425
2340
|
return {
|
|
2426
2341
|
mounted: !!this.baseGIS,
|
|
2427
|
-
engineType: ((
|
|
2342
|
+
engineType: ((o = (i = this.baseGIS) == null ? void 0 : i.getEngineType) == null ? void 0 : o.call(i)) || "unknown",
|
|
2428
2343
|
layerType: this.layerType,
|
|
2429
2344
|
visible: this.visible,
|
|
2430
|
-
layerId: ((
|
|
2345
|
+
layerId: ((a = this.currentPayload) == null ? void 0 : a.layerId) || this.options.layerId,
|
|
2431
2346
|
payload: this.currentPayload,
|
|
2432
2347
|
...this.currentState
|
|
2433
2348
|
};
|
|
2434
2349
|
}
|
|
2435
2350
|
}
|
|
2436
|
-
function
|
|
2351
|
+
function Gt(r, e) {
|
|
2437
2352
|
let t = 0;
|
|
2438
2353
|
for (let n of r)
|
|
2439
2354
|
n != null && (n = +n) >= n && ++t;
|
|
2440
2355
|
return t;
|
|
2441
2356
|
}
|
|
2442
|
-
function
|
|
2357
|
+
function Mt(r, e) {
|
|
2443
2358
|
let t, n;
|
|
2444
2359
|
if (e === void 0)
|
|
2445
2360
|
for (const s of r)
|
|
@@ -2451,72 +2366,72 @@ function xt(r, e) {
|
|
|
2451
2366
|
}
|
|
2452
2367
|
return [t, n];
|
|
2453
2368
|
}
|
|
2454
|
-
const
|
|
2369
|
+
const Nt = Math.sqrt(50), Et = Math.sqrt(10), At = Math.sqrt(2);
|
|
2455
2370
|
function Q(r, e, t) {
|
|
2456
|
-
const n = (e - r) / Math.max(0, t), s = Math.floor(Math.log10(n)), i = n / Math.pow(10, s),
|
|
2457
|
-
let
|
|
2458
|
-
return s < 0 ? (
|
|
2371
|
+
const n = (e - r) / Math.max(0, t), s = Math.floor(Math.log10(n)), i = n / Math.pow(10, s), o = i >= Nt ? 10 : i >= Et ? 5 : i >= At ? 2 : 1;
|
|
2372
|
+
let a, l, u;
|
|
2373
|
+
return s < 0 ? (u = Math.pow(10, -s) / o, a = Math.round(r * u), l = Math.round(e * u), a / u < r && ++a, l / u > e && --l, u = -u) : (u = Math.pow(10, s) * o, a = Math.round(r / u), l = Math.round(e / u), a * u < r && ++a, l * u > e && --l), l < a && 0.5 <= t && t < 2 ? Q(r, e, t * 2) : [a, l, u];
|
|
2459
2374
|
}
|
|
2460
|
-
function
|
|
2375
|
+
function Rt(r, e, t) {
|
|
2461
2376
|
if (e = +e, r = +r, t = +t, !(t > 0)) return [];
|
|
2462
2377
|
if (r === e) return [r];
|
|
2463
|
-
const n = e < r, [s, i,
|
|
2378
|
+
const n = e < r, [s, i, o] = n ? Q(e, r, t) : Q(r, e, t);
|
|
2464
2379
|
if (!(i >= s)) return [];
|
|
2465
|
-
const
|
|
2380
|
+
const a = i - s + 1, l = new Array(a);
|
|
2466
2381
|
if (n)
|
|
2467
|
-
if (
|
|
2468
|
-
else for (let
|
|
2469
|
-
else if (
|
|
2470
|
-
else for (let
|
|
2471
|
-
return
|
|
2382
|
+
if (o < 0) for (let u = 0; u < a; ++u) l[u] = (i - u) / -o;
|
|
2383
|
+
else for (let u = 0; u < a; ++u) l[u] = (i - u) * o;
|
|
2384
|
+
else if (o < 0) for (let u = 0; u < a; ++u) l[u] = (s + u) / -o;
|
|
2385
|
+
else for (let u = 0; u < a; ++u) l[u] = (s + u) * o;
|
|
2386
|
+
return l;
|
|
2472
2387
|
}
|
|
2473
|
-
function
|
|
2388
|
+
function xt(r, e, t) {
|
|
2474
2389
|
return e = +e, r = +r, t = +t, Q(r, e, t)[2];
|
|
2475
2390
|
}
|
|
2476
|
-
function
|
|
2391
|
+
function Dt(r, e, t) {
|
|
2477
2392
|
let n;
|
|
2478
2393
|
for (; ; ) {
|
|
2479
|
-
const s =
|
|
2394
|
+
const s = xt(r, e, t);
|
|
2480
2395
|
if (s === n || s === 0 || !isFinite(s))
|
|
2481
2396
|
return [r, e];
|
|
2482
2397
|
s > 0 ? (r = Math.floor(r / s) * s, e = Math.ceil(e / s) * s) : s < 0 && (r = Math.ceil(r * s) / s, e = Math.floor(e * s) / s), n = s;
|
|
2483
2398
|
}
|
|
2484
2399
|
}
|
|
2485
|
-
function
|
|
2486
|
-
return Math.max(1, Math.ceil(Math.log(
|
|
2400
|
+
function Ft(r) {
|
|
2401
|
+
return Math.max(1, Math.ceil(Math.log(Gt(r)) / Math.LN2) + 1);
|
|
2487
2402
|
}
|
|
2488
|
-
var
|
|
2489
|
-
function
|
|
2403
|
+
var Bt = Array.prototype, Ot = Bt.slice;
|
|
2404
|
+
function jt(r, e) {
|
|
2490
2405
|
return r - e;
|
|
2491
2406
|
}
|
|
2492
|
-
function
|
|
2407
|
+
function _t(r) {
|
|
2493
2408
|
for (var e = 0, t = r.length, n = r[t - 1][1] * r[0][0] - r[t - 1][0] * r[0][1]; ++e < t; ) n += r[e - 1][1] * r[e][0] - r[e - 1][0] * r[e][1];
|
|
2494
2409
|
return n;
|
|
2495
2410
|
}
|
|
2496
|
-
const
|
|
2497
|
-
function
|
|
2498
|
-
for (var t = -1, n = e.length, s; ++t < n; ) if (s =
|
|
2411
|
+
const Be = (r) => () => r;
|
|
2412
|
+
function Vt(r, e) {
|
|
2413
|
+
for (var t = -1, n = e.length, s; ++t < n; ) if (s = zt(r, e[t])) return s;
|
|
2499
2414
|
return 0;
|
|
2500
2415
|
}
|
|
2501
|
-
function
|
|
2502
|
-
for (var t = e[0], n = e[1], s = -1, i = 0,
|
|
2503
|
-
var
|
|
2504
|
-
if (
|
|
2505
|
-
c > n != d > n && t < (y -
|
|
2416
|
+
function zt(r, e) {
|
|
2417
|
+
for (var t = e[0], n = e[1], s = -1, i = 0, o = r.length, a = o - 1; i < o; a = i++) {
|
|
2418
|
+
var l = r[i], u = l[0], c = l[1], h = r[a], y = h[0], d = h[1];
|
|
2419
|
+
if (Ut(l, h, e)) return 0;
|
|
2420
|
+
c > n != d > n && t < (y - u) * (n - c) / (d - c) + u && (s = -s);
|
|
2506
2421
|
}
|
|
2507
2422
|
return s;
|
|
2508
2423
|
}
|
|
2509
|
-
function
|
|
2424
|
+
function Ut(r, e, t) {
|
|
2510
2425
|
var n;
|
|
2511
|
-
return
|
|
2426
|
+
return $t(r, e, t) && kt(r[n = +(r[0] === e[0])], t[n], e[n]);
|
|
2512
2427
|
}
|
|
2513
|
-
function
|
|
2428
|
+
function $t(r, e, t) {
|
|
2514
2429
|
return (e[0] - r[0]) * (t[1] - r[1]) === (t[0] - r[0]) * (e[1] - r[1]);
|
|
2515
2430
|
}
|
|
2516
|
-
function
|
|
2431
|
+
function kt(r, e, t) {
|
|
2517
2432
|
return r <= e && e <= t || t <= e && e <= r;
|
|
2518
2433
|
}
|
|
2519
|
-
function
|
|
2434
|
+
function Wt() {
|
|
2520
2435
|
}
|
|
2521
2436
|
var B = [
|
|
2522
2437
|
[],
|
|
@@ -2536,29 +2451,29 @@ var B = [
|
|
|
2536
2451
|
[[[0.5, 1], [1, 1.5]]],
|
|
2537
2452
|
[]
|
|
2538
2453
|
];
|
|
2539
|
-
function
|
|
2540
|
-
var r = 1, e = 1, t =
|
|
2541
|
-
function s(
|
|
2542
|
-
var c = t(
|
|
2454
|
+
function Yt() {
|
|
2455
|
+
var r = 1, e = 1, t = Ft, n = l;
|
|
2456
|
+
function s(u) {
|
|
2457
|
+
var c = t(u);
|
|
2543
2458
|
if (Array.isArray(c))
|
|
2544
|
-
c = c.slice().sort(
|
|
2459
|
+
c = c.slice().sort(jt);
|
|
2545
2460
|
else {
|
|
2546
|
-
const h =
|
|
2547
|
-
for (c =
|
|
2461
|
+
const h = Mt(u, Ht);
|
|
2462
|
+
for (c = Rt(...Dt(h[0], h[1], c), c); c[c.length - 1] >= h[1]; ) c.pop();
|
|
2548
2463
|
for (; c[1] < h[0]; ) c.shift();
|
|
2549
2464
|
}
|
|
2550
|
-
return c.map((h) => i(
|
|
2465
|
+
return c.map((h) => i(u, h));
|
|
2551
2466
|
}
|
|
2552
|
-
function i(
|
|
2467
|
+
function i(u, c) {
|
|
2553
2468
|
const h = c == null ? NaN : +c;
|
|
2554
2469
|
if (isNaN(h)) throw new Error(`invalid value: ${c}`);
|
|
2555
2470
|
var y = [], d = [];
|
|
2556
|
-
return
|
|
2557
|
-
n(I,
|
|
2471
|
+
return o(u, h, function(I) {
|
|
2472
|
+
n(I, u, h), _t(I) > 0 ? y.push([I]) : d.push(I);
|
|
2558
2473
|
}), d.forEach(function(I) {
|
|
2559
|
-
for (var b = 0, S = y.length,
|
|
2560
|
-
if (
|
|
2561
|
-
|
|
2474
|
+
for (var b = 0, S = y.length, m; b < S; ++b)
|
|
2475
|
+
if (Vt((m = y[b])[0], I) !== -1) {
|
|
2476
|
+
m.push(I);
|
|
2562
2477
|
return;
|
|
2563
2478
|
}
|
|
2564
2479
|
}), {
|
|
@@ -2567,57 +2482,60 @@ function Zt() {
|
|
|
2567
2482
|
coordinates: y
|
|
2568
2483
|
};
|
|
2569
2484
|
}
|
|
2570
|
-
function
|
|
2571
|
-
var y = new Array(), d = new Array(), I, b, S,
|
|
2572
|
-
for (I = b = -1,
|
|
2573
|
-
S =
|
|
2574
|
-
for (B[
|
|
2575
|
-
for (I = -1,
|
|
2576
|
-
S =
|
|
2577
|
-
B[
|
|
2485
|
+
function o(u, c, h) {
|
|
2486
|
+
var y = new Array(), d = new Array(), I, b, S, m, v, p;
|
|
2487
|
+
for (I = b = -1, m = z(u[0], c), B[m << 1].forEach(C); ++I < r - 1; )
|
|
2488
|
+
S = m, m = z(u[I + 1], c), B[S | m << 1].forEach(C);
|
|
2489
|
+
for (B[m << 0].forEach(C); ++b < e - 1; ) {
|
|
2490
|
+
for (I = -1, m = z(u[b * r + r], c), v = z(u[b * r], c), B[m << 1 | v << 2].forEach(C); ++I < r - 1; )
|
|
2491
|
+
S = m, m = z(u[b * r + r + I + 1], c), p = v, v = z(u[b * r + I + 1], c), B[S | m << 1 | v << 2 | p << 3].forEach(C);
|
|
2492
|
+
B[m | v << 3].forEach(C);
|
|
2578
2493
|
}
|
|
2579
|
-
for (I = -1,
|
|
2580
|
-
p =
|
|
2581
|
-
B[
|
|
2582
|
-
function
|
|
2583
|
-
var
|
|
2584
|
-
(
|
|
2494
|
+
for (I = -1, v = u[b * r] >= c, B[v << 2].forEach(C); ++I < r - 1; )
|
|
2495
|
+
p = v, v = z(u[b * r + I + 1], c), B[v << 2 | p << 3].forEach(C);
|
|
2496
|
+
B[v << 3].forEach(C);
|
|
2497
|
+
function C(w) {
|
|
2498
|
+
var R = [w[0][0] + I, w[0][1] + b], x = [w[1][0] + I, w[1][1] + b], A = a(R), O = a(x), P, G;
|
|
2499
|
+
(P = d[A]) ? (G = y[O]) ? (delete d[P.end], delete y[G.start], P === G ? (P.ring.push(x), h(P.ring)) : y[P.start] = d[G.end] = { start: P.start, end: G.end, ring: P.ring.concat(G.ring) }) : (delete d[P.end], P.ring.push(x), d[P.end = O] = P) : (P = y[O]) ? (G = d[A]) ? (delete y[P.start], delete d[G.end], P === G ? (P.ring.push(x), h(P.ring)) : y[G.start] = d[P.end] = { start: G.start, end: P.end, ring: G.ring.concat(P.ring) }) : (delete y[P.start], P.ring.unshift(R), y[P.start = A] = P) : y[A] = d[O] = { start: A, end: O, ring: [R, x] };
|
|
2585
2500
|
}
|
|
2586
2501
|
}
|
|
2587
|
-
function
|
|
2588
|
-
return
|
|
2502
|
+
function a(u) {
|
|
2503
|
+
return u[0] * 2 + u[1] * (r + 1) * 4;
|
|
2589
2504
|
}
|
|
2590
|
-
function u
|
|
2591
|
-
|
|
2592
|
-
var d = y[0], I = y[1], b = d | 0, S = I | 0,
|
|
2593
|
-
d > 0 && d < r && b === d && (y[0] =
|
|
2505
|
+
function l(u, c, h) {
|
|
2506
|
+
u.forEach(function(y) {
|
|
2507
|
+
var d = y[0], I = y[1], b = d | 0, S = I | 0, m = ae(c[S * r + b]);
|
|
2508
|
+
d > 0 && d < r && b === d && (y[0] = Oe(d, ae(c[S * r + b - 1]), m, h)), I > 0 && I < e && S === I && (y[1] = Oe(I, ae(c[(S - 1) * r + b]), m, h));
|
|
2594
2509
|
});
|
|
2595
2510
|
}
|
|
2596
|
-
return s.contour = i, s.size = function(
|
|
2511
|
+
return s.contour = i, s.size = function(u) {
|
|
2597
2512
|
if (!arguments.length) return [r, e];
|
|
2598
|
-
var c = Math.floor(
|
|
2513
|
+
var c = Math.floor(u[0]), h = Math.floor(u[1]);
|
|
2599
2514
|
if (!(c >= 0 && h >= 0)) throw new Error("invalid size");
|
|
2600
2515
|
return r = c, e = h, s;
|
|
2601
|
-
}, s.thresholds = function(
|
|
2602
|
-
return arguments.length ? (t = typeof
|
|
2603
|
-
}, s.smooth = function(
|
|
2604
|
-
return arguments.length ? (n =
|
|
2516
|
+
}, s.thresholds = function(u) {
|
|
2517
|
+
return arguments.length ? (t = typeof u == "function" ? u : Array.isArray(u) ? Be(Ot.call(u)) : Be(u), s) : t;
|
|
2518
|
+
}, s.smooth = function(u) {
|
|
2519
|
+
return arguments.length ? (n = u ? l : Wt, s) : n === l;
|
|
2605
2520
|
}, s;
|
|
2606
2521
|
}
|
|
2607
|
-
function
|
|
2522
|
+
function Ht(r) {
|
|
2608
2523
|
return isFinite(r) ? r : NaN;
|
|
2609
2524
|
}
|
|
2610
|
-
function
|
|
2525
|
+
function z(r, e) {
|
|
2611
2526
|
return r == null ? !1 : +r >= e;
|
|
2612
2527
|
}
|
|
2613
2528
|
function ae(r) {
|
|
2614
2529
|
return r == null || isNaN(r = +r) ? -1 / 0 : r;
|
|
2615
2530
|
}
|
|
2616
|
-
function
|
|
2617
|
-
const s = n - e, i = t - e,
|
|
2618
|
-
return isNaN(
|
|
2531
|
+
function Oe(r, e, t, n) {
|
|
2532
|
+
const s = n - e, i = t - e, o = isFinite(s) || isFinite(i) ? s / i : Math.sign(s) / Math.sign(i);
|
|
2533
|
+
return isNaN(o) ? r : r + o - 0.5;
|
|
2619
2534
|
}
|
|
2620
|
-
const
|
|
2535
|
+
const de = 6378137, ee = 85.0511287798066, te = 1e6, V = "EPSG:4326", $ = "EPSG:3857", qt = /* @__PURE__ */ new Set([
|
|
2536
|
+
V,
|
|
2537
|
+
$
|
|
2538
|
+
]), k = Object.freeze({
|
|
2621
2539
|
enabled: !1,
|
|
2622
2540
|
radius: 6,
|
|
2623
2541
|
minProminence: 2,
|
|
@@ -2628,22 +2546,22 @@ const Fe = 6378137, De = 85.0511287798066, ee = 1e6, $ = Object.freeze({
|
|
|
2628
2546
|
excludeBoundary: !0,
|
|
2629
2547
|
smoothingIterations: 1
|
|
2630
2548
|
});
|
|
2631
|
-
function
|
|
2549
|
+
function L(r, e = null) {
|
|
2632
2550
|
const t = Number(r);
|
|
2633
2551
|
return Number.isFinite(t) ? t : e;
|
|
2634
2552
|
}
|
|
2635
|
-
function
|
|
2553
|
+
function Ke(r, e) {
|
|
2636
2554
|
return Object.prototype.hasOwnProperty.call(r || {}, e);
|
|
2637
2555
|
}
|
|
2638
|
-
function
|
|
2556
|
+
function Ie(r) {
|
|
2639
2557
|
if (Array.isArray(r) && r.length >= 4) {
|
|
2640
|
-
const [i,
|
|
2641
|
-
if ([i,
|
|
2558
|
+
const [i, o, a, l] = r.map(Number);
|
|
2559
|
+
if ([i, o, a, l].every(Number.isFinite))
|
|
2642
2560
|
return {
|
|
2643
|
-
startLon: Math.min(i,
|
|
2644
|
-
startLat: Math.min(
|
|
2645
|
-
endLon: Math.max(i,
|
|
2646
|
-
endLat: Math.max(
|
|
2561
|
+
startLon: Math.min(i, a),
|
|
2562
|
+
startLat: Math.min(o, l),
|
|
2563
|
+
endLon: Math.max(i, a),
|
|
2564
|
+
endLat: Math.max(o, l)
|
|
2647
2565
|
};
|
|
2648
2566
|
}
|
|
2649
2567
|
if (!r || typeof r != "object")
|
|
@@ -2656,198 +2574,280 @@ function He(r) {
|
|
|
2656
2574
|
endLat: Math.max(t, s)
|
|
2657
2575
|
} : null;
|
|
2658
2576
|
}
|
|
2659
|
-
function
|
|
2577
|
+
function Xt(r = "") {
|
|
2660
2578
|
const e = String(r || "").trim().toUpperCase().replace("::", ":");
|
|
2661
|
-
return ["3857", "
|
|
2579
|
+
return ["3857", "EPSG3857", "EPSG:3857", "EPSG900913", "EPSG:900913", "900913"].includes(
|
|
2580
|
+
e
|
|
2581
|
+
) ? "EPSG:3857" : ["4326", "EPSG4326", "EPSG:4326", "WGS84", "WGS 84"].includes(e) ? "EPSG:4326" : e;
|
|
2582
|
+
}
|
|
2583
|
+
function _(r) {
|
|
2584
|
+
return r != null && String(r).trim() !== "";
|
|
2662
2585
|
}
|
|
2663
|
-
function
|
|
2664
|
-
|
|
2665
|
-
|
|
2586
|
+
function me(r = {}, e = !1) {
|
|
2587
|
+
return _(r.sourceProjectionCrs) ? r.sourceProjectionCrs : _(r.sourceProjection) ? r.sourceProjection : e && _(r.projection) ? r.projection : "";
|
|
2588
|
+
}
|
|
2589
|
+
function ge(r = {}) {
|
|
2590
|
+
return _(r.defaultSourceProjectionCrs) ? r.defaultSourceProjectionCrs : "";
|
|
2591
|
+
}
|
|
2592
|
+
function Y(r, e = V) {
|
|
2593
|
+
const t = Xt(r) || e;
|
|
2594
|
+
if (!qt.has(t))
|
|
2595
|
+
throw new Error(
|
|
2596
|
+
`暂不支持栅格投影“${t || r}”,当前仅支持 EPSG:4326 和 EPSG:3857。`
|
|
2597
|
+
);
|
|
2598
|
+
return t;
|
|
2599
|
+
}
|
|
2600
|
+
function Kt(r = []) {
|
|
2601
|
+
if (!Array.isArray(r) || r.length < 4) return !1;
|
|
2602
|
+
const [e, t, n, s] = r.slice(0, 4).map(Number);
|
|
2603
|
+
return [e, t, n, s].every(Number.isFinite) && e <= n && t <= s && n - e <= 360 && Math.abs(e) <= 360 && Math.abs(n) <= 360 && Math.abs(t) <= 90 && Math.abs(s) <= 90;
|
|
2604
|
+
}
|
|
2605
|
+
function Zt(r = {}, e = {}, t = []) {
|
|
2606
|
+
const n = me(r);
|
|
2607
|
+
if (n)
|
|
2608
|
+
return Y(n, "");
|
|
2609
|
+
if (_(e.ProjectedCSTypeGeoKey)) {
|
|
2610
|
+
const o = Number(e.ProjectedCSTypeGeoKey);
|
|
2611
|
+
if (o === 3857 || o === 900913)
|
|
2612
|
+
return $;
|
|
2613
|
+
throw new Error(
|
|
2614
|
+
`暂不支持 GeoTIFF 投影“EPSG:${e.ProjectedCSTypeGeoKey}”,当前仅支持 EPSG:4326 和 EPSG:3857。`
|
|
2615
|
+
);
|
|
2616
|
+
}
|
|
2617
|
+
const s = Number(e.GTModelTypeGeoKey);
|
|
2618
|
+
if (_(e.GTModelTypeGeoKey) && [1, 3].includes(s))
|
|
2619
|
+
throw new Error(
|
|
2620
|
+
"GeoTIFF 声明了未识别的投影坐标系,请通过 sourceProjectionCrs 显式指定 EPSG:3857。"
|
|
2621
|
+
);
|
|
2622
|
+
if (_(e.GeographicTypeGeoKey)) {
|
|
2623
|
+
if (Number(e.GeographicTypeGeoKey) === 4326)
|
|
2624
|
+
return V;
|
|
2625
|
+
throw new Error(
|
|
2626
|
+
`暂不支持 GeoTIFF 地理坐标系“EPSG:${e.GeographicTypeGeoKey}”,当前仅支持 EPSG:4326。`
|
|
2627
|
+
);
|
|
2628
|
+
}
|
|
2629
|
+
if (_(e.GTModelTypeGeoKey) && s === 2)
|
|
2630
|
+
throw new Error(
|
|
2631
|
+
"GeoTIFF 只声明了地理坐标模型,但缺少具体 CRS,请通过 sourceProjectionCrs 显式指定。"
|
|
2632
|
+
);
|
|
2633
|
+
const i = ge(r);
|
|
2634
|
+
if (i)
|
|
2635
|
+
return Y(i, "");
|
|
2636
|
+
if (Kt(t)) return V;
|
|
2637
|
+
throw new Error(
|
|
2638
|
+
"无法识别 GeoTIFF 投影,请通过 sourceProjectionCrs 显式指定 EPSG:4326 或 EPSG:3857。"
|
|
2639
|
+
);
|
|
2666
2640
|
}
|
|
2667
|
-
function
|
|
2668
|
-
const t = Number(r) /
|
|
2641
|
+
function fe(r, e) {
|
|
2642
|
+
const t = Number(r) / de * (180 / Math.PI), n = (2 * Math.atan(Math.exp(Number(e) / de)) - Math.PI / 2) * (180 / Math.PI);
|
|
2669
2643
|
return {
|
|
2670
2644
|
lng: t,
|
|
2671
|
-
lat: Math.min(Math.max(n, -
|
|
2645
|
+
lat: Math.min(Math.max(n, -ee), ee)
|
|
2672
2646
|
};
|
|
2673
2647
|
}
|
|
2674
|
-
function
|
|
2648
|
+
function Jt(r) {
|
|
2675
2649
|
return !Number.isFinite(r) || r >= -180 && r <= 180 ? r : ((r + 180) % 360 + 360) % 360 - 180;
|
|
2676
2650
|
}
|
|
2677
|
-
function
|
|
2678
|
-
|
|
2679
|
-
if (
|
|
2680
|
-
|
|
2651
|
+
function je(r) {
|
|
2652
|
+
const e = Number(r);
|
|
2653
|
+
if (!Number.isFinite(e) || Math.abs(e) > ee)
|
|
2654
|
+
throw new Error(
|
|
2655
|
+
`EPSG:3857 栅格的纬度范围不能超过 ±${ee}°。`
|
|
2656
|
+
);
|
|
2657
|
+
const t = e * Math.PI / 180;
|
|
2658
|
+
return de * Math.log(Math.tan(Math.PI / 4 + t / 2));
|
|
2659
|
+
}
|
|
2660
|
+
function _e({ area: r, projection: e, width: t, height: n, isSplit: s }) {
|
|
2661
|
+
let i = Ie(r);
|
|
2662
|
+
if (s && i && Math.abs(i.endLon - i.startLon) >= 359.999 && (i = {
|
|
2663
|
+
...i,
|
|
2681
2664
|
startLon: -180,
|
|
2682
2665
|
endLon: 180
|
|
2683
|
-
}),
|
|
2684
|
-
|
|
2666
|
+
}), !i)
|
|
2667
|
+
throw new Error("栅格缺少有效的地理范围。");
|
|
2668
|
+
const o = i.endLon - i.startLon;
|
|
2669
|
+
if (o === 0 || i.endLat === i.startLat)
|
|
2670
|
+
throw new Error("栅格地理范围无效,宽度或高度为 0。");
|
|
2671
|
+
const a = e === $ ? je(i.startLat) : i.startLat, l = e === $ ? je(i.endLat) : i.endLat, u = l - a;
|
|
2672
|
+
return {
|
|
2673
|
+
area: i,
|
|
2674
|
+
projection: e,
|
|
2675
|
+
map(c, h) {
|
|
2676
|
+
const y = l - h / n * u;
|
|
2677
|
+
return [
|
|
2678
|
+
e === $ ? fe(0, y).lat : y,
|
|
2679
|
+
Jt(i.startLon + c / t * o)
|
|
2680
|
+
];
|
|
2681
|
+
}
|
|
2682
|
+
};
|
|
2683
|
+
}
|
|
2684
|
+
function be({
|
|
2685
|
+
area: r,
|
|
2686
|
+
bbox: e,
|
|
2687
|
+
projection: t,
|
|
2688
|
+
bboxProjection: n,
|
|
2689
|
+
width: s,
|
|
2690
|
+
height: i,
|
|
2691
|
+
isSplit: o = !1
|
|
2692
|
+
}) {
|
|
2693
|
+
const a = Y(t), l = Ie(r);
|
|
2694
|
+
if (l)
|
|
2685
2695
|
return {
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2696
|
+
..._e({
|
|
2697
|
+
area: l,
|
|
2698
|
+
projection: a,
|
|
2699
|
+
width: s,
|
|
2700
|
+
height: i,
|
|
2701
|
+
isSplit: o
|
|
2702
|
+
}),
|
|
2703
|
+
bboxProjection: V
|
|
2694
2704
|
};
|
|
2695
|
-
|
|
2696
|
-
if (!Array.isArray(e) || e.length < 4 || !e.slice(0, 4).every(Number.isFinite))
|
|
2705
|
+
if (!Array.isArray(e) || e.length < 4)
|
|
2697
2706
|
throw new Error("栅格缺少地理范围,请通过 area 提供 [west, south, east, north]。");
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
const h = l - o, y = c - u;
|
|
2701
|
-
if (h === 0 || y === 0)
|
|
2707
|
+
const [u, c, h, y] = e.slice(0, 4).map(Number);
|
|
2708
|
+
if (![u, c, h, y].every(Number.isFinite) || h === u || y === c)
|
|
2702
2709
|
throw new Error("栅格地理范围无效,宽度或高度为 0。");
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2710
|
+
const d = Y(
|
|
2711
|
+
n,
|
|
2712
|
+
a
|
|
2713
|
+
), I = d === $ ? fe(u, c) : { lng: u, lat: c }, b = d === $ ? fe(h, y) : { lng: h, lat: y };
|
|
2714
|
+
return {
|
|
2715
|
+
..._e({
|
|
2706
2716
|
area: {
|
|
2707
|
-
startLon:
|
|
2708
|
-
startLat:
|
|
2709
|
-
endLon:
|
|
2710
|
-
endLat:
|
|
2717
|
+
startLon: I.lng,
|
|
2718
|
+
startLat: I.lat,
|
|
2719
|
+
endLon: b.lng,
|
|
2720
|
+
endLat: b.lat
|
|
2711
2721
|
},
|
|
2712
|
-
projection:
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
return [g.lat, le(g.lng)];
|
|
2719
|
-
}
|
|
2720
|
-
};
|
|
2721
|
-
}
|
|
2722
|
-
if (t && t !== "EPSG:4326")
|
|
2723
|
-
throw new Error(`暂不支持 ${t} 栅格,请传入 WGS84 area 覆盖原始范围。`);
|
|
2724
|
-
return {
|
|
2725
|
-
area: {
|
|
2726
|
-
startLon: o,
|
|
2727
|
-
startLat: u,
|
|
2728
|
-
endLon: l,
|
|
2729
|
-
endLat: c
|
|
2730
|
-
},
|
|
2731
|
-
projection: t || "EPSG:4326",
|
|
2732
|
-
map(d, I) {
|
|
2733
|
-
return [c - I / s * y, le(o + d / n * h)];
|
|
2734
|
-
}
|
|
2722
|
+
projection: a,
|
|
2723
|
+
width: s,
|
|
2724
|
+
height: i,
|
|
2725
|
+
isSplit: o
|
|
2726
|
+
}),
|
|
2727
|
+
bboxProjection: d
|
|
2735
2728
|
};
|
|
2736
2729
|
}
|
|
2737
|
-
function
|
|
2730
|
+
function Qt(r = {}) {
|
|
2738
2731
|
const e = String(r.sourceType || r.dataType || "").toLowerCase();
|
|
2739
2732
|
return ["tif", "tiff", "geotiff"].includes(e) ? "geotiff" : ["gray", "grey", "grayscale", "greyscale", "image"].includes(e) ? "grayscale" : ["grid", "array", "values"].includes(e) ? "grid" : r.tifUrl || r.tiffUrl || r.arrayBuffer ? "geotiff" : r.grayImageUrl || r.imageUrl ? "grayscale" : r.values || r.data || r.grid ? "grid" : "";
|
|
2740
2733
|
}
|
|
2741
|
-
function
|
|
2734
|
+
function er() {
|
|
2742
2735
|
return typeof window > "u" ? null : window.GeoTIFF || null;
|
|
2743
2736
|
}
|
|
2744
|
-
function
|
|
2737
|
+
function tr(r, e = {}, t = null) {
|
|
2745
2738
|
if (!Number.isFinite(r)) return !0;
|
|
2746
|
-
const n =
|
|
2739
|
+
const n = Ke(e, "noDataValue") ? Number(e.noDataValue) : t;
|
|
2747
2740
|
if (Number.isFinite(n) && r === n) return !0;
|
|
2748
|
-
const s =
|
|
2741
|
+
const s = L(e.validMin), i = L(e.validMax);
|
|
2749
2742
|
return s !== null && r < s || i !== null && r > i;
|
|
2750
2743
|
}
|
|
2751
|
-
function
|
|
2752
|
-
const n =
|
|
2753
|
-
for (let
|
|
2754
|
-
const
|
|
2755
|
-
i[
|
|
2744
|
+
function Ze(r, e = {}, t = null) {
|
|
2745
|
+
const n = L(e.scale, 1), s = L(e.offset, 0), i = new Float64Array(r.length);
|
|
2746
|
+
for (let o = 0; o < r.length; o += 1) {
|
|
2747
|
+
const a = Number(r[o]);
|
|
2748
|
+
i[o] = tr(a, e, t) ? Number.NaN : a * n + s;
|
|
2756
2749
|
}
|
|
2757
2750
|
return i;
|
|
2758
2751
|
}
|
|
2759
|
-
function
|
|
2752
|
+
function Je(r, e, t) {
|
|
2760
2753
|
const n = new Float64Array(r.length), s = Math.floor(e / 2);
|
|
2761
2754
|
for (let i = 0; i < t; i += 1)
|
|
2762
|
-
for (let
|
|
2763
|
-
const
|
|
2764
|
-
n[i * e +
|
|
2755
|
+
for (let o = 0; o < e; o += 1) {
|
|
2756
|
+
const a = (o + s) % e;
|
|
2757
|
+
n[i * e + o] = r[i * e + a];
|
|
2765
2758
|
}
|
|
2766
2759
|
return n;
|
|
2767
2760
|
}
|
|
2768
|
-
async function
|
|
2769
|
-
var
|
|
2770
|
-
const e =
|
|
2761
|
+
async function rr(r = {}) {
|
|
2762
|
+
var v, p, C;
|
|
2763
|
+
const e = er();
|
|
2771
2764
|
if (!e)
|
|
2772
2765
|
throw new Error("GeoTIFF 未加载,请先提供 window.GeoTIFF。");
|
|
2773
2766
|
let t = r.arrayBuffer || null;
|
|
2774
2767
|
const n = r.tifUrl || r.tiffUrl || "";
|
|
2775
2768
|
if (!t) {
|
|
2776
2769
|
if (!n) throw new Error("GeoTIFF 数据源缺少 tifUrl。");
|
|
2777
|
-
t = (await
|
|
2778
|
-
}
|
|
2779
|
-
const s = await e.fromArrayBuffer(t), i = Math.max(Math.floor(
|
|
2780
|
-
if (
|
|
2781
|
-
throw new Error(`GeoTIFF 不存在第 ${
|
|
2782
|
-
const c = { samples: [
|
|
2783
|
-
let d =
|
|
2784
|
-
r.isSplit && (d =
|
|
2770
|
+
t = (await et.get(n, { responseType: "arraybuffer" })).data;
|
|
2771
|
+
}
|
|
2772
|
+
const s = await e.fromArrayBuffer(t), i = Math.max(Math.floor(L(r.imageIndex, 0)), 0), o = await s.getImage(i), a = o.getWidth(), l = o.getHeight(), u = Math.max(Math.floor(L(r.band, 0)), 0);
|
|
2773
|
+
if (u >= o.getSamplesPerPixel())
|
|
2774
|
+
throw new Error(`GeoTIFF 不存在第 ${u} 个波段。`);
|
|
2775
|
+
const c = { samples: [u], interleave: !1 }, h = await o.readRasters(c), y = L((v = o.getGDALNoData) == null ? void 0 : v.call(o));
|
|
2776
|
+
let d = Ze(h[0], r, y);
|
|
2777
|
+
r.isSplit && (d = Je(d, a, l));
|
|
2785
2778
|
let I = [];
|
|
2786
2779
|
try {
|
|
2787
|
-
I = ((p =
|
|
2788
|
-
} catch (
|
|
2789
|
-
if (!r.area) throw
|
|
2780
|
+
I = ((p = o.getBoundingBox) == null ? void 0 : p.call(o)) || [];
|
|
2781
|
+
} catch (w) {
|
|
2782
|
+
if (!r.area) throw w;
|
|
2790
2783
|
}
|
|
2791
|
-
const b = ((
|
|
2784
|
+
const b = ((C = o.getGeoKeys) == null ? void 0 : C.call(o)) || {}, S = Zt(r, b, I), m = be({
|
|
2792
2785
|
area: r.area,
|
|
2793
2786
|
bbox: I,
|
|
2794
2787
|
projection: S,
|
|
2795
|
-
|
|
2796
|
-
|
|
2788
|
+
bboxProjection: r.area ? V : S,
|
|
2789
|
+
width: a,
|
|
2790
|
+
height: l,
|
|
2797
2791
|
isSplit: r.isSplit
|
|
2798
2792
|
});
|
|
2799
2793
|
return {
|
|
2800
2794
|
sourceType: "geotiff",
|
|
2801
2795
|
sourceUrl: n,
|
|
2802
|
-
width:
|
|
2803
|
-
height:
|
|
2796
|
+
width: a,
|
|
2797
|
+
height: l,
|
|
2804
2798
|
values: d,
|
|
2799
|
+
sourceProjectionCrs: S,
|
|
2805
2800
|
sourceProjection: S,
|
|
2806
|
-
projection:
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2801
|
+
projection: m.projection,
|
|
2802
|
+
bboxProjection: m.bboxProjection,
|
|
2803
|
+
area: m.area,
|
|
2804
|
+
mapCoordinate: m.map,
|
|
2805
|
+
band: u
|
|
2810
2806
|
};
|
|
2811
2807
|
}
|
|
2812
|
-
function
|
|
2808
|
+
function nr(r) {
|
|
2813
2809
|
return new Promise((e, t) => {
|
|
2814
2810
|
const n = new Image();
|
|
2815
2811
|
n.crossOrigin = "anonymous", n.onload = () => e(n), n.onerror = () => t(new Error(`灰度图加载失败:${r}`)), n.src = r;
|
|
2816
2812
|
});
|
|
2817
2813
|
}
|
|
2818
|
-
function
|
|
2814
|
+
function sr(r, e, t = "luminance") {
|
|
2819
2815
|
return t === "red" ? r[e] : t === "green" ? r[e + 1] : t === "blue" ? r[e + 2] : t === "average" ? (r[e] + r[e + 1] + r[e + 2]) / 3 : r[e] * 0.2126 + r[e + 1] * 0.7152 + r[e + 2] * 0.0722;
|
|
2820
2816
|
}
|
|
2821
|
-
async function
|
|
2817
|
+
async function ir(r = {}) {
|
|
2822
2818
|
if (typeof document > "u" || typeof Image > "u")
|
|
2823
2819
|
throw new Error("灰度图解析只能在浏览器环境中运行。");
|
|
2824
|
-
const e = r.grayImageUrl || r.imageUrl || "", t =
|
|
2820
|
+
const e = r.grayImageUrl || r.imageUrl || "", t = Ie(r.area);
|
|
2825
2821
|
if (!e) throw new Error("灰度图数据源缺少 grayImageUrl 或 imageUrl。");
|
|
2826
2822
|
if (!t) throw new Error("灰度图没有地理信息,必须通过 area 提供覆盖范围。");
|
|
2827
|
-
const n = await
|
|
2828
|
-
|
|
2829
|
-
const
|
|
2830
|
-
if (!
|
|
2831
|
-
|
|
2832
|
-
let
|
|
2823
|
+
const n = await nr(e), s = n.naturalWidth || n.width, i = n.naturalHeight || n.height, o = document.createElement("canvas");
|
|
2824
|
+
o.width = s, o.height = i;
|
|
2825
|
+
const a = o.getContext("2d", { willReadFrequently: !0 });
|
|
2826
|
+
if (!a) throw new Error("当前浏览器不支持 Canvas 2D。");
|
|
2827
|
+
a.drawImage(n, 0, 0, s, i);
|
|
2828
|
+
let l;
|
|
2833
2829
|
try {
|
|
2834
|
-
|
|
2835
|
-
} catch (
|
|
2836
|
-
throw new Error(`灰度图像素读取失败,请检查图片 CORS:${(
|
|
2837
|
-
}
|
|
2838
|
-
const
|
|
2839
|
-
for (let
|
|
2840
|
-
for (let
|
|
2841
|
-
const x = (
|
|
2842
|
-
if (
|
|
2843
|
-
|
|
2830
|
+
l = a.getImageData(0, 0, s, i).data;
|
|
2831
|
+
} catch (w) {
|
|
2832
|
+
throw new Error(`灰度图像素读取失败,请检查图片 CORS:${(w == null ? void 0 : w.message) || ""}`);
|
|
2833
|
+
}
|
|
2834
|
+
const u = L(r.grayMinValue, 0), c = L(r.grayMaxValue, 255), h = L(r.minValue, u), y = L(r.maxValue, c), d = c - u, I = String(r.grayChannel || r.grayMode || "luminance").toLowerCase(), b = Ke(r, "noDataValue"), S = Number(r.noDataValue), m = r.isSplit ? Math.floor(s / 2) : 0, v = new Float64Array(s * i);
|
|
2835
|
+
for (let w = 0; w < i; w += 1)
|
|
2836
|
+
for (let R = 0; R < s; R += 1) {
|
|
2837
|
+
const x = (R + m) % s, A = (w * s + x) * 4, O = w * s + R, P = sr(l, A, I);
|
|
2838
|
+
if (l[A + 3] === 0 || b && Math.abs(P - S) < 0.5) {
|
|
2839
|
+
v[O] = Number.NaN;
|
|
2844
2840
|
continue;
|
|
2845
2841
|
}
|
|
2846
|
-
let
|
|
2847
|
-
|
|
2842
|
+
let G = d === 0 ? 0 : (P - u) / d;
|
|
2843
|
+
G = Math.min(Math.max(G, 0), 1), r.invert && (G = 1 - G), v[O] = h + G * (y - h);
|
|
2848
2844
|
}
|
|
2849
|
-
const p =
|
|
2845
|
+
const p = Y(
|
|
2846
|
+
me(r, !0) || ge(r)
|
|
2847
|
+
), C = be({
|
|
2850
2848
|
area: t,
|
|
2849
|
+
projection: p,
|
|
2850
|
+
bboxProjection: V,
|
|
2851
2851
|
width: s,
|
|
2852
2852
|
height: i,
|
|
2853
2853
|
isSplit: r.isSplit
|
|
@@ -2857,11 +2857,13 @@ async function ar(r = {}) {
|
|
|
2857
2857
|
sourceUrl: e,
|
|
2858
2858
|
width: s,
|
|
2859
2859
|
height: i,
|
|
2860
|
-
values:
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2860
|
+
values: v,
|
|
2861
|
+
sourceProjectionCrs: p,
|
|
2862
|
+
sourceProjection: p,
|
|
2863
|
+
projection: C.projection,
|
|
2864
|
+
bboxProjection: C.bboxProjection,
|
|
2865
|
+
area: C.area,
|
|
2866
|
+
mapCoordinate: C.map,
|
|
2865
2867
|
band: 0
|
|
2866
2868
|
};
|
|
2867
2869
|
}
|
|
@@ -2870,29 +2872,32 @@ function or(r = {}) {
|
|
|
2870
2872
|
const e = r.values || r.data || r.grid;
|
|
2871
2873
|
if (!e) return null;
|
|
2872
2874
|
if (Array.isArray(e) && Array.isArray(e[0])) {
|
|
2873
|
-
const i = e.length,
|
|
2874
|
-
if (!
|
|
2875
|
+
const i = e.length, o = ((s = e[0]) == null ? void 0 : s.length) || 0;
|
|
2876
|
+
if (!o || e.some((a) => !Array.isArray(a) || a.length !== o))
|
|
2875
2877
|
throw new Error("二维数值网格的每一行长度必须一致。");
|
|
2876
2878
|
return {
|
|
2877
|
-
width:
|
|
2879
|
+
width: o,
|
|
2878
2880
|
height: i,
|
|
2879
2881
|
values: e.flat()
|
|
2880
2882
|
};
|
|
2881
2883
|
}
|
|
2882
|
-
const t = Math.floor(
|
|
2884
|
+
const t = Math.floor(L(r.width, 0)), n = Math.floor(L(r.height, 0));
|
|
2883
2885
|
if (t < 2 || n < 2 || e.length < t * n)
|
|
2884
2886
|
throw new Error("一维数值网格必须提供正确的 width 和 height。");
|
|
2885
2887
|
return { width: t, height: n, values: e };
|
|
2886
2888
|
}
|
|
2887
|
-
function
|
|
2889
|
+
function ar(r = {}) {
|
|
2888
2890
|
const e = or(r);
|
|
2889
2891
|
if (!e) throw new Error("数值网格缺少 values、data 或 grid。");
|
|
2890
|
-
let t =
|
|
2891
|
-
r.isSplit && (t =
|
|
2892
|
-
const n =
|
|
2892
|
+
let t = Ze(e.values, r);
|
|
2893
|
+
r.isSplit && (t = Je(t, e.width, e.height));
|
|
2894
|
+
const n = Y(
|
|
2895
|
+
me(r, !0) || ge(r)
|
|
2896
|
+
), s = be({
|
|
2893
2897
|
area: r.area,
|
|
2894
2898
|
bbox: r.bbox,
|
|
2895
|
-
projection:
|
|
2899
|
+
projection: n,
|
|
2900
|
+
bboxProjection: r.area ? V : r.bboxProjection || n,
|
|
2896
2901
|
width: e.width,
|
|
2897
2902
|
height: e.height,
|
|
2898
2903
|
isSplit: r.isSplit
|
|
@@ -2903,21 +2908,23 @@ function lr(r = {}) {
|
|
|
2903
2908
|
width: e.width,
|
|
2904
2909
|
height: e.height,
|
|
2905
2910
|
values: t,
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2911
|
+
sourceProjectionCrs: n,
|
|
2912
|
+
sourceProjection: n,
|
|
2913
|
+
projection: s.projection,
|
|
2914
|
+
bboxProjection: s.bboxProjection,
|
|
2915
|
+
area: s.area,
|
|
2916
|
+
mapCoordinate: s.map,
|
|
2910
2917
|
band: 0
|
|
2911
2918
|
};
|
|
2912
2919
|
}
|
|
2913
|
-
async function
|
|
2914
|
-
const e =
|
|
2915
|
-
if (e === "geotiff") return
|
|
2916
|
-
if (e === "grayscale") return
|
|
2917
|
-
if (e === "grid") return
|
|
2920
|
+
async function lr(r = {}) {
|
|
2921
|
+
const e = Qt(r);
|
|
2922
|
+
if (e === "geotiff") return rr(r);
|
|
2923
|
+
if (e === "grayscale") return ir(r);
|
|
2924
|
+
if (e === "grid") return ar(r);
|
|
2918
2925
|
throw new Error("无法识别栅格数据源,请提供 tifUrl、grayImageUrl 或 values。");
|
|
2919
2926
|
}
|
|
2920
|
-
function
|
|
2927
|
+
function ur(r) {
|
|
2921
2928
|
let e = Number.POSITIVE_INFINITY, t = Number.NEGATIVE_INFINITY, n = 0;
|
|
2922
2929
|
for (let s = 0; s < r.length; s += 1) {
|
|
2923
2930
|
const i = Number(r[s]);
|
|
@@ -2926,27 +2933,27 @@ function cr(r) {
|
|
|
2926
2933
|
if (!n) throw new Error("栅格中没有可用于生成等值线的有效数值。");
|
|
2927
2934
|
return { min: e, max: t, validCount: n, noDataCount: r.length - n };
|
|
2928
2935
|
}
|
|
2929
|
-
function
|
|
2930
|
-
const t = Math.max(Math.floor(
|
|
2936
|
+
function cr(r, e = te) {
|
|
2937
|
+
const t = Math.max(Math.floor(L(e, te)), 4);
|
|
2931
2938
|
if (r.width * r.height <= t)
|
|
2932
2939
|
return r;
|
|
2933
|
-
const n = Math.sqrt(t / (r.width * r.height)), s = Math.max(Math.floor(r.width * n), 2), i = Math.max(Math.floor(r.height * n), 2),
|
|
2934
|
-
for (let
|
|
2935
|
-
const
|
|
2936
|
-
for (let
|
|
2937
|
-
const c = Math.round(
|
|
2938
|
-
a
|
|
2940
|
+
const n = Math.sqrt(t / (r.width * r.height)), s = Math.max(Math.floor(r.width * n), 2), i = Math.max(Math.floor(r.height * n), 2), o = new Float64Array(s * i);
|
|
2941
|
+
for (let a = 0; a < i; a += 1) {
|
|
2942
|
+
const l = Math.round(a / Math.max(i - 1, 1) * (r.height - 1));
|
|
2943
|
+
for (let u = 0; u < s; u += 1) {
|
|
2944
|
+
const c = Math.round(u / Math.max(s - 1, 1) * (r.width - 1));
|
|
2945
|
+
o[a * s + u] = r.values[l * r.width + c];
|
|
2939
2946
|
}
|
|
2940
2947
|
}
|
|
2941
2948
|
return {
|
|
2942
2949
|
...r,
|
|
2943
2950
|
width: s,
|
|
2944
2951
|
height: i,
|
|
2945
|
-
values:
|
|
2946
|
-
mapCoordinate(
|
|
2952
|
+
values: o,
|
|
2953
|
+
mapCoordinate(a, l) {
|
|
2947
2954
|
return r.mapCoordinate(
|
|
2948
|
-
|
|
2949
|
-
|
|
2955
|
+
a / s * r.width,
|
|
2956
|
+
l / i * r.height
|
|
2950
2957
|
);
|
|
2951
2958
|
},
|
|
2952
2959
|
downsampled: !0,
|
|
@@ -2954,108 +2961,108 @@ function hr(r, e = ee) {
|
|
|
2954
2961
|
originalHeight: r.height
|
|
2955
2962
|
};
|
|
2956
2963
|
}
|
|
2957
|
-
function
|
|
2964
|
+
function Ve(r, e = 10) {
|
|
2958
2965
|
const t = 10 ** e;
|
|
2959
2966
|
return Math.round(r * t) / t;
|
|
2960
2967
|
}
|
|
2961
|
-
function
|
|
2968
|
+
function hr(r, e = {}) {
|
|
2962
2969
|
const t = e.thresholds || e.levels;
|
|
2963
2970
|
if (Array.isArray(t))
|
|
2964
|
-
return [...new Set(t.map(Number).filter(Number.isFinite))].filter((
|
|
2965
|
-
const n =
|
|
2971
|
+
return [...new Set(t.map(Number).filter(Number.isFinite))].filter((o) => o > r.min && o < r.max).sort((o, a) => o - a);
|
|
2972
|
+
const n = L(e.interval ?? e.contourInterval);
|
|
2966
2973
|
if (n !== null && n > 0) {
|
|
2967
|
-
const
|
|
2968
|
-
let
|
|
2969
|
-
for (;
|
|
2970
|
-
|
|
2971
|
-
return
|
|
2974
|
+
const o = [];
|
|
2975
|
+
let a = Math.ceil(r.min / n) * n;
|
|
2976
|
+
for (; a < r.max && o.length < 200; )
|
|
2977
|
+
a > r.min && o.push(Ve(a)), a += n;
|
|
2978
|
+
return o;
|
|
2972
2979
|
}
|
|
2973
2980
|
const s = Math.min(
|
|
2974
|
-
Math.max(Math.floor(
|
|
2981
|
+
Math.max(Math.floor(L(e.thresholdCount ?? e.levelCount, 12)), 1),
|
|
2975
2982
|
100
|
|
2976
2983
|
), i = (r.max - r.min) / (s + 1);
|
|
2977
2984
|
return Array.from(
|
|
2978
2985
|
{ length: s },
|
|
2979
|
-
(
|
|
2986
|
+
(o, a) => Ve(r.min + i * (a + 1))
|
|
2980
2987
|
);
|
|
2981
2988
|
}
|
|
2982
|
-
function
|
|
2989
|
+
function dr(r, e, t, n) {
|
|
2983
2990
|
return Math.abs(r[0]) < 1e-7 && Math.abs(e[0]) < 1e-7 || Math.abs(r[0] - t) < 1e-7 && Math.abs(e[0] - t) < 1e-7 || Math.abs(r[1]) < 1e-7 && Math.abs(e[1]) < 1e-7 || Math.abs(r[1] - n) < 1e-7 && Math.abs(e[1] - n) < 1e-7;
|
|
2984
2991
|
}
|
|
2985
|
-
function
|
|
2992
|
+
function fr(r = [], e, t) {
|
|
2986
2993
|
const n = [...r];
|
|
2987
2994
|
if (n.length > 1 && n[0][0] === n[n.length - 1][0] && n[0][1] === n[n.length - 1][1] && n.pop(), n.length < 2) return [];
|
|
2988
2995
|
const s = n.map(
|
|
2989
|
-
(
|
|
2996
|
+
(l, u) => dr(l, n[(u + 1) % n.length], e, t)
|
|
2990
2997
|
), i = s.findIndex(Boolean);
|
|
2991
2998
|
if (i < 0)
|
|
2992
2999
|
return [[...n, n[0]]];
|
|
2993
|
-
const
|
|
2994
|
-
let
|
|
2995
|
-
for (let
|
|
2996
|
-
const
|
|
2997
|
-
if (s[
|
|
2998
|
-
|
|
3000
|
+
const o = [];
|
|
3001
|
+
let a = [];
|
|
3002
|
+
for (let l = 1; l <= n.length; l += 1) {
|
|
3003
|
+
const u = (i + l) % n.length, c = (u + 1) % n.length;
|
|
3004
|
+
if (s[u]) {
|
|
3005
|
+
a.length > 1 && o.push(a), a = [];
|
|
2999
3006
|
continue;
|
|
3000
3007
|
}
|
|
3001
|
-
|
|
3008
|
+
a.length === 0 && a.push(n[u]), a.push(n[c]);
|
|
3002
3009
|
}
|
|
3003
|
-
return
|
|
3010
|
+
return a.length > 1 && o.push(a), o;
|
|
3004
3011
|
}
|
|
3005
|
-
function
|
|
3012
|
+
function yr(r = {}) {
|
|
3006
3013
|
return r.type === "Polygon" ? r.coordinates || [] : r.type === "MultiPolygon" ? (r.coordinates || []).flatMap((e) => e) : [];
|
|
3007
3014
|
}
|
|
3008
|
-
function
|
|
3015
|
+
function Ir(r, e) {
|
|
3009
3016
|
return (r == null ? void 0 : r[0]) === (e == null ? void 0 : e[0]) && (r == null ? void 0 : r[1]) === (e == null ? void 0 : e[1]);
|
|
3010
3017
|
}
|
|
3011
3018
|
function mr(r = [], e = 0) {
|
|
3012
3019
|
const t = Math.min(Math.max(Math.floor(e), 0), 3);
|
|
3013
3020
|
if (t === 0 || r.length < 3) return r;
|
|
3014
|
-
const n =
|
|
3021
|
+
const n = Ir(r[0], r[r.length - 1]);
|
|
3015
3022
|
let s = n ? r.slice(0, -1) : [...r];
|
|
3016
3023
|
for (let i = 0; i < t; i += 1) {
|
|
3017
|
-
const
|
|
3018
|
-
for (let
|
|
3019
|
-
const
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
]),
|
|
3024
|
-
|
|
3025
|
-
|
|
3024
|
+
const o = n ? [] : [s[0]], a = n ? s.length : s.length - 1;
|
|
3025
|
+
for (let l = 0; l < a; l += 1) {
|
|
3026
|
+
const u = s[l], c = s[(l + 1) % s.length];
|
|
3027
|
+
o.push([
|
|
3028
|
+
u[0] * 0.75 + c[0] * 0.25,
|
|
3029
|
+
u[1] * 0.75 + c[1] * 0.25
|
|
3030
|
+
]), o.push([
|
|
3031
|
+
u[0] * 0.25 + c[0] * 0.75,
|
|
3032
|
+
u[1] * 0.25 + c[1] * 0.75
|
|
3026
3033
|
]);
|
|
3027
3034
|
}
|
|
3028
|
-
n ||
|
|
3035
|
+
n || o.push(s[s.length - 1]), s = o;
|
|
3029
3036
|
}
|
|
3030
3037
|
return n ? [...s, s[0]] : s;
|
|
3031
3038
|
}
|
|
3032
|
-
function
|
|
3039
|
+
function gr(r, e, t = 6) {
|
|
3033
3040
|
const n = 10 ** Math.max(Math.floor(t), 0), s = [];
|
|
3034
3041
|
return r.forEach((i) => {
|
|
3035
|
-
const
|
|
3036
|
-
if (!(
|
|
3037
|
-
const
|
|
3038
|
-
(!
|
|
3042
|
+
const o = e(i[0], i[1]);
|
|
3043
|
+
if (!(o != null && o.every(Number.isFinite))) return;
|
|
3044
|
+
const a = o.map((u) => Math.round(u * n) / n), l = s[s.length - 1];
|
|
3045
|
+
(!l || l[0] !== a[0] || l[1] !== a[1]) && s.push(a);
|
|
3039
3046
|
}), s;
|
|
3040
3047
|
}
|
|
3041
|
-
function
|
|
3048
|
+
function br(r = {}) {
|
|
3042
3049
|
const e = r && typeof r == "object" ? r : {};
|
|
3043
3050
|
return {
|
|
3044
3051
|
enabled: e.enabled === !0,
|
|
3045
3052
|
radius: Math.max(
|
|
3046
|
-
Math.floor(
|
|
3053
|
+
Math.floor(L(e.radius, k.radius)),
|
|
3047
3054
|
1
|
|
3048
3055
|
),
|
|
3049
3056
|
minProminence: Math.max(
|
|
3050
|
-
|
|
3057
|
+
L(e.minProminence, k.minProminence),
|
|
3051
3058
|
0
|
|
3052
3059
|
),
|
|
3053
3060
|
minGridDistance: Math.max(
|
|
3054
|
-
|
|
3061
|
+
L(e.minGridDistance, k.minGridDistance),
|
|
3055
3062
|
0
|
|
3056
3063
|
),
|
|
3057
3064
|
maxCount: Math.max(
|
|
3058
|
-
Math.floor(
|
|
3065
|
+
Math.floor(L(e.maxCount, k.maxCount)),
|
|
3059
3066
|
0
|
|
3060
3067
|
),
|
|
3061
3068
|
includeHigh: e.includeHigh !== !1,
|
|
@@ -3064,9 +3071,9 @@ function pr(r = {}) {
|
|
|
3064
3071
|
smoothingIterations: Math.min(
|
|
3065
3072
|
Math.max(
|
|
3066
3073
|
Math.floor(
|
|
3067
|
-
|
|
3074
|
+
L(
|
|
3068
3075
|
e.smoothingIterations,
|
|
3069
|
-
|
|
3076
|
+
k.smoothingIterations
|
|
3070
3077
|
)
|
|
3071
3078
|
),
|
|
3072
3079
|
0
|
|
@@ -3075,30 +3082,30 @@ function pr(r = {}) {
|
|
|
3075
3082
|
)
|
|
3076
3083
|
};
|
|
3077
3084
|
}
|
|
3078
|
-
function
|
|
3079
|
-
const e = r.width * r.height, t = e >
|
|
3085
|
+
function pr(r) {
|
|
3086
|
+
const e = r.width * r.height, t = e > te ? Math.max(Math.ceil(Math.sqrt(e / te)), 2) : 1;
|
|
3080
3087
|
if (t === 1)
|
|
3081
3088
|
return {
|
|
3082
3089
|
width: r.width,
|
|
3083
3090
|
height: r.height,
|
|
3084
3091
|
values: r.values,
|
|
3085
3092
|
stride: t,
|
|
3086
|
-
getSourceBounds(
|
|
3087
|
-
return { startX:
|
|
3093
|
+
getSourceBounds(o, a) {
|
|
3094
|
+
return { startX: o, endX: o, startY: a, endY: a };
|
|
3088
3095
|
}
|
|
3089
3096
|
};
|
|
3090
3097
|
const n = Math.ceil(r.width / t), s = Math.ceil(r.height / t), i = new Float64Array(n * s);
|
|
3091
|
-
for (let
|
|
3092
|
-
const
|
|
3093
|
-
for (let
|
|
3094
|
-
const c =
|
|
3098
|
+
for (let o = 0; o < s; o += 1) {
|
|
3099
|
+
const a = o * t, l = Math.min(a + t - 1, r.height - 1);
|
|
3100
|
+
for (let u = 0; u < n; u += 1) {
|
|
3101
|
+
const c = u * t, h = Math.min(c + t - 1, r.width - 1);
|
|
3095
3102
|
let y = 0, d = 0;
|
|
3096
|
-
for (let I =
|
|
3103
|
+
for (let I = a; I <= l; I += 1)
|
|
3097
3104
|
for (let b = c; b <= h; b += 1) {
|
|
3098
3105
|
const S = Number(r.values[I * r.width + b]);
|
|
3099
3106
|
Number.isFinite(S) && (y += S, d += 1);
|
|
3100
3107
|
}
|
|
3101
|
-
i[
|
|
3108
|
+
i[o * n + u] = d > 0 ? y / d : Number.NaN;
|
|
3102
3109
|
}
|
|
3103
3110
|
}
|
|
3104
3111
|
return {
|
|
@@ -3106,129 +3113,129 @@ function Sr(r) {
|
|
|
3106
3113
|
height: s,
|
|
3107
3114
|
values: i,
|
|
3108
3115
|
stride: t,
|
|
3109
|
-
getSourceBounds(
|
|
3110
|
-
const
|
|
3116
|
+
getSourceBounds(o, a) {
|
|
3117
|
+
const l = o * t, u = a * t;
|
|
3111
3118
|
return {
|
|
3112
|
-
startX:
|
|
3113
|
-
endX: Math.min(
|
|
3114
|
-
startY:
|
|
3115
|
-
endY: Math.min(
|
|
3119
|
+
startX: l,
|
|
3120
|
+
endX: Math.min(l + t - 1, r.width - 1),
|
|
3121
|
+
startY: u,
|
|
3122
|
+
endY: Math.min(u + t - 1, r.height - 1)
|
|
3116
3123
|
};
|
|
3117
3124
|
}
|
|
3118
3125
|
};
|
|
3119
3126
|
}
|
|
3120
|
-
function
|
|
3127
|
+
function Sr(r, e, t, n) {
|
|
3121
3128
|
let s = r;
|
|
3122
3129
|
for (let i = 0; i < n; i += 1) {
|
|
3123
|
-
const
|
|
3124
|
-
for (let
|
|
3125
|
-
for (let
|
|
3126
|
-
const
|
|
3127
|
-
if (!Number.isFinite(Number(s[
|
|
3128
|
-
|
|
3130
|
+
const o = new Float64Array(r.length);
|
|
3131
|
+
for (let a = 0; a < t; a += 1)
|
|
3132
|
+
for (let l = 0; l < e; l += 1) {
|
|
3133
|
+
const u = a * e + l;
|
|
3134
|
+
if (!Number.isFinite(Number(s[u]))) {
|
|
3135
|
+
o[u] = Number.NaN;
|
|
3129
3136
|
continue;
|
|
3130
3137
|
}
|
|
3131
3138
|
let c = 0, h = 0;
|
|
3132
3139
|
for (let y = -1; y <= 1; y += 1) {
|
|
3133
|
-
const d =
|
|
3140
|
+
const d = a + y;
|
|
3134
3141
|
if (!(d < 0 || d >= t))
|
|
3135
3142
|
for (let I = -1; I <= 1; I += 1) {
|
|
3136
|
-
const b =
|
|
3143
|
+
const b = l + I;
|
|
3137
3144
|
if (b < 0 || b >= e) continue;
|
|
3138
3145
|
const S = Number(s[d * e + b]);
|
|
3139
3146
|
Number.isFinite(S) && (c += S, h += 1);
|
|
3140
3147
|
}
|
|
3141
3148
|
}
|
|
3142
|
-
|
|
3149
|
+
o[u] = h > 0 ? c / h : Number.NaN;
|
|
3143
3150
|
}
|
|
3144
|
-
s =
|
|
3151
|
+
s = o;
|
|
3145
3152
|
}
|
|
3146
3153
|
return s;
|
|
3147
3154
|
}
|
|
3148
3155
|
function vr(r, e, t) {
|
|
3149
3156
|
const n = e + 1, s = new Float64Array(n * (t + 1)), i = new Uint32Array(n * (t + 1));
|
|
3150
|
-
for (let
|
|
3151
|
-
let
|
|
3152
|
-
for (let
|
|
3153
|
-
const c = Number(r[
|
|
3154
|
-
Number.isFinite(c) && (
|
|
3155
|
-
const h = (
|
|
3156
|
-
s[h] = s[
|
|
3157
|
+
for (let o = 0; o < t; o += 1) {
|
|
3158
|
+
let a = 0, l = 0;
|
|
3159
|
+
for (let u = 0; u < e; u += 1) {
|
|
3160
|
+
const c = Number(r[o * e + u]);
|
|
3161
|
+
Number.isFinite(c) && (a += c, l += 1);
|
|
3162
|
+
const h = (o + 1) * n + u + 1;
|
|
3163
|
+
s[h] = s[o * n + u + 1] + a, i[h] = i[o * n + u + 1] + l;
|
|
3157
3164
|
}
|
|
3158
3165
|
}
|
|
3159
3166
|
return {
|
|
3160
|
-
query(a,
|
|
3161
|
-
const c = Math.max(Math.min(
|
|
3167
|
+
query(o, a, l, u) {
|
|
3168
|
+
const c = Math.max(Math.min(o, e - 1), 0), h = Math.max(Math.min(a, t - 1), 0), y = Math.max(Math.min(l, e - 1), c), d = Math.max(Math.min(u, t - 1), h), I = h * n + c, b = h * n + y + 1, S = (d + 1) * n + c, m = (d + 1) * n + y + 1;
|
|
3162
3169
|
return {
|
|
3163
|
-
sum: s[
|
|
3164
|
-
count: i[
|
|
3170
|
+
sum: s[m] - s[b] - s[S] + s[I],
|
|
3171
|
+
count: i[m] - i[b] - i[S] + i[I],
|
|
3165
3172
|
cellCount: (y - c + 1) * (d - h + 1)
|
|
3166
3173
|
};
|
|
3167
3174
|
}
|
|
3168
3175
|
};
|
|
3169
3176
|
}
|
|
3170
3177
|
function Pr(r, e, t, n, s, i) {
|
|
3171
|
-
const
|
|
3172
|
-
if (!Number.isFinite(
|
|
3173
|
-
let
|
|
3178
|
+
const o = s * e + n, a = Number(r[o]);
|
|
3179
|
+
if (!Number.isFinite(a)) return [];
|
|
3180
|
+
let l = i.includeHigh, u = i.includeLow, c = !1, h = !1, y = 0;
|
|
3174
3181
|
for (let I = -1; I <= 1; I += 1) {
|
|
3175
3182
|
const b = s + I;
|
|
3176
3183
|
if (!(b < 0 || b >= t))
|
|
3177
3184
|
for (let S = -1; S <= 1; S += 1) {
|
|
3178
3185
|
if (S === 0 && I === 0) continue;
|
|
3179
|
-
const
|
|
3180
|
-
if (
|
|
3181
|
-
const
|
|
3186
|
+
const m = n + S;
|
|
3187
|
+
if (m < 0 || m >= e) continue;
|
|
3188
|
+
const v = b * e + m, p = Number(r[v]);
|
|
3182
3189
|
if (!Number.isFinite(p)) {
|
|
3183
3190
|
if (i.excludeBoundary) return [];
|
|
3184
3191
|
continue;
|
|
3185
3192
|
}
|
|
3186
|
-
y += 1, p >
|
|
3193
|
+
y += 1, p > a ? (l = !1, h = !0) : p < a ? (u = !1, c = !0) : v < o && (l = !1, u = !1);
|
|
3187
3194
|
}
|
|
3188
3195
|
}
|
|
3189
3196
|
if (y < 3) return [];
|
|
3190
3197
|
const d = [];
|
|
3191
|
-
return
|
|
3198
|
+
return l && c && d.push("H"), u && h && d.push("L"), d;
|
|
3192
3199
|
}
|
|
3193
|
-
function
|
|
3194
|
-
const s = e.getSourceBounds(r.gridX, r.gridY), i = (s.startX + s.endX) / 2,
|
|
3195
|
-
let
|
|
3196
|
-
for (let
|
|
3200
|
+
function Lr(r, e, t, n) {
|
|
3201
|
+
const s = e.getSourceBounds(r.gridX, r.gridY), i = (s.startX + s.endX) / 2, o = (s.startY + s.endY) / 2;
|
|
3202
|
+
let a = null;
|
|
3203
|
+
for (let u = s.startY; u <= s.endY; u += 1)
|
|
3197
3204
|
for (let c = s.startX; c <= s.endX; c += 1) {
|
|
3198
|
-
if (n.excludeBoundary && (c < n.radius ||
|
|
3205
|
+
if (n.excludeBoundary && (c < n.radius || u < n.radius || c >= t.width - n.radius || u >= t.height - n.radius))
|
|
3199
3206
|
continue;
|
|
3200
|
-
const h = Number(t.values[
|
|
3207
|
+
const h = Number(t.values[u * t.width + c]);
|
|
3201
3208
|
if (!Number.isFinite(h)) continue;
|
|
3202
|
-
const y = (c - i) ** 2 + (
|
|
3203
|
-
(d || I) && (
|
|
3209
|
+
const y = (c - i) ** 2 + (u - o) ** 2, d = r.type === "H" ? !a || h > a.value : !a || h < a.value, I = a && h === a.value && y < a.distanceToApproximate;
|
|
3210
|
+
(d || I) && (a = { x: c, y: u, value: h, distanceToApproximate: y });
|
|
3204
3211
|
}
|
|
3205
|
-
if (!
|
|
3206
|
-
const
|
|
3207
|
-
return
|
|
3212
|
+
if (!a) return null;
|
|
3213
|
+
const l = t.mapCoordinate(a.x, a.y);
|
|
3214
|
+
return l != null && l.every(Number.isFinite) ? {
|
|
3208
3215
|
...r,
|
|
3209
|
-
value:
|
|
3210
|
-
lat:
|
|
3211
|
-
lon:
|
|
3212
|
-
sourceX:
|
|
3213
|
-
sourceY:
|
|
3216
|
+
value: a.value,
|
|
3217
|
+
lat: l[0],
|
|
3218
|
+
lon: l[1],
|
|
3219
|
+
sourceX: a.x,
|
|
3220
|
+
sourceY: a.y
|
|
3214
3221
|
} : null;
|
|
3215
3222
|
}
|
|
3216
|
-
function
|
|
3223
|
+
function ye(r, e) {
|
|
3217
3224
|
return r.type !== e.type ? r.type === "H" ? -1 : 1 : (r.type === "H" ? e.value - r.value : r.value - e.value) || e.prominence - r.prominence || r.sourceY - e.sourceY || r.sourceX - e.sourceX;
|
|
3218
3225
|
}
|
|
3219
3226
|
function Cr(r, e) {
|
|
3220
3227
|
const t = e ** 2, n = [];
|
|
3221
|
-
return r.sort(
|
|
3228
|
+
return r.sort(ye).forEach((s) => {
|
|
3222
3229
|
n.some(
|
|
3223
|
-
(
|
|
3230
|
+
(o) => o.type === s.type && (o.sourceX - s.sourceX) ** 2 + (o.sourceY - s.sourceY) ** 2 < t
|
|
3224
3231
|
) || n.push(s);
|
|
3225
3232
|
}), n;
|
|
3226
3233
|
}
|
|
3227
|
-
function
|
|
3228
|
-
const t =
|
|
3234
|
+
function wr(r, e = {}) {
|
|
3235
|
+
const t = br(e);
|
|
3229
3236
|
if (!t.enabled || t.maxCount === 0 || !t.includeHigh && !t.includeLow || r.width < 3 || r.height < 3)
|
|
3230
3237
|
return [];
|
|
3231
|
-
const n =
|
|
3238
|
+
const n = pr(r), s = Sr(
|
|
3232
3239
|
n.values,
|
|
3233
3240
|
n.width,
|
|
3234
3241
|
n.height,
|
|
@@ -3237,10 +3244,10 @@ function Tr(r, e = {}) {
|
|
|
3237
3244
|
s,
|
|
3238
3245
|
n.width,
|
|
3239
3246
|
n.height
|
|
3240
|
-
),
|
|
3247
|
+
), o = Math.max(Math.ceil(t.radius / n.stride), 1), a = [];
|
|
3241
3248
|
for (let c = 0; c < n.height; c += 1)
|
|
3242
3249
|
for (let h = 0; h < n.width; h += 1) {
|
|
3243
|
-
if (t.excludeBoundary && (h <
|
|
3250
|
+
if (t.excludeBoundary && (h < o || c < o || h >= n.width - o || c >= n.height - o))
|
|
3244
3251
|
continue;
|
|
3245
3252
|
const y = Number(s[c * n.width + h]);
|
|
3246
3253
|
if (!Number.isFinite(y)) continue;
|
|
@@ -3254,63 +3261,63 @@ function Tr(r, e = {}) {
|
|
|
3254
3261
|
);
|
|
3255
3262
|
if (d.length === 0) continue;
|
|
3256
3263
|
const I = i.query(
|
|
3257
|
-
h -
|
|
3258
|
-
c -
|
|
3259
|
-
h +
|
|
3260
|
-
c +
|
|
3264
|
+
h - o,
|
|
3265
|
+
c - o,
|
|
3266
|
+
h + o,
|
|
3267
|
+
c + o
|
|
3261
3268
|
);
|
|
3262
3269
|
if (t.excludeBoundary && I.count < I.cellCount) continue;
|
|
3263
3270
|
const b = I.count - 1;
|
|
3264
3271
|
if (b < 3) continue;
|
|
3265
3272
|
const S = (I.sum - y) / b;
|
|
3266
|
-
d.forEach((
|
|
3267
|
-
const
|
|
3268
|
-
|
|
3269
|
-
type:
|
|
3270
|
-
label:
|
|
3271
|
-
prominence:
|
|
3273
|
+
d.forEach((m) => {
|
|
3274
|
+
const v = m === "H" ? y - S : S - y;
|
|
3275
|
+
v < t.minProminence || a.push({
|
|
3276
|
+
type: m,
|
|
3277
|
+
label: m,
|
|
3278
|
+
prominence: v,
|
|
3272
3279
|
gridX: h,
|
|
3273
3280
|
gridY: c
|
|
3274
3281
|
});
|
|
3275
3282
|
});
|
|
3276
3283
|
}
|
|
3277
|
-
const
|
|
3278
|
-
return Cr(
|
|
3279
|
-
(c, h) => h.prominence - c.prominence ||
|
|
3280
|
-
).slice(0, t.maxCount).sort(
|
|
3284
|
+
const l = a.map((c) => Lr(c, n, r, t)).filter(Boolean);
|
|
3285
|
+
return Cr(l, t.minGridDistance).sort(
|
|
3286
|
+
(c, h) => h.prominence - c.prominence || ye(c, h)
|
|
3287
|
+
).slice(0, t.maxCount).sort(ye).map(({ type: c, label: h, value: y, lat: d, lon: I }) => ({ type: c, label: h, value: y, lat: d, lon: I }));
|
|
3281
3288
|
}
|
|
3282
|
-
function
|
|
3283
|
-
const t =
|
|
3289
|
+
function Tr(r, e = {}) {
|
|
3290
|
+
const t = ur(r.values);
|
|
3284
3291
|
if (t.min === t.max)
|
|
3285
3292
|
throw new Error("栅格数值全部相同,无法生成等值线。");
|
|
3286
|
-
const n =
|
|
3293
|
+
const n = cr(r, e.maxCells), s = hr(t, e);
|
|
3287
3294
|
if (s.length === 0)
|
|
3288
3295
|
throw new Error("当前值域内没有可用的等值线级别。");
|
|
3289
|
-
const i =
|
|
3290
|
-
Math.floor(
|
|
3296
|
+
const i = Yt().size([n.width, n.height]).smooth(e.smooth !== !1).thresholds(s)(n.values), o = Math.max(
|
|
3297
|
+
Math.floor(L(e.minimumLinePoints, 3)),
|
|
3291
3298
|
2
|
|
3292
|
-
),
|
|
3293
|
-
Math.max(Math.floor(
|
|
3299
|
+
), a = Math.min(
|
|
3300
|
+
Math.max(Math.floor(L(e.smoothingIterations, 0)), 0),
|
|
3294
3301
|
3
|
|
3295
|
-
),
|
|
3296
|
-
const y =
|
|
3297
|
-
(d) => e.excludeBoundary === !1 ? [d] :
|
|
3298
|
-
).map((d) => mr(d,
|
|
3302
|
+
), l = i.map((c) => {
|
|
3303
|
+
const y = yr(c).flatMap(
|
|
3304
|
+
(d) => e.excludeBoundary === !1 ? [d] : fr(d, n.width, n.height)
|
|
3305
|
+
).map((d) => mr(d, a)).map((d) => gr(d, n.mapCoordinate, e.coordinatePrecision)).filter((d) => d.length >= o);
|
|
3299
3306
|
return {
|
|
3300
3307
|
value: c.value,
|
|
3301
3308
|
label: String(c.value),
|
|
3302
3309
|
lines: y
|
|
3303
3310
|
};
|
|
3304
|
-
}),
|
|
3311
|
+
}), u = wr(r, e.centerDetection);
|
|
3305
3312
|
return {
|
|
3306
|
-
isolines:
|
|
3307
|
-
centers:
|
|
3313
|
+
isolines: l,
|
|
3314
|
+
centers: u,
|
|
3308
3315
|
thresholds: s,
|
|
3309
3316
|
range: t,
|
|
3310
3317
|
renderWidth: n.width,
|
|
3311
3318
|
renderHeight: n.height,
|
|
3312
3319
|
downsampled: !!n.downsampled,
|
|
3313
|
-
lineCount:
|
|
3320
|
+
lineCount: l.reduce((c, h) => c + h.lines.length, 0)
|
|
3314
3321
|
};
|
|
3315
3322
|
}
|
|
3316
3323
|
const Gr = /* @__PURE__ */ new Set([
|
|
@@ -3318,11 +3325,13 @@ const Gr = /* @__PURE__ */ new Set([
|
|
|
3318
3325
|
"area",
|
|
3319
3326
|
"band",
|
|
3320
3327
|
"bbox",
|
|
3328
|
+
"bboxProjection",
|
|
3321
3329
|
"contourInterval",
|
|
3322
3330
|
"centerDetection",
|
|
3323
3331
|
"coordinatePrecision",
|
|
3324
3332
|
"data",
|
|
3325
3333
|
"dataType",
|
|
3334
|
+
"defaultSourceProjectionCrs",
|
|
3326
3335
|
"excludeBoundary",
|
|
3327
3336
|
"grayChannel",
|
|
3328
3337
|
"grayImageUrl",
|
|
@@ -3342,10 +3351,12 @@ const Gr = /* @__PURE__ */ new Set([
|
|
|
3342
3351
|
"minimumLinePoints",
|
|
3343
3352
|
"noDataValue",
|
|
3344
3353
|
"offset",
|
|
3354
|
+
"projection",
|
|
3345
3355
|
"scale",
|
|
3346
3356
|
"smooth",
|
|
3347
3357
|
"smoothingIterations",
|
|
3348
3358
|
"sourceProjection",
|
|
3359
|
+
"sourceProjectionCrs",
|
|
3349
3360
|
"sourceType",
|
|
3350
3361
|
"thresholdCount",
|
|
3351
3362
|
"thresholds",
|
|
@@ -3356,13 +3367,15 @@ const Gr = /* @__PURE__ */ new Set([
|
|
|
3356
3367
|
"values",
|
|
3357
3368
|
"width",
|
|
3358
3369
|
"height"
|
|
3359
|
-
]),
|
|
3370
|
+
]), Mr = /* @__PURE__ */ new Set([
|
|
3360
3371
|
"arrayBuffer",
|
|
3361
3372
|
"area",
|
|
3362
3373
|
"band",
|
|
3363
3374
|
"bbox",
|
|
3375
|
+
"bboxProjection",
|
|
3364
3376
|
"data",
|
|
3365
3377
|
"dataType",
|
|
3378
|
+
"defaultSourceProjectionCrs",
|
|
3366
3379
|
"grayChannel",
|
|
3367
3380
|
"grayImageUrl",
|
|
3368
3381
|
"grayMaxValue",
|
|
@@ -3377,8 +3390,10 @@ const Gr = /* @__PURE__ */ new Set([
|
|
|
3377
3390
|
"minValue",
|
|
3378
3391
|
"noDataValue",
|
|
3379
3392
|
"offset",
|
|
3393
|
+
"projection",
|
|
3380
3394
|
"scale",
|
|
3381
3395
|
"sourceProjection",
|
|
3396
|
+
"sourceProjectionCrs",
|
|
3382
3397
|
"sourceType",
|
|
3383
3398
|
"tifUrl",
|
|
3384
3399
|
"tiffUrl",
|
|
@@ -3387,7 +3402,7 @@ const Gr = /* @__PURE__ */ new Set([
|
|
|
3387
3402
|
"values",
|
|
3388
3403
|
"width"
|
|
3389
3404
|
]);
|
|
3390
|
-
function
|
|
3405
|
+
function Nr(r = {}) {
|
|
3391
3406
|
const { mapCore: e, baseGIS: t, ...n } = r;
|
|
3392
3407
|
return n;
|
|
3393
3408
|
}
|
|
@@ -3395,10 +3410,10 @@ function Er(r = {}) {
|
|
|
3395
3410
|
var e;
|
|
3396
3411
|
return ((e = r.centerDetection) == null ? void 0 : e.enabled) === !0;
|
|
3397
3412
|
}
|
|
3398
|
-
function
|
|
3413
|
+
function Ar(r, e, t = null) {
|
|
3399
3414
|
const n = {};
|
|
3400
|
-
Object.entries(r).forEach(([i,
|
|
3401
|
-
Gr.has(i) || (n[i] =
|
|
3415
|
+
Object.entries(r).forEach(([i, o]) => {
|
|
3416
|
+
Gr.has(i) || (n[i] = o);
|
|
3402
3417
|
});
|
|
3403
3418
|
const s = {
|
|
3404
3419
|
...n,
|
|
@@ -3410,15 +3425,20 @@ function Rr(r, e, t = null) {
|
|
|
3410
3425
|
};
|
|
3411
3426
|
return s.centers = Array.isArray(r.centers) ? r.centers : Er(r) ? e.centers : [], s;
|
|
3412
3427
|
}
|
|
3413
|
-
function
|
|
3428
|
+
function j() {
|
|
3414
3429
|
return typeof performance < "u" ? performance.now() : Date.now();
|
|
3415
3430
|
}
|
|
3431
|
+
function Rr(r) {
|
|
3432
|
+
var t, n;
|
|
3433
|
+
const e = (n = (t = r == null ? void 0 : r.getConfig) == null ? void 0 : t.call(r)) == null ? void 0 : n.sourceProjectionCrs;
|
|
3434
|
+
return e != null && String(e).trim() !== "" ? e : "";
|
|
3435
|
+
}
|
|
3416
3436
|
function xr(r = {}) {
|
|
3417
|
-
return Object.keys(r).some((e) =>
|
|
3437
|
+
return Object.keys(r).some((e) => Mr.has(e));
|
|
3418
3438
|
}
|
|
3419
3439
|
class Zr {
|
|
3420
3440
|
constructor(e = {}) {
|
|
3421
|
-
const t =
|
|
3441
|
+
const t = Nr(e), n = t.layerId || t.contourLayerId || "raster-contour-default";
|
|
3422
3442
|
this.defaultPayload = {
|
|
3423
3443
|
thresholdCount: 12,
|
|
3424
3444
|
maxCells: 1e6,
|
|
@@ -3427,16 +3447,18 @@ class Zr {
|
|
|
3427
3447
|
visible: !0,
|
|
3428
3448
|
...t,
|
|
3429
3449
|
centerDetection: {
|
|
3430
|
-
|
|
3450
|
+
...k,
|
|
3431
3451
|
...t.centerDetection || {}
|
|
3432
3452
|
},
|
|
3433
3453
|
layerId: n
|
|
3434
|
-
}, this.baseGIS = null, this.contourController = new
|
|
3454
|
+
}, this.baseGIS = null, this.contourController = new nt({ layerId: n }), this.currentPayload = null, this.currentGrid = null, this.operationId = 0, this.state = {
|
|
3435
3455
|
layerId: n,
|
|
3436
3456
|
sourceType: "",
|
|
3437
3457
|
sourceUrl: "",
|
|
3458
|
+
sourceProjectionCrs: "",
|
|
3438
3459
|
sourceProjection: "",
|
|
3439
3460
|
projection: "",
|
|
3461
|
+
bboxProjection: "",
|
|
3440
3462
|
width: 0,
|
|
3441
3463
|
height: 0,
|
|
3442
3464
|
renderWidth: 0,
|
|
@@ -3472,14 +3494,14 @@ class Zr {
|
|
|
3472
3494
|
}
|
|
3473
3495
|
resolveBaseGIS() {
|
|
3474
3496
|
var e, t;
|
|
3475
|
-
return this.baseGIS ? (t = (e = this.baseGIS).getMapInstance) != null && t.call(e) ?
|
|
3497
|
+
return this.baseGIS ? (t = (e = this.baseGIS).getMapInstance) != null && t.call(e) ? g(null, "BaseGIS is ready.") : f(
|
|
3476
3498
|
"Map instance is not ready. Please call mapCore.init() first.",
|
|
3477
3499
|
"NOT_INITIALIZED"
|
|
3478
3500
|
) : f("RasterContourController has not been mounted.", "NOT_MOUNTED");
|
|
3479
3501
|
}
|
|
3480
|
-
async renderGrid(e, t, n, s, i = !1,
|
|
3481
|
-
var
|
|
3482
|
-
const
|
|
3502
|
+
async renderGrid(e, t, n, s, i = !1, o = 0) {
|
|
3503
|
+
var v;
|
|
3504
|
+
const a = j(), l = Tr(e, t), u = j() - a, c = Ar(t, l, e.area), h = c.centers.length, y = c.onStateChange;
|
|
3483
3505
|
c.onStateChange = (p) => {
|
|
3484
3506
|
n === this.operationId && (this.state = {
|
|
3485
3507
|
...this.state,
|
|
@@ -3495,55 +3517,57 @@ class Zr {
|
|
|
3495
3517
|
visible: (p == null ? void 0 : p.visible) ?? this.state.visible
|
|
3496
3518
|
}, y == null || y(p));
|
|
3497
3519
|
};
|
|
3498
|
-
const d =
|
|
3520
|
+
const d = j(), I = i ? await this.contourController.update(c) : await this.contourController.load(c), b = j() - d;
|
|
3499
3521
|
if (!I.success) return I;
|
|
3500
3522
|
if (n !== this.operationId)
|
|
3501
|
-
return
|
|
3502
|
-
const S =
|
|
3523
|
+
return g({ stale: !0, ignored: !0 }, "Raster contour render was superseded.");
|
|
3524
|
+
const S = j() - s, m = ((v = I.data) == null ? void 0 : v.state) || I.data || null;
|
|
3503
3525
|
return this.currentPayload = t, this.currentGrid = e, this.state = {
|
|
3504
3526
|
...this.state,
|
|
3505
3527
|
layerId: c.layerId,
|
|
3506
3528
|
sourceType: e.sourceType,
|
|
3507
3529
|
sourceUrl: e.sourceUrl,
|
|
3530
|
+
sourceProjectionCrs: e.sourceProjectionCrs || e.sourceProjection,
|
|
3508
3531
|
sourceProjection: e.sourceProjection,
|
|
3509
3532
|
projection: e.projection,
|
|
3533
|
+
bboxProjection: e.bboxProjection,
|
|
3510
3534
|
width: e.width,
|
|
3511
3535
|
height: e.height,
|
|
3512
|
-
renderWidth:
|
|
3513
|
-
renderHeight:
|
|
3514
|
-
min:
|
|
3515
|
-
max:
|
|
3516
|
-
validCount:
|
|
3517
|
-
noDataCount:
|
|
3518
|
-
levelCount:
|
|
3519
|
-
lineCount:
|
|
3520
|
-
centerCount: (
|
|
3521
|
-
lineLabelCount: (
|
|
3522
|
-
centerLabelCount: (
|
|
3523
|
-
labelCount: (
|
|
3524
|
-
lineRenderer: (
|
|
3525
|
-
thresholds:
|
|
3536
|
+
renderWidth: l.renderWidth,
|
|
3537
|
+
renderHeight: l.renderHeight,
|
|
3538
|
+
min: l.range.min,
|
|
3539
|
+
max: l.range.max,
|
|
3540
|
+
validCount: l.range.validCount,
|
|
3541
|
+
noDataCount: l.range.noDataCount,
|
|
3542
|
+
levelCount: l.thresholds.length,
|
|
3543
|
+
lineCount: l.lineCount,
|
|
3544
|
+
centerCount: (m == null ? void 0 : m.centerCount) ?? h,
|
|
3545
|
+
lineLabelCount: (m == null ? void 0 : m.lineLabelCount) || 0,
|
|
3546
|
+
centerLabelCount: (m == null ? void 0 : m.centerLabelCount) || 0,
|
|
3547
|
+
labelCount: (m == null ? void 0 : m.labelCount) || 0,
|
|
3548
|
+
lineRenderer: (m == null ? void 0 : m.lineRenderer) || "",
|
|
3549
|
+
thresholds: l.thresholds,
|
|
3526
3550
|
area: e.area,
|
|
3527
|
-
sourceElapsed:
|
|
3528
|
-
generateElapsed:
|
|
3551
|
+
sourceElapsed: o,
|
|
3552
|
+
generateElapsed: u,
|
|
3529
3553
|
renderElapsed: b,
|
|
3530
|
-
lineBuildElapsed: (
|
|
3531
|
-
labelLayoutElapsed: (
|
|
3532
|
-
primitiveReadyElapsed: (
|
|
3554
|
+
lineBuildElapsed: (m == null ? void 0 : m.lineBuildElapsed) || 0,
|
|
3555
|
+
labelLayoutElapsed: (m == null ? void 0 : m.labelLayoutElapsed) || 0,
|
|
3556
|
+
primitiveReadyElapsed: (m == null ? void 0 : m.primitiveReadyElapsed) || 0,
|
|
3533
3557
|
elapsed: S,
|
|
3534
|
-
downsampled:
|
|
3558
|
+
downsampled: l.downsampled,
|
|
3535
3559
|
visible: c.visible !== !1,
|
|
3536
3560
|
loaded: !0
|
|
3537
|
-
},
|
|
3561
|
+
}, g(
|
|
3538
3562
|
{
|
|
3539
3563
|
...this.getState(),
|
|
3540
|
-
contourState:
|
|
3564
|
+
contourState: m
|
|
3541
3565
|
},
|
|
3542
3566
|
i ? `Raster contour layer "${c.layerId}" regenerated.` : `Raster contour layer "${c.layerId}" loaded.`
|
|
3543
3567
|
);
|
|
3544
3568
|
}
|
|
3545
3569
|
async load(e = {}, t = {}) {
|
|
3546
|
-
var
|
|
3570
|
+
var a;
|
|
3547
3571
|
const n = this.resolveBaseGIS();
|
|
3548
3572
|
if (!n.success) return n;
|
|
3549
3573
|
const s = {
|
|
@@ -3553,24 +3577,24 @@ class Zr {
|
|
|
3553
3577
|
...t,
|
|
3554
3578
|
centerDetection: {
|
|
3555
3579
|
...this.defaultPayload.centerDetection,
|
|
3556
|
-
...((
|
|
3580
|
+
...((a = this.currentPayload) == null ? void 0 : a.centerDetection) || {},
|
|
3557
3581
|
...e.centerDetection || {},
|
|
3558
3582
|
...t.centerDetection || {}
|
|
3559
3583
|
}
|
|
3560
|
-
}, i = ++this.operationId,
|
|
3584
|
+
}, i = ++this.operationId, o = j();
|
|
3561
3585
|
try {
|
|
3562
|
-
const u = await
|
|
3563
|
-
return i !== this.operationId ?
|
|
3564
|
-
|
|
3586
|
+
const l = Rr(this.baseGIS) || s.defaultSourceProjectionCrs, u = l ? { ...s, defaultSourceProjectionCrs: l } : s, c = await lr(u), h = j() - o;
|
|
3587
|
+
return i !== this.operationId ? g({ stale: !0, ignored: !0 }, "Raster contour load was superseded.") : this.renderGrid(
|
|
3588
|
+
c,
|
|
3565
3589
|
s,
|
|
3566
3590
|
i,
|
|
3567
|
-
|
|
3591
|
+
o,
|
|
3568
3592
|
!1,
|
|
3569
|
-
|
|
3593
|
+
h
|
|
3570
3594
|
);
|
|
3571
|
-
} catch (
|
|
3595
|
+
} catch (l) {
|
|
3572
3596
|
return f(
|
|
3573
|
-
(
|
|
3597
|
+
(l == null ? void 0 : l.message) || "Raster contour generation failed.",
|
|
3574
3598
|
"RASTER_CONTOUR_FAILED"
|
|
3575
3599
|
);
|
|
3576
3600
|
}
|
|
@@ -3598,7 +3622,7 @@ class Zr {
|
|
|
3598
3622
|
...this.currentPayload.centerDetection || {},
|
|
3599
3623
|
...e.centerDetection || {}
|
|
3600
3624
|
}
|
|
3601
|
-
}, s = ++this.operationId, i =
|
|
3625
|
+
}, s = ++this.operationId, i = j();
|
|
3602
3626
|
try {
|
|
3603
3627
|
return await this.renderGrid(
|
|
3604
3628
|
this.currentGrid,
|
|
@@ -3607,9 +3631,9 @@ class Zr {
|
|
|
3607
3631
|
i,
|
|
3608
3632
|
!0
|
|
3609
3633
|
);
|
|
3610
|
-
} catch (
|
|
3634
|
+
} catch (o) {
|
|
3611
3635
|
return f(
|
|
3612
|
-
(
|
|
3636
|
+
(o == null ? void 0 : o.message) || "Raster contour regeneration failed.",
|
|
3613
3637
|
"RASTER_CONTOUR_FAILED"
|
|
3614
3638
|
);
|
|
3615
3639
|
}
|
|
@@ -3668,7 +3692,7 @@ class Zr {
|
|
|
3668
3692
|
};
|
|
3669
3693
|
}
|
|
3670
3694
|
}
|
|
3671
|
-
const
|
|
3695
|
+
const ze = [
|
|
3672
3696
|
{ value: 0, color: [36, 88, 190] },
|
|
3673
3697
|
{ value: 2, color: [36, 145, 184] },
|
|
3674
3698
|
{ value: 5, color: [54, 177, 111] },
|
|
@@ -3676,7 +3700,7 @@ const Oe = [
|
|
|
3676
3700
|
{ value: 11, color: [229, 178, 78] },
|
|
3677
3701
|
{ value: 14, color: [224, 103, 117] },
|
|
3678
3702
|
{ value: 18, color: [162, 82, 202] }
|
|
3679
|
-
],
|
|
3703
|
+
], Ue = [
|
|
3680
3704
|
{ value: 0, color: [178, 223, 255] },
|
|
3681
3705
|
{ value: 3, color: [190, 248, 222] },
|
|
3682
3706
|
{ value: 6, color: [235, 252, 174] },
|
|
@@ -3684,10 +3708,10 @@ const Oe = [
|
|
|
3684
3708
|
{ value: 14, color: [255, 166, 156] },
|
|
3685
3709
|
{ value: 18, color: [232, 153, 255] }
|
|
3686
3710
|
];
|
|
3687
|
-
function
|
|
3711
|
+
function T(r, e, t) {
|
|
3688
3712
|
return Math.min(Math.max(r, e), t);
|
|
3689
3713
|
}
|
|
3690
|
-
function
|
|
3714
|
+
function Dr(r) {
|
|
3691
3715
|
if (Array.isArray(r) && r.length >= 3)
|
|
3692
3716
|
return [Number(r[0]) || 0, Number(r[1]) || 0, Number(r[2]) || 0];
|
|
3693
3717
|
if (typeof r != "string")
|
|
@@ -3705,14 +3729,14 @@ function Fr(r) {
|
|
|
3705
3729
|
const n = t[1].split(",").map((s) => Number(s.trim()));
|
|
3706
3730
|
return n.length < 3 || n.slice(0, 3).some((s) => !Number.isFinite(s)) ? null : n.slice(0, 3);
|
|
3707
3731
|
}
|
|
3708
|
-
function
|
|
3732
|
+
function J(r, e) {
|
|
3709
3733
|
const n = (Array.isArray(r) && r.length > 0 ? r : e).map((s, i) => {
|
|
3710
|
-
const
|
|
3711
|
-
return !Number.isFinite(
|
|
3734
|
+
const o = Number((s == null ? void 0 : s.value) ?? (s == null ? void 0 : s.speed) ?? (s == null ? void 0 : s[0]) ?? i), a = Dr((s == null ? void 0 : s.color) ?? (s == null ? void 0 : s[1]) ?? s);
|
|
3735
|
+
return !Number.isFinite(o) || !a ? null : { value: o, color: a };
|
|
3712
3736
|
}).filter(Boolean).sort((s, i) => s.value - i.value);
|
|
3713
3737
|
return n.length > 0 ? n : e;
|
|
3714
3738
|
}
|
|
3715
|
-
function
|
|
3739
|
+
function Fr(r, e) {
|
|
3716
3740
|
if (!Array.isArray(r) || r.length === 0)
|
|
3717
3741
|
return [255, 255, 255];
|
|
3718
3742
|
if (e <= r[0].value)
|
|
@@ -3720,17 +3744,17 @@ function Dr(r, e) {
|
|
|
3720
3744
|
for (let t = 1; t < r.length; t += 1) {
|
|
3721
3745
|
const n = r[t], s = r[t - 1];
|
|
3722
3746
|
if (e <= n.value) {
|
|
3723
|
-
const i = Math.max(n.value - s.value, 1e-4),
|
|
3747
|
+
const i = Math.max(n.value - s.value, 1e-4), o = T((e - s.value) / i, 0, 1);
|
|
3724
3748
|
return s.color.map(
|
|
3725
|
-
(
|
|
3749
|
+
(a, l) => Math.round(a + (n.color[l] - a) * o)
|
|
3726
3750
|
);
|
|
3727
3751
|
}
|
|
3728
3752
|
}
|
|
3729
3753
|
return r[r.length - 1].color;
|
|
3730
3754
|
}
|
|
3731
|
-
function
|
|
3755
|
+
function le(r, e) {
|
|
3732
3756
|
const [t, n, s] = r;
|
|
3733
|
-
return `rgba(${t}, ${n}, ${s}, ${
|
|
3757
|
+
return `rgba(${t}, ${n}, ${s}, ${T(e, 0, 1)})`;
|
|
3734
3758
|
}
|
|
3735
3759
|
function Br(r, e) {
|
|
3736
3760
|
if (!r || typeof r != "object")
|
|
@@ -3752,18 +3776,18 @@ function Or(r, e) {
|
|
|
3752
3776
|
};
|
|
3753
3777
|
return t.west >= t.east || t.south >= t.north ? null : t;
|
|
3754
3778
|
}
|
|
3755
|
-
function
|
|
3779
|
+
function ue(r, e, t) {
|
|
3756
3780
|
return r && Number.isFinite(r.x) && Number.isFinite(r.y) && r.x >= -64 && r.x <= e + 64 && r.y >= -64 && r.y <= t + 64;
|
|
3757
3781
|
}
|
|
3758
|
-
function
|
|
3782
|
+
function jr(r) {
|
|
3759
3783
|
return r && Number.isFinite(r.x) && Number.isFinite(r.y);
|
|
3760
3784
|
}
|
|
3761
|
-
function
|
|
3785
|
+
function _r(r) {
|
|
3762
3786
|
return String(r || "").toLowerCase();
|
|
3763
3787
|
}
|
|
3764
|
-
class
|
|
3788
|
+
class Vr {
|
|
3765
3789
|
constructor(e = {}) {
|
|
3766
|
-
this.id = e.id || "wind-field-default", this.container = e.container || null, this.project = typeof e.project == "function" ? e.project : null, this.getViewBounds = typeof e.getViewBounds == "function" ? e.getViewBounds : null, this.getSceneMode = typeof e.getSceneMode == "function" ? e.getSceneMode : null, this.grid = e.grid instanceof
|
|
3790
|
+
this.id = e.id || "wind-field-default", this.container = e.container || null, this.project = typeof e.project == "function" ? e.project : null, this.getViewBounds = typeof e.getViewBounds == "function" ? e.getViewBounds : null, this.getSceneMode = typeof e.getSceneMode == "function" ? e.getSceneMode : null, this.grid = e.grid instanceof ne ? e.grid : new ne(e.data), this.options = {
|
|
3767
3791
|
zIndex: Number(e.zIndex ?? 30),
|
|
3768
3792
|
visible: e.visible !== !1,
|
|
3769
3793
|
running: e.running !== !1,
|
|
@@ -3788,9 +3812,9 @@ class zr {
|
|
|
3788
3812
|
projectionGrid: e.projectionGrid !== !1,
|
|
3789
3813
|
projectionGridCols: Number(e.projectionGridCols ?? 32),
|
|
3790
3814
|
projectionGridRows: Number(e.projectionGridRows ?? 20)
|
|
3791
|
-
}, this.colorScale =
|
|
3815
|
+
}, this.colorScale = J(e.colorScale, ze), this.particleColorScale = J(
|
|
3792
3816
|
e.particleColorScale,
|
|
3793
|
-
|
|
3817
|
+
Ue
|
|
3794
3818
|
), this.canvas = null, this.ctx = null, this.overlayCanvas = null, this.overlayCtx = null, this.particles = [], this.animationFrame = null, this.lastFrameTime = 0, this.destroyed = !1, this.width = 0, this.height = 0, this.resizeObserver = null, this.interactionSuspended = !1, this.runningBeforeInteraction = !1, this.overlayDirty = !0, this.spawnBoundsCache = null, this.resumeTimer = null, this.particleCursor = 0, this.projectionGrid = null, this.mount();
|
|
3795
3819
|
}
|
|
3796
3820
|
isReady() {
|
|
@@ -3816,12 +3840,12 @@ class zr {
|
|
|
3816
3840
|
resize() {
|
|
3817
3841
|
if (!this.canvas || !this.overlayCanvas || !this.container)
|
|
3818
3842
|
return;
|
|
3819
|
-
const e = this.container.getBoundingClientRect(), t =
|
|
3843
|
+
const e = this.container.getBoundingClientRect(), t = T(this.options.devicePixelRatio || 1, 1, 2), n = Math.max(1, Math.floor(e.width)), s = Math.max(1, Math.floor(e.height));
|
|
3820
3844
|
n === this.width && s === this.height || (this.width = n, this.height = s, [
|
|
3821
3845
|
[this.canvas, this.ctx],
|
|
3822
3846
|
[this.overlayCanvas, this.overlayCtx]
|
|
3823
|
-
].forEach(([i,
|
|
3824
|
-
i.width = Math.floor(n * t), i.height = Math.floor(s * t),
|
|
3847
|
+
].forEach(([i, o]) => {
|
|
3848
|
+
i.width = Math.floor(n * t), i.height = Math.floor(s * t), o == null || o.setTransform(t, 0, 0, t, 0, 0);
|
|
3825
3849
|
}), this.overlayDirty = !0, this.invalidateProjectionGrid(), this.clear());
|
|
3826
3850
|
}
|
|
3827
3851
|
clear() {
|
|
@@ -3837,10 +3861,10 @@ class zr {
|
|
|
3837
3861
|
this.options = {
|
|
3838
3862
|
...this.options,
|
|
3839
3863
|
...e
|
|
3840
|
-
}, e.colorScale !== void 0 && (this.colorScale =
|
|
3864
|
+
}, e.colorScale !== void 0 && (this.colorScale = J(e.colorScale, ze), this.overlayDirty = !0), e.particleColorScale !== void 0 && (this.particleColorScale = J(
|
|
3841
3865
|
e.particleColorScale,
|
|
3842
|
-
|
|
3843
|
-
)), this.canvas && (this.canvas.style.zIndex = String(this.options.zIndex + 1), this.canvas.style.display = this.options.visible ? "block" : "none"), this.overlayCanvas && (this.overlayCanvas.style.zIndex = String(this.options.zIndex), this.overlayCanvas.style.display = this.options.visible ? "block" : "none"), e.data && (this.grid = new
|
|
3866
|
+
Ue
|
|
3867
|
+
)), this.canvas && (this.canvas.style.zIndex = String(this.options.zIndex + 1), this.canvas.style.display = this.options.visible ? "block" : "none"), this.overlayCanvas && (this.overlayCanvas.style.zIndex = String(this.options.zIndex), this.overlayCanvas.style.display = this.options.visible ? "block" : "none"), e.data && (this.grid = new ne(e.data), this.overlayDirty = !0, this.reset()), (e.particleCount !== void 0 || e.maxAge !== void 0 || e.velocityOverlay !== void 0 || e.velocityOverlayOpacity !== void 0 || e.velocityOverlayCellSize !== void 0 || e.velocityOverlayEdgeFade !== void 0 || e.projectionGrid !== void 0 || e.projectionGridCols !== void 0 || e.projectionGridRows !== void 0 || e.reset === !0) && (this.overlayDirty = !0, this.reset()), this.drawVelocityOverlay();
|
|
3844
3868
|
}
|
|
3845
3869
|
refreshSpawnBounds() {
|
|
3846
3870
|
return this.spawnBoundsCache = this.getSpawnBounds(), this.invalidateProjectionGrid(), this.spawnBoundsCache;
|
|
@@ -3849,7 +3873,7 @@ class zr {
|
|
|
3849
3873
|
var t;
|
|
3850
3874
|
if (!this.options.projectionGrid)
|
|
3851
3875
|
return !1;
|
|
3852
|
-
const e =
|
|
3876
|
+
const e = _r((t = this.getSceneMode) == null ? void 0 : t.call(this));
|
|
3853
3877
|
return e === "2d" || e === "2.5d";
|
|
3854
3878
|
}
|
|
3855
3879
|
invalidateProjectionGrid() {
|
|
@@ -3858,11 +3882,11 @@ class zr {
|
|
|
3858
3882
|
buildProjectionGrid(e = this.spawnBoundsCache) {
|
|
3859
3883
|
if (!this.shouldUseProjectionGrid() || !e)
|
|
3860
3884
|
return this.projectionGrid = null, null;
|
|
3861
|
-
const t =
|
|
3885
|
+
const t = T(Math.floor(this.options.projectionGridCols) || 32, 8, 96), n = T(Math.floor(this.options.projectionGridRows) || 20, 6, 64), s = [];
|
|
3862
3886
|
for (let i = 0; i <= n; i += 1)
|
|
3863
|
-
for (let
|
|
3864
|
-
const
|
|
3865
|
-
s.push(this.project(
|
|
3887
|
+
for (let o = 0; o <= t; o += 1) {
|
|
3888
|
+
const a = e.west + (e.east - e.west) * (o / t), l = e.south + (e.north - e.south) * (i / n);
|
|
3889
|
+
s.push(this.project(a, l, this.options.height));
|
|
3866
3890
|
}
|
|
3867
3891
|
return this.projectionGrid = {
|
|
3868
3892
|
bounds: e,
|
|
@@ -3875,13 +3899,13 @@ class zr {
|
|
|
3875
3899
|
const n = this.projectionGrid || this.buildProjectionGrid(this.spawnBoundsCache);
|
|
3876
3900
|
if (!n || !n.bounds)
|
|
3877
3901
|
return this.project(e, t, this.options.height);
|
|
3878
|
-
const { bounds: s, cols: i, rows:
|
|
3879
|
-
if (![p,
|
|
3902
|
+
const { bounds: s, cols: i, rows: o, nodes: a } = n, l = Math.max(s.east - s.west, 1e-4), u = Math.max(s.north - s.south, 1e-4), c = (e - s.west) / l * i, h = (t - s.south) / u * o, y = T(Math.floor(c), 0, i - 1), d = T(Math.floor(h), 0, o - 1), I = y + 1, b = d + 1, S = T(c - y, 0, 1), m = T(h - d, 0, 1), v = i + 1, p = a[d * v + y], C = a[d * v + I], w = a[b * v + y], R = a[b * v + I];
|
|
3903
|
+
if (![p, C, w, R].every(jr))
|
|
3880
3904
|
return this.project(e, t, this.options.height);
|
|
3881
|
-
const
|
|
3905
|
+
const x = 1 - S, A = 1 - m;
|
|
3882
3906
|
return {
|
|
3883
|
-
x: p.x *
|
|
3884
|
-
y: p.y *
|
|
3907
|
+
x: p.x * x * A + C.x * S * A + w.x * x * m + R.x * S * m,
|
|
3908
|
+
y: p.y * x * A + C.y * S * A + w.y * x * m + R.y * S * m
|
|
3885
3909
|
};
|
|
3886
3910
|
}
|
|
3887
3911
|
getSpawnBounds() {
|
|
@@ -3927,7 +3951,7 @@ class zr {
|
|
|
3927
3951
|
if (!this.isReady())
|
|
3928
3952
|
return;
|
|
3929
3953
|
this.clear();
|
|
3930
|
-
const e =
|
|
3954
|
+
const e = T(Math.floor(this.options.particleCount), 1, 8e3), t = this.refreshSpawnBounds();
|
|
3931
3955
|
this.particles = Array.from({ length: e }, () => this.createParticle(t)), this.particleCursor = 0, this.overlayDirty = !0, this.drawVelocityOverlay();
|
|
3932
3956
|
}
|
|
3933
3957
|
getParticleColorIndex(e) {
|
|
@@ -3946,32 +3970,32 @@ class zr {
|
|
|
3946
3970
|
const e = this.spawnBoundsCache || this.refreshSpawnBounds();
|
|
3947
3971
|
if (!e)
|
|
3948
3972
|
return;
|
|
3949
|
-
const t = this.overlayCtx, n =
|
|
3973
|
+
const t = this.overlayCtx, n = T(Number(this.options.velocityOverlayCellSize) || 54, 28, 96), s = T(Math.ceil(this.width / n), 10, 64), i = T(Math.ceil(this.height / n), 8, 48), o = (e.east - e.west) / s, a = (e.north - e.south) / i, l = n * 1.25, u = this.grid.getBounds();
|
|
3950
3974
|
t.save(), t.globalCompositeOperation = "source-over";
|
|
3951
3975
|
for (let c = 0; c < i; c += 1) {
|
|
3952
|
-
const h = e.south + (c + 0.5) *
|
|
3976
|
+
const h = e.south + (c + 0.5) * a;
|
|
3953
3977
|
for (let y = 0; y < s; y += 1) {
|
|
3954
|
-
const d = e.west + (y + 0.5) *
|
|
3978
|
+
const d = e.west + (y + 0.5) * o, I = this.grid.sample(d, h);
|
|
3955
3979
|
if (!I || I.speed <= 0)
|
|
3956
3980
|
continue;
|
|
3957
3981
|
const b = this.projectPoint(d, h);
|
|
3958
|
-
if (!
|
|
3982
|
+
if (!ue(b, this.width, this.height))
|
|
3959
3983
|
continue;
|
|
3960
|
-
const S =
|
|
3961
|
-
if (
|
|
3984
|
+
const S = Fr(this.colorScale, I.speed), m = this.getDataEdgeOpacity(d, h, u), v = this.options.velocityOverlayOpacity * m;
|
|
3985
|
+
if (v <= 0.01)
|
|
3962
3986
|
continue;
|
|
3963
|
-
const p = t.createRadialGradient(b.x, b.y, 0, b.x, b.y,
|
|
3964
|
-
p.addColorStop(0,
|
|
3987
|
+
const p = t.createRadialGradient(b.x, b.y, 0, b.x, b.y, l);
|
|
3988
|
+
p.addColorStop(0, le(S, v)), p.addColorStop(1, le(S, 0)), t.fillStyle = p, t.fillRect(b.x - l, b.y - l, l * 2, l * 2);
|
|
3965
3989
|
}
|
|
3966
3990
|
}
|
|
3967
3991
|
t.restore();
|
|
3968
3992
|
}
|
|
3969
3993
|
getDataEdgeOpacity(e, t, n) {
|
|
3970
|
-
const s =
|
|
3994
|
+
const s = T(this.options.velocityOverlayEdgeFade, 0, 0.35);
|
|
3971
3995
|
if (s <= 0 || !n)
|
|
3972
3996
|
return 1;
|
|
3973
|
-
const i = (e - n.west) / Math.max(n.east - n.west, 1e-4),
|
|
3974
|
-
return
|
|
3997
|
+
const i = (e - n.west) / Math.max(n.east - n.west, 1e-4), o = (t - n.south) / Math.max(n.north - n.south, 1e-4), a = Math.min(i, 1 - i, o, 1 - o);
|
|
3998
|
+
return T(a / s, 0, 1);
|
|
3975
3999
|
}
|
|
3976
4000
|
start() {
|
|
3977
4001
|
this.destroyed || (this.options.running = !0, this.interactionSuspended = !1, this.animationFrame || (this.lastFrameTime = performance.now(), this.animationFrame = requestAnimationFrame((e) => this.animate(e))));
|
|
@@ -4001,45 +4025,45 @@ class zr {
|
|
|
4001
4025
|
}
|
|
4002
4026
|
stepParticle(e, t) {
|
|
4003
4027
|
const n = this.grid.sample(e.lon, e.lat), s = Number.isFinite(e.screenX) && Number.isFinite(e.screenY) ? { x: e.screenX, y: e.screenY } : this.projectPoint(e.lon, e.lat);
|
|
4004
|
-
if (!n || n.speed <= 0 || !
|
|
4028
|
+
if (!n || n.speed <= 0 || !ue(s, this.width, this.height))
|
|
4005
4029
|
return Object.assign(e, this.createParticle()), null;
|
|
4006
|
-
const i = e.lat * Math.PI / 180,
|
|
4007
|
-
return !h || !
|
|
4030
|
+
const i = e.lat * Math.PI / 180, o = Math.max(Math.cos(i) * 111320, 1e3), a = 111320, l = this.options.velocityScale * t, u = e.lon + n.u * l / o, c = e.lat + n.v * l / a, h = this.grid.sample(u, c), y = this.projectPoint(u, c);
|
|
4031
|
+
return !h || !ue(y, this.width, this.height) ? (Object.assign(e, this.createParticle()), null) : (e.lon = u, e.lat = c, e.screenX = y.x, e.screenY = y.y, e.age += 1, e.age > e.maxAge && Object.assign(e, this.createParticle()), { from: s, to: y, speed: h.speed });
|
|
4008
4032
|
}
|
|
4009
4033
|
getFrameParticleCount(e) {
|
|
4010
4034
|
var i;
|
|
4011
|
-
const t =
|
|
4035
|
+
const t = T(
|
|
4012
4036
|
Math.floor(this.options.maxFrameParticles || e),
|
|
4013
4037
|
1,
|
|
4014
4038
|
e
|
|
4015
4039
|
), n = Math.floor(this.options.sceneModeMaxFrameParticles || 0), s = String(((i = this.getSceneMode) == null ? void 0 : i.call(this)) || "").toLowerCase();
|
|
4016
|
-
return (s === "2d" || s === "2.5d") && n > 0 ?
|
|
4040
|
+
return (s === "2d" || s === "2.5d") && n > 0 ? T(n, 1, t) : t;
|
|
4017
4041
|
}
|
|
4018
4042
|
drawFrame(e) {
|
|
4019
4043
|
if (!this.ctx || this.width <= 0 || this.height <= 0)
|
|
4020
4044
|
return;
|
|
4021
4045
|
const t = this.ctx;
|
|
4022
|
-
t.globalCompositeOperation = "destination-in", t.fillStyle = `rgba(0, 0, 0, ${
|
|
4046
|
+
t.globalCompositeOperation = "destination-in", t.fillStyle = `rgba(0, 0, 0, ${T(this.options.fadeOpacity, 0.75, 0.98)})`, t.fillRect(0, 0, this.width, this.height), t.globalCompositeOperation = this.options.blendMode, t.lineCap = "round", t.lineJoin = "round";
|
|
4023
4047
|
const n = this.particleColorScale.map(() => []), s = this.particles.length, i = this.getFrameParticleCount(s);
|
|
4024
|
-
for (let
|
|
4025
|
-
const
|
|
4026
|
-
|
|
4048
|
+
for (let o = 0; o < i; o += 1) {
|
|
4049
|
+
const a = (this.particleCursor + o) % s, l = this.stepParticle(this.particles[a], e);
|
|
4050
|
+
l && n[this.getParticleColorIndex(l.speed)].push(l);
|
|
4027
4051
|
}
|
|
4028
|
-
this.particleCursor = (this.particleCursor + i) % s, n.forEach((
|
|
4029
|
-
if (
|
|
4052
|
+
this.particleCursor = (this.particleCursor + i) % s, n.forEach((o, a) => {
|
|
4053
|
+
if (o.length === 0)
|
|
4030
4054
|
return;
|
|
4031
|
-
const
|
|
4032
|
-
t.lineWidth = this.options.lineWidth * (0.72 +
|
|
4033
|
-
t.moveTo(
|
|
4055
|
+
const l = this.particleColorScale.length <= 1 ? 0 : a / (this.particleColorScale.length - 1);
|
|
4056
|
+
t.lineWidth = this.options.lineWidth * (0.72 + l * 0.56), t.strokeStyle = this.particleColorScale[a] ? le(this.particleColorScale[a].color, this.options.particleOpacity) : this.options.color, t.beginPath(), o.forEach((u) => {
|
|
4057
|
+
t.moveTo(u.from.x, u.from.y), t.lineTo(u.to.x, u.to.y);
|
|
4034
4058
|
}), t.stroke();
|
|
4035
4059
|
});
|
|
4036
4060
|
}
|
|
4037
4061
|
animate(e) {
|
|
4038
4062
|
if (this.animationFrame = null, !(this.destroyed || !this.options.running || this.interactionSuspended)) {
|
|
4039
4063
|
if (this.options.visible && this.isReady()) {
|
|
4040
|
-
const t = 1e3 /
|
|
4064
|
+
const t = 1e3 / T(this.options.frameRate, 1, 60), n = e - this.lastFrameTime;
|
|
4041
4065
|
if (n >= t) {
|
|
4042
|
-
const s =
|
|
4066
|
+
const s = T(n / 16.67, 0.5, 2.5);
|
|
4043
4067
|
this.lastFrameTime = e, this.drawFrame(s);
|
|
4044
4068
|
}
|
|
4045
4069
|
}
|
|
@@ -4062,67 +4086,67 @@ class zr {
|
|
|
4062
4086
|
this.stop(), this.destroyed = !0, this.clearResumeTimer(), this.resizeObserver && (this.resizeObserver.disconnect(), this.resizeObserver = null), (e = this.canvas) != null && e.parentNode && this.canvas.parentNode.removeChild(this.canvas), (t = this.overlayCanvas) != null && t.parentNode && this.overlayCanvas.parentNode.removeChild(this.overlayCanvas), this.clear(), this.canvas = null, this.ctx = null, this.overlayCanvas = null, this.overlayCtx = null, this.particles = [];
|
|
4063
4087
|
}
|
|
4064
4088
|
}
|
|
4065
|
-
function
|
|
4089
|
+
function U(r = {}) {
|
|
4066
4090
|
return typeof r == "string" ? r || "wind-field-default" : (r == null ? void 0 : r.id) || (r == null ? void 0 : r.layerId) || "wind-field-default";
|
|
4067
4091
|
}
|
|
4068
|
-
function
|
|
4092
|
+
function $e(r = {}) {
|
|
4069
4093
|
const {
|
|
4070
4094
|
id: e,
|
|
4071
4095
|
layerId: t,
|
|
4072
4096
|
data: n,
|
|
4073
4097
|
windData: s,
|
|
4074
4098
|
options: i,
|
|
4075
|
-
container:
|
|
4076
|
-
project:
|
|
4077
|
-
getViewBounds:
|
|
4078
|
-
...
|
|
4099
|
+
container: o,
|
|
4100
|
+
project: a,
|
|
4101
|
+
getViewBounds: l,
|
|
4102
|
+
...u
|
|
4079
4103
|
} = r || {};
|
|
4080
4104
|
return {
|
|
4081
|
-
...
|
|
4105
|
+
...u,
|
|
4082
4106
|
...i || {}
|
|
4083
4107
|
};
|
|
4084
4108
|
}
|
|
4085
|
-
function
|
|
4109
|
+
function ke(r) {
|
|
4086
4110
|
return !!(r && typeof r.getMapInstance == "function" && typeof r.getMapContainer == "function" && typeof r.projectToContainerPoint == "function" && typeof r.getViewBounds == "function" && typeof r.onViewChange == "function");
|
|
4087
4111
|
}
|
|
4088
4112
|
class Jr {
|
|
4089
4113
|
constructor(e = {}) {
|
|
4090
4114
|
this.baseGIS = null, this.layers = /* @__PURE__ */ new Map();
|
|
4091
|
-
const t = (e == null ? void 0 : e.mapCore) || (e == null ? void 0 : e.baseGIS) || (
|
|
4115
|
+
const t = (e == null ? void 0 : e.mapCore) || (e == null ? void 0 : e.baseGIS) || (ke(e) ? e : null);
|
|
4092
4116
|
t && this.mount(t);
|
|
4093
4117
|
}
|
|
4094
4118
|
mount(e) {
|
|
4095
4119
|
var t, n;
|
|
4096
|
-
return
|
|
4120
|
+
return ke(e) ? (this.baseGIS = e, g(
|
|
4097
4121
|
{ engineType: ((n = (t = this.baseGIS).getEngineType) == null ? void 0 : n.call(t)) || "unknown" },
|
|
4098
4122
|
"WindFieldMethods mounted with BaseGIS."
|
|
4099
4123
|
)) : f("WindFieldMethods mount requires BaseGIS instance.", "INVALID_MOUNT_TARGET");
|
|
4100
4124
|
}
|
|
4101
4125
|
resolveBaseGIS() {
|
|
4102
4126
|
var e, t;
|
|
4103
|
-
return this.baseGIS ? (t = (e = this.baseGIS).getMapInstance) != null && t.call(e) ?
|
|
4127
|
+
return this.baseGIS ? (t = (e = this.baseGIS).getMapInstance) != null && t.call(e) ? g(null, "BaseGIS is ready.") : f(
|
|
4104
4128
|
"Map instance is not ready. Please call mapCore.init() first.",
|
|
4105
|
-
|
|
4129
|
+
F.NOT_INITIALIZED
|
|
4106
4130
|
) : f("WindFieldMethods has not been mounted.", "NOT_MOUNTED");
|
|
4107
4131
|
}
|
|
4108
4132
|
addWindField(e = {}) {
|
|
4109
|
-
var
|
|
4133
|
+
var l, u;
|
|
4110
4134
|
const t = this.resolveBaseGIS();
|
|
4111
4135
|
if (!t.success)
|
|
4112
4136
|
return t;
|
|
4113
4137
|
const n = (e == null ? void 0 : e.data) || (e == null ? void 0 : e.windData);
|
|
4114
4138
|
if (!n)
|
|
4115
|
-
return f("Wind field data is required.",
|
|
4139
|
+
return f("Wind field data is required.", F.FAILED);
|
|
4116
4140
|
const s = this.baseGIS.getMapContainer();
|
|
4117
|
-
if (!(s != null && s.success) || !((
|
|
4118
|
-
return (s == null ? void 0 : s.success) === !1 ? s : f("Map container is not available.",
|
|
4119
|
-
const i =
|
|
4141
|
+
if (!(s != null && s.success) || !((l = s.data) != null && l.container))
|
|
4142
|
+
return (s == null ? void 0 : s.success) === !1 ? s : f("Map container is not available.", F.NOT_INITIALIZED);
|
|
4143
|
+
const i = U(e);
|
|
4120
4144
|
this.removeWindField(i);
|
|
4121
|
-
const
|
|
4145
|
+
const o = new Vr({
|
|
4122
4146
|
id: i,
|
|
4123
4147
|
data: n,
|
|
4124
4148
|
container: s.data.container,
|
|
4125
|
-
|
|
4149
|
+
...$e(e),
|
|
4126
4150
|
project: (c, h, y = 0) => {
|
|
4127
4151
|
const d = this.baseGIS.projectToContainerPoint({
|
|
4128
4152
|
longitude: c,
|
|
@@ -4141,54 +4165,54 @@ class Jr {
|
|
|
4141
4165
|
return c != null && c.success ? (d = c.data) == null ? void 0 : d.mode : "";
|
|
4142
4166
|
}
|
|
4143
4167
|
});
|
|
4144
|
-
if (!
|
|
4145
|
-
return
|
|
4146
|
-
const
|
|
4147
|
-
onStart: () =>
|
|
4148
|
-
onEnd: () =>
|
|
4168
|
+
if (!o.grid.valid)
|
|
4169
|
+
return o.destroy(), f(o.grid.errorMessage || "Invalid wind field data.", F.FAILED);
|
|
4170
|
+
const a = this.baseGIS.onViewChange({
|
|
4171
|
+
onStart: () => o.suspendForInteraction(),
|
|
4172
|
+
onEnd: () => o.resumeAfterInteraction()
|
|
4149
4173
|
});
|
|
4150
|
-
return
|
|
4151
|
-
layer:
|
|
4152
|
-
offViewChange: (
|
|
4153
|
-
}),
|
|
4174
|
+
return a != null && a.success ? (this.layers.set(i, {
|
|
4175
|
+
layer: o,
|
|
4176
|
+
offViewChange: (u = a.data) == null ? void 0 : u.off
|
|
4177
|
+
}), g(o.getState(), `Wind field "${i}" added.`)) : (o.destroy(), a || f("View change listener is not available."));
|
|
4154
4178
|
}
|
|
4155
4179
|
updateWindField(e = {}) {
|
|
4156
4180
|
const t = this.resolveBaseGIS();
|
|
4157
4181
|
if (!t.success)
|
|
4158
4182
|
return t;
|
|
4159
|
-
const n =
|
|
4183
|
+
const n = U(e), s = this.layers.get(n);
|
|
4160
4184
|
if (!s)
|
|
4161
|
-
return f(`Wind field "${n}" not found.`,
|
|
4162
|
-
const i =
|
|
4163
|
-
return
|
|
4185
|
+
return f(`Wind field "${n}" not found.`, F.FAILED);
|
|
4186
|
+
const i = $e(e), o = (e == null ? void 0 : e.data) || (e == null ? void 0 : e.windData);
|
|
4187
|
+
return o && (i.data = o), s.layer.updateOptions(i), g(s.layer.getState(), `Wind field "${n}" updated.`);
|
|
4164
4188
|
}
|
|
4165
4189
|
startWindField(e = {}) {
|
|
4166
|
-
const t =
|
|
4167
|
-
return n ? (n.layer.start(),
|
|
4190
|
+
const t = U(e), n = this.layers.get(t);
|
|
4191
|
+
return n ? (n.layer.start(), g(n.layer.getState(), `Wind field "${t}" started.`)) : f(`Wind field "${t}" not found.`, F.FAILED);
|
|
4168
4192
|
}
|
|
4169
4193
|
stopWindField(e = {}) {
|
|
4170
|
-
const t =
|
|
4171
|
-
return n ? (n.layer.stop(),
|
|
4194
|
+
const t = U(e), n = this.layers.get(t);
|
|
4195
|
+
return n ? (n.layer.stop(), g(n.layer.getState(), `Wind field "${t}" stopped.`)) : f(`Wind field "${t}" not found.`, F.FAILED);
|
|
4172
4196
|
}
|
|
4173
4197
|
showWindField(e = {}) {
|
|
4174
|
-
const t =
|
|
4175
|
-
return n ? (n.layer.show(),
|
|
4198
|
+
const t = U(e), n = this.layers.get(t);
|
|
4199
|
+
return n ? (n.layer.show(), g(n.layer.getState(), `Wind field "${t}" shown.`)) : f(`Wind field "${t}" not found.`, F.FAILED);
|
|
4176
4200
|
}
|
|
4177
4201
|
hideWindField(e = {}) {
|
|
4178
|
-
const t =
|
|
4179
|
-
return n ? (n.layer.hide(),
|
|
4202
|
+
const t = U(e), n = this.layers.get(t);
|
|
4203
|
+
return n ? (n.layer.hide(), g(n.layer.getState(), `Wind field "${t}" hidden.`)) : f(`Wind field "${t}" not found.`, F.FAILED);
|
|
4180
4204
|
}
|
|
4181
4205
|
removeWindField(e = {}) {
|
|
4182
4206
|
var s;
|
|
4183
|
-
const t =
|
|
4184
|
-
return n ? ((s = n.offViewChange) == null || s.call(n), n.layer.destroy(), this.layers.delete(t),
|
|
4207
|
+
const t = U(e), n = this.layers.get(t);
|
|
4208
|
+
return n ? ((s = n.offViewChange) == null || s.call(n), n.layer.destroy(), this.layers.delete(t), g({ layerId: t, removed: !0 }, `Wind field "${t}" removed.`)) : g({ layerId: t, removed: !1 }, `Wind field "${t}" not found.`);
|
|
4185
4209
|
}
|
|
4186
4210
|
clearWindFields() {
|
|
4187
4211
|
const e = this.layers.size;
|
|
4188
4212
|
return this.layers.forEach((t) => {
|
|
4189
4213
|
var n;
|
|
4190
4214
|
(n = t.offViewChange) == null || n.call(t), t.layer.destroy();
|
|
4191
|
-
}), this.layers.clear(),
|
|
4215
|
+
}), this.layers.clear(), g({ count: e }, `Wind fields cleared: ${e}.`);
|
|
4192
4216
|
}
|
|
4193
4217
|
getState() {
|
|
4194
4218
|
return {
|
|
@@ -4199,7 +4223,7 @@ class Jr {
|
|
|
4199
4223
|
}
|
|
4200
4224
|
}
|
|
4201
4225
|
export {
|
|
4202
|
-
|
|
4226
|
+
nt as ContourLayerController,
|
|
4203
4227
|
$r as GridLayerController,
|
|
4204
4228
|
kr as ImageLayerController,
|
|
4205
4229
|
Wr as LineLayerController,
|
|
@@ -4210,5 +4234,5 @@ export {
|
|
|
4210
4234
|
Zr as RasterContourController,
|
|
4211
4235
|
Hr as TyphoonPathController,
|
|
4212
4236
|
Jr as WindFieldMethods,
|
|
4213
|
-
|
|
4237
|
+
Ge as toImageLayerArea
|
|
4214
4238
|
};
|