@3clear/basegis 0.1.1 → 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 +592 -100
- package/dist/WindDataGrid-AGJaASUG.js +96 -0
- package/dist/basegis.js +9177 -5237
- package/dist/leaflet-pixi-overlay-BSJNo_DO.js +253 -0
- package/dist/methods.js +2185 -1077
- package/dist/pixi-vendor-BFDHT3Bf.js +25208 -0
- package/dist/pointLarge-Ct8TsOPW.js +690 -0
- package/dist/style.css +1 -1
- package/package.json +5 -4
- package/dist/result-D03zgqh0.js +0 -39
package/dist/methods.js
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import { f as
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
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
|
+
function je(t) {
|
|
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");
|
|
5
6
|
}
|
|
6
|
-
class
|
|
7
|
+
class Ir {
|
|
7
8
|
constructor(e = {}) {
|
|
8
9
|
this.baseGIS = null, this.items = [], this.loadedCount = 0, (e.mapCore || e.baseGIS) && this.mount(e.mapCore || e.baseGIS);
|
|
9
10
|
}
|
|
10
11
|
mount(e) {
|
|
11
|
-
return
|
|
12
|
+
return je(e) ? (this.baseGIS = e, L(null, "GraphicGroupController mounted with BaseGIS.")) : I(
|
|
12
13
|
"GraphicGroupController mount requires BaseGIS instance.",
|
|
13
14
|
"INVALID_MOUNT_TARGET"
|
|
14
15
|
);
|
|
15
16
|
}
|
|
16
17
|
resolveBaseGIS() {
|
|
17
|
-
var e,
|
|
18
|
-
return this.baseGIS ? (
|
|
18
|
+
var e, r;
|
|
19
|
+
return this.baseGIS ? (r = (e = this.baseGIS).getMapInstance) != null && r.call(e) ? L(null, "BaseGIS is ready.") : I(
|
|
19
20
|
"Map instance is not ready. Please call mapCore.init() first.",
|
|
20
21
|
"NOT_INITIALIZED"
|
|
21
|
-
) :
|
|
22
|
+
) : I("GraphicGroupController has not been mounted.", "NOT_MOUNTED");
|
|
22
23
|
}
|
|
23
24
|
drawItem(e = {}) {
|
|
24
25
|
switch (e.type) {
|
|
@@ -33,30 +34,30 @@ class Re {
|
|
|
33
34
|
case "marker":
|
|
34
35
|
return this.baseGIS.addMarker(e);
|
|
35
36
|
default:
|
|
36
|
-
return
|
|
37
|
+
return I(`Unsupported graphic type "${e.type}".`, "INVALID_GRAPHIC_TYPE");
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
|
-
load(e = [],
|
|
40
|
-
const
|
|
41
|
-
if (!
|
|
42
|
-
return
|
|
40
|
+
load(e = [], r = {}) {
|
|
41
|
+
const n = this.resolveBaseGIS();
|
|
42
|
+
if (!n.success)
|
|
43
|
+
return n;
|
|
43
44
|
if (!Array.isArray(e) || e.length === 0)
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
return
|
|
49
|
-
type:
|
|
50
|
-
id:
|
|
51
|
-
success: !!(
|
|
52
|
-
message: (
|
|
45
|
+
return I("Graphic item list is empty.", "INVALID_ITEMS");
|
|
46
|
+
r.clearBeforeLoad !== !1 && this.baseGIS.clearGraphics(), this.items = e, this.loadedCount = 0;
|
|
47
|
+
const s = e.map((i) => {
|
|
48
|
+
const o = this.drawItem(i);
|
|
49
|
+
return o != null && o.success && (this.loadedCount += 1), {
|
|
50
|
+
type: i.type,
|
|
51
|
+
id: i.id || "",
|
|
52
|
+
success: !!(o != null && o.success),
|
|
53
|
+
message: (o == null ? void 0 : o.message) || ""
|
|
53
54
|
};
|
|
54
55
|
});
|
|
55
|
-
return
|
|
56
|
+
return L(
|
|
56
57
|
{
|
|
57
58
|
total: e.length,
|
|
58
59
|
loadedCount: this.loadedCount,
|
|
59
|
-
results:
|
|
60
|
+
results: s
|
|
60
61
|
},
|
|
61
62
|
`Graphic group loaded: ${this.loadedCount}/${e.length}.`
|
|
62
63
|
);
|
|
@@ -65,8 +66,8 @@ class Re {
|
|
|
65
66
|
const e = this.resolveBaseGIS();
|
|
66
67
|
if (!e.success)
|
|
67
68
|
return e;
|
|
68
|
-
const
|
|
69
|
-
return
|
|
69
|
+
const r = this.baseGIS.clearGraphics();
|
|
70
|
+
return r.success && (this.loadedCount = 0), r;
|
|
70
71
|
}
|
|
71
72
|
getState() {
|
|
72
73
|
return {
|
|
@@ -77,276 +78,281 @@ class Re {
|
|
|
77
78
|
};
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
|
-
function
|
|
81
|
-
return Array.isArray(
|
|
81
|
+
function W(t = {}) {
|
|
82
|
+
return Array.isArray(t) || Array.isArray(t == null ? void 0 : t.features) ? { contours: t } : t || {};
|
|
82
83
|
}
|
|
83
|
-
function
|
|
84
|
-
const e =
|
|
84
|
+
function he(t = {}) {
|
|
85
|
+
const e = W(t);
|
|
85
86
|
return ["contours", "isolines", "isoline", "lines", "data", "items"].some(
|
|
86
|
-
(
|
|
87
|
+
(r) => Object.prototype.hasOwnProperty.call(e, r)
|
|
87
88
|
);
|
|
88
89
|
}
|
|
89
|
-
function
|
|
90
|
-
return !!(
|
|
90
|
+
function ze(t) {
|
|
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");
|
|
91
92
|
}
|
|
92
|
-
function
|
|
93
|
-
const { mapCore: e, baseGIS:
|
|
94
|
-
return
|
|
93
|
+
function Ve(t = {}) {
|
|
94
|
+
const { mapCore: e, baseGIS: r, ...n } = t;
|
|
95
|
+
return n;
|
|
95
96
|
}
|
|
96
|
-
class
|
|
97
|
+
class Re {
|
|
97
98
|
constructor(e = {}) {
|
|
98
|
-
const
|
|
99
|
+
const r = Ve(e), n = r.contourLayerId || r.layerId || r.id || "contour-default";
|
|
99
100
|
this.options = {
|
|
100
|
-
layerId:
|
|
101
|
-
visible:
|
|
101
|
+
layerId: n,
|
|
102
|
+
visible: r.visible ?? !0
|
|
102
103
|
}, this.defaultPayload = {
|
|
103
|
-
...
|
|
104
|
-
layerId:
|
|
104
|
+
...r,
|
|
105
|
+
layerId: n,
|
|
105
106
|
visible: this.options.visible
|
|
106
107
|
}, this.baseGIS = null, this.currentPayload = null, this.layerType = "unknown", this.visible = this.options.visible, this.currentState = {
|
|
107
|
-
layerId:
|
|
108
|
+
layerId: n,
|
|
108
109
|
sourceCount: 0,
|
|
109
110
|
levelCount: 0,
|
|
110
111
|
lineCount: 0,
|
|
112
|
+
labelCount: 0,
|
|
111
113
|
visible: this.visible,
|
|
112
114
|
destroyed: !0
|
|
113
115
|
}, (e.mapCore || e.baseGIS) && this.mount(e.mapCore || e.baseGIS);
|
|
114
116
|
}
|
|
115
117
|
mount(e) {
|
|
116
|
-
var
|
|
117
|
-
return
|
|
118
|
-
{ engineType: ((
|
|
118
|
+
var r, n;
|
|
119
|
+
return ze(e) ? (this.baseGIS = e, L(
|
|
120
|
+
{ engineType: ((n = (r = this.baseGIS).getEngineType) == null ? void 0 : n.call(r)) || "unknown" },
|
|
119
121
|
"ContourLayerController mounted with BaseGIS."
|
|
120
|
-
)) :
|
|
122
|
+
)) : I(
|
|
121
123
|
"ContourLayerController mount requires BaseGIS instance.",
|
|
122
124
|
"INVALID_MOUNT_TARGET"
|
|
123
125
|
);
|
|
124
126
|
}
|
|
125
127
|
resolveBaseGIS() {
|
|
126
|
-
var e,
|
|
127
|
-
return this.baseGIS ? (
|
|
128
|
+
var e, r;
|
|
129
|
+
return this.baseGIS ? (r = (e = this.baseGIS).getMapInstance) != null && r.call(e) ? L(null, "BaseGIS is ready.") : I(
|
|
128
130
|
"Map instance is not ready. Please call mapCore.init() first.",
|
|
129
131
|
"NOT_INITIALIZED"
|
|
130
|
-
) :
|
|
132
|
+
) : I("ContourLayerController has not been mounted.", "NOT_MOUNTED");
|
|
131
133
|
}
|
|
132
134
|
getLayerId(e = {}) {
|
|
133
|
-
var
|
|
134
|
-
return typeof e == "string" && e ? e : (e == null ? void 0 : e.contourLayerId) || (e == null ? void 0 : e.layerId) || (e == null ? void 0 : e.id) || ((
|
|
135
|
+
var r;
|
|
136
|
+
return typeof e == "string" && e ? e : (e == null ? void 0 : e.contourLayerId) || (e == null ? void 0 : e.layerId) || (e == null ? void 0 : e.id) || ((r = this.currentPayload) == null ? void 0 : r.layerId) || this.options.layerId;
|
|
135
137
|
}
|
|
136
138
|
buildPayload(e = {}) {
|
|
137
|
-
const
|
|
139
|
+
const r = W(e), n = this.getLayerId(r);
|
|
138
140
|
return {
|
|
139
141
|
...this.defaultPayload,
|
|
140
|
-
...
|
|
141
|
-
layerId:
|
|
142
|
-
visible: typeof
|
|
142
|
+
...r,
|
|
143
|
+
layerId: n,
|
|
144
|
+
visible: typeof r.visible == "boolean" ? r.visible : this.visible
|
|
143
145
|
};
|
|
144
146
|
}
|
|
145
147
|
syncStateFromResult(e) {
|
|
146
|
-
var
|
|
147
|
-
const
|
|
148
|
-
!
|
|
148
|
+
var n;
|
|
149
|
+
const r = ((n = e == null ? void 0 : e.data) == null ? void 0 : n.state) || (e == null ? void 0 : e.data) || null;
|
|
150
|
+
!r || typeof r != "object" || (this.currentState = {
|
|
149
151
|
...this.currentState,
|
|
150
|
-
...
|
|
151
|
-
}, typeof
|
|
152
|
-
}
|
|
153
|
-
async load(e = {},
|
|
154
|
-
var
|
|
155
|
-
const
|
|
156
|
-
if (!
|
|
157
|
-
return
|
|
158
|
-
const
|
|
159
|
-
...
|
|
160
|
-
...
|
|
152
|
+
...r
|
|
153
|
+
}, typeof r.visible == "boolean" && (this.visible = r.visible));
|
|
154
|
+
}
|
|
155
|
+
async load(e = {}, r = {}) {
|
|
156
|
+
var o;
|
|
157
|
+
const n = this.resolveBaseGIS();
|
|
158
|
+
if (!n.success)
|
|
159
|
+
return n;
|
|
160
|
+
const s = this.buildPayload({
|
|
161
|
+
...W(e),
|
|
162
|
+
...W(r)
|
|
161
163
|
});
|
|
162
|
-
if (!
|
|
163
|
-
return
|
|
164
|
+
if (!he(s))
|
|
165
|
+
return I(
|
|
164
166
|
"Contour layer requires contours, isolines, lines, data or items.",
|
|
165
167
|
"INVALID_CONTOUR_SOURCE"
|
|
166
168
|
);
|
|
167
|
-
const
|
|
168
|
-
return
|
|
169
|
+
const i = await this.baseGIS.upsertContourLayer(s);
|
|
170
|
+
return i.success && (this.currentPayload = s, this.visible = s.visible !== !1, this.layerType = ((o = i == null ? void 0 : i.data) == null ? void 0 : o.layerType) || this.layerType, this.syncStateFromResult(i)), i;
|
|
169
171
|
}
|
|
170
|
-
upsert(e = {},
|
|
171
|
-
return this.load(e,
|
|
172
|
+
upsert(e = {}, r = {}) {
|
|
173
|
+
return this.load(e, r);
|
|
172
174
|
}
|
|
173
175
|
async update(e = {}) {
|
|
174
|
-
var
|
|
175
|
-
const
|
|
176
|
-
if (!
|
|
177
|
-
return
|
|
178
|
-
const
|
|
176
|
+
var i;
|
|
177
|
+
const r = this.resolveBaseGIS();
|
|
178
|
+
if (!r.success)
|
|
179
|
+
return r;
|
|
180
|
+
const n = {
|
|
179
181
|
...this.currentPayload || this.defaultPayload,
|
|
180
|
-
...
|
|
182
|
+
...W(e)
|
|
181
183
|
};
|
|
182
|
-
if (!this.currentPayload && !
|
|
183
|
-
return
|
|
184
|
-
const
|
|
185
|
-
return
|
|
184
|
+
if (!this.currentPayload && !he(n))
|
|
185
|
+
return I("Contour layer has not been loaded.", "NOT_LOADED");
|
|
186
|
+
const s = await this.baseGIS.updateContourLayer(n);
|
|
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;
|
|
186
188
|
}
|
|
187
189
|
setConfig(e = {}) {
|
|
188
190
|
return this.update(e);
|
|
189
191
|
}
|
|
190
192
|
show(e = {}) {
|
|
191
|
-
const
|
|
192
|
-
if (!
|
|
193
|
-
return
|
|
194
|
-
const
|
|
193
|
+
const r = this.resolveBaseGIS();
|
|
194
|
+
if (!r.success)
|
|
195
|
+
return r;
|
|
196
|
+
const n = this.baseGIS.showContourLayer({
|
|
195
197
|
...e,
|
|
196
198
|
layerId: this.getLayerId(e)
|
|
197
199
|
});
|
|
198
|
-
return
|
|
200
|
+
return n.success && (this.visible = !0, this.syncStateFromResult(n)), n;
|
|
199
201
|
}
|
|
200
202
|
hide(e = {}) {
|
|
201
|
-
const
|
|
202
|
-
if (!
|
|
203
|
-
return
|
|
204
|
-
const
|
|
203
|
+
const r = this.resolveBaseGIS();
|
|
204
|
+
if (!r.success)
|
|
205
|
+
return r;
|
|
206
|
+
const n = this.baseGIS.hideContourLayer({
|
|
205
207
|
...e,
|
|
206
208
|
layerId: this.getLayerId(e)
|
|
207
209
|
});
|
|
208
|
-
return
|
|
210
|
+
return n.success && (this.visible = !1, this.syncStateFromResult(n)), n;
|
|
209
211
|
}
|
|
210
212
|
toggle(e) {
|
|
211
213
|
return typeof e == "boolean" ? e ? this.show() : this.hide() : this.visible ? this.hide() : this.show();
|
|
212
214
|
}
|
|
213
215
|
clear(e = {}) {
|
|
214
|
-
const
|
|
215
|
-
if (!
|
|
216
|
-
return
|
|
217
|
-
const
|
|
216
|
+
const r = this.resolveBaseGIS();
|
|
217
|
+
if (!r.success)
|
|
218
|
+
return r;
|
|
219
|
+
const n = this.baseGIS.clearContourLayer({
|
|
218
220
|
...e,
|
|
219
221
|
layerId: this.getLayerId(e)
|
|
220
222
|
});
|
|
221
|
-
return
|
|
223
|
+
return n.success && (this.currentPayload = this.currentPayload ? {
|
|
222
224
|
...this.currentPayload,
|
|
223
225
|
contours: [],
|
|
224
226
|
isolines: [],
|
|
225
227
|
isoline: [],
|
|
226
228
|
lines: []
|
|
227
|
-
} : null, this.syncStateFromResult(
|
|
229
|
+
} : null, this.syncStateFromResult(n)), n;
|
|
228
230
|
}
|
|
229
231
|
refreshState(e = {}) {
|
|
230
|
-
const
|
|
231
|
-
if (!
|
|
232
|
-
return
|
|
233
|
-
const
|
|
232
|
+
const r = this.resolveBaseGIS();
|
|
233
|
+
if (!r.success)
|
|
234
|
+
return r;
|
|
235
|
+
const n = this.baseGIS.getContourLayerState({
|
|
234
236
|
...e,
|
|
235
237
|
layerId: this.getLayerId(e)
|
|
236
238
|
});
|
|
237
|
-
return
|
|
239
|
+
return n.success && this.syncStateFromResult(n), n;
|
|
238
240
|
}
|
|
239
241
|
destroy(e = {}) {
|
|
240
242
|
if (!this.resolveBaseGIS().success)
|
|
241
|
-
return this.currentPayload = null, this.layerType = "unknown", this.currentState = {
|
|
243
|
+
return this.currentPayload = null, this.layerType = "unknown", this.visible = !1, this.currentState = {
|
|
242
244
|
...this.currentState,
|
|
243
245
|
sourceCount: 0,
|
|
244
246
|
levelCount: 0,
|
|
245
247
|
lineCount: 0,
|
|
248
|
+
labelCount: 0,
|
|
249
|
+
visible: !1,
|
|
246
250
|
destroyed: !0
|
|
247
|
-
},
|
|
248
|
-
const
|
|
251
|
+
}, L(null, "Contour layer controller destroyed (local state only).");
|
|
252
|
+
const n = this.baseGIS.removeContourLayer({
|
|
249
253
|
...e,
|
|
250
254
|
layerId: this.getLayerId(e)
|
|
251
255
|
});
|
|
252
|
-
return this.currentPayload = null, this.layerType = "unknown", this.currentState = {
|
|
256
|
+
return this.currentPayload = null, this.layerType = "unknown", this.visible = !1, this.currentState = {
|
|
253
257
|
...this.currentState,
|
|
254
258
|
sourceCount: 0,
|
|
255
259
|
levelCount: 0,
|
|
256
260
|
lineCount: 0,
|
|
261
|
+
labelCount: 0,
|
|
262
|
+
visible: !1,
|
|
257
263
|
destroyed: !0
|
|
258
|
-
},
|
|
264
|
+
}, n.success ? L(null, "Contour layer controller destroyed.") : n;
|
|
259
265
|
}
|
|
260
266
|
removeLayer(e = {}) {
|
|
261
267
|
return this.destroy(e);
|
|
262
268
|
}
|
|
263
269
|
getState() {
|
|
264
|
-
var e,
|
|
265
|
-
if ((
|
|
266
|
-
const
|
|
270
|
+
var e, r, n, s, i, o, a;
|
|
271
|
+
if ((r = (e = this.baseGIS) == null ? void 0 : e.getMapInstance) != null && r.call(e) && this.currentPayload) {
|
|
272
|
+
const c = (s = (n = this.baseGIS).getContourLayerState) == null ? void 0 : s.call(n, {
|
|
267
273
|
layerId: this.currentPayload.layerId || this.options.layerId
|
|
268
274
|
});
|
|
269
|
-
|
|
275
|
+
c != null && c.success && this.syncStateFromResult(c);
|
|
270
276
|
}
|
|
271
277
|
return {
|
|
272
278
|
mounted: !!this.baseGIS,
|
|
273
|
-
engineType: ((
|
|
279
|
+
engineType: ((o = (i = this.baseGIS) == null ? void 0 : i.getEngineType) == null ? void 0 : o.call(i)) || "unknown",
|
|
274
280
|
layerType: this.layerType,
|
|
275
281
|
visible: this.visible,
|
|
276
|
-
layerId: ((
|
|
282
|
+
layerId: ((a = this.currentPayload) == null ? void 0 : a.layerId) || this.options.layerId,
|
|
277
283
|
payload: this.currentPayload,
|
|
278
284
|
...this.currentState
|
|
279
285
|
};
|
|
280
286
|
}
|
|
281
287
|
}
|
|
282
|
-
function
|
|
283
|
-
const
|
|
284
|
-
return Number.isFinite(
|
|
288
|
+
function E(t, e = 0) {
|
|
289
|
+
const r = Number(t);
|
|
290
|
+
return Number.isFinite(r) ? r : e;
|
|
285
291
|
}
|
|
286
|
-
function
|
|
292
|
+
function de(t, e = {
|
|
287
293
|
startLon: 73,
|
|
288
294
|
startLat: 18,
|
|
289
295
|
endLon: 135,
|
|
290
296
|
endLat: 54
|
|
291
297
|
}) {
|
|
292
|
-
const
|
|
298
|
+
const r = t && typeof t == "object" ? t : e;
|
|
293
299
|
return {
|
|
294
|
-
startLon:
|
|
295
|
-
startLat:
|
|
296
|
-
endLon:
|
|
297
|
-
endLat:
|
|
300
|
+
startLon: E(r.startLon, e.startLon),
|
|
301
|
+
startLat: E(r.startLat, e.startLat),
|
|
302
|
+
endLon: E(r.endLon, e.endLon),
|
|
303
|
+
endLat: E(r.endLat, e.endLat)
|
|
298
304
|
};
|
|
299
305
|
}
|
|
300
|
-
function
|
|
301
|
-
return !!(
|
|
306
|
+
function _e(t) {
|
|
307
|
+
return !!(t && typeof t.getEngineType == "function" && typeof t.getMapInstance == "function" && typeof t.upsertGridLayer == "function" && typeof t.showGridLayer == "function" && typeof t.hideGridLayer == "function" && typeof t.removeGridLayer == "function");
|
|
302
308
|
}
|
|
303
|
-
function
|
|
304
|
-
return !!(
|
|
309
|
+
function We(t = {}) {
|
|
310
|
+
return !!(t.tifUrl || t.imageUrl || t.grayImageUrl || t.imageGridData);
|
|
305
311
|
}
|
|
306
|
-
class
|
|
312
|
+
class br {
|
|
307
313
|
constructor(e = {}) {
|
|
308
314
|
this.options = {
|
|
309
315
|
visible: e.visible ?? !0,
|
|
310
316
|
layerId: e.layerId || "grid-layer-default",
|
|
311
|
-
defaultArea:
|
|
312
|
-
gridTotal:
|
|
313
|
-
tileSize:
|
|
314
|
-
decimalPlaces:
|
|
317
|
+
defaultArea: de(e.defaultArea),
|
|
318
|
+
gridTotal: E(e.gridTotal, 4),
|
|
319
|
+
tileSize: E(e.tileSize, 512),
|
|
320
|
+
decimalPlaces: E(e.decimalPlaces, 2),
|
|
315
321
|
showLabel: !!e.showLabel,
|
|
316
322
|
showProbe: !!e.showProbe,
|
|
317
323
|
colorize: e.colorize || null
|
|
318
324
|
}, this.baseGIS = null, this.visible = this.options.visible, this.layerType = "unknown", this.currentPayload = null, (e.mapCore || e.baseGIS) && this.mount(e.mapCore || e.baseGIS);
|
|
319
325
|
}
|
|
320
326
|
mount(e) {
|
|
321
|
-
var
|
|
322
|
-
return
|
|
323
|
-
{ engineType: ((
|
|
327
|
+
var r, n;
|
|
328
|
+
return _e(e) ? (this.baseGIS = e, L(
|
|
329
|
+
{ engineType: ((n = (r = this.baseGIS).getEngineType) == null ? void 0 : n.call(r)) || "unknown" },
|
|
324
330
|
"GridLayerController mounted with BaseGIS."
|
|
325
|
-
)) :
|
|
331
|
+
)) : I(
|
|
326
332
|
"GridLayerController mount requires BaseGIS instance.",
|
|
327
333
|
"INVALID_MOUNT_TARGET"
|
|
328
334
|
);
|
|
329
335
|
}
|
|
330
336
|
resolveBaseGIS() {
|
|
331
|
-
var e,
|
|
332
|
-
return this.baseGIS ? (
|
|
337
|
+
var e, r;
|
|
338
|
+
return this.baseGIS ? (r = (e = this.baseGIS).getMapInstance) != null && r.call(e) ? L(null, "BaseGIS is ready.") : I(
|
|
333
339
|
"Map instance is not ready. Please call mapCore.init() first.",
|
|
334
340
|
"NOT_INITIALIZED"
|
|
335
|
-
) :
|
|
341
|
+
) : I("GridLayerController has not been mounted.", "NOT_MOUNTED");
|
|
336
342
|
}
|
|
337
343
|
getLayerId(e = {}) {
|
|
338
|
-
var
|
|
339
|
-
return typeof e == "string" && e ? e : (e == null ? void 0 : e.layerId) || (e == null ? void 0 : e.gridLayerId) || ((
|
|
344
|
+
var r;
|
|
345
|
+
return typeof e == "string" && e ? e : (e == null ? void 0 : e.layerId) || (e == null ? void 0 : e.gridLayerId) || ((r = this.currentPayload) == null ? void 0 : r.layerId) || this.options.layerId;
|
|
340
346
|
}
|
|
341
347
|
buildPayload(e = {}) {
|
|
342
|
-
const
|
|
348
|
+
const r = e.imageUrl || e.grayImageUrl || e.imageGridData, n = e.area ? de(e.area, this.options.defaultArea) : r ? this.options.defaultArea : void 0;
|
|
343
349
|
return {
|
|
344
350
|
...e,
|
|
345
351
|
layerId: this.getLayerId(e),
|
|
346
|
-
area:
|
|
347
|
-
gridTotal:
|
|
348
|
-
tileSize:
|
|
349
|
-
decimalPlaces:
|
|
352
|
+
area: n,
|
|
353
|
+
gridTotal: E(e.gridTotal, this.options.gridTotal),
|
|
354
|
+
tileSize: E(e.tileSize, this.options.tileSize),
|
|
355
|
+
decimalPlaces: E(e.decimalPlaces, this.options.decimalPlaces),
|
|
350
356
|
showLabel: typeof e.showLabel == "boolean" ? e.showLabel : this.options.showLabel,
|
|
351
357
|
showProbe: typeof e.showProbe == "boolean" ? e.showProbe : this.options.showProbe,
|
|
352
358
|
colorize: e.colorize || this.options.colorize,
|
|
@@ -354,17 +360,17 @@ class Fe {
|
|
|
354
360
|
};
|
|
355
361
|
}
|
|
356
362
|
async load(e = {}) {
|
|
357
|
-
var
|
|
358
|
-
const
|
|
359
|
-
if (!
|
|
360
|
-
return
|
|
361
|
-
if (!
|
|
362
|
-
return
|
|
363
|
+
var i;
|
|
364
|
+
const r = this.resolveBaseGIS();
|
|
365
|
+
if (!r.success)
|
|
366
|
+
return r;
|
|
367
|
+
if (!We(e))
|
|
368
|
+
return I(
|
|
363
369
|
"Grid layer requires tifUrl, imageUrl, grayImageUrl or imageGridData.",
|
|
364
370
|
"INVALID_GRID_SOURCE"
|
|
365
371
|
);
|
|
366
|
-
const
|
|
367
|
-
return
|
|
372
|
+
const n = this.buildPayload(e), s = await this.baseGIS.upsertGridLayer(n);
|
|
373
|
+
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), s;
|
|
368
374
|
}
|
|
369
375
|
loadTif(e = {}) {
|
|
370
376
|
return this.load({
|
|
@@ -390,142 +396,342 @@ class Fe {
|
|
|
390
396
|
...this.currentPayload,
|
|
391
397
|
...e,
|
|
392
398
|
layerId: e.layerId || e.gridLayerId || this.currentPayload.layerId
|
|
393
|
-
}) :
|
|
399
|
+
}) : I("Grid layer has not been loaded.", "NOT_LOADED");
|
|
394
400
|
}
|
|
395
401
|
show(e = {}) {
|
|
396
|
-
const
|
|
397
|
-
if (!
|
|
398
|
-
return
|
|
399
|
-
const
|
|
402
|
+
const r = this.resolveBaseGIS();
|
|
403
|
+
if (!r.success)
|
|
404
|
+
return r;
|
|
405
|
+
const n = this.baseGIS.showGridLayer({
|
|
400
406
|
layerId: this.getLayerId(e)
|
|
401
407
|
});
|
|
402
|
-
return
|
|
408
|
+
return n.success && (this.visible = !0), n;
|
|
403
409
|
}
|
|
404
410
|
hide(e = {}) {
|
|
405
|
-
const
|
|
406
|
-
if (!
|
|
407
|
-
return
|
|
408
|
-
const
|
|
411
|
+
const r = this.resolveBaseGIS();
|
|
412
|
+
if (!r.success)
|
|
413
|
+
return r;
|
|
414
|
+
const n = this.baseGIS.hideGridLayer({
|
|
409
415
|
layerId: this.getLayerId(e)
|
|
410
416
|
});
|
|
411
|
-
return
|
|
417
|
+
return n.success && (this.visible = !1), n;
|
|
412
418
|
}
|
|
413
419
|
destroy(e = {}) {
|
|
414
420
|
if (!this.resolveBaseGIS().success)
|
|
415
|
-
return this.currentPayload = null, this.layerType = "unknown",
|
|
416
|
-
const
|
|
421
|
+
return this.currentPayload = null, this.layerType = "unknown", L(null, "Grid layer controller destroyed (local state only).");
|
|
422
|
+
const n = this.baseGIS.removeGridLayer({
|
|
417
423
|
layerId: this.getLayerId(e)
|
|
418
424
|
});
|
|
419
|
-
return this.currentPayload = null, this.layerType = "unknown",
|
|
425
|
+
return this.currentPayload = null, this.layerType = "unknown", n.success ? L(null, "Grid layer controller destroyed.") : n;
|
|
420
426
|
}
|
|
421
427
|
getState() {
|
|
422
|
-
var e,
|
|
428
|
+
var e, r, n;
|
|
423
429
|
return {
|
|
424
430
|
mounted: !!this.baseGIS,
|
|
425
|
-
engineType: ((
|
|
431
|
+
engineType: ((r = (e = this.baseGIS) == null ? void 0 : e.getEngineType) == null ? void 0 : r.call(e)) || "unknown",
|
|
426
432
|
layerType: this.layerType,
|
|
427
433
|
visible: this.visible,
|
|
428
|
-
layerId: ((
|
|
434
|
+
layerId: ((n = this.currentPayload) == null ? void 0 : n.layerId) || this.options.layerId,
|
|
429
435
|
payload: this.currentPayload
|
|
430
436
|
};
|
|
431
437
|
}
|
|
432
438
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
439
|
+
const U = /* @__PURE__ */ new Map(), $e = {
|
|
440
|
+
maxSize: 12
|
|
441
|
+
};
|
|
442
|
+
function x(t, e = 0) {
|
|
443
|
+
const r = Number(t);
|
|
444
|
+
return Number.isFinite(r) ? r : e;
|
|
445
|
+
}
|
|
446
|
+
function fe(t) {
|
|
447
|
+
if (Array.isArray(t) && t.length >= 2) {
|
|
448
|
+
const e = Number(t[0]), r = Number(t[1]);
|
|
449
|
+
return Number.isFinite(e) && Number.isFinite(r) ? { lat: e, lng: r } : null;
|
|
450
|
+
}
|
|
451
|
+
if (t && typeof t == "object") {
|
|
452
|
+
const e = Number(t.lat ?? t.latitude), r = Number(t.lng ?? t.lon ?? t.longitude);
|
|
453
|
+
return Number.isFinite(e) && Number.isFinite(r) ? { lat: e, lng: r } : null;
|
|
454
|
+
}
|
|
455
|
+
return null;
|
|
436
456
|
}
|
|
437
|
-
function
|
|
457
|
+
function re(t) {
|
|
458
|
+
if (!t) return null;
|
|
459
|
+
if (typeof t.getWest == "function" && typeof t.getSouth == "function" && typeof t.getEast == "function" && typeof t.getNorth == "function")
|
|
460
|
+
return {
|
|
461
|
+
startLon: t.getWest(),
|
|
462
|
+
startLat: t.getSouth(),
|
|
463
|
+
endLon: t.getEast(),
|
|
464
|
+
endLat: t.getNorth()
|
|
465
|
+
};
|
|
466
|
+
if (Array.isArray(t)) {
|
|
467
|
+
if (t.length >= 4 && t.slice(0, 4).every((n) => Number.isFinite(Number(n))))
|
|
468
|
+
return {
|
|
469
|
+
startLon: t[0],
|
|
470
|
+
startLat: t[1],
|
|
471
|
+
endLon: t[2],
|
|
472
|
+
endLat: t[3]
|
|
473
|
+
};
|
|
474
|
+
const e = fe(t[0]), r = fe(t[1]);
|
|
475
|
+
if (e && r)
|
|
476
|
+
return {
|
|
477
|
+
startLon: e.lng,
|
|
478
|
+
startLat: e.lat,
|
|
479
|
+
endLon: r.lng,
|
|
480
|
+
endLat: r.lat
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
if (t && typeof t == "object") {
|
|
484
|
+
if (t.area) {
|
|
485
|
+
const e = re(t.area);
|
|
486
|
+
if (e) return e;
|
|
487
|
+
}
|
|
488
|
+
if (t._southWest && t._northEast)
|
|
489
|
+
return re([t._southWest, t._northEast]);
|
|
490
|
+
if (["west", "south", "east", "north"].every(
|
|
491
|
+
(e) => Number.isFinite(Number(t[e]))
|
|
492
|
+
))
|
|
493
|
+
return {
|
|
494
|
+
startLon: t.west,
|
|
495
|
+
startLat: t.south,
|
|
496
|
+
endLon: t.east,
|
|
497
|
+
endLat: t.north
|
|
498
|
+
};
|
|
499
|
+
if (["startLon", "startLat", "endLon", "endLat"].every(
|
|
500
|
+
(e) => Number.isFinite(Number(t[e]))
|
|
501
|
+
))
|
|
502
|
+
return t;
|
|
503
|
+
}
|
|
504
|
+
return null;
|
|
505
|
+
}
|
|
506
|
+
function j(t) {
|
|
507
|
+
const e = re(t);
|
|
508
|
+
if (!e) return null;
|
|
509
|
+
const r = Number(e.startLon), n = Number(e.startLat), s = Number(e.endLon), i = Number(e.endLat);
|
|
510
|
+
return [r, n, s, i].every(Number.isFinite) ? {
|
|
511
|
+
startLon: Math.min(r, s),
|
|
512
|
+
startLat: Math.min(n, i),
|
|
513
|
+
endLon: Math.max(r, s),
|
|
514
|
+
endLat: Math.max(n, i)
|
|
515
|
+
} : null;
|
|
516
|
+
}
|
|
517
|
+
function q(t, e = {
|
|
438
518
|
startLon: 73,
|
|
439
519
|
startLat: 18,
|
|
440
520
|
endLon: 135,
|
|
441
521
|
endLat: 54
|
|
442
522
|
}) {
|
|
443
|
-
const
|
|
523
|
+
const r = j(e) || {
|
|
524
|
+
startLon: 73,
|
|
525
|
+
startLat: 18,
|
|
526
|
+
endLon: 135,
|
|
527
|
+
endLat: 54
|
|
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
|
+
return {
|
|
530
|
+
startLon: Math.min(s, o),
|
|
531
|
+
startLat: Math.min(i, a),
|
|
532
|
+
endLon: Math.max(s, o),
|
|
533
|
+
endLat: Math.max(i, a)
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
function ke() {
|
|
537
|
+
return typeof window < "u" && typeof document < "u";
|
|
538
|
+
}
|
|
539
|
+
function qe(t) {
|
|
540
|
+
return `${t || ""}`.toUpperCase() === "EPSG:3857";
|
|
541
|
+
}
|
|
542
|
+
function Y(t, e = "EPSG:4326") {
|
|
543
|
+
return `${t || e}`.toUpperCase();
|
|
544
|
+
}
|
|
545
|
+
function ce(t) {
|
|
546
|
+
const e = j(t);
|
|
547
|
+
return e ? [e.startLon, e.startLat, e.endLon, e.endLat].every((r) => Math.abs(Number(r)) <= 180) : !1;
|
|
548
|
+
}
|
|
549
|
+
function ne(t, e) {
|
|
550
|
+
const r = 85.0511287798066, n = Math.min(Math.max(Number(t), -r), r), s = Number(e), i = 6378137, o = i * s * Math.PI / 180, a = i * Math.log(Math.tan(Math.PI / 4 + n * Math.PI / 360));
|
|
551
|
+
return { x: o, y: a };
|
|
552
|
+
}
|
|
553
|
+
function ye(t, e) {
|
|
554
|
+
const n = Number(t) / 6378137 * 180 / Math.PI;
|
|
555
|
+
return { lat: (2 * Math.atan(Math.exp(Number(e) / 6378137)) - Math.PI / 2) * 180 / Math.PI, lng: n };
|
|
556
|
+
}
|
|
557
|
+
function He(t) {
|
|
558
|
+
const e = j(t);
|
|
559
|
+
if (!e) return null;
|
|
560
|
+
const r = ne(e.startLat, e.startLon), n = ne(e.endLat, e.endLon);
|
|
444
561
|
return {
|
|
445
|
-
startLon:
|
|
446
|
-
startLat:
|
|
447
|
-
endLon:
|
|
448
|
-
endLat:
|
|
562
|
+
startLon: r.x,
|
|
563
|
+
startLat: r.y,
|
|
564
|
+
endLon: n.x,
|
|
565
|
+
endLat: n.y
|
|
449
566
|
};
|
|
450
567
|
}
|
|
451
|
-
function
|
|
568
|
+
function se(t) {
|
|
569
|
+
const e = j(t);
|
|
570
|
+
if (!e) return null;
|
|
571
|
+
if (ce(e)) return e;
|
|
572
|
+
const r = ye(e.startLon, e.startLat), n = ye(e.endLon, e.endLat);
|
|
452
573
|
return {
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
description: (i == null ? void 0 : i.description) || "",
|
|
458
|
-
area: U(i == null ? void 0 : i.area, t),
|
|
459
|
-
opacity: i == null ? void 0 : i.opacity,
|
|
460
|
-
isSplit: i == null ? void 0 : i.isSplit,
|
|
461
|
-
imageSourceType: i == null ? void 0 : i.imageSourceType,
|
|
462
|
-
isGrayImage: i == null ? void 0 : i.isGrayImage,
|
|
463
|
-
colorize: i == null ? void 0 : i.colorize,
|
|
464
|
-
minValue: i == null ? void 0 : i.minValue,
|
|
465
|
-
maxValue: i == null ? void 0 : i.maxValue,
|
|
466
|
-
grayMinValue: i == null ? void 0 : i.grayMinValue,
|
|
467
|
-
grayMaxValue: i == null ? void 0 : i.grayMaxValue,
|
|
468
|
-
noDataValue: i == null ? void 0 : i.noDataValue,
|
|
469
|
-
colorMapType: i == null ? void 0 : i.colorMapType,
|
|
470
|
-
type: i == null ? void 0 : i.type,
|
|
471
|
-
colorStops: i == null ? void 0 : i.colorStops,
|
|
472
|
-
colors: i == null ? void 0 : i.colors,
|
|
473
|
-
showProbe: i == null ? void 0 : i.showProbe,
|
|
474
|
-
enableProbe: i == null ? void 0 : i.enableProbe,
|
|
475
|
-
showMouseProbe: i == null ? void 0 : i.showMouseProbe,
|
|
476
|
-
showLabel: i == null ? void 0 : i.showLabel,
|
|
477
|
-
gridTotal: i == null ? void 0 : i.gridTotal,
|
|
478
|
-
tileSize: i == null ? void 0 : i.tileSize,
|
|
479
|
-
decimalPlaces: i == null ? void 0 : i.decimalPlaces
|
|
574
|
+
startLon: r.lng,
|
|
575
|
+
startLat: r.lat,
|
|
576
|
+
endLon: n.lng,
|
|
577
|
+
endLat: n.lat
|
|
480
578
|
};
|
|
481
579
|
}
|
|
482
|
-
function
|
|
483
|
-
return
|
|
580
|
+
function Ye(t) {
|
|
581
|
+
return new Promise((e, r) => {
|
|
582
|
+
const n = new Image();
|
|
583
|
+
n.crossOrigin = "anonymous", n.onload = () => e(n), n.onerror = () => r(new Error(`图片加载失败:${t}`)), n.src = t;
|
|
584
|
+
});
|
|
484
585
|
}
|
|
485
|
-
|
|
586
|
+
function Ke(t, e, r) {
|
|
587
|
+
const n = j(r) || {};
|
|
588
|
+
return [
|
|
589
|
+
t,
|
|
590
|
+
e,
|
|
591
|
+
n.startLon,
|
|
592
|
+
n.startLat,
|
|
593
|
+
n.endLon,
|
|
594
|
+
n.endLat
|
|
595
|
+
].join("|");
|
|
596
|
+
}
|
|
597
|
+
function Xe(t, e) {
|
|
598
|
+
if (!(!t || !e))
|
|
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
|
+
}
|
|
603
|
+
}
|
|
604
|
+
async function Ze(t, e) {
|
|
605
|
+
const r = j(e), n = se(r);
|
|
606
|
+
if (!ke() || !r || !n || ce(r))
|
|
607
|
+
return t;
|
|
608
|
+
const s = await Ye(t), i = s.naturalWidth || s.width, o = s.naturalHeight || s.height, a = document.createElement("canvas");
|
|
609
|
+
a.width = i, a.height = o;
|
|
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
|
+
if (!Number.isFinite(p) || p === 0)
|
|
616
|
+
return t;
|
|
617
|
+
for (let m = 0; m < o; m += 1) {
|
|
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
|
+
}
|
|
621
|
+
return h.putImageData(d, 0, 0), u.toDataURL("image/png");
|
|
622
|
+
}
|
|
623
|
+
async function ge(t) {
|
|
624
|
+
const e = Y(t == null ? void 0 : t.sourceProjection, ""), r = Y(t == null ? void 0 : t.targetProjection);
|
|
625
|
+
if (!(t != null && t.imageUrl) || !qe(e) || e === r)
|
|
626
|
+
return t;
|
|
627
|
+
const n = t.sourceArea || t.area, s = Ke(t.imageUrl, `${e}_${r}`, n);
|
|
628
|
+
if (U.has(s))
|
|
629
|
+
return {
|
|
630
|
+
...t,
|
|
631
|
+
imageUrl: U.get(s),
|
|
632
|
+
area: q(se(n) || t.area, t.area)
|
|
633
|
+
};
|
|
634
|
+
const i = se(n) || t.area;
|
|
635
|
+
let o = null;
|
|
636
|
+
ce(n) ? o = He(n) : o = j(n);
|
|
637
|
+
const a = await Ze(t.imageUrl, o);
|
|
638
|
+
return Xe(s, a), {
|
|
639
|
+
...t,
|
|
640
|
+
imageUrl: a,
|
|
641
|
+
area: q(i, t.area)
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
function me(t = {}, e = 0, r = void 0) {
|
|
645
|
+
return {
|
|
646
|
+
id: (t == null ? void 0 : t.id) || `image-${e}`,
|
|
647
|
+
name: (t == null ? void 0 : t.name) || `Image ${e + 1}`,
|
|
648
|
+
imageUrl: (t == null ? void 0 : t.imageUrl) || "",
|
|
649
|
+
tifUrl: (t == null ? void 0 : t.tifUrl) || "",
|
|
650
|
+
description: (t == null ? void 0 : t.description) || "",
|
|
651
|
+
area: q(t == null ? void 0 : t.area, r),
|
|
652
|
+
opacity: t == null ? void 0 : t.opacity,
|
|
653
|
+
zIndex: t == null ? void 0 : t.zIndex,
|
|
654
|
+
isSplit: t == null ? void 0 : t.isSplit,
|
|
655
|
+
imageSourceType: t == null ? void 0 : t.imageSourceType,
|
|
656
|
+
isGrayImage: t == null ? void 0 : t.isGrayImage,
|
|
657
|
+
colorize: t == null ? void 0 : t.colorize,
|
|
658
|
+
minValue: t == null ? void 0 : t.minValue,
|
|
659
|
+
maxValue: t == null ? void 0 : t.maxValue,
|
|
660
|
+
grayMinValue: t == null ? void 0 : t.grayMinValue,
|
|
661
|
+
grayMaxValue: t == null ? void 0 : t.grayMaxValue,
|
|
662
|
+
noDataValue: t == null ? void 0 : t.noDataValue,
|
|
663
|
+
colorMapType: t == null ? void 0 : t.colorMapType,
|
|
664
|
+
type: t == null ? void 0 : t.type,
|
|
665
|
+
colorStops: t == null ? void 0 : t.colorStops,
|
|
666
|
+
colors: t == null ? void 0 : t.colors,
|
|
667
|
+
showProbe: t == null ? void 0 : t.showProbe,
|
|
668
|
+
enableProbe: t == null ? void 0 : t.enableProbe,
|
|
669
|
+
showMouseProbe: t == null ? void 0 : t.showMouseProbe,
|
|
670
|
+
showLabel: t == null ? void 0 : t.showLabel,
|
|
671
|
+
gridTotal: t == null ? void 0 : t.gridTotal,
|
|
672
|
+
tileSize: t == null ? void 0 : t.tileSize,
|
|
673
|
+
decimalPlaces: t == null ? void 0 : t.decimalPlaces,
|
|
674
|
+
sourceProjection: t == null ? void 0 : t.sourceProjection,
|
|
675
|
+
targetProjection: t == null ? void 0 : t.targetProjection,
|
|
676
|
+
sourceArea: t == null ? void 0 : t.sourceArea
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
function Je(t) {
|
|
680
|
+
return !!(t && typeof t.getEngineType == "function" && typeof t.getMapInstance == "function" && typeof t.upsertImageLayer == "function" && typeof t.showImageLayer == "function" && typeof t.hideImageLayer == "function" && typeof t.removeImageLayer == "function");
|
|
681
|
+
}
|
|
682
|
+
class pr {
|
|
486
683
|
constructor(e = {}) {
|
|
487
684
|
this.options = {
|
|
488
685
|
visible: e.visible ?? !0,
|
|
489
|
-
opacity:
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
686
|
+
opacity: x(e.opacity, 0.85),
|
|
687
|
+
zIndex: x(e.zIndex, 650),
|
|
688
|
+
defaultArea: q(e.defaultArea),
|
|
689
|
+
gridTotal: x(e.gridTotal, 4),
|
|
690
|
+
tileSize: x(e.tileSize, 512),
|
|
691
|
+
decimalPlaces: x(e.decimalPlaces, 2),
|
|
494
692
|
imageSourceType: e.imageSourceType || "color",
|
|
495
693
|
colorize: e.colorize || null,
|
|
496
694
|
layerId: e.layerId || "image-layer-default"
|
|
497
|
-
}, this.baseGIS = null, this.items = [], this.activeIndex = -1, this.visible = this.options.visible, this.layerType = "unknown", this.currentPayload = null, (e.mapCore || e.baseGIS) && this.mount(e.mapCore || e.baseGIS);
|
|
695
|
+
}, this.baseGIS = null, this.items = [], this.activeIndex = -1, this.visible = this.options.visible, this.layerType = "unknown", this.currentPayload = null, this._operationRequestId = 0, (e.mapCore || e.baseGIS) && this.mount(e.mapCore || e.baseGIS);
|
|
498
696
|
}
|
|
499
697
|
/**
|
|
500
698
|
* 绑定 BaseGIS 实例。
|
|
501
699
|
* 这里不关心具体引擎类型,只要求传入的是 BaseGIS 主类实例。
|
|
502
700
|
*/
|
|
503
701
|
mount(e) {
|
|
504
|
-
var
|
|
505
|
-
return
|
|
506
|
-
{ engineType: ((
|
|
702
|
+
var r, n;
|
|
703
|
+
return Je(e) ? (this._operationRequestId += 1, this.baseGIS = e, L(
|
|
704
|
+
{ engineType: ((n = (r = this.baseGIS).getEngineType) == null ? void 0 : n.call(r)) || "unknown" },
|
|
507
705
|
"ImageLayerController mounted with BaseGIS."
|
|
508
|
-
)) :
|
|
706
|
+
)) : I(
|
|
509
707
|
"ImageLayerController mount requires BaseGIS instance.",
|
|
510
708
|
"INVALID_MOUNT_TARGET"
|
|
511
709
|
);
|
|
512
710
|
}
|
|
513
711
|
resolveBaseGIS() {
|
|
514
|
-
var e,
|
|
515
|
-
return this.baseGIS ? (
|
|
712
|
+
var e, r;
|
|
713
|
+
return this.baseGIS ? (r = (e = this.baseGIS).getMapInstance) != null && r.call(e) ? L(null, "BaseGIS is ready.") : I(
|
|
516
714
|
"Map instance is not ready. Please call mapCore.init() first.",
|
|
517
715
|
"NOT_INITIALIZED"
|
|
518
|
-
) :
|
|
716
|
+
) : I("ImageLayerController has not been mounted.", "NOT_MOUNTED");
|
|
519
717
|
}
|
|
520
718
|
getLayerId(e = {}) {
|
|
521
719
|
return typeof e == "string" && e ? e : (e == null ? void 0 : e.layerId) || this.options.layerId;
|
|
522
720
|
}
|
|
523
|
-
|
|
721
|
+
/* 获取图片图层目标投影 */
|
|
722
|
+
getTargetProjectionFn(e = {}) {
|
|
723
|
+
var s, i, o, a, c, l, u, h, d;
|
|
724
|
+
if (e.targetProjection)
|
|
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) || ((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
|
+
}
|
|
729
|
+
buildLayerPayload(e, r = {}) {
|
|
524
730
|
return {
|
|
525
|
-
layerId: this.getLayerId(
|
|
731
|
+
layerId: this.getLayerId(r),
|
|
526
732
|
imageUrl: e.imageUrl,
|
|
527
733
|
tifUrl: e.tifUrl,
|
|
528
|
-
area:
|
|
734
|
+
area: q(e.area, this.options.defaultArea),
|
|
529
735
|
isSplit: !!e.isSplit,
|
|
530
736
|
imageSourceType: e.imageSourceType || this.options.imageSourceType,
|
|
531
737
|
isGrayImage: e.isGrayImage,
|
|
@@ -543,46 +749,53 @@ class Ee {
|
|
|
543
749
|
enableProbe: e.enableProbe,
|
|
544
750
|
showMouseProbe: e.showMouseProbe,
|
|
545
751
|
showLabel: !!e.showLabel,
|
|
546
|
-
gridTotal:
|
|
547
|
-
tileSize:
|
|
548
|
-
decimalPlaces:
|
|
549
|
-
opacity:
|
|
550
|
-
|
|
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
|
+
visible: typeof r.visible == "boolean" ? r.visible : this.visible
|
|
551
758
|
};
|
|
552
759
|
}
|
|
553
760
|
/**
|
|
554
761
|
* 加载图片集合,并切换到默认索引。
|
|
555
762
|
* 每项字段示例:id / name / imageUrl / tifUrl / area / opacity / isSplit / imageSourceType / colorize / showLabel
|
|
556
763
|
*/
|
|
557
|
-
async load(e = [],
|
|
764
|
+
async load(e = [], r = {}) {
|
|
558
765
|
if (!Array.isArray(e) || e.length === 0)
|
|
559
|
-
return
|
|
560
|
-
const
|
|
561
|
-
if (
|
|
562
|
-
return
|
|
563
|
-
this.items =
|
|
564
|
-
const
|
|
565
|
-
return this.switchTo(
|
|
766
|
+
return I("Image list is empty.", "INVALID_ITEMS");
|
|
767
|
+
const n = e.map((i, o) => me(i, o, this.options.defaultArea)).filter((i) => i.imageUrl || i.tifUrl);
|
|
768
|
+
if (n.length === 0)
|
|
769
|
+
return I("No valid imageUrl or tifUrl found in items.", "INVALID_ITEMS");
|
|
770
|
+
this.items = n, typeof r.visible == "boolean" && (this.visible = r.visible);
|
|
771
|
+
const s = Number.isInteger(r.index) ? r.index : 0;
|
|
772
|
+
return this.switchTo(s);
|
|
566
773
|
}
|
|
567
774
|
/**
|
|
568
775
|
* 切换图片。
|
|
569
776
|
* target 可传索引数字,也可传图片 id。
|
|
570
777
|
*/
|
|
571
778
|
async switchTo(e) {
|
|
572
|
-
var
|
|
573
|
-
const
|
|
574
|
-
if (!
|
|
575
|
-
return
|
|
779
|
+
var l, u;
|
|
780
|
+
const r = this.resolveBaseGIS();
|
|
781
|
+
if (!r.success)
|
|
782
|
+
return r;
|
|
576
783
|
if (!Array.isArray(this.items) || this.items.length === 0)
|
|
577
|
-
return
|
|
578
|
-
let
|
|
579
|
-
if (typeof e == "number" ?
|
|
580
|
-
return
|
|
581
|
-
const
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
784
|
+
return I("Image list has not been loaded.", "NOT_LOADED");
|
|
785
|
+
let n = -1;
|
|
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
|
+
const s = this.items[n], i = await ge({
|
|
789
|
+
...s,
|
|
790
|
+
targetProjection: this.getTargetProjectionFn(s)
|
|
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
|
+
{ stale: !0, ignored: !0 },
|
|
794
|
+
`Image switch to "${s.name}" was superseded.`
|
|
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
|
+
{ activeIndex: n, activeItem: i },
|
|
797
|
+
`Image switched to "${i.name}".`
|
|
798
|
+
)) : c;
|
|
586
799
|
}
|
|
587
800
|
/**
|
|
588
801
|
* 更新当前图片图层数据。
|
|
@@ -591,77 +804,81 @@ class Ee {
|
|
|
591
804
|
* 与 load(items) 不同,update(payload) 不要求维护图片数组,也不表达 next / prev 两态。
|
|
592
805
|
*/
|
|
593
806
|
async update(e = {}) {
|
|
594
|
-
var
|
|
595
|
-
const
|
|
596
|
-
if (!
|
|
597
|
-
return
|
|
598
|
-
const
|
|
807
|
+
var u, h;
|
|
808
|
+
const r = this.resolveBaseGIS();
|
|
809
|
+
if (!r.success)
|
|
810
|
+
return r;
|
|
811
|
+
const n = this.items[this.activeIndex] || {}, s = this.activeIndex >= 0 ? this.activeIndex : 0, i = me(
|
|
599
812
|
{
|
|
600
|
-
...
|
|
601
|
-
...e
|
|
813
|
+
...n,
|
|
814
|
+
...e,
|
|
815
|
+
targetProjection: this.getTargetProjectionFn(e)
|
|
602
816
|
},
|
|
603
|
-
|
|
817
|
+
s,
|
|
604
818
|
this.options.defaultArea
|
|
605
819
|
);
|
|
606
|
-
if (!
|
|
607
|
-
return
|
|
820
|
+
if (!i.imageUrl && !i.tifUrl)
|
|
821
|
+
return I("Image layer update requires imageUrl or tifUrl.", "INVALID_ITEM");
|
|
608
822
|
typeof e.visible == "boolean" && (this.visible = e.visible);
|
|
609
|
-
const a = this.buildLayerPayload(
|
|
610
|
-
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
|
+
{ stale: !0, ignored: !0 },
|
|
826
|
+
`Image layer update "${i.name}" was superseded.`
|
|
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(
|
|
611
828
|
{
|
|
612
829
|
activeIndex: this.activeIndex,
|
|
613
|
-
activeItem:
|
|
830
|
+
activeItem: o
|
|
614
831
|
},
|
|
615
|
-
`Image layer updated: "${
|
|
616
|
-
)) :
|
|
832
|
+
`Image layer updated: "${o.name}".`
|
|
833
|
+
)) : l;
|
|
617
834
|
}
|
|
618
835
|
async next() {
|
|
619
836
|
if (!this.items.length)
|
|
620
|
-
return
|
|
837
|
+
return I("Image list has not been loaded.", "NOT_LOADED");
|
|
621
838
|
const e = this.activeIndex < 0 ? 0 : (this.activeIndex + 1) % this.items.length;
|
|
622
839
|
return this.switchTo(e);
|
|
623
840
|
}
|
|
624
841
|
async prev() {
|
|
625
842
|
if (!this.items.length)
|
|
626
|
-
return
|
|
843
|
+
return I("Image list has not been loaded.", "NOT_LOADED");
|
|
627
844
|
const e = this.activeIndex < 0 ? this.items.length - 1 : (this.activeIndex - 1 + this.items.length) % this.items.length;
|
|
628
845
|
return this.switchTo(e);
|
|
629
846
|
}
|
|
630
847
|
show(e = {}) {
|
|
631
|
-
const
|
|
632
|
-
if (!
|
|
633
|
-
return
|
|
634
|
-
const
|
|
848
|
+
const r = this.resolveBaseGIS();
|
|
849
|
+
if (!r.success)
|
|
850
|
+
return r;
|
|
851
|
+
const n = this.baseGIS.showImageLayer({
|
|
635
852
|
layerId: this.getLayerId(e)
|
|
636
853
|
});
|
|
637
|
-
return
|
|
854
|
+
return n.success && (this.visible = !0), n;
|
|
638
855
|
}
|
|
639
856
|
hide(e = {}) {
|
|
640
|
-
const
|
|
641
|
-
if (!
|
|
642
|
-
return
|
|
643
|
-
const
|
|
857
|
+
const r = this.resolveBaseGIS();
|
|
858
|
+
if (!r.success)
|
|
859
|
+
return r;
|
|
860
|
+
const n = this.baseGIS.hideImageLayer({
|
|
644
861
|
layerId: this.getLayerId(e)
|
|
645
862
|
});
|
|
646
|
-
return
|
|
863
|
+
return n.success && (this.visible = !1), n;
|
|
647
864
|
}
|
|
648
865
|
/**
|
|
649
866
|
* 销毁控制器。
|
|
650
867
|
* 如果地图已经先销毁,则只清理控制器本地状态。
|
|
651
868
|
*/
|
|
652
869
|
destroy(e = {}) {
|
|
653
|
-
if (!this.resolveBaseGIS().success)
|
|
654
|
-
return this.items = [], this.activeIndex = -1, this.layerType = "unknown", this.currentPayload = null,
|
|
655
|
-
const
|
|
870
|
+
if (this._operationRequestId += 1, !this.resolveBaseGIS().success)
|
|
871
|
+
return this.items = [], this.activeIndex = -1, this.layerType = "unknown", this.currentPayload = null, L(null, "Image layer controller destroyed (local state only).");
|
|
872
|
+
const n = this.baseGIS.removeImageLayer({
|
|
656
873
|
layerId: this.getLayerId(e)
|
|
657
874
|
});
|
|
658
|
-
return this.items = [], this.activeIndex = -1, this.layerType = "unknown", this.currentPayload = null,
|
|
875
|
+
return this.items = [], this.activeIndex = -1, this.layerType = "unknown", this.currentPayload = null, n.success ? L(null, "Image layer controller destroyed.") : n;
|
|
659
876
|
}
|
|
660
877
|
getState() {
|
|
661
|
-
var e,
|
|
878
|
+
var e, r;
|
|
662
879
|
return {
|
|
663
880
|
mounted: !!this.baseGIS,
|
|
664
|
-
engineType: ((
|
|
881
|
+
engineType: ((r = (e = this.baseGIS) == null ? void 0 : e.getEngineType) == null ? void 0 : r.call(e)) || "unknown",
|
|
665
882
|
layerType: this.layerType,
|
|
666
883
|
visible: this.visible,
|
|
667
884
|
total: this.items.length,
|
|
@@ -671,159 +888,159 @@ class Ee {
|
|
|
671
888
|
};
|
|
672
889
|
}
|
|
673
890
|
}
|
|
674
|
-
function
|
|
675
|
-
return Array.isArray(
|
|
891
|
+
function $(t = {}) {
|
|
892
|
+
return Array.isArray(t) || Array.isArray(t == null ? void 0 : t.features) ? { points: t } : t || {};
|
|
676
893
|
}
|
|
677
|
-
function
|
|
678
|
-
const e =
|
|
894
|
+
function Ie(t = {}) {
|
|
895
|
+
const e = $(t);
|
|
679
896
|
return ["points", "data", "items"].some(
|
|
680
|
-
(
|
|
897
|
+
(r) => Object.prototype.hasOwnProperty.call(e, r)
|
|
681
898
|
);
|
|
682
899
|
}
|
|
683
|
-
function
|
|
684
|
-
return !!(
|
|
900
|
+
function Qe(t) {
|
|
901
|
+
return !!(t && typeof t.getEngineType == "function" && typeof t.getMapInstance == "function" && typeof t.upsertPointDensityLayer == "function" && typeof t.showPointDensityLayer == "function" && typeof t.hidePointDensityLayer == "function" && typeof t.removePointDensityLayer == "function" && typeof t.clearPointDensityLayer == "function" && typeof t.getPointDensityLayerState == "function");
|
|
685
902
|
}
|
|
686
|
-
function
|
|
687
|
-
const
|
|
688
|
-
return
|
|
903
|
+
function et(t = {}) {
|
|
904
|
+
const e = { ...t };
|
|
905
|
+
return delete e.mapCore, delete e.baseGIS, e;
|
|
689
906
|
}
|
|
690
|
-
class
|
|
907
|
+
class Lr {
|
|
691
908
|
constructor(e = {}) {
|
|
692
|
-
const
|
|
909
|
+
const r = et(e), n = r.pointDensityLayerId || r.densityLayerId || r.layerId || r.id || "point-density-default";
|
|
693
910
|
this.options = {
|
|
694
|
-
layerId:
|
|
695
|
-
visible:
|
|
696
|
-
idKey:
|
|
911
|
+
layerId: n,
|
|
912
|
+
visible: r.visible ?? !0,
|
|
913
|
+
idKey: r.idKey || "id"
|
|
697
914
|
}, this.defaultPayload = {
|
|
698
|
-
...
|
|
699
|
-
layerId:
|
|
915
|
+
...r,
|
|
916
|
+
layerId: n,
|
|
700
917
|
visible: this.options.visible
|
|
701
918
|
}, this.baseGIS = null, this.currentPayload = null, this.layerType = "unknown", this.visible = this.options.visible, this.currentState = {
|
|
702
|
-
layerId:
|
|
919
|
+
layerId: n,
|
|
703
920
|
sourceCount: 0,
|
|
704
921
|
visibleCount: 0,
|
|
705
922
|
hiddenCount: 0,
|
|
706
923
|
gridCount: 0,
|
|
707
|
-
gridSize:
|
|
924
|
+
gridSize: r.gridSize ?? r.pixelRange ?? 150,
|
|
708
925
|
visible: this.visible,
|
|
709
926
|
destroyed: !0
|
|
710
927
|
}, (e.mapCore || e.baseGIS) && this.mount(e.mapCore || e.baseGIS);
|
|
711
928
|
}
|
|
712
929
|
mount(e) {
|
|
713
|
-
var
|
|
714
|
-
return
|
|
715
|
-
{ engineType: ((
|
|
930
|
+
var r, n;
|
|
931
|
+
return Qe(e) ? (this.baseGIS = e, L(
|
|
932
|
+
{ engineType: ((n = (r = this.baseGIS).getEngineType) == null ? void 0 : n.call(r)) || "unknown" },
|
|
716
933
|
"PointDensityController mounted with BaseGIS."
|
|
717
|
-
)) :
|
|
934
|
+
)) : I(
|
|
718
935
|
"PointDensityController mount requires BaseGIS instance.",
|
|
719
936
|
"INVALID_MOUNT_TARGET"
|
|
720
937
|
);
|
|
721
938
|
}
|
|
722
939
|
resolveBaseGIS() {
|
|
723
|
-
var e,
|
|
724
|
-
return this.baseGIS ? (
|
|
940
|
+
var e, r;
|
|
941
|
+
return this.baseGIS ? (r = (e = this.baseGIS).getMapInstance) != null && r.call(e) ? L(null, "BaseGIS is ready.") : I(
|
|
725
942
|
"Map instance is not ready. Please call mapCore.init() first.",
|
|
726
943
|
"NOT_INITIALIZED"
|
|
727
|
-
) :
|
|
944
|
+
) : I("PointDensityController has not been mounted.", "NOT_MOUNTED");
|
|
728
945
|
}
|
|
729
946
|
getLayerId(e = {}) {
|
|
730
|
-
var
|
|
731
|
-
return typeof e == "string" && e ? e : (e == null ? void 0 : e.pointDensityLayerId) || (e == null ? void 0 : e.densityLayerId) || (e == null ? void 0 : e.layerId) || (e == null ? void 0 : e.id) || ((
|
|
947
|
+
var r;
|
|
948
|
+
return typeof e == "string" && e ? e : (e == null ? void 0 : e.pointDensityLayerId) || (e == null ? void 0 : e.densityLayerId) || (e == null ? void 0 : e.layerId) || (e == null ? void 0 : e.id) || ((r = this.currentPayload) == null ? void 0 : r.layerId) || this.options.layerId;
|
|
732
949
|
}
|
|
733
950
|
buildPayload(e = {}) {
|
|
734
|
-
const
|
|
951
|
+
const r = $(e), n = this.getLayerId(r);
|
|
735
952
|
return {
|
|
736
953
|
...this.defaultPayload,
|
|
737
|
-
...
|
|
738
|
-
layerId:
|
|
739
|
-
visible: typeof
|
|
954
|
+
...r,
|
|
955
|
+
layerId: n,
|
|
956
|
+
visible: typeof r.visible == "boolean" ? r.visible : this.visible
|
|
740
957
|
};
|
|
741
958
|
}
|
|
742
959
|
syncStateFromResult(e) {
|
|
743
|
-
var
|
|
744
|
-
const
|
|
745
|
-
!
|
|
960
|
+
var n;
|
|
961
|
+
const r = ((n = e == null ? void 0 : e.data) == null ? void 0 : n.state) || (e == null ? void 0 : e.data) || null;
|
|
962
|
+
!r || typeof r != "object" || (this.currentState = {
|
|
746
963
|
...this.currentState,
|
|
747
|
-
...
|
|
748
|
-
}, typeof
|
|
749
|
-
}
|
|
750
|
-
async load(e = {},
|
|
751
|
-
var
|
|
752
|
-
const
|
|
753
|
-
if (!
|
|
754
|
-
return
|
|
755
|
-
const
|
|
756
|
-
...
|
|
757
|
-
...
|
|
964
|
+
...r
|
|
965
|
+
}, typeof r.visible == "boolean" && (this.visible = r.visible));
|
|
966
|
+
}
|
|
967
|
+
async load(e = {}, r = {}) {
|
|
968
|
+
var c;
|
|
969
|
+
const n = this.resolveBaseGIS();
|
|
970
|
+
if (!n.success)
|
|
971
|
+
return n;
|
|
972
|
+
const s = $(e), i = $(r), o = this.buildPayload({
|
|
973
|
+
...s,
|
|
974
|
+
...i
|
|
758
975
|
});
|
|
759
|
-
if (!
|
|
760
|
-
return
|
|
976
|
+
if (!Ie(o))
|
|
977
|
+
return I(
|
|
761
978
|
"Point density layer requires points, data or items.",
|
|
762
979
|
"INVALID_POINT_SOURCE"
|
|
763
980
|
);
|
|
764
|
-
const
|
|
765
|
-
return
|
|
981
|
+
const a = await this.baseGIS.upsertPointDensityLayer(o);
|
|
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;
|
|
766
983
|
}
|
|
767
|
-
upsert(e = {},
|
|
768
|
-
return this.load(e,
|
|
984
|
+
upsert(e = {}, r = {}) {
|
|
985
|
+
return this.load(e, r);
|
|
769
986
|
}
|
|
770
987
|
async update(e = {}) {
|
|
771
|
-
const
|
|
988
|
+
const r = {
|
|
772
989
|
...this.currentPayload || this.defaultPayload,
|
|
773
|
-
|
|
990
|
+
...$(e)
|
|
774
991
|
};
|
|
775
|
-
return !this.currentPayload && !
|
|
992
|
+
return !this.currentPayload && !Ie(r) ? I("Point density layer has not been loaded.", "NOT_LOADED") : this.load(r);
|
|
776
993
|
}
|
|
777
994
|
setConfig(e = {}) {
|
|
778
995
|
return this.update(e);
|
|
779
996
|
}
|
|
780
997
|
show(e = {}) {
|
|
781
|
-
const
|
|
782
|
-
if (!
|
|
783
|
-
return
|
|
784
|
-
const
|
|
998
|
+
const r = this.resolveBaseGIS();
|
|
999
|
+
if (!r.success)
|
|
1000
|
+
return r;
|
|
1001
|
+
const n = this.baseGIS.showPointDensityLayer({
|
|
785
1002
|
...e,
|
|
786
1003
|
layerId: this.getLayerId(e)
|
|
787
1004
|
});
|
|
788
|
-
return
|
|
1005
|
+
return n.success && (this.visible = !0, this.syncStateFromResult(n)), n;
|
|
789
1006
|
}
|
|
790
1007
|
hide(e = {}) {
|
|
791
|
-
const
|
|
792
|
-
if (!
|
|
793
|
-
return
|
|
794
|
-
const
|
|
1008
|
+
const r = this.resolveBaseGIS();
|
|
1009
|
+
if (!r.success)
|
|
1010
|
+
return r;
|
|
1011
|
+
const n = this.baseGIS.hidePointDensityLayer({
|
|
795
1012
|
...e,
|
|
796
1013
|
layerId: this.getLayerId(e)
|
|
797
1014
|
});
|
|
798
|
-
return
|
|
1015
|
+
return n.success && (this.visible = !1, this.syncStateFromResult(n)), n;
|
|
799
1016
|
}
|
|
800
1017
|
toggle(e) {
|
|
801
1018
|
return typeof e == "boolean" ? e ? this.show() : this.hide() : this.visible ? this.hide() : this.show();
|
|
802
1019
|
}
|
|
803
1020
|
clear(e = {}) {
|
|
804
|
-
const
|
|
805
|
-
if (!
|
|
806
|
-
return
|
|
807
|
-
const
|
|
1021
|
+
const r = this.resolveBaseGIS();
|
|
1022
|
+
if (!r.success)
|
|
1023
|
+
return r;
|
|
1024
|
+
const n = this.baseGIS.clearPointDensityLayer({
|
|
808
1025
|
...e,
|
|
809
1026
|
layerId: this.getLayerId(e)
|
|
810
1027
|
});
|
|
811
|
-
return
|
|
1028
|
+
return n.success && (this.currentPayload = this.currentPayload ? {
|
|
812
1029
|
...this.currentPayload,
|
|
813
1030
|
points: [],
|
|
814
1031
|
data: [],
|
|
815
1032
|
items: []
|
|
816
|
-
} : null, this.syncStateFromResult(
|
|
1033
|
+
} : null, this.syncStateFromResult(n)), n;
|
|
817
1034
|
}
|
|
818
1035
|
refreshState(e = {}) {
|
|
819
|
-
const
|
|
820
|
-
if (!
|
|
821
|
-
return
|
|
822
|
-
const
|
|
1036
|
+
const r = this.resolveBaseGIS();
|
|
1037
|
+
if (!r.success)
|
|
1038
|
+
return r;
|
|
1039
|
+
const n = this.baseGIS.getPointDensityLayerState({
|
|
823
1040
|
...e,
|
|
824
1041
|
layerId: this.getLayerId(e)
|
|
825
1042
|
});
|
|
826
|
-
return
|
|
1043
|
+
return n.success && this.syncStateFromResult(n), n;
|
|
827
1044
|
}
|
|
828
1045
|
destroy(e = {}) {
|
|
829
1046
|
if (!this.resolveBaseGIS().success)
|
|
@@ -834,8 +1051,8 @@ class Ve {
|
|
|
834
1051
|
hiddenCount: 0,
|
|
835
1052
|
gridCount: 0,
|
|
836
1053
|
destroyed: !0
|
|
837
|
-
},
|
|
838
|
-
const
|
|
1054
|
+
}, L(null, "Point density layer controller destroyed (local state only).");
|
|
1055
|
+
const n = this.baseGIS.removePointDensityLayer({
|
|
839
1056
|
...e,
|
|
840
1057
|
layerId: this.getLayerId(e)
|
|
841
1058
|
});
|
|
@@ -846,66 +1063,66 @@ class Ve {
|
|
|
846
1063
|
hiddenCount: 0,
|
|
847
1064
|
gridCount: 0,
|
|
848
1065
|
destroyed: !0
|
|
849
|
-
},
|
|
1066
|
+
}, n.success ? L(null, "Point density layer controller destroyed.") : n;
|
|
850
1067
|
}
|
|
851
1068
|
removeLayer(e = {}) {
|
|
852
1069
|
return this.destroy(e);
|
|
853
1070
|
}
|
|
854
1071
|
getState() {
|
|
855
|
-
var e,
|
|
856
|
-
if ((
|
|
857
|
-
const
|
|
1072
|
+
var e, r, n, s, i, o, a;
|
|
1073
|
+
if ((r = (e = this.baseGIS) == null ? void 0 : e.getMapInstance) != null && r.call(e) && this.currentPayload) {
|
|
1074
|
+
const c = (s = (n = this.baseGIS).getPointDensityLayerState) == null ? void 0 : s.call(n, {
|
|
858
1075
|
layerId: this.currentPayload.layerId || this.options.layerId
|
|
859
1076
|
});
|
|
860
|
-
|
|
1077
|
+
c != null && c.success && this.syncStateFromResult(c);
|
|
861
1078
|
}
|
|
862
1079
|
return {
|
|
863
1080
|
mounted: !!this.baseGIS,
|
|
864
|
-
engineType: ((
|
|
1081
|
+
engineType: ((o = (i = this.baseGIS) == null ? void 0 : i.getEngineType) == null ? void 0 : o.call(i)) || "unknown",
|
|
865
1082
|
layerType: this.layerType,
|
|
866
1083
|
visible: this.visible,
|
|
867
|
-
layerId: ((
|
|
1084
|
+
layerId: ((a = this.currentPayload) == null ? void 0 : a.layerId) || this.options.layerId,
|
|
868
1085
|
payload: this.currentPayload,
|
|
869
1086
|
...this.currentState
|
|
870
1087
|
};
|
|
871
1088
|
}
|
|
872
1089
|
}
|
|
873
|
-
function
|
|
874
|
-
return Array.isArray(
|
|
1090
|
+
function k(t = {}) {
|
|
1091
|
+
return Array.isArray(t) || Array.isArray(t == null ? void 0 : t.features) ? { points: t } : t || {};
|
|
875
1092
|
}
|
|
876
|
-
function
|
|
877
|
-
const e =
|
|
1093
|
+
function be(t = {}) {
|
|
1094
|
+
const e = k(t);
|
|
878
1095
|
return ["points", "data", "items"].some(
|
|
879
|
-
(
|
|
1096
|
+
(r) => Object.prototype.hasOwnProperty.call(e, r)
|
|
880
1097
|
);
|
|
881
1098
|
}
|
|
882
|
-
function
|
|
883
|
-
return !!(
|
|
1099
|
+
function tt(t) {
|
|
1100
|
+
return !!(t && typeof t.getEngineType == "function" && typeof t.getMapInstance == "function" && typeof t.upsertPointLargeLayer == "function" && typeof t.showPointLargeLayer == "function" && typeof t.hidePointLargeLayer == "function" && typeof t.removePointLargeLayer == "function" && typeof t.setPointLargeHighlight == "function" && typeof t.clearPointLargeHighlight == "function" && typeof t.removePointLargePoint == "function" && typeof t.clearPointLargeLayer == "function");
|
|
884
1101
|
}
|
|
885
|
-
function
|
|
886
|
-
return
|
|
1102
|
+
function pe(t, e = {}) {
|
|
1103
|
+
return t && typeof t == "object" && !Array.isArray(t) ? t.pointId ?? t.highlightId ?? t.key ?? t.id : t ?? e.pointId ?? e.highlightId ?? e.key ?? e.id;
|
|
887
1104
|
}
|
|
888
|
-
function
|
|
889
|
-
var
|
|
890
|
-
return !
|
|
1105
|
+
function rt(t, e = "id", r = "") {
|
|
1106
|
+
var n, s;
|
|
1107
|
+
return !t || typeof t != "object" || Array.isArray(t) ? r : t[e] ?? ((n = t.properties) == null ? void 0 : n[e]) ?? t.id ?? ((s = t.properties) == null ? void 0 : s.id) ?? r;
|
|
891
1108
|
}
|
|
892
|
-
function
|
|
893
|
-
const { mapCore: e, baseGIS:
|
|
894
|
-
return
|
|
1109
|
+
function nt(t = {}) {
|
|
1110
|
+
const { mapCore: e, baseGIS: r, ...n } = t;
|
|
1111
|
+
return n;
|
|
895
1112
|
}
|
|
896
|
-
class
|
|
1113
|
+
class Cr {
|
|
897
1114
|
constructor(e = {}) {
|
|
898
|
-
const
|
|
1115
|
+
const r = nt(e), n = r.pointLargeLayerId || r.largeLayerId || r.layerId || r.id || "point-large-default";
|
|
899
1116
|
this.options = {
|
|
900
|
-
layerId:
|
|
901
|
-
visible:
|
|
902
|
-
idKey:
|
|
1117
|
+
layerId: n,
|
|
1118
|
+
visible: r.visible ?? !0,
|
|
1119
|
+
idKey: r.idKey || "id"
|
|
903
1120
|
}, this.defaultPayload = {
|
|
904
|
-
...
|
|
905
|
-
layerId:
|
|
1121
|
+
...r,
|
|
1122
|
+
layerId: n,
|
|
906
1123
|
visible: this.options.visible
|
|
907
1124
|
}, this.baseGIS = null, this.currentPayload = null, this.layerType = "unknown", this.visible = this.options.visible, this.currentState = {
|
|
908
|
-
layerId:
|
|
1125
|
+
layerId: n,
|
|
909
1126
|
visible: this.visible,
|
|
910
1127
|
total: 0,
|
|
911
1128
|
renderedCount: 0,
|
|
@@ -915,127 +1132,127 @@ class ze {
|
|
|
915
1132
|
}, (e.mapCore || e.baseGIS) && this.mount(e.mapCore || e.baseGIS);
|
|
916
1133
|
}
|
|
917
1134
|
mount(e) {
|
|
918
|
-
var
|
|
919
|
-
return
|
|
920
|
-
{ engineType: ((
|
|
1135
|
+
var r, n;
|
|
1136
|
+
return tt(e) ? (this.baseGIS = e, L(
|
|
1137
|
+
{ engineType: ((n = (r = this.baseGIS).getEngineType) == null ? void 0 : n.call(r)) || "unknown" },
|
|
921
1138
|
"PointLargeLayerController mounted with BaseGIS."
|
|
922
|
-
)) :
|
|
1139
|
+
)) : I(
|
|
923
1140
|
"PointLargeLayerController mount requires BaseGIS instance.",
|
|
924
1141
|
"INVALID_MOUNT_TARGET"
|
|
925
1142
|
);
|
|
926
1143
|
}
|
|
927
1144
|
resolveBaseGIS() {
|
|
928
|
-
var e,
|
|
929
|
-
return this.baseGIS ? (
|
|
1145
|
+
var e, r;
|
|
1146
|
+
return this.baseGIS ? (r = (e = this.baseGIS).getMapInstance) != null && r.call(e) ? L(null, "BaseGIS is ready.") : I(
|
|
930
1147
|
"Map instance is not ready. Please call mapCore.init() first.",
|
|
931
1148
|
"NOT_INITIALIZED"
|
|
932
|
-
) :
|
|
1149
|
+
) : I("PointLargeLayerController has not been mounted.", "NOT_MOUNTED");
|
|
933
1150
|
}
|
|
934
|
-
getLayerId(e = {},
|
|
935
|
-
var
|
|
936
|
-
const { allowId:
|
|
937
|
-
return typeof e == "string" && e ? e : (e == null ? void 0 : e.pointLargeLayerId) || (e == null ? void 0 : e.largeLayerId) || (e == null ? void 0 : e.layerId) || (
|
|
1151
|
+
getLayerId(e = {}, r = {}) {
|
|
1152
|
+
var s;
|
|
1153
|
+
const { allowId: n = !0 } = r;
|
|
1154
|
+
return typeof e == "string" && e ? e : (e == null ? void 0 : e.pointLargeLayerId) || (e == null ? void 0 : e.largeLayerId) || (e == null ? void 0 : e.layerId) || (n ? e == null ? void 0 : e.id : "") || ((s = this.currentPayload) == null ? void 0 : s.layerId) || this.options.layerId;
|
|
938
1155
|
}
|
|
939
1156
|
buildPayload(e = {}) {
|
|
940
|
-
const
|
|
1157
|
+
const r = k(e), n = this.getLayerId(r);
|
|
941
1158
|
return {
|
|
942
1159
|
...this.defaultPayload,
|
|
943
|
-
...
|
|
944
|
-
layerId:
|
|
945
|
-
visible: typeof
|
|
1160
|
+
...r,
|
|
1161
|
+
layerId: n,
|
|
1162
|
+
visible: typeof r.visible == "boolean" ? r.visible : this.visible
|
|
946
1163
|
};
|
|
947
1164
|
}
|
|
948
1165
|
syncStateFromResult(e) {
|
|
949
|
-
var
|
|
950
|
-
const
|
|
951
|
-
!
|
|
1166
|
+
var n;
|
|
1167
|
+
const r = ((n = e == null ? void 0 : e.data) == null ? void 0 : n.state) || (e == null ? void 0 : e.data) || null;
|
|
1168
|
+
!r || typeof r != "object" || (this.currentState = {
|
|
952
1169
|
...this.currentState,
|
|
953
|
-
...
|
|
954
|
-
}, typeof
|
|
1170
|
+
...r
|
|
1171
|
+
}, typeof r.visible == "boolean" && (this.visible = r.visible));
|
|
955
1172
|
}
|
|
956
1173
|
/**
|
|
957
1174
|
* 加载或重建海量点位。
|
|
958
1175
|
* 支持 load(points, options) 或 load({ points, ...options }) 两种调用方式。
|
|
959
1176
|
*/
|
|
960
|
-
async load(e = {},
|
|
961
|
-
var
|
|
962
|
-
const
|
|
963
|
-
if (!
|
|
964
|
-
return
|
|
965
|
-
const
|
|
966
|
-
...
|
|
967
|
-
...
|
|
1177
|
+
async load(e = {}, r = {}) {
|
|
1178
|
+
var c;
|
|
1179
|
+
const n = this.resolveBaseGIS();
|
|
1180
|
+
if (!n.success)
|
|
1181
|
+
return n;
|
|
1182
|
+
const s = k(e), i = k(r), o = this.buildPayload({
|
|
1183
|
+
...s,
|
|
1184
|
+
...i
|
|
968
1185
|
});
|
|
969
|
-
if (!
|
|
970
|
-
return
|
|
1186
|
+
if (!be(o))
|
|
1187
|
+
return I(
|
|
971
1188
|
"Point large layer requires points, data or items.",
|
|
972
1189
|
"INVALID_POINT_SOURCE"
|
|
973
1190
|
);
|
|
974
|
-
const
|
|
975
|
-
return
|
|
1191
|
+
const a = await this.baseGIS.upsertPointLargeLayer(o);
|
|
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;
|
|
976
1193
|
}
|
|
977
|
-
upsert(e = {},
|
|
978
|
-
return this.load(e,
|
|
1194
|
+
upsert(e = {}, r = {}) {
|
|
1195
|
+
return this.load(e, r);
|
|
979
1196
|
}
|
|
980
1197
|
async update(e = {}) {
|
|
981
|
-
const
|
|
1198
|
+
const r = {
|
|
982
1199
|
...this.currentPayload || this.defaultPayload,
|
|
983
|
-
...
|
|
1200
|
+
...k(e)
|
|
984
1201
|
};
|
|
985
|
-
return !this.currentPayload && !
|
|
1202
|
+
return !this.currentPayload && !be(r) ? I("Point large layer has not been loaded.", "NOT_LOADED") : this.load(r);
|
|
986
1203
|
}
|
|
987
1204
|
show(e = {}) {
|
|
988
|
-
const
|
|
989
|
-
if (!
|
|
990
|
-
return
|
|
991
|
-
const
|
|
1205
|
+
const r = this.resolveBaseGIS();
|
|
1206
|
+
if (!r.success)
|
|
1207
|
+
return r;
|
|
1208
|
+
const n = this.baseGIS.showPointLargeLayer({
|
|
992
1209
|
...e,
|
|
993
1210
|
layerId: this.getLayerId(e)
|
|
994
1211
|
});
|
|
995
|
-
return
|
|
1212
|
+
return n.success && (this.visible = !0, this.syncStateFromResult(n)), n;
|
|
996
1213
|
}
|
|
997
1214
|
hide(e = {}) {
|
|
998
|
-
const
|
|
999
|
-
if (!
|
|
1000
|
-
return
|
|
1001
|
-
const
|
|
1215
|
+
const r = this.resolveBaseGIS();
|
|
1216
|
+
if (!r.success)
|
|
1217
|
+
return r;
|
|
1218
|
+
const n = this.baseGIS.hidePointLargeLayer({
|
|
1002
1219
|
...e,
|
|
1003
1220
|
layerId: this.getLayerId(e)
|
|
1004
1221
|
});
|
|
1005
|
-
return
|
|
1222
|
+
return n.success && (this.visible = !1, this.syncStateFromResult(n)), n;
|
|
1006
1223
|
}
|
|
1007
1224
|
toggle(e) {
|
|
1008
1225
|
return typeof e == "boolean" ? e ? this.show() : this.hide() : this.visible ? this.hide() : this.show();
|
|
1009
1226
|
}
|
|
1010
|
-
setHighlight(e,
|
|
1011
|
-
const
|
|
1012
|
-
if (!
|
|
1013
|
-
return
|
|
1014
|
-
const
|
|
1015
|
-
if (
|
|
1016
|
-
return
|
|
1017
|
-
const
|
|
1018
|
-
...
|
|
1019
|
-
layerId: this.getLayerId(
|
|
1020
|
-
pointId:
|
|
1227
|
+
setHighlight(e, r = {}) {
|
|
1228
|
+
const n = this.resolveBaseGIS();
|
|
1229
|
+
if (!n.success)
|
|
1230
|
+
return n;
|
|
1231
|
+
const s = e && typeof e == "object" && !Array.isArray(e) ? e : r, i = pe(e, s);
|
|
1232
|
+
if (i == null || i === "")
|
|
1233
|
+
return I("Point id is required when setting highlight.", "INVALID_POINT_ID");
|
|
1234
|
+
const o = this.baseGIS.setPointLargeHighlight({
|
|
1235
|
+
...s,
|
|
1236
|
+
layerId: this.getLayerId(s, { allowId: !1 }),
|
|
1237
|
+
pointId: i
|
|
1021
1238
|
});
|
|
1022
|
-
return
|
|
1239
|
+
return o.success && this.syncStateFromResult(o), o;
|
|
1023
1240
|
}
|
|
1024
|
-
highlight(e,
|
|
1025
|
-
return this.setHighlight(e,
|
|
1241
|
+
highlight(e, r = {}) {
|
|
1242
|
+
return this.setHighlight(e, r);
|
|
1026
1243
|
}
|
|
1027
|
-
setHighlighted(e,
|
|
1028
|
-
return this.setHighlight(e,
|
|
1244
|
+
setHighlighted(e, r = {}) {
|
|
1245
|
+
return this.setHighlight(e, r);
|
|
1029
1246
|
}
|
|
1030
1247
|
clearHighlight(e = {}) {
|
|
1031
|
-
const
|
|
1032
|
-
if (!
|
|
1033
|
-
return
|
|
1034
|
-
const
|
|
1248
|
+
const r = this.resolveBaseGIS();
|
|
1249
|
+
if (!r.success)
|
|
1250
|
+
return r;
|
|
1251
|
+
const n = this.baseGIS.clearPointLargeHighlight({
|
|
1035
1252
|
...e,
|
|
1036
1253
|
layerId: this.getLayerId(e)
|
|
1037
1254
|
});
|
|
1038
|
-
return
|
|
1255
|
+
return n.success && this.syncStateFromResult(n), n;
|
|
1039
1256
|
}
|
|
1040
1257
|
clearHighlighted(e = {}) {
|
|
1041
1258
|
return this.clearHighlight(e);
|
|
@@ -1043,79 +1260,79 @@ class ze {
|
|
|
1043
1260
|
removeCachedPoints(e = []) {
|
|
1044
1261
|
if (!this.currentPayload || !Array.isArray(this.currentPayload.points))
|
|
1045
1262
|
return;
|
|
1046
|
-
const
|
|
1263
|
+
const r = this.currentPayload.idKey || this.options.idKey, n = new Set(e.map((s) => String(s)));
|
|
1047
1264
|
this.currentPayload = {
|
|
1048
1265
|
...this.currentPayload,
|
|
1049
|
-
points: this.currentPayload.points.filter((
|
|
1050
|
-
const
|
|
1051
|
-
return !
|
|
1266
|
+
points: this.currentPayload.points.filter((s, i) => {
|
|
1267
|
+
const o = rt(s, r, i);
|
|
1268
|
+
return !n.has(String(o));
|
|
1052
1269
|
})
|
|
1053
1270
|
};
|
|
1054
1271
|
}
|
|
1055
|
-
removePoint(e,
|
|
1056
|
-
const
|
|
1057
|
-
if (!
|
|
1058
|
-
return
|
|
1059
|
-
const
|
|
1060
|
-
if (
|
|
1061
|
-
return
|
|
1062
|
-
const
|
|
1272
|
+
removePoint(e, r = {}) {
|
|
1273
|
+
const n = this.resolveBaseGIS();
|
|
1274
|
+
if (!n.success)
|
|
1275
|
+
return n;
|
|
1276
|
+
const s = e && typeof e == "object" && !Array.isArray(e) ? e : r, i = pe(e, s);
|
|
1277
|
+
if (i == null || i === "")
|
|
1278
|
+
return I("Point id is required when removing point.", "INVALID_POINT_ID");
|
|
1279
|
+
const o = this.baseGIS.removePointLargePoint({
|
|
1280
|
+
...s,
|
|
1281
|
+
layerId: this.getLayerId(s, { allowId: !1 }),
|
|
1282
|
+
pointId: i
|
|
1283
|
+
});
|
|
1284
|
+
return o.success && (this.removeCachedPoints([i]), this.syncStateFromResult(o)), o;
|
|
1285
|
+
}
|
|
1286
|
+
deletePoint(e, r = {}) {
|
|
1287
|
+
return this.removePoint(e, r);
|
|
1288
|
+
}
|
|
1289
|
+
removeById(e, r = {}) {
|
|
1290
|
+
return this.removePoint(e, r);
|
|
1291
|
+
}
|
|
1292
|
+
async removePoints(e = [], r = {}) {
|
|
1293
|
+
const n = this.resolveBaseGIS();
|
|
1294
|
+
if (!n.success)
|
|
1295
|
+
return n;
|
|
1296
|
+
const s = Array.isArray(e) ? e : [e];
|
|
1297
|
+
if (s.length === 0)
|
|
1298
|
+
return I("Point id list is required when removing points.", "INVALID_POINT_ID");
|
|
1299
|
+
const i = this.baseGIS.removePointLargePoints({
|
|
1063
1300
|
...r,
|
|
1064
1301
|
layerId: this.getLayerId(r, { allowId: !1 }),
|
|
1065
|
-
|
|
1066
|
-
});
|
|
1067
|
-
return a.success && (this.removeCachedPoints([n]), this.syncStateFromResult(a)), a;
|
|
1068
|
-
}
|
|
1069
|
-
deletePoint(e, t = {}) {
|
|
1070
|
-
return this.removePoint(e, t);
|
|
1071
|
-
}
|
|
1072
|
-
removeById(e, t = {}) {
|
|
1073
|
-
return this.removePoint(e, t);
|
|
1074
|
-
}
|
|
1075
|
-
async removePoints(e = [], t = {}) {
|
|
1076
|
-
const s = this.resolveBaseGIS();
|
|
1077
|
-
if (!s.success)
|
|
1078
|
-
return s;
|
|
1079
|
-
const r = Array.isArray(e) ? e : [e];
|
|
1080
|
-
if (r.length === 0)
|
|
1081
|
-
return c("Point id list is required when removing points.", "INVALID_POINT_ID");
|
|
1082
|
-
const n = this.baseGIS.removePointLargePoints({
|
|
1083
|
-
...t,
|
|
1084
|
-
layerId: this.getLayerId(t, { allowId: !1 }),
|
|
1085
|
-
pointIds: r
|
|
1302
|
+
pointIds: s
|
|
1086
1303
|
});
|
|
1087
|
-
return
|
|
1304
|
+
return i.success && (this.removeCachedPoints(s), this.syncStateFromResult(i)), i;
|
|
1088
1305
|
}
|
|
1089
|
-
deletePoints(e = [],
|
|
1090
|
-
return this.removePoints(e,
|
|
1306
|
+
deletePoints(e = [], r = {}) {
|
|
1307
|
+
return this.removePoints(e, r);
|
|
1091
1308
|
}
|
|
1092
|
-
removeByIds(e = [],
|
|
1093
|
-
return this.removePoints(e,
|
|
1309
|
+
removeByIds(e = [], r = {}) {
|
|
1310
|
+
return this.removePoints(e, r);
|
|
1094
1311
|
}
|
|
1095
1312
|
clear(e = {}) {
|
|
1096
|
-
const
|
|
1097
|
-
if (!
|
|
1098
|
-
return
|
|
1099
|
-
const
|
|
1313
|
+
const r = this.resolveBaseGIS();
|
|
1314
|
+
if (!r.success)
|
|
1315
|
+
return r;
|
|
1316
|
+
const n = this.baseGIS.clearPointLargeLayer({
|
|
1100
1317
|
...e,
|
|
1101
1318
|
layerId: this.getLayerId(e)
|
|
1102
1319
|
});
|
|
1103
|
-
return
|
|
1320
|
+
return n.success && (this.currentPayload = this.currentPayload ? {
|
|
1104
1321
|
...this.currentPayload,
|
|
1105
1322
|
points: [],
|
|
1106
1323
|
data: [],
|
|
1107
1324
|
items: []
|
|
1108
|
-
} : null, this.syncStateFromResult(
|
|
1325
|
+
} : null, this.syncStateFromResult(n)), n;
|
|
1109
1326
|
}
|
|
1110
1327
|
refreshState(e = {}) {
|
|
1111
|
-
const
|
|
1112
|
-
if (!
|
|
1113
|
-
return
|
|
1114
|
-
const
|
|
1328
|
+
const r = this.resolveBaseGIS();
|
|
1329
|
+
if (!r.success)
|
|
1330
|
+
return r;
|
|
1331
|
+
const n = this.baseGIS.getPointLargeLayerState({
|
|
1115
1332
|
...e,
|
|
1116
1333
|
layerId: this.getLayerId(e)
|
|
1117
1334
|
});
|
|
1118
|
-
return
|
|
1335
|
+
return n.success && this.syncStateFromResult(n), n;
|
|
1119
1336
|
}
|
|
1120
1337
|
/**
|
|
1121
1338
|
* 销毁图层。
|
|
@@ -1129,8 +1346,8 @@ class ze {
|
|
|
1129
1346
|
renderedCount: 0,
|
|
1130
1347
|
building: !1,
|
|
1131
1348
|
destroyed: !0
|
|
1132
|
-
},
|
|
1133
|
-
const
|
|
1349
|
+
}, L(null, "Point large layer controller destroyed (local state only).");
|
|
1350
|
+
const n = this.baseGIS.removePointLargeLayer({
|
|
1134
1351
|
...e,
|
|
1135
1352
|
layerId: this.getLayerId(e)
|
|
1136
1353
|
});
|
|
@@ -1140,190 +1357,1135 @@ class ze {
|
|
|
1140
1357
|
renderedCount: 0,
|
|
1141
1358
|
building: !1,
|
|
1142
1359
|
destroyed: !0
|
|
1143
|
-
},
|
|
1360
|
+
}, n.success ? L(null, "Point large layer controller destroyed.") : n;
|
|
1144
1361
|
}
|
|
1145
1362
|
removeLayer(e = {}) {
|
|
1146
1363
|
return this.destroy(e);
|
|
1147
1364
|
}
|
|
1148
1365
|
getState() {
|
|
1149
|
-
var e,
|
|
1150
|
-
if ((
|
|
1151
|
-
const
|
|
1366
|
+
var e, r, n, s, i, o, a;
|
|
1367
|
+
if ((r = (e = this.baseGIS) == null ? void 0 : e.getMapInstance) != null && r.call(e) && this.currentPayload) {
|
|
1368
|
+
const c = (s = (n = this.baseGIS).getPointLargeLayerState) == null ? void 0 : s.call(n, {
|
|
1152
1369
|
layerId: this.currentPayload.layerId || this.options.layerId
|
|
1153
1370
|
});
|
|
1154
|
-
|
|
1371
|
+
c != null && c.success && this.syncStateFromResult(c);
|
|
1155
1372
|
}
|
|
1156
1373
|
return {
|
|
1157
1374
|
mounted: !!this.baseGIS,
|
|
1158
|
-
engineType: ((
|
|
1375
|
+
engineType: ((o = (i = this.baseGIS) == null ? void 0 : i.getEngineType) == null ? void 0 : o.call(i)) || "unknown",
|
|
1159
1376
|
layerType: this.layerType,
|
|
1160
1377
|
visible: this.visible,
|
|
1161
|
-
layerId: ((
|
|
1378
|
+
layerId: ((a = this.currentPayload) == null ? void 0 : a.layerId) || this.options.layerId,
|
|
1162
1379
|
payload: this.currentPayload,
|
|
1163
1380
|
...this.currentState
|
|
1164
1381
|
};
|
|
1165
1382
|
}
|
|
1166
1383
|
}
|
|
1167
|
-
function
|
|
1384
|
+
function st(t, e) {
|
|
1385
|
+
let r = 0;
|
|
1386
|
+
for (let n of t)
|
|
1387
|
+
n != null && (n = +n) >= n && ++r;
|
|
1388
|
+
return r;
|
|
1389
|
+
}
|
|
1390
|
+
function it(t, e) {
|
|
1391
|
+
let r, n;
|
|
1392
|
+
if (e === void 0)
|
|
1393
|
+
for (const s of t)
|
|
1394
|
+
s != null && (r === void 0 ? s >= s && (r = n = s) : (r > s && (r = s), n < s && (n = s)));
|
|
1395
|
+
else {
|
|
1396
|
+
let s = -1;
|
|
1397
|
+
for (let i of t)
|
|
1398
|
+
(i = e(i, ++s, t)) != null && (r === void 0 ? i >= i && (r = n = i) : (r > i && (r = i), n < i && (n = i)));
|
|
1399
|
+
}
|
|
1400
|
+
return [r, n];
|
|
1401
|
+
}
|
|
1402
|
+
const ot = Math.sqrt(50), at = Math.sqrt(10), lt = Math.sqrt(2);
|
|
1403
|
+
function K(t, e, r) {
|
|
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, 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
|
+
}
|
|
1408
|
+
function ct(t, e, r) {
|
|
1409
|
+
if (e = +e, t = +t, r = +r, !(r > 0)) return [];
|
|
1410
|
+
if (t === e) return [t];
|
|
1411
|
+
const n = e < t, [s, i, o] = n ? K(e, t, r) : K(t, e, r);
|
|
1412
|
+
if (!(i >= s)) return [];
|
|
1413
|
+
const a = i - s + 1, c = new Array(a);
|
|
1414
|
+
if (n)
|
|
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
|
+
}
|
|
1421
|
+
function ut(t, e, r) {
|
|
1422
|
+
return e = +e, t = +t, r = +r, K(t, e, r)[2];
|
|
1423
|
+
}
|
|
1424
|
+
function ht(t, e, r) {
|
|
1425
|
+
let n;
|
|
1426
|
+
for (; ; ) {
|
|
1427
|
+
const s = ut(t, e, r);
|
|
1428
|
+
if (s === n || s === 0 || !isFinite(s))
|
|
1429
|
+
return [t, e];
|
|
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;
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
function dt(t) {
|
|
1434
|
+
return Math.max(1, Math.ceil(Math.log(st(t)) / Math.LN2) + 1);
|
|
1435
|
+
}
|
|
1436
|
+
var ft = Array.prototype, yt = ft.slice;
|
|
1437
|
+
function gt(t, e) {
|
|
1438
|
+
return t - e;
|
|
1439
|
+
}
|
|
1440
|
+
function mt(t) {
|
|
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
|
+
return n;
|
|
1443
|
+
}
|
|
1444
|
+
const Le = (t) => () => t;
|
|
1445
|
+
function It(t, e) {
|
|
1446
|
+
for (var r = -1, n = e.length, s; ++r < n; ) if (s = bt(t, e[r])) return s;
|
|
1447
|
+
return 0;
|
|
1448
|
+
}
|
|
1449
|
+
function bt(t, e) {
|
|
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 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
|
+
}
|
|
1455
|
+
return s;
|
|
1456
|
+
}
|
|
1457
|
+
function pt(t, e, r) {
|
|
1458
|
+
var n;
|
|
1459
|
+
return Lt(t, e, r) && Ct(t[n = +(t[0] === e[0])], r[n], e[n]);
|
|
1460
|
+
}
|
|
1461
|
+
function Lt(t, e, r) {
|
|
1462
|
+
return (e[0] - t[0]) * (r[1] - t[1]) === (r[0] - t[0]) * (e[1] - t[1]);
|
|
1463
|
+
}
|
|
1464
|
+
function Ct(t, e, r) {
|
|
1465
|
+
return t <= e && e <= r || r <= e && e <= t;
|
|
1466
|
+
}
|
|
1467
|
+
function St() {
|
|
1468
|
+
}
|
|
1469
|
+
var F = [
|
|
1470
|
+
[],
|
|
1471
|
+
[[[1, 1.5], [0.5, 1]]],
|
|
1472
|
+
[[[1.5, 1], [1, 1.5]]],
|
|
1473
|
+
[[[1.5, 1], [0.5, 1]]],
|
|
1474
|
+
[[[1, 0.5], [1.5, 1]]],
|
|
1475
|
+
[[[1, 1.5], [0.5, 1]], [[1, 0.5], [1.5, 1]]],
|
|
1476
|
+
[[[1, 0.5], [1, 1.5]]],
|
|
1477
|
+
[[[1, 0.5], [0.5, 1]]],
|
|
1478
|
+
[[[0.5, 1], [1, 0.5]]],
|
|
1479
|
+
[[[1, 1.5], [1, 0.5]]],
|
|
1480
|
+
[[[0.5, 1], [1, 0.5]], [[1.5, 1], [1, 1.5]]],
|
|
1481
|
+
[[[1.5, 1], [1, 0.5]]],
|
|
1482
|
+
[[[0.5, 1], [1.5, 1]]],
|
|
1483
|
+
[[[1, 1.5], [1.5, 1]]],
|
|
1484
|
+
[[[0.5, 1], [1, 1.5]]],
|
|
1485
|
+
[]
|
|
1486
|
+
];
|
|
1487
|
+
function vt() {
|
|
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
|
+
else {
|
|
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
|
+
}
|
|
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
|
+
}), f.forEach(function(y) {
|
|
1507
|
+
for (var b = 0, g = d.length, p; b < g; ++b)
|
|
1508
|
+
if (It((p = d[b])[0], y) !== -1) {
|
|
1509
|
+
p.push(y);
|
|
1510
|
+
return;
|
|
1511
|
+
}
|
|
1512
|
+
}), {
|
|
1513
|
+
type: "MultiPolygon",
|
|
1514
|
+
value: u,
|
|
1515
|
+
coordinates: d
|
|
1516
|
+
};
|
|
1517
|
+
}
|
|
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
|
+
}
|
|
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
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
function a(l) {
|
|
1536
|
+
return l[0] * 2 + l[1] * (t + 1) * 4;
|
|
1537
|
+
}
|
|
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
|
+
});
|
|
1543
|
+
}
|
|
1544
|
+
return s.contour = i, s.size = function(l) {
|
|
1545
|
+
if (!arguments.length) return [t, e];
|
|
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
|
+
}, s;
|
|
1554
|
+
}
|
|
1555
|
+
function wt(t) {
|
|
1556
|
+
return isFinite(t) ? t : NaN;
|
|
1557
|
+
}
|
|
1558
|
+
function z(t, e) {
|
|
1559
|
+
return t == null ? !1 : +t >= e;
|
|
1560
|
+
}
|
|
1561
|
+
function Z(t) {
|
|
1562
|
+
return t == null || isNaN(t = +t) ? -1 / 0 : t;
|
|
1563
|
+
}
|
|
1564
|
+
function Ce(t, e, r, n) {
|
|
1565
|
+
const s = n - e, i = r - e, o = isFinite(s) || isFinite(i) ? s / i : Math.sign(s) / Math.sign(i);
|
|
1566
|
+
return isNaN(o) ? t : t + o - 0.5;
|
|
1567
|
+
}
|
|
1568
|
+
const Se = 6378137, ve = 85.0511287798066, we = 1e6;
|
|
1569
|
+
function G(t, e = null) {
|
|
1570
|
+
const r = Number(t);
|
|
1571
|
+
return Number.isFinite(r) ? r : e;
|
|
1572
|
+
}
|
|
1573
|
+
function Fe(t, e) {
|
|
1574
|
+
return Object.prototype.hasOwnProperty.call(t || {}, e);
|
|
1575
|
+
}
|
|
1576
|
+
function Oe(t) {
|
|
1577
|
+
if (Array.isArray(t) && t.length >= 4) {
|
|
1578
|
+
const [i, o, a, c] = t.map(Number);
|
|
1579
|
+
if ([i, o, a, c].every(Number.isFinite))
|
|
1580
|
+
return {
|
|
1581
|
+
startLon: Math.min(i, a),
|
|
1582
|
+
startLat: Math.min(o, c),
|
|
1583
|
+
endLon: Math.max(i, a),
|
|
1584
|
+
endLat: Math.max(o, c)
|
|
1585
|
+
};
|
|
1586
|
+
}
|
|
1587
|
+
if (!t || typeof t != "object")
|
|
1588
|
+
return null;
|
|
1589
|
+
const e = Number(t.startLon ?? t.west ?? t.minLon), r = Number(t.startLat ?? t.south ?? t.minLat), n = Number(t.endLon ?? t.east ?? t.maxLon), s = Number(t.endLat ?? t.north ?? t.maxLat);
|
|
1590
|
+
return [e, r, n, s].every(Number.isFinite) ? {
|
|
1591
|
+
startLon: Math.min(e, n),
|
|
1592
|
+
startLat: Math.min(r, s),
|
|
1593
|
+
endLon: Math.max(e, n),
|
|
1594
|
+
endLat: Math.max(r, s)
|
|
1595
|
+
} : null;
|
|
1596
|
+
}
|
|
1597
|
+
function ie(t = "") {
|
|
1598
|
+
const e = String(t || "").trim().toUpperCase().replace("::", ":");
|
|
1599
|
+
return ["3857", "EPSG:3857", "EPSG:900913", "900913"].includes(e) ? "EPSG:3857" : ["4326", "EPSG:4326", "WGS84", "WGS 84"].includes(e) ? "EPSG:4326" : e;
|
|
1600
|
+
}
|
|
1601
|
+
function Pt(t = {}, e = []) {
|
|
1602
|
+
const r = Number(t.ProjectedCSTypeGeoKey);
|
|
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
|
+
}
|
|
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
|
+
return {
|
|
1608
|
+
lng: r,
|
|
1609
|
+
lat: Math.min(Math.max(n, -ve), ve)
|
|
1610
|
+
};
|
|
1611
|
+
}
|
|
1612
|
+
function Q(t) {
|
|
1613
|
+
return !Number.isFinite(t) || t >= -180 && t <= 180 ? t : ((t + 180) % 360 + 360) % 360 - 180;
|
|
1614
|
+
}
|
|
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;
|
|
1623
|
+
return {
|
|
1624
|
+
area: o,
|
|
1625
|
+
projection: "EPSG:4326",
|
|
1626
|
+
map(b, g) {
|
|
1627
|
+
return [
|
|
1628
|
+
o.endLat - g / s * y,
|
|
1629
|
+
Q(o.startLon + b / n * f)
|
|
1630
|
+
];
|
|
1631
|
+
}
|
|
1632
|
+
};
|
|
1633
|
+
}
|
|
1634
|
+
if (!Array.isArray(e) || e.length < 4 || !e.slice(0, 4).every(Number.isFinite))
|
|
1635
|
+
throw new Error("栅格缺少地理范围,请通过 area 提供 [west, south, east, north]。");
|
|
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)
|
|
1640
|
+
throw new Error("栅格地理范围无效,宽度或高度为 0。");
|
|
1641
|
+
if (r === "EPSG:3857") {
|
|
1642
|
+
const f = J(a, c), y = J(l, u);
|
|
1643
|
+
return {
|
|
1644
|
+
area: {
|
|
1645
|
+
startLon: f.lng,
|
|
1646
|
+
startLat: f.lat,
|
|
1647
|
+
endLon: y.lng,
|
|
1648
|
+
endLat: y.lat
|
|
1649
|
+
},
|
|
1650
|
+
projection: r,
|
|
1651
|
+
map(b, g) {
|
|
1652
|
+
const p = J(
|
|
1653
|
+
a + b / n * h,
|
|
1654
|
+
u - g / s * d
|
|
1655
|
+
);
|
|
1656
|
+
return [p.lat, Q(p.lng)];
|
|
1657
|
+
}
|
|
1658
|
+
};
|
|
1659
|
+
}
|
|
1660
|
+
if (r && r !== "EPSG:4326")
|
|
1661
|
+
throw new Error(`暂不支持 ${r} 栅格,请传入 WGS84 area 覆盖原始范围。`);
|
|
1662
|
+
return {
|
|
1663
|
+
area: {
|
|
1664
|
+
startLon: a,
|
|
1665
|
+
startLat: c,
|
|
1666
|
+
endLon: l,
|
|
1667
|
+
endLat: u
|
|
1668
|
+
},
|
|
1669
|
+
projection: r || "EPSG:4326",
|
|
1670
|
+
map(f, y) {
|
|
1671
|
+
return [u - y / s * d, Q(a + f / n * h)];
|
|
1672
|
+
}
|
|
1673
|
+
};
|
|
1674
|
+
}
|
|
1675
|
+
function Gt(t = {}) {
|
|
1676
|
+
const e = String(t.sourceType || t.dataType || "").toLowerCase();
|
|
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" : "";
|
|
1678
|
+
}
|
|
1679
|
+
function Mt() {
|
|
1680
|
+
return typeof window > "u" ? null : window.GeoTIFF || null;
|
|
1681
|
+
}
|
|
1682
|
+
function Tt(t, e = {}, r = null) {
|
|
1683
|
+
if (!Number.isFinite(t)) return !0;
|
|
1684
|
+
const n = Fe(e, "noDataValue") ? Number(e.noDataValue) : r;
|
|
1685
|
+
if (Number.isFinite(n) && t === n) return !0;
|
|
1686
|
+
const s = G(e.validMin), i = G(e.validMax);
|
|
1687
|
+
return s !== null && t < s || i !== null && t > i;
|
|
1688
|
+
}
|
|
1689
|
+
function De(t, e = {}, r = null) {
|
|
1690
|
+
const n = G(e.scale, 1), s = G(e.offset, 0), i = new Float64Array(t.length);
|
|
1691
|
+
for (let o = 0; o < t.length; o += 1) {
|
|
1692
|
+
const a = Number(t[o]);
|
|
1693
|
+
i[o] = Tt(a, e, r) ? Number.NaN : a * n + s;
|
|
1694
|
+
}
|
|
1695
|
+
return i;
|
|
1696
|
+
}
|
|
1697
|
+
function Be(t, e, r) {
|
|
1698
|
+
const n = new Float64Array(t.length), s = Math.floor(e / 2);
|
|
1699
|
+
for (let i = 0; i < r; i += 1)
|
|
1700
|
+
for (let o = 0; o < e; o += 1) {
|
|
1701
|
+
const a = (o + s) % e;
|
|
1702
|
+
n[i * e + o] = t[i * e + a];
|
|
1703
|
+
}
|
|
1704
|
+
return n;
|
|
1705
|
+
}
|
|
1706
|
+
async function xt(t = {}) {
|
|
1707
|
+
var m, v, S;
|
|
1708
|
+
const e = Mt();
|
|
1709
|
+
if (!e)
|
|
1710
|
+
throw new Error("GeoTIFF 未加载,请先提供 window.GeoTIFF。");
|
|
1711
|
+
let r = t.arrayBuffer || null;
|
|
1712
|
+
const n = t.tifUrl || t.tiffUrl || "";
|
|
1713
|
+
if (!r) {
|
|
1714
|
+
if (!n) throw new Error("GeoTIFF 数据源缺少 tifUrl。");
|
|
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));
|
|
1723
|
+
let y = [];
|
|
1724
|
+
try {
|
|
1725
|
+
y = ((v = o.getBoundingBox) == null ? void 0 : v.call(o)) || [];
|
|
1726
|
+
} catch (P) {
|
|
1727
|
+
if (!t.area) throw P;
|
|
1728
|
+
}
|
|
1729
|
+
const b = ((S = o.getGeoKeys) == null ? void 0 : S.call(o)) || {}, g = ie(t.sourceProjection) || Pt(b, y), p = ue({
|
|
1730
|
+
area: t.area,
|
|
1731
|
+
bbox: y,
|
|
1732
|
+
projection: g,
|
|
1733
|
+
width: a,
|
|
1734
|
+
height: c,
|
|
1735
|
+
isSplit: t.isSplit
|
|
1736
|
+
});
|
|
1737
|
+
return {
|
|
1738
|
+
sourceType: "geotiff",
|
|
1739
|
+
sourceUrl: n,
|
|
1740
|
+
width: a,
|
|
1741
|
+
height: c,
|
|
1742
|
+
values: f,
|
|
1743
|
+
sourceProjection: g,
|
|
1744
|
+
projection: p.projection,
|
|
1745
|
+
area: p.area,
|
|
1746
|
+
mapCoordinate: p.map,
|
|
1747
|
+
band: l
|
|
1748
|
+
};
|
|
1749
|
+
}
|
|
1750
|
+
function Nt(t) {
|
|
1751
|
+
return new Promise((e, r) => {
|
|
1752
|
+
const n = new Image();
|
|
1753
|
+
n.crossOrigin = "anonymous", n.onload = () => e(n), n.onerror = () => r(new Error(`灰度图加载失败:${t}`)), n.src = t;
|
|
1754
|
+
});
|
|
1755
|
+
}
|
|
1756
|
+
function At(t, e, r = "luminance") {
|
|
1757
|
+
return r === "red" ? t[e] : r === "green" ? t[e + 1] : r === "blue" ? t[e + 2] : r === "average" ? (t[e] + t[e + 1] + t[e + 2]) / 3 : t[e] * 0.2126 + t[e + 1] * 0.7152 + t[e + 2] * 0.0722;
|
|
1758
|
+
}
|
|
1759
|
+
async function Et(t = {}) {
|
|
1760
|
+
if (typeof document > "u" || typeof Image > "u")
|
|
1761
|
+
throw new Error("灰度图解析只能在浏览器环境中运行。");
|
|
1762
|
+
const e = t.grayImageUrl || t.imageUrl || "", r = Oe(t.area);
|
|
1763
|
+
if (!e) throw new Error("灰度图数据源缺少 grayImageUrl 或 imageUrl。");
|
|
1764
|
+
if (!r) throw new Error("灰度图没有地理信息,必须通过 area 提供覆盖范围。");
|
|
1765
|
+
const n = await Nt(e), s = n.naturalWidth || n.width, i = n.naturalHeight || n.height, o = document.createElement("canvas");
|
|
1766
|
+
o.width = s, o.height = i;
|
|
1767
|
+
const a = o.getContext("2d", { willReadFrequently: !0 });
|
|
1768
|
+
if (!a) throw new Error("当前浏览器不支持 Canvas 2D。");
|
|
1769
|
+
a.drawImage(n, 0, 0, s, i);
|
|
1770
|
+
let c;
|
|
1771
|
+
try {
|
|
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) {
|
|
1781
|
+
m[T] = Number.NaN;
|
|
1782
|
+
continue;
|
|
1783
|
+
}
|
|
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);
|
|
1786
|
+
}
|
|
1787
|
+
const v = ue({
|
|
1788
|
+
area: r,
|
|
1789
|
+
width: s,
|
|
1790
|
+
height: i,
|
|
1791
|
+
isSplit: t.isSplit
|
|
1792
|
+
});
|
|
1793
|
+
return {
|
|
1794
|
+
sourceType: "grayscale",
|
|
1795
|
+
sourceUrl: e,
|
|
1796
|
+
width: s,
|
|
1797
|
+
height: i,
|
|
1798
|
+
values: m,
|
|
1799
|
+
sourceProjection: "EPSG:4326",
|
|
1800
|
+
projection: v.projection,
|
|
1801
|
+
area: v.area,
|
|
1802
|
+
mapCoordinate: v.map,
|
|
1803
|
+
band: 0
|
|
1804
|
+
};
|
|
1805
|
+
}
|
|
1806
|
+
function Rt(t = {}) {
|
|
1807
|
+
var s;
|
|
1808
|
+
const e = t.values || t.data || t.grid;
|
|
1809
|
+
if (!e) return null;
|
|
1810
|
+
if (Array.isArray(e) && Array.isArray(e[0])) {
|
|
1811
|
+
const i = e.length, o = ((s = e[0]) == null ? void 0 : s.length) || 0;
|
|
1812
|
+
if (!o || e.some((a) => !Array.isArray(a) || a.length !== o))
|
|
1813
|
+
throw new Error("二维数值网格的每一行长度必须一致。");
|
|
1814
|
+
return {
|
|
1815
|
+
width: o,
|
|
1816
|
+
height: i,
|
|
1817
|
+
values: e.flat()
|
|
1818
|
+
};
|
|
1819
|
+
}
|
|
1820
|
+
const r = Math.floor(G(t.width, 0)), n = Math.floor(G(t.height, 0));
|
|
1821
|
+
if (r < 2 || n < 2 || e.length < r * n)
|
|
1822
|
+
throw new Error("一维数值网格必须提供正确的 width 和 height。");
|
|
1823
|
+
return { width: r, height: n, values: e };
|
|
1824
|
+
}
|
|
1825
|
+
function Ft(t = {}) {
|
|
1826
|
+
const e = Rt(t);
|
|
1827
|
+
if (!e) throw new Error("数值网格缺少 values、data 或 grid。");
|
|
1828
|
+
let r = De(e.values, t);
|
|
1829
|
+
t.isSplit && (r = Be(r, e.width, e.height));
|
|
1830
|
+
const n = ue({
|
|
1831
|
+
area: t.area,
|
|
1832
|
+
bbox: t.bbox,
|
|
1833
|
+
projection: ie(t.sourceProjection) || "EPSG:4326",
|
|
1834
|
+
width: e.width,
|
|
1835
|
+
height: e.height,
|
|
1836
|
+
isSplit: t.isSplit
|
|
1837
|
+
});
|
|
1838
|
+
return {
|
|
1839
|
+
sourceType: "grid",
|
|
1840
|
+
sourceUrl: "",
|
|
1841
|
+
width: e.width,
|
|
1842
|
+
height: e.height,
|
|
1843
|
+
values: r,
|
|
1844
|
+
sourceProjection: ie(t.sourceProjection) || "EPSG:4326",
|
|
1845
|
+
projection: n.projection,
|
|
1846
|
+
area: n.area,
|
|
1847
|
+
mapCoordinate: n.map,
|
|
1848
|
+
band: 0
|
|
1849
|
+
};
|
|
1850
|
+
}
|
|
1851
|
+
async function Ot(t = {}) {
|
|
1852
|
+
const e = Gt(t);
|
|
1853
|
+
if (e === "geotiff") return xt(t);
|
|
1854
|
+
if (e === "grayscale") return Et(t);
|
|
1855
|
+
if (e === "grid") return Ft(t);
|
|
1856
|
+
throw new Error("无法识别栅格数据源,请提供 tifUrl、grayImageUrl 或 values。");
|
|
1857
|
+
}
|
|
1858
|
+
function Dt(t) {
|
|
1859
|
+
let e = Number.POSITIVE_INFINITY, r = Number.NEGATIVE_INFINITY, n = 0;
|
|
1860
|
+
for (let s = 0; s < t.length; s += 1) {
|
|
1861
|
+
const i = Number(t[s]);
|
|
1862
|
+
Number.isFinite(i) && (e = Math.min(e, i), r = Math.max(r, i), n += 1);
|
|
1863
|
+
}
|
|
1864
|
+
if (!n) throw new Error("栅格中没有可用于生成等值线的有效数值。");
|
|
1865
|
+
return { min: e, max: r, validCount: n, noDataCount: t.length - n };
|
|
1866
|
+
}
|
|
1867
|
+
function Bt(t, e = we) {
|
|
1868
|
+
const r = Math.max(Math.floor(G(e, we)), 4);
|
|
1869
|
+
if (t.width * t.height <= r)
|
|
1870
|
+
return t;
|
|
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);
|
|
1872
|
+
for (let a = 0; a < i; a += 1) {
|
|
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];
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
return {
|
|
1880
|
+
...t,
|
|
1881
|
+
width: s,
|
|
1882
|
+
height: i,
|
|
1883
|
+
values: o,
|
|
1884
|
+
mapCoordinate(a, c) {
|
|
1885
|
+
return t.mapCoordinate(
|
|
1886
|
+
a / s * t.width,
|
|
1887
|
+
c / i * t.height
|
|
1888
|
+
);
|
|
1889
|
+
},
|
|
1890
|
+
downsampled: !0,
|
|
1891
|
+
originalWidth: t.width,
|
|
1892
|
+
originalHeight: t.height
|
|
1893
|
+
};
|
|
1894
|
+
}
|
|
1895
|
+
function Pe(t, e = 10) {
|
|
1896
|
+
const r = 10 ** e;
|
|
1897
|
+
return Math.round(t * r) / r;
|
|
1898
|
+
}
|
|
1899
|
+
function Ut(t, e = {}) {
|
|
1900
|
+
const r = e.thresholds || e.levels;
|
|
1901
|
+
if (Array.isArray(r))
|
|
1902
|
+
return [...new Set(r.map(Number).filter(Number.isFinite))].filter((o) => o > t.min && o < t.max).sort((o, a) => o - a);
|
|
1903
|
+
const n = G(e.interval ?? e.contourInterval);
|
|
1904
|
+
if (n !== null && n > 0) {
|
|
1905
|
+
const o = [];
|
|
1906
|
+
let a = Math.ceil(t.min / n) * n;
|
|
1907
|
+
for (; a < t.max && o.length < 200; )
|
|
1908
|
+
a > t.min && o.push(Pe(a)), a += n;
|
|
1909
|
+
return o;
|
|
1910
|
+
}
|
|
1911
|
+
const s = Math.min(
|
|
1912
|
+
Math.max(Math.floor(G(e.thresholdCount ?? e.levelCount, 12)), 1),
|
|
1913
|
+
100
|
|
1914
|
+
), i = (t.max - t.min) / (s + 1);
|
|
1915
|
+
return Array.from(
|
|
1916
|
+
{ length: s },
|
|
1917
|
+
(o, a) => Pe(t.min + i * (a + 1))
|
|
1918
|
+
);
|
|
1919
|
+
}
|
|
1920
|
+
function jt(t, e, r, n) {
|
|
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;
|
|
1922
|
+
}
|
|
1923
|
+
function zt(t = [], e, r) {
|
|
1924
|
+
const n = [...t];
|
|
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 [];
|
|
1926
|
+
const s = n.map(
|
|
1927
|
+
(c, l) => jt(c, n[(l + 1) % n.length], e, r)
|
|
1928
|
+
), i = s.findIndex(Boolean);
|
|
1929
|
+
if (i < 0)
|
|
1930
|
+
return [[...n, n[0]]];
|
|
1931
|
+
const o = [];
|
|
1932
|
+
let a = [];
|
|
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]) {
|
|
1936
|
+
a.length > 1 && o.push(a), a = [];
|
|
1937
|
+
continue;
|
|
1938
|
+
}
|
|
1939
|
+
a.length === 0 && a.push(n[l]), a.push(n[u]);
|
|
1940
|
+
}
|
|
1941
|
+
return a.length > 1 && o.push(a), o;
|
|
1942
|
+
}
|
|
1943
|
+
function Vt(t = {}) {
|
|
1944
|
+
return t.type === "Polygon" ? t.coordinates || [] : t.type === "MultiPolygon" ? (t.coordinates || []).flatMap((e) => e) : [];
|
|
1945
|
+
}
|
|
1946
|
+
function _t(t, e) {
|
|
1947
|
+
return (t == null ? void 0 : t[0]) === (e == null ? void 0 : e[0]) && (t == null ? void 0 : t[1]) === (e == null ? void 0 : e[1]);
|
|
1948
|
+
}
|
|
1949
|
+
function Wt(t = [], e = 0) {
|
|
1950
|
+
const r = Math.min(Math.max(Math.floor(e), 0), 3);
|
|
1951
|
+
if (r === 0 || t.length < 3) return t;
|
|
1952
|
+
const n = _t(t[0], t[t.length - 1]);
|
|
1953
|
+
let s = n ? t.slice(0, -1) : [...t];
|
|
1954
|
+
for (let i = 0; i < r; i += 1) {
|
|
1955
|
+
const o = n ? [] : [s[0]], a = n ? s.length : s.length - 1;
|
|
1956
|
+
for (let c = 0; c < a; c += 1) {
|
|
1957
|
+
const l = s[c], u = s[(c + 1) % s.length];
|
|
1958
|
+
o.push([
|
|
1959
|
+
l[0] * 0.75 + u[0] * 0.25,
|
|
1960
|
+
l[1] * 0.75 + u[1] * 0.25
|
|
1961
|
+
]), o.push([
|
|
1962
|
+
l[0] * 0.25 + u[0] * 0.75,
|
|
1963
|
+
l[1] * 0.25 + u[1] * 0.75
|
|
1964
|
+
]);
|
|
1965
|
+
}
|
|
1966
|
+
n || o.push(s[s.length - 1]), s = o;
|
|
1967
|
+
}
|
|
1968
|
+
return n ? [...s, s[0]] : s;
|
|
1969
|
+
}
|
|
1970
|
+
function $t(t, e, r = 6) {
|
|
1971
|
+
const n = 10 ** Math.max(Math.floor(r), 0), s = [];
|
|
1972
|
+
return t.forEach((i) => {
|
|
1973
|
+
const o = e(i[0], i[1]);
|
|
1974
|
+
if (!(o != null && o.every(Number.isFinite))) return;
|
|
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);
|
|
1977
|
+
}), s;
|
|
1978
|
+
}
|
|
1979
|
+
function kt(t, e = {}) {
|
|
1980
|
+
const r = Dt(t.values);
|
|
1981
|
+
if (r.min === r.max)
|
|
1982
|
+
throw new Error("栅格数值全部相同,无法生成等值线。");
|
|
1983
|
+
const n = Bt(t, e.maxCells), s = Ut(r, e);
|
|
1984
|
+
if (s.length === 0)
|
|
1985
|
+
throw new Error("当前值域内没有可用的等值线级别。");
|
|
1986
|
+
const i = vt().size([n.width, n.height]).smooth(e.smooth !== !1).thresholds(s)(n.values), o = Math.max(
|
|
1987
|
+
Math.floor(G(e.minimumLinePoints, 3)),
|
|
1988
|
+
2
|
|
1989
|
+
), a = Math.min(
|
|
1990
|
+
Math.max(Math.floor(G(e.smoothingIterations, 0)), 0),
|
|
1991
|
+
3
|
|
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);
|
|
1996
|
+
return {
|
|
1997
|
+
value: l.value,
|
|
1998
|
+
label: String(l.value),
|
|
1999
|
+
lines: h
|
|
2000
|
+
};
|
|
2001
|
+
});
|
|
2002
|
+
return {
|
|
2003
|
+
isolines: c,
|
|
2004
|
+
thresholds: s,
|
|
2005
|
+
range: r,
|
|
2006
|
+
renderWidth: n.width,
|
|
2007
|
+
renderHeight: n.height,
|
|
2008
|
+
downsampled: !!n.downsampled,
|
|
2009
|
+
lineCount: c.reduce((l, u) => l + u.lines.length, 0)
|
|
2010
|
+
};
|
|
2011
|
+
}
|
|
2012
|
+
const qt = /* @__PURE__ */ new Set([
|
|
2013
|
+
"arrayBuffer",
|
|
2014
|
+
"area",
|
|
2015
|
+
"band",
|
|
2016
|
+
"bbox",
|
|
2017
|
+
"contourInterval",
|
|
2018
|
+
"coordinatePrecision",
|
|
2019
|
+
"data",
|
|
2020
|
+
"dataType",
|
|
2021
|
+
"excludeBoundary",
|
|
2022
|
+
"grayChannel",
|
|
2023
|
+
"grayImageUrl",
|
|
2024
|
+
"grayMaxValue",
|
|
2025
|
+
"grayMinValue",
|
|
2026
|
+
"grid",
|
|
2027
|
+
"imageIndex",
|
|
2028
|
+
"imageUrl",
|
|
2029
|
+
"interval",
|
|
2030
|
+
"invert",
|
|
2031
|
+
"isSplit",
|
|
2032
|
+
"levelCount",
|
|
2033
|
+
"levels",
|
|
2034
|
+
"maxCells",
|
|
2035
|
+
"maxValue",
|
|
2036
|
+
"minValue",
|
|
2037
|
+
"minimumLinePoints",
|
|
2038
|
+
"noDataValue",
|
|
2039
|
+
"offset",
|
|
2040
|
+
"scale",
|
|
2041
|
+
"smooth",
|
|
2042
|
+
"smoothingIterations",
|
|
2043
|
+
"sourceProjection",
|
|
2044
|
+
"sourceType",
|
|
2045
|
+
"thresholdCount",
|
|
2046
|
+
"thresholds",
|
|
2047
|
+
"tifUrl",
|
|
2048
|
+
"tiffUrl",
|
|
2049
|
+
"validMax",
|
|
2050
|
+
"validMin",
|
|
2051
|
+
"values",
|
|
2052
|
+
"width",
|
|
2053
|
+
"height"
|
|
2054
|
+
]), Ht = /* @__PURE__ */ new Set([
|
|
2055
|
+
"arrayBuffer",
|
|
2056
|
+
"area",
|
|
2057
|
+
"band",
|
|
2058
|
+
"bbox",
|
|
2059
|
+
"data",
|
|
2060
|
+
"dataType",
|
|
2061
|
+
"grayChannel",
|
|
2062
|
+
"grayImageUrl",
|
|
2063
|
+
"grayMaxValue",
|
|
2064
|
+
"grayMinValue",
|
|
2065
|
+
"grid",
|
|
2066
|
+
"height",
|
|
2067
|
+
"imageIndex",
|
|
2068
|
+
"imageUrl",
|
|
2069
|
+
"invert",
|
|
2070
|
+
"isSplit",
|
|
2071
|
+
"maxValue",
|
|
2072
|
+
"minValue",
|
|
2073
|
+
"noDataValue",
|
|
2074
|
+
"offset",
|
|
2075
|
+
"scale",
|
|
2076
|
+
"sourceProjection",
|
|
2077
|
+
"sourceType",
|
|
2078
|
+
"tifUrl",
|
|
2079
|
+
"tiffUrl",
|
|
2080
|
+
"validMax",
|
|
2081
|
+
"validMin",
|
|
2082
|
+
"values",
|
|
2083
|
+
"width"
|
|
2084
|
+
]);
|
|
2085
|
+
function Yt(t = {}) {
|
|
2086
|
+
const { mapCore: e, baseGIS: r, ...n } = t;
|
|
2087
|
+
return n;
|
|
2088
|
+
}
|
|
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);
|
|
2093
|
+
}), {
|
|
2094
|
+
...n,
|
|
2095
|
+
layerId: t.layerId || t.contourLayerId || "raster-contour-default",
|
|
2096
|
+
coordinateOrder: "latlng",
|
|
2097
|
+
// Leaflet 使用栅格真实范围动态创建当前视野需要的世界副本。
|
|
2098
|
+
worldCopyArea: t.worldCopyArea || r,
|
|
2099
|
+
isolines: e
|
|
2100
|
+
};
|
|
2101
|
+
}
|
|
2102
|
+
function B() {
|
|
2103
|
+
return typeof performance < "u" ? performance.now() : Date.now();
|
|
2104
|
+
}
|
|
2105
|
+
function Xt(t = {}) {
|
|
2106
|
+
return Object.keys(t).some((e) => Ht.has(e));
|
|
2107
|
+
}
|
|
2108
|
+
class Sr {
|
|
2109
|
+
constructor(e = {}) {
|
|
2110
|
+
const r = Yt(e), n = r.layerId || r.contourLayerId || "raster-contour-default";
|
|
2111
|
+
this.defaultPayload = {
|
|
2112
|
+
thresholdCount: 12,
|
|
2113
|
+
maxCells: 1e6,
|
|
2114
|
+
smooth: !0,
|
|
2115
|
+
excludeBoundary: !0,
|
|
2116
|
+
visible: !0,
|
|
2117
|
+
...r,
|
|
2118
|
+
layerId: n
|
|
2119
|
+
}, this.baseGIS = null, this.contourController = new Re({ layerId: n }), this.currentPayload = null, this.currentGrid = null, this.operationId = 0, this.state = {
|
|
2120
|
+
layerId: n,
|
|
2121
|
+
sourceType: "",
|
|
2122
|
+
sourceUrl: "",
|
|
2123
|
+
sourceProjection: "",
|
|
2124
|
+
projection: "",
|
|
2125
|
+
width: 0,
|
|
2126
|
+
height: 0,
|
|
2127
|
+
renderWidth: 0,
|
|
2128
|
+
renderHeight: 0,
|
|
2129
|
+
min: null,
|
|
2130
|
+
max: null,
|
|
2131
|
+
validCount: 0,
|
|
2132
|
+
noDataCount: 0,
|
|
2133
|
+
levelCount: 0,
|
|
2134
|
+
lineCount: 0,
|
|
2135
|
+
labelCount: 0,
|
|
2136
|
+
lineRenderer: "",
|
|
2137
|
+
thresholds: [],
|
|
2138
|
+
area: null,
|
|
2139
|
+
sourceElapsed: 0,
|
|
2140
|
+
generateElapsed: 0,
|
|
2141
|
+
renderElapsed: 0,
|
|
2142
|
+
lineBuildElapsed: 0,
|
|
2143
|
+
labelLayoutElapsed: 0,
|
|
2144
|
+
primitiveReadyElapsed: 0,
|
|
2145
|
+
elapsed: 0,
|
|
2146
|
+
downsampled: !1,
|
|
2147
|
+
visible: this.defaultPayload.visible !== !1,
|
|
2148
|
+
loaded: !1
|
|
2149
|
+
}, (e.mapCore || e.baseGIS) && this.mount(e.mapCore || e.baseGIS);
|
|
2150
|
+
}
|
|
2151
|
+
mount(e) {
|
|
2152
|
+
const r = this.contourController.mount(e);
|
|
2153
|
+
return r.success && (this.baseGIS = e), r;
|
|
2154
|
+
}
|
|
2155
|
+
resolveBaseGIS() {
|
|
2156
|
+
var e, r;
|
|
2157
|
+
return this.baseGIS ? (r = (e = this.baseGIS).getMapInstance) != null && r.call(e) ? L(null, "BaseGIS is ready.") : I(
|
|
2158
|
+
"Map instance is not ready. Please call mapCore.init() first.",
|
|
2159
|
+
"NOT_INITIALIZED"
|
|
2160
|
+
) : I("RasterContourController has not been mounted.", "NOT_MOUNTED");
|
|
2161
|
+
}
|
|
2162
|
+
async renderGrid(e, r, n, s, i = !1, o = 0) {
|
|
2163
|
+
var p;
|
|
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) => {
|
|
2166
|
+
n === this.operationId && (this.state = {
|
|
2167
|
+
...this.state,
|
|
2168
|
+
lineCount: (m == null ? void 0 : m.lineCount) ?? this.state.lineCount,
|
|
2169
|
+
labelCount: (m == null ? void 0 : m.labelCount) ?? this.state.labelCount,
|
|
2170
|
+
lineRenderer: (m == null ? void 0 : m.lineRenderer) ?? this.state.lineRenderer,
|
|
2171
|
+
lineBuildElapsed: (m == null ? void 0 : m.lineBuildElapsed) ?? this.state.lineBuildElapsed,
|
|
2172
|
+
labelLayoutElapsed: (m == null ? void 0 : m.labelLayoutElapsed) ?? this.state.labelLayoutElapsed,
|
|
2173
|
+
primitiveReadyElapsed: (m == null ? void 0 : m.primitiveReadyElapsed) ?? this.state.primitiveReadyElapsed,
|
|
2174
|
+
visible: (m == null ? void 0 : m.visible) ?? this.state.visible
|
|
2175
|
+
}, h == null || h(m));
|
|
2176
|
+
};
|
|
2177
|
+
const d = B(), f = i ? await this.contourController.update(u) : await this.contourController.load(u), y = B() - d;
|
|
2178
|
+
if (!f.success) return f;
|
|
2179
|
+
if (n !== this.operationId)
|
|
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;
|
|
2182
|
+
return this.currentPayload = r, this.currentGrid = e, this.state = {
|
|
2183
|
+
...this.state,
|
|
2184
|
+
layerId: u.layerId,
|
|
2185
|
+
sourceType: e.sourceType,
|
|
2186
|
+
sourceUrl: e.sourceUrl,
|
|
2187
|
+
sourceProjection: e.sourceProjection,
|
|
2188
|
+
projection: e.projection,
|
|
2189
|
+
width: e.width,
|
|
2190
|
+
height: e.height,
|
|
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,
|
|
2199
|
+
labelCount: (g == null ? void 0 : g.labelCount) || 0,
|
|
2200
|
+
lineRenderer: (g == null ? void 0 : g.lineRenderer) || "",
|
|
2201
|
+
thresholds: c.thresholds,
|
|
2202
|
+
area: e.area,
|
|
2203
|
+
sourceElapsed: o,
|
|
2204
|
+
generateElapsed: l,
|
|
2205
|
+
renderElapsed: y,
|
|
2206
|
+
lineBuildElapsed: (g == null ? void 0 : g.lineBuildElapsed) || 0,
|
|
2207
|
+
labelLayoutElapsed: (g == null ? void 0 : g.labelLayoutElapsed) || 0,
|
|
2208
|
+
primitiveReadyElapsed: (g == null ? void 0 : g.primitiveReadyElapsed) || 0,
|
|
2209
|
+
elapsed: b,
|
|
2210
|
+
downsampled: c.downsampled,
|
|
2211
|
+
visible: u.visible !== !1,
|
|
2212
|
+
loaded: !0
|
|
2213
|
+
}, L(
|
|
2214
|
+
{
|
|
2215
|
+
...this.getState(),
|
|
2216
|
+
contourState: g
|
|
2217
|
+
},
|
|
2218
|
+
i ? `Raster contour layer "${u.layerId}" regenerated.` : `Raster contour layer "${u.layerId}" loaded.`
|
|
2219
|
+
);
|
|
2220
|
+
}
|
|
2221
|
+
async load(e = {}, r = {}) {
|
|
2222
|
+
const n = this.resolveBaseGIS();
|
|
2223
|
+
if (!n.success) return n;
|
|
2224
|
+
const s = {
|
|
2225
|
+
...this.defaultPayload,
|
|
2226
|
+
...this.currentPayload || {},
|
|
2227
|
+
...e,
|
|
2228
|
+
...r
|
|
2229
|
+
}, i = ++this.operationId, o = B();
|
|
2230
|
+
try {
|
|
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(
|
|
2233
|
+
a,
|
|
2234
|
+
s,
|
|
2235
|
+
i,
|
|
2236
|
+
o,
|
|
2237
|
+
!1,
|
|
2238
|
+
c
|
|
2239
|
+
);
|
|
2240
|
+
} catch (a) {
|
|
2241
|
+
return I(
|
|
2242
|
+
(a == null ? void 0 : a.message) || "Raster contour generation failed.",
|
|
2243
|
+
"RASTER_CONTOUR_FAILED"
|
|
2244
|
+
);
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
loadGeoTiff(e = {}, r = {}) {
|
|
2248
|
+
return this.load({ ...e, sourceType: "geotiff" }, r);
|
|
2249
|
+
}
|
|
2250
|
+
loadGrayImage(e = {}, r = {}) {
|
|
2251
|
+
return this.load({ ...e, sourceType: "grayscale" }, r);
|
|
2252
|
+
}
|
|
2253
|
+
loadGrid(e = {}, r = {}) {
|
|
2254
|
+
return this.load({ ...e, sourceType: "grid" }, r);
|
|
2255
|
+
}
|
|
2256
|
+
async update(e = {}) {
|
|
2257
|
+
if (!this.currentPayload || !this.currentGrid)
|
|
2258
|
+
return I("Raster contour source has not been loaded.", "NOT_LOADED");
|
|
2259
|
+
if (Xt(e))
|
|
2260
|
+
return this.load(e);
|
|
2261
|
+
const r = this.resolveBaseGIS();
|
|
2262
|
+
if (!r.success) return r;
|
|
2263
|
+
const n = {
|
|
2264
|
+
...this.currentPayload,
|
|
2265
|
+
...e
|
|
2266
|
+
}, s = ++this.operationId, i = B();
|
|
2267
|
+
try {
|
|
2268
|
+
return await this.renderGrid(
|
|
2269
|
+
this.currentGrid,
|
|
2270
|
+
n,
|
|
2271
|
+
s,
|
|
2272
|
+
i,
|
|
2273
|
+
!0
|
|
2274
|
+
);
|
|
2275
|
+
} catch (o) {
|
|
2276
|
+
return I(
|
|
2277
|
+
(o == null ? void 0 : o.message) || "Raster contour regeneration failed.",
|
|
2278
|
+
"RASTER_CONTOUR_FAILED"
|
|
2279
|
+
);
|
|
2280
|
+
}
|
|
2281
|
+
}
|
|
2282
|
+
show() {
|
|
2283
|
+
const e = this.contourController.show();
|
|
2284
|
+
return e.success && (this.state.visible = !0), e;
|
|
2285
|
+
}
|
|
2286
|
+
hide() {
|
|
2287
|
+
const e = this.contourController.hide();
|
|
2288
|
+
return e.success && (this.state.visible = !1), e;
|
|
2289
|
+
}
|
|
2290
|
+
toggle(e) {
|
|
2291
|
+
return typeof e == "boolean" ? e ? this.show() : this.hide() : this.state.visible ? this.hide() : this.show();
|
|
2292
|
+
}
|
|
2293
|
+
clear() {
|
|
2294
|
+
this.operationId += 1;
|
|
2295
|
+
const e = this.contourController.clear();
|
|
2296
|
+
return e.success && (this.state = {
|
|
2297
|
+
...this.state,
|
|
2298
|
+
levelCount: 0,
|
|
2299
|
+
lineCount: 0,
|
|
2300
|
+
labelCount: 0,
|
|
2301
|
+
thresholds: [],
|
|
2302
|
+
loaded: !1
|
|
2303
|
+
}), e;
|
|
2304
|
+
}
|
|
2305
|
+
destroy() {
|
|
2306
|
+
this.operationId += 1;
|
|
2307
|
+
const e = this.contourController.destroy();
|
|
2308
|
+
return this.currentPayload = null, this.currentGrid = null, this.baseGIS = null, this.state = {
|
|
2309
|
+
...this.state,
|
|
2310
|
+
levelCount: 0,
|
|
2311
|
+
lineCount: 0,
|
|
2312
|
+
labelCount: 0,
|
|
2313
|
+
thresholds: [],
|
|
2314
|
+
loaded: !1
|
|
2315
|
+
}, e;
|
|
2316
|
+
}
|
|
2317
|
+
getRasterData() {
|
|
2318
|
+
return this.currentGrid;
|
|
2319
|
+
}
|
|
2320
|
+
getState() {
|
|
2321
|
+
var e, r;
|
|
2322
|
+
return {
|
|
2323
|
+
...this.state,
|
|
2324
|
+
engineType: ((r = (e = this.baseGIS) == null ? void 0 : e.getEngineType) == null ? void 0 : r.call(e)) || "unknown",
|
|
2325
|
+
contour: this.contourController.getState()
|
|
2326
|
+
};
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
function _() {
|
|
1168
2330
|
return typeof window < "u" ? window.Cesium : null;
|
|
1169
2331
|
}
|
|
1170
|
-
function
|
|
1171
|
-
let e =
|
|
2332
|
+
function Zt(t) {
|
|
2333
|
+
let e = t;
|
|
1172
2334
|
return e > 90 && (e -= 180), e < -90 && (e += 180), e;
|
|
1173
2335
|
}
|
|
1174
|
-
function
|
|
1175
|
-
return
|
|
2336
|
+
function Jt(t, e = 0) {
|
|
2337
|
+
return O.divIcon({
|
|
1176
2338
|
className: "pressure-label-icon",
|
|
1177
|
-
html: `<span style="transform: translate(-50%, -50%) rotate(${
|
|
2339
|
+
html: `<span style="transform: translate(-50%, -50%) rotate(${Zt(e)}deg)">${t}</span>`,
|
|
1178
2340
|
iconSize: [0, 0],
|
|
1179
2341
|
iconAnchor: [0, 0]
|
|
1180
2342
|
});
|
|
1181
2343
|
}
|
|
1182
|
-
function
|
|
1183
|
-
return
|
|
1184
|
-
className: `pressure-center-icon pressure-center-icon--${
|
|
1185
|
-
html: `<span class="pressure-center-icon__type">${
|
|
2344
|
+
function Qt(t) {
|
|
2345
|
+
return O.divIcon({
|
|
2346
|
+
className: `pressure-center-icon pressure-center-icon--${t.type.toLowerCase()}`,
|
|
2347
|
+
html: `<span class="pressure-center-icon__type">${t.type}</span><span class="pressure-center-icon__value">${t.value}</span>`,
|
|
1186
2348
|
iconSize: [0, 0],
|
|
1187
2349
|
iconAnchor: [0, 0]
|
|
1188
2350
|
});
|
|
1189
2351
|
}
|
|
1190
|
-
function
|
|
1191
|
-
return
|
|
1192
|
-
(
|
|
2352
|
+
function oe(t, e) {
|
|
2353
|
+
return t.some(
|
|
2354
|
+
(r) => !(e.right < r.left || e.left > r.right || e.bottom < r.top || e.top > r.bottom)
|
|
1193
2355
|
);
|
|
1194
2356
|
}
|
|
1195
|
-
function
|
|
2357
|
+
function ae(t, e, r) {
|
|
1196
2358
|
return {
|
|
1197
|
-
left:
|
|
1198
|
-
right:
|
|
1199
|
-
top:
|
|
1200
|
-
bottom:
|
|
2359
|
+
left: t.x - e,
|
|
2360
|
+
right: t.x + e,
|
|
2361
|
+
top: t.y - r,
|
|
2362
|
+
bottom: t.y + r
|
|
1201
2363
|
};
|
|
1202
2364
|
}
|
|
1203
|
-
function
|
|
1204
|
-
|
|
1205
|
-
for (let
|
|
1206
|
-
const
|
|
1207
|
-
if (!
|
|
1208
|
-
return e.push(
|
|
2365
|
+
function Ge(t, e, r = 18, n = 10) {
|
|
2366
|
+
t.sort((s, i) => s.score - i.score);
|
|
2367
|
+
for (let s = 0; s < t.length; s += 1) {
|
|
2368
|
+
const i = t[s], o = ae(i.point, r, n);
|
|
2369
|
+
if (!oe(e, o))
|
|
2370
|
+
return e.push(o), i;
|
|
1209
2371
|
}
|
|
1210
2372
|
return null;
|
|
1211
2373
|
}
|
|
1212
|
-
function
|
|
1213
|
-
return e ?
|
|
2374
|
+
function Me(t = [], e = 0) {
|
|
2375
|
+
return e ? t.map((r) => [r[0], r[1] + e]) : t;
|
|
1214
2376
|
}
|
|
1215
|
-
function
|
|
1216
|
-
if (
|
|
1217
|
-
return
|
|
1218
|
-
const
|
|
1219
|
-
for (let
|
|
1220
|
-
|
|
1221
|
-
const
|
|
1222
|
-
return
|
|
2377
|
+
function er(t = [], e = 2) {
|
|
2378
|
+
if (t.length <= 2 || e <= 1)
|
|
2379
|
+
return t;
|
|
2380
|
+
const r = [];
|
|
2381
|
+
for (let s = 0; s < t.length; s += e)
|
|
2382
|
+
r.push(t[s]);
|
|
2383
|
+
const n = t[t.length - 1];
|
|
2384
|
+
return r[r.length - 1] !== n && r.push(n), r;
|
|
1223
2385
|
}
|
|
1224
|
-
function
|
|
1225
|
-
let e = Number(
|
|
2386
|
+
function tr(t) {
|
|
2387
|
+
let e = Number(t);
|
|
1226
2388
|
for (; e > 180; )
|
|
1227
2389
|
e -= 360;
|
|
1228
2390
|
for (; e < -180; )
|
|
1229
2391
|
e += 360;
|
|
1230
2392
|
return e;
|
|
1231
2393
|
}
|
|
1232
|
-
function
|
|
1233
|
-
return Math.round(Number(
|
|
2394
|
+
function Te(t) {
|
|
2395
|
+
return Math.round(Number(t) / 100);
|
|
1234
2396
|
}
|
|
1235
|
-
function
|
|
1236
|
-
const
|
|
1237
|
-
for (let
|
|
1238
|
-
const
|
|
1239
|
-
Number.isFinite(
|
|
2397
|
+
function rr(t = [], e = 0) {
|
|
2398
|
+
const r = [];
|
|
2399
|
+
for (let n = 0; n < t.length - 1; n += 2) {
|
|
2400
|
+
const s = Number(t[n]), i = Number(t[n + 1]) + e;
|
|
2401
|
+
Number.isFinite(s) && Number.isFinite(i) && r.push([s, i]);
|
|
1240
2402
|
}
|
|
1241
|
-
return
|
|
2403
|
+
return r;
|
|
1242
2404
|
}
|
|
1243
|
-
function
|
|
1244
|
-
const
|
|
2405
|
+
function nr(t, e, r, n, s) {
|
|
2406
|
+
const i = s * s, o = i * s;
|
|
1245
2407
|
return [
|
|
1246
|
-
0.5 * (2 * e[0] + (-
|
|
1247
|
-
0.5 * (2 * e[1] + (-
|
|
2408
|
+
0.5 * (2 * e[0] + (-t[0] + r[0]) * s + (2 * t[0] - 5 * e[0] + 4 * r[0] - n[0]) * i + (-t[0] + 3 * e[0] - 3 * r[0] + n[0]) * o),
|
|
2409
|
+
0.5 * (2 * e[1] + (-t[1] + r[1]) * s + (2 * t[1] - 5 * e[1] + 4 * r[1] - n[1]) * i + (-t[1] + 3 * e[1] - 3 * r[1] + n[1]) * o)
|
|
1248
2410
|
];
|
|
1249
2411
|
}
|
|
1250
|
-
function
|
|
1251
|
-
if (
|
|
1252
|
-
return
|
|
1253
|
-
const
|
|
1254
|
-
for (let
|
|
1255
|
-
const
|
|
1256
|
-
for (let
|
|
1257
|
-
|
|
2412
|
+
function sr(t = [], e = 5) {
|
|
2413
|
+
if (t.length < 3)
|
|
2414
|
+
return t;
|
|
2415
|
+
const r = [t[0]];
|
|
2416
|
+
for (let n = 0; n < t.length - 1; n += 1) {
|
|
2417
|
+
const s = t[n - 1] || t[n], i = t[n], o = t[n + 1], a = t[n + 2] || o;
|
|
2418
|
+
for (let c = 1; c <= e; c += 1)
|
|
2419
|
+
r.push(nr(s, i, o, a, c / e));
|
|
1258
2420
|
}
|
|
1259
|
-
return
|
|
2421
|
+
return r;
|
|
1260
2422
|
}
|
|
1261
|
-
function
|
|
1262
|
-
const e = (
|
|
1263
|
-
const
|
|
2423
|
+
function ir(t = {}) {
|
|
2424
|
+
const e = (t.isoline || []).map((n) => {
|
|
2425
|
+
const s = Number(n.value);
|
|
1264
2426
|
return {
|
|
1265
|
-
value:
|
|
1266
|
-
hpa:
|
|
1267
|
-
major:
|
|
1268
|
-
lines: [
|
|
2427
|
+
value: s,
|
|
2428
|
+
hpa: Te(s),
|
|
2429
|
+
major: s % 800 === 0,
|
|
2430
|
+
lines: [sr(rr(n.points))].filter((i) => i.length > 1)
|
|
1269
2431
|
};
|
|
1270
|
-
}),
|
|
1271
|
-
const
|
|
1272
|
-
for (let
|
|
1273
|
-
|
|
1274
|
-
type:
|
|
1275
|
-
value:
|
|
1276
|
-
lat: Number(
|
|
1277
|
-
lon:
|
|
2432
|
+
}), r = ["high", "low"].flatMap((n) => {
|
|
2433
|
+
const s = t[n] || {}, i = Array.isArray(s.value) ? s.value : [], o = Array.isArray(s.points) ? s.points : [], a = [];
|
|
2434
|
+
for (let c = 0; c < o.length - 1; c += 2)
|
|
2435
|
+
a.push({
|
|
2436
|
+
type: n === "high" ? "H" : "L",
|
|
2437
|
+
value: Te(i[c / 2]),
|
|
2438
|
+
lat: Number(o[c]),
|
|
2439
|
+
lon: tr(o[c + 1])
|
|
1278
2440
|
});
|
|
1279
|
-
return
|
|
2441
|
+
return a;
|
|
1280
2442
|
});
|
|
1281
2443
|
return {
|
|
1282
2444
|
isolines: e,
|
|
1283
|
-
centers:
|
|
2445
|
+
centers: r
|
|
1284
2446
|
};
|
|
1285
2447
|
}
|
|
1286
|
-
function
|
|
1287
|
-
return Array.isArray(
|
|
1288
|
-
...
|
|
1289
|
-
isolines:
|
|
1290
|
-
centers: Array.isArray(
|
|
1291
|
-
} :
|
|
2448
|
+
function le(t = {}) {
|
|
2449
|
+
return Array.isArray(t == null ? void 0 : t.isolines) ? {
|
|
2450
|
+
...t,
|
|
2451
|
+
isolines: t.isolines,
|
|
2452
|
+
centers: Array.isArray(t.centers) ? t.centers : []
|
|
2453
|
+
} : ir(t);
|
|
1292
2454
|
}
|
|
1293
|
-
function
|
|
2455
|
+
function vr(t = {}) {
|
|
1294
2456
|
const e = /* @__PURE__ */ new Map();
|
|
1295
|
-
return (
|
|
1296
|
-
const
|
|
1297
|
-
return e.has(
|
|
2457
|
+
return (r = "default") => {
|
|
2458
|
+
const n = r || "default";
|
|
2459
|
+
return e.has(n) || e.set(n, le(t[n] || t.default || {})), e.get(n);
|
|
1298
2460
|
};
|
|
1299
2461
|
}
|
|
1300
|
-
class
|
|
2462
|
+
class or {
|
|
1301
2463
|
constructor(e = {}) {
|
|
1302
2464
|
this.mapCore = e.mapCore, this.mapContainerId = e.mapContainerId, this.getData = e.getData, this.isVisible = e.isVisible, this.onStateChange = e.onStateChange, this.worldCopyOffsets = e.worldCopyOffsets || [-360, 0, 360], this.cesiumWorldCopyOffsets = e.cesiumWorldCopyOffsets || [0], this.cesiumLineThinStep = e.cesiumLineThinStep || 2, this.labelLayerGroup = null, this.cesiumLabelCollection = null, this.labelUpdateTimer = null, this.removeViewChangeListener = null;
|
|
1303
2465
|
}
|
|
1304
2466
|
// 当前引擎类型由 BaseGIS 决定,标注层只负责适配具体绘制方式。
|
|
1305
2467
|
isCesiumEngine() {
|
|
1306
|
-
var e,
|
|
1307
|
-
return ((
|
|
2468
|
+
var e, r;
|
|
2469
|
+
return ((r = (e = this.mapCore) == null ? void 0 : e.getEngineType) == null ? void 0 : r.call(e)) === "cesium";
|
|
1308
2470
|
}
|
|
1309
2471
|
// Cesium 3D 模式需要判断地球背面遮挡,2D/哥伦布视图不做额外遮挡过滤。
|
|
1310
2472
|
getCesiumSceneMode() {
|
|
1311
|
-
var
|
|
1312
|
-
const e = (
|
|
1313
|
-
return (
|
|
2473
|
+
var r, n, s;
|
|
2474
|
+
const e = (n = (r = this.mapCore) == null ? void 0 : r.getMapInstance) == null ? void 0 : n.call(r);
|
|
2475
|
+
return (s = e == null ? void 0 : e.scene) == null ? void 0 : s.mode;
|
|
1314
2476
|
}
|
|
1315
2477
|
// 挂载标注层事件:Leaflet 监听地图事件,Cesium 走 BaseGIS 的视图变化回调。
|
|
1316
2478
|
mount() {
|
|
1317
|
-
var
|
|
2479
|
+
var r, n, s, i, o, a;
|
|
1318
2480
|
if (this.isCesiumEngine()) {
|
|
1319
|
-
this.removeViewChangeListener = ((
|
|
2481
|
+
this.removeViewChangeListener = ((i = (s = (n = (r = this.mapCore) == null ? void 0 : r.onViewChange) == null ? void 0 : n.call(r, {
|
|
1320
2482
|
onEnd: () => this.scheduleUpdate(),
|
|
1321
2483
|
endDelay: 180
|
|
1322
|
-
})) == null ? void 0 :
|
|
2484
|
+
})) == null ? void 0 : s.data) == null ? void 0 : i.off) || null;
|
|
1323
2485
|
return;
|
|
1324
2486
|
}
|
|
1325
|
-
const e = (
|
|
1326
|
-
e && (this.labelLayerGroup =
|
|
2487
|
+
const e = (a = (o = this.mapCore) == null ? void 0 : o.getMapInstance) == null ? void 0 : a.call(o);
|
|
2488
|
+
e && (this.labelLayerGroup = O.layerGroup().addTo(e), e.on("moveend zoomend resize", this.scheduleUpdate, this));
|
|
1327
2489
|
}
|
|
1328
2490
|
// 地图连续移动时只在下一帧刷新一次标签,减少重复碰撞计算。
|
|
1329
2491
|
scheduleUpdate() {
|
|
@@ -1343,50 +2505,50 @@ class Ge {
|
|
|
1343
2505
|
}
|
|
1344
2506
|
// 销毁时移除地图事件、Cesium LabelCollection 和 Leaflet 图层组。
|
|
1345
2507
|
destroy() {
|
|
1346
|
-
var
|
|
2508
|
+
var r, n, s, i, o;
|
|
1347
2509
|
this.labelUpdateTimer && (window.cancelAnimationFrame(this.labelUpdateTimer), this.labelUpdateTimer = null);
|
|
1348
|
-
const e = (
|
|
1349
|
-
(
|
|
2510
|
+
const e = (n = (r = this.mapCore) == null ? void 0 : r.getMapInstance) == null ? void 0 : n.call(r);
|
|
2511
|
+
(s = e == null ? void 0 : e.off) == null || s.call(e, "moveend zoomend resize", this.scheduleUpdate, this), (i = this.removeViewChangeListener) == null || i.call(this), this.removeViewChangeListener = null, this.clearCesiumLabelCollection(!0), (o = this.labelLayerGroup) == null || o.remove(), this.labelLayerGroup = null;
|
|
1350
2512
|
}
|
|
1351
2513
|
// 把标签数量回传给页面状态面板。
|
|
1352
2514
|
emitStateChange(e) {
|
|
1353
|
-
var
|
|
1354
|
-
(
|
|
2515
|
+
var r;
|
|
2516
|
+
(r = this.onStateChange) == null || r.call(this, {
|
|
1355
2517
|
labelCount: e
|
|
1356
2518
|
});
|
|
1357
2519
|
}
|
|
1358
2520
|
// Cesium 3D 球面下,屏幕外或地球背面的点不参与标签候选。
|
|
1359
2521
|
isCesiumPointVisible(e) {
|
|
1360
|
-
var u, h,
|
|
1361
|
-
const
|
|
1362
|
-
if (!
|
|
2522
|
+
var l, u, h, d, f, y;
|
|
2523
|
+
const r = (u = (l = this.mapCore) == null ? void 0 : l.getMapInstance) == null ? void 0 : u.call(l), n = _(), s = r == null ? void 0 : r.scene;
|
|
2524
|
+
if (!r || !n || !s)
|
|
1363
2525
|
return !1;
|
|
1364
|
-
if (this.getCesiumSceneMode() !==
|
|
2526
|
+
if (this.getCesiumSceneMode() !== n.SceneMode.SCENE3D)
|
|
1365
2527
|
return !0;
|
|
1366
|
-
const
|
|
1367
|
-
if (!
|
|
2528
|
+
const i = ((h = s.globe) == null ? void 0 : h.ellipsoid) || ((d = s.mapProjection) == null ? void 0 : d.ellipsoid), o = ((f = s.camera) == null ? void 0 : f.positionWC) || ((y = s.camera) == null ? void 0 : y.position);
|
|
2529
|
+
if (!i || !o)
|
|
1368
2530
|
return !0;
|
|
1369
|
-
const
|
|
1370
|
-
return new
|
|
2531
|
+
const a = n.Cartesian3.fromDegrees(e[1], e[0], 0);
|
|
2532
|
+
return new n.EllipsoidalOccluder(i, o).isPointVisible(a);
|
|
1371
2533
|
}
|
|
1372
2534
|
// 标签候选点只在地图容器附近参与碰撞,防止屏幕外点影响布局。
|
|
1373
|
-
isCesiumScreenPointInViewport(e,
|
|
1374
|
-
const
|
|
1375
|
-
return !
|
|
2535
|
+
isCesiumScreenPointInViewport(e, r = 80) {
|
|
2536
|
+
const n = document.getElementById(this.mapContainerId), s = (n == null ? void 0 : n.clientWidth) || 0, i = (n == null ? void 0 : n.clientHeight) || 0;
|
|
2537
|
+
return !s || !i ? !0 : !(e.x < -r || e.y < -r || e.x > s + r || e.y > i + r);
|
|
1376
2538
|
}
|
|
1377
2539
|
// LabelCollection 比为每个标签创建 Entity 更轻量,适合动态重建。
|
|
1378
2540
|
ensureCesiumLabelCollection() {
|
|
1379
|
-
var
|
|
1380
|
-
const e = (
|
|
1381
|
-
return !((
|
|
2541
|
+
var n, s, i;
|
|
2542
|
+
const e = (s = (n = this.mapCore) == null ? void 0 : n.getMapInstance) == null ? void 0 : s.call(n), r = _();
|
|
2543
|
+
return !((i = e == null ? void 0 : e.scene) != null && i.primitives) || !r ? null : (this.cesiumLabelCollection || (this.cesiumLabelCollection = e.scene.primitives.add(new r.LabelCollection())), this.cesiumLabelCollection);
|
|
1382
2544
|
}
|
|
1383
2545
|
// 数据更新和图层隐藏时清空标签;页面卸载时才销毁集合。
|
|
1384
2546
|
clearCesiumLabelCollection(e = !1) {
|
|
1385
|
-
var
|
|
1386
|
-
const
|
|
2547
|
+
var n, s, i;
|
|
2548
|
+
const r = (s = (n = this.mapCore) == null ? void 0 : n.getMapInstance) == null ? void 0 : s.call(n);
|
|
1387
2549
|
if (this.cesiumLabelCollection) {
|
|
1388
|
-
if (e && ((
|
|
1389
|
-
|
|
2550
|
+
if (e && ((i = r == null ? void 0 : r.scene) != null && i.primitives)) {
|
|
2551
|
+
r.scene.primitives.remove(this.cesiumLabelCollection), this.cesiumLabelCollection = null;
|
|
1390
2552
|
return;
|
|
1391
2553
|
}
|
|
1392
2554
|
this.cesiumLabelCollection.removeAll();
|
|
@@ -1394,194 +2556,194 @@ class Ge {
|
|
|
1394
2556
|
}
|
|
1395
2557
|
// 页面数据统一是 [lat, lon],Cesium 创建坐标时需要 [lon, lat]。
|
|
1396
2558
|
createCesiumPosition(e) {
|
|
1397
|
-
return
|
|
2559
|
+
return _().Cartesian3.fromDegrees(e[1], e[0], 0);
|
|
1398
2560
|
}
|
|
1399
2561
|
// 将地理点投影到容器像素坐标,供标签碰撞避让使用。
|
|
1400
2562
|
projectCesiumPoint(e) {
|
|
1401
|
-
var
|
|
2563
|
+
var s, i;
|
|
1402
2564
|
if (!this.isCesiumPointVisible(e))
|
|
1403
2565
|
return null;
|
|
1404
|
-
const
|
|
2566
|
+
const r = (i = (s = this.mapCore) == null ? void 0 : s.projectToContainerPoint) == null ? void 0 : i.call(s, {
|
|
1405
2567
|
latitude: e[0],
|
|
1406
2568
|
longitude: e[1]
|
|
1407
2569
|
});
|
|
1408
|
-
if (!(
|
|
2570
|
+
if (!(r != null && r.success))
|
|
1409
2571
|
return null;
|
|
1410
|
-
const
|
|
1411
|
-
return this.isCesiumScreenPointInViewport(
|
|
2572
|
+
const n = O.point(r.data.x, r.data.y);
|
|
2573
|
+
return this.isCesiumScreenPointInViewport(n) ? n : null;
|
|
1412
2574
|
}
|
|
1413
2575
|
// Cesium 添加单个标签,中心点标签和线值标签共用该方法。
|
|
1414
|
-
addCesiumLabel(e,
|
|
1415
|
-
const
|
|
1416
|
-
return !
|
|
2576
|
+
addCesiumLabel(e, r, n = {}) {
|
|
2577
|
+
const s = _(), i = this.ensureCesiumLabelCollection();
|
|
2578
|
+
return !i || !s || !this.isCesiumPointVisible(e) ? null : i.add({
|
|
1417
2579
|
position: this.createCesiumPosition(e),
|
|
1418
|
-
text:
|
|
1419
|
-
font:
|
|
1420
|
-
fillColor:
|
|
1421
|
-
outlineColor:
|
|
1422
|
-
outlineWidth:
|
|
1423
|
-
style:
|
|
1424
|
-
showBackground:
|
|
1425
|
-
backgroundColor:
|
|
1426
|
-
backgroundPadding:
|
|
1427
|
-
horizontalOrigin:
|
|
1428
|
-
verticalOrigin:
|
|
1429
|
-
disableDepthTestDistance:
|
|
1430
|
-
scale:
|
|
2580
|
+
text: r,
|
|
2581
|
+
font: n.font || "12px Arial",
|
|
2582
|
+
fillColor: n.fillColor || s.Color.fromCssColorString("#244349"),
|
|
2583
|
+
outlineColor: s.Color.fromCssColorString("rgba(255,255,255,0.72)"),
|
|
2584
|
+
outlineWidth: n.outlineWidth ?? 2,
|
|
2585
|
+
style: s.LabelStyle.FILL_AND_OUTLINE,
|
|
2586
|
+
showBackground: n.showBackground !== !1,
|
|
2587
|
+
backgroundColor: n.backgroundColor || s.Color.fromCssColorString("rgba(246,251,231,0.92)"),
|
|
2588
|
+
backgroundPadding: n.backgroundPadding || new s.Cartesian2(7, 4),
|
|
2589
|
+
horizontalOrigin: s.HorizontalOrigin.CENTER,
|
|
2590
|
+
verticalOrigin: s.VerticalOrigin.CENTER,
|
|
2591
|
+
disableDepthTestDistance: n.disableDepthTestDistance ?? 0,
|
|
2592
|
+
scale: n.scale || 1
|
|
1431
2593
|
});
|
|
1432
2594
|
}
|
|
1433
2595
|
// Cesium H/L 中心点标注,先做屏幕碰撞检测再绘制。
|
|
1434
|
-
addCesiumCenters(e,
|
|
1435
|
-
const
|
|
1436
|
-
if (!
|
|
2596
|
+
addCesiumCenters(e, r) {
|
|
2597
|
+
const n = _();
|
|
2598
|
+
if (!n)
|
|
1437
2599
|
return 0;
|
|
1438
|
-
let
|
|
1439
|
-
return e.centers.forEach((
|
|
1440
|
-
this.cesiumWorldCopyOffsets.forEach((
|
|
1441
|
-
const
|
|
1442
|
-
if (!
|
|
2600
|
+
let s = 0;
|
|
2601
|
+
return e.centers.forEach((i) => {
|
|
2602
|
+
this.cesiumWorldCopyOffsets.forEach((o) => {
|
|
2603
|
+
const a = [i.lat, i.lon + o], c = this.projectCesiumPoint(a);
|
|
2604
|
+
if (!c)
|
|
1443
2605
|
return;
|
|
1444
|
-
const
|
|
1445
|
-
|
|
1446
|
-
${
|
|
2606
|
+
const l = ae(c, 18, 20);
|
|
2607
|
+
oe(r, l) || (r.push(l), this.addCesiumLabel(a, `${i.type}
|
|
2608
|
+
${i.value}`, {
|
|
1447
2609
|
font: "700 18px Arial",
|
|
1448
|
-
fillColor:
|
|
1449
|
-
backgroundColor:
|
|
2610
|
+
fillColor: n.Color.fromCssColorString(i.type === "H" ? "#efb7ff" : "#e3f8ff"),
|
|
2611
|
+
backgroundColor: n.Color.TRANSPARENT,
|
|
1450
2612
|
showBackground: !1,
|
|
1451
2613
|
outlineWidth: 3
|
|
1452
|
-
}),
|
|
2614
|
+
}), s += 1);
|
|
1453
2615
|
});
|
|
1454
|
-
}),
|
|
2616
|
+
}), s;
|
|
1455
2617
|
}
|
|
1456
2618
|
// Leaflet H/L 中心点标注,按当前视野过滤后再做碰撞检测。
|
|
1457
|
-
addLeafletCenters(e,
|
|
1458
|
-
var a,
|
|
1459
|
-
const
|
|
1460
|
-
if (!
|
|
2619
|
+
addLeafletCenters(e, r) {
|
|
2620
|
+
var o, a, c, l;
|
|
2621
|
+
const n = (a = (o = this.mapCore) == null ? void 0 : o.getMapInstance) == null ? void 0 : a.call(o), s = (l = (c = n == null ? void 0 : n.getBounds) == null ? void 0 : c.call(n)) == null ? void 0 : l.pad(0.2);
|
|
2622
|
+
if (!n || !s || !this.labelLayerGroup)
|
|
1461
2623
|
return 0;
|
|
1462
|
-
let
|
|
1463
|
-
return e.centers.forEach((
|
|
1464
|
-
this.worldCopyOffsets.forEach((
|
|
1465
|
-
const d = [
|
|
1466
|
-
if (!
|
|
2624
|
+
let i = 0;
|
|
2625
|
+
return e.centers.forEach((u) => {
|
|
2626
|
+
this.worldCopyOffsets.forEach((h) => {
|
|
2627
|
+
const d = [u.lat, u.lon + h];
|
|
2628
|
+
if (!s.contains(d))
|
|
1467
2629
|
return;
|
|
1468
|
-
const f =
|
|
1469
|
-
|
|
2630
|
+
const f = n.latLngToContainerPoint(d), y = ae(f, 16, 18);
|
|
2631
|
+
oe(r, y) || (r.push(y), O.marker(d, {
|
|
1470
2632
|
interactive: !1,
|
|
1471
2633
|
keyboard: !1,
|
|
1472
|
-
icon:
|
|
2634
|
+
icon: Qt(u),
|
|
1473
2635
|
zIndexOffset: 140
|
|
1474
|
-
}).addTo(this.labelLayerGroup),
|
|
2636
|
+
}).addTo(this.labelLayerGroup), i += 1);
|
|
1475
2637
|
});
|
|
1476
|
-
}),
|
|
2638
|
+
}), i;
|
|
1477
2639
|
}
|
|
1478
2640
|
// 线值标签统一从折线中采样候选点,再按离视野中心的距离排序。
|
|
1479
|
-
getLineLabelCandidates(e,
|
|
1480
|
-
const { bounds:
|
|
1481
|
-
for (let
|
|
1482
|
-
const
|
|
1483
|
-
(
|
|
1484
|
-
(
|
|
2641
|
+
getLineLabelCandidates(e, r = {}) {
|
|
2642
|
+
const { bounds: n, useSegmentMidpoint: s = !1, viewCenter: i, projectPoint: o } = r, a = [], c = Math.max(Math.floor(e.length / 40), 1);
|
|
2643
|
+
for (let l = 0; l < e.length - 1; l += c) {
|
|
2644
|
+
const u = e[l], h = e[Math.min(l + c, e.length - 1)], d = [
|
|
2645
|
+
(u[0] + h[0]) / 2,
|
|
2646
|
+
(u[1] + h[1]) / 2
|
|
1485
2647
|
];
|
|
1486
|
-
if (
|
|
2648
|
+
if (n && !n.contains(d))
|
|
1487
2649
|
continue;
|
|
1488
|
-
const f =
|
|
1489
|
-
if (!f || !
|
|
2650
|
+
const f = o(u), y = o(h), b = o(d);
|
|
2651
|
+
if (!f || !y || !b)
|
|
1490
2652
|
continue;
|
|
1491
|
-
const
|
|
1492
|
-
|
|
2653
|
+
const g = s ? O.point((f.x + y.x) / 2, (f.y + y.y) / 2) : b;
|
|
2654
|
+
a.push({
|
|
1493
2655
|
position: d,
|
|
1494
|
-
point:
|
|
1495
|
-
angle: Math.atan2(
|
|
1496
|
-
score:
|
|
2656
|
+
point: g,
|
|
2657
|
+
angle: Math.atan2(y.y - f.y, y.x - f.x) * 180 / Math.PI,
|
|
2658
|
+
score: g.distanceTo(i)
|
|
1497
2659
|
});
|
|
1498
2660
|
}
|
|
1499
|
-
return
|
|
2661
|
+
return a;
|
|
1500
2662
|
}
|
|
1501
2663
|
// Leaflet 线值标签:每条线选择靠近视野中心且不碰撞的位置。
|
|
1502
|
-
addLeafletLineLabels(e,
|
|
1503
|
-
var
|
|
1504
|
-
const
|
|
1505
|
-
if (!
|
|
2664
|
+
addLeafletLineLabels(e, r) {
|
|
2665
|
+
var a, c, l, u;
|
|
2666
|
+
const n = (c = (a = this.mapCore) == null ? void 0 : a.getMapInstance) == null ? void 0 : c.call(a), s = (u = (l = n == null ? void 0 : n.getBounds) == null ? void 0 : l.call(n)) == null ? void 0 : u.pad(0.15);
|
|
2667
|
+
if (!n || !s || !this.labelLayerGroup)
|
|
1506
2668
|
return 0;
|
|
1507
|
-
const
|
|
1508
|
-
let
|
|
1509
|
-
return e.isolines.forEach((
|
|
2669
|
+
const i = n.getSize().divideBy(2);
|
|
2670
|
+
let o = 0;
|
|
2671
|
+
return e.isolines.forEach((h) => {
|
|
1510
2672
|
this.worldCopyOffsets.forEach((d) => {
|
|
1511
|
-
|
|
1512
|
-
const
|
|
1513
|
-
bounds:
|
|
2673
|
+
h.lines.forEach((f) => {
|
|
2674
|
+
const y = Me(f, d), b = Ge(this.getLineLabelCandidates(y, {
|
|
2675
|
+
bounds: s,
|
|
1514
2676
|
useSegmentMidpoint: !0,
|
|
1515
|
-
viewCenter:
|
|
1516
|
-
projectPoint: (
|
|
1517
|
-
}),
|
|
1518
|
-
|
|
2677
|
+
viewCenter: i,
|
|
2678
|
+
projectPoint: (g) => n.latLngToContainerPoint(g)
|
|
2679
|
+
}), r);
|
|
2680
|
+
b && (O.marker(b.position, {
|
|
1519
2681
|
interactive: !1,
|
|
1520
2682
|
keyboard: !1,
|
|
1521
|
-
icon:
|
|
2683
|
+
icon: Jt(h.hpa, b.angle),
|
|
1522
2684
|
zIndexOffset: 120
|
|
1523
|
-
}).addTo(this.labelLayerGroup),
|
|
2685
|
+
}).addTo(this.labelLayerGroup), o += 1);
|
|
1524
2686
|
});
|
|
1525
2687
|
});
|
|
1526
|
-
}),
|
|
2688
|
+
}), o;
|
|
1527
2689
|
}
|
|
1528
2690
|
// Cesium 线值标签:先将候选点投影到屏幕,再按距离和碰撞筛选。
|
|
1529
|
-
addCesiumLineLabels(e,
|
|
1530
|
-
let
|
|
1531
|
-
const
|
|
1532
|
-
return e.isolines.forEach((
|
|
1533
|
-
this.cesiumWorldCopyOffsets.forEach((
|
|
1534
|
-
|
|
1535
|
-
const
|
|
1536
|
-
viewCenter:
|
|
1537
|
-
projectPoint: (
|
|
1538
|
-
}),
|
|
1539
|
-
|
|
2691
|
+
addCesiumLineLabels(e, r) {
|
|
2692
|
+
let n = 0;
|
|
2693
|
+
const s = document.getElementById(this.mapContainerId), i = O.point(((s == null ? void 0 : s.clientWidth) || 0) / 2, ((s == null ? void 0 : s.clientHeight) || 0) / 2);
|
|
2694
|
+
return e.isolines.forEach((o) => {
|
|
2695
|
+
this.cesiumWorldCopyOffsets.forEach((a) => {
|
|
2696
|
+
o.lines.forEach((c) => {
|
|
2697
|
+
const l = er(Me(c, a), this.cesiumLineThinStep), u = Ge(this.getLineLabelCandidates(l, {
|
|
2698
|
+
viewCenter: i,
|
|
2699
|
+
projectPoint: (h) => this.projectCesiumPoint(h)
|
|
2700
|
+
}), r);
|
|
2701
|
+
u && (this.addCesiumLabel(u.position, String(o.hpa), {
|
|
1540
2702
|
font: "12px Arial"
|
|
1541
|
-
}),
|
|
2703
|
+
}), n += 1);
|
|
1542
2704
|
});
|
|
1543
2705
|
});
|
|
1544
|
-
}),
|
|
2706
|
+
}), n;
|
|
1545
2707
|
}
|
|
1546
2708
|
// 重建 Cesium 全部标签,并请求场景刷新。
|
|
1547
2709
|
updateCesiumLabels() {
|
|
1548
|
-
var
|
|
1549
|
-
const e = (
|
|
1550
|
-
if (!
|
|
2710
|
+
var a, c, l, u, h, d, f, y, b;
|
|
2711
|
+
const e = (c = (a = this.mapCore) == null ? void 0 : a.getMapInstance) == null ? void 0 : c.call(a), r = (l = this.getData) == null ? void 0 : l.call(this);
|
|
2712
|
+
if (!r)
|
|
1551
2713
|
return this.clear(), 0;
|
|
1552
|
-
const
|
|
2714
|
+
const n = this.cesiumLabelCollection;
|
|
1553
2715
|
this.cesiumLabelCollection = null;
|
|
1554
|
-
const
|
|
1555
|
-
if (!
|
|
1556
|
-
return this.cesiumLabelCollection =
|
|
1557
|
-
const
|
|
1558
|
-
let
|
|
2716
|
+
const s = this.ensureCesiumLabelCollection();
|
|
2717
|
+
if (!s)
|
|
2718
|
+
return this.cesiumLabelCollection = n, 0;
|
|
2719
|
+
const i = [];
|
|
2720
|
+
let o = 0;
|
|
1559
2721
|
try {
|
|
1560
|
-
|
|
1561
|
-
} catch (
|
|
1562
|
-
throw (f = (d = (
|
|
2722
|
+
o = this.addCesiumCenters(r, i) + this.addCesiumLineLabels(r, i), n && n !== s && ((u = e == null ? void 0 : e.scene) != null && u.primitives) && e.scene.primitives.remove(n);
|
|
2723
|
+
} catch (g) {
|
|
2724
|
+
throw (f = (d = (h = e == null ? void 0 : e.scene) == null ? void 0 : h.primitives) == null ? void 0 : d.remove) == null || f.call(d, s), this.cesiumLabelCollection = n, g;
|
|
1563
2725
|
}
|
|
1564
|
-
return this.emitStateChange(
|
|
2726
|
+
return this.emitStateChange(o), (b = (y = e == null ? void 0 : e.scene) == null ? void 0 : y.requestRender) == null || b.call(y), o;
|
|
1565
2727
|
}
|
|
1566
2728
|
// 重建 Leaflet 全部标签和 marker。
|
|
1567
2729
|
updateLeafletLabels() {
|
|
1568
|
-
var
|
|
1569
|
-
const e = (
|
|
1570
|
-
if (!e || !
|
|
2730
|
+
var a, c, l;
|
|
2731
|
+
const e = (a = this.getData) == null ? void 0 : a.call(this), r = (l = (c = this.mapCore) == null ? void 0 : c.getMapInstance) == null ? void 0 : l.call(c);
|
|
2732
|
+
if (!e || !r || !this.labelLayerGroup)
|
|
1571
2733
|
return this.clear(), 0;
|
|
1572
|
-
const
|
|
1573
|
-
this.labelLayerGroup =
|
|
1574
|
-
const
|
|
1575
|
-
let
|
|
2734
|
+
const n = this.labelLayerGroup, s = O.layerGroup();
|
|
2735
|
+
this.labelLayerGroup = s;
|
|
2736
|
+
const i = [];
|
|
2737
|
+
let o = 0;
|
|
1576
2738
|
try {
|
|
1577
|
-
|
|
1578
|
-
} catch (
|
|
1579
|
-
throw
|
|
2739
|
+
o = this.addLeafletCenters(e, i) + this.addLeafletLineLabels(e, i), s.addTo(r), n == null || n.remove();
|
|
2740
|
+
} catch (u) {
|
|
2741
|
+
throw s.remove(), this.labelLayerGroup = n, u;
|
|
1580
2742
|
}
|
|
1581
|
-
return this.emitStateChange(
|
|
2743
|
+
return this.emitStateChange(o), o;
|
|
1582
2744
|
}
|
|
1583
2745
|
}
|
|
1584
|
-
class
|
|
2746
|
+
class wr {
|
|
1585
2747
|
/**
|
|
1586
2748
|
* @param {Object} options 等压线组合图层参数。
|
|
1587
2749
|
* @param {Object} options.mapCore 必填,BaseGIS 实例,线图层和标注层都通过它访问当前地图引擎。
|
|
@@ -1605,7 +2767,7 @@ class Ue {
|
|
|
1605
2767
|
* @param {Function} [options.onAnnotationStateChange] 标注状态变化回调,返回 labelCount。
|
|
1606
2768
|
*/
|
|
1607
2769
|
constructor(e = {}) {
|
|
1608
|
-
this.mapCore = e.mapCore, this.currentData =
|
|
2770
|
+
this.mapCore = e.mapCore, this.currentData = le(e.data || e.sourceData || {}), this.contourController = new Re({
|
|
1609
2771
|
mapCore: e.mapCore,
|
|
1610
2772
|
layerId: e.layerId || "pressure-contour",
|
|
1611
2773
|
color: e.color || "rgba(255,255,255,0.82)",
|
|
@@ -1618,7 +2780,7 @@ class Ue {
|
|
|
1618
2780
|
worldCopyOffsets: e.worldCopyOffsets || [-360, 0, 360],
|
|
1619
2781
|
lineThinStep: e.lineThinStep || 1,
|
|
1620
2782
|
onStateChange: e.onContourStateChange
|
|
1621
|
-
}), this.annotationLayer = new
|
|
2783
|
+
}), this.annotationLayer = new or({
|
|
1622
2784
|
mapCore: e.mapCore,
|
|
1623
2785
|
mapContainerId: e.mapContainerId,
|
|
1624
2786
|
getData: () => this.currentData,
|
|
@@ -1632,22 +2794,22 @@ class Ue {
|
|
|
1632
2794
|
mount() {
|
|
1633
2795
|
this.annotationLayer.mount();
|
|
1634
2796
|
}
|
|
1635
|
-
buildPayload(e,
|
|
1636
|
-
return this.currentData =
|
|
2797
|
+
buildPayload(e, r = {}) {
|
|
2798
|
+
return this.currentData = le(e), {
|
|
1637
2799
|
isolines: this.currentData.isolines || [],
|
|
1638
|
-
visible:
|
|
1639
|
-
...
|
|
2800
|
+
visible: r.visible !== !1,
|
|
2801
|
+
...r
|
|
1640
2802
|
};
|
|
1641
2803
|
}
|
|
1642
|
-
async load(e,
|
|
2804
|
+
async load(e, r = {}) {
|
|
1643
2805
|
this.annotationLayer.clear();
|
|
1644
|
-
const
|
|
1645
|
-
return s != null && s.success && this.annotationLayer.update(), s;
|
|
1646
|
-
}
|
|
1647
|
-
async update(e, t = {}) {
|
|
1648
|
-
const s = this.buildPayload(e, t), n = !!this.contourController.getState().payload ? await this.contourController.update(s) : await this.contourController.load(s);
|
|
2806
|
+
const n = await this.contourController.load(this.buildPayload(e, r));
|
|
1649
2807
|
return n != null && n.success && this.annotationLayer.update(), n;
|
|
1650
2808
|
}
|
|
2809
|
+
async update(e, r = {}) {
|
|
2810
|
+
const n = this.buildPayload(e, r), i = !!this.contourController.getState().payload ? await this.contourController.update(n) : await this.contourController.load(n);
|
|
2811
|
+
return i != null && i.success && this.annotationLayer.update(), i;
|
|
2812
|
+
}
|
|
1651
2813
|
hide() {
|
|
1652
2814
|
const e = this.contourController.hide();
|
|
1653
2815
|
return this.annotationLayer.clear(), e;
|
|
@@ -1668,63 +2830,7 @@ class Ue {
|
|
|
1668
2830
|
this.annotationLayer.destroy(), this.contourController.destroy();
|
|
1669
2831
|
}
|
|
1670
2832
|
}
|
|
1671
|
-
|
|
1672
|
-
constructor(e = {}) {
|
|
1673
|
-
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();
|
|
1674
|
-
}
|
|
1675
|
-
parse() {
|
|
1676
|
-
if (this.bound.length < 6) {
|
|
1677
|
-
this.errorMessage = "Wind field Bound must contain at least 6 values.";
|
|
1678
|
-
return;
|
|
1679
|
-
}
|
|
1680
|
-
const [e, t, s, r, n, a, o = 1] = this.bound, l = Number(s) * Number(r) * 2;
|
|
1681
|
-
if (!Number.isFinite(Number(e)) || !Number.isFinite(Number(t)) || Number(s) < 2 || Number(r) < 2 || Number(n) <= 0 || Number(a) <= 0 || this.data.length !== l) {
|
|
1682
|
-
this.errorMessage = `Invalid wind field data. Expected DataAry length ${l}, got ${this.data.length}.`;
|
|
1683
|
-
return;
|
|
1684
|
-
}
|
|
1685
|
-
this.lonMin = Number(e), this.latMin = Number(t), this.lonCount = Number(s), this.latCount = Number(r), this.lonSpan = Number(n), this.latSpan = Number(a), this.valueScale = Number(o) || 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;
|
|
1686
|
-
}
|
|
1687
|
-
contains(e, t) {
|
|
1688
|
-
return Number.isFinite(e) && Number.isFinite(t) && e >= this.lonMin && e <= this.lonMax && t >= this.latMin && t <= this.latMax;
|
|
1689
|
-
}
|
|
1690
|
-
getBounds() {
|
|
1691
|
-
return {
|
|
1692
|
-
west: this.lonMin,
|
|
1693
|
-
south: this.latMin,
|
|
1694
|
-
east: this.lonMax,
|
|
1695
|
-
north: this.latMax
|
|
1696
|
-
};
|
|
1697
|
-
}
|
|
1698
|
-
getCenter() {
|
|
1699
|
-
return {
|
|
1700
|
-
lon: this.lonMin + this.lonSpan / 2,
|
|
1701
|
-
lat: this.latMin + this.latSpan / 2
|
|
1702
|
-
};
|
|
1703
|
-
}
|
|
1704
|
-
getVector(e, t) {
|
|
1705
|
-
const s = (e * this.lonCount + t) * 2;
|
|
1706
|
-
return {
|
|
1707
|
-
u: Number(this.data[s]) / this.valueScale,
|
|
1708
|
-
v: Number(this.data[s + 1]) / this.valueScale
|
|
1709
|
-
};
|
|
1710
|
-
}
|
|
1711
|
-
/**
|
|
1712
|
-
* 双线性插值。
|
|
1713
|
-
*
|
|
1714
|
-
* 数据约定为从左下角开始平铺,因此 row 直接对应从南到北的纬度索引。
|
|
1715
|
-
*/
|
|
1716
|
-
sample(e, t) {
|
|
1717
|
-
if (!this.valid || !this.contains(e, t))
|
|
1718
|
-
return null;
|
|
1719
|
-
const s = (e - this.lonMin) / this.lonStep, r = (t - this.latMin) / this.latStep, n = Math.max(0, Math.min(Math.floor(s), this.lonCount - 2)), a = Math.max(0, Math.min(Math.floor(r), this.latCount - 2)), o = n + 1, l = a + 1, u = Math.max(0, Math.min(s - n, 1)), h = Math.max(0, Math.min(r - a, 1)), I = this.getVector(a, n), d = this.getVector(a, o), f = this.getVector(l, n), g = this.getVector(l, o), m = 1 - u, p = 1 - h, v = m * p, C = u * p, L = m * h, A = u * h, T = I.u * v + d.u * C + f.u * L + g.u * A, M = I.v * v + d.v * C + f.v * L + g.v * A;
|
|
1720
|
-
return !Number.isFinite(T) || !Number.isFinite(M) ? null : {
|
|
1721
|
-
u: T,
|
|
1722
|
-
v: M,
|
|
1723
|
-
speed: Math.hypot(T, M)
|
|
1724
|
-
};
|
|
1725
|
-
}
|
|
1726
|
-
}
|
|
1727
|
-
const ee = [
|
|
2833
|
+
const xe = [
|
|
1728
2834
|
{ value: 0, color: [36, 88, 190] },
|
|
1729
2835
|
{ value: 2, color: [36, 145, 184] },
|
|
1730
2836
|
{ value: 5, color: [54, 177, 111] },
|
|
@@ -1732,7 +2838,7 @@ const ee = [
|
|
|
1732
2838
|
{ value: 11, color: [229, 178, 78] },
|
|
1733
2839
|
{ value: 14, color: [224, 103, 117] },
|
|
1734
2840
|
{ value: 18, color: [162, 82, 202] }
|
|
1735
|
-
],
|
|
2841
|
+
], Ne = [
|
|
1736
2842
|
{ value: 0, color: [178, 223, 255] },
|
|
1737
2843
|
{ value: 3, color: [190, 248, 222] },
|
|
1738
2844
|
{ value: 6, color: [235, 252, 174] },
|
|
@@ -1740,86 +2846,86 @@ const ee = [
|
|
|
1740
2846
|
{ value: 14, color: [255, 166, 156] },
|
|
1741
2847
|
{ value: 18, color: [232, 153, 255] }
|
|
1742
2848
|
];
|
|
1743
|
-
function
|
|
1744
|
-
return Math.min(Math.max(
|
|
2849
|
+
function w(t, e, r) {
|
|
2850
|
+
return Math.min(Math.max(t, e), r);
|
|
1745
2851
|
}
|
|
1746
|
-
function
|
|
1747
|
-
if (Array.isArray(
|
|
1748
|
-
return [Number(
|
|
1749
|
-
if (typeof
|
|
2852
|
+
function ar(t) {
|
|
2853
|
+
if (Array.isArray(t) && t.length >= 3)
|
|
2854
|
+
return [Number(t[0]) || 0, Number(t[1]) || 0, Number(t[2]) || 0];
|
|
2855
|
+
if (typeof t != "string")
|
|
1750
2856
|
return null;
|
|
1751
|
-
const e =
|
|
2857
|
+
const e = t.trim().replace("#", "");
|
|
1752
2858
|
if (/^[0-9a-f]{6}$/i.test(e))
|
|
1753
2859
|
return [
|
|
1754
2860
|
parseInt(e.slice(0, 2), 16),
|
|
1755
2861
|
parseInt(e.slice(2, 4), 16),
|
|
1756
2862
|
parseInt(e.slice(4, 6), 16)
|
|
1757
2863
|
];
|
|
1758
|
-
const
|
|
1759
|
-
if (!
|
|
2864
|
+
const r = t.match(/rgba?\(([^)]+)\)/i);
|
|
2865
|
+
if (!r)
|
|
1760
2866
|
return null;
|
|
1761
|
-
const
|
|
1762
|
-
return
|
|
1763
|
-
}
|
|
1764
|
-
function
|
|
1765
|
-
const
|
|
1766
|
-
const
|
|
1767
|
-
return !Number.isFinite(
|
|
1768
|
-
}).filter(Boolean).sort((
|
|
1769
|
-
return
|
|
1770
|
-
}
|
|
1771
|
-
function
|
|
1772
|
-
if (!Array.isArray(
|
|
2867
|
+
const n = r[1].split(",").map((s) => Number(s.trim()));
|
|
2868
|
+
return n.length < 3 || n.slice(0, 3).some((s) => !Number.isFinite(s)) ? null : n.slice(0, 3);
|
|
2869
|
+
}
|
|
2870
|
+
function H(t, e) {
|
|
2871
|
+
const n = (Array.isArray(t) && t.length > 0 ? t : e).map((s, i) => {
|
|
2872
|
+
const o = Number((s == null ? void 0 : s.value) ?? (s == null ? void 0 : s.speed) ?? (s == null ? void 0 : s[0]) ?? i), a = ar((s == null ? void 0 : s.color) ?? (s == null ? void 0 : s[1]) ?? s);
|
|
2873
|
+
return !Number.isFinite(o) || !a ? null : { value: o, color: a };
|
|
2874
|
+
}).filter(Boolean).sort((s, i) => s.value - i.value);
|
|
2875
|
+
return n.length > 0 ? n : e;
|
|
2876
|
+
}
|
|
2877
|
+
function lr(t, e) {
|
|
2878
|
+
if (!Array.isArray(t) || t.length === 0)
|
|
1773
2879
|
return [255, 255, 255];
|
|
1774
|
-
if (e <=
|
|
1775
|
-
return
|
|
1776
|
-
for (let
|
|
1777
|
-
const
|
|
1778
|
-
if (e <=
|
|
1779
|
-
const
|
|
1780
|
-
return
|
|
1781
|
-
(
|
|
2880
|
+
if (e <= t[0].value)
|
|
2881
|
+
return t[0].color;
|
|
2882
|
+
for (let r = 1; r < t.length; r += 1) {
|
|
2883
|
+
const n = t[r], s = t[r - 1];
|
|
2884
|
+
if (e <= n.value) {
|
|
2885
|
+
const i = Math.max(n.value - s.value, 1e-4), o = w((e - s.value) / i, 0, 1);
|
|
2886
|
+
return s.color.map(
|
|
2887
|
+
(a, c) => Math.round(a + (n.color[c] - a) * o)
|
|
1782
2888
|
);
|
|
1783
2889
|
}
|
|
1784
2890
|
}
|
|
1785
|
-
return
|
|
2891
|
+
return t[t.length - 1].color;
|
|
1786
2892
|
}
|
|
1787
|
-
function
|
|
1788
|
-
const [
|
|
1789
|
-
return `rgba(${
|
|
2893
|
+
function ee(t, e) {
|
|
2894
|
+
const [r, n, s] = t;
|
|
2895
|
+
return `rgba(${r}, ${n}, ${s}, ${w(e, 0, 1)})`;
|
|
1790
2896
|
}
|
|
1791
|
-
function
|
|
1792
|
-
if (!
|
|
2897
|
+
function cr(t, e) {
|
|
2898
|
+
if (!t || typeof t != "object")
|
|
1793
2899
|
return e;
|
|
1794
|
-
const
|
|
1795
|
-
return [
|
|
1796
|
-
west: Math.min(
|
|
1797
|
-
south: Math.min(
|
|
1798
|
-
east: Math.max(
|
|
1799
|
-
north: Math.max(
|
|
2900
|
+
const r = Number(t.west), n = Number(t.south), s = Number(t.east), i = Number(t.north);
|
|
2901
|
+
return [r, n, s, i].every(Number.isFinite) ? {
|
|
2902
|
+
west: Math.min(r, s),
|
|
2903
|
+
south: Math.min(n, i),
|
|
2904
|
+
east: Math.max(r, s),
|
|
2905
|
+
north: Math.max(n, i)
|
|
1800
2906
|
} : e;
|
|
1801
2907
|
}
|
|
1802
|
-
function
|
|
1803
|
-
const
|
|
1804
|
-
west: Math.max(
|
|
1805
|
-
south: Math.max(
|
|
1806
|
-
east: Math.min(
|
|
1807
|
-
north: Math.min(
|
|
2908
|
+
function ur(t, e) {
|
|
2909
|
+
const r = {
|
|
2910
|
+
west: Math.max(t.west, e.west),
|
|
2911
|
+
south: Math.max(t.south, e.south),
|
|
2912
|
+
east: Math.min(t.east, e.east),
|
|
2913
|
+
north: Math.min(t.north, e.north)
|
|
1808
2914
|
};
|
|
1809
|
-
return
|
|
2915
|
+
return r.west >= r.east || r.south >= r.north ? null : r;
|
|
1810
2916
|
}
|
|
1811
|
-
function
|
|
1812
|
-
return
|
|
2917
|
+
function te(t, e, r) {
|
|
2918
|
+
return t && Number.isFinite(t.x) && Number.isFinite(t.y) && t.x >= -64 && t.x <= e + 64 && t.y >= -64 && t.y <= r + 64;
|
|
1813
2919
|
}
|
|
1814
|
-
function
|
|
1815
|
-
return
|
|
2920
|
+
function hr(t) {
|
|
2921
|
+
return t && Number.isFinite(t.x) && Number.isFinite(t.y);
|
|
1816
2922
|
}
|
|
1817
|
-
function
|
|
1818
|
-
return String(
|
|
2923
|
+
function dr(t) {
|
|
2924
|
+
return String(t || "").toLowerCase();
|
|
1819
2925
|
}
|
|
1820
|
-
class
|
|
2926
|
+
class fr {
|
|
1821
2927
|
constructor(e = {}) {
|
|
1822
|
-
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 = {
|
|
1823
2929
|
zIndex: Number(e.zIndex ?? 30),
|
|
1824
2930
|
visible: e.visible !== !1,
|
|
1825
2931
|
running: e.running !== !1,
|
|
@@ -1844,17 +2950,17 @@ class Oe {
|
|
|
1844
2950
|
projectionGrid: e.projectionGrid !== !1,
|
|
1845
2951
|
projectionGridCols: Number(e.projectionGridCols ?? 32),
|
|
1846
2952
|
projectionGridRows: Number(e.projectionGridRows ?? 20)
|
|
1847
|
-
}, this.colorScale =
|
|
2953
|
+
}, this.colorScale = H(e.colorScale, xe), this.particleColorScale = H(
|
|
1848
2954
|
e.particleColorScale,
|
|
1849
|
-
|
|
2955
|
+
Ne
|
|
1850
2956
|
), this.canvas = null, this.ctx = null, this.overlayCanvas = null, this.overlayCtx = null, this.particles = [], this.animationFrame = null, this.lastFrameTime = 0, this.destroyed = !1, this.width = 0, this.height = 0, this.resizeObserver = null, this.interactionSuspended = !1, this.runningBeforeInteraction = !1, this.overlayDirty = !0, this.spawnBoundsCache = null, this.resumeTimer = null, this.particleCursor = 0, this.projectionGrid = null, this.mount();
|
|
1851
2957
|
}
|
|
1852
2958
|
isReady() {
|
|
1853
2959
|
return !!(this.container && this.project && this.grid.valid);
|
|
1854
2960
|
}
|
|
1855
|
-
createCanvas(e,
|
|
1856
|
-
const
|
|
1857
|
-
return
|
|
2961
|
+
createCanvas(e, r) {
|
|
2962
|
+
const n = document.createElement("canvas");
|
|
2963
|
+
return n.className = e, n.style.position = "absolute", n.style.inset = "0", n.style.width = "100%", n.style.height = "100%", n.style.pointerEvents = "none", n.style.zIndex = String(r), n.style.display = this.options.visible ? "block" : "none", this.container.appendChild(n), n;
|
|
1858
2964
|
}
|
|
1859
2965
|
mount() {
|
|
1860
2966
|
if (!this.container || this.canvas)
|
|
@@ -1872,12 +2978,12 @@ class Oe {
|
|
|
1872
2978
|
resize() {
|
|
1873
2979
|
if (!this.canvas || !this.overlayCanvas || !this.container)
|
|
1874
2980
|
return;
|
|
1875
|
-
const e = this.container.getBoundingClientRect(),
|
|
1876
|
-
|
|
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));
|
|
2982
|
+
n === this.width && s === this.height || (this.width = n, this.height = s, [
|
|
1877
2983
|
[this.canvas, this.ctx],
|
|
1878
2984
|
[this.overlayCanvas, this.overlayCtx]
|
|
1879
|
-
].forEach(([
|
|
1880
|
-
|
|
2985
|
+
].forEach(([i, o]) => {
|
|
2986
|
+
i.width = Math.floor(n * r), i.height = Math.floor(s * r), o == null || o.setTransform(r, 0, 0, r, 0, 0);
|
|
1881
2987
|
}), this.overlayDirty = !0, this.invalidateProjectionGrid(), this.clear());
|
|
1882
2988
|
}
|
|
1883
2989
|
clear() {
|
|
@@ -1893,19 +2999,19 @@ class Oe {
|
|
|
1893
2999
|
this.options = {
|
|
1894
3000
|
...this.options,
|
|
1895
3001
|
...e
|
|
1896
|
-
}, e.colorScale !== void 0 && (this.colorScale =
|
|
3002
|
+
}, e.colorScale !== void 0 && (this.colorScale = H(e.colorScale, xe), this.overlayDirty = !0), e.particleColorScale !== void 0 && (this.particleColorScale = H(
|
|
1897
3003
|
e.particleColorScale,
|
|
1898
|
-
|
|
1899
|
-
)), 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
|
|
3004
|
+
Ne
|
|
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();
|
|
1900
3006
|
}
|
|
1901
3007
|
refreshSpawnBounds() {
|
|
1902
3008
|
return this.spawnBoundsCache = this.getSpawnBounds(), this.invalidateProjectionGrid(), this.spawnBoundsCache;
|
|
1903
3009
|
}
|
|
1904
3010
|
shouldUseProjectionGrid() {
|
|
1905
|
-
var
|
|
3011
|
+
var r;
|
|
1906
3012
|
if (!this.options.projectionGrid)
|
|
1907
3013
|
return !1;
|
|
1908
|
-
const e =
|
|
3014
|
+
const e = dr((r = this.getSceneMode) == null ? void 0 : r.call(this));
|
|
1909
3015
|
return e === "2d" || e === "2.5d";
|
|
1910
3016
|
}
|
|
1911
3017
|
invalidateProjectionGrid() {
|
|
@@ -1914,36 +3020,36 @@ class Oe {
|
|
|
1914
3020
|
buildProjectionGrid(e = this.spawnBoundsCache) {
|
|
1915
3021
|
if (!this.shouldUseProjectionGrid() || !e)
|
|
1916
3022
|
return this.projectionGrid = null, null;
|
|
1917
|
-
const
|
|
1918
|
-
for (let
|
|
1919
|
-
for (let
|
|
1920
|
-
const
|
|
1921
|
-
|
|
3023
|
+
const r = w(Math.floor(this.options.projectionGridCols) || 32, 8, 96), n = w(Math.floor(this.options.projectionGridRows) || 20, 6, 64), s = [];
|
|
3024
|
+
for (let i = 0; i <= n; i += 1)
|
|
3025
|
+
for (let o = 0; o <= r; o += 1) {
|
|
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));
|
|
1922
3028
|
}
|
|
1923
3029
|
return this.projectionGrid = {
|
|
1924
3030
|
bounds: e,
|
|
1925
|
-
cols:
|
|
1926
|
-
rows:
|
|
1927
|
-
nodes:
|
|
3031
|
+
cols: r,
|
|
3032
|
+
rows: n,
|
|
3033
|
+
nodes: s
|
|
1928
3034
|
}, this.projectionGrid;
|
|
1929
3035
|
}
|
|
1930
|
-
projectPoint(e,
|
|
1931
|
-
const
|
|
1932
|
-
if (!
|
|
1933
|
-
return this.project(e,
|
|
1934
|
-
const { bounds:
|
|
1935
|
-
if (![
|
|
1936
|
-
return this.project(e,
|
|
1937
|
-
const
|
|
3036
|
+
projectPoint(e, r) {
|
|
3037
|
+
const n = this.projectionGrid || this.buildProjectionGrid(this.spawnBoundsCache);
|
|
3038
|
+
if (!n || !n.bounds)
|
|
3039
|
+
return this.project(e, r, this.options.height);
|
|
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))
|
|
3042
|
+
return this.project(e, r, this.options.height);
|
|
3043
|
+
const M = 1 - g, T = 1 - p;
|
|
1938
3044
|
return {
|
|
1939
|
-
x:
|
|
1940
|
-
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
|
|
1941
3047
|
};
|
|
1942
3048
|
}
|
|
1943
3049
|
getSpawnBounds() {
|
|
1944
|
-
var
|
|
1945
|
-
const e = this.grid.getBounds(),
|
|
1946
|
-
return
|
|
3050
|
+
var n;
|
|
3051
|
+
const e = this.grid.getBounds(), r = cr((n = this.getViewBounds) == null ? void 0 : n.call(this), e);
|
|
3052
|
+
return ur(e, r) || e;
|
|
1947
3053
|
}
|
|
1948
3054
|
createParticle(e = this.spawnBoundsCache || this.refreshSpawnBounds()) {
|
|
1949
3055
|
if (!e)
|
|
@@ -1953,12 +3059,12 @@ class Oe {
|
|
|
1953
3059
|
age: this.options.maxAge,
|
|
1954
3060
|
maxAge: this.options.maxAge
|
|
1955
3061
|
};
|
|
1956
|
-
for (let
|
|
1957
|
-
const
|
|
1958
|
-
if (
|
|
3062
|
+
for (let r = 0; r < 8; r += 1) {
|
|
3063
|
+
const n = e.west + Math.random() * (e.east - e.west), s = e.south + Math.random() * (e.north - e.south), i = this.grid.sample(n, s);
|
|
3064
|
+
if (i && i.speed > 0)
|
|
1959
3065
|
return {
|
|
1960
|
-
lon:
|
|
1961
|
-
lat:
|
|
3066
|
+
lon: n,
|
|
3067
|
+
lat: s,
|
|
1962
3068
|
screenX: null,
|
|
1963
3069
|
screenY: null,
|
|
1964
3070
|
age: Math.floor(Math.random() * this.options.maxAge),
|
|
@@ -1983,16 +3089,16 @@ class Oe {
|
|
|
1983
3089
|
if (!this.isReady())
|
|
1984
3090
|
return;
|
|
1985
3091
|
this.clear();
|
|
1986
|
-
const e =
|
|
1987
|
-
this.particles = Array.from({ length: e }, () => this.createParticle(
|
|
3092
|
+
const e = w(Math.floor(this.options.particleCount), 1, 8e3), r = this.refreshSpawnBounds();
|
|
3093
|
+
this.particles = Array.from({ length: e }, () => this.createParticle(r)), this.particleCursor = 0, this.overlayDirty = !0, this.drawVelocityOverlay();
|
|
1988
3094
|
}
|
|
1989
3095
|
getParticleColorIndex(e) {
|
|
1990
3096
|
if (!Array.isArray(this.particleColorScale) || this.particleColorScale.length <= 1)
|
|
1991
3097
|
return 0;
|
|
1992
|
-
for (let
|
|
1993
|
-
const
|
|
1994
|
-
if (e <=
|
|
1995
|
-
return
|
|
3098
|
+
for (let r = 1; r < this.particleColorScale.length; r += 1) {
|
|
3099
|
+
const n = this.particleColorScale[r - 1], s = this.particleColorScale[r], i = n.value + (s.value - n.value) / 2;
|
|
3100
|
+
if (e <= i)
|
|
3101
|
+
return r - 1;
|
|
1996
3102
|
}
|
|
1997
3103
|
return this.particleColorScale.length - 1;
|
|
1998
3104
|
}
|
|
@@ -2002,32 +3108,32 @@ class Oe {
|
|
|
2002
3108
|
const e = this.spawnBoundsCache || this.refreshSpawnBounds();
|
|
2003
3109
|
if (!e)
|
|
2004
3110
|
return;
|
|
2005
|
-
const
|
|
2006
|
-
|
|
2007
|
-
for (let
|
|
2008
|
-
const
|
|
2009
|
-
for (let d = 0; d <
|
|
2010
|
-
const f = e.west + (d + 0.5) *
|
|
2011
|
-
if (!
|
|
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();
|
|
3112
|
+
r.save(), r.globalCompositeOperation = "source-over";
|
|
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);
|
|
3117
|
+
if (!y || y.speed <= 0)
|
|
2012
3118
|
continue;
|
|
2013
|
-
const
|
|
2014
|
-
if (!
|
|
3119
|
+
const b = this.projectPoint(f, h);
|
|
3120
|
+
if (!te(b, this.width, this.height))
|
|
2015
3121
|
continue;
|
|
2016
|
-
const
|
|
2017
|
-
if (
|
|
3122
|
+
const g = lr(this.colorScale, y.speed), p = this.getDataEdgeOpacity(f, h, l), m = this.options.velocityOverlayOpacity * p;
|
|
3123
|
+
if (m <= 0.01)
|
|
2018
3124
|
continue;
|
|
2019
|
-
const
|
|
2020
|
-
|
|
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);
|
|
2021
3127
|
}
|
|
2022
3128
|
}
|
|
2023
|
-
|
|
3129
|
+
r.restore();
|
|
2024
3130
|
}
|
|
2025
|
-
getDataEdgeOpacity(e,
|
|
2026
|
-
const
|
|
2027
|
-
if (
|
|
3131
|
+
getDataEdgeOpacity(e, r, n) {
|
|
3132
|
+
const s = w(this.options.velocityOverlayEdgeFade, 0, 0.35);
|
|
3133
|
+
if (s <= 0 || !n)
|
|
2028
3134
|
return 1;
|
|
2029
|
-
const
|
|
2030
|
-
return
|
|
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);
|
|
3136
|
+
return w(a / s, 0, 1);
|
|
2031
3137
|
}
|
|
2032
3138
|
start() {
|
|
2033
3139
|
this.destroyed || (this.options.running = !0, this.interactionSuspended = !1, this.animationFrame || (this.lastFrameTime = performance.now(), this.animationFrame = requestAnimationFrame((e) => this.animate(e))));
|
|
@@ -2055,51 +3161,51 @@ class Oe {
|
|
|
2055
3161
|
hide() {
|
|
2056
3162
|
this.options.visible = !1, this.canvas && (this.canvas.style.display = "none"), this.overlayCanvas && (this.overlayCanvas.style.display = "none");
|
|
2057
3163
|
}
|
|
2058
|
-
stepParticle(e,
|
|
2059
|
-
const
|
|
2060
|
-
if (!
|
|
3164
|
+
stepParticle(e, r) {
|
|
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);
|
|
3166
|
+
if (!n || n.speed <= 0 || !te(s, this.width, this.height))
|
|
2061
3167
|
return Object.assign(e, this.createParticle()), null;
|
|
2062
|
-
const
|
|
2063
|
-
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 });
|
|
2064
3170
|
}
|
|
2065
3171
|
getFrameParticleCount(e) {
|
|
2066
|
-
var
|
|
2067
|
-
const
|
|
3172
|
+
var i;
|
|
3173
|
+
const r = w(
|
|
2068
3174
|
Math.floor(this.options.maxFrameParticles || e),
|
|
2069
3175
|
1,
|
|
2070
3176
|
e
|
|
2071
|
-
),
|
|
2072
|
-
return (
|
|
3177
|
+
), n = Math.floor(this.options.sceneModeMaxFrameParticles || 0), s = String(((i = this.getSceneMode) == null ? void 0 : i.call(this)) || "").toLowerCase();
|
|
3178
|
+
return (s === "2d" || s === "2.5d") && n > 0 ? w(n, 1, r) : r;
|
|
2073
3179
|
}
|
|
2074
3180
|
drawFrame(e) {
|
|
2075
3181
|
if (!this.ctx || this.width <= 0 || this.height <= 0)
|
|
2076
3182
|
return;
|
|
2077
|
-
const
|
|
2078
|
-
|
|
2079
|
-
const
|
|
2080
|
-
for (let
|
|
2081
|
-
const
|
|
2082
|
-
|
|
3183
|
+
const r = this.ctx;
|
|
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";
|
|
3185
|
+
const n = this.particleColorScale.map(() => []), s = this.particles.length, i = this.getFrameParticleCount(s);
|
|
3186
|
+
for (let o = 0; o < i; o += 1) {
|
|
3187
|
+
const a = (this.particleCursor + o) % s, c = this.stepParticle(this.particles[a], e);
|
|
3188
|
+
c && n[this.getParticleColorIndex(c.speed)].push(c);
|
|
2083
3189
|
}
|
|
2084
|
-
this.particleCursor = (this.particleCursor +
|
|
2085
|
-
if (
|
|
3190
|
+
this.particleCursor = (this.particleCursor + i) % s, n.forEach((o, a) => {
|
|
3191
|
+
if (o.length === 0)
|
|
2086
3192
|
return;
|
|
2087
|
-
const
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
}),
|
|
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);
|
|
3196
|
+
}), r.stroke();
|
|
2091
3197
|
});
|
|
2092
3198
|
}
|
|
2093
3199
|
animate(e) {
|
|
2094
3200
|
if (this.animationFrame = null, !(this.destroyed || !this.options.running || this.interactionSuspended)) {
|
|
2095
3201
|
if (this.options.visible && this.isReady()) {
|
|
2096
|
-
const
|
|
2097
|
-
if (
|
|
2098
|
-
const
|
|
2099
|
-
this.lastFrameTime = e, this.drawFrame(
|
|
3202
|
+
const r = 1e3 / w(this.options.frameRate, 1, 60), n = e - this.lastFrameTime;
|
|
3203
|
+
if (n >= r) {
|
|
3204
|
+
const s = w(n / 16.67, 0.5, 2.5);
|
|
3205
|
+
this.lastFrameTime = e, this.drawFrame(s);
|
|
2100
3206
|
}
|
|
2101
3207
|
}
|
|
2102
|
-
this.animationFrame = requestAnimationFrame((
|
|
3208
|
+
this.animationFrame = requestAnimationFrame((r) => this.animate(r));
|
|
2103
3209
|
}
|
|
2104
3210
|
}
|
|
2105
3211
|
getState() {
|
|
@@ -2114,137 +3220,137 @@ class Oe {
|
|
|
2114
3220
|
};
|
|
2115
3221
|
}
|
|
2116
3222
|
destroy() {
|
|
2117
|
-
var e,
|
|
2118
|
-
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), (
|
|
3223
|
+
var e, r;
|
|
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 = [];
|
|
2119
3225
|
}
|
|
2120
3226
|
}
|
|
2121
|
-
function
|
|
2122
|
-
return typeof
|
|
3227
|
+
function V(t = {}) {
|
|
3228
|
+
return typeof t == "string" ? t || "wind-field-default" : (t == null ? void 0 : t.id) || (t == null ? void 0 : t.layerId) || "wind-field-default";
|
|
2123
3229
|
}
|
|
2124
|
-
function
|
|
3230
|
+
function Ae(t = {}) {
|
|
2125
3231
|
const {
|
|
2126
3232
|
id: e,
|
|
2127
|
-
layerId:
|
|
2128
|
-
data:
|
|
2129
|
-
windData:
|
|
2130
|
-
options:
|
|
2131
|
-
container:
|
|
2132
|
-
project:
|
|
2133
|
-
getViewBounds:
|
|
2134
|
-
...
|
|
2135
|
-
} =
|
|
3233
|
+
layerId: r,
|
|
3234
|
+
data: n,
|
|
3235
|
+
windData: s,
|
|
3236
|
+
options: i,
|
|
3237
|
+
container: o,
|
|
3238
|
+
project: a,
|
|
3239
|
+
getViewBounds: c,
|
|
3240
|
+
...l
|
|
3241
|
+
} = t || {};
|
|
2136
3242
|
return {
|
|
2137
|
-
...
|
|
2138
|
-
...
|
|
3243
|
+
...l,
|
|
3244
|
+
...i || {}
|
|
2139
3245
|
};
|
|
2140
3246
|
}
|
|
2141
|
-
function
|
|
2142
|
-
return !!(
|
|
3247
|
+
function Ee(t) {
|
|
3248
|
+
return !!(t && typeof t.getMapInstance == "function" && typeof t.getMapContainer == "function" && typeof t.projectToContainerPoint == "function" && typeof t.getViewBounds == "function" && typeof t.onViewChange == "function");
|
|
2143
3249
|
}
|
|
2144
|
-
class
|
|
3250
|
+
class Pr {
|
|
2145
3251
|
constructor(e = {}) {
|
|
2146
3252
|
this.baseGIS = null, this.layers = /* @__PURE__ */ new Map();
|
|
2147
|
-
const
|
|
2148
|
-
|
|
3253
|
+
const r = (e == null ? void 0 : e.mapCore) || (e == null ? void 0 : e.baseGIS) || (Ee(e) ? e : null);
|
|
3254
|
+
r && this.mount(r);
|
|
2149
3255
|
}
|
|
2150
3256
|
mount(e) {
|
|
2151
|
-
var
|
|
2152
|
-
return
|
|
2153
|
-
{ engineType: ((
|
|
3257
|
+
var r, n;
|
|
3258
|
+
return Ee(e) ? (this.baseGIS = e, L(
|
|
3259
|
+
{ engineType: ((n = (r = this.baseGIS).getEngineType) == null ? void 0 : n.call(r)) || "unknown" },
|
|
2154
3260
|
"WindFieldMethods mounted with BaseGIS."
|
|
2155
|
-
)) :
|
|
3261
|
+
)) : I("WindFieldMethods mount requires BaseGIS instance.", "INVALID_MOUNT_TARGET");
|
|
2156
3262
|
}
|
|
2157
3263
|
resolveBaseGIS() {
|
|
2158
|
-
var e,
|
|
2159
|
-
return this.baseGIS ? (
|
|
3264
|
+
var e, r;
|
|
3265
|
+
return this.baseGIS ? (r = (e = this.baseGIS).getMapInstance) != null && r.call(e) ? L(null, "BaseGIS is ready.") : I(
|
|
2160
3266
|
"Map instance is not ready. Please call mapCore.init() first.",
|
|
2161
|
-
|
|
2162
|
-
) :
|
|
3267
|
+
R.NOT_INITIALIZED
|
|
3268
|
+
) : I("WindFieldMethods has not been mounted.", "NOT_MOUNTED");
|
|
2163
3269
|
}
|
|
2164
3270
|
addWindField(e = {}) {
|
|
2165
|
-
var
|
|
2166
|
-
const
|
|
2167
|
-
if (!
|
|
2168
|
-
return
|
|
2169
|
-
const
|
|
2170
|
-
if (!
|
|
2171
|
-
return
|
|
2172
|
-
const
|
|
2173
|
-
if (!(
|
|
2174
|
-
return (
|
|
2175
|
-
const
|
|
2176
|
-
this.removeWindField(
|
|
2177
|
-
const
|
|
2178
|
-
id:
|
|
2179
|
-
data:
|
|
2180
|
-
container:
|
|
2181
|
-
...
|
|
2182
|
-
project: (
|
|
3271
|
+
var c, l;
|
|
3272
|
+
const r = this.resolveBaseGIS();
|
|
3273
|
+
if (!r.success)
|
|
3274
|
+
return r;
|
|
3275
|
+
const n = (e == null ? void 0 : e.data) || (e == null ? void 0 : e.windData);
|
|
3276
|
+
if (!n)
|
|
3277
|
+
return I("Wind field data is required.", R.FAILED);
|
|
3278
|
+
const s = this.baseGIS.getMapContainer();
|
|
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);
|
|
3282
|
+
this.removeWindField(i);
|
|
3283
|
+
const o = new fr({
|
|
3284
|
+
id: i,
|
|
3285
|
+
data: n,
|
|
3286
|
+
container: s.data.container,
|
|
3287
|
+
...Ae(e),
|
|
3288
|
+
project: (u, h, d = 0) => {
|
|
2183
3289
|
const f = this.baseGIS.projectToContainerPoint({
|
|
2184
|
-
longitude:
|
|
2185
|
-
latitude:
|
|
3290
|
+
longitude: u,
|
|
3291
|
+
latitude: h,
|
|
2186
3292
|
height: d
|
|
2187
3293
|
});
|
|
2188
3294
|
return f != null && f.success ? f.data : null;
|
|
2189
3295
|
},
|
|
2190
3296
|
getViewBounds: () => {
|
|
2191
|
-
const
|
|
2192
|
-
return
|
|
3297
|
+
const u = this.baseGIS.getViewBounds();
|
|
3298
|
+
return u != null && u.success ? u.data : null;
|
|
2193
3299
|
},
|
|
2194
3300
|
getSceneMode: () => {
|
|
2195
|
-
var
|
|
2196
|
-
const
|
|
2197
|
-
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 : "";
|
|
2198
3304
|
}
|
|
2199
3305
|
});
|
|
2200
|
-
if (!
|
|
2201
|
-
return
|
|
2202
|
-
const
|
|
2203
|
-
onStart: () =>
|
|
2204
|
-
onEnd: () =>
|
|
3306
|
+
if (!o.grid.valid)
|
|
3307
|
+
return o.destroy(), I(o.grid.errorMessage || "Invalid wind field data.", R.FAILED);
|
|
3308
|
+
const a = this.baseGIS.onViewChange({
|
|
3309
|
+
onStart: () => o.suspendForInteraction(),
|
|
3310
|
+
onEnd: () => o.resumeAfterInteraction()
|
|
2205
3311
|
});
|
|
2206
|
-
return
|
|
2207
|
-
layer:
|
|
2208
|
-
offViewChange: (
|
|
2209
|
-
}),
|
|
3312
|
+
return a != null && a.success ? (this.layers.set(i, {
|
|
3313
|
+
layer: o,
|
|
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."));
|
|
2210
3316
|
}
|
|
2211
3317
|
updateWindField(e = {}) {
|
|
2212
|
-
const
|
|
2213
|
-
if (!
|
|
2214
|
-
return
|
|
2215
|
-
const
|
|
2216
|
-
if (!
|
|
2217
|
-
return
|
|
2218
|
-
const
|
|
2219
|
-
return
|
|
3318
|
+
const r = this.resolveBaseGIS();
|
|
3319
|
+
if (!r.success)
|
|
3320
|
+
return r;
|
|
3321
|
+
const n = V(e), s = this.layers.get(n);
|
|
3322
|
+
if (!s)
|
|
3323
|
+
return I(`Wind field "${n}" not found.`, R.FAILED);
|
|
3324
|
+
const i = Ae(e), o = (e == null ? void 0 : e.data) || (e == null ? void 0 : e.windData);
|
|
3325
|
+
return o && (i.data = o), s.layer.updateOptions(i), L(s.layer.getState(), `Wind field "${n}" updated.`);
|
|
2220
3326
|
}
|
|
2221
3327
|
startWindField(e = {}) {
|
|
2222
|
-
const
|
|
2223
|
-
return
|
|
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);
|
|
2224
3330
|
}
|
|
2225
3331
|
stopWindField(e = {}) {
|
|
2226
|
-
const
|
|
2227
|
-
return
|
|
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);
|
|
2228
3334
|
}
|
|
2229
3335
|
showWindField(e = {}) {
|
|
2230
|
-
const
|
|
2231
|
-
return
|
|
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);
|
|
2232
3338
|
}
|
|
2233
3339
|
hideWindField(e = {}) {
|
|
2234
|
-
const
|
|
2235
|
-
return
|
|
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);
|
|
2236
3342
|
}
|
|
2237
3343
|
removeWindField(e = {}) {
|
|
2238
|
-
var
|
|
2239
|
-
const
|
|
2240
|
-
return
|
|
3344
|
+
var s;
|
|
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.`);
|
|
2241
3347
|
}
|
|
2242
3348
|
clearWindFields() {
|
|
2243
3349
|
const e = this.layers.size;
|
|
2244
|
-
return this.layers.forEach((
|
|
2245
|
-
var
|
|
2246
|
-
(
|
|
2247
|
-
}), this.layers.clear(),
|
|
3350
|
+
return this.layers.forEach((r) => {
|
|
3351
|
+
var n;
|
|
3352
|
+
(n = r.offViewChange) == null || n.call(r), r.layer.destroy();
|
|
3353
|
+
}), this.layers.clear(), L({ count: e }, `Wind fields cleared: ${e}.`);
|
|
2248
3354
|
}
|
|
2249
3355
|
getState() {
|
|
2250
3356
|
return {
|
|
@@ -2255,14 +3361,16 @@ class je {
|
|
|
2255
3361
|
}
|
|
2256
3362
|
}
|
|
2257
3363
|
export {
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
3364
|
+
Re as ContourLayerController,
|
|
3365
|
+
Ir as GraphicGroupController,
|
|
3366
|
+
br as GridLayerController,
|
|
3367
|
+
pr as ImageLayerController,
|
|
3368
|
+
Lr as PointDensityController,
|
|
3369
|
+
Cr as PointLargeLayerController,
|
|
3370
|
+
wr as PressureContourLayer,
|
|
3371
|
+
Sr as RasterContourController,
|
|
3372
|
+
Pr as WindFieldMethods,
|
|
3373
|
+
ir as buildPressureRenderData,
|
|
3374
|
+
vr as createPressureDataResolver,
|
|
3375
|
+
j as toImageLayerArea
|
|
2268
3376
|
};
|