@3clear/basegis 0.1.2 → 0.1.3
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 +368 -58
- package/dist/WindDataGrid-AGJaASUG.js +96 -0
- package/dist/basegis.js +5124 -2890
- package/dist/methods.js +500 -541
- package/package.json +1 -1
- package/dist/result-D03zgqh0.js +0 -39
package/dist/methods.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { f as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { f as I, s as L, W as X, R } from "./WindDataGrid-AGJaASUG.js";
|
|
2
|
+
import Ue from "axios";
|
|
3
|
+
import O from "leaflet";
|
|
4
4
|
function je(t) {
|
|
5
5
|
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
6
|
}
|
|
@@ -9,17 +9,17 @@ class Ir {
|
|
|
9
9
|
this.baseGIS = null, this.items = [], this.loadedCount = 0, (e.mapCore || e.baseGIS) && this.mount(e.mapCore || e.baseGIS);
|
|
10
10
|
}
|
|
11
11
|
mount(e) {
|
|
12
|
-
return je(e) ? (this.baseGIS = e,
|
|
12
|
+
return je(e) ? (this.baseGIS = e, L(null, "GraphicGroupController mounted with BaseGIS.")) : I(
|
|
13
13
|
"GraphicGroupController mount requires BaseGIS instance.",
|
|
14
14
|
"INVALID_MOUNT_TARGET"
|
|
15
15
|
);
|
|
16
16
|
}
|
|
17
17
|
resolveBaseGIS() {
|
|
18
18
|
var e, r;
|
|
19
|
-
return this.baseGIS ? (r = (e = this.baseGIS).getMapInstance) != null && r.call(e) ?
|
|
19
|
+
return this.baseGIS ? (r = (e = this.baseGIS).getMapInstance) != null && r.call(e) ? L(null, "BaseGIS is ready.") : I(
|
|
20
20
|
"Map instance is not ready. Please call mapCore.init() first.",
|
|
21
21
|
"NOT_INITIALIZED"
|
|
22
|
-
) :
|
|
22
|
+
) : I("GraphicGroupController has not been mounted.", "NOT_MOUNTED");
|
|
23
23
|
}
|
|
24
24
|
drawItem(e = {}) {
|
|
25
25
|
switch (e.type) {
|
|
@@ -34,7 +34,7 @@ class Ir {
|
|
|
34
34
|
case "marker":
|
|
35
35
|
return this.baseGIS.addMarker(e);
|
|
36
36
|
default:
|
|
37
|
-
return
|
|
37
|
+
return I(`Unsupported graphic type "${e.type}".`, "INVALID_GRAPHIC_TYPE");
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
load(e = [], r = {}) {
|
|
@@ -42,7 +42,7 @@ class Ir {
|
|
|
42
42
|
if (!n.success)
|
|
43
43
|
return n;
|
|
44
44
|
if (!Array.isArray(e) || e.length === 0)
|
|
45
|
-
return
|
|
45
|
+
return I("Graphic item list is empty.", "INVALID_ITEMS");
|
|
46
46
|
r.clearBeforeLoad !== !1 && this.baseGIS.clearGraphics(), this.items = e, this.loadedCount = 0;
|
|
47
47
|
const s = e.map((i) => {
|
|
48
48
|
const o = this.drawItem(i);
|
|
@@ -53,7 +53,7 @@ class Ir {
|
|
|
53
53
|
message: (o == null ? void 0 : o.message) || ""
|
|
54
54
|
};
|
|
55
55
|
});
|
|
56
|
-
return
|
|
56
|
+
return L(
|
|
57
57
|
{
|
|
58
58
|
total: e.length,
|
|
59
59
|
loadedCount: this.loadedCount,
|
|
@@ -87,16 +87,16 @@ function he(t = {}) {
|
|
|
87
87
|
(r) => Object.prototype.hasOwnProperty.call(e, r)
|
|
88
88
|
);
|
|
89
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function ze(t) {
|
|
91
91
|
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
92
|
}
|
|
93
|
-
function
|
|
93
|
+
function Ve(t = {}) {
|
|
94
94
|
const { mapCore: e, baseGIS: r, ...n } = t;
|
|
95
95
|
return n;
|
|
96
96
|
}
|
|
97
97
|
class Re {
|
|
98
98
|
constructor(e = {}) {
|
|
99
|
-
const r =
|
|
99
|
+
const r = Ve(e), n = r.contourLayerId || r.layerId || r.id || "contour-default";
|
|
100
100
|
this.options = {
|
|
101
101
|
layerId: n,
|
|
102
102
|
visible: r.visible ?? !0
|
|
@@ -116,20 +116,20 @@ class Re {
|
|
|
116
116
|
}
|
|
117
117
|
mount(e) {
|
|
118
118
|
var r, n;
|
|
119
|
-
return
|
|
119
|
+
return ze(e) ? (this.baseGIS = e, L(
|
|
120
120
|
{ engineType: ((n = (r = this.baseGIS).getEngineType) == null ? void 0 : n.call(r)) || "unknown" },
|
|
121
121
|
"ContourLayerController mounted with BaseGIS."
|
|
122
|
-
)) :
|
|
122
|
+
)) : I(
|
|
123
123
|
"ContourLayerController mount requires BaseGIS instance.",
|
|
124
124
|
"INVALID_MOUNT_TARGET"
|
|
125
125
|
);
|
|
126
126
|
}
|
|
127
127
|
resolveBaseGIS() {
|
|
128
128
|
var e, r;
|
|
129
|
-
return this.baseGIS ? (r = (e = this.baseGIS).getMapInstance) != null && r.call(e) ?
|
|
129
|
+
return this.baseGIS ? (r = (e = this.baseGIS).getMapInstance) != null && r.call(e) ? L(null, "BaseGIS is ready.") : I(
|
|
130
130
|
"Map instance is not ready. Please call mapCore.init() first.",
|
|
131
131
|
"NOT_INITIALIZED"
|
|
132
|
-
) :
|
|
132
|
+
) : I("ContourLayerController has not been mounted.", "NOT_MOUNTED");
|
|
133
133
|
}
|
|
134
134
|
getLayerId(e = {}) {
|
|
135
135
|
var r;
|
|
@@ -162,7 +162,7 @@ class Re {
|
|
|
162
162
|
...W(r)
|
|
163
163
|
});
|
|
164
164
|
if (!he(s))
|
|
165
|
-
return
|
|
165
|
+
return I(
|
|
166
166
|
"Contour layer requires contours, isolines, lines, data or items.",
|
|
167
167
|
"INVALID_CONTOUR_SOURCE"
|
|
168
168
|
);
|
|
@@ -182,7 +182,7 @@ class Re {
|
|
|
182
182
|
...W(e)
|
|
183
183
|
};
|
|
184
184
|
if (!this.currentPayload && !he(n))
|
|
185
|
-
return
|
|
185
|
+
return I("Contour layer has not been loaded.", "NOT_LOADED");
|
|
186
186
|
const s = await this.baseGIS.updateContourLayer(n);
|
|
187
187
|
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;
|
|
188
188
|
}
|
|
@@ -248,7 +248,7 @@ class Re {
|
|
|
248
248
|
labelCount: 0,
|
|
249
249
|
visible: !1,
|
|
250
250
|
destroyed: !0
|
|
251
|
-
},
|
|
251
|
+
}, L(null, "Contour layer controller destroyed (local state only).");
|
|
252
252
|
const n = this.baseGIS.removeContourLayer({
|
|
253
253
|
...e,
|
|
254
254
|
layerId: this.getLayerId(e)
|
|
@@ -261,7 +261,7 @@ class Re {
|
|
|
261
261
|
labelCount: 0,
|
|
262
262
|
visible: !1,
|
|
263
263
|
destroyed: !0
|
|
264
|
-
}, n.success ?
|
|
264
|
+
}, n.success ? L(null, "Contour layer controller destroyed.") : n;
|
|
265
265
|
}
|
|
266
266
|
removeLayer(e = {}) {
|
|
267
267
|
return this.destroy(e);
|
|
@@ -269,10 +269,10 @@ class Re {
|
|
|
269
269
|
getState() {
|
|
270
270
|
var e, r, n, s, i, o, a;
|
|
271
271
|
if ((r = (e = this.baseGIS) == null ? void 0 : e.getMapInstance) != null && r.call(e) && this.currentPayload) {
|
|
272
|
-
const
|
|
272
|
+
const c = (s = (n = this.baseGIS).getContourLayerState) == null ? void 0 : s.call(n, {
|
|
273
273
|
layerId: this.currentPayload.layerId || this.options.layerId
|
|
274
274
|
});
|
|
275
|
-
|
|
275
|
+
c != null && c.success && this.syncStateFromResult(c);
|
|
276
276
|
}
|
|
277
277
|
return {
|
|
278
278
|
mounted: !!this.baseGIS,
|
|
@@ -325,20 +325,20 @@ class br {
|
|
|
325
325
|
}
|
|
326
326
|
mount(e) {
|
|
327
327
|
var r, n;
|
|
328
|
-
return _e(e) ? (this.baseGIS = e,
|
|
328
|
+
return _e(e) ? (this.baseGIS = e, L(
|
|
329
329
|
{ engineType: ((n = (r = this.baseGIS).getEngineType) == null ? void 0 : n.call(r)) || "unknown" },
|
|
330
330
|
"GridLayerController mounted with BaseGIS."
|
|
331
|
-
)) :
|
|
331
|
+
)) : I(
|
|
332
332
|
"GridLayerController mount requires BaseGIS instance.",
|
|
333
333
|
"INVALID_MOUNT_TARGET"
|
|
334
334
|
);
|
|
335
335
|
}
|
|
336
336
|
resolveBaseGIS() {
|
|
337
337
|
var e, r;
|
|
338
|
-
return this.baseGIS ? (r = (e = this.baseGIS).getMapInstance) != null && r.call(e) ?
|
|
338
|
+
return this.baseGIS ? (r = (e = this.baseGIS).getMapInstance) != null && r.call(e) ? L(null, "BaseGIS is ready.") : I(
|
|
339
339
|
"Map instance is not ready. Please call mapCore.init() first.",
|
|
340
340
|
"NOT_INITIALIZED"
|
|
341
|
-
) :
|
|
341
|
+
) : I("GridLayerController has not been mounted.", "NOT_MOUNTED");
|
|
342
342
|
}
|
|
343
343
|
getLayerId(e = {}) {
|
|
344
344
|
var r;
|
|
@@ -365,7 +365,7 @@ class br {
|
|
|
365
365
|
if (!r.success)
|
|
366
366
|
return r;
|
|
367
367
|
if (!We(e))
|
|
368
|
-
return
|
|
368
|
+
return I(
|
|
369
369
|
"Grid layer requires tifUrl, imageUrl, grayImageUrl or imageGridData.",
|
|
370
370
|
"INVALID_GRID_SOURCE"
|
|
371
371
|
);
|
|
@@ -396,7 +396,7 @@ class br {
|
|
|
396
396
|
...this.currentPayload,
|
|
397
397
|
...e,
|
|
398
398
|
layerId: e.layerId || e.gridLayerId || this.currentPayload.layerId
|
|
399
|
-
}) :
|
|
399
|
+
}) : I("Grid layer has not been loaded.", "NOT_LOADED");
|
|
400
400
|
}
|
|
401
401
|
show(e = {}) {
|
|
402
402
|
const r = this.resolveBaseGIS();
|
|
@@ -418,11 +418,11 @@ class br {
|
|
|
418
418
|
}
|
|
419
419
|
destroy(e = {}) {
|
|
420
420
|
if (!this.resolveBaseGIS().success)
|
|
421
|
-
return this.currentPayload = null, this.layerType = "unknown",
|
|
421
|
+
return this.currentPayload = null, this.layerType = "unknown", L(null, "Grid layer controller destroyed (local state only).");
|
|
422
422
|
const n = this.baseGIS.removeGridLayer({
|
|
423
423
|
layerId: this.getLayerId(e)
|
|
424
424
|
});
|
|
425
|
-
return this.currentPayload = null, this.layerType = "unknown", n.success ?
|
|
425
|
+
return this.currentPayload = null, this.layerType = "unknown", n.success ? L(null, "Grid layer controller destroyed.") : n;
|
|
426
426
|
}
|
|
427
427
|
getState() {
|
|
428
428
|
var e, r, n;
|
|
@@ -436,10 +436,10 @@ class br {
|
|
|
436
436
|
};
|
|
437
437
|
}
|
|
438
438
|
}
|
|
439
|
-
const
|
|
439
|
+
const U = /* @__PURE__ */ new Map(), $e = {
|
|
440
440
|
maxSize: 12
|
|
441
441
|
};
|
|
442
|
-
function
|
|
442
|
+
function x(t, e = 0) {
|
|
443
443
|
const r = Number(t);
|
|
444
444
|
return Number.isFinite(r) ? r : e;
|
|
445
445
|
}
|
|
@@ -525,7 +525,7 @@ function q(t, e = {
|
|
|
525
525
|
startLat: 18,
|
|
526
526
|
endLon: 135,
|
|
527
527
|
endLat: 54
|
|
528
|
-
}, n = j(t) || r, s =
|
|
528
|
+
}, n = j(t) || r, s = x(n.startLon, r.startLon), i = x(n.startLat, r.startLat), o = x(n.endLon, r.endLon), a = x(n.endLat, r.endLat);
|
|
529
529
|
return {
|
|
530
530
|
startLon: Math.min(s, o),
|
|
531
531
|
startLat: Math.min(i, a),
|
|
@@ -542,7 +542,7 @@ function qe(t) {
|
|
|
542
542
|
function Y(t, e = "EPSG:4326") {
|
|
543
543
|
return `${t || e}`.toUpperCase();
|
|
544
544
|
}
|
|
545
|
-
function
|
|
545
|
+
function ce(t) {
|
|
546
546
|
const e = j(t);
|
|
547
547
|
return e ? [e.startLon, e.startLat, e.endLon, e.endLat].every((r) => Math.abs(Number(r)) <= 180) : !1;
|
|
548
548
|
}
|
|
@@ -568,7 +568,7 @@ function He(t) {
|
|
|
568
568
|
function se(t) {
|
|
569
569
|
const e = j(t);
|
|
570
570
|
if (!e) return null;
|
|
571
|
-
if (
|
|
571
|
+
if (ce(e)) return e;
|
|
572
572
|
const r = ye(e.startLon, e.startLat), n = ye(e.endLon, e.endLat);
|
|
573
573
|
return {
|
|
574
574
|
startLon: r.lng,
|
|
@@ -596,44 +596,44 @@ function Ke(t, e, r) {
|
|
|
596
596
|
}
|
|
597
597
|
function Xe(t, e) {
|
|
598
598
|
if (!(!t || !e))
|
|
599
|
-
for (
|
|
600
|
-
const r =
|
|
601
|
-
|
|
599
|
+
for (U.has(t) && U.delete(t), U.set(t, e); U.size > $e.maxSize; ) {
|
|
600
|
+
const r = U.keys().next().value;
|
|
601
|
+
U.delete(r);
|
|
602
602
|
}
|
|
603
603
|
}
|
|
604
604
|
async function Ze(t, e) {
|
|
605
605
|
const r = j(e), n = se(r);
|
|
606
|
-
if (!ke() || !r || !n ||
|
|
606
|
+
if (!ke() || !r || !n || ce(r))
|
|
607
607
|
return t;
|
|
608
608
|
const s = await Ye(t), i = s.naturalWidth || s.width, o = s.naturalHeight || s.height, a = document.createElement("canvas");
|
|
609
609
|
a.width = i, a.height = o;
|
|
610
|
-
const
|
|
611
|
-
|
|
612
|
-
const
|
|
613
|
-
|
|
614
|
-
const
|
|
610
|
+
const c = a.getContext("2d", { willReadFrequently: !0 });
|
|
611
|
+
c.drawImage(s, 0, 0, i, o);
|
|
612
|
+
const l = c.getImageData(0, 0, i, o), u = document.createElement("canvas");
|
|
613
|
+
u.width = i, u.height = o;
|
|
614
|
+
const h = u.getContext("2d", { willReadFrequently: !0 }), d = h.createImageData(i, o), f = l.data, y = d.data, b = Math.min(Number(r.startLat), Number(r.endLat)), g = Math.max(Number(r.startLat), Number(r.endLat)), p = g - b;
|
|
615
615
|
if (!Number.isFinite(p) || p === 0)
|
|
616
616
|
return t;
|
|
617
617
|
for (let m = 0; m < o; m += 1) {
|
|
618
|
-
const v = n.endLat - (n.endLat - n.startLat) * m / Math.max(o - 1, 1),
|
|
619
|
-
y.set(f.subarray(
|
|
618
|
+
const v = n.endLat - (n.endLat - n.startLat) * m / Math.max(o - 1, 1), S = ne(v, 0), P = Math.round((g - S.y) / p * (o - 1)), M = Math.min(Math.max(P, 0), o - 1) * i * 4, T = m * i * 4;
|
|
619
|
+
y.set(f.subarray(M, M + i * 4), T);
|
|
620
620
|
}
|
|
621
|
-
return
|
|
621
|
+
return h.putImageData(d, 0, 0), u.toDataURL("image/png");
|
|
622
622
|
}
|
|
623
623
|
async function ge(t) {
|
|
624
624
|
const e = Y(t == null ? void 0 : t.sourceProjection, ""), r = Y(t == null ? void 0 : t.targetProjection);
|
|
625
625
|
if (!(t != null && t.imageUrl) || !qe(e) || e === r)
|
|
626
626
|
return t;
|
|
627
627
|
const n = t.sourceArea || t.area, s = Ke(t.imageUrl, `${e}_${r}`, n);
|
|
628
|
-
if (
|
|
628
|
+
if (U.has(s))
|
|
629
629
|
return {
|
|
630
630
|
...t,
|
|
631
|
-
imageUrl:
|
|
631
|
+
imageUrl: U.get(s),
|
|
632
632
|
area: q(se(n) || t.area, t.area)
|
|
633
633
|
};
|
|
634
634
|
const i = se(n) || t.area;
|
|
635
635
|
let o = null;
|
|
636
|
-
|
|
636
|
+
ce(n) ? o = He(n) : o = j(n);
|
|
637
637
|
const a = await Ze(t.imageUrl, o);
|
|
638
638
|
return Xe(s, a), {
|
|
639
639
|
...t,
|
|
@@ -683,12 +683,12 @@ class pr {
|
|
|
683
683
|
constructor(e = {}) {
|
|
684
684
|
this.options = {
|
|
685
685
|
visible: e.visible ?? !0,
|
|
686
|
-
opacity:
|
|
687
|
-
zIndex:
|
|
686
|
+
opacity: x(e.opacity, 0.85),
|
|
687
|
+
zIndex: x(e.zIndex, 650),
|
|
688
688
|
defaultArea: q(e.defaultArea),
|
|
689
|
-
gridTotal:
|
|
690
|
-
tileSize:
|
|
691
|
-
decimalPlaces:
|
|
689
|
+
gridTotal: x(e.gridTotal, 4),
|
|
690
|
+
tileSize: x(e.tileSize, 512),
|
|
691
|
+
decimalPlaces: x(e.decimalPlaces, 2),
|
|
692
692
|
imageSourceType: e.imageSourceType || "color",
|
|
693
693
|
colorize: e.colorize || null,
|
|
694
694
|
layerId: e.layerId || "image-layer-default"
|
|
@@ -700,31 +700,31 @@ class pr {
|
|
|
700
700
|
*/
|
|
701
701
|
mount(e) {
|
|
702
702
|
var r, n;
|
|
703
|
-
return Je(e) ? (this._operationRequestId += 1, this.baseGIS = e,
|
|
703
|
+
return Je(e) ? (this._operationRequestId += 1, this.baseGIS = e, L(
|
|
704
704
|
{ engineType: ((n = (r = this.baseGIS).getEngineType) == null ? void 0 : n.call(r)) || "unknown" },
|
|
705
705
|
"ImageLayerController mounted with BaseGIS."
|
|
706
|
-
)) :
|
|
706
|
+
)) : I(
|
|
707
707
|
"ImageLayerController mount requires BaseGIS instance.",
|
|
708
708
|
"INVALID_MOUNT_TARGET"
|
|
709
709
|
);
|
|
710
710
|
}
|
|
711
711
|
resolveBaseGIS() {
|
|
712
712
|
var e, r;
|
|
713
|
-
return this.baseGIS ? (r = (e = this.baseGIS).getMapInstance) != null && r.call(e) ?
|
|
713
|
+
return this.baseGIS ? (r = (e = this.baseGIS).getMapInstance) != null && r.call(e) ? L(null, "BaseGIS is ready.") : I(
|
|
714
714
|
"Map instance is not ready. Please call mapCore.init() first.",
|
|
715
715
|
"NOT_INITIALIZED"
|
|
716
|
-
) :
|
|
716
|
+
) : I("ImageLayerController has not been mounted.", "NOT_MOUNTED");
|
|
717
717
|
}
|
|
718
718
|
getLayerId(e = {}) {
|
|
719
719
|
return typeof e == "string" && e ? e : (e == null ? void 0 : e.layerId) || this.options.layerId;
|
|
720
720
|
}
|
|
721
721
|
/* 获取图片图层目标投影 */
|
|
722
722
|
getTargetProjectionFn(e = {}) {
|
|
723
|
-
var s, i, o, a, l, u,
|
|
723
|
+
var s, i, o, a, c, l, u, h, d;
|
|
724
724
|
if (e.targetProjection)
|
|
725
725
|
return Y(e.targetProjection);
|
|
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 ? Y(n) : (((
|
|
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) || ((u = (l = (c = r == null ? void 0 : r.options) == null ? void 0 : c.crs) == null ? void 0 : l.options) == null ? void 0 : u.code);
|
|
727
|
+
return n ? Y(n) : (((d = (h = this.baseGIS) == null ? void 0 : h.getEngineType) == null ? void 0 : d.call(h)) === "leaflet", "EPSG:4326");
|
|
728
728
|
}
|
|
729
729
|
buildLayerPayload(e, r = {}) {
|
|
730
730
|
return {
|
|
@@ -749,11 +749,11 @@ class pr {
|
|
|
749
749
|
enableProbe: e.enableProbe,
|
|
750
750
|
showMouseProbe: e.showMouseProbe,
|
|
751
751
|
showLabel: !!e.showLabel,
|
|
752
|
-
gridTotal:
|
|
753
|
-
tileSize:
|
|
754
|
-
decimalPlaces:
|
|
755
|
-
opacity:
|
|
756
|
-
zIndex:
|
|
752
|
+
gridTotal: x(e.gridTotal, this.options.gridTotal),
|
|
753
|
+
tileSize: x(e.tileSize, this.options.tileSize),
|
|
754
|
+
decimalPlaces: x(e.decimalPlaces, this.options.decimalPlaces),
|
|
755
|
+
opacity: x(e.opacity, this.options.opacity),
|
|
756
|
+
zIndex: x(e.zIndex, this.options.zIndex),
|
|
757
757
|
visible: typeof r.visible == "boolean" ? r.visible : this.visible
|
|
758
758
|
};
|
|
759
759
|
}
|
|
@@ -763,10 +763,10 @@ class pr {
|
|
|
763
763
|
*/
|
|
764
764
|
async load(e = [], r = {}) {
|
|
765
765
|
if (!Array.isArray(e) || e.length === 0)
|
|
766
|
-
return
|
|
766
|
+
return I("Image list is empty.", "INVALID_ITEMS");
|
|
767
767
|
const n = e.map((i, o) => me(i, o, this.options.defaultArea)).filter((i) => i.imageUrl || i.tifUrl);
|
|
768
768
|
if (n.length === 0)
|
|
769
|
-
return
|
|
769
|
+
return I("No valid imageUrl or tifUrl found in items.", "INVALID_ITEMS");
|
|
770
770
|
this.items = n, typeof r.visible == "boolean" && (this.visible = r.visible);
|
|
771
771
|
const s = Number.isInteger(r.index) ? r.index : 0;
|
|
772
772
|
return this.switchTo(s);
|
|
@@ -776,26 +776,26 @@ class pr {
|
|
|
776
776
|
* target 可传索引数字,也可传图片 id。
|
|
777
777
|
*/
|
|
778
778
|
async switchTo(e) {
|
|
779
|
-
var
|
|
779
|
+
var l, u;
|
|
780
780
|
const r = this.resolveBaseGIS();
|
|
781
781
|
if (!r.success)
|
|
782
782
|
return r;
|
|
783
783
|
if (!Array.isArray(this.items) || this.items.length === 0)
|
|
784
|
-
return
|
|
784
|
+
return I("Image list has not been loaded.", "NOT_LOADED");
|
|
785
785
|
let n = -1;
|
|
786
|
-
if (typeof e == "number" ? n = e : typeof e == "string" && (n = this.items.findIndex((
|
|
787
|
-
return
|
|
786
|
+
if (typeof e == "number" ? n = e : typeof e == "string" && (n = this.items.findIndex((h) => h.id === e)), n < 0 || n >= this.items.length)
|
|
787
|
+
return I(`Invalid image target "${e}".`, "INVALID_TARGET");
|
|
788
788
|
const s = this.items[n], i = await ge({
|
|
789
789
|
...s,
|
|
790
790
|
targetProjection: this.getTargetProjectionFn(s)
|
|
791
|
-
}), o = this.buildLayerPayload(i), a = ++this._operationRequestId,
|
|
792
|
-
return a !== this._operationRequestId || (
|
|
791
|
+
}), o = this.buildLayerPayload(i), a = ++this._operationRequestId, c = await this.baseGIS.upsertImageLayer(o);
|
|
792
|
+
return a !== this._operationRequestId || (l = c == null ? void 0 : c.data) != null && l.stale ? L(
|
|
793
793
|
{ stale: !0, ignored: !0 },
|
|
794
794
|
`Image switch to "${s.name}" was superseded.`
|
|
795
|
-
) :
|
|
795
|
+
) : c.success ? (this.activeIndex = n, this.layerType = ((u = c == null ? void 0 : c.data) == null ? void 0 : u.layerType) || this.layerType, this.currentPayload = o, L(
|
|
796
796
|
{ activeIndex: n, activeItem: i },
|
|
797
797
|
`Image switched to "${i.name}".`
|
|
798
|
-
)) :
|
|
798
|
+
)) : c;
|
|
799
799
|
}
|
|
800
800
|
/**
|
|
801
801
|
* 更新当前图片图层数据。
|
|
@@ -804,7 +804,7 @@ class pr {
|
|
|
804
804
|
* 与 load(items) 不同,update(payload) 不要求维护图片数组,也不表达 next / prev 两态。
|
|
805
805
|
*/
|
|
806
806
|
async update(e = {}) {
|
|
807
|
-
var
|
|
807
|
+
var u, h;
|
|
808
808
|
const r = this.resolveBaseGIS();
|
|
809
809
|
if (!r.success)
|
|
810
810
|
return r;
|
|
@@ -818,29 +818,29 @@ class pr {
|
|
|
818
818
|
this.options.defaultArea
|
|
819
819
|
);
|
|
820
820
|
if (!i.imageUrl && !i.tifUrl)
|
|
821
|
-
return
|
|
821
|
+
return I("Image layer update requires imageUrl or tifUrl.", "INVALID_ITEM");
|
|
822
822
|
typeof e.visible == "boolean" && (this.visible = e.visible);
|
|
823
|
-
const o = await ge(i), a = this.buildLayerPayload(o, e),
|
|
824
|
-
return
|
|
823
|
+
const o = await ge(i), a = this.buildLayerPayload(o, e), c = ++this._operationRequestId, l = await this.baseGIS.upsertImageLayer(a);
|
|
824
|
+
return c !== this._operationRequestId || (u = l == null ? void 0 : l.data) != null && u.stale ? L(
|
|
825
825
|
{ stale: !0, ignored: !0 },
|
|
826
826
|
`Image layer update "${i.name}" was superseded.`
|
|
827
|
-
) :
|
|
827
|
+
) : 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(
|
|
828
828
|
{
|
|
829
829
|
activeIndex: this.activeIndex,
|
|
830
830
|
activeItem: o
|
|
831
831
|
},
|
|
832
832
|
`Image layer updated: "${o.name}".`
|
|
833
|
-
)) :
|
|
833
|
+
)) : l;
|
|
834
834
|
}
|
|
835
835
|
async next() {
|
|
836
836
|
if (!this.items.length)
|
|
837
|
-
return
|
|
837
|
+
return I("Image list has not been loaded.", "NOT_LOADED");
|
|
838
838
|
const e = this.activeIndex < 0 ? 0 : (this.activeIndex + 1) % this.items.length;
|
|
839
839
|
return this.switchTo(e);
|
|
840
840
|
}
|
|
841
841
|
async prev() {
|
|
842
842
|
if (!this.items.length)
|
|
843
|
-
return
|
|
843
|
+
return I("Image list has not been loaded.", "NOT_LOADED");
|
|
844
844
|
const e = this.activeIndex < 0 ? this.items.length - 1 : (this.activeIndex - 1 + this.items.length) % this.items.length;
|
|
845
845
|
return this.switchTo(e);
|
|
846
846
|
}
|
|
@@ -868,11 +868,11 @@ class pr {
|
|
|
868
868
|
*/
|
|
869
869
|
destroy(e = {}) {
|
|
870
870
|
if (this._operationRequestId += 1, !this.resolveBaseGIS().success)
|
|
871
|
-
return this.items = [], this.activeIndex = -1, this.layerType = "unknown", this.currentPayload = null,
|
|
871
|
+
return this.items = [], this.activeIndex = -1, this.layerType = "unknown", this.currentPayload = null, L(null, "Image layer controller destroyed (local state only).");
|
|
872
872
|
const n = this.baseGIS.removeImageLayer({
|
|
873
873
|
layerId: this.getLayerId(e)
|
|
874
874
|
});
|
|
875
|
-
return this.items = [], this.activeIndex = -1, this.layerType = "unknown", this.currentPayload = null, n.success ?
|
|
875
|
+
return this.items = [], this.activeIndex = -1, this.layerType = "unknown", this.currentPayload = null, n.success ? L(null, "Image layer controller destroyed.") : n;
|
|
876
876
|
}
|
|
877
877
|
getState() {
|
|
878
878
|
var e, r;
|
|
@@ -904,7 +904,7 @@ function et(t = {}) {
|
|
|
904
904
|
const e = { ...t };
|
|
905
905
|
return delete e.mapCore, delete e.baseGIS, e;
|
|
906
906
|
}
|
|
907
|
-
class
|
|
907
|
+
class Lr {
|
|
908
908
|
constructor(e = {}) {
|
|
909
909
|
const r = et(e), n = r.pointDensityLayerId || r.densityLayerId || r.layerId || r.id || "point-density-default";
|
|
910
910
|
this.options = {
|
|
@@ -928,20 +928,20 @@ class Sr {
|
|
|
928
928
|
}
|
|
929
929
|
mount(e) {
|
|
930
930
|
var r, n;
|
|
931
|
-
return Qe(e) ? (this.baseGIS = e,
|
|
931
|
+
return Qe(e) ? (this.baseGIS = e, L(
|
|
932
932
|
{ engineType: ((n = (r = this.baseGIS).getEngineType) == null ? void 0 : n.call(r)) || "unknown" },
|
|
933
933
|
"PointDensityController mounted with BaseGIS."
|
|
934
|
-
)) :
|
|
934
|
+
)) : I(
|
|
935
935
|
"PointDensityController mount requires BaseGIS instance.",
|
|
936
936
|
"INVALID_MOUNT_TARGET"
|
|
937
937
|
);
|
|
938
938
|
}
|
|
939
939
|
resolveBaseGIS() {
|
|
940
940
|
var e, r;
|
|
941
|
-
return this.baseGIS ? (r = (e = this.baseGIS).getMapInstance) != null && r.call(e) ?
|
|
941
|
+
return this.baseGIS ? (r = (e = this.baseGIS).getMapInstance) != null && r.call(e) ? L(null, "BaseGIS is ready.") : I(
|
|
942
942
|
"Map instance is not ready. Please call mapCore.init() first.",
|
|
943
943
|
"NOT_INITIALIZED"
|
|
944
|
-
) :
|
|
944
|
+
) : I("PointDensityController has not been mounted.", "NOT_MOUNTED");
|
|
945
945
|
}
|
|
946
946
|
getLayerId(e = {}) {
|
|
947
947
|
var r;
|
|
@@ -965,7 +965,7 @@ class Sr {
|
|
|
965
965
|
}, typeof r.visible == "boolean" && (this.visible = r.visible));
|
|
966
966
|
}
|
|
967
967
|
async load(e = {}, r = {}) {
|
|
968
|
-
var
|
|
968
|
+
var c;
|
|
969
969
|
const n = this.resolveBaseGIS();
|
|
970
970
|
if (!n.success)
|
|
971
971
|
return n;
|
|
@@ -974,12 +974,12 @@ class Sr {
|
|
|
974
974
|
...i
|
|
975
975
|
});
|
|
976
976
|
if (!Ie(o))
|
|
977
|
-
return
|
|
977
|
+
return I(
|
|
978
978
|
"Point density layer requires points, data or items.",
|
|
979
979
|
"INVALID_POINT_SOURCE"
|
|
980
980
|
);
|
|
981
981
|
const a = await this.baseGIS.upsertPointDensityLayer(o);
|
|
982
|
-
return a.success && (this.currentPayload = o, this.visible = o.visible !== !1, this.layerType = ((
|
|
982
|
+
return a.success && (this.currentPayload = o, this.visible = o.visible !== !1, this.layerType = ((c = a == null ? void 0 : a.data) == null ? void 0 : c.layerType) || this.layerType, this.syncStateFromResult(a)), a;
|
|
983
983
|
}
|
|
984
984
|
upsert(e = {}, r = {}) {
|
|
985
985
|
return this.load(e, r);
|
|
@@ -989,7 +989,7 @@ class Sr {
|
|
|
989
989
|
...this.currentPayload || this.defaultPayload,
|
|
990
990
|
...$(e)
|
|
991
991
|
};
|
|
992
|
-
return !this.currentPayload && !Ie(r) ?
|
|
992
|
+
return !this.currentPayload && !Ie(r) ? I("Point density layer has not been loaded.", "NOT_LOADED") : this.load(r);
|
|
993
993
|
}
|
|
994
994
|
setConfig(e = {}) {
|
|
995
995
|
return this.update(e);
|
|
@@ -1051,7 +1051,7 @@ class Sr {
|
|
|
1051
1051
|
hiddenCount: 0,
|
|
1052
1052
|
gridCount: 0,
|
|
1053
1053
|
destroyed: !0
|
|
1054
|
-
},
|
|
1054
|
+
}, L(null, "Point density layer controller destroyed (local state only).");
|
|
1055
1055
|
const n = this.baseGIS.removePointDensityLayer({
|
|
1056
1056
|
...e,
|
|
1057
1057
|
layerId: this.getLayerId(e)
|
|
@@ -1063,7 +1063,7 @@ class Sr {
|
|
|
1063
1063
|
hiddenCount: 0,
|
|
1064
1064
|
gridCount: 0,
|
|
1065
1065
|
destroyed: !0
|
|
1066
|
-
}, n.success ?
|
|
1066
|
+
}, n.success ? L(null, "Point density layer controller destroyed.") : n;
|
|
1067
1067
|
}
|
|
1068
1068
|
removeLayer(e = {}) {
|
|
1069
1069
|
return this.destroy(e);
|
|
@@ -1071,10 +1071,10 @@ class Sr {
|
|
|
1071
1071
|
getState() {
|
|
1072
1072
|
var e, r, n, s, i, o, a;
|
|
1073
1073
|
if ((r = (e = this.baseGIS) == null ? void 0 : e.getMapInstance) != null && r.call(e) && this.currentPayload) {
|
|
1074
|
-
const
|
|
1074
|
+
const c = (s = (n = this.baseGIS).getPointDensityLayerState) == null ? void 0 : s.call(n, {
|
|
1075
1075
|
layerId: this.currentPayload.layerId || this.options.layerId
|
|
1076
1076
|
});
|
|
1077
|
-
|
|
1077
|
+
c != null && c.success && this.syncStateFromResult(c);
|
|
1078
1078
|
}
|
|
1079
1079
|
return {
|
|
1080
1080
|
mounted: !!this.baseGIS,
|
|
@@ -1133,20 +1133,20 @@ class Cr {
|
|
|
1133
1133
|
}
|
|
1134
1134
|
mount(e) {
|
|
1135
1135
|
var r, n;
|
|
1136
|
-
return tt(e) ? (this.baseGIS = e,
|
|
1136
|
+
return tt(e) ? (this.baseGIS = e, L(
|
|
1137
1137
|
{ engineType: ((n = (r = this.baseGIS).getEngineType) == null ? void 0 : n.call(r)) || "unknown" },
|
|
1138
1138
|
"PointLargeLayerController mounted with BaseGIS."
|
|
1139
|
-
)) :
|
|
1139
|
+
)) : I(
|
|
1140
1140
|
"PointLargeLayerController mount requires BaseGIS instance.",
|
|
1141
1141
|
"INVALID_MOUNT_TARGET"
|
|
1142
1142
|
);
|
|
1143
1143
|
}
|
|
1144
1144
|
resolveBaseGIS() {
|
|
1145
1145
|
var e, r;
|
|
1146
|
-
return this.baseGIS ? (r = (e = this.baseGIS).getMapInstance) != null && r.call(e) ?
|
|
1146
|
+
return this.baseGIS ? (r = (e = this.baseGIS).getMapInstance) != null && r.call(e) ? L(null, "BaseGIS is ready.") : I(
|
|
1147
1147
|
"Map instance is not ready. Please call mapCore.init() first.",
|
|
1148
1148
|
"NOT_INITIALIZED"
|
|
1149
|
-
) :
|
|
1149
|
+
) : I("PointLargeLayerController has not been mounted.", "NOT_MOUNTED");
|
|
1150
1150
|
}
|
|
1151
1151
|
getLayerId(e = {}, r = {}) {
|
|
1152
1152
|
var s;
|
|
@@ -1175,7 +1175,7 @@ class Cr {
|
|
|
1175
1175
|
* 支持 load(points, options) 或 load({ points, ...options }) 两种调用方式。
|
|
1176
1176
|
*/
|
|
1177
1177
|
async load(e = {}, r = {}) {
|
|
1178
|
-
var
|
|
1178
|
+
var c;
|
|
1179
1179
|
const n = this.resolveBaseGIS();
|
|
1180
1180
|
if (!n.success)
|
|
1181
1181
|
return n;
|
|
@@ -1184,12 +1184,12 @@ class Cr {
|
|
|
1184
1184
|
...i
|
|
1185
1185
|
});
|
|
1186
1186
|
if (!be(o))
|
|
1187
|
-
return
|
|
1187
|
+
return I(
|
|
1188
1188
|
"Point large layer requires points, data or items.",
|
|
1189
1189
|
"INVALID_POINT_SOURCE"
|
|
1190
1190
|
);
|
|
1191
1191
|
const a = await this.baseGIS.upsertPointLargeLayer(o);
|
|
1192
|
-
return a.success && (this.currentPayload = o, this.visible = o.visible !== !1, this.layerType = ((
|
|
1192
|
+
return a.success && (this.currentPayload = o, this.visible = o.visible !== !1, this.layerType = ((c = a == null ? void 0 : a.data) == null ? void 0 : c.layerType) || this.layerType, this.syncStateFromResult(a)), a;
|
|
1193
1193
|
}
|
|
1194
1194
|
upsert(e = {}, r = {}) {
|
|
1195
1195
|
return this.load(e, r);
|
|
@@ -1199,7 +1199,7 @@ class Cr {
|
|
|
1199
1199
|
...this.currentPayload || this.defaultPayload,
|
|
1200
1200
|
...k(e)
|
|
1201
1201
|
};
|
|
1202
|
-
return !this.currentPayload && !be(r) ?
|
|
1202
|
+
return !this.currentPayload && !be(r) ? I("Point large layer has not been loaded.", "NOT_LOADED") : this.load(r);
|
|
1203
1203
|
}
|
|
1204
1204
|
show(e = {}) {
|
|
1205
1205
|
const r = this.resolveBaseGIS();
|
|
@@ -1230,7 +1230,7 @@ class Cr {
|
|
|
1230
1230
|
return n;
|
|
1231
1231
|
const s = e && typeof e == "object" && !Array.isArray(e) ? e : r, i = pe(e, s);
|
|
1232
1232
|
if (i == null || i === "")
|
|
1233
|
-
return
|
|
1233
|
+
return I("Point id is required when setting highlight.", "INVALID_POINT_ID");
|
|
1234
1234
|
const o = this.baseGIS.setPointLargeHighlight({
|
|
1235
1235
|
...s,
|
|
1236
1236
|
layerId: this.getLayerId(s, { allowId: !1 }),
|
|
@@ -1275,7 +1275,7 @@ class Cr {
|
|
|
1275
1275
|
return n;
|
|
1276
1276
|
const s = e && typeof e == "object" && !Array.isArray(e) ? e : r, i = pe(e, s);
|
|
1277
1277
|
if (i == null || i === "")
|
|
1278
|
-
return
|
|
1278
|
+
return I("Point id is required when removing point.", "INVALID_POINT_ID");
|
|
1279
1279
|
const o = this.baseGIS.removePointLargePoint({
|
|
1280
1280
|
...s,
|
|
1281
1281
|
layerId: this.getLayerId(s, { allowId: !1 }),
|
|
@@ -1295,7 +1295,7 @@ class Cr {
|
|
|
1295
1295
|
return n;
|
|
1296
1296
|
const s = Array.isArray(e) ? e : [e];
|
|
1297
1297
|
if (s.length === 0)
|
|
1298
|
-
return
|
|
1298
|
+
return I("Point id list is required when removing points.", "INVALID_POINT_ID");
|
|
1299
1299
|
const i = this.baseGIS.removePointLargePoints({
|
|
1300
1300
|
...r,
|
|
1301
1301
|
layerId: this.getLayerId(r, { allowId: !1 }),
|
|
@@ -1346,7 +1346,7 @@ class Cr {
|
|
|
1346
1346
|
renderedCount: 0,
|
|
1347
1347
|
building: !1,
|
|
1348
1348
|
destroyed: !0
|
|
1349
|
-
},
|
|
1349
|
+
}, L(null, "Point large layer controller destroyed (local state only).");
|
|
1350
1350
|
const n = this.baseGIS.removePointLargeLayer({
|
|
1351
1351
|
...e,
|
|
1352
1352
|
layerId: this.getLayerId(e)
|
|
@@ -1357,7 +1357,7 @@ class Cr {
|
|
|
1357
1357
|
renderedCount: 0,
|
|
1358
1358
|
building: !1,
|
|
1359
1359
|
destroyed: !0
|
|
1360
|
-
}, n.success ?
|
|
1360
|
+
}, n.success ? L(null, "Point large layer controller destroyed.") : n;
|
|
1361
1361
|
}
|
|
1362
1362
|
removeLayer(e = {}) {
|
|
1363
1363
|
return this.destroy(e);
|
|
@@ -1365,10 +1365,10 @@ class Cr {
|
|
|
1365
1365
|
getState() {
|
|
1366
1366
|
var e, r, n, s, i, o, a;
|
|
1367
1367
|
if ((r = (e = this.baseGIS) == null ? void 0 : e.getMapInstance) != null && r.call(e) && this.currentPayload) {
|
|
1368
|
-
const
|
|
1368
|
+
const c = (s = (n = this.baseGIS).getPointLargeLayerState) == null ? void 0 : s.call(n, {
|
|
1369
1369
|
layerId: this.currentPayload.layerId || this.options.layerId
|
|
1370
1370
|
});
|
|
1371
|
-
|
|
1371
|
+
c != null && c.success && this.syncStateFromResult(c);
|
|
1372
1372
|
}
|
|
1373
1373
|
return {
|
|
1374
1374
|
mounted: !!this.baseGIS,
|
|
@@ -1402,29 +1402,29 @@ function it(t, e) {
|
|
|
1402
1402
|
const ot = Math.sqrt(50), at = Math.sqrt(10), lt = Math.sqrt(2);
|
|
1403
1403
|
function K(t, e, r) {
|
|
1404
1404
|
const n = (e - t) / Math.max(0, r), s = Math.floor(Math.log10(n)), i = n / Math.pow(10, s), o = i >= ot ? 10 : i >= at ? 5 : i >= lt ? 2 : 1;
|
|
1405
|
-
let a,
|
|
1406
|
-
return s < 0 ? (
|
|
1405
|
+
let a, c, l;
|
|
1406
|
+
return s < 0 ? (l = Math.pow(10, -s) / o, a = Math.round(t * l), c = Math.round(e * l), a / l < t && ++a, c / l > e && --c, l = -l) : (l = Math.pow(10, s) * o, a = Math.round(t / l), c = Math.round(e / l), a * l < t && ++a, c * l > e && --c), c < a && 0.5 <= r && r < 2 ? K(t, e, r * 2) : [a, c, l];
|
|
1407
1407
|
}
|
|
1408
|
-
function
|
|
1408
|
+
function ct(t, e, r) {
|
|
1409
1409
|
if (e = +e, t = +t, r = +r, !(r > 0)) return [];
|
|
1410
1410
|
if (t === e) return [t];
|
|
1411
1411
|
const n = e < t, [s, i, o] = n ? K(e, t, r) : K(t, e, r);
|
|
1412
1412
|
if (!(i >= s)) return [];
|
|
1413
|
-
const a = i - s + 1,
|
|
1413
|
+
const a = i - s + 1, c = new Array(a);
|
|
1414
1414
|
if (n)
|
|
1415
|
-
if (o < 0) for (let
|
|
1416
|
-
else for (let
|
|
1417
|
-
else if (o < 0) for (let
|
|
1418
|
-
else for (let
|
|
1419
|
-
return
|
|
1415
|
+
if (o < 0) for (let l = 0; l < a; ++l) c[l] = (i - l) / -o;
|
|
1416
|
+
else for (let l = 0; l < a; ++l) c[l] = (i - l) * o;
|
|
1417
|
+
else if (o < 0) for (let l = 0; l < a; ++l) c[l] = (s + l) / -o;
|
|
1418
|
+
else for (let l = 0; l < a; ++l) c[l] = (s + l) * o;
|
|
1419
|
+
return c;
|
|
1420
1420
|
}
|
|
1421
|
-
function
|
|
1421
|
+
function ut(t, e, r) {
|
|
1422
1422
|
return e = +e, t = +t, r = +r, K(t, e, r)[2];
|
|
1423
1423
|
}
|
|
1424
1424
|
function ht(t, e, r) {
|
|
1425
1425
|
let n;
|
|
1426
1426
|
for (; ; ) {
|
|
1427
|
-
const s =
|
|
1427
|
+
const s = ut(t, e, r);
|
|
1428
1428
|
if (s === n || s === 0 || !isFinite(s))
|
|
1429
1429
|
return [t, e];
|
|
1430
1430
|
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;
|
|
@@ -1441,30 +1441,30 @@ function mt(t) {
|
|
|
1441
1441
|
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
1442
|
return n;
|
|
1443
1443
|
}
|
|
1444
|
-
const
|
|
1444
|
+
const Le = (t) => () => t;
|
|
1445
1445
|
function It(t, e) {
|
|
1446
1446
|
for (var r = -1, n = e.length, s; ++r < n; ) if (s = bt(t, e[r])) return s;
|
|
1447
1447
|
return 0;
|
|
1448
1448
|
}
|
|
1449
1449
|
function bt(t, e) {
|
|
1450
1450
|
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 (pt(
|
|
1453
|
-
|
|
1451
|
+
var c = t[i], l = c[0], u = c[1], h = t[a], d = h[0], f = h[1];
|
|
1452
|
+
if (pt(c, h, e)) return 0;
|
|
1453
|
+
u > n != f > n && r < (d - l) * (n - u) / (f - u) + l && (s = -s);
|
|
1454
1454
|
}
|
|
1455
1455
|
return s;
|
|
1456
1456
|
}
|
|
1457
1457
|
function pt(t, e, r) {
|
|
1458
1458
|
var n;
|
|
1459
|
-
return
|
|
1459
|
+
return Lt(t, e, r) && Ct(t[n = +(t[0] === e[0])], r[n], e[n]);
|
|
1460
1460
|
}
|
|
1461
|
-
function
|
|
1461
|
+
function Lt(t, e, r) {
|
|
1462
1462
|
return (e[0] - t[0]) * (r[1] - t[1]) === (r[0] - t[0]) * (e[1] - t[1]);
|
|
1463
1463
|
}
|
|
1464
1464
|
function Ct(t, e, r) {
|
|
1465
1465
|
return t <= e && e <= r || r <= e && e <= t;
|
|
1466
1466
|
}
|
|
1467
|
-
function
|
|
1467
|
+
function St() {
|
|
1468
1468
|
}
|
|
1469
1469
|
var F = [
|
|
1470
1470
|
[],
|
|
@@ -1485,103 +1485,103 @@ var F = [
|
|
|
1485
1485
|
[]
|
|
1486
1486
|
];
|
|
1487
1487
|
function vt() {
|
|
1488
|
-
var t = 1, e = 1, r = dt, n =
|
|
1489
|
-
function s(
|
|
1490
|
-
var
|
|
1491
|
-
if (Array.isArray(
|
|
1492
|
-
|
|
1488
|
+
var t = 1, e = 1, r = dt, n = c;
|
|
1489
|
+
function s(l) {
|
|
1490
|
+
var u = r(l);
|
|
1491
|
+
if (Array.isArray(u))
|
|
1492
|
+
u = u.slice().sort(gt);
|
|
1493
1493
|
else {
|
|
1494
|
-
const
|
|
1495
|
-
for (
|
|
1496
|
-
for (;
|
|
1494
|
+
const h = it(l, wt);
|
|
1495
|
+
for (u = ct(...ht(h[0], h[1], u), u); u[u.length - 1] >= h[1]; ) u.pop();
|
|
1496
|
+
for (; u[1] < h[0]; ) u.shift();
|
|
1497
1497
|
}
|
|
1498
|
-
return
|
|
1499
|
-
}
|
|
1500
|
-
function i(
|
|
1501
|
-
const
|
|
1502
|
-
if (isNaN(
|
|
1503
|
-
var
|
|
1504
|
-
return o(
|
|
1505
|
-
n(y,
|
|
1498
|
+
return u.map((h) => i(l, h));
|
|
1499
|
+
}
|
|
1500
|
+
function i(l, u) {
|
|
1501
|
+
const h = u == null ? NaN : +u;
|
|
1502
|
+
if (isNaN(h)) throw new Error(`invalid value: ${u}`);
|
|
1503
|
+
var d = [], f = [];
|
|
1504
|
+
return o(l, h, function(y) {
|
|
1505
|
+
n(y, l, h), mt(y) > 0 ? d.push([y]) : f.push(y);
|
|
1506
1506
|
}), f.forEach(function(y) {
|
|
1507
|
-
for (var
|
|
1508
|
-
if (It((p =
|
|
1507
|
+
for (var b = 0, g = d.length, p; b < g; ++b)
|
|
1508
|
+
if (It((p = d[b])[0], y) !== -1) {
|
|
1509
1509
|
p.push(y);
|
|
1510
1510
|
return;
|
|
1511
1511
|
}
|
|
1512
1512
|
}), {
|
|
1513
1513
|
type: "MultiPolygon",
|
|
1514
|
-
value:
|
|
1515
|
-
coordinates:
|
|
1514
|
+
value: u,
|
|
1515
|
+
coordinates: d
|
|
1516
1516
|
};
|
|
1517
1517
|
}
|
|
1518
|
-
function o(
|
|
1519
|
-
var
|
|
1520
|
-
for (y =
|
|
1521
|
-
g = p, p =
|
|
1522
|
-
for (F[p << 0].forEach(
|
|
1523
|
-
for (y = -1, p =
|
|
1524
|
-
g = p, p =
|
|
1525
|
-
F[p | m << 3].forEach(
|
|
1518
|
+
function o(l, u, h) {
|
|
1519
|
+
var d = new Array(), f = new Array(), y, b, g, p, m, v;
|
|
1520
|
+
for (y = b = -1, p = z(l[0], u), F[p << 1].forEach(S); ++y < t - 1; )
|
|
1521
|
+
g = p, p = z(l[y + 1], u), F[g | p << 1].forEach(S);
|
|
1522
|
+
for (F[p << 0].forEach(S); ++b < e - 1; ) {
|
|
1523
|
+
for (y = -1, p = z(l[b * t + t], u), m = z(l[b * t], u), F[p << 1 | m << 2].forEach(S); ++y < t - 1; )
|
|
1524
|
+
g = p, p = z(l[b * t + t + y + 1], u), v = m, m = z(l[b * t + y + 1], u), F[g | p << 1 | m << 2 | v << 3].forEach(S);
|
|
1525
|
+
F[p | m << 3].forEach(S);
|
|
1526
1526
|
}
|
|
1527
|
-
for (y = -1, m =
|
|
1528
|
-
v = m, m =
|
|
1529
|
-
F[m << 3].forEach(
|
|
1530
|
-
function
|
|
1531
|
-
var
|
|
1532
|
-
(
|
|
1527
|
+
for (y = -1, m = l[b * t] >= u, F[m << 2].forEach(S); ++y < t - 1; )
|
|
1528
|
+
v = m, m = z(l[b * t + y + 1], u), F[m << 2 | v << 3].forEach(S);
|
|
1529
|
+
F[m << 3].forEach(S);
|
|
1530
|
+
function S(P) {
|
|
1531
|
+
var A = [P[0][0] + y, P[0][1] + b], M = [P[1][0] + y, P[1][1] + b], T = a(A), D = a(M), C, N;
|
|
1532
|
+
(C = f[T]) ? (N = d[D]) ? (delete f[C.end], delete d[N.start], C === N ? (C.ring.push(M), h(C.ring)) : d[C.start] = f[N.end] = { start: C.start, end: N.end, ring: C.ring.concat(N.ring) }) : (delete f[C.end], C.ring.push(M), f[C.end = D] = C) : (C = d[D]) ? (N = f[T]) ? (delete d[C.start], delete f[N.end], C === N ? (C.ring.push(M), h(C.ring)) : d[N.start] = f[C.end] = { start: N.start, end: C.end, ring: N.ring.concat(C.ring) }) : (delete d[C.start], C.ring.unshift(A), d[C.start = T] = C) : d[T] = f[D] = { start: T, end: D, ring: [A, M] };
|
|
1533
1533
|
}
|
|
1534
1534
|
}
|
|
1535
|
-
function a(
|
|
1536
|
-
return
|
|
1535
|
+
function a(l) {
|
|
1536
|
+
return l[0] * 2 + l[1] * (t + 1) * 4;
|
|
1537
1537
|
}
|
|
1538
|
-
function l
|
|
1539
|
-
|
|
1540
|
-
var f =
|
|
1541
|
-
f > 0 && f < t &&
|
|
1538
|
+
function c(l, u, h) {
|
|
1539
|
+
l.forEach(function(d) {
|
|
1540
|
+
var f = d[0], y = d[1], b = f | 0, g = y | 0, p = Z(u[g * t + b]);
|
|
1541
|
+
f > 0 && f < t && b === f && (d[0] = Ce(f, Z(u[g * t + b - 1]), p, h)), y > 0 && y < e && g === y && (d[1] = Ce(y, Z(u[(g - 1) * t + b]), p, h));
|
|
1542
1542
|
});
|
|
1543
1543
|
}
|
|
1544
|
-
return s.contour = i, s.size = function(
|
|
1544
|
+
return s.contour = i, s.size = function(l) {
|
|
1545
1545
|
if (!arguments.length) return [t, e];
|
|
1546
|
-
var
|
|
1547
|
-
if (!(
|
|
1548
|
-
return t =
|
|
1549
|
-
}, s.thresholds = function(
|
|
1550
|
-
return arguments.length ? (r = typeof
|
|
1551
|
-
}, s.smooth = function(
|
|
1552
|
-
return arguments.length ? (n =
|
|
1546
|
+
var u = Math.floor(l[0]), h = Math.floor(l[1]);
|
|
1547
|
+
if (!(u >= 0 && h >= 0)) throw new Error("invalid size");
|
|
1548
|
+
return t = u, e = h, s;
|
|
1549
|
+
}, s.thresholds = function(l) {
|
|
1550
|
+
return arguments.length ? (r = typeof l == "function" ? l : Array.isArray(l) ? Le(yt.call(l)) : Le(l), s) : r;
|
|
1551
|
+
}, s.smooth = function(l) {
|
|
1552
|
+
return arguments.length ? (n = l ? c : St, s) : n === c;
|
|
1553
1553
|
}, s;
|
|
1554
1554
|
}
|
|
1555
1555
|
function wt(t) {
|
|
1556
1556
|
return isFinite(t) ? t : NaN;
|
|
1557
1557
|
}
|
|
1558
|
-
function
|
|
1558
|
+
function z(t, e) {
|
|
1559
1559
|
return t == null ? !1 : +t >= e;
|
|
1560
1560
|
}
|
|
1561
|
-
function
|
|
1561
|
+
function Z(t) {
|
|
1562
1562
|
return t == null || isNaN(t = +t) ? -1 / 0 : t;
|
|
1563
1563
|
}
|
|
1564
1564
|
function Ce(t, e, r, n) {
|
|
1565
1565
|
const s = n - e, i = r - e, o = isFinite(s) || isFinite(i) ? s / i : Math.sign(s) / Math.sign(i);
|
|
1566
1566
|
return isNaN(o) ? t : t + o - 0.5;
|
|
1567
1567
|
}
|
|
1568
|
-
const
|
|
1569
|
-
function
|
|
1568
|
+
const Se = 6378137, ve = 85.0511287798066, we = 1e6;
|
|
1569
|
+
function G(t, e = null) {
|
|
1570
1570
|
const r = Number(t);
|
|
1571
1571
|
return Number.isFinite(r) ? r : e;
|
|
1572
1572
|
}
|
|
1573
1573
|
function Fe(t, e) {
|
|
1574
1574
|
return Object.prototype.hasOwnProperty.call(t || {}, e);
|
|
1575
1575
|
}
|
|
1576
|
-
function
|
|
1576
|
+
function Oe(t) {
|
|
1577
1577
|
if (Array.isArray(t) && t.length >= 4) {
|
|
1578
|
-
const [i, o, a,
|
|
1579
|
-
if ([i, o, a,
|
|
1578
|
+
const [i, o, a, c] = t.map(Number);
|
|
1579
|
+
if ([i, o, a, c].every(Number.isFinite))
|
|
1580
1580
|
return {
|
|
1581
1581
|
startLon: Math.min(i, a),
|
|
1582
|
-
startLat: Math.min(o,
|
|
1582
|
+
startLat: Math.min(o, c),
|
|
1583
1583
|
endLon: Math.max(i, a),
|
|
1584
|
-
endLat: Math.max(o,
|
|
1584
|
+
endLat: Math.max(o, c)
|
|
1585
1585
|
};
|
|
1586
1586
|
}
|
|
1587
1587
|
if (!t || typeof t != "object")
|
|
@@ -1602,52 +1602,58 @@ function Pt(t = {}, e = []) {
|
|
|
1602
1602
|
const r = Number(t.ProjectedCSTypeGeoKey);
|
|
1603
1603
|
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
1604
|
}
|
|
1605
|
-
function
|
|
1606
|
-
const r = Number(t) /
|
|
1605
|
+
function J(t, e) {
|
|
1606
|
+
const r = Number(t) / Se * (180 / Math.PI), n = (2 * Math.atan(Math.exp(Number(e) / Se)) - Math.PI / 2) * (180 / Math.PI);
|
|
1607
1607
|
return {
|
|
1608
1608
|
lng: r,
|
|
1609
1609
|
lat: Math.min(Math.max(n, -ve), ve)
|
|
1610
1610
|
};
|
|
1611
1611
|
}
|
|
1612
|
-
function
|
|
1612
|
+
function Q(t) {
|
|
1613
1613
|
return !Number.isFinite(t) || t >= -180 && t <= 180 ? t : ((t + 180) % 360 + 360) % 360 - 180;
|
|
1614
1614
|
}
|
|
1615
|
-
function
|
|
1616
|
-
|
|
1617
|
-
if (i) {
|
|
1618
|
-
|
|
1615
|
+
function ue({ area: t, bbox: e, projection: r, width: n, height: s, isSplit: i = !1 }) {
|
|
1616
|
+
let o = Oe(t);
|
|
1617
|
+
if (i && o && Math.abs(o.endLon - o.startLon) >= 359.999 && (o = {
|
|
1618
|
+
...o,
|
|
1619
|
+
startLon: -180,
|
|
1620
|
+
endLon: 180
|
|
1621
|
+
}), o) {
|
|
1622
|
+
const f = o.endLon - o.startLon, y = o.endLat - o.startLat;
|
|
1619
1623
|
return {
|
|
1620
|
-
area:
|
|
1624
|
+
area: o,
|
|
1621
1625
|
projection: "EPSG:4326",
|
|
1622
|
-
map(
|
|
1626
|
+
map(b, g) {
|
|
1623
1627
|
return [
|
|
1624
|
-
|
|
1625
|
-
|
|
1628
|
+
o.endLat - g / s * y,
|
|
1629
|
+
Q(o.startLon + b / n * f)
|
|
1626
1630
|
];
|
|
1627
1631
|
}
|
|
1628
1632
|
};
|
|
1629
1633
|
}
|
|
1630
1634
|
if (!Array.isArray(e) || e.length < 4 || !e.slice(0, 4).every(Number.isFinite))
|
|
1631
1635
|
throw new Error("栅格缺少地理范围,请通过 area 提供 [west, south, east, north]。");
|
|
1632
|
-
|
|
1633
|
-
|
|
1636
|
+
let [a, c, l, u] = e;
|
|
1637
|
+
i && (!r || r === "EPSG:4326") && Math.abs(l - a) >= 359.999 && (a = -180, l = 180);
|
|
1638
|
+
const h = l - a, d = u - c;
|
|
1639
|
+
if (h === 0 || d === 0)
|
|
1634
1640
|
throw new Error("栅格地理范围无效,宽度或高度为 0。");
|
|
1635
1641
|
if (r === "EPSG:3857") {
|
|
1636
|
-
const
|
|
1642
|
+
const f = J(a, c), y = J(l, u);
|
|
1637
1643
|
return {
|
|
1638
1644
|
area: {
|
|
1639
|
-
startLon:
|
|
1640
|
-
startLat:
|
|
1641
|
-
endLon:
|
|
1642
|
-
endLat:
|
|
1645
|
+
startLon: f.lng,
|
|
1646
|
+
startLat: f.lat,
|
|
1647
|
+
endLon: y.lng,
|
|
1648
|
+
endLat: y.lat
|
|
1643
1649
|
},
|
|
1644
1650
|
projection: r,
|
|
1645
|
-
map(
|
|
1646
|
-
const
|
|
1647
|
-
|
|
1648
|
-
u -
|
|
1651
|
+
map(b, g) {
|
|
1652
|
+
const p = J(
|
|
1653
|
+
a + b / n * h,
|
|
1654
|
+
u - g / s * d
|
|
1649
1655
|
);
|
|
1650
|
-
return [
|
|
1656
|
+
return [p.lat, Q(p.lng)];
|
|
1651
1657
|
}
|
|
1652
1658
|
};
|
|
1653
1659
|
}
|
|
@@ -1655,40 +1661,40 @@ function ce({ area: t, bbox: e, projection: r, width: n, height: s }) {
|
|
|
1655
1661
|
throw new Error(`暂不支持 ${r} 栅格,请传入 WGS84 area 覆盖原始范围。`);
|
|
1656
1662
|
return {
|
|
1657
1663
|
area: {
|
|
1658
|
-
startLon:
|
|
1659
|
-
startLat:
|
|
1664
|
+
startLon: a,
|
|
1665
|
+
startLat: c,
|
|
1660
1666
|
endLon: l,
|
|
1661
1667
|
endLat: u
|
|
1662
1668
|
},
|
|
1663
1669
|
projection: r || "EPSG:4326",
|
|
1664
|
-
map(
|
|
1665
|
-
return [u -
|
|
1670
|
+
map(f, y) {
|
|
1671
|
+
return [u - y / s * d, Q(a + f / n * h)];
|
|
1666
1672
|
}
|
|
1667
1673
|
};
|
|
1668
1674
|
}
|
|
1669
|
-
function
|
|
1675
|
+
function Gt(t = {}) {
|
|
1670
1676
|
const e = String(t.sourceType || t.dataType || "").toLowerCase();
|
|
1671
1677
|
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" : "";
|
|
1672
1678
|
}
|
|
1673
|
-
function
|
|
1679
|
+
function Mt() {
|
|
1674
1680
|
return typeof window > "u" ? null : window.GeoTIFF || null;
|
|
1675
1681
|
}
|
|
1676
1682
|
function Tt(t, e = {}, r = null) {
|
|
1677
1683
|
if (!Number.isFinite(t)) return !0;
|
|
1678
1684
|
const n = Fe(e, "noDataValue") ? Number(e.noDataValue) : r;
|
|
1679
1685
|
if (Number.isFinite(n) && t === n) return !0;
|
|
1680
|
-
const s =
|
|
1686
|
+
const s = G(e.validMin), i = G(e.validMax);
|
|
1681
1687
|
return s !== null && t < s || i !== null && t > i;
|
|
1682
1688
|
}
|
|
1683
|
-
function
|
|
1684
|
-
const n =
|
|
1689
|
+
function De(t, e = {}, r = null) {
|
|
1690
|
+
const n = G(e.scale, 1), s = G(e.offset, 0), i = new Float64Array(t.length);
|
|
1685
1691
|
for (let o = 0; o < t.length; o += 1) {
|
|
1686
1692
|
const a = Number(t[o]);
|
|
1687
1693
|
i[o] = Tt(a, e, r) ? Number.NaN : a * n + s;
|
|
1688
1694
|
}
|
|
1689
1695
|
return i;
|
|
1690
1696
|
}
|
|
1691
|
-
function
|
|
1697
|
+
function Be(t, e, r) {
|
|
1692
1698
|
const n = new Float64Array(t.length), s = Math.floor(e / 2);
|
|
1693
1699
|
for (let i = 0; i < r; i += 1)
|
|
1694
1700
|
for (let o = 0; o < e; o += 1) {
|
|
@@ -1698,46 +1704,47 @@ function De(t, e, r) {
|
|
|
1698
1704
|
return n;
|
|
1699
1705
|
}
|
|
1700
1706
|
async function xt(t = {}) {
|
|
1701
|
-
var m, v,
|
|
1702
|
-
const e =
|
|
1707
|
+
var m, v, S;
|
|
1708
|
+
const e = Mt();
|
|
1703
1709
|
if (!e)
|
|
1704
1710
|
throw new Error("GeoTIFF 未加载,请先提供 window.GeoTIFF。");
|
|
1705
1711
|
let r = t.arrayBuffer || null;
|
|
1706
1712
|
const n = t.tifUrl || t.tiffUrl || "";
|
|
1707
1713
|
if (!r) {
|
|
1708
1714
|
if (!n) throw new Error("GeoTIFF 数据源缺少 tifUrl。");
|
|
1709
|
-
r = (await
|
|
1710
|
-
}
|
|
1711
|
-
const s = await e.fromArrayBuffer(r), i = Math.max(Math.floor(
|
|
1712
|
-
if (
|
|
1713
|
-
throw new Error(`GeoTIFF 不存在第 ${
|
|
1714
|
-
const
|
|
1715
|
-
let f =
|
|
1716
|
-
t.isSplit && (f =
|
|
1715
|
+
r = (await Ue.get(n, { responseType: "arraybuffer" })).data;
|
|
1716
|
+
}
|
|
1717
|
+
const s = await e.fromArrayBuffer(r), i = Math.max(Math.floor(G(t.imageIndex, 0)), 0), o = await s.getImage(i), a = o.getWidth(), c = o.getHeight(), l = Math.max(Math.floor(G(t.band, 0)), 0);
|
|
1718
|
+
if (l >= o.getSamplesPerPixel())
|
|
1719
|
+
throw new Error(`GeoTIFF 不存在第 ${l} 个波段。`);
|
|
1720
|
+
const u = { samples: [l], interleave: !1 }, h = await o.readRasters(u), d = G((m = o.getGDALNoData) == null ? void 0 : m.call(o));
|
|
1721
|
+
let f = De(h[0], t, d);
|
|
1722
|
+
t.isSplit && (f = Be(f, a, c));
|
|
1717
1723
|
let y = [];
|
|
1718
1724
|
try {
|
|
1719
1725
|
y = ((v = o.getBoundingBox) == null ? void 0 : v.call(o)) || [];
|
|
1720
|
-
} catch (
|
|
1721
|
-
if (!t.area) throw
|
|
1726
|
+
} catch (P) {
|
|
1727
|
+
if (!t.area) throw P;
|
|
1722
1728
|
}
|
|
1723
|
-
const
|
|
1729
|
+
const b = ((S = o.getGeoKeys) == null ? void 0 : S.call(o)) || {}, g = ie(t.sourceProjection) || Pt(b, y), p = ue({
|
|
1724
1730
|
area: t.area,
|
|
1725
1731
|
bbox: y,
|
|
1726
1732
|
projection: g,
|
|
1727
1733
|
width: a,
|
|
1728
|
-
height:
|
|
1734
|
+
height: c,
|
|
1735
|
+
isSplit: t.isSplit
|
|
1729
1736
|
});
|
|
1730
1737
|
return {
|
|
1731
1738
|
sourceType: "geotiff",
|
|
1732
1739
|
sourceUrl: n,
|
|
1733
1740
|
width: a,
|
|
1734
|
-
height:
|
|
1741
|
+
height: c,
|
|
1735
1742
|
values: f,
|
|
1736
1743
|
sourceProjection: g,
|
|
1737
1744
|
projection: p.projection,
|
|
1738
1745
|
area: p.area,
|
|
1739
1746
|
mapCoordinate: p.map,
|
|
1740
|
-
band:
|
|
1747
|
+
band: l
|
|
1741
1748
|
};
|
|
1742
1749
|
}
|
|
1743
1750
|
function Nt(t) {
|
|
@@ -1752,7 +1759,7 @@ function At(t, e, r = "luminance") {
|
|
|
1752
1759
|
async function Et(t = {}) {
|
|
1753
1760
|
if (typeof document > "u" || typeof Image > "u")
|
|
1754
1761
|
throw new Error("灰度图解析只能在浏览器环境中运行。");
|
|
1755
|
-
const e = t.grayImageUrl || t.imageUrl || "", r =
|
|
1762
|
+
const e = t.grayImageUrl || t.imageUrl || "", r = Oe(t.area);
|
|
1756
1763
|
if (!e) throw new Error("灰度图数据源缺少 grayImageUrl 或 imageUrl。");
|
|
1757
1764
|
if (!r) throw new Error("灰度图没有地理信息,必须通过 area 提供覆盖范围。");
|
|
1758
1765
|
const n = await Nt(e), s = n.naturalWidth || n.width, i = n.naturalHeight || n.height, o = document.createElement("canvas");
|
|
@@ -1760,24 +1767,29 @@ async function Et(t = {}) {
|
|
|
1760
1767
|
const a = o.getContext("2d", { willReadFrequently: !0 });
|
|
1761
1768
|
if (!a) throw new Error("当前浏览器不支持 Canvas 2D。");
|
|
1762
1769
|
a.drawImage(n, 0, 0, s, i);
|
|
1763
|
-
let
|
|
1770
|
+
let c;
|
|
1764
1771
|
try {
|
|
1765
|
-
|
|
1766
|
-
} catch (
|
|
1767
|
-
throw new Error(`灰度图像素读取失败,请检查图片 CORS:${(
|
|
1768
|
-
}
|
|
1769
|
-
const
|
|
1770
|
-
for (let
|
|
1771
|
-
for (let
|
|
1772
|
-
const
|
|
1773
|
-
if (
|
|
1772
|
+
c = a.getImageData(0, 0, s, i).data;
|
|
1773
|
+
} catch (S) {
|
|
1774
|
+
throw new Error(`灰度图像素读取失败,请检查图片 CORS:${(S == null ? void 0 : S.message) || ""}`);
|
|
1775
|
+
}
|
|
1776
|
+
const l = G(t.grayMinValue, 0), u = G(t.grayMaxValue, 255), h = G(t.minValue, l), d = G(t.maxValue, u), f = u - l, y = String(t.grayChannel || t.grayMode || "luminance").toLowerCase(), b = Fe(t, "noDataValue"), g = Number(t.noDataValue), p = t.isSplit ? Math.floor(s / 2) : 0, m = new Float64Array(s * i);
|
|
1777
|
+
for (let S = 0; S < i; S += 1)
|
|
1778
|
+
for (let P = 0; P < s; P += 1) {
|
|
1779
|
+
const A = (P + p) % s, M = (S * s + A) * 4, T = S * s + P, D = At(c, M, y);
|
|
1780
|
+
if (c[M + 3] === 0 || b && Math.abs(D - g) < 0.5) {
|
|
1774
1781
|
m[T] = Number.NaN;
|
|
1775
1782
|
continue;
|
|
1776
1783
|
}
|
|
1777
|
-
let
|
|
1778
|
-
|
|
1784
|
+
let C = f === 0 ? 0 : (D - l) / f;
|
|
1785
|
+
C = Math.min(Math.max(C, 0), 1), t.invert && (C = 1 - C), m[T] = h + C * (d - h);
|
|
1779
1786
|
}
|
|
1780
|
-
const v =
|
|
1787
|
+
const v = ue({
|
|
1788
|
+
area: r,
|
|
1789
|
+
width: s,
|
|
1790
|
+
height: i,
|
|
1791
|
+
isSplit: t.isSplit
|
|
1792
|
+
});
|
|
1781
1793
|
return {
|
|
1782
1794
|
sourceType: "grayscale",
|
|
1783
1795
|
sourceUrl: e,
|
|
@@ -1805,7 +1817,7 @@ function Rt(t = {}) {
|
|
|
1805
1817
|
values: e.flat()
|
|
1806
1818
|
};
|
|
1807
1819
|
}
|
|
1808
|
-
const r = Math.floor(
|
|
1820
|
+
const r = Math.floor(G(t.width, 0)), n = Math.floor(G(t.height, 0));
|
|
1809
1821
|
if (r < 2 || n < 2 || e.length < r * n)
|
|
1810
1822
|
throw new Error("一维数值网格必须提供正确的 width 和 height。");
|
|
1811
1823
|
return { width: r, height: n, values: e };
|
|
@@ -1813,14 +1825,15 @@ function Rt(t = {}) {
|
|
|
1813
1825
|
function Ft(t = {}) {
|
|
1814
1826
|
const e = Rt(t);
|
|
1815
1827
|
if (!e) throw new Error("数值网格缺少 values、data 或 grid。");
|
|
1816
|
-
let r =
|
|
1817
|
-
t.isSplit && (r =
|
|
1818
|
-
const n =
|
|
1828
|
+
let r = De(e.values, t);
|
|
1829
|
+
t.isSplit && (r = Be(r, e.width, e.height));
|
|
1830
|
+
const n = ue({
|
|
1819
1831
|
area: t.area,
|
|
1820
1832
|
bbox: t.bbox,
|
|
1821
1833
|
projection: ie(t.sourceProjection) || "EPSG:4326",
|
|
1822
1834
|
width: e.width,
|
|
1823
|
-
height: e.height
|
|
1835
|
+
height: e.height,
|
|
1836
|
+
isSplit: t.isSplit
|
|
1824
1837
|
});
|
|
1825
1838
|
return {
|
|
1826
1839
|
sourceType: "grid",
|
|
@@ -1835,14 +1848,14 @@ function Ft(t = {}) {
|
|
|
1835
1848
|
band: 0
|
|
1836
1849
|
};
|
|
1837
1850
|
}
|
|
1838
|
-
async function
|
|
1839
|
-
const e =
|
|
1851
|
+
async function Ot(t = {}) {
|
|
1852
|
+
const e = Gt(t);
|
|
1840
1853
|
if (e === "geotiff") return xt(t);
|
|
1841
1854
|
if (e === "grayscale") return Et(t);
|
|
1842
1855
|
if (e === "grid") return Ft(t);
|
|
1843
1856
|
throw new Error("无法识别栅格数据源,请提供 tifUrl、grayImageUrl 或 values。");
|
|
1844
1857
|
}
|
|
1845
|
-
function
|
|
1858
|
+
function Dt(t) {
|
|
1846
1859
|
let e = Number.POSITIVE_INFINITY, r = Number.NEGATIVE_INFINITY, n = 0;
|
|
1847
1860
|
for (let s = 0; s < t.length; s += 1) {
|
|
1848
1861
|
const i = Number(t[s]);
|
|
@@ -1851,16 +1864,16 @@ function Ot(t) {
|
|
|
1851
1864
|
if (!n) throw new Error("栅格中没有可用于生成等值线的有效数值。");
|
|
1852
1865
|
return { min: e, max: r, validCount: n, noDataCount: t.length - n };
|
|
1853
1866
|
}
|
|
1854
|
-
function
|
|
1855
|
-
const r = Math.max(Math.floor(
|
|
1867
|
+
function Bt(t, e = we) {
|
|
1868
|
+
const r = Math.max(Math.floor(G(e, we)), 4);
|
|
1856
1869
|
if (t.width * t.height <= r)
|
|
1857
1870
|
return t;
|
|
1858
1871
|
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);
|
|
1859
1872
|
for (let a = 0; a < i; a += 1) {
|
|
1860
|
-
const
|
|
1861
|
-
for (let
|
|
1862
|
-
const
|
|
1863
|
-
o[a * s +
|
|
1873
|
+
const c = Math.round(a / Math.max(i - 1, 1) * (t.height - 1));
|
|
1874
|
+
for (let l = 0; l < s; l += 1) {
|
|
1875
|
+
const u = Math.round(l / Math.max(s - 1, 1) * (t.width - 1));
|
|
1876
|
+
o[a * s + l] = t.values[c * t.width + u];
|
|
1864
1877
|
}
|
|
1865
1878
|
}
|
|
1866
1879
|
return {
|
|
@@ -1868,10 +1881,10 @@ function Dt(t, e = we) {
|
|
|
1868
1881
|
width: s,
|
|
1869
1882
|
height: i,
|
|
1870
1883
|
values: o,
|
|
1871
|
-
mapCoordinate(a,
|
|
1884
|
+
mapCoordinate(a, c) {
|
|
1872
1885
|
return t.mapCoordinate(
|
|
1873
1886
|
a / s * t.width,
|
|
1874
|
-
|
|
1887
|
+
c / i * t.height
|
|
1875
1888
|
);
|
|
1876
1889
|
},
|
|
1877
1890
|
downsampled: !0,
|
|
@@ -1883,11 +1896,11 @@ function Pe(t, e = 10) {
|
|
|
1883
1896
|
const r = 10 ** e;
|
|
1884
1897
|
return Math.round(t * r) / r;
|
|
1885
1898
|
}
|
|
1886
|
-
function
|
|
1899
|
+
function Ut(t, e = {}) {
|
|
1887
1900
|
const r = e.thresholds || e.levels;
|
|
1888
1901
|
if (Array.isArray(r))
|
|
1889
1902
|
return [...new Set(r.map(Number).filter(Number.isFinite))].filter((o) => o > t.min && o < t.max).sort((o, a) => o - a);
|
|
1890
|
-
const n =
|
|
1903
|
+
const n = G(e.interval ?? e.contourInterval);
|
|
1891
1904
|
if (n !== null && n > 0) {
|
|
1892
1905
|
const o = [];
|
|
1893
1906
|
let a = Math.ceil(t.min / n) * n;
|
|
@@ -1896,7 +1909,7 @@ function Vt(t, e = {}) {
|
|
|
1896
1909
|
return o;
|
|
1897
1910
|
}
|
|
1898
1911
|
const s = Math.min(
|
|
1899
|
-
Math.max(Math.floor(
|
|
1912
|
+
Math.max(Math.floor(G(e.thresholdCount ?? e.levelCount, 12)), 1),
|
|
1900
1913
|
100
|
|
1901
1914
|
), i = (t.max - t.min) / (s + 1);
|
|
1902
1915
|
return Array.from(
|
|
@@ -1907,27 +1920,27 @@ function Vt(t, e = {}) {
|
|
|
1907
1920
|
function jt(t, e, r, n) {
|
|
1908
1921
|
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;
|
|
1909
1922
|
}
|
|
1910
|
-
function
|
|
1923
|
+
function zt(t = [], e, r) {
|
|
1911
1924
|
const n = [...t];
|
|
1912
1925
|
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 [];
|
|
1913
1926
|
const s = n.map(
|
|
1914
|
-
(
|
|
1927
|
+
(c, l) => jt(c, n[(l + 1) % n.length], e, r)
|
|
1915
1928
|
), i = s.findIndex(Boolean);
|
|
1916
1929
|
if (i < 0)
|
|
1917
1930
|
return [[...n, n[0]]];
|
|
1918
1931
|
const o = [];
|
|
1919
1932
|
let a = [];
|
|
1920
|
-
for (let
|
|
1921
|
-
const
|
|
1922
|
-
if (s[
|
|
1933
|
+
for (let c = 1; c <= n.length; c += 1) {
|
|
1934
|
+
const l = (i + c) % n.length, u = (l + 1) % n.length;
|
|
1935
|
+
if (s[l]) {
|
|
1923
1936
|
a.length > 1 && o.push(a), a = [];
|
|
1924
1937
|
continue;
|
|
1925
1938
|
}
|
|
1926
|
-
a.length === 0 && a.push(n[
|
|
1939
|
+
a.length === 0 && a.push(n[l]), a.push(n[u]);
|
|
1927
1940
|
}
|
|
1928
1941
|
return a.length > 1 && o.push(a), o;
|
|
1929
1942
|
}
|
|
1930
|
-
function
|
|
1943
|
+
function Vt(t = {}) {
|
|
1931
1944
|
return t.type === "Polygon" ? t.coordinates || [] : t.type === "MultiPolygon" ? (t.coordinates || []).flatMap((e) => e) : [];
|
|
1932
1945
|
}
|
|
1933
1946
|
function _t(t, e) {
|
|
@@ -1940,14 +1953,14 @@ function Wt(t = [], e = 0) {
|
|
|
1940
1953
|
let s = n ? t.slice(0, -1) : [...t];
|
|
1941
1954
|
for (let i = 0; i < r; i += 1) {
|
|
1942
1955
|
const o = n ? [] : [s[0]], a = n ? s.length : s.length - 1;
|
|
1943
|
-
for (let
|
|
1944
|
-
const
|
|
1956
|
+
for (let c = 0; c < a; c += 1) {
|
|
1957
|
+
const l = s[c], u = s[(c + 1) % s.length];
|
|
1945
1958
|
o.push([
|
|
1946
|
-
|
|
1947
|
-
|
|
1959
|
+
l[0] * 0.75 + u[0] * 0.25,
|
|
1960
|
+
l[1] * 0.75 + u[1] * 0.25
|
|
1948
1961
|
]), o.push([
|
|
1949
|
-
|
|
1950
|
-
|
|
1962
|
+
l[0] * 0.25 + u[0] * 0.75,
|
|
1963
|
+
l[1] * 0.25 + u[1] * 0.75
|
|
1951
1964
|
]);
|
|
1952
1965
|
}
|
|
1953
1966
|
n || o.push(s[s.length - 1]), s = o;
|
|
@@ -1959,41 +1972,41 @@ function $t(t, e, r = 6) {
|
|
|
1959
1972
|
return t.forEach((i) => {
|
|
1960
1973
|
const o = e(i[0], i[1]);
|
|
1961
1974
|
if (!(o != null && o.every(Number.isFinite))) return;
|
|
1962
|
-
const a = o.map((
|
|
1963
|
-
(!
|
|
1975
|
+
const a = o.map((l) => Math.round(l * n) / n), c = s[s.length - 1];
|
|
1976
|
+
(!c || c[0] !== a[0] || c[1] !== a[1]) && s.push(a);
|
|
1964
1977
|
}), s;
|
|
1965
1978
|
}
|
|
1966
1979
|
function kt(t, e = {}) {
|
|
1967
|
-
const r =
|
|
1980
|
+
const r = Dt(t.values);
|
|
1968
1981
|
if (r.min === r.max)
|
|
1969
1982
|
throw new Error("栅格数值全部相同,无法生成等值线。");
|
|
1970
|
-
const n =
|
|
1983
|
+
const n = Bt(t, e.maxCells), s = Ut(r, e);
|
|
1971
1984
|
if (s.length === 0)
|
|
1972
1985
|
throw new Error("当前值域内没有可用的等值线级别。");
|
|
1973
1986
|
const i = vt().size([n.width, n.height]).smooth(e.smooth !== !1).thresholds(s)(n.values), o = Math.max(
|
|
1974
|
-
Math.floor(
|
|
1987
|
+
Math.floor(G(e.minimumLinePoints, 3)),
|
|
1975
1988
|
2
|
|
1976
1989
|
), a = Math.min(
|
|
1977
|
-
Math.max(Math.floor(
|
|
1990
|
+
Math.max(Math.floor(G(e.smoothingIterations, 0)), 0),
|
|
1978
1991
|
3
|
|
1979
|
-
),
|
|
1980
|
-
const
|
|
1981
|
-
(
|
|
1982
|
-
).map((
|
|
1992
|
+
), c = i.map((l) => {
|
|
1993
|
+
const h = Vt(l).flatMap(
|
|
1994
|
+
(d) => e.excludeBoundary === !1 ? [d] : zt(d, n.width, n.height)
|
|
1995
|
+
).map((d) => Wt(d, a)).map((d) => $t(d, n.mapCoordinate, e.coordinatePrecision)).filter((d) => d.length >= o);
|
|
1983
1996
|
return {
|
|
1984
|
-
value:
|
|
1985
|
-
label: String(
|
|
1986
|
-
lines:
|
|
1997
|
+
value: l.value,
|
|
1998
|
+
label: String(l.value),
|
|
1999
|
+
lines: h
|
|
1987
2000
|
};
|
|
1988
2001
|
});
|
|
1989
2002
|
return {
|
|
1990
|
-
isolines:
|
|
2003
|
+
isolines: c,
|
|
1991
2004
|
thresholds: s,
|
|
1992
2005
|
range: r,
|
|
1993
2006
|
renderWidth: n.width,
|
|
1994
2007
|
renderHeight: n.height,
|
|
1995
2008
|
downsampled: !!n.downsampled,
|
|
1996
|
-
lineCount:
|
|
2009
|
+
lineCount: c.reduce((l, u) => l + u.lines.length, 0)
|
|
1997
2010
|
};
|
|
1998
2011
|
}
|
|
1999
2012
|
const qt = /* @__PURE__ */ new Set([
|
|
@@ -2073,24 +2086,26 @@ function Yt(t = {}) {
|
|
|
2073
2086
|
const { mapCore: e, baseGIS: r, ...n } = t;
|
|
2074
2087
|
return n;
|
|
2075
2088
|
}
|
|
2076
|
-
function Kt(t, e) {
|
|
2077
|
-
const
|
|
2078
|
-
return Object.entries(t).forEach(([
|
|
2079
|
-
qt.has(
|
|
2089
|
+
function Kt(t, e, r = null) {
|
|
2090
|
+
const n = {};
|
|
2091
|
+
return Object.entries(t).forEach(([s, i]) => {
|
|
2092
|
+
qt.has(s) || (n[s] = i);
|
|
2080
2093
|
}), {
|
|
2081
|
-
...
|
|
2094
|
+
...n,
|
|
2082
2095
|
layerId: t.layerId || t.contourLayerId || "raster-contour-default",
|
|
2083
2096
|
coordinateOrder: "latlng",
|
|
2097
|
+
// Leaflet 使用栅格真实范围动态创建当前视野需要的世界副本。
|
|
2098
|
+
worldCopyArea: t.worldCopyArea || r,
|
|
2084
2099
|
isolines: e
|
|
2085
2100
|
};
|
|
2086
2101
|
}
|
|
2087
|
-
function
|
|
2102
|
+
function B() {
|
|
2088
2103
|
return typeof performance < "u" ? performance.now() : Date.now();
|
|
2089
2104
|
}
|
|
2090
2105
|
function Xt(t = {}) {
|
|
2091
2106
|
return Object.keys(t).some((e) => Ht.has(e));
|
|
2092
2107
|
}
|
|
2093
|
-
class
|
|
2108
|
+
class Sr {
|
|
2094
2109
|
constructor(e = {}) {
|
|
2095
2110
|
const r = Yt(e), n = r.layerId || r.contourLayerId || "raster-contour-default";
|
|
2096
2111
|
this.defaultPayload = {
|
|
@@ -2139,15 +2154,15 @@ class Lr {
|
|
|
2139
2154
|
}
|
|
2140
2155
|
resolveBaseGIS() {
|
|
2141
2156
|
var e, r;
|
|
2142
|
-
return this.baseGIS ? (r = (e = this.baseGIS).getMapInstance) != null && r.call(e) ?
|
|
2157
|
+
return this.baseGIS ? (r = (e = this.baseGIS).getMapInstance) != null && r.call(e) ? L(null, "BaseGIS is ready.") : I(
|
|
2143
2158
|
"Map instance is not ready. Please call mapCore.init() first.",
|
|
2144
2159
|
"NOT_INITIALIZED"
|
|
2145
|
-
) :
|
|
2160
|
+
) : I("RasterContourController has not been mounted.", "NOT_MOUNTED");
|
|
2146
2161
|
}
|
|
2147
2162
|
async renderGrid(e, r, n, s, i = !1, o = 0) {
|
|
2148
2163
|
var p;
|
|
2149
|
-
const a =
|
|
2150
|
-
|
|
2164
|
+
const a = B(), c = kt(e, r), l = B() - a, u = Kt(r, c.isolines, e.area), h = u.onStateChange;
|
|
2165
|
+
u.onStateChange = (m) => {
|
|
2151
2166
|
n === this.operationId && (this.state = {
|
|
2152
2167
|
...this.state,
|
|
2153
2168
|
lineCount: (m == null ? void 0 : m.lineCount) ?? this.state.lineCount,
|
|
@@ -2157,50 +2172,50 @@ class Lr {
|
|
|
2157
2172
|
labelLayoutElapsed: (m == null ? void 0 : m.labelLayoutElapsed) ?? this.state.labelLayoutElapsed,
|
|
2158
2173
|
primitiveReadyElapsed: (m == null ? void 0 : m.primitiveReadyElapsed) ?? this.state.primitiveReadyElapsed,
|
|
2159
2174
|
visible: (m == null ? void 0 : m.visible) ?? this.state.visible
|
|
2160
|
-
},
|
|
2175
|
+
}, h == null || h(m));
|
|
2161
2176
|
};
|
|
2162
|
-
const
|
|
2177
|
+
const d = B(), f = i ? await this.contourController.update(u) : await this.contourController.load(u), y = B() - d;
|
|
2163
2178
|
if (!f.success) return f;
|
|
2164
2179
|
if (n !== this.operationId)
|
|
2165
|
-
return
|
|
2166
|
-
const
|
|
2180
|
+
return L({ stale: !0, ignored: !0 }, "Raster contour render was superseded.");
|
|
2181
|
+
const b = B() - s, g = ((p = f.data) == null ? void 0 : p.state) || f.data || null;
|
|
2167
2182
|
return this.currentPayload = r, this.currentGrid = e, this.state = {
|
|
2168
2183
|
...this.state,
|
|
2169
|
-
layerId:
|
|
2184
|
+
layerId: u.layerId,
|
|
2170
2185
|
sourceType: e.sourceType,
|
|
2171
2186
|
sourceUrl: e.sourceUrl,
|
|
2172
2187
|
sourceProjection: e.sourceProjection,
|
|
2173
2188
|
projection: e.projection,
|
|
2174
2189
|
width: e.width,
|
|
2175
2190
|
height: e.height,
|
|
2176
|
-
renderWidth:
|
|
2177
|
-
renderHeight:
|
|
2178
|
-
min:
|
|
2179
|
-
max:
|
|
2180
|
-
validCount:
|
|
2181
|
-
noDataCount:
|
|
2182
|
-
levelCount:
|
|
2183
|
-
lineCount:
|
|
2191
|
+
renderWidth: c.renderWidth,
|
|
2192
|
+
renderHeight: c.renderHeight,
|
|
2193
|
+
min: c.range.min,
|
|
2194
|
+
max: c.range.max,
|
|
2195
|
+
validCount: c.range.validCount,
|
|
2196
|
+
noDataCount: c.range.noDataCount,
|
|
2197
|
+
levelCount: c.thresholds.length,
|
|
2198
|
+
lineCount: c.lineCount,
|
|
2184
2199
|
labelCount: (g == null ? void 0 : g.labelCount) || 0,
|
|
2185
2200
|
lineRenderer: (g == null ? void 0 : g.lineRenderer) || "",
|
|
2186
|
-
thresholds:
|
|
2201
|
+
thresholds: c.thresholds,
|
|
2187
2202
|
area: e.area,
|
|
2188
2203
|
sourceElapsed: o,
|
|
2189
|
-
generateElapsed:
|
|
2204
|
+
generateElapsed: l,
|
|
2190
2205
|
renderElapsed: y,
|
|
2191
2206
|
lineBuildElapsed: (g == null ? void 0 : g.lineBuildElapsed) || 0,
|
|
2192
2207
|
labelLayoutElapsed: (g == null ? void 0 : g.labelLayoutElapsed) || 0,
|
|
2193
2208
|
primitiveReadyElapsed: (g == null ? void 0 : g.primitiveReadyElapsed) || 0,
|
|
2194
|
-
elapsed:
|
|
2195
|
-
downsampled:
|
|
2196
|
-
visible:
|
|
2209
|
+
elapsed: b,
|
|
2210
|
+
downsampled: c.downsampled,
|
|
2211
|
+
visible: u.visible !== !1,
|
|
2197
2212
|
loaded: !0
|
|
2198
|
-
},
|
|
2213
|
+
}, L(
|
|
2199
2214
|
{
|
|
2200
2215
|
...this.getState(),
|
|
2201
2216
|
contourState: g
|
|
2202
2217
|
},
|
|
2203
|
-
i ? `Raster contour layer "${
|
|
2218
|
+
i ? `Raster contour layer "${u.layerId}" regenerated.` : `Raster contour layer "${u.layerId}" loaded.`
|
|
2204
2219
|
);
|
|
2205
2220
|
}
|
|
2206
2221
|
async load(e = {}, r = {}) {
|
|
@@ -2211,19 +2226,19 @@ class Lr {
|
|
|
2211
2226
|
...this.currentPayload || {},
|
|
2212
2227
|
...e,
|
|
2213
2228
|
...r
|
|
2214
|
-
}, i = ++this.operationId, o =
|
|
2229
|
+
}, i = ++this.operationId, o = B();
|
|
2215
2230
|
try {
|
|
2216
|
-
const a = await
|
|
2217
|
-
return i !== this.operationId ?
|
|
2231
|
+
const a = await Ot(s), c = B() - o;
|
|
2232
|
+
return i !== this.operationId ? L({ stale: !0, ignored: !0 }, "Raster contour load was superseded.") : this.renderGrid(
|
|
2218
2233
|
a,
|
|
2219
2234
|
s,
|
|
2220
2235
|
i,
|
|
2221
2236
|
o,
|
|
2222
2237
|
!1,
|
|
2223
|
-
|
|
2238
|
+
c
|
|
2224
2239
|
);
|
|
2225
2240
|
} catch (a) {
|
|
2226
|
-
return
|
|
2241
|
+
return I(
|
|
2227
2242
|
(a == null ? void 0 : a.message) || "Raster contour generation failed.",
|
|
2228
2243
|
"RASTER_CONTOUR_FAILED"
|
|
2229
2244
|
);
|
|
@@ -2240,7 +2255,7 @@ class Lr {
|
|
|
2240
2255
|
}
|
|
2241
2256
|
async update(e = {}) {
|
|
2242
2257
|
if (!this.currentPayload || !this.currentGrid)
|
|
2243
|
-
return
|
|
2258
|
+
return I("Raster contour source has not been loaded.", "NOT_LOADED");
|
|
2244
2259
|
if (Xt(e))
|
|
2245
2260
|
return this.load(e);
|
|
2246
2261
|
const r = this.resolveBaseGIS();
|
|
@@ -2248,7 +2263,7 @@ class Lr {
|
|
|
2248
2263
|
const n = {
|
|
2249
2264
|
...this.currentPayload,
|
|
2250
2265
|
...e
|
|
2251
|
-
}, s = ++this.operationId, i =
|
|
2266
|
+
}, s = ++this.operationId, i = B();
|
|
2252
2267
|
try {
|
|
2253
2268
|
return await this.renderGrid(
|
|
2254
2269
|
this.currentGrid,
|
|
@@ -2258,7 +2273,7 @@ class Lr {
|
|
|
2258
2273
|
!0
|
|
2259
2274
|
);
|
|
2260
2275
|
} catch (o) {
|
|
2261
|
-
return
|
|
2276
|
+
return I(
|
|
2262
2277
|
(o == null ? void 0 : o.message) || "Raster contour regeneration failed.",
|
|
2263
2278
|
"RASTER_CONTOUR_FAILED"
|
|
2264
2279
|
);
|
|
@@ -2319,7 +2334,7 @@ function Zt(t) {
|
|
|
2319
2334
|
return e > 90 && (e -= 180), e < -90 && (e += 180), e;
|
|
2320
2335
|
}
|
|
2321
2336
|
function Jt(t, e = 0) {
|
|
2322
|
-
return
|
|
2337
|
+
return O.divIcon({
|
|
2323
2338
|
className: "pressure-label-icon",
|
|
2324
2339
|
html: `<span style="transform: translate(-50%, -50%) rotate(${Zt(e)}deg)">${t}</span>`,
|
|
2325
2340
|
iconSize: [0, 0],
|
|
@@ -2327,7 +2342,7 @@ function Jt(t, e = 0) {
|
|
|
2327
2342
|
});
|
|
2328
2343
|
}
|
|
2329
2344
|
function Qt(t) {
|
|
2330
|
-
return
|
|
2345
|
+
return O.divIcon({
|
|
2331
2346
|
className: `pressure-center-icon pressure-center-icon--${t.type.toLowerCase()}`,
|
|
2332
2347
|
html: `<span class="pressure-center-icon__type">${t.type}</span><span class="pressure-center-icon__value">${t.value}</span>`,
|
|
2333
2348
|
iconSize: [0, 0],
|
|
@@ -2347,7 +2362,7 @@ function ae(t, e, r) {
|
|
|
2347
2362
|
bottom: t.y + r
|
|
2348
2363
|
};
|
|
2349
2364
|
}
|
|
2350
|
-
function
|
|
2365
|
+
function Ge(t, e, r = 18, n = 10) {
|
|
2351
2366
|
t.sort((s, i) => s.score - i.score);
|
|
2352
2367
|
for (let s = 0; s < t.length; s += 1) {
|
|
2353
2368
|
const i = t[s], o = ae(i.point, r, n);
|
|
@@ -2356,7 +2371,7 @@ function Me(t, e, r = 18, n = 10) {
|
|
|
2356
2371
|
}
|
|
2357
2372
|
return null;
|
|
2358
2373
|
}
|
|
2359
|
-
function
|
|
2374
|
+
function Me(t = [], e = 0) {
|
|
2360
2375
|
return e ? t.map((r) => [r[0], r[1] + e]) : t;
|
|
2361
2376
|
}
|
|
2362
2377
|
function er(t = [], e = 2) {
|
|
@@ -2400,8 +2415,8 @@ function sr(t = [], e = 5) {
|
|
|
2400
2415
|
const r = [t[0]];
|
|
2401
2416
|
for (let n = 0; n < t.length - 1; n += 1) {
|
|
2402
2417
|
const s = t[n - 1] || t[n], i = t[n], o = t[n + 1], a = t[n + 2] || o;
|
|
2403
|
-
for (let
|
|
2404
|
-
r.push(nr(s, i, o, a,
|
|
2418
|
+
for (let c = 1; c <= e; c += 1)
|
|
2419
|
+
r.push(nr(s, i, o, a, c / e));
|
|
2405
2420
|
}
|
|
2406
2421
|
return r;
|
|
2407
2422
|
}
|
|
@@ -2416,12 +2431,12 @@ function ir(t = {}) {
|
|
|
2416
2431
|
};
|
|
2417
2432
|
}), r = ["high", "low"].flatMap((n) => {
|
|
2418
2433
|
const s = t[n] || {}, i = Array.isArray(s.value) ? s.value : [], o = Array.isArray(s.points) ? s.points : [], a = [];
|
|
2419
|
-
for (let
|
|
2434
|
+
for (let c = 0; c < o.length - 1; c += 2)
|
|
2420
2435
|
a.push({
|
|
2421
2436
|
type: n === "high" ? "H" : "L",
|
|
2422
|
-
value: Te(i[
|
|
2423
|
-
lat: Number(o[
|
|
2424
|
-
lon: tr(o[
|
|
2437
|
+
value: Te(i[c / 2]),
|
|
2438
|
+
lat: Number(o[c]),
|
|
2439
|
+
lon: tr(o[c + 1])
|
|
2425
2440
|
});
|
|
2426
2441
|
return a;
|
|
2427
2442
|
});
|
|
@@ -2470,7 +2485,7 @@ class or {
|
|
|
2470
2485
|
return;
|
|
2471
2486
|
}
|
|
2472
2487
|
const e = (a = (o = this.mapCore) == null ? void 0 : o.getMapInstance) == null ? void 0 : a.call(o);
|
|
2473
|
-
e && (this.labelLayerGroup =
|
|
2488
|
+
e && (this.labelLayerGroup = O.layerGroup().addTo(e), e.on("moveend zoomend resize", this.scheduleUpdate, this));
|
|
2474
2489
|
}
|
|
2475
2490
|
// 地图连续移动时只在下一帧刷新一次标签,减少重复碰撞计算。
|
|
2476
2491
|
scheduleUpdate() {
|
|
@@ -2504,13 +2519,13 @@ class or {
|
|
|
2504
2519
|
}
|
|
2505
2520
|
// Cesium 3D 球面下,屏幕外或地球背面的点不参与标签候选。
|
|
2506
2521
|
isCesiumPointVisible(e) {
|
|
2507
|
-
var u,
|
|
2508
|
-
const r = (
|
|
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;
|
|
2509
2524
|
if (!r || !n || !s)
|
|
2510
2525
|
return !1;
|
|
2511
2526
|
if (this.getCesiumSceneMode() !== n.SceneMode.SCENE3D)
|
|
2512
2527
|
return !0;
|
|
2513
|
-
const i = ((
|
|
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);
|
|
2514
2529
|
if (!i || !o)
|
|
2515
2530
|
return !0;
|
|
2516
2531
|
const a = n.Cartesian3.fromDegrees(e[1], e[0], 0);
|
|
@@ -2554,7 +2569,7 @@ class or {
|
|
|
2554
2569
|
});
|
|
2555
2570
|
if (!(r != null && r.success))
|
|
2556
2571
|
return null;
|
|
2557
|
-
const n =
|
|
2572
|
+
const n = O.point(r.data.x, r.data.y);
|
|
2558
2573
|
return this.isCesiumScreenPointInViewport(n) ? n : null;
|
|
2559
2574
|
}
|
|
2560
2575
|
// Cesium 添加单个标签,中心点标签和线值标签共用该方法。
|
|
@@ -2585,11 +2600,11 @@ class or {
|
|
|
2585
2600
|
let s = 0;
|
|
2586
2601
|
return e.centers.forEach((i) => {
|
|
2587
2602
|
this.cesiumWorldCopyOffsets.forEach((o) => {
|
|
2588
|
-
const a = [i.lat, i.lon + o],
|
|
2589
|
-
if (!
|
|
2603
|
+
const a = [i.lat, i.lon + o], c = this.projectCesiumPoint(a);
|
|
2604
|
+
if (!c)
|
|
2590
2605
|
return;
|
|
2591
|
-
const
|
|
2592
|
-
oe(r,
|
|
2606
|
+
const l = ae(c, 18, 20);
|
|
2607
|
+
oe(r, l) || (r.push(l), this.addCesiumLabel(a, `${i.type}
|
|
2593
2608
|
${i.value}`, {
|
|
2594
2609
|
font: "700 18px Arial",
|
|
2595
2610
|
fillColor: n.Color.fromCssColorString(i.type === "H" ? "#efb7ff" : "#e3f8ff"),
|
|
@@ -2602,21 +2617,21 @@ ${i.value}`, {
|
|
|
2602
2617
|
}
|
|
2603
2618
|
// Leaflet H/L 中心点标注,按当前视野过滤后再做碰撞检测。
|
|
2604
2619
|
addLeafletCenters(e, r) {
|
|
2605
|
-
var o, a,
|
|
2606
|
-
const n = (a = (o = this.mapCore) == null ? void 0 : o.getMapInstance) == null ? void 0 : a.call(o), s = (
|
|
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);
|
|
2607
2622
|
if (!n || !s || !this.labelLayerGroup)
|
|
2608
2623
|
return 0;
|
|
2609
2624
|
let i = 0;
|
|
2610
|
-
return e.centers.forEach((
|
|
2611
|
-
this.worldCopyOffsets.forEach((
|
|
2612
|
-
const
|
|
2613
|
-
if (!s.contains(
|
|
2625
|
+
return e.centers.forEach((u) => {
|
|
2626
|
+
this.worldCopyOffsets.forEach((h) => {
|
|
2627
|
+
const d = [u.lat, u.lon + h];
|
|
2628
|
+
if (!s.contains(d))
|
|
2614
2629
|
return;
|
|
2615
|
-
const f = n.latLngToContainerPoint(
|
|
2616
|
-
oe(r, y) || (r.push(y),
|
|
2630
|
+
const f = n.latLngToContainerPoint(d), y = ae(f, 16, 18);
|
|
2631
|
+
oe(r, y) || (r.push(y), O.marker(d, {
|
|
2617
2632
|
interactive: !1,
|
|
2618
2633
|
keyboard: !1,
|
|
2619
|
-
icon: Qt(
|
|
2634
|
+
icon: Qt(u),
|
|
2620
2635
|
zIndexOffset: 140
|
|
2621
2636
|
}).addTo(this.labelLayerGroup), i += 1);
|
|
2622
2637
|
});
|
|
@@ -2624,20 +2639,20 @@ ${i.value}`, {
|
|
|
2624
2639
|
}
|
|
2625
2640
|
// 线值标签统一从折线中采样候选点,再按离视野中心的距离排序。
|
|
2626
2641
|
getLineLabelCandidates(e, r = {}) {
|
|
2627
|
-
const { bounds: n, useSegmentMidpoint: s = !1, viewCenter: i, projectPoint: o } = r, a = [],
|
|
2628
|
-
for (let
|
|
2629
|
-
const
|
|
2630
|
-
(
|
|
2631
|
-
(
|
|
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
|
|
2632
2647
|
];
|
|
2633
|
-
if (n && !n.contains(
|
|
2648
|
+
if (n && !n.contains(d))
|
|
2634
2649
|
continue;
|
|
2635
|
-
const f = o(
|
|
2636
|
-
if (!f || !y || !
|
|
2650
|
+
const f = o(u), y = o(h), b = o(d);
|
|
2651
|
+
if (!f || !y || !b)
|
|
2637
2652
|
continue;
|
|
2638
|
-
const g = s ?
|
|
2653
|
+
const g = s ? O.point((f.x + y.x) / 2, (f.y + y.y) / 2) : b;
|
|
2639
2654
|
a.push({
|
|
2640
|
-
position:
|
|
2655
|
+
position: d,
|
|
2641
2656
|
point: g,
|
|
2642
2657
|
angle: Math.atan2(y.y - f.y, y.x - f.x) * 180 / Math.PI,
|
|
2643
2658
|
score: g.distanceTo(i)
|
|
@@ -2647,25 +2662,25 @@ ${i.value}`, {
|
|
|
2647
2662
|
}
|
|
2648
2663
|
// Leaflet 线值标签:每条线选择靠近视野中心且不碰撞的位置。
|
|
2649
2664
|
addLeafletLineLabels(e, r) {
|
|
2650
|
-
var a, l, u
|
|
2651
|
-
const n = (
|
|
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);
|
|
2652
2667
|
if (!n || !s || !this.labelLayerGroup)
|
|
2653
2668
|
return 0;
|
|
2654
2669
|
const i = n.getSize().divideBy(2);
|
|
2655
2670
|
let o = 0;
|
|
2656
|
-
return e.isolines.forEach((
|
|
2657
|
-
this.worldCopyOffsets.forEach((
|
|
2658
|
-
|
|
2659
|
-
const y =
|
|
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, {
|
|
2660
2675
|
bounds: s,
|
|
2661
2676
|
useSegmentMidpoint: !0,
|
|
2662
2677
|
viewCenter: i,
|
|
2663
2678
|
projectPoint: (g) => n.latLngToContainerPoint(g)
|
|
2664
2679
|
}), r);
|
|
2665
|
-
|
|
2680
|
+
b && (O.marker(b.position, {
|
|
2666
2681
|
interactive: !1,
|
|
2667
2682
|
keyboard: !1,
|
|
2668
|
-
icon: Jt(
|
|
2683
|
+
icon: Jt(h.hpa, b.angle),
|
|
2669
2684
|
zIndexOffset: 120
|
|
2670
2685
|
}).addTo(this.labelLayerGroup), o += 1);
|
|
2671
2686
|
});
|
|
@@ -2675,15 +2690,15 @@ ${i.value}`, {
|
|
|
2675
2690
|
// Cesium 线值标签:先将候选点投影到屏幕,再按距离和碰撞筛选。
|
|
2676
2691
|
addCesiumLineLabels(e, r) {
|
|
2677
2692
|
let n = 0;
|
|
2678
|
-
const s = document.getElementById(this.mapContainerId), i =
|
|
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);
|
|
2679
2694
|
return e.isolines.forEach((o) => {
|
|
2680
2695
|
this.cesiumWorldCopyOffsets.forEach((a) => {
|
|
2681
|
-
o.lines.forEach((
|
|
2682
|
-
const
|
|
2696
|
+
o.lines.forEach((c) => {
|
|
2697
|
+
const l = er(Me(c, a), this.cesiumLineThinStep), u = Ge(this.getLineLabelCandidates(l, {
|
|
2683
2698
|
viewCenter: i,
|
|
2684
|
-
projectPoint: (
|
|
2699
|
+
projectPoint: (h) => this.projectCesiumPoint(h)
|
|
2685
2700
|
}), r);
|
|
2686
|
-
|
|
2701
|
+
u && (this.addCesiumLabel(u.position, String(o.hpa), {
|
|
2687
2702
|
font: "12px Arial"
|
|
2688
2703
|
}), n += 1);
|
|
2689
2704
|
});
|
|
@@ -2692,8 +2707,8 @@ ${i.value}`, {
|
|
|
2692
2707
|
}
|
|
2693
2708
|
// 重建 Cesium 全部标签,并请求场景刷新。
|
|
2694
2709
|
updateCesiumLabels() {
|
|
2695
|
-
var a, l, u,
|
|
2696
|
-
const e = (
|
|
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);
|
|
2697
2712
|
if (!r)
|
|
2698
2713
|
return this.clear(), 0;
|
|
2699
2714
|
const n = this.cesiumLabelCollection;
|
|
@@ -2704,26 +2719,26 @@ ${i.value}`, {
|
|
|
2704
2719
|
const i = [];
|
|
2705
2720
|
let o = 0;
|
|
2706
2721
|
try {
|
|
2707
|
-
o = this.addCesiumCenters(r, i) + this.addCesiumLineLabels(r, i), n && n !== s && ((
|
|
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);
|
|
2708
2723
|
} catch (g) {
|
|
2709
|
-
throw (f = (
|
|
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;
|
|
2710
2725
|
}
|
|
2711
|
-
return this.emitStateChange(o), (
|
|
2726
|
+
return this.emitStateChange(o), (b = (y = e == null ? void 0 : e.scene) == null ? void 0 : y.requestRender) == null || b.call(y), o;
|
|
2712
2727
|
}
|
|
2713
2728
|
// 重建 Leaflet 全部标签和 marker。
|
|
2714
2729
|
updateLeafletLabels() {
|
|
2715
|
-
var a,
|
|
2716
|
-
const e = (a = this.getData) == null ? void 0 : a.call(this), r = (
|
|
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);
|
|
2717
2732
|
if (!e || !r || !this.labelLayerGroup)
|
|
2718
2733
|
return this.clear(), 0;
|
|
2719
|
-
const n = this.labelLayerGroup, s =
|
|
2734
|
+
const n = this.labelLayerGroup, s = O.layerGroup();
|
|
2720
2735
|
this.labelLayerGroup = s;
|
|
2721
2736
|
const i = [];
|
|
2722
2737
|
let o = 0;
|
|
2723
2738
|
try {
|
|
2724
2739
|
o = this.addLeafletCenters(e, i) + this.addLeafletLineLabels(e, i), s.addTo(r), n == null || n.remove();
|
|
2725
|
-
} catch (
|
|
2726
|
-
throw s.remove(), this.labelLayerGroup = n,
|
|
2740
|
+
} catch (u) {
|
|
2741
|
+
throw s.remove(), this.labelLayerGroup = n, u;
|
|
2727
2742
|
}
|
|
2728
2743
|
return this.emitStateChange(o), o;
|
|
2729
2744
|
}
|
|
@@ -2815,62 +2830,6 @@ class wr {
|
|
|
2815
2830
|
this.annotationLayer.destroy(), this.contourController.destroy();
|
|
2816
2831
|
}
|
|
2817
2832
|
}
|
|
2818
|
-
class Q {
|
|
2819
|
-
constructor(e = {}) {
|
|
2820
|
-
this.rawData = e, this.bound = Array.isArray(e.Bound) ? e.Bound : [], this.data = Array.isArray(e.DataAry) ? e.DataAry : [], this.valid = !1, this.errorMessage = "", this.lonMin = 0, this.latMin = 0, this.lonMax = 0, this.latMax = 0, this.lonCount = 0, this.latCount = 0, this.lonSpan = 0, this.latSpan = 0, this.lonStep = 0, this.latStep = 0, this.valueScale = 1, this.parse();
|
|
2821
|
-
}
|
|
2822
|
-
parse() {
|
|
2823
|
-
if (this.bound.length < 6) {
|
|
2824
|
-
this.errorMessage = "Wind field Bound must contain at least 6 values.";
|
|
2825
|
-
return;
|
|
2826
|
-
}
|
|
2827
|
-
const [e, r, n, s, i, o, a = 1] = this.bound, l = Number(n) * Number(s) * 2;
|
|
2828
|
-
if (!Number.isFinite(Number(e)) || !Number.isFinite(Number(r)) || Number(n) < 2 || Number(s) < 2 || Number(i) <= 0 || Number(o) <= 0 || this.data.length !== l) {
|
|
2829
|
-
this.errorMessage = `Invalid wind field data. Expected DataAry length ${l}, got ${this.data.length}.`;
|
|
2830
|
-
return;
|
|
2831
|
-
}
|
|
2832
|
-
this.lonMin = Number(e), this.latMin = Number(r), this.lonCount = Number(n), this.latCount = Number(s), this.lonSpan = Number(i), this.latSpan = Number(o), this.valueScale = Number(a) || 1, this.lonMax = this.lonMin + this.lonSpan, this.latMax = this.latMin + this.latSpan, this.lonStep = this.lonSpan / (this.lonCount - 1), this.latStep = this.latSpan / (this.latCount - 1), this.valid = !0;
|
|
2833
|
-
}
|
|
2834
|
-
contains(e, r) {
|
|
2835
|
-
return Number.isFinite(e) && Number.isFinite(r) && e >= this.lonMin && e <= this.lonMax && r >= this.latMin && r <= this.latMax;
|
|
2836
|
-
}
|
|
2837
|
-
getBounds() {
|
|
2838
|
-
return {
|
|
2839
|
-
west: this.lonMin,
|
|
2840
|
-
south: this.latMin,
|
|
2841
|
-
east: this.lonMax,
|
|
2842
|
-
north: this.latMax
|
|
2843
|
-
};
|
|
2844
|
-
}
|
|
2845
|
-
getCenter() {
|
|
2846
|
-
return {
|
|
2847
|
-
lon: this.lonMin + this.lonSpan / 2,
|
|
2848
|
-
lat: this.latMin + this.latSpan / 2
|
|
2849
|
-
};
|
|
2850
|
-
}
|
|
2851
|
-
getVector(e, r) {
|
|
2852
|
-
const n = (e * this.lonCount + r) * 2;
|
|
2853
|
-
return {
|
|
2854
|
-
u: Number(this.data[n]) / this.valueScale,
|
|
2855
|
-
v: Number(this.data[n + 1]) / this.valueScale
|
|
2856
|
-
};
|
|
2857
|
-
}
|
|
2858
|
-
/**
|
|
2859
|
-
* 双线性插值。
|
|
2860
|
-
*
|
|
2861
|
-
* 数据约定为从左下角开始平铺,因此 row 直接对应从南到北的纬度索引。
|
|
2862
|
-
*/
|
|
2863
|
-
sample(e, r) {
|
|
2864
|
-
if (!this.valid || !this.contains(e, r))
|
|
2865
|
-
return null;
|
|
2866
|
-
const n = (e - this.lonMin) / this.lonStep, s = (r - this.latMin) / this.latStep, i = Math.max(0, Math.min(Math.floor(n), this.lonCount - 2)), o = Math.max(0, Math.min(Math.floor(s), this.latCount - 2)), a = i + 1, l = o + 1, u = Math.max(0, Math.min(n - i, 1)), c = Math.max(0, Math.min(s - o, 1)), d = this.getVector(o, i), h = this.getVector(o, a), f = this.getVector(l, i), y = this.getVector(l, a), I = 1 - u, g = 1 - c, p = I * g, m = u * g, v = I * c, C = u * c, w = d.u * p + h.u * m + f.u * v + y.u * C, x = d.v * p + h.v * m + f.v * v + y.v * C;
|
|
2867
|
-
return !Number.isFinite(w) || !Number.isFinite(x) ? null : {
|
|
2868
|
-
u: w,
|
|
2869
|
-
v: x,
|
|
2870
|
-
speed: Math.hypot(w, x)
|
|
2871
|
-
};
|
|
2872
|
-
}
|
|
2873
|
-
}
|
|
2874
2833
|
const xe = [
|
|
2875
2834
|
{ value: 0, color: [36, 88, 190] },
|
|
2876
2835
|
{ value: 2, color: [36, 145, 184] },
|
|
@@ -2887,7 +2846,7 @@ const xe = [
|
|
|
2887
2846
|
{ value: 14, color: [255, 166, 156] },
|
|
2888
2847
|
{ value: 18, color: [232, 153, 255] }
|
|
2889
2848
|
];
|
|
2890
|
-
function
|
|
2849
|
+
function w(t, e, r) {
|
|
2891
2850
|
return Math.min(Math.max(t, e), r);
|
|
2892
2851
|
}
|
|
2893
2852
|
function ar(t) {
|
|
@@ -2923,9 +2882,9 @@ function lr(t, e) {
|
|
|
2923
2882
|
for (let r = 1; r < t.length; r += 1) {
|
|
2924
2883
|
const n = t[r], s = t[r - 1];
|
|
2925
2884
|
if (e <= n.value) {
|
|
2926
|
-
const i = Math.max(n.value - s.value, 1e-4), o =
|
|
2885
|
+
const i = Math.max(n.value - s.value, 1e-4), o = w((e - s.value) / i, 0, 1);
|
|
2927
2886
|
return s.color.map(
|
|
2928
|
-
(a,
|
|
2887
|
+
(a, c) => Math.round(a + (n.color[c] - a) * o)
|
|
2929
2888
|
);
|
|
2930
2889
|
}
|
|
2931
2890
|
}
|
|
@@ -2933,9 +2892,9 @@ function lr(t, e) {
|
|
|
2933
2892
|
}
|
|
2934
2893
|
function ee(t, e) {
|
|
2935
2894
|
const [r, n, s] = t;
|
|
2936
|
-
return `rgba(${r}, ${n}, ${s}, ${
|
|
2895
|
+
return `rgba(${r}, ${n}, ${s}, ${w(e, 0, 1)})`;
|
|
2937
2896
|
}
|
|
2938
|
-
function
|
|
2897
|
+
function cr(t, e) {
|
|
2939
2898
|
if (!t || typeof t != "object")
|
|
2940
2899
|
return e;
|
|
2941
2900
|
const r = Number(t.west), n = Number(t.south), s = Number(t.east), i = Number(t.north);
|
|
@@ -2946,7 +2905,7 @@ function ur(t, e) {
|
|
|
2946
2905
|
north: Math.max(n, i)
|
|
2947
2906
|
} : e;
|
|
2948
2907
|
}
|
|
2949
|
-
function
|
|
2908
|
+
function ur(t, e) {
|
|
2950
2909
|
const r = {
|
|
2951
2910
|
west: Math.max(t.west, e.west),
|
|
2952
2911
|
south: Math.max(t.south, e.south),
|
|
@@ -2966,7 +2925,7 @@ function dr(t) {
|
|
|
2966
2925
|
}
|
|
2967
2926
|
class fr {
|
|
2968
2927
|
constructor(e = {}) {
|
|
2969
|
-
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
|
|
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 X ? e.grid : new X(e.data), this.options = {
|
|
2970
2929
|
zIndex: Number(e.zIndex ?? 30),
|
|
2971
2930
|
visible: e.visible !== !1,
|
|
2972
2931
|
running: e.running !== !1,
|
|
@@ -3019,7 +2978,7 @@ class fr {
|
|
|
3019
2978
|
resize() {
|
|
3020
2979
|
if (!this.canvas || !this.overlayCanvas || !this.container)
|
|
3021
2980
|
return;
|
|
3022
|
-
const e = this.container.getBoundingClientRect(), r =
|
|
2981
|
+
const e = this.container.getBoundingClientRect(), r = w(this.options.devicePixelRatio || 1, 1, 2), n = Math.max(1, Math.floor(e.width)), s = Math.max(1, Math.floor(e.height));
|
|
3023
2982
|
n === this.width && s === this.height || (this.width = n, this.height = s, [
|
|
3024
2983
|
[this.canvas, this.ctx],
|
|
3025
2984
|
[this.overlayCanvas, this.overlayCtx]
|
|
@@ -3043,7 +3002,7 @@ class fr {
|
|
|
3043
3002
|
}, e.colorScale !== void 0 && (this.colorScale = H(e.colorScale, xe), this.overlayDirty = !0), e.particleColorScale !== void 0 && (this.particleColorScale = H(
|
|
3044
3003
|
e.particleColorScale,
|
|
3045
3004
|
Ne
|
|
3046
|
-
)), 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
|
|
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 X(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();
|
|
3047
3006
|
}
|
|
3048
3007
|
refreshSpawnBounds() {
|
|
3049
3008
|
return this.spawnBoundsCache = this.getSpawnBounds(), this.invalidateProjectionGrid(), this.spawnBoundsCache;
|
|
@@ -3061,11 +3020,11 @@ class fr {
|
|
|
3061
3020
|
buildProjectionGrid(e = this.spawnBoundsCache) {
|
|
3062
3021
|
if (!this.shouldUseProjectionGrid() || !e)
|
|
3063
3022
|
return this.projectionGrid = null, null;
|
|
3064
|
-
const r =
|
|
3023
|
+
const r = w(Math.floor(this.options.projectionGridCols) || 32, 8, 96), n = w(Math.floor(this.options.projectionGridRows) || 20, 6, 64), s = [];
|
|
3065
3024
|
for (let i = 0; i <= n; i += 1)
|
|
3066
3025
|
for (let o = 0; o <= r; o += 1) {
|
|
3067
|
-
const a = e.west + (e.east - e.west) * (o / r),
|
|
3068
|
-
s.push(this.project(a,
|
|
3026
|
+
const a = e.west + (e.east - e.west) * (o / r), c = e.south + (e.north - e.south) * (i / n);
|
|
3027
|
+
s.push(this.project(a, c, this.options.height));
|
|
3069
3028
|
}
|
|
3070
3029
|
return this.projectionGrid = {
|
|
3071
3030
|
bounds: e,
|
|
@@ -3078,19 +3037,19 @@ class fr {
|
|
|
3078
3037
|
const n = this.projectionGrid || this.buildProjectionGrid(this.spawnBoundsCache);
|
|
3079
3038
|
if (!n || !n.bounds)
|
|
3080
3039
|
return this.project(e, r, this.options.height);
|
|
3081
|
-
const { bounds: s, cols: i, rows: o, nodes: a } = n,
|
|
3082
|
-
if (![v,
|
|
3040
|
+
const { bounds: s, cols: i, rows: o, nodes: a } = n, c = Math.max(s.east - s.west, 1e-4), l = Math.max(s.north - s.south, 1e-4), u = (e - s.west) / c * i, h = (r - s.south) / l * o, d = w(Math.floor(u), 0, i - 1), f = w(Math.floor(h), 0, o - 1), y = d + 1, b = f + 1, g = w(u - d, 0, 1), p = w(h - f, 0, 1), m = i + 1, v = a[f * m + d], S = a[f * m + y], P = a[b * m + d], A = a[b * m + y];
|
|
3041
|
+
if (![v, S, P, A].every(hr))
|
|
3083
3042
|
return this.project(e, r, this.options.height);
|
|
3084
|
-
const
|
|
3043
|
+
const M = 1 - g, T = 1 - p;
|
|
3085
3044
|
return {
|
|
3086
|
-
x: v.x *
|
|
3087
|
-
y: v.y *
|
|
3045
|
+
x: v.x * M * T + S.x * g * T + P.x * M * p + A.x * g * p,
|
|
3046
|
+
y: v.y * M * T + S.y * g * T + P.y * M * p + A.y * g * p
|
|
3088
3047
|
};
|
|
3089
3048
|
}
|
|
3090
3049
|
getSpawnBounds() {
|
|
3091
3050
|
var n;
|
|
3092
|
-
const e = this.grid.getBounds(), r =
|
|
3093
|
-
return
|
|
3051
|
+
const e = this.grid.getBounds(), r = cr((n = this.getViewBounds) == null ? void 0 : n.call(this), e);
|
|
3052
|
+
return ur(e, r) || e;
|
|
3094
3053
|
}
|
|
3095
3054
|
createParticle(e = this.spawnBoundsCache || this.refreshSpawnBounds()) {
|
|
3096
3055
|
if (!e)
|
|
@@ -3130,7 +3089,7 @@ class fr {
|
|
|
3130
3089
|
if (!this.isReady())
|
|
3131
3090
|
return;
|
|
3132
3091
|
this.clear();
|
|
3133
|
-
const e =
|
|
3092
|
+
const e = w(Math.floor(this.options.particleCount), 1, 8e3), r = this.refreshSpawnBounds();
|
|
3134
3093
|
this.particles = Array.from({ length: e }, () => this.createParticle(r)), this.particleCursor = 0, this.overlayDirty = !0, this.drawVelocityOverlay();
|
|
3135
3094
|
}
|
|
3136
3095
|
getParticleColorIndex(e) {
|
|
@@ -3149,32 +3108,32 @@ class fr {
|
|
|
3149
3108
|
const e = this.spawnBoundsCache || this.refreshSpawnBounds();
|
|
3150
3109
|
if (!e)
|
|
3151
3110
|
return;
|
|
3152
|
-
const r = this.overlayCtx, n =
|
|
3111
|
+
const r = this.overlayCtx, n = w(Number(this.options.velocityOverlayCellSize) || 54, 28, 96), s = w(Math.ceil(this.width / n), 10, 64), i = w(Math.ceil(this.height / n), 8, 48), o = (e.east - e.west) / s, a = (e.north - e.south) / i, c = n * 1.25, l = this.grid.getBounds();
|
|
3153
3112
|
r.save(), r.globalCompositeOperation = "source-over";
|
|
3154
|
-
for (let
|
|
3155
|
-
const
|
|
3156
|
-
for (let
|
|
3157
|
-
const f = e.west + (
|
|
3113
|
+
for (let u = 0; u < i; u += 1) {
|
|
3114
|
+
const h = e.south + (u + 0.5) * a;
|
|
3115
|
+
for (let d = 0; d < s; d += 1) {
|
|
3116
|
+
const f = e.west + (d + 0.5) * o, y = this.grid.sample(f, h);
|
|
3158
3117
|
if (!y || y.speed <= 0)
|
|
3159
3118
|
continue;
|
|
3160
|
-
const
|
|
3161
|
-
if (!te(
|
|
3119
|
+
const b = this.projectPoint(f, h);
|
|
3120
|
+
if (!te(b, this.width, this.height))
|
|
3162
3121
|
continue;
|
|
3163
|
-
const g = lr(this.colorScale, y.speed), p = this.getDataEdgeOpacity(f,
|
|
3122
|
+
const g = lr(this.colorScale, y.speed), p = this.getDataEdgeOpacity(f, h, l), m = this.options.velocityOverlayOpacity * p;
|
|
3164
3123
|
if (m <= 0.01)
|
|
3165
3124
|
continue;
|
|
3166
|
-
const v = r.createRadialGradient(
|
|
3167
|
-
v.addColorStop(0, ee(g, m)), v.addColorStop(1, ee(g, 0)), r.fillStyle = v, r.fillRect(
|
|
3125
|
+
const v = r.createRadialGradient(b.x, b.y, 0, b.x, b.y, c);
|
|
3126
|
+
v.addColorStop(0, ee(g, m)), v.addColorStop(1, ee(g, 0)), r.fillStyle = v, r.fillRect(b.x - c, b.y - c, c * 2, c * 2);
|
|
3168
3127
|
}
|
|
3169
3128
|
}
|
|
3170
3129
|
r.restore();
|
|
3171
3130
|
}
|
|
3172
3131
|
getDataEdgeOpacity(e, r, n) {
|
|
3173
|
-
const s =
|
|
3132
|
+
const s = w(this.options.velocityOverlayEdgeFade, 0, 0.35);
|
|
3174
3133
|
if (s <= 0 || !n)
|
|
3175
3134
|
return 1;
|
|
3176
3135
|
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);
|
|
3177
|
-
return
|
|
3136
|
+
return w(a / s, 0, 1);
|
|
3178
3137
|
}
|
|
3179
3138
|
start() {
|
|
3180
3139
|
this.destroyed || (this.options.running = !0, this.interactionSuspended = !1, this.animationFrame || (this.lastFrameTime = performance.now(), this.animationFrame = requestAnimationFrame((e) => this.animate(e))));
|
|
@@ -3206,43 +3165,43 @@ class fr {
|
|
|
3206
3165
|
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);
|
|
3207
3166
|
if (!n || n.speed <= 0 || !te(s, this.width, this.height))
|
|
3208
3167
|
return Object.assign(e, this.createParticle()), null;
|
|
3209
|
-
const i = e.lat * Math.PI / 180, o = Math.max(Math.cos(i) * 111320, 1e3), a = 111320,
|
|
3210
|
-
return !
|
|
3168
|
+
const i = e.lat * Math.PI / 180, o = Math.max(Math.cos(i) * 111320, 1e3), a = 111320, c = this.options.velocityScale * r, l = e.lon + n.u * c / o, u = e.lat + n.v * c / a, h = this.grid.sample(l, u), d = this.projectPoint(l, u);
|
|
3169
|
+
return !h || !te(d, this.width, this.height) ? (Object.assign(e, this.createParticle()), null) : (e.lon = l, e.lat = u, e.screenX = d.x, e.screenY = d.y, e.age += 1, e.age > e.maxAge && Object.assign(e, this.createParticle()), { from: s, to: d, speed: h.speed });
|
|
3211
3170
|
}
|
|
3212
3171
|
getFrameParticleCount(e) {
|
|
3213
3172
|
var i;
|
|
3214
|
-
const r =
|
|
3173
|
+
const r = w(
|
|
3215
3174
|
Math.floor(this.options.maxFrameParticles || e),
|
|
3216
3175
|
1,
|
|
3217
3176
|
e
|
|
3218
3177
|
), n = Math.floor(this.options.sceneModeMaxFrameParticles || 0), s = String(((i = this.getSceneMode) == null ? void 0 : i.call(this)) || "").toLowerCase();
|
|
3219
|
-
return (s === "2d" || s === "2.5d") && n > 0 ?
|
|
3178
|
+
return (s === "2d" || s === "2.5d") && n > 0 ? w(n, 1, r) : r;
|
|
3220
3179
|
}
|
|
3221
3180
|
drawFrame(e) {
|
|
3222
3181
|
if (!this.ctx || this.width <= 0 || this.height <= 0)
|
|
3223
3182
|
return;
|
|
3224
3183
|
const r = this.ctx;
|
|
3225
|
-
r.globalCompositeOperation = "destination-in", r.fillStyle = `rgba(0, 0, 0, ${
|
|
3184
|
+
r.globalCompositeOperation = "destination-in", r.fillStyle = `rgba(0, 0, 0, ${w(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";
|
|
3226
3185
|
const n = this.particleColorScale.map(() => []), s = this.particles.length, i = this.getFrameParticleCount(s);
|
|
3227
3186
|
for (let o = 0; o < i; o += 1) {
|
|
3228
|
-
const a = (this.particleCursor + o) % s,
|
|
3229
|
-
|
|
3187
|
+
const a = (this.particleCursor + o) % s, c = this.stepParticle(this.particles[a], e);
|
|
3188
|
+
c && n[this.getParticleColorIndex(c.speed)].push(c);
|
|
3230
3189
|
}
|
|
3231
3190
|
this.particleCursor = (this.particleCursor + i) % s, n.forEach((o, a) => {
|
|
3232
3191
|
if (o.length === 0)
|
|
3233
3192
|
return;
|
|
3234
|
-
const
|
|
3235
|
-
r.lineWidth = this.options.lineWidth * (0.72 +
|
|
3236
|
-
r.moveTo(
|
|
3193
|
+
const c = this.particleColorScale.length <= 1 ? 0 : a / (this.particleColorScale.length - 1);
|
|
3194
|
+
r.lineWidth = this.options.lineWidth * (0.72 + c * 0.56), r.strokeStyle = this.particleColorScale[a] ? ee(this.particleColorScale[a].color, this.options.particleOpacity) : this.options.color, r.beginPath(), o.forEach((l) => {
|
|
3195
|
+
r.moveTo(l.from.x, l.from.y), r.lineTo(l.to.x, l.to.y);
|
|
3237
3196
|
}), r.stroke();
|
|
3238
3197
|
});
|
|
3239
3198
|
}
|
|
3240
3199
|
animate(e) {
|
|
3241
3200
|
if (this.animationFrame = null, !(this.destroyed || !this.options.running || this.interactionSuspended)) {
|
|
3242
3201
|
if (this.options.visible && this.isReady()) {
|
|
3243
|
-
const r = 1e3 /
|
|
3202
|
+
const r = 1e3 / w(this.options.frameRate, 1, 60), n = e - this.lastFrameTime;
|
|
3244
3203
|
if (n >= r) {
|
|
3245
|
-
const s =
|
|
3204
|
+
const s = w(n / 16.67, 0.5, 2.5);
|
|
3246
3205
|
this.lastFrameTime = e, this.drawFrame(s);
|
|
3247
3206
|
}
|
|
3248
3207
|
}
|
|
@@ -3265,7 +3224,7 @@ class fr {
|
|
|
3265
3224
|
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 = [];
|
|
3266
3225
|
}
|
|
3267
3226
|
}
|
|
3268
|
-
function
|
|
3227
|
+
function V(t = {}) {
|
|
3269
3228
|
return typeof t == "string" ? t || "wind-field-default" : (t == null ? void 0 : t.id) || (t == null ? void 0 : t.layerId) || "wind-field-default";
|
|
3270
3229
|
}
|
|
3271
3230
|
function Ae(t = {}) {
|
|
@@ -3277,11 +3236,11 @@ function Ae(t = {}) {
|
|
|
3277
3236
|
options: i,
|
|
3278
3237
|
container: o,
|
|
3279
3238
|
project: a,
|
|
3280
|
-
getViewBounds:
|
|
3281
|
-
...
|
|
3239
|
+
getViewBounds: c,
|
|
3240
|
+
...l
|
|
3282
3241
|
} = t || {};
|
|
3283
3242
|
return {
|
|
3284
|
-
...
|
|
3243
|
+
...l,
|
|
3285
3244
|
...i || {}
|
|
3286
3245
|
};
|
|
3287
3246
|
}
|
|
@@ -3296,102 +3255,102 @@ class Pr {
|
|
|
3296
3255
|
}
|
|
3297
3256
|
mount(e) {
|
|
3298
3257
|
var r, n;
|
|
3299
|
-
return Ee(e) ? (this.baseGIS = e,
|
|
3258
|
+
return Ee(e) ? (this.baseGIS = e, L(
|
|
3300
3259
|
{ engineType: ((n = (r = this.baseGIS).getEngineType) == null ? void 0 : n.call(r)) || "unknown" },
|
|
3301
3260
|
"WindFieldMethods mounted with BaseGIS."
|
|
3302
|
-
)) :
|
|
3261
|
+
)) : I("WindFieldMethods mount requires BaseGIS instance.", "INVALID_MOUNT_TARGET");
|
|
3303
3262
|
}
|
|
3304
3263
|
resolveBaseGIS() {
|
|
3305
3264
|
var e, r;
|
|
3306
|
-
return this.baseGIS ? (r = (e = this.baseGIS).getMapInstance) != null && r.call(e) ?
|
|
3265
|
+
return this.baseGIS ? (r = (e = this.baseGIS).getMapInstance) != null && r.call(e) ? L(null, "BaseGIS is ready.") : I(
|
|
3307
3266
|
"Map instance is not ready. Please call mapCore.init() first.",
|
|
3308
3267
|
R.NOT_INITIALIZED
|
|
3309
|
-
) :
|
|
3268
|
+
) : I("WindFieldMethods has not been mounted.", "NOT_MOUNTED");
|
|
3310
3269
|
}
|
|
3311
3270
|
addWindField(e = {}) {
|
|
3312
|
-
var
|
|
3271
|
+
var c, l;
|
|
3313
3272
|
const r = this.resolveBaseGIS();
|
|
3314
3273
|
if (!r.success)
|
|
3315
3274
|
return r;
|
|
3316
3275
|
const n = (e == null ? void 0 : e.data) || (e == null ? void 0 : e.windData);
|
|
3317
3276
|
if (!n)
|
|
3318
|
-
return
|
|
3277
|
+
return I("Wind field data is required.", R.FAILED);
|
|
3319
3278
|
const s = this.baseGIS.getMapContainer();
|
|
3320
|
-
if (!(s != null && s.success) || !((
|
|
3321
|
-
return (s == null ? void 0 : s.success) === !1 ? s :
|
|
3322
|
-
const i =
|
|
3279
|
+
if (!(s != null && s.success) || !((c = s.data) != null && c.container))
|
|
3280
|
+
return (s == null ? void 0 : s.success) === !1 ? s : I("Map container is not available.", R.NOT_INITIALIZED);
|
|
3281
|
+
const i = V(e);
|
|
3323
3282
|
this.removeWindField(i);
|
|
3324
3283
|
const o = new fr({
|
|
3325
3284
|
id: i,
|
|
3326
3285
|
data: n,
|
|
3327
3286
|
container: s.data.container,
|
|
3328
3287
|
...Ae(e),
|
|
3329
|
-
project: (
|
|
3288
|
+
project: (u, h, d = 0) => {
|
|
3330
3289
|
const f = this.baseGIS.projectToContainerPoint({
|
|
3331
|
-
longitude:
|
|
3332
|
-
latitude:
|
|
3333
|
-
height:
|
|
3290
|
+
longitude: u,
|
|
3291
|
+
latitude: h,
|
|
3292
|
+
height: d
|
|
3334
3293
|
});
|
|
3335
3294
|
return f != null && f.success ? f.data : null;
|
|
3336
3295
|
},
|
|
3337
3296
|
getViewBounds: () => {
|
|
3338
|
-
const
|
|
3339
|
-
return
|
|
3297
|
+
const u = this.baseGIS.getViewBounds();
|
|
3298
|
+
return u != null && u.success ? u.data : null;
|
|
3340
3299
|
},
|
|
3341
3300
|
getSceneMode: () => {
|
|
3342
|
-
var
|
|
3343
|
-
const
|
|
3344
|
-
return
|
|
3301
|
+
var h, d, f;
|
|
3302
|
+
const u = (d = (h = this.baseGIS).getSceneMode) == null ? void 0 : d.call(h);
|
|
3303
|
+
return u != null && u.success ? (f = u.data) == null ? void 0 : f.mode : "";
|
|
3345
3304
|
}
|
|
3346
3305
|
});
|
|
3347
3306
|
if (!o.grid.valid)
|
|
3348
|
-
return o.destroy(),
|
|
3307
|
+
return o.destroy(), I(o.grid.errorMessage || "Invalid wind field data.", R.FAILED);
|
|
3349
3308
|
const a = this.baseGIS.onViewChange({
|
|
3350
3309
|
onStart: () => o.suspendForInteraction(),
|
|
3351
3310
|
onEnd: () => o.resumeAfterInteraction()
|
|
3352
3311
|
});
|
|
3353
3312
|
return a != null && a.success ? (this.layers.set(i, {
|
|
3354
3313
|
layer: o,
|
|
3355
|
-
offViewChange: (
|
|
3356
|
-
}),
|
|
3314
|
+
offViewChange: (l = a.data) == null ? void 0 : l.off
|
|
3315
|
+
}), L(o.getState(), `Wind field "${i}" added.`)) : (o.destroy(), a || I("View change listener is not available."));
|
|
3357
3316
|
}
|
|
3358
3317
|
updateWindField(e = {}) {
|
|
3359
3318
|
const r = this.resolveBaseGIS();
|
|
3360
3319
|
if (!r.success)
|
|
3361
3320
|
return r;
|
|
3362
|
-
const n =
|
|
3321
|
+
const n = V(e), s = this.layers.get(n);
|
|
3363
3322
|
if (!s)
|
|
3364
|
-
return
|
|
3323
|
+
return I(`Wind field "${n}" not found.`, R.FAILED);
|
|
3365
3324
|
const i = Ae(e), o = (e == null ? void 0 : e.data) || (e == null ? void 0 : e.windData);
|
|
3366
|
-
return o && (i.data = o), s.layer.updateOptions(i),
|
|
3325
|
+
return o && (i.data = o), s.layer.updateOptions(i), L(s.layer.getState(), `Wind field "${n}" updated.`);
|
|
3367
3326
|
}
|
|
3368
3327
|
startWindField(e = {}) {
|
|
3369
|
-
const r =
|
|
3370
|
-
return n ? (n.layer.start(),
|
|
3328
|
+
const r = V(e), n = this.layers.get(r);
|
|
3329
|
+
return n ? (n.layer.start(), L(n.layer.getState(), `Wind field "${r}" started.`)) : I(`Wind field "${r}" not found.`, R.FAILED);
|
|
3371
3330
|
}
|
|
3372
3331
|
stopWindField(e = {}) {
|
|
3373
|
-
const r =
|
|
3374
|
-
return n ? (n.layer.stop(),
|
|
3332
|
+
const r = V(e), n = this.layers.get(r);
|
|
3333
|
+
return n ? (n.layer.stop(), L(n.layer.getState(), `Wind field "${r}" stopped.`)) : I(`Wind field "${r}" not found.`, R.FAILED);
|
|
3375
3334
|
}
|
|
3376
3335
|
showWindField(e = {}) {
|
|
3377
|
-
const r =
|
|
3378
|
-
return n ? (n.layer.show(),
|
|
3336
|
+
const r = V(e), n = this.layers.get(r);
|
|
3337
|
+
return n ? (n.layer.show(), L(n.layer.getState(), `Wind field "${r}" shown.`)) : I(`Wind field "${r}" not found.`, R.FAILED);
|
|
3379
3338
|
}
|
|
3380
3339
|
hideWindField(e = {}) {
|
|
3381
|
-
const r =
|
|
3382
|
-
return n ? (n.layer.hide(),
|
|
3340
|
+
const r = V(e), n = this.layers.get(r);
|
|
3341
|
+
return n ? (n.layer.hide(), L(n.layer.getState(), `Wind field "${r}" hidden.`)) : I(`Wind field "${r}" not found.`, R.FAILED);
|
|
3383
3342
|
}
|
|
3384
3343
|
removeWindField(e = {}) {
|
|
3385
3344
|
var s;
|
|
3386
|
-
const r =
|
|
3387
|
-
return n ? ((s = n.offViewChange) == null || s.call(n), n.layer.destroy(), this.layers.delete(r),
|
|
3345
|
+
const r = V(e), n = this.layers.get(r);
|
|
3346
|
+
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.`);
|
|
3388
3347
|
}
|
|
3389
3348
|
clearWindFields() {
|
|
3390
3349
|
const e = this.layers.size;
|
|
3391
3350
|
return this.layers.forEach((r) => {
|
|
3392
3351
|
var n;
|
|
3393
3352
|
(n = r.offViewChange) == null || n.call(r), r.layer.destroy();
|
|
3394
|
-
}), this.layers.clear(),
|
|
3353
|
+
}), this.layers.clear(), L({ count: e }, `Wind fields cleared: ${e}.`);
|
|
3395
3354
|
}
|
|
3396
3355
|
getState() {
|
|
3397
3356
|
return {
|
|
@@ -3406,10 +3365,10 @@ export {
|
|
|
3406
3365
|
Ir as GraphicGroupController,
|
|
3407
3366
|
br as GridLayerController,
|
|
3408
3367
|
pr as ImageLayerController,
|
|
3409
|
-
|
|
3368
|
+
Lr as PointDensityController,
|
|
3410
3369
|
Cr as PointLargeLayerController,
|
|
3411
3370
|
wr as PressureContourLayer,
|
|
3412
|
-
|
|
3371
|
+
Sr as RasterContourController,
|
|
3413
3372
|
Pr as WindFieldMethods,
|
|
3414
3373
|
ir as buildPressureRenderData,
|
|
3415
3374
|
vr as createPressureDataResolver,
|