@3clear/basegis 0.1.3 → 0.1.4
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 +905 -142
- package/dist/basegis.js +5519 -2674
- package/dist/methods.js +1402 -1049
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/methods.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { f as I, s as L, W as
|
|
1
|
+
import { f as I, s as L, W as ee, R as F } from "./WindDataGrid-AGJaASUG.js";
|
|
2
2
|
import Ue from "axios";
|
|
3
|
-
|
|
4
|
-
function je(t) {
|
|
3
|
+
function $e(t) {
|
|
5
4
|
return !!(t && typeof t.getMapInstance == "function" && typeof t.drawPoint == "function" && typeof t.drawLine == "function" && typeof t.drawPolygon == "function" && typeof t.drawText == "function" && typeof t.addMarker == "function" && typeof t.clearGraphics == "function");
|
|
6
5
|
}
|
|
7
|
-
class
|
|
6
|
+
class xr {
|
|
8
7
|
constructor(e = {}) {
|
|
9
8
|
this.baseGIS = null, this.items = [], this.loadedCount = 0, (e.mapCore || e.baseGIS) && this.mount(e.mapCore || e.baseGIS);
|
|
10
9
|
}
|
|
11
10
|
mount(e) {
|
|
12
|
-
return
|
|
11
|
+
return $e(e) ? (this.baseGIS = e, L(null, "GraphicGroupController mounted with BaseGIS.")) : I(
|
|
13
12
|
"GraphicGroupController mount requires BaseGIS instance.",
|
|
14
13
|
"INVALID_MOUNT_TARGET"
|
|
15
14
|
);
|
|
@@ -81,22 +80,22 @@ class Ir {
|
|
|
81
80
|
function W(t = {}) {
|
|
82
81
|
return Array.isArray(t) || Array.isArray(t == null ? void 0 : t.features) ? { contours: t } : t || {};
|
|
83
82
|
}
|
|
84
|
-
function
|
|
83
|
+
function ge(t = {}) {
|
|
85
84
|
const e = W(t);
|
|
86
|
-
return ["contours", "isolines", "isoline", "lines", "data", "items"].some(
|
|
85
|
+
return ["contours", "isolines", "isoline", "lines", "data", "items", "centers"].some(
|
|
87
86
|
(r) => Object.prototype.hasOwnProperty.call(e, r)
|
|
88
87
|
);
|
|
89
88
|
}
|
|
90
|
-
function
|
|
89
|
+
function We(t) {
|
|
91
90
|
return !!(t && typeof t.getEngineType == "function" && typeof t.getMapInstance == "function" && typeof t.upsertContourLayer == "function" && typeof t.updateContourLayer == "function" && typeof t.showContourLayer == "function" && typeof t.hideContourLayer == "function" && typeof t.removeContourLayer == "function" && typeof t.clearContourLayer == "function" && typeof t.getContourLayerState == "function");
|
|
92
91
|
}
|
|
93
|
-
function
|
|
92
|
+
function ke(t = {}) {
|
|
94
93
|
const { mapCore: e, baseGIS: r, ...n } = t;
|
|
95
94
|
return n;
|
|
96
95
|
}
|
|
97
|
-
class
|
|
96
|
+
class Ye {
|
|
98
97
|
constructor(e = {}) {
|
|
99
|
-
const r =
|
|
98
|
+
const r = ke(e), n = r.contourLayerId || r.layerId || r.id || "contour-default";
|
|
100
99
|
this.options = {
|
|
101
100
|
layerId: n,
|
|
102
101
|
visible: r.visible ?? !0
|
|
@@ -109,6 +108,9 @@ class Re {
|
|
|
109
108
|
sourceCount: 0,
|
|
110
109
|
levelCount: 0,
|
|
111
110
|
lineCount: 0,
|
|
111
|
+
centerCount: 0,
|
|
112
|
+
lineLabelCount: 0,
|
|
113
|
+
centerLabelCount: 0,
|
|
112
114
|
labelCount: 0,
|
|
113
115
|
visible: this.visible,
|
|
114
116
|
destroyed: !0
|
|
@@ -116,7 +118,7 @@ class Re {
|
|
|
116
118
|
}
|
|
117
119
|
mount(e) {
|
|
118
120
|
var r, n;
|
|
119
|
-
return
|
|
121
|
+
return We(e) ? (this.baseGIS = e, L(
|
|
120
122
|
{ engineType: ((n = (r = this.baseGIS).getEngineType) == null ? void 0 : n.call(r)) || "unknown" },
|
|
121
123
|
"ContourLayerController mounted with BaseGIS."
|
|
122
124
|
)) : I(
|
|
@@ -161,9 +163,9 @@ class Re {
|
|
|
161
163
|
...W(e),
|
|
162
164
|
...W(r)
|
|
163
165
|
});
|
|
164
|
-
if (!
|
|
166
|
+
if (!ge(s))
|
|
165
167
|
return I(
|
|
166
|
-
"Contour layer requires contours, isolines, lines, data or
|
|
168
|
+
"Contour layer requires contours, isolines, lines, data, items or centers.",
|
|
167
169
|
"INVALID_CONTOUR_SOURCE"
|
|
168
170
|
);
|
|
169
171
|
const i = await this.baseGIS.upsertContourLayer(s);
|
|
@@ -181,7 +183,7 @@ class Re {
|
|
|
181
183
|
...this.currentPayload || this.defaultPayload,
|
|
182
184
|
...W(e)
|
|
183
185
|
};
|
|
184
|
-
if (!this.currentPayload && !
|
|
186
|
+
if (!this.currentPayload && !ge(n))
|
|
185
187
|
return I("Contour layer has not been loaded.", "NOT_LOADED");
|
|
186
188
|
const s = await this.baseGIS.updateContourLayer(n);
|
|
187
189
|
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;
|
|
@@ -225,7 +227,8 @@ class Re {
|
|
|
225
227
|
contours: [],
|
|
226
228
|
isolines: [],
|
|
227
229
|
isoline: [],
|
|
228
|
-
lines: []
|
|
230
|
+
lines: [],
|
|
231
|
+
centers: []
|
|
229
232
|
} : null, this.syncStateFromResult(n)), n;
|
|
230
233
|
}
|
|
231
234
|
refreshState(e = {}) {
|
|
@@ -245,6 +248,9 @@ class Re {
|
|
|
245
248
|
sourceCount: 0,
|
|
246
249
|
levelCount: 0,
|
|
247
250
|
lineCount: 0,
|
|
251
|
+
centerCount: 0,
|
|
252
|
+
lineLabelCount: 0,
|
|
253
|
+
centerLabelCount: 0,
|
|
248
254
|
labelCount: 0,
|
|
249
255
|
visible: !1,
|
|
250
256
|
destroyed: !0
|
|
@@ -258,6 +264,9 @@ class Re {
|
|
|
258
264
|
sourceCount: 0,
|
|
259
265
|
levelCount: 0,
|
|
260
266
|
lineCount: 0,
|
|
267
|
+
centerCount: 0,
|
|
268
|
+
lineLabelCount: 0,
|
|
269
|
+
centerLabelCount: 0,
|
|
261
270
|
labelCount: 0,
|
|
262
271
|
visible: !1,
|
|
263
272
|
destroyed: !0
|
|
@@ -269,10 +278,10 @@ class Re {
|
|
|
269
278
|
getState() {
|
|
270
279
|
var e, r, n, s, i, o, a;
|
|
271
280
|
if ((r = (e = this.baseGIS) == null ? void 0 : e.getMapInstance) != null && r.call(e) && this.currentPayload) {
|
|
272
|
-
const
|
|
281
|
+
const u = (s = (n = this.baseGIS).getContourLayerState) == null ? void 0 : s.call(n, {
|
|
273
282
|
layerId: this.currentPayload.layerId || this.options.layerId
|
|
274
283
|
});
|
|
275
|
-
|
|
284
|
+
u != null && u.success && this.syncStateFromResult(u);
|
|
276
285
|
}
|
|
277
286
|
return {
|
|
278
287
|
mounted: !!this.baseGIS,
|
|
@@ -285,11 +294,11 @@ class Re {
|
|
|
285
294
|
};
|
|
286
295
|
}
|
|
287
296
|
}
|
|
288
|
-
function
|
|
297
|
+
function R(t, e = 0) {
|
|
289
298
|
const r = Number(t);
|
|
290
299
|
return Number.isFinite(r) ? r : e;
|
|
291
300
|
}
|
|
292
|
-
function
|
|
301
|
+
function Ie(t, e = {
|
|
293
302
|
startLon: 73,
|
|
294
303
|
startLat: 18,
|
|
295
304
|
endLon: 135,
|
|
@@ -297,27 +306,27 @@ function de(t, e = {
|
|
|
297
306
|
}) {
|
|
298
307
|
const r = t && typeof t == "object" ? t : e;
|
|
299
308
|
return {
|
|
300
|
-
startLon:
|
|
301
|
-
startLat:
|
|
302
|
-
endLon:
|
|
303
|
-
endLat:
|
|
309
|
+
startLon: R(r.startLon, e.startLon),
|
|
310
|
+
startLat: R(r.startLat, e.startLat),
|
|
311
|
+
endLon: R(r.endLon, e.endLon),
|
|
312
|
+
endLat: R(r.endLat, e.endLat)
|
|
304
313
|
};
|
|
305
314
|
}
|
|
306
|
-
function
|
|
315
|
+
function qe(t) {
|
|
307
316
|
return !!(t && typeof t.getEngineType == "function" && typeof t.getMapInstance == "function" && typeof t.upsertGridLayer == "function" && typeof t.showGridLayer == "function" && typeof t.hideGridLayer == "function" && typeof t.removeGridLayer == "function");
|
|
308
317
|
}
|
|
309
|
-
function
|
|
318
|
+
function He(t = {}) {
|
|
310
319
|
return !!(t.tifUrl || t.imageUrl || t.grayImageUrl || t.imageGridData);
|
|
311
320
|
}
|
|
312
|
-
class
|
|
321
|
+
class Ar {
|
|
313
322
|
constructor(e = {}) {
|
|
314
323
|
this.options = {
|
|
315
324
|
visible: e.visible ?? !0,
|
|
316
325
|
layerId: e.layerId || "grid-layer-default",
|
|
317
|
-
defaultArea:
|
|
318
|
-
gridTotal:
|
|
319
|
-
tileSize:
|
|
320
|
-
decimalPlaces:
|
|
326
|
+
defaultArea: Ie(e.defaultArea),
|
|
327
|
+
gridTotal: R(e.gridTotal, 4),
|
|
328
|
+
tileSize: R(e.tileSize, 512),
|
|
329
|
+
decimalPlaces: R(e.decimalPlaces, 2),
|
|
321
330
|
showLabel: !!e.showLabel,
|
|
322
331
|
showProbe: !!e.showProbe,
|
|
323
332
|
colorize: e.colorize || null
|
|
@@ -325,7 +334,7 @@ class br {
|
|
|
325
334
|
}
|
|
326
335
|
mount(e) {
|
|
327
336
|
var r, n;
|
|
328
|
-
return
|
|
337
|
+
return qe(e) ? (this.baseGIS = e, L(
|
|
329
338
|
{ engineType: ((n = (r = this.baseGIS).getEngineType) == null ? void 0 : n.call(r)) || "unknown" },
|
|
330
339
|
"GridLayerController mounted with BaseGIS."
|
|
331
340
|
)) : I(
|
|
@@ -345,14 +354,14 @@ class br {
|
|
|
345
354
|
return typeof e == "string" && e ? e : (e == null ? void 0 : e.layerId) || (e == null ? void 0 : e.gridLayerId) || ((r = this.currentPayload) == null ? void 0 : r.layerId) || this.options.layerId;
|
|
346
355
|
}
|
|
347
356
|
buildPayload(e = {}) {
|
|
348
|
-
const r = e.imageUrl || e.grayImageUrl || e.imageGridData, n = e.area ?
|
|
357
|
+
const r = e.imageUrl || e.grayImageUrl || e.imageGridData, n = e.area ? Ie(e.area, this.options.defaultArea) : r ? this.options.defaultArea : void 0;
|
|
349
358
|
return {
|
|
350
359
|
...e,
|
|
351
360
|
layerId: this.getLayerId(e),
|
|
352
361
|
area: n,
|
|
353
|
-
gridTotal:
|
|
354
|
-
tileSize:
|
|
355
|
-
decimalPlaces:
|
|
362
|
+
gridTotal: R(e.gridTotal, this.options.gridTotal),
|
|
363
|
+
tileSize: R(e.tileSize, this.options.tileSize),
|
|
364
|
+
decimalPlaces: R(e.decimalPlaces, this.options.decimalPlaces),
|
|
356
365
|
showLabel: typeof e.showLabel == "boolean" ? e.showLabel : this.options.showLabel,
|
|
357
366
|
showProbe: typeof e.showProbe == "boolean" ? e.showProbe : this.options.showProbe,
|
|
358
367
|
colorize: e.colorize || this.options.colorize,
|
|
@@ -364,7 +373,7 @@ class br {
|
|
|
364
373
|
const r = this.resolveBaseGIS();
|
|
365
374
|
if (!r.success)
|
|
366
375
|
return r;
|
|
367
|
-
if (!
|
|
376
|
+
if (!He(e))
|
|
368
377
|
return I(
|
|
369
378
|
"Grid layer requires tifUrl, imageUrl, grayImageUrl or imageGridData.",
|
|
370
379
|
"INVALID_GRID_SOURCE"
|
|
@@ -436,14 +445,14 @@ class br {
|
|
|
436
445
|
};
|
|
437
446
|
}
|
|
438
447
|
}
|
|
439
|
-
const
|
|
448
|
+
const _ = /* @__PURE__ */ new Map(), Xe = {
|
|
440
449
|
maxSize: 12
|
|
441
450
|
};
|
|
442
451
|
function x(t, e = 0) {
|
|
443
452
|
const r = Number(t);
|
|
444
453
|
return Number.isFinite(r) ? r : e;
|
|
445
454
|
}
|
|
446
|
-
function
|
|
455
|
+
function me(t) {
|
|
447
456
|
if (Array.isArray(t) && t.length >= 2) {
|
|
448
457
|
const e = Number(t[0]), r = Number(t[1]);
|
|
449
458
|
return Number.isFinite(e) && Number.isFinite(r) ? { lat: e, lng: r } : null;
|
|
@@ -454,7 +463,7 @@ function fe(t) {
|
|
|
454
463
|
}
|
|
455
464
|
return null;
|
|
456
465
|
}
|
|
457
|
-
function
|
|
466
|
+
function le(t) {
|
|
458
467
|
if (!t) return null;
|
|
459
468
|
if (typeof t.getWest == "function" && typeof t.getSouth == "function" && typeof t.getEast == "function" && typeof t.getNorth == "function")
|
|
460
469
|
return {
|
|
@@ -471,7 +480,7 @@ function re(t) {
|
|
|
471
480
|
endLon: t[2],
|
|
472
481
|
endLat: t[3]
|
|
473
482
|
};
|
|
474
|
-
const e =
|
|
483
|
+
const e = me(t[0]), r = me(t[1]);
|
|
475
484
|
if (e && r)
|
|
476
485
|
return {
|
|
477
486
|
startLon: e.lng,
|
|
@@ -482,11 +491,11 @@ function re(t) {
|
|
|
482
491
|
}
|
|
483
492
|
if (t && typeof t == "object") {
|
|
484
493
|
if (t.area) {
|
|
485
|
-
const e =
|
|
494
|
+
const e = le(t.area);
|
|
486
495
|
if (e) return e;
|
|
487
496
|
}
|
|
488
497
|
if (t._southWest && t._northEast)
|
|
489
|
-
return
|
|
498
|
+
return le([t._southWest, t._northEast]);
|
|
490
499
|
if (["west", "south", "east", "north"].every(
|
|
491
500
|
(e) => Number.isFinite(Number(t[e]))
|
|
492
501
|
))
|
|
@@ -504,7 +513,7 @@ function re(t) {
|
|
|
504
513
|
return null;
|
|
505
514
|
}
|
|
506
515
|
function j(t) {
|
|
507
|
-
const e =
|
|
516
|
+
const e = le(t);
|
|
508
517
|
if (!e) return null;
|
|
509
518
|
const r = Number(e.startLon), n = Number(e.startLat), s = Number(e.endLon), i = Number(e.endLat);
|
|
510
519
|
return [r, n, s, i].every(Number.isFinite) ? {
|
|
@@ -514,7 +523,7 @@ function j(t) {
|
|
|
514
523
|
endLat: Math.max(n, i)
|
|
515
524
|
} : null;
|
|
516
525
|
}
|
|
517
|
-
function
|
|
526
|
+
function H(t, e = {
|
|
518
527
|
startLon: 73,
|
|
519
528
|
startLat: 18,
|
|
520
529
|
endLon: 135,
|
|
@@ -533,31 +542,31 @@ function q(t, e = {
|
|
|
533
542
|
endLat: Math.max(i, a)
|
|
534
543
|
};
|
|
535
544
|
}
|
|
536
|
-
function
|
|
545
|
+
function Ke() {
|
|
537
546
|
return typeof window < "u" && typeof document < "u";
|
|
538
547
|
}
|
|
539
|
-
function
|
|
548
|
+
function Ze(t) {
|
|
540
549
|
return `${t || ""}`.toUpperCase() === "EPSG:3857";
|
|
541
550
|
}
|
|
542
|
-
function
|
|
551
|
+
function Z(t, e = "EPSG:4326") {
|
|
543
552
|
return `${t || e}`.toUpperCase();
|
|
544
553
|
}
|
|
545
|
-
function
|
|
554
|
+
function fe(t) {
|
|
546
555
|
const e = j(t);
|
|
547
556
|
return e ? [e.startLon, e.startLat, e.endLon, e.endLat].every((r) => Math.abs(Number(r)) <= 180) : !1;
|
|
548
557
|
}
|
|
549
|
-
function
|
|
558
|
+
function ue(t, e) {
|
|
550
559
|
const r = 85.0511287798066, n = Math.min(Math.max(Number(t), -r), r), s = Number(e), i = 6378137, o = i * s * Math.PI / 180, a = i * Math.log(Math.tan(Math.PI / 4 + n * Math.PI / 360));
|
|
551
560
|
return { x: o, y: a };
|
|
552
561
|
}
|
|
553
|
-
function
|
|
562
|
+
function be(t, e) {
|
|
554
563
|
const n = Number(t) / 6378137 * 180 / Math.PI;
|
|
555
564
|
return { lat: (2 * Math.atan(Math.exp(Number(e) / 6378137)) - Math.PI / 2) * 180 / Math.PI, lng: n };
|
|
556
565
|
}
|
|
557
|
-
function
|
|
566
|
+
function Je(t) {
|
|
558
567
|
const e = j(t);
|
|
559
568
|
if (!e) return null;
|
|
560
|
-
const r =
|
|
569
|
+
const r = ue(e.startLat, e.startLon), n = ue(e.endLat, e.endLon);
|
|
561
570
|
return {
|
|
562
571
|
startLon: r.x,
|
|
563
572
|
startLat: r.y,
|
|
@@ -565,11 +574,11 @@ function He(t) {
|
|
|
565
574
|
endLat: n.y
|
|
566
575
|
};
|
|
567
576
|
}
|
|
568
|
-
function
|
|
577
|
+
function ce(t) {
|
|
569
578
|
const e = j(t);
|
|
570
579
|
if (!e) return null;
|
|
571
|
-
if (
|
|
572
|
-
const r =
|
|
580
|
+
if (fe(e)) return e;
|
|
581
|
+
const r = be(e.startLon, e.startLat), n = be(e.endLon, e.endLat);
|
|
573
582
|
return {
|
|
574
583
|
startLon: r.lng,
|
|
575
584
|
startLat: r.lat,
|
|
@@ -577,13 +586,13 @@ function se(t) {
|
|
|
577
586
|
endLat: n.lat
|
|
578
587
|
};
|
|
579
588
|
}
|
|
580
|
-
function
|
|
589
|
+
function Qe(t) {
|
|
581
590
|
return new Promise((e, r) => {
|
|
582
591
|
const n = new Image();
|
|
583
592
|
n.crossOrigin = "anonymous", n.onload = () => e(n), n.onerror = () => r(new Error(`图片加载失败:${t}`)), n.src = t;
|
|
584
593
|
});
|
|
585
594
|
}
|
|
586
|
-
function
|
|
595
|
+
function et(t, e, r) {
|
|
587
596
|
const n = j(r) || {};
|
|
588
597
|
return [
|
|
589
598
|
t,
|
|
@@ -594,61 +603,61 @@ function Ke(t, e, r) {
|
|
|
594
603
|
n.endLat
|
|
595
604
|
].join("|");
|
|
596
605
|
}
|
|
597
|
-
function
|
|
606
|
+
function tt(t, e) {
|
|
598
607
|
if (!(!t || !e))
|
|
599
|
-
for (
|
|
600
|
-
const r =
|
|
601
|
-
|
|
608
|
+
for (_.has(t) && _.delete(t), _.set(t, e); _.size > Xe.maxSize; ) {
|
|
609
|
+
const r = _.keys().next().value;
|
|
610
|
+
_.delete(r);
|
|
602
611
|
}
|
|
603
612
|
}
|
|
604
|
-
async function
|
|
605
|
-
const r = j(e), n =
|
|
606
|
-
if (!
|
|
613
|
+
async function rt(t, e) {
|
|
614
|
+
const r = j(e), n = ce(r);
|
|
615
|
+
if (!Ke() || !r || !n || fe(r))
|
|
607
616
|
return t;
|
|
608
|
-
const s = await
|
|
617
|
+
const s = await Qe(t), i = s.naturalWidth || s.width, o = s.naturalHeight || s.height, a = document.createElement("canvas");
|
|
609
618
|
a.width = i, a.height = o;
|
|
610
|
-
const
|
|
611
|
-
|
|
612
|
-
const l =
|
|
613
|
-
|
|
614
|
-
const h =
|
|
615
|
-
if (!Number.isFinite(
|
|
619
|
+
const u = a.getContext("2d", { willReadFrequently: !0 });
|
|
620
|
+
u.drawImage(s, 0, 0, i, o);
|
|
621
|
+
const l = u.getImageData(0, 0, i, o), c = document.createElement("canvas");
|
|
622
|
+
c.width = i, c.height = o;
|
|
623
|
+
const h = c.getContext("2d", { willReadFrequently: !0 }), f = h.createImageData(i, o), d = l.data, y = f.data, m = Math.min(Number(r.startLat), Number(r.endLat)), S = Math.max(Number(r.startLat), Number(r.endLat)), g = S - m;
|
|
624
|
+
if (!Number.isFinite(g) || g === 0)
|
|
616
625
|
return t;
|
|
617
|
-
for (let
|
|
618
|
-
const
|
|
619
|
-
y.set(
|
|
626
|
+
for (let v = 0; v < o; v += 1) {
|
|
627
|
+
const b = n.endLat - (n.endLat - n.startLat) * v / Math.max(o - 1, 1), w = ue(b, 0), G = Math.round((S - w.y) / g * (o - 1)), T = Math.min(Math.max(G, 0), o - 1) * i * 4, N = v * i * 4;
|
|
628
|
+
y.set(d.subarray(T, T + i * 4), N);
|
|
620
629
|
}
|
|
621
|
-
return h.putImageData(
|
|
630
|
+
return h.putImageData(f, 0, 0), c.toDataURL("image/png");
|
|
622
631
|
}
|
|
623
|
-
async function
|
|
624
|
-
const e =
|
|
625
|
-
if (!(t != null && t.imageUrl) || !
|
|
632
|
+
async function Se(t) {
|
|
633
|
+
const e = Z(t == null ? void 0 : t.sourceProjection, ""), r = Z(t == null ? void 0 : t.targetProjection);
|
|
634
|
+
if (!(t != null && t.imageUrl) || !Ze(e) || e === r)
|
|
626
635
|
return t;
|
|
627
|
-
const n = t.sourceArea || t.area, s =
|
|
628
|
-
if (
|
|
636
|
+
const n = t.sourceArea || t.area, s = et(t.imageUrl, `${e}_${r}`, n);
|
|
637
|
+
if (_.has(s))
|
|
629
638
|
return {
|
|
630
639
|
...t,
|
|
631
|
-
imageUrl:
|
|
632
|
-
area:
|
|
640
|
+
imageUrl: _.get(s),
|
|
641
|
+
area: H(ce(n) || t.area, t.area)
|
|
633
642
|
};
|
|
634
|
-
const i =
|
|
643
|
+
const i = ce(n) || t.area;
|
|
635
644
|
let o = null;
|
|
636
|
-
|
|
637
|
-
const a = await
|
|
638
|
-
return
|
|
645
|
+
fe(n) ? o = Je(n) : o = j(n);
|
|
646
|
+
const a = await rt(t.imageUrl, o);
|
|
647
|
+
return tt(s, a), {
|
|
639
648
|
...t,
|
|
640
649
|
imageUrl: a,
|
|
641
|
-
area:
|
|
650
|
+
area: H(i, t.area)
|
|
642
651
|
};
|
|
643
652
|
}
|
|
644
|
-
function
|
|
653
|
+
function Le(t = {}, e = 0, r = void 0) {
|
|
645
654
|
return {
|
|
646
655
|
id: (t == null ? void 0 : t.id) || `image-${e}`,
|
|
647
656
|
name: (t == null ? void 0 : t.name) || `Image ${e + 1}`,
|
|
648
657
|
imageUrl: (t == null ? void 0 : t.imageUrl) || "",
|
|
649
658
|
tifUrl: (t == null ? void 0 : t.tifUrl) || "",
|
|
650
659
|
description: (t == null ? void 0 : t.description) || "",
|
|
651
|
-
area:
|
|
660
|
+
area: H(t == null ? void 0 : t.area, r),
|
|
652
661
|
opacity: t == null ? void 0 : t.opacity,
|
|
653
662
|
zIndex: t == null ? void 0 : t.zIndex,
|
|
654
663
|
isSplit: t == null ? void 0 : t.isSplit,
|
|
@@ -676,16 +685,16 @@ function me(t = {}, e = 0, r = void 0) {
|
|
|
676
685
|
sourceArea: t == null ? void 0 : t.sourceArea
|
|
677
686
|
};
|
|
678
687
|
}
|
|
679
|
-
function
|
|
688
|
+
function nt(t) {
|
|
680
689
|
return !!(t && typeof t.getEngineType == "function" && typeof t.getMapInstance == "function" && typeof t.upsertImageLayer == "function" && typeof t.showImageLayer == "function" && typeof t.hideImageLayer == "function" && typeof t.removeImageLayer == "function");
|
|
681
690
|
}
|
|
682
|
-
class
|
|
691
|
+
class Er {
|
|
683
692
|
constructor(e = {}) {
|
|
684
693
|
this.options = {
|
|
685
694
|
visible: e.visible ?? !0,
|
|
686
695
|
opacity: x(e.opacity, 0.85),
|
|
687
696
|
zIndex: x(e.zIndex, 650),
|
|
688
|
-
defaultArea:
|
|
697
|
+
defaultArea: H(e.defaultArea),
|
|
689
698
|
gridTotal: x(e.gridTotal, 4),
|
|
690
699
|
tileSize: x(e.tileSize, 512),
|
|
691
700
|
decimalPlaces: x(e.decimalPlaces, 2),
|
|
@@ -700,7 +709,7 @@ class pr {
|
|
|
700
709
|
*/
|
|
701
710
|
mount(e) {
|
|
702
711
|
var r, n;
|
|
703
|
-
return
|
|
712
|
+
return nt(e) ? (this._operationRequestId += 1, this.baseGIS = e, L(
|
|
704
713
|
{ engineType: ((n = (r = this.baseGIS).getEngineType) == null ? void 0 : n.call(r)) || "unknown" },
|
|
705
714
|
"ImageLayerController mounted with BaseGIS."
|
|
706
715
|
)) : I(
|
|
@@ -720,18 +729,18 @@ class pr {
|
|
|
720
729
|
}
|
|
721
730
|
/* 获取图片图层目标投影 */
|
|
722
731
|
getTargetProjectionFn(e = {}) {
|
|
723
|
-
var s, i, o, a,
|
|
732
|
+
var s, i, o, a, u, l, c, h, f;
|
|
724
733
|
if (e.targetProjection)
|
|
725
|
-
return
|
|
726
|
-
const r = (i = (s = this.baseGIS) == null ? void 0 : s.getMapInstance) == null ? void 0 : i.call(s), n = ((a = (o = r == null ? void 0 : r.options) == null ? void 0 : o.crs) == null ? void 0 : a.code) || ((
|
|
727
|
-
return n ?
|
|
734
|
+
return Z(e.targetProjection);
|
|
735
|
+
const r = (i = (s = this.baseGIS) == null ? void 0 : s.getMapInstance) == null ? void 0 : i.call(s), n = ((a = (o = r == null ? void 0 : r.options) == null ? void 0 : o.crs) == null ? void 0 : a.code) || ((c = (l = (u = r == null ? void 0 : r.options) == null ? void 0 : u.crs) == null ? void 0 : l.options) == null ? void 0 : c.code);
|
|
736
|
+
return n ? Z(n) : (((f = (h = this.baseGIS) == null ? void 0 : h.getEngineType) == null ? void 0 : f.call(h)) === "leaflet", "EPSG:4326");
|
|
728
737
|
}
|
|
729
738
|
buildLayerPayload(e, r = {}) {
|
|
730
739
|
return {
|
|
731
740
|
layerId: this.getLayerId(r),
|
|
732
741
|
imageUrl: e.imageUrl,
|
|
733
742
|
tifUrl: e.tifUrl,
|
|
734
|
-
area:
|
|
743
|
+
area: H(e.area, this.options.defaultArea),
|
|
735
744
|
isSplit: !!e.isSplit,
|
|
736
745
|
imageSourceType: e.imageSourceType || this.options.imageSourceType,
|
|
737
746
|
isGrayImage: e.isGrayImage,
|
|
@@ -764,7 +773,7 @@ class pr {
|
|
|
764
773
|
async load(e = [], r = {}) {
|
|
765
774
|
if (!Array.isArray(e) || e.length === 0)
|
|
766
775
|
return I("Image list is empty.", "INVALID_ITEMS");
|
|
767
|
-
const n = e.map((i, o) =>
|
|
776
|
+
const n = e.map((i, o) => Le(i, o, this.options.defaultArea)).filter((i) => i.imageUrl || i.tifUrl);
|
|
768
777
|
if (n.length === 0)
|
|
769
778
|
return I("No valid imageUrl or tifUrl found in items.", "INVALID_ITEMS");
|
|
770
779
|
this.items = n, typeof r.visible == "boolean" && (this.visible = r.visible);
|
|
@@ -776,7 +785,7 @@ class pr {
|
|
|
776
785
|
* target 可传索引数字,也可传图片 id。
|
|
777
786
|
*/
|
|
778
787
|
async switchTo(e) {
|
|
779
|
-
var l,
|
|
788
|
+
var l, c;
|
|
780
789
|
const r = this.resolveBaseGIS();
|
|
781
790
|
if (!r.success)
|
|
782
791
|
return r;
|
|
@@ -785,17 +794,17 @@ class pr {
|
|
|
785
794
|
let n = -1;
|
|
786
795
|
if (typeof e == "number" ? n = e : typeof e == "string" && (n = this.items.findIndex((h) => h.id === e)), n < 0 || n >= this.items.length)
|
|
787
796
|
return I(`Invalid image target "${e}".`, "INVALID_TARGET");
|
|
788
|
-
const s = this.items[n], i = await
|
|
797
|
+
const s = this.items[n], i = await Se({
|
|
789
798
|
...s,
|
|
790
799
|
targetProjection: this.getTargetProjectionFn(s)
|
|
791
|
-
}), o = this.buildLayerPayload(i), a = ++this._operationRequestId,
|
|
792
|
-
return a !== this._operationRequestId || (l =
|
|
800
|
+
}), o = this.buildLayerPayload(i), a = ++this._operationRequestId, u = await this.baseGIS.upsertImageLayer(o);
|
|
801
|
+
return a !== this._operationRequestId || (l = u == null ? void 0 : u.data) != null && l.stale ? L(
|
|
793
802
|
{ stale: !0, ignored: !0 },
|
|
794
803
|
`Image switch to "${s.name}" was superseded.`
|
|
795
|
-
) :
|
|
804
|
+
) : u.success ? (this.activeIndex = n, this.layerType = ((c = u == null ? void 0 : u.data) == null ? void 0 : c.layerType) || this.layerType, this.currentPayload = o, L(
|
|
796
805
|
{ activeIndex: n, activeItem: i },
|
|
797
806
|
`Image switched to "${i.name}".`
|
|
798
|
-
)) :
|
|
807
|
+
)) : u;
|
|
799
808
|
}
|
|
800
809
|
/**
|
|
801
810
|
* 更新当前图片图层数据。
|
|
@@ -804,11 +813,11 @@ class pr {
|
|
|
804
813
|
* 与 load(items) 不同,update(payload) 不要求维护图片数组,也不表达 next / prev 两态。
|
|
805
814
|
*/
|
|
806
815
|
async update(e = {}) {
|
|
807
|
-
var
|
|
816
|
+
var c, h;
|
|
808
817
|
const r = this.resolveBaseGIS();
|
|
809
818
|
if (!r.success)
|
|
810
819
|
return r;
|
|
811
|
-
const n = this.items[this.activeIndex] || {}, s = this.activeIndex >= 0 ? this.activeIndex : 0, i =
|
|
820
|
+
const n = this.items[this.activeIndex] || {}, s = this.activeIndex >= 0 ? this.activeIndex : 0, i = Le(
|
|
812
821
|
{
|
|
813
822
|
...n,
|
|
814
823
|
...e,
|
|
@@ -820,8 +829,8 @@ class pr {
|
|
|
820
829
|
if (!i.imageUrl && !i.tifUrl)
|
|
821
830
|
return I("Image layer update requires imageUrl or tifUrl.", "INVALID_ITEM");
|
|
822
831
|
typeof e.visible == "boolean" && (this.visible = e.visible);
|
|
823
|
-
const o = await
|
|
824
|
-
return
|
|
832
|
+
const o = await Se(i), a = this.buildLayerPayload(o, e), u = ++this._operationRequestId, l = await this.baseGIS.upsertImageLayer(a);
|
|
833
|
+
return u !== this._operationRequestId || (c = l == null ? void 0 : l.data) != null && c.stale ? L(
|
|
825
834
|
{ stale: !0, ignored: !0 },
|
|
826
835
|
`Image layer update "${i.name}" was superseded.`
|
|
827
836
|
) : l.success ? (this.items.length === 0 ? (this.items = [o], this.activeIndex = 0) : (this.items.splice(s, 1, o), this.activeIndex = s), this.layerType = ((h = l == null ? void 0 : l.data) == null ? void 0 : h.layerType) || this.layerType, this.currentPayload = a, L(
|
|
@@ -888,25 +897,584 @@ class pr {
|
|
|
888
897
|
};
|
|
889
898
|
}
|
|
890
899
|
}
|
|
900
|
+
const st = {
|
|
901
|
+
color: "#2f80ff",
|
|
902
|
+
width: 3,
|
|
903
|
+
opacity: 1,
|
|
904
|
+
pattern: "solid",
|
|
905
|
+
dashLength: 12,
|
|
906
|
+
gapLength: 8
|
|
907
|
+
}, it = {
|
|
908
|
+
enabled: !1,
|
|
909
|
+
mode: "reveal",
|
|
910
|
+
durationMs: 1e4,
|
|
911
|
+
autoplay: !0,
|
|
912
|
+
loop: !1
|
|
913
|
+
};
|
|
914
|
+
function X(t, e) {
|
|
915
|
+
return Object.prototype.hasOwnProperty.call(t || {}, e);
|
|
916
|
+
}
|
|
917
|
+
function M(t) {
|
|
918
|
+
return !!(t && typeof t == "object" && !Array.isArray(t));
|
|
919
|
+
}
|
|
891
920
|
function $(t = {}) {
|
|
921
|
+
return Array.isArray(t) ? { lines: t } : M(t) ? t : {};
|
|
922
|
+
}
|
|
923
|
+
function ot(t, e) {
|
|
924
|
+
if (!M(e))
|
|
925
|
+
return e;
|
|
926
|
+
const r = M(t) ? t : {};
|
|
927
|
+
return {
|
|
928
|
+
...r,
|
|
929
|
+
...e,
|
|
930
|
+
flow: M(e.flow) ? {
|
|
931
|
+
...M(r.flow) ? r.flow : {},
|
|
932
|
+
...e.flow
|
|
933
|
+
} : e.flow ?? r.flow
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
function Be(t = {}, e = {}) {
|
|
937
|
+
if (!M(e))
|
|
938
|
+
return { ...M(t) ? t : {} };
|
|
939
|
+
const r = {
|
|
940
|
+
...M(t) ? t : {},
|
|
941
|
+
...e
|
|
942
|
+
};
|
|
943
|
+
return X(e, "color") && (r.color = ot(t == null ? void 0 : t.color, e.color)), r.weight !== void 0 && !X(e, "width") && (r.width = r.weight), r;
|
|
944
|
+
}
|
|
945
|
+
function De(t = {}, e = {}) {
|
|
946
|
+
return M(e) ? {
|
|
947
|
+
...M(t) ? t : {},
|
|
948
|
+
...e,
|
|
949
|
+
icon: M(e.icon) ? {
|
|
950
|
+
...M(t == null ? void 0 : t.icon) ? t.icon : {},
|
|
951
|
+
...e.icon
|
|
952
|
+
} : e.icon ?? (t == null ? void 0 : t.icon)
|
|
953
|
+
} : { ...M(t) ? t : {} };
|
|
954
|
+
}
|
|
955
|
+
function te(t = {}, e = {}) {
|
|
956
|
+
const r = $(t), n = $(e), s = {
|
|
957
|
+
...r,
|
|
958
|
+
...n
|
|
959
|
+
};
|
|
960
|
+
return s.style = Be(r.style, X(n, "style") ? n.style : {}), s.animation = De(
|
|
961
|
+
r.animation,
|
|
962
|
+
X(n, "animation") ? n.animation : {}
|
|
963
|
+
), s;
|
|
964
|
+
}
|
|
965
|
+
function at(t = {}) {
|
|
966
|
+
const { mapCore: e, baseGIS: r, ...n } = t;
|
|
967
|
+
return n;
|
|
968
|
+
}
|
|
969
|
+
function lt(t, e = "style.color") {
|
|
970
|
+
if (typeof t == "string" && t.trim())
|
|
971
|
+
return "";
|
|
972
|
+
if (!M(t) || t.type !== "gradient")
|
|
973
|
+
return `${e} must be a CSS color string or a gradient object.`;
|
|
974
|
+
if (!Array.isArray(t.stops) || t.stops.length < 2)
|
|
975
|
+
return `${e}.stops requires at least two gradient stops.`;
|
|
976
|
+
let r = -1;
|
|
977
|
+
for (let n = 0; n < t.stops.length; n += 1) {
|
|
978
|
+
const s = t.stops[n], i = Number(s == null ? void 0 : s.offset);
|
|
979
|
+
if (!Number.isFinite(i) || i < 0 || i > 1 || i < r)
|
|
980
|
+
return `${e}.stops[${n}].offset must be ordered between 0 and 1.`;
|
|
981
|
+
if (typeof (s == null ? void 0 : s.color) != "string" || !s.color.trim())
|
|
982
|
+
return `${e}.stops[${n}].color must be a CSS color string.`;
|
|
983
|
+
r = i;
|
|
984
|
+
}
|
|
985
|
+
if (M(t.flow) && t.flow.enabled === !0) {
|
|
986
|
+
const n = Number(t.flow.durationMs ?? 2400);
|
|
987
|
+
if (!Number.isFinite(n) || n <= 0)
|
|
988
|
+
return `${e}.flow.durationMs must be greater than 0.`;
|
|
989
|
+
if (t.flow.direction !== void 0 && !["forward", "reverse"].includes(t.flow.direction))
|
|
990
|
+
return `${e}.flow.direction must be "forward" or "reverse".`;
|
|
991
|
+
}
|
|
992
|
+
return "";
|
|
993
|
+
}
|
|
994
|
+
function Oe(t = {}, e = "style") {
|
|
995
|
+
if (!M(t))
|
|
996
|
+
return `${e} must be an object.`;
|
|
997
|
+
if (t.pattern !== void 0 && !["solid", "dashed"].includes(t.pattern))
|
|
998
|
+
return `${e}.pattern must be "solid" or "dashed".`;
|
|
999
|
+
for (const r of ["width", "dashLength", "gapLength"])
|
|
1000
|
+
if (t[r] !== void 0 && (!Number.isFinite(Number(t[r])) || Number(t[r]) <= 0))
|
|
1001
|
+
return `${e}.${r} must be greater than 0.`;
|
|
1002
|
+
return t.opacity !== void 0 && (!Number.isFinite(Number(t.opacity)) || Number(t.opacity) < 0 || Number(t.opacity) > 1) ? `${e}.opacity must be between 0 and 1.` : t.color === void 0 ? "" : lt(t.color, `${e}.color`);
|
|
1003
|
+
}
|
|
1004
|
+
function ut(t) {
|
|
1005
|
+
if (!Array.isArray(t) || t.length === 0)
|
|
1006
|
+
return "Line layer requires a non-empty lines array.";
|
|
1007
|
+
const e = /* @__PURE__ */ new Set();
|
|
1008
|
+
for (let r = 0; r < t.length; r += 1) {
|
|
1009
|
+
const n = t[r], s = n == null ? void 0 : n.id;
|
|
1010
|
+
if (s == null || String(s).trim() === "")
|
|
1011
|
+
return `lines[${r}].id is required.`;
|
|
1012
|
+
if (e.has(String(s)))
|
|
1013
|
+
return `Line id "${s}" is duplicated.`;
|
|
1014
|
+
if (e.add(String(s)), !Array.isArray(n.positions) || n.positions.length < 2)
|
|
1015
|
+
return `lines[${r}].positions requires at least two coordinates.`;
|
|
1016
|
+
for (let i = 0; i < n.positions.length; i += 1) {
|
|
1017
|
+
const o = n.positions[i], a = Number(o == null ? void 0 : o[0]), u = Number(o == null ? void 0 : o[1]), l = (o == null ? void 0 : o.length) > 2 ? Number(o[2]) : 0;
|
|
1018
|
+
if (!Array.isArray(o) || !Number.isFinite(a) || !Number.isFinite(u) || u < -90 || u > 90 || !Number.isFinite(l))
|
|
1019
|
+
return `lines[${r}].positions[${i}] must be [longitude, latitude, height?].`;
|
|
1020
|
+
}
|
|
1021
|
+
if (n.style !== void 0) {
|
|
1022
|
+
const i = Oe(n.style, `lines[${r}].style`);
|
|
1023
|
+
if (i) return i;
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
return "";
|
|
1027
|
+
}
|
|
1028
|
+
function ct(t = {}, e = []) {
|
|
1029
|
+
if (!(t != null && t.enabled))
|
|
1030
|
+
return "";
|
|
1031
|
+
if (t.mode !== void 0 && t.mode !== "reveal")
|
|
1032
|
+
return 'animation.mode currently only supports "reveal".';
|
|
1033
|
+
const r = Number(t.durationMs);
|
|
1034
|
+
if (!Number.isFinite(r) || r <= 0)
|
|
1035
|
+
return "animation.durationMs must be greater than 0.";
|
|
1036
|
+
if (!t.lineId || !e.some((n) => String(n.id) === String(t.lineId)))
|
|
1037
|
+
return "animation.lineId must match an existing line id.";
|
|
1038
|
+
if (t.icon !== void 0 && t.icon !== null) {
|
|
1039
|
+
if (!M(t.icon))
|
|
1040
|
+
return "animation.icon must be an object.";
|
|
1041
|
+
if (t.icon.url !== void 0 && typeof t.icon.url != "string")
|
|
1042
|
+
return "animation.icon.url must be a string.";
|
|
1043
|
+
if (t.icon.size !== void 0 && (!Array.isArray(t.icon.size) || t.icon.size.length < 2 || t.icon.size.some((n) => !Number.isFinite(Number(n)) || Number(n) <= 0)))
|
|
1044
|
+
return "animation.icon.size must be [width, height].";
|
|
1045
|
+
}
|
|
1046
|
+
return "";
|
|
1047
|
+
}
|
|
1048
|
+
function re(t = {}) {
|
|
1049
|
+
var e, r;
|
|
1050
|
+
return !((e = t.animation) != null && e.enabled) || t.animation.lineId || ((r = t.lines) == null ? void 0 : r.length) !== 1 ? t : {
|
|
1051
|
+
...t,
|
|
1052
|
+
animation: {
|
|
1053
|
+
...t.animation,
|
|
1054
|
+
lineId: t.lines[0].id
|
|
1055
|
+
}
|
|
1056
|
+
};
|
|
1057
|
+
}
|
|
1058
|
+
function ve(t = {}) {
|
|
1059
|
+
const e = ut(t.lines);
|
|
1060
|
+
if (e) return e;
|
|
1061
|
+
const r = Oe(t.style);
|
|
1062
|
+
return r || ct(t.animation, t.lines);
|
|
1063
|
+
}
|
|
1064
|
+
function ht(t) {
|
|
1065
|
+
return !!(t && typeof t.getEngineType == "function" && typeof t.getMapInstance == "function" && typeof t.upsertLineLayer == "function" && typeof t.updateLineLayer == "function" && typeof t.showLineLayer == "function" && typeof t.hideLineLayer == "function" && typeof t.clearLineLayer == "function" && typeof t.removeLineLayer == "function" && typeof t.getLineLayerState == "function" && typeof t.playLineAnimation == "function" && typeof t.pauseLineAnimation == "function" && typeof t.restartLineAnimation == "function");
|
|
1066
|
+
}
|
|
1067
|
+
class Rr {
|
|
1068
|
+
constructor(e = {}) {
|
|
1069
|
+
const r = at(e), n = r.lineLayerId || r.layerId || r.id || "line-default";
|
|
1070
|
+
this.baseGIS = null, this.visible = r.visible !== !1, this.layerType = "unknown", this.defaultPayload = re({
|
|
1071
|
+
...r,
|
|
1072
|
+
layerId: n,
|
|
1073
|
+
visible: this.visible,
|
|
1074
|
+
style: Be(st, r.style || {}),
|
|
1075
|
+
animation: De(it, r.animation || {})
|
|
1076
|
+
}), this.currentPayload = null, this.currentState = {
|
|
1077
|
+
layerId: n,
|
|
1078
|
+
visible: this.visible,
|
|
1079
|
+
lineCount: 0,
|
|
1080
|
+
pointCount: 0,
|
|
1081
|
+
animationEnabled: !1,
|
|
1082
|
+
animationRunning: !1,
|
|
1083
|
+
animatedLineId: "",
|
|
1084
|
+
progress: 0,
|
|
1085
|
+
destroyed: !0
|
|
1086
|
+
}, (e.mapCore || e.baseGIS) && this.mount(e.mapCore || e.baseGIS);
|
|
1087
|
+
}
|
|
1088
|
+
mount(e) {
|
|
1089
|
+
var r;
|
|
1090
|
+
return ht(e) ? (this.baseGIS = e, L(
|
|
1091
|
+
{ engineType: ((r = e.getEngineType) == null ? void 0 : r.call(e)) || "unknown" },
|
|
1092
|
+
"LineLayerController mounted with BaseGIS."
|
|
1093
|
+
)) : I(
|
|
1094
|
+
"LineLayerController mount requires BaseGIS instance.",
|
|
1095
|
+
"INVALID_MOUNT_TARGET"
|
|
1096
|
+
);
|
|
1097
|
+
}
|
|
1098
|
+
resolveBaseGIS() {
|
|
1099
|
+
var e, r;
|
|
1100
|
+
return this.baseGIS ? (r = (e = this.baseGIS).getMapInstance) != null && r.call(e) ? L(null, "BaseGIS is ready.") : I(
|
|
1101
|
+
"Map instance is not ready. Please call mapCore.init() first.",
|
|
1102
|
+
"NOT_INITIALIZED"
|
|
1103
|
+
) : I("LineLayerController has not been mounted.", "NOT_MOUNTED");
|
|
1104
|
+
}
|
|
1105
|
+
getLayerId(e = {}) {
|
|
1106
|
+
var r;
|
|
1107
|
+
return typeof e == "string" || typeof e == "number" ? String(e) : e.lineLayerId || e.layerId || e.id || ((r = this.currentPayload) == null ? void 0 : r.layerId) || this.defaultPayload.layerId;
|
|
1108
|
+
}
|
|
1109
|
+
buildPayload(e = {}) {
|
|
1110
|
+
const r = $(e), n = te(this.defaultPayload, r);
|
|
1111
|
+
return n.layerId = this.getLayerId(n), n.visible = X(r, "visible") ? r.visible !== !1 : this.visible, re(n);
|
|
1112
|
+
}
|
|
1113
|
+
syncStateFromResult(e) {
|
|
1114
|
+
var s, i, o, a;
|
|
1115
|
+
const r = ((s = e == null ? void 0 : e.data) == null ? void 0 : s.state) || (e == null ? void 0 : e.data);
|
|
1116
|
+
if (!r || typeof r != "object") return;
|
|
1117
|
+
const n = (o = (i = this.baseGIS) == null ? void 0 : i.getEngineType) == null ? void 0 : o.call(i);
|
|
1118
|
+
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 = {
|
|
1119
|
+
...this.currentState,
|
|
1120
|
+
...r
|
|
1121
|
+
}, typeof r.visible == "boolean" && (this.visible = r.visible);
|
|
1122
|
+
}
|
|
1123
|
+
async load(e = {}, r = {}) {
|
|
1124
|
+
var a;
|
|
1125
|
+
const n = this.resolveBaseGIS();
|
|
1126
|
+
if (!n.success) return n;
|
|
1127
|
+
const s = this.buildPayload(
|
|
1128
|
+
te($(e), $(r))
|
|
1129
|
+
), i = ve(s);
|
|
1130
|
+
if (i)
|
|
1131
|
+
return I(i, "INVALID_LINE_LAYER_PAYLOAD");
|
|
1132
|
+
const o = await this.baseGIS.upsertLineLayer(s);
|
|
1133
|
+
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;
|
|
1134
|
+
}
|
|
1135
|
+
async update(e = {}) {
|
|
1136
|
+
var o;
|
|
1137
|
+
const r = this.resolveBaseGIS();
|
|
1138
|
+
if (!r.success) return r;
|
|
1139
|
+
if (!this.currentPayload)
|
|
1140
|
+
return I("Line layer has not been loaded.", "NOT_LOADED");
|
|
1141
|
+
const n = re(
|
|
1142
|
+
te(this.currentPayload, $(e))
|
|
1143
|
+
), s = ve(n);
|
|
1144
|
+
if (s)
|
|
1145
|
+
return I(s, "INVALID_LINE_LAYER_PAYLOAD");
|
|
1146
|
+
const i = await this.baseGIS.updateLineLayer(n);
|
|
1147
|
+
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;
|
|
1148
|
+
}
|
|
1149
|
+
show(e = {}) {
|
|
1150
|
+
const r = this.resolveBaseGIS();
|
|
1151
|
+
if (!r.success) return r;
|
|
1152
|
+
const n = this.baseGIS.showLineLayer({ ...e, layerId: this.getLayerId(e) });
|
|
1153
|
+
return n.success && (this.visible = !0, this.currentPayload && (this.currentPayload = { ...this.currentPayload, visible: !0 }), this.syncStateFromResult(n)), n;
|
|
1154
|
+
}
|
|
1155
|
+
hide(e = {}) {
|
|
1156
|
+
const r = this.resolveBaseGIS();
|
|
1157
|
+
if (!r.success) return r;
|
|
1158
|
+
const n = this.baseGIS.hideLineLayer({ ...e, layerId: this.getLayerId(e) });
|
|
1159
|
+
return n.success && (this.visible = !1, this.currentPayload && (this.currentPayload = { ...this.currentPayload, visible: !1 }), this.syncStateFromResult(n)), n;
|
|
1160
|
+
}
|
|
1161
|
+
toggle(e) {
|
|
1162
|
+
return typeof e == "boolean" ? e ? this.show() : this.hide() : this.visible ? this.hide() : this.show();
|
|
1163
|
+
}
|
|
1164
|
+
clear(e = {}) {
|
|
1165
|
+
const r = this.resolveBaseGIS();
|
|
1166
|
+
if (!r.success) return r;
|
|
1167
|
+
const n = this.baseGIS.clearLineLayer({ ...e, layerId: this.getLayerId(e) });
|
|
1168
|
+
return n.success && (this.currentPayload && (this.currentPayload = { ...this.currentPayload, lines: [] }), this.syncStateFromResult(n)), n;
|
|
1169
|
+
}
|
|
1170
|
+
playAnimation(e = {}) {
|
|
1171
|
+
const r = this.resolveBaseGIS();
|
|
1172
|
+
if (!r.success) return r;
|
|
1173
|
+
const n = this.baseGIS.playLineAnimation({
|
|
1174
|
+
...e,
|
|
1175
|
+
layerId: this.getLayerId(e)
|
|
1176
|
+
});
|
|
1177
|
+
return n.success && (this.currentPayload && (this.currentPayload = {
|
|
1178
|
+
...this.currentPayload,
|
|
1179
|
+
animation: { ...this.currentPayload.animation, autoplay: !0 }
|
|
1180
|
+
}), this.syncStateFromResult(n)), n;
|
|
1181
|
+
}
|
|
1182
|
+
pauseAnimation(e = {}) {
|
|
1183
|
+
const r = this.resolveBaseGIS();
|
|
1184
|
+
if (!r.success) return r;
|
|
1185
|
+
const n = this.baseGIS.pauseLineAnimation({
|
|
1186
|
+
...e,
|
|
1187
|
+
layerId: this.getLayerId(e)
|
|
1188
|
+
});
|
|
1189
|
+
return n.success && (this.currentPayload && (this.currentPayload = {
|
|
1190
|
+
...this.currentPayload,
|
|
1191
|
+
animation: { ...this.currentPayload.animation, autoplay: !1 }
|
|
1192
|
+
}), this.syncStateFromResult(n)), n;
|
|
1193
|
+
}
|
|
1194
|
+
restartAnimation(e = {}) {
|
|
1195
|
+
const r = this.resolveBaseGIS();
|
|
1196
|
+
if (!r.success) return r;
|
|
1197
|
+
const n = this.baseGIS.restartLineAnimation({
|
|
1198
|
+
...e,
|
|
1199
|
+
layerId: this.getLayerId(e)
|
|
1200
|
+
});
|
|
1201
|
+
return n.success && (this.currentPayload && (this.currentPayload = {
|
|
1202
|
+
...this.currentPayload,
|
|
1203
|
+
animation: {
|
|
1204
|
+
...this.currentPayload.animation,
|
|
1205
|
+
autoplay: (e == null ? void 0 : e.autoplay) !== !1
|
|
1206
|
+
}
|
|
1207
|
+
}), this.syncStateFromResult(n)), n;
|
|
1208
|
+
}
|
|
1209
|
+
refreshState(e = {}) {
|
|
1210
|
+
const r = this.resolveBaseGIS();
|
|
1211
|
+
if (!r.success) return r;
|
|
1212
|
+
const n = this.baseGIS.getLineLayerState({
|
|
1213
|
+
...e,
|
|
1214
|
+
layerId: this.getLayerId(e)
|
|
1215
|
+
});
|
|
1216
|
+
return n.success && this.syncStateFromResult(n), n;
|
|
1217
|
+
}
|
|
1218
|
+
resetLocalState() {
|
|
1219
|
+
this.currentPayload = null, this.layerType = "unknown", this.visible = !1, this.currentState = {
|
|
1220
|
+
...this.currentState,
|
|
1221
|
+
lineCount: 0,
|
|
1222
|
+
pointCount: 0,
|
|
1223
|
+
animationEnabled: !1,
|
|
1224
|
+
animationRunning: !1,
|
|
1225
|
+
animatedLineId: "",
|
|
1226
|
+
progress: 0,
|
|
1227
|
+
visible: !1,
|
|
1228
|
+
destroyed: !0
|
|
1229
|
+
};
|
|
1230
|
+
}
|
|
1231
|
+
destroy(e = {}) {
|
|
1232
|
+
if (!this.resolveBaseGIS().success)
|
|
1233
|
+
return this.resetLocalState(), L(null, "Line layer controller destroyed (local state only).");
|
|
1234
|
+
const n = this.baseGIS.removeLineLayer({
|
|
1235
|
+
...e,
|
|
1236
|
+
layerId: this.getLayerId(e)
|
|
1237
|
+
});
|
|
1238
|
+
return this.resetLocalState(), n.success ? L(null, "Line layer controller destroyed.") : n;
|
|
1239
|
+
}
|
|
1240
|
+
getState() {
|
|
1241
|
+
var e, r, n, s, i, o;
|
|
1242
|
+
if ((r = (e = this.baseGIS) == null ? void 0 : e.getMapInstance) != null && r.call(e) && this.currentPayload) {
|
|
1243
|
+
const a = (s = (n = this.baseGIS).getLineLayerState) == null ? void 0 : s.call(n, { layerId: this.getLayerId() });
|
|
1244
|
+
a != null && a.success && this.syncStateFromResult(a);
|
|
1245
|
+
}
|
|
1246
|
+
return {
|
|
1247
|
+
mounted: !!this.baseGIS,
|
|
1248
|
+
engineType: ((o = (i = this.baseGIS) == null ? void 0 : i.getEngineType) == null ? void 0 : o.call(i)) || "unknown",
|
|
1249
|
+
layerType: this.layerType,
|
|
1250
|
+
layerId: this.getLayerId(),
|
|
1251
|
+
visible: this.visible,
|
|
1252
|
+
payload: this.currentPayload,
|
|
1253
|
+
...this.currentState
|
|
1254
|
+
};
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
function k(t = {}) {
|
|
892
1258
|
return Array.isArray(t) || Array.isArray(t == null ? void 0 : t.features) ? { points: t } : t || {};
|
|
893
1259
|
}
|
|
894
|
-
function
|
|
895
|
-
const e =
|
|
1260
|
+
function pe(t = {}) {
|
|
1261
|
+
const e = k(t);
|
|
896
1262
|
return ["points", "data", "items"].some(
|
|
897
1263
|
(r) => Object.prototype.hasOwnProperty.call(e, r)
|
|
898
1264
|
);
|
|
899
1265
|
}
|
|
900
|
-
function
|
|
1266
|
+
function dt(t) {
|
|
1267
|
+
return !!(t && typeof t.getEngineType == "function" && typeof t.getMapInstance == "function" && typeof t.upsertPointClusterLayer == "function" && typeof t.showPointClusterLayer == "function" && typeof t.hidePointClusterLayer == "function" && typeof t.removePointClusterLayer == "function" && typeof t.clearPointClusterLayer == "function" && typeof t.getPointClusterLayerState == "function");
|
|
1268
|
+
}
|
|
1269
|
+
function ft(t = {}) {
|
|
1270
|
+
const e = { ...t };
|
|
1271
|
+
return delete e.mapCore, delete e.baseGIS, e;
|
|
1272
|
+
}
|
|
1273
|
+
class Fr {
|
|
1274
|
+
constructor(e = {}) {
|
|
1275
|
+
const r = ft(e), n = r.pointClusterLayerId || r.clusterLayerId || r.layerId || r.id || "point-cluster-default";
|
|
1276
|
+
this.options = {
|
|
1277
|
+
layerId: n,
|
|
1278
|
+
visible: r.visible ?? !0,
|
|
1279
|
+
idKey: r.idKey || "id"
|
|
1280
|
+
}, this.defaultPayload = {
|
|
1281
|
+
...r,
|
|
1282
|
+
layerId: n,
|
|
1283
|
+
visible: this.options.visible
|
|
1284
|
+
}, this.baseGIS = null, this.currentPayload = null, this.layerType = "unknown", this.visible = this.options.visible, this.currentState = {
|
|
1285
|
+
layerId: n,
|
|
1286
|
+
sourceCount: 0,
|
|
1287
|
+
inViewCount: 0,
|
|
1288
|
+
outOfViewCount: 0,
|
|
1289
|
+
visiblePointCount: 0,
|
|
1290
|
+
clusteredPointCount: 0,
|
|
1291
|
+
clusterCount: 0,
|
|
1292
|
+
renderedCount: 0,
|
|
1293
|
+
pixelRange: r.pixelRange ?? r.clusterRadius ?? 64,
|
|
1294
|
+
minimumClusterSize: r.minimumClusterSize ?? 2,
|
|
1295
|
+
visible: this.visible,
|
|
1296
|
+
destroyed: !0
|
|
1297
|
+
}, (e.mapCore || e.baseGIS) && this.mount(e.mapCore || e.baseGIS);
|
|
1298
|
+
}
|
|
1299
|
+
mount(e) {
|
|
1300
|
+
var r, n;
|
|
1301
|
+
return dt(e) ? (this.baseGIS = e, L(
|
|
1302
|
+
{ engineType: ((n = (r = this.baseGIS).getEngineType) == null ? void 0 : n.call(r)) || "unknown" },
|
|
1303
|
+
"PointClusterController mounted with BaseGIS."
|
|
1304
|
+
)) : I(
|
|
1305
|
+
"PointClusterController mount requires BaseGIS instance.",
|
|
1306
|
+
"INVALID_MOUNT_TARGET"
|
|
1307
|
+
);
|
|
1308
|
+
}
|
|
1309
|
+
resolveBaseGIS() {
|
|
1310
|
+
var e, r;
|
|
1311
|
+
return this.baseGIS ? (r = (e = this.baseGIS).getMapInstance) != null && r.call(e) ? L(null, "BaseGIS is ready.") : I(
|
|
1312
|
+
"Map instance is not ready. Please call mapCore.init() first.",
|
|
1313
|
+
"NOT_INITIALIZED"
|
|
1314
|
+
) : I("PointClusterController has not been mounted.", "NOT_MOUNTED");
|
|
1315
|
+
}
|
|
1316
|
+
getLayerId(e = {}) {
|
|
1317
|
+
var r;
|
|
1318
|
+
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) || ((r = this.currentPayload) == null ? void 0 : r.layerId) || this.options.layerId;
|
|
1319
|
+
}
|
|
1320
|
+
buildPayload(e = {}) {
|
|
1321
|
+
const r = k(e);
|
|
1322
|
+
return {
|
|
1323
|
+
...this.defaultPayload,
|
|
1324
|
+
...r,
|
|
1325
|
+
layerId: this.getLayerId(r),
|
|
1326
|
+
visible: typeof r.visible == "boolean" ? r.visible : this.visible
|
|
1327
|
+
};
|
|
1328
|
+
}
|
|
1329
|
+
syncStateFromResult(e) {
|
|
1330
|
+
var n;
|
|
1331
|
+
const r = ((n = e == null ? void 0 : e.data) == null ? void 0 : n.state) || (e == null ? void 0 : e.data) || null;
|
|
1332
|
+
!r || typeof r != "object" || (this.currentState = {
|
|
1333
|
+
...this.currentState,
|
|
1334
|
+
...r
|
|
1335
|
+
}, typeof r.visible == "boolean" && (this.visible = r.visible));
|
|
1336
|
+
}
|
|
1337
|
+
async load(e = {}, r = {}) {
|
|
1338
|
+
var o;
|
|
1339
|
+
const n = this.resolveBaseGIS();
|
|
1340
|
+
if (!n.success)
|
|
1341
|
+
return n;
|
|
1342
|
+
const s = this.buildPayload({
|
|
1343
|
+
...k(e),
|
|
1344
|
+
...k(r)
|
|
1345
|
+
});
|
|
1346
|
+
if (!pe(s))
|
|
1347
|
+
return I(
|
|
1348
|
+
"Point cluster layer requires points, data or items.",
|
|
1349
|
+
"INVALID_POINT_SOURCE"
|
|
1350
|
+
);
|
|
1351
|
+
const i = await this.baseGIS.upsertPointClusterLayer(s);
|
|
1352
|
+
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;
|
|
1353
|
+
}
|
|
1354
|
+
upsert(e = {}, r = {}) {
|
|
1355
|
+
return this.load(e, r);
|
|
1356
|
+
}
|
|
1357
|
+
update(e = {}) {
|
|
1358
|
+
const r = {
|
|
1359
|
+
...this.currentPayload || this.defaultPayload,
|
|
1360
|
+
...k(e)
|
|
1361
|
+
};
|
|
1362
|
+
return !this.currentPayload && !pe(r) ? I("Point cluster layer has not been loaded.", "NOT_LOADED") : this.load(r);
|
|
1363
|
+
}
|
|
1364
|
+
setConfig(e = {}) {
|
|
1365
|
+
return this.update(e);
|
|
1366
|
+
}
|
|
1367
|
+
show(e = {}) {
|
|
1368
|
+
const r = this.resolveBaseGIS();
|
|
1369
|
+
if (!r.success)
|
|
1370
|
+
return r;
|
|
1371
|
+
const n = this.baseGIS.showPointClusterLayer({
|
|
1372
|
+
...e,
|
|
1373
|
+
layerId: this.getLayerId(e)
|
|
1374
|
+
});
|
|
1375
|
+
return n.success && (this.visible = !0, this.syncStateFromResult(n)), n;
|
|
1376
|
+
}
|
|
1377
|
+
hide(e = {}) {
|
|
1378
|
+
const r = this.resolveBaseGIS();
|
|
1379
|
+
if (!r.success)
|
|
1380
|
+
return r;
|
|
1381
|
+
const n = this.baseGIS.hidePointClusterLayer({
|
|
1382
|
+
...e,
|
|
1383
|
+
layerId: this.getLayerId(e)
|
|
1384
|
+
});
|
|
1385
|
+
return n.success && (this.visible = !1, this.syncStateFromResult(n)), n;
|
|
1386
|
+
}
|
|
1387
|
+
toggle(e) {
|
|
1388
|
+
return typeof e == "boolean" ? e ? this.show() : this.hide() : this.visible ? this.hide() : this.show();
|
|
1389
|
+
}
|
|
1390
|
+
clear(e = {}) {
|
|
1391
|
+
const r = this.resolveBaseGIS();
|
|
1392
|
+
if (!r.success)
|
|
1393
|
+
return r;
|
|
1394
|
+
const n = this.baseGIS.clearPointClusterLayer({
|
|
1395
|
+
...e,
|
|
1396
|
+
layerId: this.getLayerId(e)
|
|
1397
|
+
});
|
|
1398
|
+
return n.success && (this.currentPayload = this.currentPayload ? {
|
|
1399
|
+
...this.currentPayload,
|
|
1400
|
+
points: [],
|
|
1401
|
+
data: [],
|
|
1402
|
+
items: []
|
|
1403
|
+
} : null, this.syncStateFromResult(n)), n;
|
|
1404
|
+
}
|
|
1405
|
+
refreshState(e = {}) {
|
|
1406
|
+
const r = this.resolveBaseGIS();
|
|
1407
|
+
if (!r.success)
|
|
1408
|
+
return r;
|
|
1409
|
+
const n = this.baseGIS.getPointClusterLayerState({
|
|
1410
|
+
...e,
|
|
1411
|
+
layerId: this.getLayerId(e)
|
|
1412
|
+
});
|
|
1413
|
+
return n.success && this.syncStateFromResult(n), n;
|
|
1414
|
+
}
|
|
1415
|
+
destroy(e = {}) {
|
|
1416
|
+
if (!this.resolveBaseGIS().success)
|
|
1417
|
+
return this.resetLocalState(), L(null, "Point cluster layer controller destroyed (local state only).");
|
|
1418
|
+
const n = this.baseGIS.removePointClusterLayer({
|
|
1419
|
+
...e,
|
|
1420
|
+
layerId: this.getLayerId(e)
|
|
1421
|
+
});
|
|
1422
|
+
return this.resetLocalState(), n.success ? L(null, "Point cluster layer controller destroyed.") : n;
|
|
1423
|
+
}
|
|
1424
|
+
resetLocalState() {
|
|
1425
|
+
this.currentPayload = null, this.layerType = "unknown", this.currentState = {
|
|
1426
|
+
...this.currentState,
|
|
1427
|
+
sourceCount: 0,
|
|
1428
|
+
inViewCount: 0,
|
|
1429
|
+
outOfViewCount: 0,
|
|
1430
|
+
visiblePointCount: 0,
|
|
1431
|
+
clusteredPointCount: 0,
|
|
1432
|
+
clusterCount: 0,
|
|
1433
|
+
renderedCount: 0,
|
|
1434
|
+
destroyed: !0
|
|
1435
|
+
};
|
|
1436
|
+
}
|
|
1437
|
+
removeLayer(e = {}) {
|
|
1438
|
+
return this.destroy(e);
|
|
1439
|
+
}
|
|
1440
|
+
getState() {
|
|
1441
|
+
var e, r, n, s, i, o, a;
|
|
1442
|
+
if ((r = (e = this.baseGIS) == null ? void 0 : e.getMapInstance) != null && r.call(e) && this.currentPayload) {
|
|
1443
|
+
const u = (s = (n = this.baseGIS).getPointClusterLayerState) == null ? void 0 : s.call(n, {
|
|
1444
|
+
layerId: this.currentPayload.layerId || this.options.layerId
|
|
1445
|
+
});
|
|
1446
|
+
u != null && u.success && this.syncStateFromResult(u);
|
|
1447
|
+
}
|
|
1448
|
+
return {
|
|
1449
|
+
mounted: !!this.baseGIS,
|
|
1450
|
+
engineType: ((o = (i = this.baseGIS) == null ? void 0 : i.getEngineType) == null ? void 0 : o.call(i)) || "unknown",
|
|
1451
|
+
layerType: this.layerType,
|
|
1452
|
+
visible: this.visible,
|
|
1453
|
+
layerId: ((a = this.currentPayload) == null ? void 0 : a.layerId) || this.options.layerId,
|
|
1454
|
+
payload: this.currentPayload,
|
|
1455
|
+
...this.currentState
|
|
1456
|
+
};
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
function Y(t = {}) {
|
|
1460
|
+
return Array.isArray(t) || Array.isArray(t == null ? void 0 : t.features) ? { points: t } : t || {};
|
|
1461
|
+
}
|
|
1462
|
+
function we(t = {}) {
|
|
1463
|
+
const e = Y(t);
|
|
1464
|
+
return ["points", "data", "items"].some(
|
|
1465
|
+
(r) => Object.prototype.hasOwnProperty.call(e, r)
|
|
1466
|
+
);
|
|
1467
|
+
}
|
|
1468
|
+
function yt(t) {
|
|
901
1469
|
return !!(t && typeof t.getEngineType == "function" && typeof t.getMapInstance == "function" && typeof t.upsertPointDensityLayer == "function" && typeof t.showPointDensityLayer == "function" && typeof t.hidePointDensityLayer == "function" && typeof t.removePointDensityLayer == "function" && typeof t.clearPointDensityLayer == "function" && typeof t.getPointDensityLayerState == "function");
|
|
902
1470
|
}
|
|
903
|
-
function
|
|
1471
|
+
function gt(t = {}) {
|
|
904
1472
|
const e = { ...t };
|
|
905
1473
|
return delete e.mapCore, delete e.baseGIS, e;
|
|
906
1474
|
}
|
|
907
|
-
class
|
|
1475
|
+
class Br {
|
|
908
1476
|
constructor(e = {}) {
|
|
909
|
-
const r =
|
|
1477
|
+
const r = gt(e), n = r.pointDensityLayerId || r.densityLayerId || r.layerId || r.id || "point-density-default";
|
|
910
1478
|
this.options = {
|
|
911
1479
|
layerId: n,
|
|
912
1480
|
visible: r.visible ?? !0,
|
|
@@ -928,7 +1496,7 @@ class Lr {
|
|
|
928
1496
|
}
|
|
929
1497
|
mount(e) {
|
|
930
1498
|
var r, n;
|
|
931
|
-
return
|
|
1499
|
+
return yt(e) ? (this.baseGIS = e, L(
|
|
932
1500
|
{ engineType: ((n = (r = this.baseGIS).getEngineType) == null ? void 0 : n.call(r)) || "unknown" },
|
|
933
1501
|
"PointDensityController mounted with BaseGIS."
|
|
934
1502
|
)) : I(
|
|
@@ -948,7 +1516,7 @@ class Lr {
|
|
|
948
1516
|
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) || ((r = this.currentPayload) == null ? void 0 : r.layerId) || this.options.layerId;
|
|
949
1517
|
}
|
|
950
1518
|
buildPayload(e = {}) {
|
|
951
|
-
const r =
|
|
1519
|
+
const r = Y(e), n = this.getLayerId(r);
|
|
952
1520
|
return {
|
|
953
1521
|
...this.defaultPayload,
|
|
954
1522
|
...r,
|
|
@@ -965,21 +1533,21 @@ class Lr {
|
|
|
965
1533
|
}, typeof r.visible == "boolean" && (this.visible = r.visible));
|
|
966
1534
|
}
|
|
967
1535
|
async load(e = {}, r = {}) {
|
|
968
|
-
var
|
|
1536
|
+
var u;
|
|
969
1537
|
const n = this.resolveBaseGIS();
|
|
970
1538
|
if (!n.success)
|
|
971
1539
|
return n;
|
|
972
|
-
const s =
|
|
1540
|
+
const s = Y(e), i = Y(r), o = this.buildPayload({
|
|
973
1541
|
...s,
|
|
974
1542
|
...i
|
|
975
1543
|
});
|
|
976
|
-
if (!
|
|
1544
|
+
if (!we(o))
|
|
977
1545
|
return I(
|
|
978
1546
|
"Point density layer requires points, data or items.",
|
|
979
1547
|
"INVALID_POINT_SOURCE"
|
|
980
1548
|
);
|
|
981
1549
|
const a = await this.baseGIS.upsertPointDensityLayer(o);
|
|
982
|
-
return a.success && (this.currentPayload = o, this.visible = o.visible !== !1, this.layerType = ((
|
|
1550
|
+
return a.success && (this.currentPayload = o, this.visible = o.visible !== !1, this.layerType = ((u = a == null ? void 0 : a.data) == null ? void 0 : u.layerType) || this.layerType, this.syncStateFromResult(a)), a;
|
|
983
1551
|
}
|
|
984
1552
|
upsert(e = {}, r = {}) {
|
|
985
1553
|
return this.load(e, r);
|
|
@@ -987,9 +1555,9 @@ class Lr {
|
|
|
987
1555
|
async update(e = {}) {
|
|
988
1556
|
const r = {
|
|
989
1557
|
...this.currentPayload || this.defaultPayload,
|
|
990
|
-
|
|
1558
|
+
...Y(e)
|
|
991
1559
|
};
|
|
992
|
-
return !this.currentPayload && !
|
|
1560
|
+
return !this.currentPayload && !we(r) ? I("Point density layer has not been loaded.", "NOT_LOADED") : this.load(r);
|
|
993
1561
|
}
|
|
994
1562
|
setConfig(e = {}) {
|
|
995
1563
|
return this.update(e);
|
|
@@ -1071,10 +1639,10 @@ class Lr {
|
|
|
1071
1639
|
getState() {
|
|
1072
1640
|
var e, r, n, s, i, o, a;
|
|
1073
1641
|
if ((r = (e = this.baseGIS) == null ? void 0 : e.getMapInstance) != null && r.call(e) && this.currentPayload) {
|
|
1074
|
-
const
|
|
1642
|
+
const u = (s = (n = this.baseGIS).getPointDensityLayerState) == null ? void 0 : s.call(n, {
|
|
1075
1643
|
layerId: this.currentPayload.layerId || this.options.layerId
|
|
1076
1644
|
});
|
|
1077
|
-
|
|
1645
|
+
u != null && u.success && this.syncStateFromResult(u);
|
|
1078
1646
|
}
|
|
1079
1647
|
return {
|
|
1080
1648
|
mounted: !!this.baseGIS,
|
|
@@ -1087,32 +1655,32 @@ class Lr {
|
|
|
1087
1655
|
};
|
|
1088
1656
|
}
|
|
1089
1657
|
}
|
|
1090
|
-
function
|
|
1658
|
+
function q(t = {}) {
|
|
1091
1659
|
return Array.isArray(t) || Array.isArray(t == null ? void 0 : t.features) ? { points: t } : t || {};
|
|
1092
1660
|
}
|
|
1093
|
-
function
|
|
1094
|
-
const e =
|
|
1661
|
+
function Pe(t = {}) {
|
|
1662
|
+
const e = q(t);
|
|
1095
1663
|
return ["points", "data", "items"].some(
|
|
1096
1664
|
(r) => Object.prototype.hasOwnProperty.call(e, r)
|
|
1097
1665
|
);
|
|
1098
1666
|
}
|
|
1099
|
-
function
|
|
1667
|
+
function It(t) {
|
|
1100
1668
|
return !!(t && typeof t.getEngineType == "function" && typeof t.getMapInstance == "function" && typeof t.upsertPointLargeLayer == "function" && typeof t.showPointLargeLayer == "function" && typeof t.hidePointLargeLayer == "function" && typeof t.removePointLargeLayer == "function" && typeof t.setPointLargeHighlight == "function" && typeof t.clearPointLargeHighlight == "function" && typeof t.removePointLargePoint == "function" && typeof t.clearPointLargeLayer == "function");
|
|
1101
1669
|
}
|
|
1102
|
-
function
|
|
1670
|
+
function Ce(t, e = {}) {
|
|
1103
1671
|
return t && typeof t == "object" && !Array.isArray(t) ? t.pointId ?? t.highlightId ?? t.key ?? t.id : t ?? e.pointId ?? e.highlightId ?? e.key ?? e.id;
|
|
1104
1672
|
}
|
|
1105
|
-
function
|
|
1673
|
+
function mt(t, e = "id", r = "") {
|
|
1106
1674
|
var n, s;
|
|
1107
1675
|
return !t || typeof t != "object" || Array.isArray(t) ? r : t[e] ?? ((n = t.properties) == null ? void 0 : n[e]) ?? t.id ?? ((s = t.properties) == null ? void 0 : s.id) ?? r;
|
|
1108
1676
|
}
|
|
1109
|
-
function
|
|
1677
|
+
function bt(t = {}) {
|
|
1110
1678
|
const { mapCore: e, baseGIS: r, ...n } = t;
|
|
1111
1679
|
return n;
|
|
1112
1680
|
}
|
|
1113
|
-
class
|
|
1681
|
+
class Dr {
|
|
1114
1682
|
constructor(e = {}) {
|
|
1115
|
-
const r =
|
|
1683
|
+
const r = bt(e), n = r.pointLargeLayerId || r.largeLayerId || r.layerId || r.id || "point-large-default";
|
|
1116
1684
|
this.options = {
|
|
1117
1685
|
layerId: n,
|
|
1118
1686
|
visible: r.visible ?? !0,
|
|
@@ -1133,7 +1701,7 @@ class Cr {
|
|
|
1133
1701
|
}
|
|
1134
1702
|
mount(e) {
|
|
1135
1703
|
var r, n;
|
|
1136
|
-
return
|
|
1704
|
+
return It(e) ? (this.baseGIS = e, L(
|
|
1137
1705
|
{ engineType: ((n = (r = this.baseGIS).getEngineType) == null ? void 0 : n.call(r)) || "unknown" },
|
|
1138
1706
|
"PointLargeLayerController mounted with BaseGIS."
|
|
1139
1707
|
)) : I(
|
|
@@ -1154,7 +1722,7 @@ class Cr {
|
|
|
1154
1722
|
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;
|
|
1155
1723
|
}
|
|
1156
1724
|
buildPayload(e = {}) {
|
|
1157
|
-
const r =
|
|
1725
|
+
const r = q(e), n = this.getLayerId(r);
|
|
1158
1726
|
return {
|
|
1159
1727
|
...this.defaultPayload,
|
|
1160
1728
|
...r,
|
|
@@ -1175,21 +1743,21 @@ class Cr {
|
|
|
1175
1743
|
* 支持 load(points, options) 或 load({ points, ...options }) 两种调用方式。
|
|
1176
1744
|
*/
|
|
1177
1745
|
async load(e = {}, r = {}) {
|
|
1178
|
-
var
|
|
1746
|
+
var u;
|
|
1179
1747
|
const n = this.resolveBaseGIS();
|
|
1180
1748
|
if (!n.success)
|
|
1181
1749
|
return n;
|
|
1182
|
-
const s =
|
|
1750
|
+
const s = q(e), i = q(r), o = this.buildPayload({
|
|
1183
1751
|
...s,
|
|
1184
1752
|
...i
|
|
1185
1753
|
});
|
|
1186
|
-
if (!
|
|
1754
|
+
if (!Pe(o))
|
|
1187
1755
|
return I(
|
|
1188
1756
|
"Point large layer requires points, data or items.",
|
|
1189
1757
|
"INVALID_POINT_SOURCE"
|
|
1190
1758
|
);
|
|
1191
1759
|
const a = await this.baseGIS.upsertPointLargeLayer(o);
|
|
1192
|
-
return a.success && (this.currentPayload = o, this.visible = o.visible !== !1, this.layerType = ((
|
|
1760
|
+
return a.success && (this.currentPayload = o, this.visible = o.visible !== !1, this.layerType = ((u = a == null ? void 0 : a.data) == null ? void 0 : u.layerType) || this.layerType, this.syncStateFromResult(a)), a;
|
|
1193
1761
|
}
|
|
1194
1762
|
upsert(e = {}, r = {}) {
|
|
1195
1763
|
return this.load(e, r);
|
|
@@ -1197,9 +1765,9 @@ class Cr {
|
|
|
1197
1765
|
async update(e = {}) {
|
|
1198
1766
|
const r = {
|
|
1199
1767
|
...this.currentPayload || this.defaultPayload,
|
|
1200
|
-
...
|
|
1768
|
+
...q(e)
|
|
1201
1769
|
};
|
|
1202
|
-
return !this.currentPayload && !
|
|
1770
|
+
return !this.currentPayload && !Pe(r) ? I("Point large layer has not been loaded.", "NOT_LOADED") : this.load(r);
|
|
1203
1771
|
}
|
|
1204
1772
|
show(e = {}) {
|
|
1205
1773
|
const r = this.resolveBaseGIS();
|
|
@@ -1228,7 +1796,7 @@ class Cr {
|
|
|
1228
1796
|
const n = this.resolveBaseGIS();
|
|
1229
1797
|
if (!n.success)
|
|
1230
1798
|
return n;
|
|
1231
|
-
const s = e && typeof e == "object" && !Array.isArray(e) ? e : r, i =
|
|
1799
|
+
const s = e && typeof e == "object" && !Array.isArray(e) ? e : r, i = Ce(e, s);
|
|
1232
1800
|
if (i == null || i === "")
|
|
1233
1801
|
return I("Point id is required when setting highlight.", "INVALID_POINT_ID");
|
|
1234
1802
|
const o = this.baseGIS.setPointLargeHighlight({
|
|
@@ -1264,7 +1832,7 @@ class Cr {
|
|
|
1264
1832
|
this.currentPayload = {
|
|
1265
1833
|
...this.currentPayload,
|
|
1266
1834
|
points: this.currentPayload.points.filter((s, i) => {
|
|
1267
|
-
const o =
|
|
1835
|
+
const o = mt(s, r, i);
|
|
1268
1836
|
return !n.has(String(o));
|
|
1269
1837
|
})
|
|
1270
1838
|
};
|
|
@@ -1273,7 +1841,7 @@ class Cr {
|
|
|
1273
1841
|
const n = this.resolveBaseGIS();
|
|
1274
1842
|
if (!n.success)
|
|
1275
1843
|
return n;
|
|
1276
|
-
const s = e && typeof e == "object" && !Array.isArray(e) ? e : r, i =
|
|
1844
|
+
const s = e && typeof e == "object" && !Array.isArray(e) ? e : r, i = Ce(e, s);
|
|
1277
1845
|
if (i == null || i === "")
|
|
1278
1846
|
return I("Point id is required when removing point.", "INVALID_POINT_ID");
|
|
1279
1847
|
const o = this.baseGIS.removePointLargePoint({
|
|
@@ -1365,10 +1933,10 @@ class Cr {
|
|
|
1365
1933
|
getState() {
|
|
1366
1934
|
var e, r, n, s, i, o, a;
|
|
1367
1935
|
if ((r = (e = this.baseGIS) == null ? void 0 : e.getMapInstance) != null && r.call(e) && this.currentPayload) {
|
|
1368
|
-
const
|
|
1936
|
+
const u = (s = (n = this.baseGIS).getPointLargeLayerState) == null ? void 0 : s.call(n, {
|
|
1369
1937
|
layerId: this.currentPayload.layerId || this.options.layerId
|
|
1370
1938
|
});
|
|
1371
|
-
|
|
1939
|
+
u != null && u.success && this.syncStateFromResult(u);
|
|
1372
1940
|
}
|
|
1373
1941
|
return {
|
|
1374
1942
|
mounted: !!this.baseGIS,
|
|
@@ -1381,13 +1949,13 @@ class Cr {
|
|
|
1381
1949
|
};
|
|
1382
1950
|
}
|
|
1383
1951
|
}
|
|
1384
|
-
function
|
|
1952
|
+
function St(t, e) {
|
|
1385
1953
|
let r = 0;
|
|
1386
1954
|
for (let n of t)
|
|
1387
1955
|
n != null && (n = +n) >= n && ++r;
|
|
1388
1956
|
return r;
|
|
1389
1957
|
}
|
|
1390
|
-
function
|
|
1958
|
+
function Lt(t, e) {
|
|
1391
1959
|
let r, n;
|
|
1392
1960
|
if (e === void 0)
|
|
1393
1961
|
for (const s of t)
|
|
@@ -1399,74 +1967,74 @@ function it(t, e) {
|
|
|
1399
1967
|
}
|
|
1400
1968
|
return [r, n];
|
|
1401
1969
|
}
|
|
1402
|
-
const
|
|
1403
|
-
function
|
|
1404
|
-
const n = (e - t) / Math.max(0, r), s = Math.floor(Math.log10(n)), i = n / Math.pow(10, s), o = i >=
|
|
1405
|
-
let a,
|
|
1406
|
-
return s < 0 ? (l = Math.pow(10, -s) / o, a = Math.round(t * l),
|
|
1970
|
+
const vt = Math.sqrt(50), pt = Math.sqrt(10), wt = Math.sqrt(2);
|
|
1971
|
+
function J(t, e, r) {
|
|
1972
|
+
const n = (e - t) / Math.max(0, r), s = Math.floor(Math.log10(n)), i = n / Math.pow(10, s), o = i >= vt ? 10 : i >= pt ? 5 : i >= wt ? 2 : 1;
|
|
1973
|
+
let a, u, l;
|
|
1974
|
+
return s < 0 ? (l = Math.pow(10, -s) / o, a = Math.round(t * l), u = Math.round(e * l), a / l < t && ++a, u / l > e && --u, l = -l) : (l = Math.pow(10, s) * o, a = Math.round(t / l), u = Math.round(e / l), a * l < t && ++a, u * l > e && --u), u < a && 0.5 <= r && r < 2 ? J(t, e, r * 2) : [a, u, l];
|
|
1407
1975
|
}
|
|
1408
|
-
function
|
|
1976
|
+
function Pt(t, e, r) {
|
|
1409
1977
|
if (e = +e, t = +t, r = +r, !(r > 0)) return [];
|
|
1410
1978
|
if (t === e) return [t];
|
|
1411
|
-
const n = e < t, [s, i, o] = n ?
|
|
1979
|
+
const n = e < t, [s, i, o] = n ? J(e, t, r) : J(t, e, r);
|
|
1412
1980
|
if (!(i >= s)) return [];
|
|
1413
|
-
const a = i - s + 1,
|
|
1981
|
+
const a = i - s + 1, u = new Array(a);
|
|
1414
1982
|
if (n)
|
|
1415
|
-
if (o < 0) for (let l = 0; l < a; ++l)
|
|
1416
|
-
else for (let l = 0; l < a; ++l)
|
|
1417
|
-
else if (o < 0) for (let l = 0; l < a; ++l)
|
|
1418
|
-
else for (let l = 0; l < a; ++l)
|
|
1419
|
-
return
|
|
1983
|
+
if (o < 0) for (let l = 0; l < a; ++l) u[l] = (i - l) / -o;
|
|
1984
|
+
else for (let l = 0; l < a; ++l) u[l] = (i - l) * o;
|
|
1985
|
+
else if (o < 0) for (let l = 0; l < a; ++l) u[l] = (s + l) / -o;
|
|
1986
|
+
else for (let l = 0; l < a; ++l) u[l] = (s + l) * o;
|
|
1987
|
+
return u;
|
|
1420
1988
|
}
|
|
1421
|
-
function
|
|
1422
|
-
return e = +e, t = +t, r = +r,
|
|
1989
|
+
function Ct(t, e, r) {
|
|
1990
|
+
return e = +e, t = +t, r = +r, J(t, e, r)[2];
|
|
1423
1991
|
}
|
|
1424
|
-
function
|
|
1992
|
+
function Gt(t, e, r) {
|
|
1425
1993
|
let n;
|
|
1426
1994
|
for (; ; ) {
|
|
1427
|
-
const s =
|
|
1995
|
+
const s = Ct(t, e, r);
|
|
1428
1996
|
if (s === n || s === 0 || !isFinite(s))
|
|
1429
1997
|
return [t, e];
|
|
1430
1998
|
s > 0 ? (t = Math.floor(t / s) * s, e = Math.ceil(e / s) * s) : s < 0 && (t = Math.ceil(t * s) / s, e = Math.floor(e * s) / s), n = s;
|
|
1431
1999
|
}
|
|
1432
2000
|
}
|
|
1433
|
-
function
|
|
1434
|
-
return Math.max(1, Math.ceil(Math.log(
|
|
2001
|
+
function Mt(t) {
|
|
2002
|
+
return Math.max(1, Math.ceil(Math.log(St(t)) / Math.LN2) + 1);
|
|
1435
2003
|
}
|
|
1436
|
-
var
|
|
1437
|
-
function
|
|
2004
|
+
var Tt = Array.prototype, Nt = Tt.slice;
|
|
2005
|
+
function xt(t, e) {
|
|
1438
2006
|
return t - e;
|
|
1439
2007
|
}
|
|
1440
|
-
function
|
|
2008
|
+
function At(t) {
|
|
1441
2009
|
for (var e = 0, r = t.length, n = t[r - 1][1] * t[0][0] - t[r - 1][0] * t[0][1]; ++e < r; ) n += t[e - 1][1] * t[e][0] - t[e - 1][0] * t[e][1];
|
|
1442
2010
|
return n;
|
|
1443
2011
|
}
|
|
1444
|
-
const
|
|
1445
|
-
function
|
|
1446
|
-
for (var r = -1, n = e.length, s; ++r < n; ) if (s =
|
|
2012
|
+
const Ge = (t) => () => t;
|
|
2013
|
+
function Et(t, e) {
|
|
2014
|
+
for (var r = -1, n = e.length, s; ++r < n; ) if (s = Rt(t, e[r])) return s;
|
|
1447
2015
|
return 0;
|
|
1448
2016
|
}
|
|
1449
|
-
function
|
|
2017
|
+
function Rt(t, e) {
|
|
1450
2018
|
for (var r = e[0], n = e[1], s = -1, i = 0, o = t.length, a = o - 1; i < o; a = i++) {
|
|
1451
|
-
var
|
|
1452
|
-
if (
|
|
1453
|
-
|
|
2019
|
+
var u = t[i], l = u[0], c = u[1], h = t[a], f = h[0], d = h[1];
|
|
2020
|
+
if (Ft(u, h, e)) return 0;
|
|
2021
|
+
c > n != d > n && r < (f - l) * (n - c) / (d - c) + l && (s = -s);
|
|
1454
2022
|
}
|
|
1455
2023
|
return s;
|
|
1456
2024
|
}
|
|
1457
|
-
function
|
|
2025
|
+
function Ft(t, e, r) {
|
|
1458
2026
|
var n;
|
|
1459
|
-
return
|
|
2027
|
+
return Bt(t, e, r) && Dt(t[n = +(t[0] === e[0])], r[n], e[n]);
|
|
1460
2028
|
}
|
|
1461
|
-
function
|
|
2029
|
+
function Bt(t, e, r) {
|
|
1462
2030
|
return (e[0] - t[0]) * (r[1] - t[1]) === (r[0] - t[0]) * (e[1] - t[1]);
|
|
1463
2031
|
}
|
|
1464
|
-
function
|
|
2032
|
+
function Dt(t, e, r) {
|
|
1465
2033
|
return t <= e && e <= r || r <= e && e <= t;
|
|
1466
2034
|
}
|
|
1467
|
-
function
|
|
2035
|
+
function Ot() {
|
|
1468
2036
|
}
|
|
1469
|
-
var
|
|
2037
|
+
var B = [
|
|
1470
2038
|
[],
|
|
1471
2039
|
[[[1, 1.5], [0.5, 1]]],
|
|
1472
2040
|
[[[1.5, 1], [1, 1.5]]],
|
|
@@ -1484,104 +2052,114 @@ var F = [
|
|
|
1484
2052
|
[[[0.5, 1], [1, 1.5]]],
|
|
1485
2053
|
[]
|
|
1486
2054
|
];
|
|
1487
|
-
function
|
|
1488
|
-
var t = 1, e = 1, r =
|
|
2055
|
+
function _t() {
|
|
2056
|
+
var t = 1, e = 1, r = Mt, n = u;
|
|
1489
2057
|
function s(l) {
|
|
1490
|
-
var
|
|
1491
|
-
if (Array.isArray(
|
|
1492
|
-
|
|
2058
|
+
var c = r(l);
|
|
2059
|
+
if (Array.isArray(c))
|
|
2060
|
+
c = c.slice().sort(xt);
|
|
1493
2061
|
else {
|
|
1494
|
-
const h =
|
|
1495
|
-
for (
|
|
1496
|
-
for (;
|
|
2062
|
+
const h = Lt(l, jt);
|
|
2063
|
+
for (c = Pt(...Gt(h[0], h[1], c), c); c[c.length - 1] >= h[1]; ) c.pop();
|
|
2064
|
+
for (; c[1] < h[0]; ) c.shift();
|
|
1497
2065
|
}
|
|
1498
|
-
return
|
|
2066
|
+
return c.map((h) => i(l, h));
|
|
1499
2067
|
}
|
|
1500
|
-
function i(l,
|
|
1501
|
-
const h =
|
|
1502
|
-
if (isNaN(h)) throw new Error(`invalid value: ${
|
|
1503
|
-
var
|
|
2068
|
+
function i(l, c) {
|
|
2069
|
+
const h = c == null ? NaN : +c;
|
|
2070
|
+
if (isNaN(h)) throw new Error(`invalid value: ${c}`);
|
|
2071
|
+
var f = [], d = [];
|
|
1504
2072
|
return o(l, h, function(y) {
|
|
1505
|
-
n(y, l, h),
|
|
1506
|
-
}),
|
|
1507
|
-
for (var
|
|
1508
|
-
if (
|
|
1509
|
-
|
|
2073
|
+
n(y, l, h), At(y) > 0 ? f.push([y]) : d.push(y);
|
|
2074
|
+
}), d.forEach(function(y) {
|
|
2075
|
+
for (var m = 0, S = f.length, g; m < S; ++m)
|
|
2076
|
+
if (Et((g = f[m])[0], y) !== -1) {
|
|
2077
|
+
g.push(y);
|
|
1510
2078
|
return;
|
|
1511
2079
|
}
|
|
1512
2080
|
}), {
|
|
1513
2081
|
type: "MultiPolygon",
|
|
1514
|
-
value:
|
|
1515
|
-
coordinates:
|
|
2082
|
+
value: c,
|
|
2083
|
+
coordinates: f
|
|
1516
2084
|
};
|
|
1517
2085
|
}
|
|
1518
|
-
function o(l,
|
|
1519
|
-
var
|
|
1520
|
-
for (y =
|
|
1521
|
-
|
|
1522
|
-
for (
|
|
1523
|
-
for (y = -1,
|
|
1524
|
-
|
|
1525
|
-
|
|
2086
|
+
function o(l, c, h) {
|
|
2087
|
+
var f = new Array(), d = new Array(), y, m, S, g, v, b;
|
|
2088
|
+
for (y = m = -1, g = V(l[0], c), B[g << 1].forEach(w); ++y < t - 1; )
|
|
2089
|
+
S = g, g = V(l[y + 1], c), B[S | g << 1].forEach(w);
|
|
2090
|
+
for (B[g << 0].forEach(w); ++m < e - 1; ) {
|
|
2091
|
+
for (y = -1, g = V(l[m * t + t], c), v = V(l[m * t], c), B[g << 1 | v << 2].forEach(w); ++y < t - 1; )
|
|
2092
|
+
S = g, g = V(l[m * t + t + y + 1], c), b = v, v = V(l[m * t + y + 1], c), B[S | g << 1 | v << 2 | b << 3].forEach(w);
|
|
2093
|
+
B[g | v << 3].forEach(w);
|
|
1526
2094
|
}
|
|
1527
|
-
for (y = -1,
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
function
|
|
1531
|
-
var
|
|
1532
|
-
(
|
|
2095
|
+
for (y = -1, v = l[m * t] >= c, B[v << 2].forEach(w); ++y < t - 1; )
|
|
2096
|
+
b = v, v = V(l[m * t + y + 1], c), B[v << 2 | b << 3].forEach(w);
|
|
2097
|
+
B[v << 3].forEach(w);
|
|
2098
|
+
function w(G) {
|
|
2099
|
+
var E = [G[0][0] + y, G[0][1] + m], T = [G[1][0] + y, G[1][1] + m], N = a(E), D = a(T), p, A;
|
|
2100
|
+
(p = d[N]) ? (A = f[D]) ? (delete d[p.end], delete f[A.start], p === A ? (p.ring.push(T), h(p.ring)) : f[p.start] = d[A.end] = { start: p.start, end: A.end, ring: p.ring.concat(A.ring) }) : (delete d[p.end], p.ring.push(T), d[p.end = D] = p) : (p = f[D]) ? (A = d[N]) ? (delete f[p.start], delete d[A.end], p === A ? (p.ring.push(T), h(p.ring)) : f[A.start] = d[p.end] = { start: A.start, end: p.end, ring: A.ring.concat(p.ring) }) : (delete f[p.start], p.ring.unshift(E), f[p.start = N] = p) : f[N] = d[D] = { start: N, end: D, ring: [E, T] };
|
|
1533
2101
|
}
|
|
1534
2102
|
}
|
|
1535
2103
|
function a(l) {
|
|
1536
2104
|
return l[0] * 2 + l[1] * (t + 1) * 4;
|
|
1537
2105
|
}
|
|
1538
|
-
function
|
|
1539
|
-
l.forEach(function(
|
|
1540
|
-
var
|
|
1541
|
-
|
|
2106
|
+
function u(l, c, h) {
|
|
2107
|
+
l.forEach(function(f) {
|
|
2108
|
+
var d = f[0], y = f[1], m = d | 0, S = y | 0, g = ne(c[S * t + m]);
|
|
2109
|
+
d > 0 && d < t && m === d && (f[0] = Me(d, ne(c[S * t + m - 1]), g, h)), y > 0 && y < e && S === y && (f[1] = Me(y, ne(c[(S - 1) * t + m]), g, h));
|
|
1542
2110
|
});
|
|
1543
2111
|
}
|
|
1544
2112
|
return s.contour = i, s.size = function(l) {
|
|
1545
2113
|
if (!arguments.length) return [t, e];
|
|
1546
|
-
var
|
|
1547
|
-
if (!(
|
|
1548
|
-
return t =
|
|
2114
|
+
var c = Math.floor(l[0]), h = Math.floor(l[1]);
|
|
2115
|
+
if (!(c >= 0 && h >= 0)) throw new Error("invalid size");
|
|
2116
|
+
return t = c, e = h, s;
|
|
1549
2117
|
}, s.thresholds = function(l) {
|
|
1550
|
-
return arguments.length ? (r = typeof l == "function" ? l : Array.isArray(l) ?
|
|
2118
|
+
return arguments.length ? (r = typeof l == "function" ? l : Array.isArray(l) ? Ge(Nt.call(l)) : Ge(l), s) : r;
|
|
1551
2119
|
}, s.smooth = function(l) {
|
|
1552
|
-
return arguments.length ? (n = l ?
|
|
2120
|
+
return arguments.length ? (n = l ? u : Ot, s) : n === u;
|
|
1553
2121
|
}, s;
|
|
1554
2122
|
}
|
|
1555
|
-
function
|
|
2123
|
+
function jt(t) {
|
|
1556
2124
|
return isFinite(t) ? t : NaN;
|
|
1557
2125
|
}
|
|
1558
|
-
function
|
|
2126
|
+
function V(t, e) {
|
|
1559
2127
|
return t == null ? !1 : +t >= e;
|
|
1560
2128
|
}
|
|
1561
|
-
function
|
|
2129
|
+
function ne(t) {
|
|
1562
2130
|
return t == null || isNaN(t = +t) ? -1 / 0 : t;
|
|
1563
2131
|
}
|
|
1564
|
-
function
|
|
2132
|
+
function Me(t, e, r, n) {
|
|
1565
2133
|
const s = n - e, i = r - e, o = isFinite(s) || isFinite(i) ? s / i : Math.sign(s) / Math.sign(i);
|
|
1566
2134
|
return isNaN(o) ? t : t + o - 0.5;
|
|
1567
2135
|
}
|
|
1568
|
-
const
|
|
1569
|
-
|
|
2136
|
+
const Te = 6378137, Ne = 85.0511287798066, Q = 1e6, U = Object.freeze({
|
|
2137
|
+
enabled: !1,
|
|
2138
|
+
radius: 6,
|
|
2139
|
+
minProminence: 2,
|
|
2140
|
+
minGridDistance: 20,
|
|
2141
|
+
maxCount: 12,
|
|
2142
|
+
includeHigh: !0,
|
|
2143
|
+
includeLow: !0,
|
|
2144
|
+
excludeBoundary: !0,
|
|
2145
|
+
smoothingIterations: 1
|
|
2146
|
+
});
|
|
2147
|
+
function P(t, e = null) {
|
|
1570
2148
|
const r = Number(t);
|
|
1571
2149
|
return Number.isFinite(r) ? r : e;
|
|
1572
2150
|
}
|
|
1573
|
-
function
|
|
2151
|
+
function _e(t, e) {
|
|
1574
2152
|
return Object.prototype.hasOwnProperty.call(t || {}, e);
|
|
1575
2153
|
}
|
|
1576
|
-
function
|
|
2154
|
+
function je(t) {
|
|
1577
2155
|
if (Array.isArray(t) && t.length >= 4) {
|
|
1578
|
-
const [i, o, a,
|
|
1579
|
-
if ([i, o, a,
|
|
2156
|
+
const [i, o, a, u] = t.map(Number);
|
|
2157
|
+
if ([i, o, a, u].every(Number.isFinite))
|
|
1580
2158
|
return {
|
|
1581
2159
|
startLon: Math.min(i, a),
|
|
1582
|
-
startLat: Math.min(o,
|
|
2160
|
+
startLat: Math.min(o, u),
|
|
1583
2161
|
endLon: Math.max(i, a),
|
|
1584
|
-
endLat: Math.max(o,
|
|
2162
|
+
endLat: Math.max(o, u)
|
|
1585
2163
|
};
|
|
1586
2164
|
}
|
|
1587
2165
|
if (!t || typeof t != "object")
|
|
@@ -1594,66 +2172,66 @@ function Oe(t) {
|
|
|
1594
2172
|
endLat: Math.max(r, s)
|
|
1595
2173
|
} : null;
|
|
1596
2174
|
}
|
|
1597
|
-
function
|
|
2175
|
+
function he(t = "") {
|
|
1598
2176
|
const e = String(t || "").trim().toUpperCase().replace("::", ":");
|
|
1599
2177
|
return ["3857", "EPSG:3857", "EPSG:900913", "900913"].includes(e) ? "EPSG:3857" : ["4326", "EPSG:4326", "WGS84", "WGS 84"].includes(e) ? "EPSG:4326" : e;
|
|
1600
2178
|
}
|
|
1601
|
-
function
|
|
2179
|
+
function Vt(t = {}, e = []) {
|
|
1602
2180
|
const r = Number(t.ProjectedCSTypeGeoKey);
|
|
1603
2181
|
return r === 3857 || r === 900913 ? "EPSG:3857" : Number(t.GeographicTypeGeoKey) === 4326 || e.length >= 4 && Math.abs(Number(e[0])) <= 360 && Math.abs(Number(e[2])) <= 360 && Math.abs(Number(e[1])) <= 180 && Math.abs(Number(e[3])) <= 180 ? "EPSG:4326" : "";
|
|
1604
2182
|
}
|
|
1605
|
-
function
|
|
1606
|
-
const r = Number(t) /
|
|
2183
|
+
function se(t, e) {
|
|
2184
|
+
const r = Number(t) / Te * (180 / Math.PI), n = (2 * Math.atan(Math.exp(Number(e) / Te)) - Math.PI / 2) * (180 / Math.PI);
|
|
1607
2185
|
return {
|
|
1608
2186
|
lng: r,
|
|
1609
|
-
lat: Math.min(Math.max(n, -
|
|
2187
|
+
lat: Math.min(Math.max(n, -Ne), Ne)
|
|
1610
2188
|
};
|
|
1611
2189
|
}
|
|
1612
|
-
function
|
|
2190
|
+
function ie(t) {
|
|
1613
2191
|
return !Number.isFinite(t) || t >= -180 && t <= 180 ? t : ((t + 180) % 360 + 360) % 360 - 180;
|
|
1614
2192
|
}
|
|
1615
|
-
function
|
|
1616
|
-
let o =
|
|
2193
|
+
function ye({ area: t, bbox: e, projection: r, width: n, height: s, isSplit: i = !1 }) {
|
|
2194
|
+
let o = je(t);
|
|
1617
2195
|
if (i && o && Math.abs(o.endLon - o.startLon) >= 359.999 && (o = {
|
|
1618
2196
|
...o,
|
|
1619
2197
|
startLon: -180,
|
|
1620
2198
|
endLon: 180
|
|
1621
2199
|
}), o) {
|
|
1622
|
-
const
|
|
2200
|
+
const d = o.endLon - o.startLon, y = o.endLat - o.startLat;
|
|
1623
2201
|
return {
|
|
1624
2202
|
area: o,
|
|
1625
2203
|
projection: "EPSG:4326",
|
|
1626
|
-
map(
|
|
2204
|
+
map(m, S) {
|
|
1627
2205
|
return [
|
|
1628
|
-
o.endLat -
|
|
1629
|
-
|
|
2206
|
+
o.endLat - S / s * y,
|
|
2207
|
+
ie(o.startLon + m / n * d)
|
|
1630
2208
|
];
|
|
1631
2209
|
}
|
|
1632
2210
|
};
|
|
1633
2211
|
}
|
|
1634
2212
|
if (!Array.isArray(e) || e.length < 4 || !e.slice(0, 4).every(Number.isFinite))
|
|
1635
2213
|
throw new Error("栅格缺少地理范围,请通过 area 提供 [west, south, east, north]。");
|
|
1636
|
-
let [a,
|
|
2214
|
+
let [a, u, l, c] = e;
|
|
1637
2215
|
i && (!r || r === "EPSG:4326") && Math.abs(l - a) >= 359.999 && (a = -180, l = 180);
|
|
1638
|
-
const h = l - a,
|
|
1639
|
-
if (h === 0 ||
|
|
2216
|
+
const h = l - a, f = c - u;
|
|
2217
|
+
if (h === 0 || f === 0)
|
|
1640
2218
|
throw new Error("栅格地理范围无效,宽度或高度为 0。");
|
|
1641
2219
|
if (r === "EPSG:3857") {
|
|
1642
|
-
const
|
|
2220
|
+
const d = se(a, u), y = se(l, c);
|
|
1643
2221
|
return {
|
|
1644
2222
|
area: {
|
|
1645
|
-
startLon:
|
|
1646
|
-
startLat:
|
|
2223
|
+
startLon: d.lng,
|
|
2224
|
+
startLat: d.lat,
|
|
1647
2225
|
endLon: y.lng,
|
|
1648
2226
|
endLat: y.lat
|
|
1649
2227
|
},
|
|
1650
2228
|
projection: r,
|
|
1651
|
-
map(
|
|
1652
|
-
const
|
|
1653
|
-
a +
|
|
1654
|
-
|
|
2229
|
+
map(m, S) {
|
|
2230
|
+
const g = se(
|
|
2231
|
+
a + m / n * h,
|
|
2232
|
+
c - S / s * f
|
|
1655
2233
|
);
|
|
1656
|
-
return [
|
|
2234
|
+
return [g.lat, ie(g.lng)];
|
|
1657
2235
|
}
|
|
1658
2236
|
};
|
|
1659
2237
|
}
|
|
@@ -1662,39 +2240,39 @@ function ue({ area: t, bbox: e, projection: r, width: n, height: s, isSplit: i =
|
|
|
1662
2240
|
return {
|
|
1663
2241
|
area: {
|
|
1664
2242
|
startLon: a,
|
|
1665
|
-
startLat:
|
|
2243
|
+
startLat: u,
|
|
1666
2244
|
endLon: l,
|
|
1667
|
-
endLat:
|
|
2245
|
+
endLat: c
|
|
1668
2246
|
},
|
|
1669
2247
|
projection: r || "EPSG:4326",
|
|
1670
|
-
map(
|
|
1671
|
-
return [
|
|
2248
|
+
map(d, y) {
|
|
2249
|
+
return [c - y / s * f, ie(a + d / n * h)];
|
|
1672
2250
|
}
|
|
1673
2251
|
};
|
|
1674
2252
|
}
|
|
1675
|
-
function
|
|
2253
|
+
function zt(t = {}) {
|
|
1676
2254
|
const e = String(t.sourceType || t.dataType || "").toLowerCase();
|
|
1677
2255
|
return ["tif", "tiff", "geotiff"].includes(e) ? "geotiff" : ["gray", "grey", "grayscale", "greyscale", "image"].includes(e) ? "grayscale" : ["grid", "array", "values"].includes(e) ? "grid" : t.tifUrl || t.tiffUrl || t.arrayBuffer ? "geotiff" : t.grayImageUrl || t.imageUrl ? "grayscale" : t.values || t.data || t.grid ? "grid" : "";
|
|
1678
2256
|
}
|
|
1679
|
-
function
|
|
2257
|
+
function Ut() {
|
|
1680
2258
|
return typeof window > "u" ? null : window.GeoTIFF || null;
|
|
1681
2259
|
}
|
|
1682
|
-
function
|
|
2260
|
+
function $t(t, e = {}, r = null) {
|
|
1683
2261
|
if (!Number.isFinite(t)) return !0;
|
|
1684
|
-
const n =
|
|
2262
|
+
const n = _e(e, "noDataValue") ? Number(e.noDataValue) : r;
|
|
1685
2263
|
if (Number.isFinite(n) && t === n) return !0;
|
|
1686
|
-
const s =
|
|
2264
|
+
const s = P(e.validMin), i = P(e.validMax);
|
|
1687
2265
|
return s !== null && t < s || i !== null && t > i;
|
|
1688
2266
|
}
|
|
1689
|
-
function
|
|
1690
|
-
const n =
|
|
2267
|
+
function Ve(t, e = {}, r = null) {
|
|
2268
|
+
const n = P(e.scale, 1), s = P(e.offset, 0), i = new Float64Array(t.length);
|
|
1691
2269
|
for (let o = 0; o < t.length; o += 1) {
|
|
1692
2270
|
const a = Number(t[o]);
|
|
1693
|
-
i[o] =
|
|
2271
|
+
i[o] = $t(a, e, r) ? Number.NaN : a * n + s;
|
|
1694
2272
|
}
|
|
1695
2273
|
return i;
|
|
1696
2274
|
}
|
|
1697
|
-
function
|
|
2275
|
+
function ze(t, e, r) {
|
|
1698
2276
|
const n = new Float64Array(t.length), s = Math.floor(e / 2);
|
|
1699
2277
|
for (let i = 0; i < r; i += 1)
|
|
1700
2278
|
for (let o = 0; o < e; o += 1) {
|
|
@@ -1703,9 +2281,9 @@ function Be(t, e, r) {
|
|
|
1703
2281
|
}
|
|
1704
2282
|
return n;
|
|
1705
2283
|
}
|
|
1706
|
-
async function
|
|
1707
|
-
var
|
|
1708
|
-
const e =
|
|
2284
|
+
async function Wt(t = {}) {
|
|
2285
|
+
var v, b, w;
|
|
2286
|
+
const e = Ut();
|
|
1709
2287
|
if (!e)
|
|
1710
2288
|
throw new Error("GeoTIFF 未加载,请先提供 window.GeoTIFF。");
|
|
1711
2289
|
let r = t.arrayBuffer || null;
|
|
@@ -1714,77 +2292,77 @@ async function xt(t = {}) {
|
|
|
1714
2292
|
if (!n) throw new Error("GeoTIFF 数据源缺少 tifUrl。");
|
|
1715
2293
|
r = (await Ue.get(n, { responseType: "arraybuffer" })).data;
|
|
1716
2294
|
}
|
|
1717
|
-
const s = await e.fromArrayBuffer(r), i = Math.max(Math.floor(
|
|
2295
|
+
const s = await e.fromArrayBuffer(r), i = Math.max(Math.floor(P(t.imageIndex, 0)), 0), o = await s.getImage(i), a = o.getWidth(), u = o.getHeight(), l = Math.max(Math.floor(P(t.band, 0)), 0);
|
|
1718
2296
|
if (l >= o.getSamplesPerPixel())
|
|
1719
2297
|
throw new Error(`GeoTIFF 不存在第 ${l} 个波段。`);
|
|
1720
|
-
const
|
|
1721
|
-
let
|
|
1722
|
-
t.isSplit && (
|
|
2298
|
+
const c = { samples: [l], interleave: !1 }, h = await o.readRasters(c), f = P((v = o.getGDALNoData) == null ? void 0 : v.call(o));
|
|
2299
|
+
let d = Ve(h[0], t, f);
|
|
2300
|
+
t.isSplit && (d = ze(d, a, u));
|
|
1723
2301
|
let y = [];
|
|
1724
2302
|
try {
|
|
1725
|
-
y = ((
|
|
1726
|
-
} catch (
|
|
1727
|
-
if (!t.area) throw
|
|
2303
|
+
y = ((b = o.getBoundingBox) == null ? void 0 : b.call(o)) || [];
|
|
2304
|
+
} catch (G) {
|
|
2305
|
+
if (!t.area) throw G;
|
|
1728
2306
|
}
|
|
1729
|
-
const
|
|
2307
|
+
const m = ((w = o.getGeoKeys) == null ? void 0 : w.call(o)) || {}, S = he(t.sourceProjection) || Vt(m, y), g = ye({
|
|
1730
2308
|
area: t.area,
|
|
1731
2309
|
bbox: y,
|
|
1732
|
-
projection:
|
|
2310
|
+
projection: S,
|
|
1733
2311
|
width: a,
|
|
1734
|
-
height:
|
|
2312
|
+
height: u,
|
|
1735
2313
|
isSplit: t.isSplit
|
|
1736
2314
|
});
|
|
1737
2315
|
return {
|
|
1738
2316
|
sourceType: "geotiff",
|
|
1739
2317
|
sourceUrl: n,
|
|
1740
2318
|
width: a,
|
|
1741
|
-
height:
|
|
1742
|
-
values:
|
|
1743
|
-
sourceProjection:
|
|
1744
|
-
projection:
|
|
1745
|
-
area:
|
|
1746
|
-
mapCoordinate:
|
|
2319
|
+
height: u,
|
|
2320
|
+
values: d,
|
|
2321
|
+
sourceProjection: S,
|
|
2322
|
+
projection: g.projection,
|
|
2323
|
+
area: g.area,
|
|
2324
|
+
mapCoordinate: g.map,
|
|
1747
2325
|
band: l
|
|
1748
2326
|
};
|
|
1749
2327
|
}
|
|
1750
|
-
function
|
|
2328
|
+
function kt(t) {
|
|
1751
2329
|
return new Promise((e, r) => {
|
|
1752
2330
|
const n = new Image();
|
|
1753
2331
|
n.crossOrigin = "anonymous", n.onload = () => e(n), n.onerror = () => r(new Error(`灰度图加载失败:${t}`)), n.src = t;
|
|
1754
2332
|
});
|
|
1755
2333
|
}
|
|
1756
|
-
function
|
|
2334
|
+
function Yt(t, e, r = "luminance") {
|
|
1757
2335
|
return r === "red" ? t[e] : r === "green" ? t[e + 1] : r === "blue" ? t[e + 2] : r === "average" ? (t[e] + t[e + 1] + t[e + 2]) / 3 : t[e] * 0.2126 + t[e + 1] * 0.7152 + t[e + 2] * 0.0722;
|
|
1758
2336
|
}
|
|
1759
|
-
async function
|
|
2337
|
+
async function qt(t = {}) {
|
|
1760
2338
|
if (typeof document > "u" || typeof Image > "u")
|
|
1761
2339
|
throw new Error("灰度图解析只能在浏览器环境中运行。");
|
|
1762
|
-
const e = t.grayImageUrl || t.imageUrl || "", r =
|
|
2340
|
+
const e = t.grayImageUrl || t.imageUrl || "", r = je(t.area);
|
|
1763
2341
|
if (!e) throw new Error("灰度图数据源缺少 grayImageUrl 或 imageUrl。");
|
|
1764
2342
|
if (!r) throw new Error("灰度图没有地理信息,必须通过 area 提供覆盖范围。");
|
|
1765
|
-
const n = await
|
|
2343
|
+
const n = await kt(e), s = n.naturalWidth || n.width, i = n.naturalHeight || n.height, o = document.createElement("canvas");
|
|
1766
2344
|
o.width = s, o.height = i;
|
|
1767
2345
|
const a = o.getContext("2d", { willReadFrequently: !0 });
|
|
1768
2346
|
if (!a) throw new Error("当前浏览器不支持 Canvas 2D。");
|
|
1769
2347
|
a.drawImage(n, 0, 0, s, i);
|
|
1770
|
-
let
|
|
2348
|
+
let u;
|
|
1771
2349
|
try {
|
|
1772
|
-
|
|
1773
|
-
} catch (
|
|
1774
|
-
throw new Error(`灰度图像素读取失败,请检查图片 CORS:${(
|
|
1775
|
-
}
|
|
1776
|
-
const l =
|
|
1777
|
-
for (let
|
|
1778
|
-
for (let
|
|
1779
|
-
const
|
|
1780
|
-
if (
|
|
1781
|
-
|
|
2350
|
+
u = a.getImageData(0, 0, s, i).data;
|
|
2351
|
+
} catch (w) {
|
|
2352
|
+
throw new Error(`灰度图像素读取失败,请检查图片 CORS:${(w == null ? void 0 : w.message) || ""}`);
|
|
2353
|
+
}
|
|
2354
|
+
const l = P(t.grayMinValue, 0), c = P(t.grayMaxValue, 255), h = P(t.minValue, l), f = P(t.maxValue, c), d = c - l, y = String(t.grayChannel || t.grayMode || "luminance").toLowerCase(), m = _e(t, "noDataValue"), S = Number(t.noDataValue), g = t.isSplit ? Math.floor(s / 2) : 0, v = new Float64Array(s * i);
|
|
2355
|
+
for (let w = 0; w < i; w += 1)
|
|
2356
|
+
for (let G = 0; G < s; G += 1) {
|
|
2357
|
+
const E = (G + g) % s, T = (w * s + E) * 4, N = w * s + G, D = Yt(u, T, y);
|
|
2358
|
+
if (u[T + 3] === 0 || m && Math.abs(D - S) < 0.5) {
|
|
2359
|
+
v[N] = Number.NaN;
|
|
1782
2360
|
continue;
|
|
1783
2361
|
}
|
|
1784
|
-
let
|
|
1785
|
-
|
|
2362
|
+
let p = d === 0 ? 0 : (D - l) / d;
|
|
2363
|
+
p = Math.min(Math.max(p, 0), 1), t.invert && (p = 1 - p), v[N] = h + p * (f - h);
|
|
1786
2364
|
}
|
|
1787
|
-
const
|
|
2365
|
+
const b = ye({
|
|
1788
2366
|
area: r,
|
|
1789
2367
|
width: s,
|
|
1790
2368
|
height: i,
|
|
@@ -1795,15 +2373,15 @@ async function Et(t = {}) {
|
|
|
1795
2373
|
sourceUrl: e,
|
|
1796
2374
|
width: s,
|
|
1797
2375
|
height: i,
|
|
1798
|
-
values:
|
|
2376
|
+
values: v,
|
|
1799
2377
|
sourceProjection: "EPSG:4326",
|
|
1800
|
-
projection:
|
|
1801
|
-
area:
|
|
1802
|
-
mapCoordinate:
|
|
2378
|
+
projection: b.projection,
|
|
2379
|
+
area: b.area,
|
|
2380
|
+
mapCoordinate: b.map,
|
|
1803
2381
|
band: 0
|
|
1804
2382
|
};
|
|
1805
2383
|
}
|
|
1806
|
-
function
|
|
2384
|
+
function Ht(t = {}) {
|
|
1807
2385
|
var s;
|
|
1808
2386
|
const e = t.values || t.data || t.grid;
|
|
1809
2387
|
if (!e) return null;
|
|
@@ -1817,20 +2395,20 @@ function Rt(t = {}) {
|
|
|
1817
2395
|
values: e.flat()
|
|
1818
2396
|
};
|
|
1819
2397
|
}
|
|
1820
|
-
const r = Math.floor(
|
|
2398
|
+
const r = Math.floor(P(t.width, 0)), n = Math.floor(P(t.height, 0));
|
|
1821
2399
|
if (r < 2 || n < 2 || e.length < r * n)
|
|
1822
2400
|
throw new Error("一维数值网格必须提供正确的 width 和 height。");
|
|
1823
2401
|
return { width: r, height: n, values: e };
|
|
1824
2402
|
}
|
|
1825
|
-
function
|
|
1826
|
-
const e =
|
|
2403
|
+
function Xt(t = {}) {
|
|
2404
|
+
const e = Ht(t);
|
|
1827
2405
|
if (!e) throw new Error("数值网格缺少 values、data 或 grid。");
|
|
1828
|
-
let r =
|
|
1829
|
-
t.isSplit && (r =
|
|
1830
|
-
const n =
|
|
2406
|
+
let r = Ve(e.values, t);
|
|
2407
|
+
t.isSplit && (r = ze(r, e.width, e.height));
|
|
2408
|
+
const n = ye({
|
|
1831
2409
|
area: t.area,
|
|
1832
2410
|
bbox: t.bbox,
|
|
1833
|
-
projection:
|
|
2411
|
+
projection: he(t.sourceProjection) || "EPSG:4326",
|
|
1834
2412
|
width: e.width,
|
|
1835
2413
|
height: e.height,
|
|
1836
2414
|
isSplit: t.isSplit
|
|
@@ -1841,21 +2419,21 @@ function Ft(t = {}) {
|
|
|
1841
2419
|
width: e.width,
|
|
1842
2420
|
height: e.height,
|
|
1843
2421
|
values: r,
|
|
1844
|
-
sourceProjection:
|
|
2422
|
+
sourceProjection: he(t.sourceProjection) || "EPSG:4326",
|
|
1845
2423
|
projection: n.projection,
|
|
1846
2424
|
area: n.area,
|
|
1847
2425
|
mapCoordinate: n.map,
|
|
1848
2426
|
band: 0
|
|
1849
2427
|
};
|
|
1850
2428
|
}
|
|
1851
|
-
async function
|
|
1852
|
-
const e =
|
|
1853
|
-
if (e === "geotiff") return
|
|
1854
|
-
if (e === "grayscale") return
|
|
1855
|
-
if (e === "grid") return
|
|
2429
|
+
async function Kt(t = {}) {
|
|
2430
|
+
const e = zt(t);
|
|
2431
|
+
if (e === "geotiff") return Wt(t);
|
|
2432
|
+
if (e === "grayscale") return qt(t);
|
|
2433
|
+
if (e === "grid") return Xt(t);
|
|
1856
2434
|
throw new Error("无法识别栅格数据源,请提供 tifUrl、grayImageUrl 或 values。");
|
|
1857
2435
|
}
|
|
1858
|
-
function
|
|
2436
|
+
function Zt(t) {
|
|
1859
2437
|
let e = Number.POSITIVE_INFINITY, r = Number.NEGATIVE_INFINITY, n = 0;
|
|
1860
2438
|
for (let s = 0; s < t.length; s += 1) {
|
|
1861
2439
|
const i = Number(t[s]);
|
|
@@ -1864,16 +2442,16 @@ function Dt(t) {
|
|
|
1864
2442
|
if (!n) throw new Error("栅格中没有可用于生成等值线的有效数值。");
|
|
1865
2443
|
return { min: e, max: r, validCount: n, noDataCount: t.length - n };
|
|
1866
2444
|
}
|
|
1867
|
-
function
|
|
1868
|
-
const r = Math.max(Math.floor(
|
|
2445
|
+
function Jt(t, e = Q) {
|
|
2446
|
+
const r = Math.max(Math.floor(P(e, Q)), 4);
|
|
1869
2447
|
if (t.width * t.height <= r)
|
|
1870
2448
|
return t;
|
|
1871
2449
|
const n = Math.sqrt(r / (t.width * t.height)), s = Math.max(Math.floor(t.width * n), 2), i = Math.max(Math.floor(t.height * n), 2), o = new Float64Array(s * i);
|
|
1872
2450
|
for (let a = 0; a < i; a += 1) {
|
|
1873
|
-
const
|
|
2451
|
+
const u = Math.round(a / Math.max(i - 1, 1) * (t.height - 1));
|
|
1874
2452
|
for (let l = 0; l < s; l += 1) {
|
|
1875
|
-
const
|
|
1876
|
-
o[a * s + l] = t.values[
|
|
2453
|
+
const c = Math.round(l / Math.max(s - 1, 1) * (t.width - 1));
|
|
2454
|
+
o[a * s + l] = t.values[u * t.width + c];
|
|
1877
2455
|
}
|
|
1878
2456
|
}
|
|
1879
2457
|
return {
|
|
@@ -1881,10 +2459,10 @@ function Bt(t, e = we) {
|
|
|
1881
2459
|
width: s,
|
|
1882
2460
|
height: i,
|
|
1883
2461
|
values: o,
|
|
1884
|
-
mapCoordinate(a,
|
|
2462
|
+
mapCoordinate(a, u) {
|
|
1885
2463
|
return t.mapCoordinate(
|
|
1886
2464
|
a / s * t.width,
|
|
1887
|
-
|
|
2465
|
+
u / i * t.height
|
|
1888
2466
|
);
|
|
1889
2467
|
},
|
|
1890
2468
|
downsampled: !0,
|
|
@@ -1892,129 +2470,372 @@ function Bt(t, e = we) {
|
|
|
1892
2470
|
originalHeight: t.height
|
|
1893
2471
|
};
|
|
1894
2472
|
}
|
|
1895
|
-
function
|
|
2473
|
+
function xe(t, e = 10) {
|
|
1896
2474
|
const r = 10 ** e;
|
|
1897
2475
|
return Math.round(t * r) / r;
|
|
1898
2476
|
}
|
|
1899
|
-
function
|
|
2477
|
+
function Qt(t, e = {}) {
|
|
1900
2478
|
const r = e.thresholds || e.levels;
|
|
1901
2479
|
if (Array.isArray(r))
|
|
1902
2480
|
return [...new Set(r.map(Number).filter(Number.isFinite))].filter((o) => o > t.min && o < t.max).sort((o, a) => o - a);
|
|
1903
|
-
const n =
|
|
2481
|
+
const n = P(e.interval ?? e.contourInterval);
|
|
1904
2482
|
if (n !== null && n > 0) {
|
|
1905
2483
|
const o = [];
|
|
1906
2484
|
let a = Math.ceil(t.min / n) * n;
|
|
1907
2485
|
for (; a < t.max && o.length < 200; )
|
|
1908
|
-
a > t.min && o.push(
|
|
2486
|
+
a > t.min && o.push(xe(a)), a += n;
|
|
1909
2487
|
return o;
|
|
1910
2488
|
}
|
|
1911
2489
|
const s = Math.min(
|
|
1912
|
-
Math.max(Math.floor(
|
|
2490
|
+
Math.max(Math.floor(P(e.thresholdCount ?? e.levelCount, 12)), 1),
|
|
1913
2491
|
100
|
|
1914
2492
|
), i = (t.max - t.min) / (s + 1);
|
|
1915
2493
|
return Array.from(
|
|
1916
2494
|
{ length: s },
|
|
1917
|
-
(o, a) =>
|
|
2495
|
+
(o, a) => xe(t.min + i * (a + 1))
|
|
1918
2496
|
);
|
|
1919
2497
|
}
|
|
1920
|
-
function
|
|
2498
|
+
function er(t, e, r, n) {
|
|
1921
2499
|
return Math.abs(t[0]) < 1e-7 && Math.abs(e[0]) < 1e-7 || Math.abs(t[0] - r) < 1e-7 && Math.abs(e[0] - r) < 1e-7 || Math.abs(t[1]) < 1e-7 && Math.abs(e[1]) < 1e-7 || Math.abs(t[1] - n) < 1e-7 && Math.abs(e[1] - n) < 1e-7;
|
|
1922
2500
|
}
|
|
1923
|
-
function
|
|
2501
|
+
function tr(t = [], e, r) {
|
|
1924
2502
|
const n = [...t];
|
|
1925
2503
|
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 [];
|
|
1926
2504
|
const s = n.map(
|
|
1927
|
-
(
|
|
2505
|
+
(u, l) => er(u, n[(l + 1) % n.length], e, r)
|
|
1928
2506
|
), i = s.findIndex(Boolean);
|
|
1929
2507
|
if (i < 0)
|
|
1930
2508
|
return [[...n, n[0]]];
|
|
1931
2509
|
const o = [];
|
|
1932
2510
|
let a = [];
|
|
1933
|
-
for (let
|
|
1934
|
-
const l = (i +
|
|
2511
|
+
for (let u = 1; u <= n.length; u += 1) {
|
|
2512
|
+
const l = (i + u) % n.length, c = (l + 1) % n.length;
|
|
1935
2513
|
if (s[l]) {
|
|
1936
2514
|
a.length > 1 && o.push(a), a = [];
|
|
1937
2515
|
continue;
|
|
1938
2516
|
}
|
|
1939
|
-
a.length === 0 && a.push(n[l]), a.push(n[
|
|
2517
|
+
a.length === 0 && a.push(n[l]), a.push(n[c]);
|
|
1940
2518
|
}
|
|
1941
2519
|
return a.length > 1 && o.push(a), o;
|
|
1942
2520
|
}
|
|
1943
|
-
function
|
|
2521
|
+
function rr(t = {}) {
|
|
1944
2522
|
return t.type === "Polygon" ? t.coordinates || [] : t.type === "MultiPolygon" ? (t.coordinates || []).flatMap((e) => e) : [];
|
|
1945
2523
|
}
|
|
1946
|
-
function
|
|
2524
|
+
function nr(t, e) {
|
|
1947
2525
|
return (t == null ? void 0 : t[0]) === (e == null ? void 0 : e[0]) && (t == null ? void 0 : t[1]) === (e == null ? void 0 : e[1]);
|
|
1948
2526
|
}
|
|
1949
|
-
function
|
|
2527
|
+
function sr(t = [], e = 0) {
|
|
1950
2528
|
const r = Math.min(Math.max(Math.floor(e), 0), 3);
|
|
1951
2529
|
if (r === 0 || t.length < 3) return t;
|
|
1952
|
-
const n =
|
|
2530
|
+
const n = nr(t[0], t[t.length - 1]);
|
|
1953
2531
|
let s = n ? t.slice(0, -1) : [...t];
|
|
1954
2532
|
for (let i = 0; i < r; i += 1) {
|
|
1955
2533
|
const o = n ? [] : [s[0]], a = n ? s.length : s.length - 1;
|
|
1956
|
-
for (let
|
|
1957
|
-
const l = s[
|
|
2534
|
+
for (let u = 0; u < a; u += 1) {
|
|
2535
|
+
const l = s[u], c = s[(u + 1) % s.length];
|
|
1958
2536
|
o.push([
|
|
1959
|
-
l[0] * 0.75 +
|
|
1960
|
-
l[1] * 0.75 +
|
|
2537
|
+
l[0] * 0.75 + c[0] * 0.25,
|
|
2538
|
+
l[1] * 0.75 + c[1] * 0.25
|
|
1961
2539
|
]), o.push([
|
|
1962
|
-
l[0] * 0.25 +
|
|
1963
|
-
l[1] * 0.25 +
|
|
2540
|
+
l[0] * 0.25 + c[0] * 0.75,
|
|
2541
|
+
l[1] * 0.25 + c[1] * 0.75
|
|
1964
2542
|
]);
|
|
1965
2543
|
}
|
|
1966
2544
|
n || o.push(s[s.length - 1]), s = o;
|
|
1967
2545
|
}
|
|
1968
2546
|
return n ? [...s, s[0]] : s;
|
|
1969
2547
|
}
|
|
1970
|
-
function
|
|
2548
|
+
function ir(t, e, r = 6) {
|
|
1971
2549
|
const n = 10 ** Math.max(Math.floor(r), 0), s = [];
|
|
1972
2550
|
return t.forEach((i) => {
|
|
1973
2551
|
const o = e(i[0], i[1]);
|
|
1974
2552
|
if (!(o != null && o.every(Number.isFinite))) return;
|
|
1975
|
-
const a = o.map((l) => Math.round(l * n) / n),
|
|
1976
|
-
(!
|
|
2553
|
+
const a = o.map((l) => Math.round(l * n) / n), u = s[s.length - 1];
|
|
2554
|
+
(!u || u[0] !== a[0] || u[1] !== a[1]) && s.push(a);
|
|
1977
2555
|
}), s;
|
|
1978
2556
|
}
|
|
1979
|
-
function
|
|
1980
|
-
const
|
|
2557
|
+
function or(t = {}) {
|
|
2558
|
+
const e = t && typeof t == "object" ? t : {};
|
|
2559
|
+
return {
|
|
2560
|
+
enabled: e.enabled === !0,
|
|
2561
|
+
radius: Math.max(
|
|
2562
|
+
Math.floor(P(e.radius, U.radius)),
|
|
2563
|
+
1
|
|
2564
|
+
),
|
|
2565
|
+
minProminence: Math.max(
|
|
2566
|
+
P(e.minProminence, U.minProminence),
|
|
2567
|
+
0
|
|
2568
|
+
),
|
|
2569
|
+
minGridDistance: Math.max(
|
|
2570
|
+
P(e.minGridDistance, U.minGridDistance),
|
|
2571
|
+
0
|
|
2572
|
+
),
|
|
2573
|
+
maxCount: Math.max(
|
|
2574
|
+
Math.floor(P(e.maxCount, U.maxCount)),
|
|
2575
|
+
0
|
|
2576
|
+
),
|
|
2577
|
+
includeHigh: e.includeHigh !== !1,
|
|
2578
|
+
includeLow: e.includeLow !== !1,
|
|
2579
|
+
excludeBoundary: e.excludeBoundary !== !1,
|
|
2580
|
+
smoothingIterations: Math.min(
|
|
2581
|
+
Math.max(
|
|
2582
|
+
Math.floor(
|
|
2583
|
+
P(
|
|
2584
|
+
e.smoothingIterations,
|
|
2585
|
+
U.smoothingIterations
|
|
2586
|
+
)
|
|
2587
|
+
),
|
|
2588
|
+
0
|
|
2589
|
+
),
|
|
2590
|
+
3
|
|
2591
|
+
)
|
|
2592
|
+
};
|
|
2593
|
+
}
|
|
2594
|
+
function ar(t) {
|
|
2595
|
+
const e = t.width * t.height, r = e > Q ? Math.max(Math.ceil(Math.sqrt(e / Q)), 2) : 1;
|
|
2596
|
+
if (r === 1)
|
|
2597
|
+
return {
|
|
2598
|
+
width: t.width,
|
|
2599
|
+
height: t.height,
|
|
2600
|
+
values: t.values,
|
|
2601
|
+
stride: r,
|
|
2602
|
+
getSourceBounds(o, a) {
|
|
2603
|
+
return { startX: o, endX: o, startY: a, endY: a };
|
|
2604
|
+
}
|
|
2605
|
+
};
|
|
2606
|
+
const n = Math.ceil(t.width / r), s = Math.ceil(t.height / r), i = new Float64Array(n * s);
|
|
2607
|
+
for (let o = 0; o < s; o += 1) {
|
|
2608
|
+
const a = o * r, u = Math.min(a + r - 1, t.height - 1);
|
|
2609
|
+
for (let l = 0; l < n; l += 1) {
|
|
2610
|
+
const c = l * r, h = Math.min(c + r - 1, t.width - 1);
|
|
2611
|
+
let f = 0, d = 0;
|
|
2612
|
+
for (let y = a; y <= u; y += 1)
|
|
2613
|
+
for (let m = c; m <= h; m += 1) {
|
|
2614
|
+
const S = Number(t.values[y * t.width + m]);
|
|
2615
|
+
Number.isFinite(S) && (f += S, d += 1);
|
|
2616
|
+
}
|
|
2617
|
+
i[o * n + l] = d > 0 ? f / d : Number.NaN;
|
|
2618
|
+
}
|
|
2619
|
+
}
|
|
2620
|
+
return {
|
|
2621
|
+
width: n,
|
|
2622
|
+
height: s,
|
|
2623
|
+
values: i,
|
|
2624
|
+
stride: r,
|
|
2625
|
+
getSourceBounds(o, a) {
|
|
2626
|
+
const u = o * r, l = a * r;
|
|
2627
|
+
return {
|
|
2628
|
+
startX: u,
|
|
2629
|
+
endX: Math.min(u + r - 1, t.width - 1),
|
|
2630
|
+
startY: l,
|
|
2631
|
+
endY: Math.min(l + r - 1, t.height - 1)
|
|
2632
|
+
};
|
|
2633
|
+
}
|
|
2634
|
+
};
|
|
2635
|
+
}
|
|
2636
|
+
function lr(t, e, r, n) {
|
|
2637
|
+
let s = t;
|
|
2638
|
+
for (let i = 0; i < n; i += 1) {
|
|
2639
|
+
const o = new Float64Array(t.length);
|
|
2640
|
+
for (let a = 0; a < r; a += 1)
|
|
2641
|
+
for (let u = 0; u < e; u += 1) {
|
|
2642
|
+
const l = a * e + u;
|
|
2643
|
+
if (!Number.isFinite(Number(s[l]))) {
|
|
2644
|
+
o[l] = Number.NaN;
|
|
2645
|
+
continue;
|
|
2646
|
+
}
|
|
2647
|
+
let c = 0, h = 0;
|
|
2648
|
+
for (let f = -1; f <= 1; f += 1) {
|
|
2649
|
+
const d = a + f;
|
|
2650
|
+
if (!(d < 0 || d >= r))
|
|
2651
|
+
for (let y = -1; y <= 1; y += 1) {
|
|
2652
|
+
const m = u + y;
|
|
2653
|
+
if (m < 0 || m >= e) continue;
|
|
2654
|
+
const S = Number(s[d * e + m]);
|
|
2655
|
+
Number.isFinite(S) && (c += S, h += 1);
|
|
2656
|
+
}
|
|
2657
|
+
}
|
|
2658
|
+
o[l] = h > 0 ? c / h : Number.NaN;
|
|
2659
|
+
}
|
|
2660
|
+
s = o;
|
|
2661
|
+
}
|
|
2662
|
+
return s;
|
|
2663
|
+
}
|
|
2664
|
+
function ur(t, e, r) {
|
|
2665
|
+
const n = e + 1, s = new Float64Array(n * (r + 1)), i = new Uint32Array(n * (r + 1));
|
|
2666
|
+
for (let o = 0; o < r; o += 1) {
|
|
2667
|
+
let a = 0, u = 0;
|
|
2668
|
+
for (let l = 0; l < e; l += 1) {
|
|
2669
|
+
const c = Number(t[o * e + l]);
|
|
2670
|
+
Number.isFinite(c) && (a += c, u += 1);
|
|
2671
|
+
const h = (o + 1) * n + l + 1;
|
|
2672
|
+
s[h] = s[o * n + l + 1] + a, i[h] = i[o * n + l + 1] + u;
|
|
2673
|
+
}
|
|
2674
|
+
}
|
|
2675
|
+
return {
|
|
2676
|
+
query(o, a, u, l) {
|
|
2677
|
+
const c = Math.max(Math.min(o, e - 1), 0), h = Math.max(Math.min(a, r - 1), 0), f = Math.max(Math.min(u, e - 1), c), d = Math.max(Math.min(l, r - 1), h), y = h * n + c, m = h * n + f + 1, S = (d + 1) * n + c, g = (d + 1) * n + f + 1;
|
|
2678
|
+
return {
|
|
2679
|
+
sum: s[g] - s[m] - s[S] + s[y],
|
|
2680
|
+
count: i[g] - i[m] - i[S] + i[y],
|
|
2681
|
+
cellCount: (f - c + 1) * (d - h + 1)
|
|
2682
|
+
};
|
|
2683
|
+
}
|
|
2684
|
+
};
|
|
2685
|
+
}
|
|
2686
|
+
function cr(t, e, r, n, s, i) {
|
|
2687
|
+
const o = s * e + n, a = Number(t[o]);
|
|
2688
|
+
if (!Number.isFinite(a)) return [];
|
|
2689
|
+
let u = i.includeHigh, l = i.includeLow, c = !1, h = !1, f = 0;
|
|
2690
|
+
for (let y = -1; y <= 1; y += 1) {
|
|
2691
|
+
const m = s + y;
|
|
2692
|
+
if (!(m < 0 || m >= r))
|
|
2693
|
+
for (let S = -1; S <= 1; S += 1) {
|
|
2694
|
+
if (S === 0 && y === 0) continue;
|
|
2695
|
+
const g = n + S;
|
|
2696
|
+
if (g < 0 || g >= e) continue;
|
|
2697
|
+
const v = m * e + g, b = Number(t[v]);
|
|
2698
|
+
if (!Number.isFinite(b)) {
|
|
2699
|
+
if (i.excludeBoundary) return [];
|
|
2700
|
+
continue;
|
|
2701
|
+
}
|
|
2702
|
+
f += 1, b > a ? (u = !1, h = !0) : b < a ? (l = !1, c = !0) : v < o && (u = !1, l = !1);
|
|
2703
|
+
}
|
|
2704
|
+
}
|
|
2705
|
+
if (f < 3) return [];
|
|
2706
|
+
const d = [];
|
|
2707
|
+
return u && c && d.push("H"), l && h && d.push("L"), d;
|
|
2708
|
+
}
|
|
2709
|
+
function hr(t, e, r, n) {
|
|
2710
|
+
const s = e.getSourceBounds(t.gridX, t.gridY), i = (s.startX + s.endX) / 2, o = (s.startY + s.endY) / 2;
|
|
2711
|
+
let a = null;
|
|
2712
|
+
for (let l = s.startY; l <= s.endY; l += 1)
|
|
2713
|
+
for (let c = s.startX; c <= s.endX; c += 1) {
|
|
2714
|
+
if (n.excludeBoundary && (c < n.radius || l < n.radius || c >= r.width - n.radius || l >= r.height - n.radius))
|
|
2715
|
+
continue;
|
|
2716
|
+
const h = Number(r.values[l * r.width + c]);
|
|
2717
|
+
if (!Number.isFinite(h)) continue;
|
|
2718
|
+
const f = (c - i) ** 2 + (l - o) ** 2, d = t.type === "H" ? !a || h > a.value : !a || h < a.value, y = a && h === a.value && f < a.distanceToApproximate;
|
|
2719
|
+
(d || y) && (a = { x: c, y: l, value: h, distanceToApproximate: f });
|
|
2720
|
+
}
|
|
2721
|
+
if (!a) return null;
|
|
2722
|
+
const u = r.mapCoordinate(a.x, a.y);
|
|
2723
|
+
return u != null && u.every(Number.isFinite) ? {
|
|
2724
|
+
...t,
|
|
2725
|
+
value: a.value,
|
|
2726
|
+
lat: u[0],
|
|
2727
|
+
lon: u[1],
|
|
2728
|
+
sourceX: a.x,
|
|
2729
|
+
sourceY: a.y
|
|
2730
|
+
} : null;
|
|
2731
|
+
}
|
|
2732
|
+
function de(t, e) {
|
|
2733
|
+
return t.type !== e.type ? t.type === "H" ? -1 : 1 : (t.type === "H" ? e.value - t.value : t.value - e.value) || e.prominence - t.prominence || t.sourceY - e.sourceY || t.sourceX - e.sourceX;
|
|
2734
|
+
}
|
|
2735
|
+
function dr(t, e) {
|
|
2736
|
+
const r = e ** 2, n = [];
|
|
2737
|
+
return t.sort(de).forEach((s) => {
|
|
2738
|
+
n.some(
|
|
2739
|
+
(o) => o.type === s.type && (o.sourceX - s.sourceX) ** 2 + (o.sourceY - s.sourceY) ** 2 < r
|
|
2740
|
+
) || n.push(s);
|
|
2741
|
+
}), n;
|
|
2742
|
+
}
|
|
2743
|
+
function fr(t, e = {}) {
|
|
2744
|
+
const r = or(e);
|
|
2745
|
+
if (!r.enabled || r.maxCount === 0 || !r.includeHigh && !r.includeLow || t.width < 3 || t.height < 3)
|
|
2746
|
+
return [];
|
|
2747
|
+
const n = ar(t), s = lr(
|
|
2748
|
+
n.values,
|
|
2749
|
+
n.width,
|
|
2750
|
+
n.height,
|
|
2751
|
+
r.smoothingIterations
|
|
2752
|
+
), i = ur(
|
|
2753
|
+
s,
|
|
2754
|
+
n.width,
|
|
2755
|
+
n.height
|
|
2756
|
+
), o = Math.max(Math.ceil(r.radius / n.stride), 1), a = [];
|
|
2757
|
+
for (let c = 0; c < n.height; c += 1)
|
|
2758
|
+
for (let h = 0; h < n.width; h += 1) {
|
|
2759
|
+
if (r.excludeBoundary && (h < o || c < o || h >= n.width - o || c >= n.height - o))
|
|
2760
|
+
continue;
|
|
2761
|
+
const f = Number(s[c * n.width + h]);
|
|
2762
|
+
if (!Number.isFinite(f)) continue;
|
|
2763
|
+
const d = cr(
|
|
2764
|
+
s,
|
|
2765
|
+
n.width,
|
|
2766
|
+
n.height,
|
|
2767
|
+
h,
|
|
2768
|
+
c,
|
|
2769
|
+
r
|
|
2770
|
+
);
|
|
2771
|
+
if (d.length === 0) continue;
|
|
2772
|
+
const y = i.query(
|
|
2773
|
+
h - o,
|
|
2774
|
+
c - o,
|
|
2775
|
+
h + o,
|
|
2776
|
+
c + o
|
|
2777
|
+
);
|
|
2778
|
+
if (r.excludeBoundary && y.count < y.cellCount) continue;
|
|
2779
|
+
const m = y.count - 1;
|
|
2780
|
+
if (m < 3) continue;
|
|
2781
|
+
const S = (y.sum - f) / m;
|
|
2782
|
+
d.forEach((g) => {
|
|
2783
|
+
const v = g === "H" ? f - S : S - f;
|
|
2784
|
+
v < r.minProminence || a.push({
|
|
2785
|
+
type: g,
|
|
2786
|
+
label: g,
|
|
2787
|
+
prominence: v,
|
|
2788
|
+
gridX: h,
|
|
2789
|
+
gridY: c
|
|
2790
|
+
});
|
|
2791
|
+
});
|
|
2792
|
+
}
|
|
2793
|
+
const u = a.map((c) => hr(c, n, t, r)).filter(Boolean);
|
|
2794
|
+
return dr(u, r.minGridDistance).sort(
|
|
2795
|
+
(c, h) => h.prominence - c.prominence || de(c, h)
|
|
2796
|
+
).slice(0, r.maxCount).sort(de).map(({ type: c, label: h, value: f, lat: d, lon: y }) => ({ type: c, label: h, value: f, lat: d, lon: y }));
|
|
2797
|
+
}
|
|
2798
|
+
function yr(t, e = {}) {
|
|
2799
|
+
const r = Zt(t.values);
|
|
1981
2800
|
if (r.min === r.max)
|
|
1982
2801
|
throw new Error("栅格数值全部相同,无法生成等值线。");
|
|
1983
|
-
const n =
|
|
2802
|
+
const n = Jt(t, e.maxCells), s = Qt(r, e);
|
|
1984
2803
|
if (s.length === 0)
|
|
1985
2804
|
throw new Error("当前值域内没有可用的等值线级别。");
|
|
1986
|
-
const i =
|
|
1987
|
-
Math.floor(
|
|
2805
|
+
const i = _t().size([n.width, n.height]).smooth(e.smooth !== !1).thresholds(s)(n.values), o = Math.max(
|
|
2806
|
+
Math.floor(P(e.minimumLinePoints, 3)),
|
|
1988
2807
|
2
|
|
1989
2808
|
), a = Math.min(
|
|
1990
|
-
Math.max(Math.floor(
|
|
2809
|
+
Math.max(Math.floor(P(e.smoothingIterations, 0)), 0),
|
|
1991
2810
|
3
|
|
1992
|
-
),
|
|
1993
|
-
const
|
|
1994
|
-
(d) => e.excludeBoundary === !1 ? [d] :
|
|
1995
|
-
).map((d) =>
|
|
2811
|
+
), u = i.map((c) => {
|
|
2812
|
+
const f = rr(c).flatMap(
|
|
2813
|
+
(d) => e.excludeBoundary === !1 ? [d] : tr(d, n.width, n.height)
|
|
2814
|
+
).map((d) => sr(d, a)).map((d) => ir(d, n.mapCoordinate, e.coordinatePrecision)).filter((d) => d.length >= o);
|
|
1996
2815
|
return {
|
|
1997
|
-
value:
|
|
1998
|
-
label: String(
|
|
1999
|
-
lines:
|
|
2816
|
+
value: c.value,
|
|
2817
|
+
label: String(c.value),
|
|
2818
|
+
lines: f
|
|
2000
2819
|
};
|
|
2001
|
-
});
|
|
2820
|
+
}), l = fr(t, e.centerDetection);
|
|
2002
2821
|
return {
|
|
2003
|
-
isolines:
|
|
2822
|
+
isolines: u,
|
|
2823
|
+
centers: l,
|
|
2004
2824
|
thresholds: s,
|
|
2005
2825
|
range: r,
|
|
2006
2826
|
renderWidth: n.width,
|
|
2007
2827
|
renderHeight: n.height,
|
|
2008
2828
|
downsampled: !!n.downsampled,
|
|
2009
|
-
lineCount:
|
|
2829
|
+
lineCount: u.reduce((c, h) => c + h.lines.length, 0)
|
|
2010
2830
|
};
|
|
2011
2831
|
}
|
|
2012
|
-
const
|
|
2832
|
+
const gr = /* @__PURE__ */ new Set([
|
|
2013
2833
|
"arrayBuffer",
|
|
2014
2834
|
"area",
|
|
2015
2835
|
"band",
|
|
2016
2836
|
"bbox",
|
|
2017
2837
|
"contourInterval",
|
|
2838
|
+
"centerDetection",
|
|
2018
2839
|
"coordinatePrecision",
|
|
2019
2840
|
"data",
|
|
2020
2841
|
"dataType",
|
|
@@ -2051,7 +2872,7 @@ const qt = /* @__PURE__ */ new Set([
|
|
|
2051
2872
|
"values",
|
|
2052
2873
|
"width",
|
|
2053
2874
|
"height"
|
|
2054
|
-
]),
|
|
2875
|
+
]), Ir = /* @__PURE__ */ new Set([
|
|
2055
2876
|
"arrayBuffer",
|
|
2056
2877
|
"area",
|
|
2057
2878
|
"band",
|
|
@@ -2082,32 +2903,38 @@ const qt = /* @__PURE__ */ new Set([
|
|
|
2082
2903
|
"values",
|
|
2083
2904
|
"width"
|
|
2084
2905
|
]);
|
|
2085
|
-
function
|
|
2906
|
+
function mr(t = {}) {
|
|
2086
2907
|
const { mapCore: e, baseGIS: r, ...n } = t;
|
|
2087
2908
|
return n;
|
|
2088
2909
|
}
|
|
2089
|
-
function
|
|
2910
|
+
function br(t = {}) {
|
|
2911
|
+
var e;
|
|
2912
|
+
return ((e = t.centerDetection) == null ? void 0 : e.enabled) === !0;
|
|
2913
|
+
}
|
|
2914
|
+
function Sr(t, e, r = null) {
|
|
2090
2915
|
const n = {};
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
})
|
|
2916
|
+
Object.entries(t).forEach(([i, o]) => {
|
|
2917
|
+
gr.has(i) || (n[i] = o);
|
|
2918
|
+
});
|
|
2919
|
+
const s = {
|
|
2094
2920
|
...n,
|
|
2095
2921
|
layerId: t.layerId || t.contourLayerId || "raster-contour-default",
|
|
2096
2922
|
coordinateOrder: "latlng",
|
|
2097
2923
|
// Leaflet 使用栅格真实范围动态创建当前视野需要的世界副本。
|
|
2098
2924
|
worldCopyArea: t.worldCopyArea || r,
|
|
2099
|
-
isolines: e
|
|
2925
|
+
isolines: e.isolines
|
|
2100
2926
|
};
|
|
2927
|
+
return s.centers = Array.isArray(t.centers) ? t.centers : br(t) ? e.centers : [], s;
|
|
2101
2928
|
}
|
|
2102
|
-
function
|
|
2929
|
+
function O() {
|
|
2103
2930
|
return typeof performance < "u" ? performance.now() : Date.now();
|
|
2104
2931
|
}
|
|
2105
|
-
function
|
|
2106
|
-
return Object.keys(t).some((e) =>
|
|
2932
|
+
function Lr(t = {}) {
|
|
2933
|
+
return Object.keys(t).some((e) => Ir.has(e));
|
|
2107
2934
|
}
|
|
2108
|
-
class
|
|
2935
|
+
class Or {
|
|
2109
2936
|
constructor(e = {}) {
|
|
2110
|
-
const r =
|
|
2937
|
+
const r = mr(e), n = r.layerId || r.contourLayerId || "raster-contour-default";
|
|
2111
2938
|
this.defaultPayload = {
|
|
2112
2939
|
thresholdCount: 12,
|
|
2113
2940
|
maxCells: 1e6,
|
|
@@ -2115,8 +2942,12 @@ class Sr {
|
|
|
2115
2942
|
excludeBoundary: !0,
|
|
2116
2943
|
visible: !0,
|
|
2117
2944
|
...r,
|
|
2945
|
+
centerDetection: {
|
|
2946
|
+
...U,
|
|
2947
|
+
...r.centerDetection || {}
|
|
2948
|
+
},
|
|
2118
2949
|
layerId: n
|
|
2119
|
-
}, this.baseGIS = null, this.contourController = new
|
|
2950
|
+
}, this.baseGIS = null, this.contourController = new Ye({ layerId: n }), this.currentPayload = null, this.currentGrid = null, this.operationId = 0, this.state = {
|
|
2120
2951
|
layerId: n,
|
|
2121
2952
|
sourceType: "",
|
|
2122
2953
|
sourceUrl: "",
|
|
@@ -2132,6 +2963,9 @@ class Sr {
|
|
|
2132
2963
|
noDataCount: 0,
|
|
2133
2964
|
levelCount: 0,
|
|
2134
2965
|
lineCount: 0,
|
|
2966
|
+
centerCount: 0,
|
|
2967
|
+
lineLabelCount: 0,
|
|
2968
|
+
centerLabelCount: 0,
|
|
2135
2969
|
labelCount: 0,
|
|
2136
2970
|
lineRenderer: "",
|
|
2137
2971
|
thresholds: [],
|
|
@@ -2160,86 +2994,99 @@ class Sr {
|
|
|
2160
2994
|
) : I("RasterContourController has not been mounted.", "NOT_MOUNTED");
|
|
2161
2995
|
}
|
|
2162
2996
|
async renderGrid(e, r, n, s, i = !1, o = 0) {
|
|
2163
|
-
var
|
|
2164
|
-
const a =
|
|
2165
|
-
|
|
2997
|
+
var v;
|
|
2998
|
+
const a = O(), u = yr(e, r), l = O() - a, c = Sr(r, u, e.area), h = c.centers.length, f = c.onStateChange;
|
|
2999
|
+
c.onStateChange = (b) => {
|
|
2166
3000
|
n === this.operationId && (this.state = {
|
|
2167
3001
|
...this.state,
|
|
2168
|
-
lineCount: (
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
3002
|
+
lineCount: (b == null ? void 0 : b.lineCount) ?? this.state.lineCount,
|
|
3003
|
+
centerCount: (b == null ? void 0 : b.centerCount) ?? h,
|
|
3004
|
+
lineLabelCount: (b == null ? void 0 : b.lineLabelCount) ?? this.state.lineLabelCount,
|
|
3005
|
+
centerLabelCount: (b == null ? void 0 : b.centerLabelCount) ?? this.state.centerLabelCount,
|
|
3006
|
+
labelCount: (b == null ? void 0 : b.labelCount) ?? this.state.labelCount,
|
|
3007
|
+
lineRenderer: (b == null ? void 0 : b.lineRenderer) ?? this.state.lineRenderer,
|
|
3008
|
+
lineBuildElapsed: (b == null ? void 0 : b.lineBuildElapsed) ?? this.state.lineBuildElapsed,
|
|
3009
|
+
labelLayoutElapsed: (b == null ? void 0 : b.labelLayoutElapsed) ?? this.state.labelLayoutElapsed,
|
|
3010
|
+
primitiveReadyElapsed: (b == null ? void 0 : b.primitiveReadyElapsed) ?? this.state.primitiveReadyElapsed,
|
|
3011
|
+
visible: (b == null ? void 0 : b.visible) ?? this.state.visible
|
|
3012
|
+
}, f == null || f(b));
|
|
2176
3013
|
};
|
|
2177
|
-
const d =
|
|
2178
|
-
if (!
|
|
3014
|
+
const d = O(), y = i ? await this.contourController.update(c) : await this.contourController.load(c), m = O() - d;
|
|
3015
|
+
if (!y.success) return y;
|
|
2179
3016
|
if (n !== this.operationId)
|
|
2180
3017
|
return L({ stale: !0, ignored: !0 }, "Raster contour render was superseded.");
|
|
2181
|
-
const
|
|
3018
|
+
const S = O() - s, g = ((v = y.data) == null ? void 0 : v.state) || y.data || null;
|
|
2182
3019
|
return this.currentPayload = r, this.currentGrid = e, this.state = {
|
|
2183
3020
|
...this.state,
|
|
2184
|
-
layerId:
|
|
3021
|
+
layerId: c.layerId,
|
|
2185
3022
|
sourceType: e.sourceType,
|
|
2186
3023
|
sourceUrl: e.sourceUrl,
|
|
2187
3024
|
sourceProjection: e.sourceProjection,
|
|
2188
3025
|
projection: e.projection,
|
|
2189
3026
|
width: e.width,
|
|
2190
3027
|
height: e.height,
|
|
2191
|
-
renderWidth:
|
|
2192
|
-
renderHeight:
|
|
2193
|
-
min:
|
|
2194
|
-
max:
|
|
2195
|
-
validCount:
|
|
2196
|
-
noDataCount:
|
|
2197
|
-
levelCount:
|
|
2198
|
-
lineCount:
|
|
3028
|
+
renderWidth: u.renderWidth,
|
|
3029
|
+
renderHeight: u.renderHeight,
|
|
3030
|
+
min: u.range.min,
|
|
3031
|
+
max: u.range.max,
|
|
3032
|
+
validCount: u.range.validCount,
|
|
3033
|
+
noDataCount: u.range.noDataCount,
|
|
3034
|
+
levelCount: u.thresholds.length,
|
|
3035
|
+
lineCount: u.lineCount,
|
|
3036
|
+
centerCount: (g == null ? void 0 : g.centerCount) ?? h,
|
|
3037
|
+
lineLabelCount: (g == null ? void 0 : g.lineLabelCount) || 0,
|
|
3038
|
+
centerLabelCount: (g == null ? void 0 : g.centerLabelCount) || 0,
|
|
2199
3039
|
labelCount: (g == null ? void 0 : g.labelCount) || 0,
|
|
2200
3040
|
lineRenderer: (g == null ? void 0 : g.lineRenderer) || "",
|
|
2201
|
-
thresholds:
|
|
3041
|
+
thresholds: u.thresholds,
|
|
2202
3042
|
area: e.area,
|
|
2203
3043
|
sourceElapsed: o,
|
|
2204
3044
|
generateElapsed: l,
|
|
2205
|
-
renderElapsed:
|
|
3045
|
+
renderElapsed: m,
|
|
2206
3046
|
lineBuildElapsed: (g == null ? void 0 : g.lineBuildElapsed) || 0,
|
|
2207
3047
|
labelLayoutElapsed: (g == null ? void 0 : g.labelLayoutElapsed) || 0,
|
|
2208
3048
|
primitiveReadyElapsed: (g == null ? void 0 : g.primitiveReadyElapsed) || 0,
|
|
2209
|
-
elapsed:
|
|
2210
|
-
downsampled:
|
|
2211
|
-
visible:
|
|
3049
|
+
elapsed: S,
|
|
3050
|
+
downsampled: u.downsampled,
|
|
3051
|
+
visible: c.visible !== !1,
|
|
2212
3052
|
loaded: !0
|
|
2213
3053
|
}, L(
|
|
2214
3054
|
{
|
|
2215
3055
|
...this.getState(),
|
|
2216
3056
|
contourState: g
|
|
2217
3057
|
},
|
|
2218
|
-
i ? `Raster contour layer "${
|
|
3058
|
+
i ? `Raster contour layer "${c.layerId}" regenerated.` : `Raster contour layer "${c.layerId}" loaded.`
|
|
2219
3059
|
);
|
|
2220
3060
|
}
|
|
2221
3061
|
async load(e = {}, r = {}) {
|
|
3062
|
+
var a;
|
|
2222
3063
|
const n = this.resolveBaseGIS();
|
|
2223
3064
|
if (!n.success) return n;
|
|
2224
3065
|
const s = {
|
|
2225
3066
|
...this.defaultPayload,
|
|
2226
3067
|
...this.currentPayload || {},
|
|
2227
3068
|
...e,
|
|
2228
|
-
...r
|
|
2229
|
-
|
|
3069
|
+
...r,
|
|
3070
|
+
centerDetection: {
|
|
3071
|
+
...this.defaultPayload.centerDetection,
|
|
3072
|
+
...((a = this.currentPayload) == null ? void 0 : a.centerDetection) || {},
|
|
3073
|
+
...e.centerDetection || {},
|
|
3074
|
+
...r.centerDetection || {}
|
|
3075
|
+
}
|
|
3076
|
+
}, i = ++this.operationId, o = O();
|
|
2230
3077
|
try {
|
|
2231
|
-
const
|
|
3078
|
+
const u = await Kt(s), l = O() - o;
|
|
2232
3079
|
return i !== this.operationId ? L({ stale: !0, ignored: !0 }, "Raster contour load was superseded.") : this.renderGrid(
|
|
2233
|
-
|
|
3080
|
+
u,
|
|
2234
3081
|
s,
|
|
2235
3082
|
i,
|
|
2236
3083
|
o,
|
|
2237
3084
|
!1,
|
|
2238
|
-
|
|
3085
|
+
l
|
|
2239
3086
|
);
|
|
2240
|
-
} catch (
|
|
3087
|
+
} catch (u) {
|
|
2241
3088
|
return I(
|
|
2242
|
-
(
|
|
3089
|
+
(u == null ? void 0 : u.message) || "Raster contour generation failed.",
|
|
2243
3090
|
"RASTER_CONTOUR_FAILED"
|
|
2244
3091
|
);
|
|
2245
3092
|
}
|
|
@@ -2256,14 +3103,18 @@ class Sr {
|
|
|
2256
3103
|
async update(e = {}) {
|
|
2257
3104
|
if (!this.currentPayload || !this.currentGrid)
|
|
2258
3105
|
return I("Raster contour source has not been loaded.", "NOT_LOADED");
|
|
2259
|
-
if (
|
|
3106
|
+
if (Lr(e))
|
|
2260
3107
|
return this.load(e);
|
|
2261
3108
|
const r = this.resolveBaseGIS();
|
|
2262
3109
|
if (!r.success) return r;
|
|
2263
3110
|
const n = {
|
|
2264
3111
|
...this.currentPayload,
|
|
2265
|
-
...e
|
|
2266
|
-
|
|
3112
|
+
...e,
|
|
3113
|
+
centerDetection: {
|
|
3114
|
+
...this.currentPayload.centerDetection || {},
|
|
3115
|
+
...e.centerDetection || {}
|
|
3116
|
+
}
|
|
3117
|
+
}, s = ++this.operationId, i = O();
|
|
2267
3118
|
try {
|
|
2268
3119
|
return await this.renderGrid(
|
|
2269
3120
|
this.currentGrid,
|
|
@@ -2297,6 +3148,9 @@ class Sr {
|
|
|
2297
3148
|
...this.state,
|
|
2298
3149
|
levelCount: 0,
|
|
2299
3150
|
lineCount: 0,
|
|
3151
|
+
centerCount: 0,
|
|
3152
|
+
lineLabelCount: 0,
|
|
3153
|
+
centerLabelCount: 0,
|
|
2300
3154
|
labelCount: 0,
|
|
2301
3155
|
thresholds: [],
|
|
2302
3156
|
loaded: !1
|
|
@@ -2309,9 +3163,13 @@ class Sr {
|
|
|
2309
3163
|
...this.state,
|
|
2310
3164
|
levelCount: 0,
|
|
2311
3165
|
lineCount: 0,
|
|
3166
|
+
centerCount: 0,
|
|
3167
|
+
lineLabelCount: 0,
|
|
3168
|
+
centerLabelCount: 0,
|
|
2312
3169
|
labelCount: 0,
|
|
2313
3170
|
thresholds: [],
|
|
2314
|
-
loaded: !1
|
|
3171
|
+
loaded: !1,
|
|
3172
|
+
visible: !1
|
|
2315
3173
|
}, e;
|
|
2316
3174
|
}
|
|
2317
3175
|
getRasterData() {
|
|
@@ -2326,511 +3184,7 @@ class Sr {
|
|
|
2326
3184
|
};
|
|
2327
3185
|
}
|
|
2328
3186
|
}
|
|
2329
|
-
|
|
2330
|
-
return typeof window < "u" ? window.Cesium : null;
|
|
2331
|
-
}
|
|
2332
|
-
function Zt(t) {
|
|
2333
|
-
let e = t;
|
|
2334
|
-
return e > 90 && (e -= 180), e < -90 && (e += 180), e;
|
|
2335
|
-
}
|
|
2336
|
-
function Jt(t, e = 0) {
|
|
2337
|
-
return O.divIcon({
|
|
2338
|
-
className: "pressure-label-icon",
|
|
2339
|
-
html: `<span style="transform: translate(-50%, -50%) rotate(${Zt(e)}deg)">${t}</span>`,
|
|
2340
|
-
iconSize: [0, 0],
|
|
2341
|
-
iconAnchor: [0, 0]
|
|
2342
|
-
});
|
|
2343
|
-
}
|
|
2344
|
-
function Qt(t) {
|
|
2345
|
-
return O.divIcon({
|
|
2346
|
-
className: `pressure-center-icon pressure-center-icon--${t.type.toLowerCase()}`,
|
|
2347
|
-
html: `<span class="pressure-center-icon__type">${t.type}</span><span class="pressure-center-icon__value">${t.value}</span>`,
|
|
2348
|
-
iconSize: [0, 0],
|
|
2349
|
-
iconAnchor: [0, 0]
|
|
2350
|
-
});
|
|
2351
|
-
}
|
|
2352
|
-
function oe(t, e) {
|
|
2353
|
-
return t.some(
|
|
2354
|
-
(r) => !(e.right < r.left || e.left > r.right || e.bottom < r.top || e.top > r.bottom)
|
|
2355
|
-
);
|
|
2356
|
-
}
|
|
2357
|
-
function ae(t, e, r) {
|
|
2358
|
-
return {
|
|
2359
|
-
left: t.x - e,
|
|
2360
|
-
right: t.x + e,
|
|
2361
|
-
top: t.y - r,
|
|
2362
|
-
bottom: t.y + r
|
|
2363
|
-
};
|
|
2364
|
-
}
|
|
2365
|
-
function Ge(t, e, r = 18, n = 10) {
|
|
2366
|
-
t.sort((s, i) => s.score - i.score);
|
|
2367
|
-
for (let s = 0; s < t.length; s += 1) {
|
|
2368
|
-
const i = t[s], o = ae(i.point, r, n);
|
|
2369
|
-
if (!oe(e, o))
|
|
2370
|
-
return e.push(o), i;
|
|
2371
|
-
}
|
|
2372
|
-
return null;
|
|
2373
|
-
}
|
|
2374
|
-
function Me(t = [], e = 0) {
|
|
2375
|
-
return e ? t.map((r) => [r[0], r[1] + e]) : t;
|
|
2376
|
-
}
|
|
2377
|
-
function er(t = [], e = 2) {
|
|
2378
|
-
if (t.length <= 2 || e <= 1)
|
|
2379
|
-
return t;
|
|
2380
|
-
const r = [];
|
|
2381
|
-
for (let s = 0; s < t.length; s += e)
|
|
2382
|
-
r.push(t[s]);
|
|
2383
|
-
const n = t[t.length - 1];
|
|
2384
|
-
return r[r.length - 1] !== n && r.push(n), r;
|
|
2385
|
-
}
|
|
2386
|
-
function tr(t) {
|
|
2387
|
-
let e = Number(t);
|
|
2388
|
-
for (; e > 180; )
|
|
2389
|
-
e -= 360;
|
|
2390
|
-
for (; e < -180; )
|
|
2391
|
-
e += 360;
|
|
2392
|
-
return e;
|
|
2393
|
-
}
|
|
2394
|
-
function Te(t) {
|
|
2395
|
-
return Math.round(Number(t) / 100);
|
|
2396
|
-
}
|
|
2397
|
-
function rr(t = [], e = 0) {
|
|
2398
|
-
const r = [];
|
|
2399
|
-
for (let n = 0; n < t.length - 1; n += 2) {
|
|
2400
|
-
const s = Number(t[n]), i = Number(t[n + 1]) + e;
|
|
2401
|
-
Number.isFinite(s) && Number.isFinite(i) && r.push([s, i]);
|
|
2402
|
-
}
|
|
2403
|
-
return r;
|
|
2404
|
-
}
|
|
2405
|
-
function nr(t, e, r, n, s) {
|
|
2406
|
-
const i = s * s, o = i * s;
|
|
2407
|
-
return [
|
|
2408
|
-
0.5 * (2 * e[0] + (-t[0] + r[0]) * s + (2 * t[0] - 5 * e[0] + 4 * r[0] - n[0]) * i + (-t[0] + 3 * e[0] - 3 * r[0] + n[0]) * o),
|
|
2409
|
-
0.5 * (2 * e[1] + (-t[1] + r[1]) * s + (2 * t[1] - 5 * e[1] + 4 * r[1] - n[1]) * i + (-t[1] + 3 * e[1] - 3 * r[1] + n[1]) * o)
|
|
2410
|
-
];
|
|
2411
|
-
}
|
|
2412
|
-
function sr(t = [], e = 5) {
|
|
2413
|
-
if (t.length < 3)
|
|
2414
|
-
return t;
|
|
2415
|
-
const r = [t[0]];
|
|
2416
|
-
for (let n = 0; n < t.length - 1; n += 1) {
|
|
2417
|
-
const s = t[n - 1] || t[n], i = t[n], o = t[n + 1], a = t[n + 2] || o;
|
|
2418
|
-
for (let c = 1; c <= e; c += 1)
|
|
2419
|
-
r.push(nr(s, i, o, a, c / e));
|
|
2420
|
-
}
|
|
2421
|
-
return r;
|
|
2422
|
-
}
|
|
2423
|
-
function ir(t = {}) {
|
|
2424
|
-
const e = (t.isoline || []).map((n) => {
|
|
2425
|
-
const s = Number(n.value);
|
|
2426
|
-
return {
|
|
2427
|
-
value: s,
|
|
2428
|
-
hpa: Te(s),
|
|
2429
|
-
major: s % 800 === 0,
|
|
2430
|
-
lines: [sr(rr(n.points))].filter((i) => i.length > 1)
|
|
2431
|
-
};
|
|
2432
|
-
}), r = ["high", "low"].flatMap((n) => {
|
|
2433
|
-
const s = t[n] || {}, i = Array.isArray(s.value) ? s.value : [], o = Array.isArray(s.points) ? s.points : [], a = [];
|
|
2434
|
-
for (let c = 0; c < o.length - 1; c += 2)
|
|
2435
|
-
a.push({
|
|
2436
|
-
type: n === "high" ? "H" : "L",
|
|
2437
|
-
value: Te(i[c / 2]),
|
|
2438
|
-
lat: Number(o[c]),
|
|
2439
|
-
lon: tr(o[c + 1])
|
|
2440
|
-
});
|
|
2441
|
-
return a;
|
|
2442
|
-
});
|
|
2443
|
-
return {
|
|
2444
|
-
isolines: e,
|
|
2445
|
-
centers: r
|
|
2446
|
-
};
|
|
2447
|
-
}
|
|
2448
|
-
function le(t = {}) {
|
|
2449
|
-
return Array.isArray(t == null ? void 0 : t.isolines) ? {
|
|
2450
|
-
...t,
|
|
2451
|
-
isolines: t.isolines,
|
|
2452
|
-
centers: Array.isArray(t.centers) ? t.centers : []
|
|
2453
|
-
} : ir(t);
|
|
2454
|
-
}
|
|
2455
|
-
function vr(t = {}) {
|
|
2456
|
-
const e = /* @__PURE__ */ new Map();
|
|
2457
|
-
return (r = "default") => {
|
|
2458
|
-
const n = r || "default";
|
|
2459
|
-
return e.has(n) || e.set(n, le(t[n] || t.default || {})), e.get(n);
|
|
2460
|
-
};
|
|
2461
|
-
}
|
|
2462
|
-
class or {
|
|
2463
|
-
constructor(e = {}) {
|
|
2464
|
-
this.mapCore = e.mapCore, this.mapContainerId = e.mapContainerId, this.getData = e.getData, this.isVisible = e.isVisible, this.onStateChange = e.onStateChange, this.worldCopyOffsets = e.worldCopyOffsets || [-360, 0, 360], this.cesiumWorldCopyOffsets = e.cesiumWorldCopyOffsets || [0], this.cesiumLineThinStep = e.cesiumLineThinStep || 2, this.labelLayerGroup = null, this.cesiumLabelCollection = null, this.labelUpdateTimer = null, this.removeViewChangeListener = null;
|
|
2465
|
-
}
|
|
2466
|
-
// 当前引擎类型由 BaseGIS 决定,标注层只负责适配具体绘制方式。
|
|
2467
|
-
isCesiumEngine() {
|
|
2468
|
-
var e, r;
|
|
2469
|
-
return ((r = (e = this.mapCore) == null ? void 0 : e.getEngineType) == null ? void 0 : r.call(e)) === "cesium";
|
|
2470
|
-
}
|
|
2471
|
-
// Cesium 3D 模式需要判断地球背面遮挡,2D/哥伦布视图不做额外遮挡过滤。
|
|
2472
|
-
getCesiumSceneMode() {
|
|
2473
|
-
var r, n, s;
|
|
2474
|
-
const e = (n = (r = this.mapCore) == null ? void 0 : r.getMapInstance) == null ? void 0 : n.call(r);
|
|
2475
|
-
return (s = e == null ? void 0 : e.scene) == null ? void 0 : s.mode;
|
|
2476
|
-
}
|
|
2477
|
-
// 挂载标注层事件:Leaflet 监听地图事件,Cesium 走 BaseGIS 的视图变化回调。
|
|
2478
|
-
mount() {
|
|
2479
|
-
var r, n, s, i, o, a;
|
|
2480
|
-
if (this.isCesiumEngine()) {
|
|
2481
|
-
this.removeViewChangeListener = ((i = (s = (n = (r = this.mapCore) == null ? void 0 : r.onViewChange) == null ? void 0 : n.call(r, {
|
|
2482
|
-
onEnd: () => this.scheduleUpdate(),
|
|
2483
|
-
endDelay: 180
|
|
2484
|
-
})) == null ? void 0 : s.data) == null ? void 0 : i.off) || null;
|
|
2485
|
-
return;
|
|
2486
|
-
}
|
|
2487
|
-
const e = (a = (o = this.mapCore) == null ? void 0 : o.getMapInstance) == null ? void 0 : a.call(o);
|
|
2488
|
-
e && (this.labelLayerGroup = O.layerGroup().addTo(e), e.on("moveend zoomend resize", this.scheduleUpdate, this));
|
|
2489
|
-
}
|
|
2490
|
-
// 地图连续移动时只在下一帧刷新一次标签,减少重复碰撞计算。
|
|
2491
|
-
scheduleUpdate() {
|
|
2492
|
-
this.labelUpdateTimer && window.cancelAnimationFrame(this.labelUpdateTimer), this.labelUpdateTimer = window.requestAnimationFrame(() => {
|
|
2493
|
-
this.labelUpdateTimer = null, this.update();
|
|
2494
|
-
});
|
|
2495
|
-
}
|
|
2496
|
-
// 根据当前显隐状态和引擎类型刷新标注。
|
|
2497
|
-
update() {
|
|
2498
|
-
var e;
|
|
2499
|
-
return (e = this.isVisible) != null && e.call(this) ? this.isCesiumEngine() ? this.updateCesiumLabels() : this.updateLeafletLabels() : (this.clear(), 0);
|
|
2500
|
-
}
|
|
2501
|
-
// 清空当前标注,并同步标签数量为 0。
|
|
2502
|
-
clear() {
|
|
2503
|
-
var e;
|
|
2504
|
-
this.isCesiumEngine() ? this.clearCesiumLabelCollection() : (e = this.labelLayerGroup) == null || e.clearLayers(), this.emitStateChange(0);
|
|
2505
|
-
}
|
|
2506
|
-
// 销毁时移除地图事件、Cesium LabelCollection 和 Leaflet 图层组。
|
|
2507
|
-
destroy() {
|
|
2508
|
-
var r, n, s, i, o;
|
|
2509
|
-
this.labelUpdateTimer && (window.cancelAnimationFrame(this.labelUpdateTimer), this.labelUpdateTimer = null);
|
|
2510
|
-
const e = (n = (r = this.mapCore) == null ? void 0 : r.getMapInstance) == null ? void 0 : n.call(r);
|
|
2511
|
-
(s = e == null ? void 0 : e.off) == null || s.call(e, "moveend zoomend resize", this.scheduleUpdate, this), (i = this.removeViewChangeListener) == null || i.call(this), this.removeViewChangeListener = null, this.clearCesiumLabelCollection(!0), (o = this.labelLayerGroup) == null || o.remove(), this.labelLayerGroup = null;
|
|
2512
|
-
}
|
|
2513
|
-
// 把标签数量回传给页面状态面板。
|
|
2514
|
-
emitStateChange(e) {
|
|
2515
|
-
var r;
|
|
2516
|
-
(r = this.onStateChange) == null || r.call(this, {
|
|
2517
|
-
labelCount: e
|
|
2518
|
-
});
|
|
2519
|
-
}
|
|
2520
|
-
// Cesium 3D 球面下,屏幕外或地球背面的点不参与标签候选。
|
|
2521
|
-
isCesiumPointVisible(e) {
|
|
2522
|
-
var l, u, h, d, f, y;
|
|
2523
|
-
const r = (u = (l = this.mapCore) == null ? void 0 : l.getMapInstance) == null ? void 0 : u.call(l), n = _(), s = r == null ? void 0 : r.scene;
|
|
2524
|
-
if (!r || !n || !s)
|
|
2525
|
-
return !1;
|
|
2526
|
-
if (this.getCesiumSceneMode() !== n.SceneMode.SCENE3D)
|
|
2527
|
-
return !0;
|
|
2528
|
-
const i = ((h = s.globe) == null ? void 0 : h.ellipsoid) || ((d = s.mapProjection) == null ? void 0 : d.ellipsoid), o = ((f = s.camera) == null ? void 0 : f.positionWC) || ((y = s.camera) == null ? void 0 : y.position);
|
|
2529
|
-
if (!i || !o)
|
|
2530
|
-
return !0;
|
|
2531
|
-
const a = n.Cartesian3.fromDegrees(e[1], e[0], 0);
|
|
2532
|
-
return new n.EllipsoidalOccluder(i, o).isPointVisible(a);
|
|
2533
|
-
}
|
|
2534
|
-
// 标签候选点只在地图容器附近参与碰撞,防止屏幕外点影响布局。
|
|
2535
|
-
isCesiumScreenPointInViewport(e, r = 80) {
|
|
2536
|
-
const n = document.getElementById(this.mapContainerId), s = (n == null ? void 0 : n.clientWidth) || 0, i = (n == null ? void 0 : n.clientHeight) || 0;
|
|
2537
|
-
return !s || !i ? !0 : !(e.x < -r || e.y < -r || e.x > s + r || e.y > i + r);
|
|
2538
|
-
}
|
|
2539
|
-
// LabelCollection 比为每个标签创建 Entity 更轻量,适合动态重建。
|
|
2540
|
-
ensureCesiumLabelCollection() {
|
|
2541
|
-
var n, s, i;
|
|
2542
|
-
const e = (s = (n = this.mapCore) == null ? void 0 : n.getMapInstance) == null ? void 0 : s.call(n), r = _();
|
|
2543
|
-
return !((i = e == null ? void 0 : e.scene) != null && i.primitives) || !r ? null : (this.cesiumLabelCollection || (this.cesiumLabelCollection = e.scene.primitives.add(new r.LabelCollection())), this.cesiumLabelCollection);
|
|
2544
|
-
}
|
|
2545
|
-
// 数据更新和图层隐藏时清空标签;页面卸载时才销毁集合。
|
|
2546
|
-
clearCesiumLabelCollection(e = !1) {
|
|
2547
|
-
var n, s, i;
|
|
2548
|
-
const r = (s = (n = this.mapCore) == null ? void 0 : n.getMapInstance) == null ? void 0 : s.call(n);
|
|
2549
|
-
if (this.cesiumLabelCollection) {
|
|
2550
|
-
if (e && ((i = r == null ? void 0 : r.scene) != null && i.primitives)) {
|
|
2551
|
-
r.scene.primitives.remove(this.cesiumLabelCollection), this.cesiumLabelCollection = null;
|
|
2552
|
-
return;
|
|
2553
|
-
}
|
|
2554
|
-
this.cesiumLabelCollection.removeAll();
|
|
2555
|
-
}
|
|
2556
|
-
}
|
|
2557
|
-
// 页面数据统一是 [lat, lon],Cesium 创建坐标时需要 [lon, lat]。
|
|
2558
|
-
createCesiumPosition(e) {
|
|
2559
|
-
return _().Cartesian3.fromDegrees(e[1], e[0], 0);
|
|
2560
|
-
}
|
|
2561
|
-
// 将地理点投影到容器像素坐标,供标签碰撞避让使用。
|
|
2562
|
-
projectCesiumPoint(e) {
|
|
2563
|
-
var s, i;
|
|
2564
|
-
if (!this.isCesiumPointVisible(e))
|
|
2565
|
-
return null;
|
|
2566
|
-
const r = (i = (s = this.mapCore) == null ? void 0 : s.projectToContainerPoint) == null ? void 0 : i.call(s, {
|
|
2567
|
-
latitude: e[0],
|
|
2568
|
-
longitude: e[1]
|
|
2569
|
-
});
|
|
2570
|
-
if (!(r != null && r.success))
|
|
2571
|
-
return null;
|
|
2572
|
-
const n = O.point(r.data.x, r.data.y);
|
|
2573
|
-
return this.isCesiumScreenPointInViewport(n) ? n : null;
|
|
2574
|
-
}
|
|
2575
|
-
// Cesium 添加单个标签,中心点标签和线值标签共用该方法。
|
|
2576
|
-
addCesiumLabel(e, r, n = {}) {
|
|
2577
|
-
const s = _(), i = this.ensureCesiumLabelCollection();
|
|
2578
|
-
return !i || !s || !this.isCesiumPointVisible(e) ? null : i.add({
|
|
2579
|
-
position: this.createCesiumPosition(e),
|
|
2580
|
-
text: r,
|
|
2581
|
-
font: n.font || "12px Arial",
|
|
2582
|
-
fillColor: n.fillColor || s.Color.fromCssColorString("#244349"),
|
|
2583
|
-
outlineColor: s.Color.fromCssColorString("rgba(255,255,255,0.72)"),
|
|
2584
|
-
outlineWidth: n.outlineWidth ?? 2,
|
|
2585
|
-
style: s.LabelStyle.FILL_AND_OUTLINE,
|
|
2586
|
-
showBackground: n.showBackground !== !1,
|
|
2587
|
-
backgroundColor: n.backgroundColor || s.Color.fromCssColorString("rgba(246,251,231,0.92)"),
|
|
2588
|
-
backgroundPadding: n.backgroundPadding || new s.Cartesian2(7, 4),
|
|
2589
|
-
horizontalOrigin: s.HorizontalOrigin.CENTER,
|
|
2590
|
-
verticalOrigin: s.VerticalOrigin.CENTER,
|
|
2591
|
-
disableDepthTestDistance: n.disableDepthTestDistance ?? 0,
|
|
2592
|
-
scale: n.scale || 1
|
|
2593
|
-
});
|
|
2594
|
-
}
|
|
2595
|
-
// Cesium H/L 中心点标注,先做屏幕碰撞检测再绘制。
|
|
2596
|
-
addCesiumCenters(e, r) {
|
|
2597
|
-
const n = _();
|
|
2598
|
-
if (!n)
|
|
2599
|
-
return 0;
|
|
2600
|
-
let s = 0;
|
|
2601
|
-
return e.centers.forEach((i) => {
|
|
2602
|
-
this.cesiumWorldCopyOffsets.forEach((o) => {
|
|
2603
|
-
const a = [i.lat, i.lon + o], c = this.projectCesiumPoint(a);
|
|
2604
|
-
if (!c)
|
|
2605
|
-
return;
|
|
2606
|
-
const l = ae(c, 18, 20);
|
|
2607
|
-
oe(r, l) || (r.push(l), this.addCesiumLabel(a, `${i.type}
|
|
2608
|
-
${i.value}`, {
|
|
2609
|
-
font: "700 18px Arial",
|
|
2610
|
-
fillColor: n.Color.fromCssColorString(i.type === "H" ? "#efb7ff" : "#e3f8ff"),
|
|
2611
|
-
backgroundColor: n.Color.TRANSPARENT,
|
|
2612
|
-
showBackground: !1,
|
|
2613
|
-
outlineWidth: 3
|
|
2614
|
-
}), s += 1);
|
|
2615
|
-
});
|
|
2616
|
-
}), s;
|
|
2617
|
-
}
|
|
2618
|
-
// Leaflet H/L 中心点标注,按当前视野过滤后再做碰撞检测。
|
|
2619
|
-
addLeafletCenters(e, r) {
|
|
2620
|
-
var o, a, c, l;
|
|
2621
|
-
const n = (a = (o = this.mapCore) == null ? void 0 : o.getMapInstance) == null ? void 0 : a.call(o), s = (l = (c = n == null ? void 0 : n.getBounds) == null ? void 0 : c.call(n)) == null ? void 0 : l.pad(0.2);
|
|
2622
|
-
if (!n || !s || !this.labelLayerGroup)
|
|
2623
|
-
return 0;
|
|
2624
|
-
let i = 0;
|
|
2625
|
-
return e.centers.forEach((u) => {
|
|
2626
|
-
this.worldCopyOffsets.forEach((h) => {
|
|
2627
|
-
const d = [u.lat, u.lon + h];
|
|
2628
|
-
if (!s.contains(d))
|
|
2629
|
-
return;
|
|
2630
|
-
const f = n.latLngToContainerPoint(d), y = ae(f, 16, 18);
|
|
2631
|
-
oe(r, y) || (r.push(y), O.marker(d, {
|
|
2632
|
-
interactive: !1,
|
|
2633
|
-
keyboard: !1,
|
|
2634
|
-
icon: Qt(u),
|
|
2635
|
-
zIndexOffset: 140
|
|
2636
|
-
}).addTo(this.labelLayerGroup), i += 1);
|
|
2637
|
-
});
|
|
2638
|
-
}), i;
|
|
2639
|
-
}
|
|
2640
|
-
// 线值标签统一从折线中采样候选点,再按离视野中心的距离排序。
|
|
2641
|
-
getLineLabelCandidates(e, r = {}) {
|
|
2642
|
-
const { bounds: n, useSegmentMidpoint: s = !1, viewCenter: i, projectPoint: o } = r, a = [], c = Math.max(Math.floor(e.length / 40), 1);
|
|
2643
|
-
for (let l = 0; l < e.length - 1; l += c) {
|
|
2644
|
-
const u = e[l], h = e[Math.min(l + c, e.length - 1)], d = [
|
|
2645
|
-
(u[0] + h[0]) / 2,
|
|
2646
|
-
(u[1] + h[1]) / 2
|
|
2647
|
-
];
|
|
2648
|
-
if (n && !n.contains(d))
|
|
2649
|
-
continue;
|
|
2650
|
-
const f = o(u), y = o(h), b = o(d);
|
|
2651
|
-
if (!f || !y || !b)
|
|
2652
|
-
continue;
|
|
2653
|
-
const g = s ? O.point((f.x + y.x) / 2, (f.y + y.y) / 2) : b;
|
|
2654
|
-
a.push({
|
|
2655
|
-
position: d,
|
|
2656
|
-
point: g,
|
|
2657
|
-
angle: Math.atan2(y.y - f.y, y.x - f.x) * 180 / Math.PI,
|
|
2658
|
-
score: g.distanceTo(i)
|
|
2659
|
-
});
|
|
2660
|
-
}
|
|
2661
|
-
return a;
|
|
2662
|
-
}
|
|
2663
|
-
// Leaflet 线值标签:每条线选择靠近视野中心且不碰撞的位置。
|
|
2664
|
-
addLeafletLineLabels(e, r) {
|
|
2665
|
-
var a, c, l, u;
|
|
2666
|
-
const n = (c = (a = this.mapCore) == null ? void 0 : a.getMapInstance) == null ? void 0 : c.call(a), s = (u = (l = n == null ? void 0 : n.getBounds) == null ? void 0 : l.call(n)) == null ? void 0 : u.pad(0.15);
|
|
2667
|
-
if (!n || !s || !this.labelLayerGroup)
|
|
2668
|
-
return 0;
|
|
2669
|
-
const i = n.getSize().divideBy(2);
|
|
2670
|
-
let o = 0;
|
|
2671
|
-
return e.isolines.forEach((h) => {
|
|
2672
|
-
this.worldCopyOffsets.forEach((d) => {
|
|
2673
|
-
h.lines.forEach((f) => {
|
|
2674
|
-
const y = Me(f, d), b = Ge(this.getLineLabelCandidates(y, {
|
|
2675
|
-
bounds: s,
|
|
2676
|
-
useSegmentMidpoint: !0,
|
|
2677
|
-
viewCenter: i,
|
|
2678
|
-
projectPoint: (g) => n.latLngToContainerPoint(g)
|
|
2679
|
-
}), r);
|
|
2680
|
-
b && (O.marker(b.position, {
|
|
2681
|
-
interactive: !1,
|
|
2682
|
-
keyboard: !1,
|
|
2683
|
-
icon: Jt(h.hpa, b.angle),
|
|
2684
|
-
zIndexOffset: 120
|
|
2685
|
-
}).addTo(this.labelLayerGroup), o += 1);
|
|
2686
|
-
});
|
|
2687
|
-
});
|
|
2688
|
-
}), o;
|
|
2689
|
-
}
|
|
2690
|
-
// Cesium 线值标签:先将候选点投影到屏幕,再按距离和碰撞筛选。
|
|
2691
|
-
addCesiumLineLabels(e, r) {
|
|
2692
|
-
let n = 0;
|
|
2693
|
-
const s = document.getElementById(this.mapContainerId), i = O.point(((s == null ? void 0 : s.clientWidth) || 0) / 2, ((s == null ? void 0 : s.clientHeight) || 0) / 2);
|
|
2694
|
-
return e.isolines.forEach((o) => {
|
|
2695
|
-
this.cesiumWorldCopyOffsets.forEach((a) => {
|
|
2696
|
-
o.lines.forEach((c) => {
|
|
2697
|
-
const l = er(Me(c, a), this.cesiumLineThinStep), u = Ge(this.getLineLabelCandidates(l, {
|
|
2698
|
-
viewCenter: i,
|
|
2699
|
-
projectPoint: (h) => this.projectCesiumPoint(h)
|
|
2700
|
-
}), r);
|
|
2701
|
-
u && (this.addCesiumLabel(u.position, String(o.hpa), {
|
|
2702
|
-
font: "12px Arial"
|
|
2703
|
-
}), n += 1);
|
|
2704
|
-
});
|
|
2705
|
-
});
|
|
2706
|
-
}), n;
|
|
2707
|
-
}
|
|
2708
|
-
// 重建 Cesium 全部标签,并请求场景刷新。
|
|
2709
|
-
updateCesiumLabels() {
|
|
2710
|
-
var a, c, l, u, h, d, f, y, b;
|
|
2711
|
-
const e = (c = (a = this.mapCore) == null ? void 0 : a.getMapInstance) == null ? void 0 : c.call(a), r = (l = this.getData) == null ? void 0 : l.call(this);
|
|
2712
|
-
if (!r)
|
|
2713
|
-
return this.clear(), 0;
|
|
2714
|
-
const n = this.cesiumLabelCollection;
|
|
2715
|
-
this.cesiumLabelCollection = null;
|
|
2716
|
-
const s = this.ensureCesiumLabelCollection();
|
|
2717
|
-
if (!s)
|
|
2718
|
-
return this.cesiumLabelCollection = n, 0;
|
|
2719
|
-
const i = [];
|
|
2720
|
-
let o = 0;
|
|
2721
|
-
try {
|
|
2722
|
-
o = this.addCesiumCenters(r, i) + this.addCesiumLineLabels(r, i), n && n !== s && ((u = e == null ? void 0 : e.scene) != null && u.primitives) && e.scene.primitives.remove(n);
|
|
2723
|
-
} catch (g) {
|
|
2724
|
-
throw (f = (d = (h = e == null ? void 0 : e.scene) == null ? void 0 : h.primitives) == null ? void 0 : d.remove) == null || f.call(d, s), this.cesiumLabelCollection = n, g;
|
|
2725
|
-
}
|
|
2726
|
-
return this.emitStateChange(o), (b = (y = e == null ? void 0 : e.scene) == null ? void 0 : y.requestRender) == null || b.call(y), o;
|
|
2727
|
-
}
|
|
2728
|
-
// 重建 Leaflet 全部标签和 marker。
|
|
2729
|
-
updateLeafletLabels() {
|
|
2730
|
-
var a, c, l;
|
|
2731
|
-
const e = (a = this.getData) == null ? void 0 : a.call(this), r = (l = (c = this.mapCore) == null ? void 0 : c.getMapInstance) == null ? void 0 : l.call(c);
|
|
2732
|
-
if (!e || !r || !this.labelLayerGroup)
|
|
2733
|
-
return this.clear(), 0;
|
|
2734
|
-
const n = this.labelLayerGroup, s = O.layerGroup();
|
|
2735
|
-
this.labelLayerGroup = s;
|
|
2736
|
-
const i = [];
|
|
2737
|
-
let o = 0;
|
|
2738
|
-
try {
|
|
2739
|
-
o = this.addLeafletCenters(e, i) + this.addLeafletLineLabels(e, i), s.addTo(r), n == null || n.remove();
|
|
2740
|
-
} catch (u) {
|
|
2741
|
-
throw s.remove(), this.labelLayerGroup = n, u;
|
|
2742
|
-
}
|
|
2743
|
-
return this.emitStateChange(o), o;
|
|
2744
|
-
}
|
|
2745
|
-
}
|
|
2746
|
-
class wr {
|
|
2747
|
-
/**
|
|
2748
|
-
* @param {Object} options 等压线组合图层参数。
|
|
2749
|
-
* @param {Object} options.mapCore 必填,BaseGIS 实例,线图层和标注层都通过它访问当前地图引擎。
|
|
2750
|
-
* @param {String} [options.layerId='pressure-contour'] 图层 id,用于后续更新、显隐和销毁同一组等压线。
|
|
2751
|
-
* @param {Object} [options.data] 初始数据,支持 Windy 原始数据,也支持已整理的 `{ isolines, centers }`。
|
|
2752
|
-
* @param {Object} [options.sourceData] 初始数据别名,作用同 data。
|
|
2753
|
-
* @param {String} [options.color='rgba(255,255,255,0.82)'] 等压线颜色。
|
|
2754
|
-
* @param {Number} [options.weight=1.15] Leaflet 线宽,保留该字段是为了兼容 Leaflet polyline 参数。
|
|
2755
|
-
* @param {Number} [options.width=1.15] Cesium 线宽,Cesium 和 Leaflet 页面可同时传 width / weight。
|
|
2756
|
-
* @param {Number} [options.opacity=1] 等压线透明度。
|
|
2757
|
-
* @param {Number} [options.smoothFactor=0.2] Leaflet 折线简化参数,不是数据平滑;数据平滑由 smoothLine 处理。
|
|
2758
|
-
* @param {String} [options.lineJoin='round'] 线段连接样式,主要给 Leaflet 使用。
|
|
2759
|
-
* @param {String} [options.lineCap='round'] 线段端点样式,主要给 Leaflet 使用。
|
|
2760
|
-
* @param {Number[]} [options.worldCopyOffsets=[-360,0,360]] 世界副本经度偏移,Leaflet 跨日期变更线时使用。
|
|
2761
|
-
* @param {Number} [options.lineThinStep=1] 绘制线时的抽稀步长,Cesium 数据量大时可调大。
|
|
2762
|
-
* @param {String} [options.mapContainerId] 地图容器 id,Cesium 标签碰撞和屏幕范围判断会用到。
|
|
2763
|
-
* @param {Function} [options.isAnnotationVisible] 标注显隐判断函数,返回 false 时不显示线值标签和 H/L 中心点。
|
|
2764
|
-
* @param {Number[]} [options.cesiumWorldCopyOffsets=[0]] Cesium 标注经度偏移,默认不复制世界副本。
|
|
2765
|
-
* @param {Number} [options.cesiumLineThinStep=2] Cesium 线值标签候选点抽稀步长,值越大标签计算越少。
|
|
2766
|
-
* @param {Function} [options.onContourStateChange] 线图层状态变化回调,返回 levelCount / lineCount 等统计。
|
|
2767
|
-
* @param {Function} [options.onAnnotationStateChange] 标注状态变化回调,返回 labelCount。
|
|
2768
|
-
*/
|
|
2769
|
-
constructor(e = {}) {
|
|
2770
|
-
this.mapCore = e.mapCore, this.currentData = le(e.data || e.sourceData || {}), this.contourController = new Re({
|
|
2771
|
-
mapCore: e.mapCore,
|
|
2772
|
-
layerId: e.layerId || "pressure-contour",
|
|
2773
|
-
color: e.color || "rgba(255,255,255,0.82)",
|
|
2774
|
-
weight: e.weight ?? 1.15,
|
|
2775
|
-
width: e.width ?? 1.15,
|
|
2776
|
-
opacity: e.opacity ?? 1,
|
|
2777
|
-
smoothFactor: e.smoothFactor ?? 0.2,
|
|
2778
|
-
lineJoin: e.lineJoin || "round",
|
|
2779
|
-
lineCap: e.lineCap || "round",
|
|
2780
|
-
worldCopyOffsets: e.worldCopyOffsets || [-360, 0, 360],
|
|
2781
|
-
lineThinStep: e.lineThinStep || 1,
|
|
2782
|
-
onStateChange: e.onContourStateChange
|
|
2783
|
-
}), this.annotationLayer = new or({
|
|
2784
|
-
mapCore: e.mapCore,
|
|
2785
|
-
mapContainerId: e.mapContainerId,
|
|
2786
|
-
getData: () => this.currentData,
|
|
2787
|
-
isVisible: e.isAnnotationVisible,
|
|
2788
|
-
worldCopyOffsets: e.worldCopyOffsets || [-360, 0, 360],
|
|
2789
|
-
cesiumWorldCopyOffsets: e.cesiumWorldCopyOffsets || [0],
|
|
2790
|
-
cesiumLineThinStep: e.cesiumLineThinStep || 2,
|
|
2791
|
-
onStateChange: e.onAnnotationStateChange
|
|
2792
|
-
});
|
|
2793
|
-
}
|
|
2794
|
-
mount() {
|
|
2795
|
-
this.annotationLayer.mount();
|
|
2796
|
-
}
|
|
2797
|
-
buildPayload(e, r = {}) {
|
|
2798
|
-
return this.currentData = le(e), {
|
|
2799
|
-
isolines: this.currentData.isolines || [],
|
|
2800
|
-
visible: r.visible !== !1,
|
|
2801
|
-
...r
|
|
2802
|
-
};
|
|
2803
|
-
}
|
|
2804
|
-
async load(e, r = {}) {
|
|
2805
|
-
this.annotationLayer.clear();
|
|
2806
|
-
const n = await this.contourController.load(this.buildPayload(e, r));
|
|
2807
|
-
return n != null && n.success && this.annotationLayer.update(), n;
|
|
2808
|
-
}
|
|
2809
|
-
async update(e, r = {}) {
|
|
2810
|
-
const n = this.buildPayload(e, r), i = !!this.contourController.getState().payload ? await this.contourController.update(n) : await this.contourController.load(n);
|
|
2811
|
-
return i != null && i.success && this.annotationLayer.update(), i;
|
|
2812
|
-
}
|
|
2813
|
-
hide() {
|
|
2814
|
-
const e = this.contourController.hide();
|
|
2815
|
-
return this.annotationLayer.clear(), e;
|
|
2816
|
-
}
|
|
2817
|
-
updateAnnotations() {
|
|
2818
|
-
return this.annotationLayer.update();
|
|
2819
|
-
}
|
|
2820
|
-
scheduleAnnotationUpdate() {
|
|
2821
|
-
this.annotationLayer.scheduleUpdate();
|
|
2822
|
-
}
|
|
2823
|
-
clearAnnotations() {
|
|
2824
|
-
this.annotationLayer.clear();
|
|
2825
|
-
}
|
|
2826
|
-
getState() {
|
|
2827
|
-
return this.contourController.getState();
|
|
2828
|
-
}
|
|
2829
|
-
destroy() {
|
|
2830
|
-
this.annotationLayer.destroy(), this.contourController.destroy();
|
|
2831
|
-
}
|
|
2832
|
-
}
|
|
2833
|
-
const xe = [
|
|
3187
|
+
const Ae = [
|
|
2834
3188
|
{ value: 0, color: [36, 88, 190] },
|
|
2835
3189
|
{ value: 2, color: [36, 145, 184] },
|
|
2836
3190
|
{ value: 5, color: [54, 177, 111] },
|
|
@@ -2838,7 +3192,7 @@ const xe = [
|
|
|
2838
3192
|
{ value: 11, color: [229, 178, 78] },
|
|
2839
3193
|
{ value: 14, color: [224, 103, 117] },
|
|
2840
3194
|
{ value: 18, color: [162, 82, 202] }
|
|
2841
|
-
],
|
|
3195
|
+
], Ee = [
|
|
2842
3196
|
{ value: 0, color: [178, 223, 255] },
|
|
2843
3197
|
{ value: 3, color: [190, 248, 222] },
|
|
2844
3198
|
{ value: 6, color: [235, 252, 174] },
|
|
@@ -2846,10 +3200,10 @@ const xe = [
|
|
|
2846
3200
|
{ value: 14, color: [255, 166, 156] },
|
|
2847
3201
|
{ value: 18, color: [232, 153, 255] }
|
|
2848
3202
|
];
|
|
2849
|
-
function
|
|
3203
|
+
function C(t, e, r) {
|
|
2850
3204
|
return Math.min(Math.max(t, e), r);
|
|
2851
3205
|
}
|
|
2852
|
-
function
|
|
3206
|
+
function vr(t) {
|
|
2853
3207
|
if (Array.isArray(t) && t.length >= 3)
|
|
2854
3208
|
return [Number(t[0]) || 0, Number(t[1]) || 0, Number(t[2]) || 0];
|
|
2855
3209
|
if (typeof t != "string")
|
|
@@ -2867,14 +3221,14 @@ function ar(t) {
|
|
|
2867
3221
|
const n = r[1].split(",").map((s) => Number(s.trim()));
|
|
2868
3222
|
return n.length < 3 || n.slice(0, 3).some((s) => !Number.isFinite(s)) ? null : n.slice(0, 3);
|
|
2869
3223
|
}
|
|
2870
|
-
function
|
|
3224
|
+
function K(t, e) {
|
|
2871
3225
|
const n = (Array.isArray(t) && t.length > 0 ? t : e).map((s, i) => {
|
|
2872
|
-
const o = Number((s == null ? void 0 : s.value) ?? (s == null ? void 0 : s.speed) ?? (s == null ? void 0 : s[0]) ?? i), a =
|
|
3226
|
+
const o = Number((s == null ? void 0 : s.value) ?? (s == null ? void 0 : s.speed) ?? (s == null ? void 0 : s[0]) ?? i), a = vr((s == null ? void 0 : s.color) ?? (s == null ? void 0 : s[1]) ?? s);
|
|
2873
3227
|
return !Number.isFinite(o) || !a ? null : { value: o, color: a };
|
|
2874
3228
|
}).filter(Boolean).sort((s, i) => s.value - i.value);
|
|
2875
3229
|
return n.length > 0 ? n : e;
|
|
2876
3230
|
}
|
|
2877
|
-
function
|
|
3231
|
+
function pr(t, e) {
|
|
2878
3232
|
if (!Array.isArray(t) || t.length === 0)
|
|
2879
3233
|
return [255, 255, 255];
|
|
2880
3234
|
if (e <= t[0].value)
|
|
@@ -2882,19 +3236,19 @@ function lr(t, e) {
|
|
|
2882
3236
|
for (let r = 1; r < t.length; r += 1) {
|
|
2883
3237
|
const n = t[r], s = t[r - 1];
|
|
2884
3238
|
if (e <= n.value) {
|
|
2885
|
-
const i = Math.max(n.value - s.value, 1e-4), o =
|
|
3239
|
+
const i = Math.max(n.value - s.value, 1e-4), o = C((e - s.value) / i, 0, 1);
|
|
2886
3240
|
return s.color.map(
|
|
2887
|
-
(a,
|
|
3241
|
+
(a, u) => Math.round(a + (n.color[u] - a) * o)
|
|
2888
3242
|
);
|
|
2889
3243
|
}
|
|
2890
3244
|
}
|
|
2891
3245
|
return t[t.length - 1].color;
|
|
2892
3246
|
}
|
|
2893
|
-
function
|
|
3247
|
+
function oe(t, e) {
|
|
2894
3248
|
const [r, n, s] = t;
|
|
2895
|
-
return `rgba(${r}, ${n}, ${s}, ${
|
|
3249
|
+
return `rgba(${r}, ${n}, ${s}, ${C(e, 0, 1)})`;
|
|
2896
3250
|
}
|
|
2897
|
-
function
|
|
3251
|
+
function wr(t, e) {
|
|
2898
3252
|
if (!t || typeof t != "object")
|
|
2899
3253
|
return e;
|
|
2900
3254
|
const r = Number(t.west), n = Number(t.south), s = Number(t.east), i = Number(t.north);
|
|
@@ -2905,7 +3259,7 @@ function cr(t, e) {
|
|
|
2905
3259
|
north: Math.max(n, i)
|
|
2906
3260
|
} : e;
|
|
2907
3261
|
}
|
|
2908
|
-
function
|
|
3262
|
+
function Pr(t, e) {
|
|
2909
3263
|
const r = {
|
|
2910
3264
|
west: Math.max(t.west, e.west),
|
|
2911
3265
|
south: Math.max(t.south, e.south),
|
|
@@ -2914,18 +3268,18 @@ function ur(t, e) {
|
|
|
2914
3268
|
};
|
|
2915
3269
|
return r.west >= r.east || r.south >= r.north ? null : r;
|
|
2916
3270
|
}
|
|
2917
|
-
function
|
|
3271
|
+
function ae(t, e, r) {
|
|
2918
3272
|
return t && Number.isFinite(t.x) && Number.isFinite(t.y) && t.x >= -64 && t.x <= e + 64 && t.y >= -64 && t.y <= r + 64;
|
|
2919
3273
|
}
|
|
2920
|
-
function
|
|
3274
|
+
function Cr(t) {
|
|
2921
3275
|
return t && Number.isFinite(t.x) && Number.isFinite(t.y);
|
|
2922
3276
|
}
|
|
2923
|
-
function
|
|
3277
|
+
function Gr(t) {
|
|
2924
3278
|
return String(t || "").toLowerCase();
|
|
2925
3279
|
}
|
|
2926
|
-
class
|
|
3280
|
+
class Mr {
|
|
2927
3281
|
constructor(e = {}) {
|
|
2928
|
-
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
|
|
3282
|
+
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 ee ? e.grid : new ee(e.data), this.options = {
|
|
2929
3283
|
zIndex: Number(e.zIndex ?? 30),
|
|
2930
3284
|
visible: e.visible !== !1,
|
|
2931
3285
|
running: e.running !== !1,
|
|
@@ -2950,9 +3304,9 @@ class fr {
|
|
|
2950
3304
|
projectionGrid: e.projectionGrid !== !1,
|
|
2951
3305
|
projectionGridCols: Number(e.projectionGridCols ?? 32),
|
|
2952
3306
|
projectionGridRows: Number(e.projectionGridRows ?? 20)
|
|
2953
|
-
}, this.colorScale =
|
|
3307
|
+
}, this.colorScale = K(e.colorScale, Ae), this.particleColorScale = K(
|
|
2954
3308
|
e.particleColorScale,
|
|
2955
|
-
|
|
3309
|
+
Ee
|
|
2956
3310
|
), 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();
|
|
2957
3311
|
}
|
|
2958
3312
|
isReady() {
|
|
@@ -2978,7 +3332,7 @@ class fr {
|
|
|
2978
3332
|
resize() {
|
|
2979
3333
|
if (!this.canvas || !this.overlayCanvas || !this.container)
|
|
2980
3334
|
return;
|
|
2981
|
-
const e = this.container.getBoundingClientRect(), r =
|
|
3335
|
+
const e = this.container.getBoundingClientRect(), r = C(this.options.devicePixelRatio || 1, 1, 2), n = Math.max(1, Math.floor(e.width)), s = Math.max(1, Math.floor(e.height));
|
|
2982
3336
|
n === this.width && s === this.height || (this.width = n, this.height = s, [
|
|
2983
3337
|
[this.canvas, this.ctx],
|
|
2984
3338
|
[this.overlayCanvas, this.overlayCtx]
|
|
@@ -2999,10 +3353,10 @@ class fr {
|
|
|
2999
3353
|
this.options = {
|
|
3000
3354
|
...this.options,
|
|
3001
3355
|
...e
|
|
3002
|
-
}, e.colorScale !== void 0 && (this.colorScale =
|
|
3356
|
+
}, e.colorScale !== void 0 && (this.colorScale = K(e.colorScale, Ae), this.overlayDirty = !0), e.particleColorScale !== void 0 && (this.particleColorScale = K(
|
|
3003
3357
|
e.particleColorScale,
|
|
3004
|
-
|
|
3005
|
-
)), 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
|
|
3358
|
+
Ee
|
|
3359
|
+
)), 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 ee(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();
|
|
3006
3360
|
}
|
|
3007
3361
|
refreshSpawnBounds() {
|
|
3008
3362
|
return this.spawnBoundsCache = this.getSpawnBounds(), this.invalidateProjectionGrid(), this.spawnBoundsCache;
|
|
@@ -3011,7 +3365,7 @@ class fr {
|
|
|
3011
3365
|
var r;
|
|
3012
3366
|
if (!this.options.projectionGrid)
|
|
3013
3367
|
return !1;
|
|
3014
|
-
const e =
|
|
3368
|
+
const e = Gr((r = this.getSceneMode) == null ? void 0 : r.call(this));
|
|
3015
3369
|
return e === "2d" || e === "2.5d";
|
|
3016
3370
|
}
|
|
3017
3371
|
invalidateProjectionGrid() {
|
|
@@ -3020,11 +3374,11 @@ class fr {
|
|
|
3020
3374
|
buildProjectionGrid(e = this.spawnBoundsCache) {
|
|
3021
3375
|
if (!this.shouldUseProjectionGrid() || !e)
|
|
3022
3376
|
return this.projectionGrid = null, null;
|
|
3023
|
-
const r =
|
|
3377
|
+
const r = C(Math.floor(this.options.projectionGridCols) || 32, 8, 96), n = C(Math.floor(this.options.projectionGridRows) || 20, 6, 64), s = [];
|
|
3024
3378
|
for (let i = 0; i <= n; i += 1)
|
|
3025
3379
|
for (let o = 0; o <= r; o += 1) {
|
|
3026
|
-
const a = e.west + (e.east - e.west) * (o / r),
|
|
3027
|
-
s.push(this.project(a,
|
|
3380
|
+
const a = e.west + (e.east - e.west) * (o / r), u = e.south + (e.north - e.south) * (i / n);
|
|
3381
|
+
s.push(this.project(a, u, this.options.height));
|
|
3028
3382
|
}
|
|
3029
3383
|
return this.projectionGrid = {
|
|
3030
3384
|
bounds: e,
|
|
@@ -3037,19 +3391,19 @@ class fr {
|
|
|
3037
3391
|
const n = this.projectionGrid || this.buildProjectionGrid(this.spawnBoundsCache);
|
|
3038
3392
|
if (!n || !n.bounds)
|
|
3039
3393
|
return this.project(e, r, this.options.height);
|
|
3040
|
-
const { bounds: s, cols: i, rows: o, nodes: a } = n,
|
|
3041
|
-
if (![
|
|
3394
|
+
const { bounds: s, cols: i, rows: o, nodes: a } = n, u = Math.max(s.east - s.west, 1e-4), l = Math.max(s.north - s.south, 1e-4), c = (e - s.west) / u * i, h = (r - s.south) / l * o, f = C(Math.floor(c), 0, i - 1), d = C(Math.floor(h), 0, o - 1), y = f + 1, m = d + 1, S = C(c - f, 0, 1), g = C(h - d, 0, 1), v = i + 1, b = a[d * v + f], w = a[d * v + y], G = a[m * v + f], E = a[m * v + y];
|
|
3395
|
+
if (![b, w, G, E].every(Cr))
|
|
3042
3396
|
return this.project(e, r, this.options.height);
|
|
3043
|
-
const
|
|
3397
|
+
const T = 1 - S, N = 1 - g;
|
|
3044
3398
|
return {
|
|
3045
|
-
x:
|
|
3046
|
-
y:
|
|
3399
|
+
x: b.x * T * N + w.x * S * N + G.x * T * g + E.x * S * g,
|
|
3400
|
+
y: b.y * T * N + w.y * S * N + G.y * T * g + E.y * S * g
|
|
3047
3401
|
};
|
|
3048
3402
|
}
|
|
3049
3403
|
getSpawnBounds() {
|
|
3050
3404
|
var n;
|
|
3051
|
-
const e = this.grid.getBounds(), r =
|
|
3052
|
-
return
|
|
3405
|
+
const e = this.grid.getBounds(), r = wr((n = this.getViewBounds) == null ? void 0 : n.call(this), e);
|
|
3406
|
+
return Pr(e, r) || e;
|
|
3053
3407
|
}
|
|
3054
3408
|
createParticle(e = this.spawnBoundsCache || this.refreshSpawnBounds()) {
|
|
3055
3409
|
if (!e)
|
|
@@ -3089,7 +3443,7 @@ class fr {
|
|
|
3089
3443
|
if (!this.isReady())
|
|
3090
3444
|
return;
|
|
3091
3445
|
this.clear();
|
|
3092
|
-
const e =
|
|
3446
|
+
const e = C(Math.floor(this.options.particleCount), 1, 8e3), r = this.refreshSpawnBounds();
|
|
3093
3447
|
this.particles = Array.from({ length: e }, () => this.createParticle(r)), this.particleCursor = 0, this.overlayDirty = !0, this.drawVelocityOverlay();
|
|
3094
3448
|
}
|
|
3095
3449
|
getParticleColorIndex(e) {
|
|
@@ -3108,32 +3462,32 @@ class fr {
|
|
|
3108
3462
|
const e = this.spawnBoundsCache || this.refreshSpawnBounds();
|
|
3109
3463
|
if (!e)
|
|
3110
3464
|
return;
|
|
3111
|
-
const r = this.overlayCtx, n =
|
|
3465
|
+
const r = this.overlayCtx, n = C(Number(this.options.velocityOverlayCellSize) || 54, 28, 96), s = C(Math.ceil(this.width / n), 10, 64), i = C(Math.ceil(this.height / n), 8, 48), o = (e.east - e.west) / s, a = (e.north - e.south) / i, u = n * 1.25, l = this.grid.getBounds();
|
|
3112
3466
|
r.save(), r.globalCompositeOperation = "source-over";
|
|
3113
|
-
for (let
|
|
3114
|
-
const h = e.south + (
|
|
3115
|
-
for (let
|
|
3116
|
-
const
|
|
3467
|
+
for (let c = 0; c < i; c += 1) {
|
|
3468
|
+
const h = e.south + (c + 0.5) * a;
|
|
3469
|
+
for (let f = 0; f < s; f += 1) {
|
|
3470
|
+
const d = e.west + (f + 0.5) * o, y = this.grid.sample(d, h);
|
|
3117
3471
|
if (!y || y.speed <= 0)
|
|
3118
3472
|
continue;
|
|
3119
|
-
const
|
|
3120
|
-
if (!
|
|
3473
|
+
const m = this.projectPoint(d, h);
|
|
3474
|
+
if (!ae(m, this.width, this.height))
|
|
3121
3475
|
continue;
|
|
3122
|
-
const
|
|
3123
|
-
if (
|
|
3476
|
+
const S = pr(this.colorScale, y.speed), g = this.getDataEdgeOpacity(d, h, l), v = this.options.velocityOverlayOpacity * g;
|
|
3477
|
+
if (v <= 0.01)
|
|
3124
3478
|
continue;
|
|
3125
|
-
const
|
|
3126
|
-
|
|
3479
|
+
const b = r.createRadialGradient(m.x, m.y, 0, m.x, m.y, u);
|
|
3480
|
+
b.addColorStop(0, oe(S, v)), b.addColorStop(1, oe(S, 0)), r.fillStyle = b, r.fillRect(m.x - u, m.y - u, u * 2, u * 2);
|
|
3127
3481
|
}
|
|
3128
3482
|
}
|
|
3129
3483
|
r.restore();
|
|
3130
3484
|
}
|
|
3131
3485
|
getDataEdgeOpacity(e, r, n) {
|
|
3132
|
-
const s =
|
|
3486
|
+
const s = C(this.options.velocityOverlayEdgeFade, 0, 0.35);
|
|
3133
3487
|
if (s <= 0 || !n)
|
|
3134
3488
|
return 1;
|
|
3135
3489
|
const i = (e - n.west) / Math.max(n.east - n.west, 1e-4), o = (r - n.south) / Math.max(n.north - n.south, 1e-4), a = Math.min(i, 1 - i, o, 1 - o);
|
|
3136
|
-
return
|
|
3490
|
+
return C(a / s, 0, 1);
|
|
3137
3491
|
}
|
|
3138
3492
|
start() {
|
|
3139
3493
|
this.destroyed || (this.options.running = !0, this.interactionSuspended = !1, this.animationFrame || (this.lastFrameTime = performance.now(), this.animationFrame = requestAnimationFrame((e) => this.animate(e))));
|
|
@@ -3163,35 +3517,35 @@ class fr {
|
|
|
3163
3517
|
}
|
|
3164
3518
|
stepParticle(e, r) {
|
|
3165
3519
|
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);
|
|
3166
|
-
if (!n || n.speed <= 0 || !
|
|
3520
|
+
if (!n || n.speed <= 0 || !ae(s, this.width, this.height))
|
|
3167
3521
|
return Object.assign(e, this.createParticle()), null;
|
|
3168
|
-
const i = e.lat * Math.PI / 180, o = Math.max(Math.cos(i) * 111320, 1e3), a = 111320,
|
|
3169
|
-
return !h || !
|
|
3522
|
+
const i = e.lat * Math.PI / 180, o = Math.max(Math.cos(i) * 111320, 1e3), a = 111320, u = this.options.velocityScale * r, l = e.lon + n.u * u / o, c = e.lat + n.v * u / a, h = this.grid.sample(l, c), f = this.projectPoint(l, c);
|
|
3523
|
+
return !h || !ae(f, this.width, this.height) ? (Object.assign(e, this.createParticle()), null) : (e.lon = l, e.lat = c, e.screenX = f.x, e.screenY = f.y, e.age += 1, e.age > e.maxAge && Object.assign(e, this.createParticle()), { from: s, to: f, speed: h.speed });
|
|
3170
3524
|
}
|
|
3171
3525
|
getFrameParticleCount(e) {
|
|
3172
3526
|
var i;
|
|
3173
|
-
const r =
|
|
3527
|
+
const r = C(
|
|
3174
3528
|
Math.floor(this.options.maxFrameParticles || e),
|
|
3175
3529
|
1,
|
|
3176
3530
|
e
|
|
3177
3531
|
), n = Math.floor(this.options.sceneModeMaxFrameParticles || 0), s = String(((i = this.getSceneMode) == null ? void 0 : i.call(this)) || "").toLowerCase();
|
|
3178
|
-
return (s === "2d" || s === "2.5d") && n > 0 ?
|
|
3532
|
+
return (s === "2d" || s === "2.5d") && n > 0 ? C(n, 1, r) : r;
|
|
3179
3533
|
}
|
|
3180
3534
|
drawFrame(e) {
|
|
3181
3535
|
if (!this.ctx || this.width <= 0 || this.height <= 0)
|
|
3182
3536
|
return;
|
|
3183
3537
|
const r = this.ctx;
|
|
3184
|
-
r.globalCompositeOperation = "destination-in", r.fillStyle = `rgba(0, 0, 0, ${
|
|
3538
|
+
r.globalCompositeOperation = "destination-in", r.fillStyle = `rgba(0, 0, 0, ${C(this.options.fadeOpacity, 0.75, 0.98)})`, r.fillRect(0, 0, this.width, this.height), r.globalCompositeOperation = this.options.blendMode, r.lineCap = "round", r.lineJoin = "round";
|
|
3185
3539
|
const n = this.particleColorScale.map(() => []), s = this.particles.length, i = this.getFrameParticleCount(s);
|
|
3186
3540
|
for (let o = 0; o < i; o += 1) {
|
|
3187
|
-
const a = (this.particleCursor + o) % s,
|
|
3188
|
-
|
|
3541
|
+
const a = (this.particleCursor + o) % s, u = this.stepParticle(this.particles[a], e);
|
|
3542
|
+
u && n[this.getParticleColorIndex(u.speed)].push(u);
|
|
3189
3543
|
}
|
|
3190
3544
|
this.particleCursor = (this.particleCursor + i) % s, n.forEach((o, a) => {
|
|
3191
3545
|
if (o.length === 0)
|
|
3192
3546
|
return;
|
|
3193
|
-
const
|
|
3194
|
-
r.lineWidth = this.options.lineWidth * (0.72 +
|
|
3547
|
+
const u = this.particleColorScale.length <= 1 ? 0 : a / (this.particleColorScale.length - 1);
|
|
3548
|
+
r.lineWidth = this.options.lineWidth * (0.72 + u * 0.56), r.strokeStyle = this.particleColorScale[a] ? oe(this.particleColorScale[a].color, this.options.particleOpacity) : this.options.color, r.beginPath(), o.forEach((l) => {
|
|
3195
3549
|
r.moveTo(l.from.x, l.from.y), r.lineTo(l.to.x, l.to.y);
|
|
3196
3550
|
}), r.stroke();
|
|
3197
3551
|
});
|
|
@@ -3199,9 +3553,9 @@ class fr {
|
|
|
3199
3553
|
animate(e) {
|
|
3200
3554
|
if (this.animationFrame = null, !(this.destroyed || !this.options.running || this.interactionSuspended)) {
|
|
3201
3555
|
if (this.options.visible && this.isReady()) {
|
|
3202
|
-
const r = 1e3 /
|
|
3556
|
+
const r = 1e3 / C(this.options.frameRate, 1, 60), n = e - this.lastFrameTime;
|
|
3203
3557
|
if (n >= r) {
|
|
3204
|
-
const s =
|
|
3558
|
+
const s = C(n / 16.67, 0.5, 2.5);
|
|
3205
3559
|
this.lastFrameTime = e, this.drawFrame(s);
|
|
3206
3560
|
}
|
|
3207
3561
|
}
|
|
@@ -3224,10 +3578,10 @@ class fr {
|
|
|
3224
3578
|
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), (r = this.overlayCanvas) != null && r.parentNode && this.overlayCanvas.parentNode.removeChild(this.overlayCanvas), this.clear(), this.canvas = null, this.ctx = null, this.overlayCanvas = null, this.overlayCtx = null, this.particles = [];
|
|
3225
3579
|
}
|
|
3226
3580
|
}
|
|
3227
|
-
function
|
|
3581
|
+
function z(t = {}) {
|
|
3228
3582
|
return typeof t == "string" ? t || "wind-field-default" : (t == null ? void 0 : t.id) || (t == null ? void 0 : t.layerId) || "wind-field-default";
|
|
3229
3583
|
}
|
|
3230
|
-
function
|
|
3584
|
+
function Re(t = {}) {
|
|
3231
3585
|
const {
|
|
3232
3586
|
id: e,
|
|
3233
3587
|
layerId: r,
|
|
@@ -3236,7 +3590,7 @@ function Ae(t = {}) {
|
|
|
3236
3590
|
options: i,
|
|
3237
3591
|
container: o,
|
|
3238
3592
|
project: a,
|
|
3239
|
-
getViewBounds:
|
|
3593
|
+
getViewBounds: u,
|
|
3240
3594
|
...l
|
|
3241
3595
|
} = t || {};
|
|
3242
3596
|
return {
|
|
@@ -3244,18 +3598,18 @@ function Ae(t = {}) {
|
|
|
3244
3598
|
...i || {}
|
|
3245
3599
|
};
|
|
3246
3600
|
}
|
|
3247
|
-
function
|
|
3601
|
+
function Fe(t) {
|
|
3248
3602
|
return !!(t && typeof t.getMapInstance == "function" && typeof t.getMapContainer == "function" && typeof t.projectToContainerPoint == "function" && typeof t.getViewBounds == "function" && typeof t.onViewChange == "function");
|
|
3249
3603
|
}
|
|
3250
|
-
class
|
|
3604
|
+
class _r {
|
|
3251
3605
|
constructor(e = {}) {
|
|
3252
3606
|
this.baseGIS = null, this.layers = /* @__PURE__ */ new Map();
|
|
3253
|
-
const r = (e == null ? void 0 : e.mapCore) || (e == null ? void 0 : e.baseGIS) || (
|
|
3607
|
+
const r = (e == null ? void 0 : e.mapCore) || (e == null ? void 0 : e.baseGIS) || (Fe(e) ? e : null);
|
|
3254
3608
|
r && this.mount(r);
|
|
3255
3609
|
}
|
|
3256
3610
|
mount(e) {
|
|
3257
3611
|
var r, n;
|
|
3258
|
-
return
|
|
3612
|
+
return Fe(e) ? (this.baseGIS = e, L(
|
|
3259
3613
|
{ engineType: ((n = (r = this.baseGIS).getEngineType) == null ? void 0 : n.call(r)) || "unknown" },
|
|
3260
3614
|
"WindFieldMethods mounted with BaseGIS."
|
|
3261
3615
|
)) : I("WindFieldMethods mount requires BaseGIS instance.", "INVALID_MOUNT_TARGET");
|
|
@@ -3264,47 +3618,47 @@ class Pr {
|
|
|
3264
3618
|
var e, r;
|
|
3265
3619
|
return this.baseGIS ? (r = (e = this.baseGIS).getMapInstance) != null && r.call(e) ? L(null, "BaseGIS is ready.") : I(
|
|
3266
3620
|
"Map instance is not ready. Please call mapCore.init() first.",
|
|
3267
|
-
|
|
3621
|
+
F.NOT_INITIALIZED
|
|
3268
3622
|
) : I("WindFieldMethods has not been mounted.", "NOT_MOUNTED");
|
|
3269
3623
|
}
|
|
3270
3624
|
addWindField(e = {}) {
|
|
3271
|
-
var
|
|
3625
|
+
var u, l;
|
|
3272
3626
|
const r = this.resolveBaseGIS();
|
|
3273
3627
|
if (!r.success)
|
|
3274
3628
|
return r;
|
|
3275
3629
|
const n = (e == null ? void 0 : e.data) || (e == null ? void 0 : e.windData);
|
|
3276
3630
|
if (!n)
|
|
3277
|
-
return I("Wind field data is required.",
|
|
3631
|
+
return I("Wind field data is required.", F.FAILED);
|
|
3278
3632
|
const s = this.baseGIS.getMapContainer();
|
|
3279
|
-
if (!(s != null && s.success) || !((
|
|
3280
|
-
return (s == null ? void 0 : s.success) === !1 ? s : I("Map container is not available.",
|
|
3281
|
-
const i =
|
|
3633
|
+
if (!(s != null && s.success) || !((u = s.data) != null && u.container))
|
|
3634
|
+
return (s == null ? void 0 : s.success) === !1 ? s : I("Map container is not available.", F.NOT_INITIALIZED);
|
|
3635
|
+
const i = z(e);
|
|
3282
3636
|
this.removeWindField(i);
|
|
3283
|
-
const o = new
|
|
3637
|
+
const o = new Mr({
|
|
3284
3638
|
id: i,
|
|
3285
3639
|
data: n,
|
|
3286
3640
|
container: s.data.container,
|
|
3287
|
-
...
|
|
3288
|
-
project: (
|
|
3289
|
-
const
|
|
3290
|
-
longitude:
|
|
3641
|
+
...Re(e),
|
|
3642
|
+
project: (c, h, f = 0) => {
|
|
3643
|
+
const d = this.baseGIS.projectToContainerPoint({
|
|
3644
|
+
longitude: c,
|
|
3291
3645
|
latitude: h,
|
|
3292
|
-
height:
|
|
3646
|
+
height: f
|
|
3293
3647
|
});
|
|
3294
|
-
return
|
|
3648
|
+
return d != null && d.success ? d.data : null;
|
|
3295
3649
|
},
|
|
3296
3650
|
getViewBounds: () => {
|
|
3297
|
-
const
|
|
3298
|
-
return
|
|
3651
|
+
const c = this.baseGIS.getViewBounds();
|
|
3652
|
+
return c != null && c.success ? c.data : null;
|
|
3299
3653
|
},
|
|
3300
3654
|
getSceneMode: () => {
|
|
3301
|
-
var h,
|
|
3302
|
-
const
|
|
3303
|
-
return
|
|
3655
|
+
var h, f, d;
|
|
3656
|
+
const c = (f = (h = this.baseGIS).getSceneMode) == null ? void 0 : f.call(h);
|
|
3657
|
+
return c != null && c.success ? (d = c.data) == null ? void 0 : d.mode : "";
|
|
3304
3658
|
}
|
|
3305
3659
|
});
|
|
3306
3660
|
if (!o.grid.valid)
|
|
3307
|
-
return o.destroy(), I(o.grid.errorMessage || "Invalid wind field data.",
|
|
3661
|
+
return o.destroy(), I(o.grid.errorMessage || "Invalid wind field data.", F.FAILED);
|
|
3308
3662
|
const a = this.baseGIS.onViewChange({
|
|
3309
3663
|
onStart: () => o.suspendForInteraction(),
|
|
3310
3664
|
onEnd: () => o.resumeAfterInteraction()
|
|
@@ -3318,31 +3672,31 @@ class Pr {
|
|
|
3318
3672
|
const r = this.resolveBaseGIS();
|
|
3319
3673
|
if (!r.success)
|
|
3320
3674
|
return r;
|
|
3321
|
-
const n =
|
|
3675
|
+
const n = z(e), s = this.layers.get(n);
|
|
3322
3676
|
if (!s)
|
|
3323
|
-
return I(`Wind field "${n}" not found.`,
|
|
3324
|
-
const i =
|
|
3677
|
+
return I(`Wind field "${n}" not found.`, F.FAILED);
|
|
3678
|
+
const i = Re(e), o = (e == null ? void 0 : e.data) || (e == null ? void 0 : e.windData);
|
|
3325
3679
|
return o && (i.data = o), s.layer.updateOptions(i), L(s.layer.getState(), `Wind field "${n}" updated.`);
|
|
3326
3680
|
}
|
|
3327
3681
|
startWindField(e = {}) {
|
|
3328
|
-
const r =
|
|
3329
|
-
return n ? (n.layer.start(), L(n.layer.getState(), `Wind field "${r}" started.`)) : I(`Wind field "${r}" not found.`,
|
|
3682
|
+
const r = z(e), n = this.layers.get(r);
|
|
3683
|
+
return n ? (n.layer.start(), L(n.layer.getState(), `Wind field "${r}" started.`)) : I(`Wind field "${r}" not found.`, F.FAILED);
|
|
3330
3684
|
}
|
|
3331
3685
|
stopWindField(e = {}) {
|
|
3332
|
-
const r =
|
|
3333
|
-
return n ? (n.layer.stop(), L(n.layer.getState(), `Wind field "${r}" stopped.`)) : I(`Wind field "${r}" not found.`,
|
|
3686
|
+
const r = z(e), n = this.layers.get(r);
|
|
3687
|
+
return n ? (n.layer.stop(), L(n.layer.getState(), `Wind field "${r}" stopped.`)) : I(`Wind field "${r}" not found.`, F.FAILED);
|
|
3334
3688
|
}
|
|
3335
3689
|
showWindField(e = {}) {
|
|
3336
|
-
const r =
|
|
3337
|
-
return n ? (n.layer.show(), L(n.layer.getState(), `Wind field "${r}" shown.`)) : I(`Wind field "${r}" not found.`,
|
|
3690
|
+
const r = z(e), n = this.layers.get(r);
|
|
3691
|
+
return n ? (n.layer.show(), L(n.layer.getState(), `Wind field "${r}" shown.`)) : I(`Wind field "${r}" not found.`, F.FAILED);
|
|
3338
3692
|
}
|
|
3339
3693
|
hideWindField(e = {}) {
|
|
3340
|
-
const r =
|
|
3341
|
-
return n ? (n.layer.hide(), L(n.layer.getState(), `Wind field "${r}" hidden.`)) : I(`Wind field "${r}" not found.`,
|
|
3694
|
+
const r = z(e), n = this.layers.get(r);
|
|
3695
|
+
return n ? (n.layer.hide(), L(n.layer.getState(), `Wind field "${r}" hidden.`)) : I(`Wind field "${r}" not found.`, F.FAILED);
|
|
3342
3696
|
}
|
|
3343
3697
|
removeWindField(e = {}) {
|
|
3344
3698
|
var s;
|
|
3345
|
-
const r =
|
|
3699
|
+
const r = z(e), n = this.layers.get(r);
|
|
3346
3700
|
return n ? ((s = n.offViewChange) == null || s.call(n), n.layer.destroy(), this.layers.delete(r), L({ layerId: r, removed: !0 }, `Wind field "${r}" removed.`)) : L({ layerId: r, removed: !1 }, `Wind field "${r}" not found.`);
|
|
3347
3701
|
}
|
|
3348
3702
|
clearWindFields() {
|
|
@@ -3361,16 +3715,15 @@ class Pr {
|
|
|
3361
3715
|
}
|
|
3362
3716
|
}
|
|
3363
3717
|
export {
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
vr as createPressureDataResolver,
|
|
3718
|
+
Ye as ContourLayerController,
|
|
3719
|
+
xr as GraphicGroupController,
|
|
3720
|
+
Ar as GridLayerController,
|
|
3721
|
+
Er as ImageLayerController,
|
|
3722
|
+
Rr as LineLayerController,
|
|
3723
|
+
Fr as PointClusterController,
|
|
3724
|
+
Br as PointDensityController,
|
|
3725
|
+
Dr as PointLargeLayerController,
|
|
3726
|
+
Or as RasterContourController,
|
|
3727
|
+
_r as WindFieldMethods,
|
|
3375
3728
|
j as toImageLayerArea
|
|
3376
3729
|
};
|