@3clear/basegis 0.1.0 → 0.1.2

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