@3clear/basegis 0.1.1 → 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 y, R as G } from "./result-D03zgqh0.js";
2
- import w from "leaflet";
3
- function re(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 Re {
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 re(e) ? (this.baseGIS = e, y(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) ? y(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 Re {
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 r = e.map((n) => {
47
- const a = this.drawItem(n);
48
- return a != null && a.success && (this.loadedCount += 1), {
49
- type: n.type,
50
- id: n.id || "",
51
- success: !!(a != null && a.success),
52
- message: (a == null ? void 0 : a.message) || ""
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);
49
+ return o != null && o.success && (this.loadedCount += 1), {
50
+ type: i.type,
51
+ id: i.id || "",
52
+ success: !!(o != null && o.success),
53
+ message: (o == null ? void 0 : o.message) || ""
53
54
  };
54
55
  });
55
- return y(
56
+ return S(
56
57
  {
57
58
  total: e.length,
58
59
  loadedCount: this.loadedCount,
59
- results: r
60
+ results: s
60
61
  },
61
62
  `Graphic group loaded: ${this.loadedCount}/${e.length}.`
62
63
  );
@@ -65,8 +66,8 @@ class Re {
65
66
  const e = this.resolveBaseGIS();
66
67
  if (!e.success)
67
68
  return e;
68
- const 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,276 +78,281 @@ class Re {
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 k(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 ne(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 ae(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 oe {
97
+ class Re {
97
98
  constructor(e = {}) {
98
- const t = ae(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 ne(e) ? (this.baseGIS = e, y(
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) ? y(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
- }
153
- async load(e = {}, t = {}) {
154
- var a;
155
- const s = this.resolveBaseGIS();
156
- if (!s.success)
157
- return s;
158
- const r = this.buildPayload({
159
- ...O(e),
160
- ...O(t)
152
+ ...r
153
+ }, typeof r.visible == "boolean" && (this.visible = r.visible));
154
+ }
155
+ async load(e = {}, r = {}) {
156
+ var o;
157
+ const n = this.resolveBaseGIS();
158
+ if (!n.success)
159
+ return n;
160
+ const s = this.buildPayload({
161
+ ...W(e),
162
+ ...W(r)
161
163
  });
162
- if (!k(r))
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 n = await this.baseGIS.upsertContourLayer(r);
168
- return n.success && (this.currentPayload = r, this.visible = r.visible !== !1, this.layerType = ((a = n == null ? void 0 : n.data) == null ? void 0 : a.layerType) || this.layerType, this.syncStateFromResult(n)), n;
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 n;
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 && !k(s))
183
- return c("Contour layer has not been loaded.", "NOT_LOADED");
184
- const r = await this.baseGIS.updateContourLayer(s);
185
- return r.success && (this.currentPayload = s, this.visible = s.visible !== !1, this.layerType = ((n = r == null ? void 0 : r.data) == null ? void 0 : n.layerType) || this.layerType, this.syncStateFromResult(r)), r;
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
- }, y(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 ? y(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, r, n, a, o;
265
- if ((t = (e = this.baseGIS) == null ? void 0 : e.getMapInstance) != null && t.call(e) && this.currentPayload) {
266
- const l = (r = (s = this.baseGIS).getContourLayerState) == null ? void 0 : r.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: ((a = (n = this.baseGIS) == null ? void 0 : n.getEngineType) == null ? void 0 : a.call(n)) || "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
- layerId: ((o = this.currentPayload) == null ? void 0 : o.layerId) || this.options.layerId,
282
+ layerId: ((a = this.currentPayload) == null ? void 0 : a.layerId) || this.options.layerId,
277
283
  payload: this.currentPayload,
278
284
  ...this.currentState
279
285
  };
280
286
  }
281
287
  }
282
- function 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 q(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 le(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 ce(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 Fe {
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: q(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 le(e) ? (this.baseGIS = e, y(
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) ? y(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 ? q(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 Fe {
354
360
  };
355
361
  }
356
362
  async load(e = {}) {
357
- var n;
358
- const t = this.resolveBaseGIS();
359
- if (!t.success)
360
- return t;
361
- if (!ce(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), r = await this.baseGIS.upsertGridLayer(s);
367
- return r.success && (this.currentPayload = s, this.visible = s.visible !== !1, this.layerType = ((n = r == null ? void 0 : r.data) == null ? void 0 : n.layerType) || this.layerType), r;
372
+ const n = this.buildPayload(e), s = await this.baseGIS.upsertGridLayer(n);
373
+ return s.success && (this.currentPayload = n, this.visible = n.visible !== !1, this.layerType = ((i = s == null ? void 0 : s.data) == null ? void 0 : i.layerType) || this.layerType), s;
368
374
  }
369
375
  loadTif(e = {}) {
370
376
  return this.load({
@@ -390,142 +396,342 @@ class Fe {
390
396
  ...this.currentPayload,
391
397
  ...e,
392
398
  layerId: e.layerId || e.gridLayerId || this.currentPayload.layerId
393
- }) : 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", y(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 ? y(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;
436
505
  }
437
- function U(i, e = {
506
+ function j(t) {
507
+ const e = re(t);
508
+ if (!e) return null;
509
+ const r = Number(e.startLon), n = Number(e.startLat), s = Number(e.endLon), i = Number(e.endLat);
510
+ return [r, n, s, i].every(Number.isFinite) ? {
511
+ startLon: Math.min(r, s),
512
+ startLat: Math.min(n, i),
513
+ endLon: Math.max(r, s),
514
+ endLat: Math.max(n, i)
515
+ } : null;
516
+ }
517
+ function q(t, e = {
438
518
  startLon: 73,
439
519
  startLat: 18,
440
520
  endLon: 135,
441
521
  endLat: 54
442
522
  }) {
443
- const 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 H(i = {}, e = 0, t = void 0) {
536
+ function ke() {
537
+ return typeof window < "u" && typeof document < "u";
538
+ }
539
+ function qe(t) {
540
+ return `${t || ""}`.toUpperCase() === "EPSG:3857";
541
+ }
542
+ function Y(t, e = "EPSG:4326") {
543
+ return `${t || e}`.toUpperCase();
544
+ }
545
+ function 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);
452
561
  return {
453
- id: (i == null ? void 0 : i.id) || `image-${e}`,
454
- name: (i == null ? void 0 : i.name) || `Image ${e + 1}`,
455
- imageUrl: (i == null ? void 0 : i.imageUrl) || "",
456
- tifUrl: (i == null ? void 0 : i.tifUrl) || "",
457
- description: (i == null ? void 0 : i.description) || "",
458
- area: U(i == null ? void 0 : i.area, t),
459
- opacity: i == null ? void 0 : i.opacity,
460
- isSplit: i == null ? void 0 : i.isSplit,
461
- imageSourceType: i == null ? void 0 : i.imageSourceType,
462
- isGrayImage: i == null ? void 0 : i.isGrayImage,
463
- colorize: i == null ? void 0 : i.colorize,
464
- minValue: i == null ? void 0 : i.minValue,
465
- maxValue: i == null ? void 0 : i.maxValue,
466
- grayMinValue: i == null ? void 0 : i.grayMinValue,
467
- grayMaxValue: i == null ? void 0 : i.grayMaxValue,
468
- noDataValue: i == null ? void 0 : i.noDataValue,
469
- colorMapType: i == null ? void 0 : i.colorMapType,
470
- type: i == null ? void 0 : i.type,
471
- colorStops: i == null ? void 0 : i.colorStops,
472
- colors: i == null ? void 0 : i.colors,
473
- showProbe: i == null ? void 0 : i.showProbe,
474
- enableProbe: i == null ? void 0 : i.enableProbe,
475
- showMouseProbe: i == null ? void 0 : i.showMouseProbe,
476
- showLabel: i == null ? void 0 : i.showLabel,
477
- gridTotal: i == null ? void 0 : i.gridTotal,
478
- tileSize: i == null ? void 0 : i.tileSize,
479
- decimalPlaces: i == null ? void 0 : i.decimalPlaces
562
+ startLon: r.x,
563
+ startLat: r.y,
564
+ endLon: n.x,
565
+ endLat: n.y
480
566
  };
481
567
  }
482
- function ue(i) {
483
- 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");
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
+ };
484
579
  }
485
- class Ee {
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 {
486
683
  constructor(e = {}) {
487
684
  this.options = {
488
685
  visible: e.visible ?? !0,
489
- opacity: S(e.opacity, 0.85),
490
- defaultArea: U(e.defaultArea),
491
- gridTotal: S(e.gridTotal, 4),
492
- tileSize: S(e.tileSize, 512),
493
- 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),
494
692
  imageSourceType: e.imageSourceType || "color",
495
693
  colorize: e.colorize || null,
496
694
  layerId: e.layerId || "image-layer-default"
497
- }, this.baseGIS = null, this.items = [], this.activeIndex = -1, this.visible = this.options.visible, this.layerType = "unknown", this.currentPayload = null, (e.mapCore || e.baseGIS) && this.mount(e.mapCore || e.baseGIS);
695
+ }, this.baseGIS = null, this.items = [], this.activeIndex = -1, this.visible = this.options.visible, this.layerType = "unknown", this.currentPayload = null, this._operationRequestId = 0, (e.mapCore || e.baseGIS) && this.mount(e.mapCore || e.baseGIS);
498
696
  }
499
697
  /**
500
698
  * 绑定 BaseGIS 实例。
501
699
  * 这里不关心具体引擎类型,只要求传入的是 BaseGIS 主类实例。
502
700
  */
503
701
  mount(e) {
504
- var t, s;
505
- return ue(e) ? (this.baseGIS = e, y(
506
- { 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" },
507
705
  "ImageLayerController mounted with BaseGIS."
508
- )) : c(
706
+ )) : b(
509
707
  "ImageLayerController mount requires BaseGIS instance.",
510
708
  "INVALID_MOUNT_TARGET"
511
709
  );
512
710
  }
513
711
  resolveBaseGIS() {
514
- var e, t;
515
- return this.baseGIS ? (t = (e = this.baseGIS).getMapInstance) != null && t.call(e) ? y(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(
516
714
  "Map instance is not ready. Please call mapCore.init() first.",
517
715
  "NOT_INITIALIZED"
518
- ) : c("ImageLayerController has not been mounted.", "NOT_MOUNTED");
716
+ ) : b("ImageLayerController has not been mounted.", "NOT_MOUNTED");
519
717
  }
520
718
  getLayerId(e = {}) {
521
719
  return typeof e == "string" && e ? e : (e == null ? void 0 : e.layerId) || this.options.layerId;
522
720
  }
523
- 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 = {}) {
524
730
  return {
525
- layerId: this.getLayerId(t),
731
+ layerId: this.getLayerId(r),
526
732
  imageUrl: e.imageUrl,
527
733
  tifUrl: e.tifUrl,
528
- area: U(e.area, this.options.defaultArea),
734
+ area: q(e.area, this.options.defaultArea),
529
735
  isSplit: !!e.isSplit,
530
736
  imageSourceType: e.imageSourceType || this.options.imageSourceType,
531
737
  isGrayImage: e.isGrayImage,
@@ -543,46 +749,53 @@ class Ee {
543
749
  enableProbe: e.enableProbe,
544
750
  showMouseProbe: e.showMouseProbe,
545
751
  showLabel: !!e.showLabel,
546
- gridTotal: S(e.gridTotal, this.options.gridTotal),
547
- tileSize: S(e.tileSize, this.options.tileSize),
548
- decimalPlaces: S(e.decimalPlaces, this.options.decimalPlaces),
549
- opacity: S(e.opacity, this.options.opacity),
550
- 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
551
758
  };
552
759
  }
553
760
  /**
554
761
  * 加载图片集合,并切换到默认索引。
555
762
  * 每项字段示例:id / name / imageUrl / tifUrl / area / opacity / isSplit / imageSourceType / colorize / showLabel
556
763
  */
557
- async load(e = [], t = {}) {
764
+ async load(e = [], r = {}) {
558
765
  if (!Array.isArray(e) || e.length === 0)
559
- return c("Image list is empty.", "INVALID_ITEMS");
560
- const s = e.map((n, a) => H(n, a, this.options.defaultArea)).filter((n) => n.imageUrl || n.tifUrl);
561
- if (s.length === 0)
562
- return c("No valid imageUrl or tifUrl found in items.", "INVALID_ITEMS");
563
- this.items = s, typeof t.visible == "boolean" && (this.visible = t.visible);
564
- const r = Number.isInteger(t.index) ? t.index : 0;
565
- return this.switchTo(r);
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);
566
773
  }
567
774
  /**
568
775
  * 切换图片。
569
776
  * target 可传索引数字,也可传图片 id。
570
777
  */
571
778
  async switchTo(e) {
572
- var o;
573
- const t = this.resolveBaseGIS();
574
- if (!t.success)
575
- return t;
779
+ var u, c;
780
+ const r = this.resolveBaseGIS();
781
+ if (!r.success)
782
+ return r;
576
783
  if (!Array.isArray(this.items) || this.items.length === 0)
577
- return c("Image list has not been loaded.", "NOT_LOADED");
578
- let s = -1;
579
- if (typeof e == "number" ? s = e : typeof e == "string" && (s = this.items.findIndex((l) => l.id === e)), s < 0 || s >= this.items.length)
580
- return c(`Invalid image target "${e}".`, "INVALID_TARGET");
581
- const r = this.items[s], n = this.buildLayerPayload(r), a = await this.baseGIS.upsertImageLayer(n);
582
- return a.success ? (this.activeIndex = s, this.layerType = ((o = a == null ? void 0 : a.data) == null ? void 0 : o.layerType) || this.layerType, this.currentPayload = n, y(
583
- { activeIndex: s, activeItem: r },
584
- `Image switched to "${r.name}".`
585
- )) : a;
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;
586
799
  }
587
800
  /**
588
801
  * 更新当前图片图层数据。
@@ -591,77 +804,81 @@ class Ee {
591
804
  * 与 load(items) 不同,update(payload) 不要求维护图片数组,也不表达 next / prev 两态。
592
805
  */
593
806
  async update(e = {}) {
594
- var l;
595
- const t = this.resolveBaseGIS();
596
- if (!t.success)
597
- return t;
598
- const s = this.items[this.activeIndex] || {}, r = this.activeIndex >= 0 ? this.activeIndex : 0, n = H(
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(
599
812
  {
600
- ...s,
601
- ...e
813
+ ...n,
814
+ ...e,
815
+ targetProjection: this.getTargetProjectionFn(e)
602
816
  },
603
- r,
817
+ s,
604
818
  this.options.defaultArea
605
819
  );
606
- if (!n.imageUrl && !n.tifUrl)
607
- return c("Image layer update requires imageUrl or tifUrl.", "INVALID_ITEM");
820
+ if (!i.imageUrl && !i.tifUrl)
821
+ return b("Image layer update requires imageUrl or tifUrl.", "INVALID_ITEM");
608
822
  typeof e.visible == "boolean" && (this.visible = e.visible);
609
- const a = this.buildLayerPayload(n, e), o = await this.baseGIS.upsertImageLayer(a);
610
- return o.success ? (this.items.length === 0 ? (this.items = [n], this.activeIndex = 0) : (this.items.splice(r, 1, n), this.activeIndex = r), this.layerType = ((l = o == null ? void 0 : o.data) == null ? void 0 : l.layerType) || this.layerType, this.currentPayload = a, y(
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(
611
828
  {
612
829
  activeIndex: this.activeIndex,
613
- activeItem: n
830
+ activeItem: o
614
831
  },
615
- `Image layer updated: "${n.name}".`
616
- )) : o;
832
+ `Image layer updated: "${o.name}".`
833
+ )) : u;
617
834
  }
618
835
  async next() {
619
836
  if (!this.items.length)
620
- return c("Image list has not been loaded.", "NOT_LOADED");
837
+ return b("Image list has not been loaded.", "NOT_LOADED");
621
838
  const e = this.activeIndex < 0 ? 0 : (this.activeIndex + 1) % this.items.length;
622
839
  return this.switchTo(e);
623
840
  }
624
841
  async prev() {
625
842
  if (!this.items.length)
626
- return c("Image list has not been loaded.", "NOT_LOADED");
843
+ return b("Image list has not been loaded.", "NOT_LOADED");
627
844
  const e = this.activeIndex < 0 ? this.items.length - 1 : (this.activeIndex - 1 + this.items.length) % this.items.length;
628
845
  return this.switchTo(e);
629
846
  }
630
847
  show(e = {}) {
631
- const t = this.resolveBaseGIS();
632
- if (!t.success)
633
- return t;
634
- const s = this.baseGIS.showImageLayer({
848
+ const r = this.resolveBaseGIS();
849
+ if (!r.success)
850
+ return r;
851
+ const n = this.baseGIS.showImageLayer({
635
852
  layerId: this.getLayerId(e)
636
853
  });
637
- return s.success && (this.visible = !0), s;
854
+ return n.success && (this.visible = !0), n;
638
855
  }
639
856
  hide(e = {}) {
640
- const t = this.resolveBaseGIS();
641
- if (!t.success)
642
- return t;
643
- const s = this.baseGIS.hideImageLayer({
857
+ const r = this.resolveBaseGIS();
858
+ if (!r.success)
859
+ return r;
860
+ const n = this.baseGIS.hideImageLayer({
644
861
  layerId: this.getLayerId(e)
645
862
  });
646
- return s.success && (this.visible = !1), s;
863
+ return n.success && (this.visible = !1), n;
647
864
  }
648
865
  /**
649
866
  * 销毁控制器。
650
867
  * 如果地图已经先销毁,则只清理控制器本地状态。
651
868
  */
652
869
  destroy(e = {}) {
653
- if (!this.resolveBaseGIS().success)
654
- return this.items = [], this.activeIndex = -1, this.layerType = "unknown", this.currentPayload = null, y(null, "Image layer controller destroyed (local state only).");
655
- 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({
656
873
  layerId: this.getLayerId(e)
657
874
  });
658
- return this.items = [], this.activeIndex = -1, this.layerType = "unknown", this.currentPayload = null, s.success ? y(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;
659
876
  }
660
877
  getState() {
661
- var e, t;
878
+ var e, r;
662
879
  return {
663
880
  mounted: !!this.baseGIS,
664
- 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",
665
882
  layerType: this.layerType,
666
883
  visible: this.visible,
667
884
  total: this.items.length,
@@ -671,159 +888,159 @@ class Ee {
671
888
  };
672
889
  }
673
890
  }
674
- function B(i = {}) {
675
- 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 || {};
676
893
  }
677
- function Y(i = {}) {
678
- const e = B(i);
894
+ function Ie(t = {}) {
895
+ const e = $(t);
679
896
  return ["points", "data", "items"].some(
680
- (t) => Object.prototype.hasOwnProperty.call(e, t)
897
+ (r) => Object.prototype.hasOwnProperty.call(e, r)
681
898
  );
682
899
  }
683
- function he(i) {
684
- 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");
685
902
  }
686
- function de(i = {}) {
687
- const { mapCore: e, baseGIS: t, ...s } = i;
688
- return s;
903
+ function et(t = {}) {
904
+ const e = { ...t };
905
+ return delete e.mapCore, delete e.baseGIS, e;
689
906
  }
690
- class Ve {
907
+ class Sr {
691
908
  constructor(e = {}) {
692
- const t = de(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";
693
910
  this.options = {
694
- layerId: s,
695
- visible: t.visible ?? !0,
696
- idKey: t.idKey || "id"
911
+ layerId: n,
912
+ visible: r.visible ?? !0,
913
+ idKey: r.idKey || "id"
697
914
  }, this.defaultPayload = {
698
- ...t,
699
- layerId: s,
915
+ ...r,
916
+ layerId: n,
700
917
  visible: this.options.visible
701
918
  }, this.baseGIS = null, this.currentPayload = null, this.layerType = "unknown", this.visible = this.options.visible, this.currentState = {
702
- layerId: s,
919
+ layerId: n,
703
920
  sourceCount: 0,
704
921
  visibleCount: 0,
705
922
  hiddenCount: 0,
706
923
  gridCount: 0,
707
- gridSize: t.gridSize ?? t.pixelRange ?? 150,
924
+ gridSize: r.gridSize ?? r.pixelRange ?? 150,
708
925
  visible: this.visible,
709
926
  destroyed: !0
710
927
  }, (e.mapCore || e.baseGIS) && this.mount(e.mapCore || e.baseGIS);
711
928
  }
712
929
  mount(e) {
713
- var t, s;
714
- return he(e) ? (this.baseGIS = e, y(
715
- { 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" },
716
933
  "PointDensityController mounted with BaseGIS."
717
- )) : c(
934
+ )) : b(
718
935
  "PointDensityController mount requires BaseGIS instance.",
719
936
  "INVALID_MOUNT_TARGET"
720
937
  );
721
938
  }
722
939
  resolveBaseGIS() {
723
- var e, t;
724
- return this.baseGIS ? (t = (e = this.baseGIS).getMapInstance) != null && t.call(e) ? y(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(
725
942
  "Map instance is not ready. Please call mapCore.init() first.",
726
943
  "NOT_INITIALIZED"
727
- ) : c("PointDensityController has not been mounted.", "NOT_MOUNTED");
944
+ ) : b("PointDensityController has not been mounted.", "NOT_MOUNTED");
728
945
  }
729
946
  getLayerId(e = {}) {
730
- var t;
731
- return typeof e == "string" && e ? e : (e == null ? void 0 : e.pointDensityLayerId) || (e == null ? void 0 : e.densityLayerId) || (e == null ? void 0 : e.layerId) || (e == null ? void 0 : e.id) || ((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;
732
949
  }
733
950
  buildPayload(e = {}) {
734
- const t = B(e), s = this.getLayerId(t);
951
+ const r = $(e), n = this.getLayerId(r);
735
952
  return {
736
953
  ...this.defaultPayload,
737
- ...t,
738
- layerId: s,
739
- visible: typeof t.visible == "boolean" ? t.visible : this.visible
954
+ ...r,
955
+ layerId: n,
956
+ visible: typeof r.visible == "boolean" ? r.visible : this.visible
740
957
  };
741
958
  }
742
959
  syncStateFromResult(e) {
743
- var s;
744
- const t = ((s = e == null ? void 0 : e.data) == null ? void 0 : s.state) || (e == null ? void 0 : e.data) || null;
745
- !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 = {
746
963
  ...this.currentState,
747
- ...t
748
- }, typeof t.visible == "boolean" && (this.visible = t.visible));
964
+ ...r
965
+ }, typeof r.visible == "boolean" && (this.visible = r.visible));
749
966
  }
750
- async load(e = {}, t = {}) {
967
+ async load(e = {}, r = {}) {
751
968
  var l;
752
- const s = this.resolveBaseGIS();
753
- if (!s.success)
754
- return s;
755
- const r = B(e), n = B(t), a = this.buildPayload({
756
- ...r,
757
- ...n
969
+ const n = this.resolveBaseGIS();
970
+ if (!n.success)
971
+ return n;
972
+ const s = $(e), i = $(r), o = this.buildPayload({
973
+ ...s,
974
+ ...i
758
975
  });
759
- if (!Y(a))
760
- return c(
976
+ if (!Ie(o))
977
+ return b(
761
978
  "Point density layer requires points, data or items.",
762
979
  "INVALID_POINT_SOURCE"
763
980
  );
764
- const o = await this.baseGIS.upsertPointDensityLayer(a);
765
- return o.success && (this.currentPayload = a, this.visible = a.visible !== !1, this.layerType = ((l = o == null ? void 0 : o.data) == null ? void 0 : l.layerType) || this.layerType, this.syncStateFromResult(o)), o;
981
+ const a = await this.baseGIS.upsertPointDensityLayer(o);
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;
766
983
  }
767
- upsert(e = {}, t = {}) {
768
- return this.load(e, t);
984
+ upsert(e = {}, r = {}) {
985
+ return this.load(e, r);
769
986
  }
770
987
  async update(e = {}) {
771
- const t = {
988
+ const r = {
772
989
  ...this.currentPayload || this.defaultPayload,
773
- ...B(e)
990
+ ...$(e)
774
991
  };
775
- return !this.currentPayload && !Y(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);
776
993
  }
777
994
  setConfig(e = {}) {
778
995
  return this.update(e);
779
996
  }
780
997
  show(e = {}) {
781
- const t = this.resolveBaseGIS();
782
- if (!t.success)
783
- return t;
784
- const s = this.baseGIS.showPointDensityLayer({
998
+ const r = this.resolveBaseGIS();
999
+ if (!r.success)
1000
+ return r;
1001
+ const n = this.baseGIS.showPointDensityLayer({
785
1002
  ...e,
786
1003
  layerId: this.getLayerId(e)
787
1004
  });
788
- return s.success && (this.visible = !0, this.syncStateFromResult(s)), s;
1005
+ return n.success && (this.visible = !0, this.syncStateFromResult(n)), n;
789
1006
  }
790
1007
  hide(e = {}) {
791
- const t = this.resolveBaseGIS();
792
- if (!t.success)
793
- return t;
794
- const s = this.baseGIS.hidePointDensityLayer({
1008
+ const r = this.resolveBaseGIS();
1009
+ if (!r.success)
1010
+ return r;
1011
+ const n = this.baseGIS.hidePointDensityLayer({
795
1012
  ...e,
796
1013
  layerId: this.getLayerId(e)
797
1014
  });
798
- return s.success && (this.visible = !1, this.syncStateFromResult(s)), s;
1015
+ return n.success && (this.visible = !1, this.syncStateFromResult(n)), n;
799
1016
  }
800
1017
  toggle(e) {
801
1018
  return typeof e == "boolean" ? e ? this.show() : this.hide() : this.visible ? this.hide() : this.show();
802
1019
  }
803
1020
  clear(e = {}) {
804
- const t = this.resolveBaseGIS();
805
- if (!t.success)
806
- return t;
807
- const s = this.baseGIS.clearPointDensityLayer({
1021
+ const r = this.resolveBaseGIS();
1022
+ if (!r.success)
1023
+ return r;
1024
+ const n = this.baseGIS.clearPointDensityLayer({
808
1025
  ...e,
809
1026
  layerId: this.getLayerId(e)
810
1027
  });
811
- return s.success && (this.currentPayload = this.currentPayload ? {
1028
+ return n.success && (this.currentPayload = this.currentPayload ? {
812
1029
  ...this.currentPayload,
813
1030
  points: [],
814
1031
  data: [],
815
1032
  items: []
816
- } : null, this.syncStateFromResult(s)), s;
1033
+ } : null, this.syncStateFromResult(n)), n;
817
1034
  }
818
1035
  refreshState(e = {}) {
819
- const t = this.resolveBaseGIS();
820
- if (!t.success)
821
- return t;
822
- const s = this.baseGIS.getPointDensityLayerState({
1036
+ const r = this.resolveBaseGIS();
1037
+ if (!r.success)
1038
+ return r;
1039
+ const n = this.baseGIS.getPointDensityLayerState({
823
1040
  ...e,
824
1041
  layerId: this.getLayerId(e)
825
1042
  });
826
- return s.success && this.syncStateFromResult(s), s;
1043
+ return n.success && this.syncStateFromResult(n), n;
827
1044
  }
828
1045
  destroy(e = {}) {
829
1046
  if (!this.resolveBaseGIS().success)
@@ -834,8 +1051,8 @@ class Ve {
834
1051
  hiddenCount: 0,
835
1052
  gridCount: 0,
836
1053
  destroyed: !0
837
- }, y(null, "Point density layer controller destroyed (local state only).");
838
- const s = this.baseGIS.removePointDensityLayer({
1054
+ }, S(null, "Point density layer controller destroyed (local state only).");
1055
+ const n = this.baseGIS.removePointDensityLayer({
839
1056
  ...e,
840
1057
  layerId: this.getLayerId(e)
841
1058
  });
@@ -846,66 +1063,66 @@ class Ve {
846
1063
  hiddenCount: 0,
847
1064
  gridCount: 0,
848
1065
  destroyed: !0
849
- }, s.success ? y(null, "Point density layer controller destroyed.") : s;
1066
+ }, n.success ? S(null, "Point density layer controller destroyed.") : n;
850
1067
  }
851
1068
  removeLayer(e = {}) {
852
1069
  return this.destroy(e);
853
1070
  }
854
1071
  getState() {
855
- var e, t, s, r, n, a, o;
856
- if ((t = (e = this.baseGIS) == null ? void 0 : e.getMapInstance) != null && t.call(e) && this.currentPayload) {
857
- const l = (r = (s = this.baseGIS).getPointDensityLayerState) == null ? void 0 : r.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, {
858
1075
  layerId: this.currentPayload.layerId || this.options.layerId
859
1076
  });
860
1077
  l != null && l.success && this.syncStateFromResult(l);
861
1078
  }
862
1079
  return {
863
1080
  mounted: !!this.baseGIS,
864
- engineType: ((a = (n = this.baseGIS) == null ? void 0 : n.getEngineType) == null ? void 0 : a.call(n)) || "unknown",
1081
+ engineType: ((o = (i = this.baseGIS) == null ? void 0 : i.getEngineType) == null ? void 0 : o.call(i)) || "unknown",
865
1082
  layerType: this.layerType,
866
1083
  visible: this.visible,
867
- layerId: ((o = this.currentPayload) == null ? void 0 : o.layerId) || this.options.layerId,
1084
+ layerId: ((a = this.currentPayload) == null ? void 0 : a.layerId) || this.options.layerId,
868
1085
  payload: this.currentPayload,
869
1086
  ...this.currentState
870
1087
  };
871
1088
  }
872
1089
  }
873
- function D(i = {}) {
874
- 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 || {};
875
1092
  }
876
- function Z(i = {}) {
877
- const e = D(i);
1093
+ function be(t = {}) {
1094
+ const e = k(t);
878
1095
  return ["points", "data", "items"].some(
879
- (t) => Object.prototype.hasOwnProperty.call(e, t)
1096
+ (r) => Object.prototype.hasOwnProperty.call(e, r)
880
1097
  );
881
1098
  }
882
- function ye(i) {
883
- 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");
884
1101
  }
885
- function K(i, e = {}) {
886
- 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;
887
1104
  }
888
- function fe(i, e = "id", t = "") {
889
- var s, r;
890
- return !i || typeof i != "object" || Array.isArray(i) ? t : i[e] ?? ((s = i.properties) == null ? void 0 : s[e]) ?? i.id ?? ((r = i.properties) == null ? void 0 : r.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;
891
1108
  }
892
- function Ie(i = {}) {
893
- const { mapCore: e, baseGIS: t, ...s } = i;
894
- return s;
1109
+ function nt(t = {}) {
1110
+ const { mapCore: e, baseGIS: r, ...n } = t;
1111
+ return n;
895
1112
  }
896
- class ze {
1113
+ class Cr {
897
1114
  constructor(e = {}) {
898
- const t = Ie(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";
899
1116
  this.options = {
900
- layerId: s,
901
- visible: t.visible ?? !0,
902
- idKey: t.idKey || "id"
1117
+ layerId: n,
1118
+ visible: r.visible ?? !0,
1119
+ idKey: r.idKey || "id"
903
1120
  }, this.defaultPayload = {
904
- ...t,
905
- layerId: s,
1121
+ ...r,
1122
+ layerId: n,
906
1123
  visible: this.options.visible
907
1124
  }, this.baseGIS = null, this.currentPayload = null, this.layerType = "unknown", this.visible = this.options.visible, this.currentState = {
908
- layerId: s,
1125
+ layerId: n,
909
1126
  visible: this.visible,
910
1127
  total: 0,
911
1128
  renderedCount: 0,
@@ -915,127 +1132,127 @@ class ze {
915
1132
  }, (e.mapCore || e.baseGIS) && this.mount(e.mapCore || e.baseGIS);
916
1133
  }
917
1134
  mount(e) {
918
- var t, s;
919
- return ye(e) ? (this.baseGIS = e, y(
920
- { 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" },
921
1138
  "PointLargeLayerController mounted with BaseGIS."
922
- )) : c(
1139
+ )) : b(
923
1140
  "PointLargeLayerController mount requires BaseGIS instance.",
924
1141
  "INVALID_MOUNT_TARGET"
925
1142
  );
926
1143
  }
927
1144
  resolveBaseGIS() {
928
- var e, t;
929
- return this.baseGIS ? (t = (e = this.baseGIS).getMapInstance) != null && t.call(e) ? y(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(
930
1147
  "Map instance is not ready. Please call mapCore.init() first.",
931
1148
  "NOT_INITIALIZED"
932
- ) : c("PointLargeLayerController has not been mounted.", "NOT_MOUNTED");
1149
+ ) : b("PointLargeLayerController has not been mounted.", "NOT_MOUNTED");
933
1150
  }
934
- getLayerId(e = {}, t = {}) {
935
- var r;
936
- const { allowId: s = !0 } = t;
937
- return typeof e == "string" && e ? e : (e == null ? void 0 : e.pointLargeLayerId) || (e == null ? void 0 : e.largeLayerId) || (e == null ? void 0 : e.layerId) || (s ? e == null ? void 0 : e.id : "") || ((r = this.currentPayload) == null ? void 0 : r.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;
938
1155
  }
939
1156
  buildPayload(e = {}) {
940
- const t = D(e), s = this.getLayerId(t);
1157
+ const r = k(e), n = this.getLayerId(r);
941
1158
  return {
942
1159
  ...this.defaultPayload,
943
- ...t,
944
- layerId: s,
945
- visible: typeof t.visible == "boolean" ? t.visible : this.visible
1160
+ ...r,
1161
+ layerId: n,
1162
+ visible: typeof r.visible == "boolean" ? r.visible : this.visible
946
1163
  };
947
1164
  }
948
1165
  syncStateFromResult(e) {
949
- var s;
950
- const t = ((s = e == null ? void 0 : e.data) == null ? void 0 : s.state) || (e == null ? void 0 : e.data) || null;
951
- !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 = {
952
1169
  ...this.currentState,
953
- ...t
954
- }, typeof t.visible == "boolean" && (this.visible = t.visible));
1170
+ ...r
1171
+ }, typeof r.visible == "boolean" && (this.visible = r.visible));
955
1172
  }
956
1173
  /**
957
1174
  * 加载或重建海量点位。
958
1175
  * 支持 load(points, options) 或 load({ points, ...options }) 两种调用方式。
959
1176
  */
960
- async load(e = {}, t = {}) {
1177
+ async load(e = {}, r = {}) {
961
1178
  var l;
962
- const s = this.resolveBaseGIS();
963
- if (!s.success)
964
- return s;
965
- const r = D(e), n = D(t), a = this.buildPayload({
966
- ...r,
967
- ...n
1179
+ const n = this.resolveBaseGIS();
1180
+ if (!n.success)
1181
+ return n;
1182
+ const s = k(e), i = k(r), o = this.buildPayload({
1183
+ ...s,
1184
+ ...i
968
1185
  });
969
- if (!Z(a))
970
- return c(
1186
+ if (!be(o))
1187
+ return b(
971
1188
  "Point large layer requires points, data or items.",
972
1189
  "INVALID_POINT_SOURCE"
973
1190
  );
974
- const o = await this.baseGIS.upsertPointLargeLayer(a);
975
- return o.success && (this.currentPayload = a, this.visible = a.visible !== !1, this.layerType = ((l = o == null ? void 0 : o.data) == null ? void 0 : l.layerType) || this.layerType, this.syncStateFromResult(o)), o;
1191
+ const a = await this.baseGIS.upsertPointLargeLayer(o);
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;
976
1193
  }
977
- upsert(e = {}, t = {}) {
978
- return this.load(e, t);
1194
+ upsert(e = {}, r = {}) {
1195
+ return this.load(e, r);
979
1196
  }
980
1197
  async update(e = {}) {
981
- const t = {
1198
+ const r = {
982
1199
  ...this.currentPayload || this.defaultPayload,
983
- ...D(e)
1200
+ ...k(e)
984
1201
  };
985
- return !this.currentPayload && !Z(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);
986
1203
  }
987
1204
  show(e = {}) {
988
- const t = this.resolveBaseGIS();
989
- if (!t.success)
990
- return t;
991
- const s = this.baseGIS.showPointLargeLayer({
1205
+ const r = this.resolveBaseGIS();
1206
+ if (!r.success)
1207
+ return r;
1208
+ const n = this.baseGIS.showPointLargeLayer({
992
1209
  ...e,
993
1210
  layerId: this.getLayerId(e)
994
1211
  });
995
- return s.success && (this.visible = !0, this.syncStateFromResult(s)), s;
1212
+ return n.success && (this.visible = !0, this.syncStateFromResult(n)), n;
996
1213
  }
997
1214
  hide(e = {}) {
998
- const t = this.resolveBaseGIS();
999
- if (!t.success)
1000
- return t;
1001
- const s = this.baseGIS.hidePointLargeLayer({
1215
+ const r = this.resolveBaseGIS();
1216
+ if (!r.success)
1217
+ return r;
1218
+ const n = this.baseGIS.hidePointLargeLayer({
1002
1219
  ...e,
1003
1220
  layerId: this.getLayerId(e)
1004
1221
  });
1005
- return s.success && (this.visible = !1, this.syncStateFromResult(s)), s;
1222
+ return n.success && (this.visible = !1, this.syncStateFromResult(n)), n;
1006
1223
  }
1007
1224
  toggle(e) {
1008
1225
  return typeof e == "boolean" ? e ? this.show() : this.hide() : this.visible ? this.hide() : this.show();
1009
1226
  }
1010
- setHighlight(e, t = {}) {
1011
- const s = this.resolveBaseGIS();
1012
- if (!s.success)
1013
- return s;
1014
- const r = e && typeof e == "object" && !Array.isArray(e) ? e : t, n = K(e, r);
1015
- if (n == null || n === "")
1016
- return c("Point id is required when setting highlight.", "INVALID_POINT_ID");
1017
- const a = this.baseGIS.setPointLargeHighlight({
1018
- ...r,
1019
- layerId: this.getLayerId(r, { allowId: !1 }),
1020
- pointId: n
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");
1234
+ const o = this.baseGIS.setPointLargeHighlight({
1235
+ ...s,
1236
+ layerId: this.getLayerId(s, { allowId: !1 }),
1237
+ pointId: i
1021
1238
  });
1022
- return a.success && this.syncStateFromResult(a), a;
1239
+ return o.success && this.syncStateFromResult(o), o;
1023
1240
  }
1024
- highlight(e, t = {}) {
1025
- return this.setHighlight(e, t);
1241
+ highlight(e, r = {}) {
1242
+ return this.setHighlight(e, r);
1026
1243
  }
1027
- setHighlighted(e, t = {}) {
1028
- return this.setHighlight(e, t);
1244
+ setHighlighted(e, r = {}) {
1245
+ return this.setHighlight(e, r);
1029
1246
  }
1030
1247
  clearHighlight(e = {}) {
1031
- const t = this.resolveBaseGIS();
1032
- if (!t.success)
1033
- return t;
1034
- const s = this.baseGIS.clearPointLargeHighlight({
1248
+ const r = this.resolveBaseGIS();
1249
+ if (!r.success)
1250
+ return r;
1251
+ const n = this.baseGIS.clearPointLargeHighlight({
1035
1252
  ...e,
1036
1253
  layerId: this.getLayerId(e)
1037
1254
  });
1038
- return s.success && this.syncStateFromResult(s), s;
1255
+ return n.success && this.syncStateFromResult(n), n;
1039
1256
  }
1040
1257
  clearHighlighted(e = {}) {
1041
1258
  return this.clearHighlight(e);
@@ -1043,79 +1260,79 @@ class ze {
1043
1260
  removeCachedPoints(e = []) {
1044
1261
  if (!this.currentPayload || !Array.isArray(this.currentPayload.points))
1045
1262
  return;
1046
- const t = this.currentPayload.idKey || this.options.idKey, s = new Set(e.map((r) => String(r)));
1263
+ const r = this.currentPayload.idKey || this.options.idKey, n = new Set(e.map((s) => String(s)));
1047
1264
  this.currentPayload = {
1048
1265
  ...this.currentPayload,
1049
- points: this.currentPayload.points.filter((r, n) => {
1050
- const a = fe(r, t, n);
1051
- return !s.has(String(a));
1266
+ points: this.currentPayload.points.filter((s, i) => {
1267
+ const o = rt(s, r, i);
1268
+ return !n.has(String(o));
1052
1269
  })
1053
1270
  };
1054
1271
  }
1055
- removePoint(e, t = {}) {
1056
- const s = this.resolveBaseGIS();
1057
- if (!s.success)
1058
- return s;
1059
- const r = e && typeof e == "object" && !Array.isArray(e) ? e : t, n = K(e, r);
1060
- if (n == null || n === "")
1061
- return c("Point id is required when removing point.", "INVALID_POINT_ID");
1062
- const a = this.baseGIS.removePointLargePoint({
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");
1279
+ const o = this.baseGIS.removePointLargePoint({
1280
+ ...s,
1281
+ layerId: this.getLayerId(s, { allowId: !1 }),
1282
+ pointId: i
1283
+ });
1284
+ return o.success && (this.removeCachedPoints([i]), this.syncStateFromResult(o)), o;
1285
+ }
1286
+ deletePoint(e, r = {}) {
1287
+ return this.removePoint(e, r);
1288
+ }
1289
+ removeById(e, r = {}) {
1290
+ return this.removePoint(e, r);
1291
+ }
1292
+ async removePoints(e = [], r = {}) {
1293
+ const n = this.resolveBaseGIS();
1294
+ if (!n.success)
1295
+ return n;
1296
+ const s = Array.isArray(e) ? e : [e];
1297
+ if (s.length === 0)
1298
+ return b("Point id list is required when removing points.", "INVALID_POINT_ID");
1299
+ const i = this.baseGIS.removePointLargePoints({
1063
1300
  ...r,
1064
1301
  layerId: this.getLayerId(r, { allowId: !1 }),
1065
- pointId: n
1066
- });
1067
- return a.success && (this.removeCachedPoints([n]), this.syncStateFromResult(a)), a;
1068
- }
1069
- deletePoint(e, t = {}) {
1070
- return this.removePoint(e, t);
1071
- }
1072
- removeById(e, t = {}) {
1073
- return this.removePoint(e, t);
1074
- }
1075
- async removePoints(e = [], t = {}) {
1076
- const s = this.resolveBaseGIS();
1077
- if (!s.success)
1078
- return s;
1079
- const r = Array.isArray(e) ? e : [e];
1080
- if (r.length === 0)
1081
- return c("Point id list is required when removing points.", "INVALID_POINT_ID");
1082
- const n = this.baseGIS.removePointLargePoints({
1083
- ...t,
1084
- layerId: this.getLayerId(t, { allowId: !1 }),
1085
- pointIds: r
1302
+ pointIds: s
1086
1303
  });
1087
- return n.success && (this.removeCachedPoints(r), this.syncStateFromResult(n)), n;
1304
+ return i.success && (this.removeCachedPoints(s), this.syncStateFromResult(i)), i;
1088
1305
  }
1089
- deletePoints(e = [], t = {}) {
1090
- return this.removePoints(e, t);
1306
+ deletePoints(e = [], r = {}) {
1307
+ return this.removePoints(e, r);
1091
1308
  }
1092
- removeByIds(e = [], t = {}) {
1093
- return this.removePoints(e, t);
1309
+ removeByIds(e = [], r = {}) {
1310
+ return this.removePoints(e, r);
1094
1311
  }
1095
1312
  clear(e = {}) {
1096
- const t = this.resolveBaseGIS();
1097
- if (!t.success)
1098
- return t;
1099
- const s = this.baseGIS.clearPointLargeLayer({
1313
+ const r = this.resolveBaseGIS();
1314
+ if (!r.success)
1315
+ return r;
1316
+ const n = this.baseGIS.clearPointLargeLayer({
1100
1317
  ...e,
1101
1318
  layerId: this.getLayerId(e)
1102
1319
  });
1103
- return s.success && (this.currentPayload = this.currentPayload ? {
1320
+ return n.success && (this.currentPayload = this.currentPayload ? {
1104
1321
  ...this.currentPayload,
1105
1322
  points: [],
1106
1323
  data: [],
1107
1324
  items: []
1108
- } : null, this.syncStateFromResult(s)), s;
1325
+ } : null, this.syncStateFromResult(n)), n;
1109
1326
  }
1110
1327
  refreshState(e = {}) {
1111
- const t = this.resolveBaseGIS();
1112
- if (!t.success)
1113
- return t;
1114
- const s = this.baseGIS.getPointLargeLayerState({
1328
+ const r = this.resolveBaseGIS();
1329
+ if (!r.success)
1330
+ return r;
1331
+ const n = this.baseGIS.getPointLargeLayerState({
1115
1332
  ...e,
1116
1333
  layerId: this.getLayerId(e)
1117
1334
  });
1118
- return s.success && this.syncStateFromResult(s), s;
1335
+ return n.success && this.syncStateFromResult(n), n;
1119
1336
  }
1120
1337
  /**
1121
1338
  * 销毁图层。
@@ -1129,8 +1346,8 @@ class ze {
1129
1346
  renderedCount: 0,
1130
1347
  building: !1,
1131
1348
  destroyed: !0
1132
- }, y(null, "Point large layer controller destroyed (local state only).");
1133
- const s = this.baseGIS.removePointLargeLayer({
1349
+ }, S(null, "Point large layer controller destroyed (local state only).");
1350
+ const n = this.baseGIS.removePointLargeLayer({
1134
1351
  ...e,
1135
1352
  layerId: this.getLayerId(e)
1136
1353
  });
@@ -1140,190 +1357,1120 @@ class ze {
1140
1357
  renderedCount: 0,
1141
1358
  building: !1,
1142
1359
  destroyed: !0
1143
- }, s.success ? y(null, "Point large layer controller destroyed.") : s;
1360
+ }, n.success ? S(null, "Point large layer controller destroyed.") : n;
1144
1361
  }
1145
1362
  removeLayer(e = {}) {
1146
1363
  return this.destroy(e);
1147
1364
  }
1148
1365
  getState() {
1149
- var e, t, s, r, n, a, o;
1150
- if ((t = (e = this.baseGIS) == null ? void 0 : e.getMapInstance) != null && t.call(e) && this.currentPayload) {
1151
- const l = (r = (s = this.baseGIS).getPointLargeLayerState) == null ? void 0 : r.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, {
1152
1369
  layerId: this.currentPayload.layerId || this.options.layerId
1153
1370
  });
1154
1371
  l != null && l.success && this.syncStateFromResult(l);
1155
1372
  }
1156
1373
  return {
1157
1374
  mounted: !!this.baseGIS,
1158
- engineType: ((a = (n = this.baseGIS) == null ? void 0 : n.getEngineType) == null ? void 0 : a.call(n)) || "unknown",
1375
+ engineType: ((o = (i = this.baseGIS) == null ? void 0 : i.getEngineType) == null ? void 0 : o.call(i)) || "unknown",
1159
1376
  layerType: this.layerType,
1160
1377
  visible: this.visible,
1161
- layerId: ((o = this.currentPayload) == null ? void 0 : o.layerId) || this.options.layerId,
1378
+ layerId: ((a = this.currentPayload) == null ? void 0 : a.layerId) || this.options.layerId,
1162
1379
  payload: this.currentPayload,
1163
1380
  ...this.currentState
1164
1381
  };
1165
1382
  }
1166
1383
  }
1167
- function N() {
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 _() {
1168
2315
  return typeof window < "u" ? window.Cesium : null;
1169
2316
  }
1170
- function ge(i) {
1171
- let e = i;
2317
+ function Zt(t) {
2318
+ let e = t;
1172
2319
  return e > 90 && (e -= 180), e < -90 && (e += 180), e;
1173
2320
  }
1174
- function me(i, e = 0) {
1175
- return w.divIcon({
2321
+ function Jt(t, e = 0) {
2322
+ return B.divIcon({
1176
2323
  className: "pressure-label-icon",
1177
- html: `<span style="transform: translate(-50%, -50%) rotate(${ge(e)}deg)">${i}</span>`,
2324
+ html: `<span style="transform: translate(-50%, -50%) rotate(${Zt(e)}deg)">${t}</span>`,
1178
2325
  iconSize: [0, 0],
1179
2326
  iconAnchor: [0, 0]
1180
2327
  });
1181
2328
  }
1182
- function be(i) {
1183
- return w.divIcon({
1184
- className: `pressure-center-icon pressure-center-icon--${i.type.toLowerCase()}`,
1185
- 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>`,
1186
2333
  iconSize: [0, 0],
1187
2334
  iconAnchor: [0, 0]
1188
2335
  });
1189
2336
  }
1190
- function j(i, e) {
1191
- return i.some(
1192
- (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)
1193
2340
  );
1194
2341
  }
1195
- function W(i, e, t) {
2342
+ function ae(t, e, r) {
1196
2343
  return {
1197
- left: i.x - e,
1198
- right: i.x + e,
1199
- top: i.y - t,
1200
- bottom: i.y + t
2344
+ left: t.x - e,
2345
+ right: t.x + e,
2346
+ top: t.y - r,
2347
+ bottom: t.y + r
1201
2348
  };
1202
2349
  }
1203
- function X(i, e, t = 18, s = 10) {
1204
- i.sort((r, n) => r.score - n.score);
1205
- for (let r = 0; r < i.length; r += 1) {
1206
- const n = i[r], a = W(n.point, t, s);
1207
- if (!j(e, a))
1208
- return e.push(a), n;
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;
1209
2356
  }
1210
2357
  return null;
1211
2358
  }
1212
- function J(i = [], e = 0) {
1213
- 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;
1214
2361
  }
1215
- function pe(i = [], e = 2) {
1216
- if (i.length <= 2 || e <= 1)
1217
- return i;
1218
- const t = [];
1219
- for (let r = 0; r < i.length; r += e)
1220
- t.push(i[r]);
1221
- const s = i[i.length - 1];
1222
- 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;
1223
2370
  }
1224
- function Se(i) {
1225
- let e = Number(i);
2371
+ function tr(t) {
2372
+ let e = Number(t);
1226
2373
  for (; e > 180; )
1227
2374
  e -= 360;
1228
2375
  for (; e < -180; )
1229
2376
  e += 360;
1230
2377
  return e;
1231
2378
  }
1232
- function Q(i) {
1233
- return Math.round(Number(i) / 100);
2379
+ function Te(t) {
2380
+ return Math.round(Number(t) / 100);
1234
2381
  }
1235
- function ve(i = [], e = 0) {
1236
- const t = [];
1237
- for (let s = 0; s < i.length - 1; s += 2) {
1238
- const r = Number(i[s]), n = Number(i[s + 1]) + e;
1239
- Number.isFinite(r) && Number.isFinite(n) && t.push([r, n]);
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]);
1240
2387
  }
1241
- return t;
2388
+ return r;
1242
2389
  }
1243
- function Ce(i, e, t, s, r) {
1244
- const n = r * r, a = n * r;
2390
+ function nr(t, e, r, n, s) {
2391
+ const i = s * s, o = i * s;
1245
2392
  return [
1246
- 0.5 * (2 * e[0] + (-i[0] + t[0]) * r + (2 * i[0] - 5 * e[0] + 4 * t[0] - s[0]) * n + (-i[0] + 3 * e[0] - 3 * t[0] + s[0]) * a),
1247
- 0.5 * (2 * e[1] + (-i[1] + t[1]) * r + (2 * i[1] - 5 * e[1] + 4 * t[1] - s[1]) * n + (-i[1] + 3 * e[1] - 3 * t[1] + s[1]) * a)
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)
1248
2395
  ];
1249
2396
  }
1250
- function Le(i = [], e = 5) {
1251
- if (i.length < 3)
1252
- return i;
1253
- const t = [i[0]];
1254
- for (let s = 0; s < i.length - 1; s += 1) {
1255
- const r = i[s - 1] || i[s], n = i[s], a = i[s + 1], o = i[s + 2] || a;
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;
1256
2403
  for (let l = 1; l <= e; l += 1)
1257
- t.push(Ce(r, n, a, o, l / e));
2404
+ r.push(nr(s, i, o, a, l / e));
1258
2405
  }
1259
- return t;
2406
+ return r;
1260
2407
  }
1261
- function Pe(i = {}) {
1262
- const e = (i.isoline || []).map((s) => {
1263
- const r = Number(s.value);
2408
+ function ir(t = {}) {
2409
+ const e = (t.isoline || []).map((n) => {
2410
+ const s = Number(n.value);
1264
2411
  return {
1265
- value: r,
1266
- hpa: Q(r),
1267
- major: r % 800 === 0,
1268
- lines: [Le(ve(s.points))].filter((n) => n.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)
1269
2416
  };
1270
- }), t = ["high", "low"].flatMap((s) => {
1271
- const r = i[s] || {}, n = Array.isArray(r.value) ? r.value : [], a = Array.isArray(r.points) ? r.points : [], o = [];
1272
- for (let l = 0; l < a.length - 1; l += 2)
1273
- o.push({
1274
- type: s === "high" ? "H" : "L",
1275
- value: Q(n[l / 2]),
1276
- lat: Number(a[l]),
1277
- lon: Se(a[l + 1])
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 = [];
2419
+ for (let l = 0; l < o.length - 1; l += 2)
2420
+ a.push({
2421
+ type: n === "high" ? "H" : "L",
2422
+ value: Te(i[l / 2]),
2423
+ lat: Number(o[l]),
2424
+ lon: tr(o[l + 1])
1278
2425
  });
1279
- return o;
2426
+ return a;
1280
2427
  });
1281
2428
  return {
1282
2429
  isolines: e,
1283
- centers: t
2430
+ centers: r
1284
2431
  };
1285
2432
  }
1286
- function $(i = {}) {
1287
- return Array.isArray(i == null ? void 0 : i.isolines) ? {
1288
- ...i,
1289
- isolines: i.isolines,
1290
- centers: Array.isArray(i.centers) ? i.centers : []
1291
- } : Pe(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);
1292
2439
  }
1293
- function _e(i = {}) {
2440
+ function vr(t = {}) {
1294
2441
  const e = /* @__PURE__ */ new Map();
1295
- return (t = "default") => {
1296
- const s = t || "default";
1297
- return e.has(s) || e.set(s, $(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);
1298
2445
  };
1299
2446
  }
1300
- class Ge {
2447
+ class or {
1301
2448
  constructor(e = {}) {
1302
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;
1303
2450
  }
1304
2451
  // 当前引擎类型由 BaseGIS 决定,标注层只负责适配具体绘制方式。
1305
2452
  isCesiumEngine() {
1306
- var e, t;
1307
- 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";
1308
2455
  }
1309
2456
  // Cesium 3D 模式需要判断地球背面遮挡,2D/哥伦布视图不做额外遮挡过滤。
1310
2457
  getCesiumSceneMode() {
1311
- var t, s, r;
1312
- const e = (s = (t = this.mapCore) == null ? void 0 : t.getMapInstance) == null ? void 0 : s.call(t);
1313
- return (r = e == null ? void 0 : e.scene) == null ? void 0 : r.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;
1314
2461
  }
1315
2462
  // 挂载标注层事件:Leaflet 监听地图事件,Cesium 走 BaseGIS 的视图变化回调。
1316
2463
  mount() {
1317
- var t, s, r, n, a, o;
2464
+ var r, n, s, i, o, a;
1318
2465
  if (this.isCesiumEngine()) {
1319
- this.removeViewChangeListener = ((n = (r = (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, {
1320
2467
  onEnd: () => this.scheduleUpdate(),
1321
2468
  endDelay: 180
1322
- })) == null ? void 0 : r.data) == null ? void 0 : n.off) || null;
2469
+ })) == null ? void 0 : s.data) == null ? void 0 : i.off) || null;
1323
2470
  return;
1324
2471
  }
1325
- const e = (o = (a = this.mapCore) == null ? void 0 : a.getMapInstance) == null ? void 0 : o.call(a);
1326
- e && (this.labelLayerGroup = w.layerGroup().addTo(e), e.on("moveend zoomend resize", this.scheduleUpdate, this));
2472
+ const e = (a = (o = this.mapCore) == null ? void 0 : o.getMapInstance) == null ? void 0 : a.call(o);
2473
+ e && (this.labelLayerGroup = B.layerGroup().addTo(e), e.on("moveend zoomend resize", this.scheduleUpdate, this));
1327
2474
  }
1328
2475
  // 地图连续移动时只在下一帧刷新一次标签,减少重复碰撞计算。
1329
2476
  scheduleUpdate() {
@@ -1343,50 +2490,50 @@ class Ge {
1343
2490
  }
1344
2491
  // 销毁时移除地图事件、Cesium LabelCollection 和 Leaflet 图层组。
1345
2492
  destroy() {
1346
- var t, s, r, n, a;
2493
+ var r, n, s, i, o;
1347
2494
  this.labelUpdateTimer && (window.cancelAnimationFrame(this.labelUpdateTimer), this.labelUpdateTimer = null);
1348
- const e = (s = (t = this.mapCore) == null ? void 0 : t.getMapInstance) == null ? void 0 : s.call(t);
1349
- (r = e == null ? void 0 : e.off) == null || r.call(e, "moveend zoomend resize", this.scheduleUpdate, this), (n = this.removeViewChangeListener) == null || n.call(this), this.removeViewChangeListener = null, this.clearCesiumLabelCollection(!0), (a = this.labelLayerGroup) == null || a.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;
1350
2497
  }
1351
2498
  // 把标签数量回传给页面状态面板。
1352
2499
  emitStateChange(e) {
1353
- var t;
1354
- (t = this.onStateChange) == null || t.call(this, {
2500
+ var r;
2501
+ (r = this.onStateChange) == null || r.call(this, {
1355
2502
  labelCount: e
1356
2503
  });
1357
2504
  }
1358
2505
  // Cesium 3D 球面下,屏幕外或地球背面的点不参与标签候选。
1359
2506
  isCesiumPointVisible(e) {
1360
- var u, h, I, d, f, g;
1361
- const t = (h = (u = this.mapCore) == null ? void 0 : u.getMapInstance) == null ? void 0 : h.call(u), s = N(), r = t == null ? void 0 : t.scene;
1362
- if (!t || !s || !r)
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)
1363
2510
  return !1;
1364
- if (this.getCesiumSceneMode() !== s.SceneMode.SCENE3D)
2511
+ if (this.getCesiumSceneMode() !== n.SceneMode.SCENE3D)
1365
2512
  return !0;
1366
- const n = ((I = r.globe) == null ? void 0 : I.ellipsoid) || ((d = r.mapProjection) == null ? void 0 : d.ellipsoid), a = ((f = r.camera) == null ? void 0 : f.positionWC) || ((g = r.camera) == null ? void 0 : g.position);
1367
- if (!n || !a)
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)
1368
2515
  return !0;
1369
- const o = s.Cartesian3.fromDegrees(e[1], e[0], 0);
1370
- return new s.EllipsoidalOccluder(n, a).isPointVisible(o);
2516
+ const a = n.Cartesian3.fromDegrees(e[1], e[0], 0);
2517
+ return new n.EllipsoidalOccluder(i, o).isPointVisible(a);
1371
2518
  }
1372
2519
  // 标签候选点只在地图容器附近参与碰撞,防止屏幕外点影响布局。
1373
- isCesiumScreenPointInViewport(e, t = 80) {
1374
- const s = document.getElementById(this.mapContainerId), r = (s == null ? void 0 : s.clientWidth) || 0, n = (s == null ? void 0 : s.clientHeight) || 0;
1375
- return !r || !n ? !0 : !(e.x < -t || e.y < -t || e.x > r + t || e.y > n + 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);
1376
2523
  }
1377
2524
  // LabelCollection 比为每个标签创建 Entity 更轻量,适合动态重建。
1378
2525
  ensureCesiumLabelCollection() {
1379
- var s, r, n;
1380
- const e = (r = (s = this.mapCore) == null ? void 0 : s.getMapInstance) == null ? void 0 : r.call(s), t = N();
1381
- return !((n = e == null ? void 0 : e.scene) != null && n.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);
1382
2529
  }
1383
2530
  // 数据更新和图层隐藏时清空标签;页面卸载时才销毁集合。
1384
2531
  clearCesiumLabelCollection(e = !1) {
1385
- var s, r, n;
1386
- const t = (r = (s = this.mapCore) == null ? void 0 : s.getMapInstance) == null ? void 0 : r.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);
1387
2534
  if (this.cesiumLabelCollection) {
1388
- if (e && ((n = t == null ? void 0 : t.scene) != null && n.primitives)) {
1389
- 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;
1390
2537
  return;
1391
2538
  }
1392
2539
  this.cesiumLabelCollection.removeAll();
@@ -1394,194 +2541,194 @@ class Ge {
1394
2541
  }
1395
2542
  // 页面数据统一是 [lat, lon],Cesium 创建坐标时需要 [lon, lat]。
1396
2543
  createCesiumPosition(e) {
1397
- return N().Cartesian3.fromDegrees(e[1], e[0], 0);
2544
+ return _().Cartesian3.fromDegrees(e[1], e[0], 0);
1398
2545
  }
1399
2546
  // 将地理点投影到容器像素坐标,供标签碰撞避让使用。
1400
2547
  projectCesiumPoint(e) {
1401
- var r, n;
2548
+ var s, i;
1402
2549
  if (!this.isCesiumPointVisible(e))
1403
2550
  return null;
1404
- const t = (n = (r = this.mapCore) == null ? void 0 : r.projectToContainerPoint) == null ? void 0 : n.call(r, {
2551
+ const r = (i = (s = this.mapCore) == null ? void 0 : s.projectToContainerPoint) == null ? void 0 : i.call(s, {
1405
2552
  latitude: e[0],
1406
2553
  longitude: e[1]
1407
2554
  });
1408
- if (!(t != null && t.success))
2555
+ if (!(r != null && r.success))
1409
2556
  return null;
1410
- const s = w.point(t.data.x, t.data.y);
1411
- return this.isCesiumScreenPointInViewport(s) ? s : null;
2557
+ const n = B.point(r.data.x, r.data.y);
2558
+ return this.isCesiumScreenPointInViewport(n) ? n : null;
1412
2559
  }
1413
2560
  // Cesium 添加单个标签,中心点标签和线值标签共用该方法。
1414
- addCesiumLabel(e, t, s = {}) {
1415
- const r = N(), n = this.ensureCesiumLabelCollection();
1416
- return !n || !r || !this.isCesiumPointVisible(e) ? null : n.add({
2561
+ addCesiumLabel(e, r, n = {}) {
2562
+ const s = _(), i = this.ensureCesiumLabelCollection();
2563
+ return !i || !s || !this.isCesiumPointVisible(e) ? null : i.add({
1417
2564
  position: this.createCesiumPosition(e),
1418
- text: t,
1419
- font: s.font || "12px Arial",
1420
- fillColor: s.fillColor || r.Color.fromCssColorString("#244349"),
1421
- outlineColor: r.Color.fromCssColorString("rgba(255,255,255,0.72)"),
1422
- outlineWidth: s.outlineWidth ?? 2,
1423
- style: r.LabelStyle.FILL_AND_OUTLINE,
1424
- showBackground: s.showBackground !== !1,
1425
- backgroundColor: s.backgroundColor || r.Color.fromCssColorString("rgba(246,251,231,0.92)"),
1426
- backgroundPadding: s.backgroundPadding || new r.Cartesian2(7, 4),
1427
- horizontalOrigin: r.HorizontalOrigin.CENTER,
1428
- verticalOrigin: r.VerticalOrigin.CENTER,
1429
- disableDepthTestDistance: s.disableDepthTestDistance ?? 0,
1430
- 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
1431
2578
  });
1432
2579
  }
1433
2580
  // Cesium H/L 中心点标注,先做屏幕碰撞检测再绘制。
1434
- addCesiumCenters(e, t) {
1435
- const s = N();
1436
- if (!s)
2581
+ addCesiumCenters(e, r) {
2582
+ const n = _();
2583
+ if (!n)
1437
2584
  return 0;
1438
- let r = 0;
1439
- return e.centers.forEach((n) => {
1440
- this.cesiumWorldCopyOffsets.forEach((a) => {
1441
- const o = [n.lat, n.lon + a], l = this.projectCesiumPoint(o);
2585
+ let s = 0;
2586
+ return e.centers.forEach((i) => {
2587
+ this.cesiumWorldCopyOffsets.forEach((o) => {
2588
+ const a = [i.lat, i.lon + o], l = this.projectCesiumPoint(a);
1442
2589
  if (!l)
1443
2590
  return;
1444
- const u = W(l, 18, 20);
1445
- j(t, u) || (t.push(u), this.addCesiumLabel(o, `${n.type}
1446
- ${n.value}`, {
2591
+ const u = ae(l, 18, 20);
2592
+ oe(r, u) || (r.push(u), this.addCesiumLabel(a, `${i.type}
2593
+ ${i.value}`, {
1447
2594
  font: "700 18px Arial",
1448
- fillColor: s.Color.fromCssColorString(n.type === "H" ? "#efb7ff" : "#e3f8ff"),
1449
- backgroundColor: s.Color.TRANSPARENT,
2595
+ fillColor: n.Color.fromCssColorString(i.type === "H" ? "#efb7ff" : "#e3f8ff"),
2596
+ backgroundColor: n.Color.TRANSPARENT,
1450
2597
  showBackground: !1,
1451
2598
  outlineWidth: 3
1452
- }), r += 1);
2599
+ }), s += 1);
1453
2600
  });
1454
- }), r;
2601
+ }), s;
1455
2602
  }
1456
2603
  // Leaflet H/L 中心点标注,按当前视野过滤后再做碰撞检测。
1457
- addLeafletCenters(e, t) {
1458
- var a, o, l, u;
1459
- const s = (o = (a = this.mapCore) == null ? void 0 : a.getMapInstance) == null ? void 0 : o.call(a), r = (u = (l = s == null ? void 0 : s.getBounds) == null ? void 0 : l.call(s)) == null ? void 0 : u.pad(0.2);
1460
- if (!s || !r || !this.labelLayerGroup)
2604
+ addLeafletCenters(e, r) {
2605
+ var o, a, l, u;
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)
1461
2608
  return 0;
1462
- let n = 0;
1463
- return e.centers.forEach((h) => {
1464
- this.worldCopyOffsets.forEach((I) => {
1465
- const d = [h.lat, h.lon + I];
1466
- if (!r.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))
1467
2614
  return;
1468
- const f = s.latLngToContainerPoint(d), g = W(f, 16, 18);
1469
- j(t, g) || (t.push(g), w.marker(d, {
2615
+ const f = n.latLngToContainerPoint(h), y = ae(f, 16, 18);
2616
+ oe(r, y) || (r.push(y), B.marker(h, {
1470
2617
  interactive: !1,
1471
2618
  keyboard: !1,
1472
- icon: be(h),
2619
+ icon: Qt(c),
1473
2620
  zIndexOffset: 140
1474
- }).addTo(this.labelLayerGroup), n += 1);
2621
+ }).addTo(this.labelLayerGroup), i += 1);
1475
2622
  });
1476
- }), n;
2623
+ }), i;
1477
2624
  }
1478
2625
  // 线值标签统一从折线中采样候选点,再按离视野中心的距离排序。
1479
- getLineLabelCandidates(e, t = {}) {
1480
- const { bounds: s, useSegmentMidpoint: r = !1, viewCenter: n, projectPoint: a } = t, o = [], 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);
1481
2628
  for (let u = 0; u < e.length - 1; u += l) {
1482
- const h = e[u], I = e[Math.min(u + l, e.length - 1)], d = [
1483
- (h[0] + I[0]) / 2,
1484
- (h[1] + I[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
1485
2632
  ];
1486
- if (s && !s.contains(d))
2633
+ if (n && !n.contains(h))
1487
2634
  continue;
1488
- const f = a(h), g = a(I), m = a(d);
1489
- if (!f || !g || !m)
2635
+ const f = o(c), y = o(d), I = o(h);
2636
+ if (!f || !y || !I)
1490
2637
  continue;
1491
- const p = r ? w.point((f.x + g.x) / 2, (f.y + g.y) / 2) : m;
1492
- o.push({
1493
- position: d,
1494
- point: p,
1495
- angle: Math.atan2(g.y - f.y, g.x - f.x) * 180 / Math.PI,
1496
- score: p.distanceTo(n)
2638
+ const g = s ? B.point((f.x + y.x) / 2, (f.y + y.y) / 2) : I;
2639
+ a.push({
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)
1497
2644
  });
1498
2645
  }
1499
- return o;
2646
+ return a;
1500
2647
  }
1501
2648
  // Leaflet 线值标签:每条线选择靠近视野中心且不碰撞的位置。
1502
- addLeafletLineLabels(e, t) {
1503
- var o, l, u, h;
1504
- const s = (l = (o = this.mapCore) == null ? void 0 : o.getMapInstance) == null ? void 0 : l.call(o), r = (h = (u = s == null ? void 0 : s.getBounds) == null ? void 0 : u.call(s)) == null ? void 0 : h.pad(0.15);
1505
- if (!s || !r || !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)
1506
2653
  return 0;
1507
- const n = s.getSize().divideBy(2);
1508
- let a = 0;
1509
- return e.isolines.forEach((I) => {
1510
- this.worldCopyOffsets.forEach((d) => {
1511
- I.lines.forEach((f) => {
1512
- const g = J(f, d), m = X(this.getLineLabelCandidates(g, {
1513
- bounds: r,
2654
+ const i = n.getSize().divideBy(2);
2655
+ let o = 0;
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,
1514
2661
  useSegmentMidpoint: !0,
1515
- viewCenter: n,
1516
- projectPoint: (p) => s.latLngToContainerPoint(p)
1517
- }), t);
1518
- m && (w.marker(m.position, {
2662
+ viewCenter: i,
2663
+ projectPoint: (g) => n.latLngToContainerPoint(g)
2664
+ }), r);
2665
+ I && (B.marker(I.position, {
1519
2666
  interactive: !1,
1520
2667
  keyboard: !1,
1521
- icon: me(I.hpa, m.angle),
2668
+ icon: Jt(d.hpa, I.angle),
1522
2669
  zIndexOffset: 120
1523
- }).addTo(this.labelLayerGroup), a += 1);
2670
+ }).addTo(this.labelLayerGroup), o += 1);
1524
2671
  });
1525
2672
  });
1526
- }), a;
2673
+ }), o;
1527
2674
  }
1528
2675
  // Cesium 线值标签:先将候选点投影到屏幕,再按距离和碰撞筛选。
1529
- addCesiumLineLabels(e, t) {
1530
- let s = 0;
1531
- const r = document.getElementById(this.mapContainerId), n = w.point(((r == null ? void 0 : r.clientWidth) || 0) / 2, ((r == null ? void 0 : r.clientHeight) || 0) / 2);
1532
- return e.isolines.forEach((a) => {
1533
- this.cesiumWorldCopyOffsets.forEach((o) => {
1534
- a.lines.forEach((l) => {
1535
- const u = pe(J(l, o), this.cesiumLineThinStep), h = X(this.getLineLabelCandidates(u, {
1536
- viewCenter: n,
1537
- projectPoint: (I) => this.projectCesiumPoint(I)
1538
- }), t);
1539
- h && (this.addCesiumLabel(h.position, String(a.hpa), {
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);
2679
+ return e.isolines.forEach((o) => {
2680
+ this.cesiumWorldCopyOffsets.forEach((a) => {
2681
+ o.lines.forEach((l) => {
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), {
1540
2687
  font: "12px Arial"
1541
- }), s += 1);
2688
+ }), n += 1);
1542
2689
  });
1543
2690
  });
1544
- }), s;
2691
+ }), n;
1545
2692
  }
1546
2693
  // 重建 Cesium 全部标签,并请求场景刷新。
1547
2694
  updateCesiumLabels() {
1548
- var o, l, u, h, I, d, f, g, m;
1549
- const e = (l = (o = this.mapCore) == null ? void 0 : o.getMapInstance) == null ? void 0 : l.call(o), t = (u = this.getData) == null ? void 0 : u.call(this);
1550
- 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)
1551
2698
  return this.clear(), 0;
1552
- const s = this.cesiumLabelCollection;
2699
+ const n = this.cesiumLabelCollection;
1553
2700
  this.cesiumLabelCollection = null;
1554
- const r = this.ensureCesiumLabelCollection();
1555
- if (!r)
1556
- return this.cesiumLabelCollection = s, 0;
1557
- const n = [];
1558
- let a = 0;
2701
+ const s = this.ensureCesiumLabelCollection();
2702
+ if (!s)
2703
+ return this.cesiumLabelCollection = n, 0;
2704
+ const i = [];
2705
+ let o = 0;
1559
2706
  try {
1560
- a = this.addCesiumCenters(t, n) + this.addCesiumLineLabels(t, n), s && s !== r && ((h = e == null ? void 0 : e.scene) != null && h.primitives) && e.scene.primitives.remove(s);
1561
- } catch (p) {
1562
- throw (f = (d = (I = e == null ? void 0 : e.scene) == null ? void 0 : I.primitives) == null ? void 0 : d.remove) == null || f.call(d, r), 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;
1563
2710
  }
1564
- return this.emitStateChange(a), (m = (g = e == null ? void 0 : e.scene) == null ? void 0 : g.requestRender) == null || m.call(g), a;
2711
+ return this.emitStateChange(o), (I = (y = e == null ? void 0 : e.scene) == null ? void 0 : y.requestRender) == null || I.call(y), o;
1565
2712
  }
1566
2713
  // 重建 Leaflet 全部标签和 marker。
1567
2714
  updateLeafletLabels() {
1568
- var o, l, u;
1569
- const e = (o = this.getData) == null ? void 0 : o.call(this), t = (u = (l = this.mapCore) == null ? void 0 : l.getMapInstance) == null ? void 0 : u.call(l);
1570
- if (!e || !t || !this.labelLayerGroup)
2715
+ var a, l, u;
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)
1571
2718
  return this.clear(), 0;
1572
- const s = this.labelLayerGroup, r = w.layerGroup();
1573
- this.labelLayerGroup = r;
1574
- const n = [];
1575
- let a = 0;
2719
+ const n = this.labelLayerGroup, s = B.layerGroup();
2720
+ this.labelLayerGroup = s;
2721
+ const i = [];
2722
+ let o = 0;
1576
2723
  try {
1577
- a = this.addLeafletCenters(e, n) + this.addLeafletLineLabels(e, n), r.addTo(t), s == null || s.remove();
1578
- } catch (h) {
1579
- throw r.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;
1580
2727
  }
1581
- return this.emitStateChange(a), a;
2728
+ return this.emitStateChange(o), o;
1582
2729
  }
1583
2730
  }
1584
- class Ue {
2731
+ class wr {
1585
2732
  /**
1586
2733
  * @param {Object} options 等压线组合图层参数。
1587
2734
  * @param {Object} options.mapCore 必填,BaseGIS 实例,线图层和标注层都通过它访问当前地图引擎。
@@ -1605,7 +2752,7 @@ class Ue {
1605
2752
  * @param {Function} [options.onAnnotationStateChange] 标注状态变化回调,返回 labelCount。
1606
2753
  */
1607
2754
  constructor(e = {}) {
1608
- this.mapCore = e.mapCore, this.currentData = $(e.data || e.sourceData || {}), this.contourController = new oe({
2755
+ this.mapCore = e.mapCore, this.currentData = le(e.data || e.sourceData || {}), this.contourController = new Re({
1609
2756
  mapCore: e.mapCore,
1610
2757
  layerId: e.layerId || "pressure-contour",
1611
2758
  color: e.color || "rgba(255,255,255,0.82)",
@@ -1618,7 +2765,7 @@ class Ue {
1618
2765
  worldCopyOffsets: e.worldCopyOffsets || [-360, 0, 360],
1619
2766
  lineThinStep: e.lineThinStep || 1,
1620
2767
  onStateChange: e.onContourStateChange
1621
- }), this.annotationLayer = new Ge({
2768
+ }), this.annotationLayer = new or({
1622
2769
  mapCore: e.mapCore,
1623
2770
  mapContainerId: e.mapContainerId,
1624
2771
  getData: () => this.currentData,
@@ -1632,22 +2779,22 @@ class Ue {
1632
2779
  mount() {
1633
2780
  this.annotationLayer.mount();
1634
2781
  }
1635
- buildPayload(e, t = {}) {
1636
- return this.currentData = $(e), {
2782
+ buildPayload(e, r = {}) {
2783
+ return this.currentData = le(e), {
1637
2784
  isolines: this.currentData.isolines || [],
1638
- visible: t.visible !== !1,
1639
- ...t
2785
+ visible: r.visible !== !1,
2786
+ ...r
1640
2787
  };
1641
2788
  }
1642
- async load(e, t = {}) {
2789
+ async load(e, r = {}) {
1643
2790
  this.annotationLayer.clear();
1644
- const s = await this.contourController.load(this.buildPayload(e, t));
1645
- return s != null && s.success && this.annotationLayer.update(), s;
1646
- }
1647
- async update(e, t = {}) {
1648
- const s = this.buildPayload(e, t), n = !!this.contourController.getState().payload ? await this.contourController.update(s) : await this.contourController.load(s);
2791
+ const n = await this.contourController.load(this.buildPayload(e, r));
1649
2792
  return n != null && n.success && this.annotationLayer.update(), n;
1650
2793
  }
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;
2797
+ }
1651
2798
  hide() {
1652
2799
  const e = this.contourController.hide();
1653
2800
  return this.annotationLayer.clear(), e;
@@ -1668,7 +2815,7 @@ class Ue {
1668
2815
  this.annotationLayer.destroy(), this.contourController.destroy();
1669
2816
  }
1670
2817
  }
1671
- class V {
2818
+ class Q {
1672
2819
  constructor(e = {}) {
1673
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();
1674
2821
  }
@@ -1677,15 +2824,15 @@ class V {
1677
2824
  this.errorMessage = "Wind field Bound must contain at least 6 values.";
1678
2825
  return;
1679
2826
  }
1680
- const [e, t, s, r, n, a, o = 1] = this.bound, l = Number(s) * Number(r) * 2;
1681
- if (!Number.isFinite(Number(e)) || !Number.isFinite(Number(t)) || Number(s) < 2 || Number(r) < 2 || Number(n) <= 0 || Number(a) <= 0 || this.data.length !== l) {
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) {
1682
2829
  this.errorMessage = `Invalid wind field data. Expected DataAry length ${l}, got ${this.data.length}.`;
1683
2830
  return;
1684
2831
  }
1685
- this.lonMin = Number(e), this.latMin = Number(t), this.lonCount = Number(s), this.latCount = Number(r), this.lonSpan = Number(n), this.latSpan = Number(a), this.valueScale = Number(o) || 1, this.lonMax = this.lonMin + this.lonSpan, this.latMax = this.latMin + this.latSpan, this.lonStep = this.lonSpan / (this.lonCount - 1), this.latStep = this.latSpan / (this.latCount - 1), this.valid = !0;
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;
1686
2833
  }
1687
- contains(e, t) {
1688
- 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;
1689
2836
  }
1690
2837
  getBounds() {
1691
2838
  return {
@@ -1701,11 +2848,11 @@ class V {
1701
2848
  lat: this.latMin + this.latSpan / 2
1702
2849
  };
1703
2850
  }
1704
- getVector(e, t) {
1705
- const s = (e * this.lonCount + t) * 2;
2851
+ getVector(e, r) {
2852
+ const n = (e * this.lonCount + r) * 2;
1706
2853
  return {
1707
- u: Number(this.data[s]) / this.valueScale,
1708
- 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
1709
2856
  };
1710
2857
  }
1711
2858
  /**
@@ -1713,18 +2860,18 @@ class V {
1713
2860
  *
1714
2861
  * 数据约定为从左下角开始平铺,因此 row 直接对应从南到北的纬度索引。
1715
2862
  */
1716
- sample(e, t) {
1717
- if (!this.valid || !this.contains(e, t))
2863
+ sample(e, r) {
2864
+ if (!this.valid || !this.contains(e, r))
1718
2865
  return null;
1719
- const s = (e - this.lonMin) / this.lonStep, r = (t - this.latMin) / this.latStep, n = Math.max(0, Math.min(Math.floor(s), this.lonCount - 2)), a = Math.max(0, Math.min(Math.floor(r), this.latCount - 2)), o = n + 1, l = a + 1, u = Math.max(0, Math.min(s - n, 1)), h = Math.max(0, Math.min(r - a, 1)), I = this.getVector(a, n), d = this.getVector(a, o), f = this.getVector(l, n), g = this.getVector(l, o), m = 1 - u, p = 1 - h, v = m * p, C = u * p, L = m * h, A = u * h, T = I.u * v + d.u * C + f.u * L + g.u * A, M = I.v * v + d.v * C + f.v * L + g.v * A;
1720
- return !Number.isFinite(T) || !Number.isFinite(M) ? null : {
1721
- u: T,
1722
- v: M,
1723
- speed: Math.hypot(T, M)
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)
1724
2871
  };
1725
2872
  }
1726
2873
  }
1727
- const ee = [
2874
+ const xe = [
1728
2875
  { value: 0, color: [36, 88, 190] },
1729
2876
  { value: 2, color: [36, 145, 184] },
1730
2877
  { value: 5, color: [54, 177, 111] },
@@ -1732,7 +2879,7 @@ const ee = [
1732
2879
  { value: 11, color: [229, 178, 78] },
1733
2880
  { value: 14, color: [224, 103, 117] },
1734
2881
  { value: 18, color: [162, 82, 202] }
1735
- ], te = [
2882
+ ], Ne = [
1736
2883
  { value: 0, color: [178, 223, 255] },
1737
2884
  { value: 3, color: [190, 248, 222] },
1738
2885
  { value: 6, color: [235, 252, 174] },
@@ -1740,86 +2887,86 @@ const ee = [
1740
2887
  { value: 14, color: [255, 166, 156] },
1741
2888
  { value: 18, color: [232, 153, 255] }
1742
2889
  ];
1743
- function b(i, e, t) {
1744
- return Math.min(Math.max(i, e), t);
2890
+ function P(t, e, r) {
2891
+ return Math.min(Math.max(t, e), r);
1745
2892
  }
1746
- function we(i) {
1747
- if (Array.isArray(i) && i.length >= 3)
1748
- return [Number(i[0]) || 0, Number(i[1]) || 0, Number(i[2]) || 0];
1749
- 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")
1750
2897
  return null;
1751
- const e = i.trim().replace("#", "");
2898
+ const e = t.trim().replace("#", "");
1752
2899
  if (/^[0-9a-f]{6}$/i.test(e))
1753
2900
  return [
1754
2901
  parseInt(e.slice(0, 2), 16),
1755
2902
  parseInt(e.slice(2, 4), 16),
1756
2903
  parseInt(e.slice(4, 6), 16)
1757
2904
  ];
1758
- const t = i.match(/rgba?\(([^)]+)\)/i);
1759
- if (!t)
2905
+ const r = t.match(/rgba?\(([^)]+)\)/i);
2906
+ if (!r)
1760
2907
  return null;
1761
- const s = t[1].split(",").map((r) => Number(r.trim()));
1762
- return s.length < 3 || s.slice(0, 3).some((r) => !Number.isFinite(r)) ? null : s.slice(0, 3);
1763
- }
1764
- function E(i, e) {
1765
- const s = (Array.isArray(i) && i.length > 0 ? i : e).map((r, n) => {
1766
- const a = Number((r == null ? void 0 : r.value) ?? (r == null ? void 0 : r.speed) ?? (r == null ? void 0 : r[0]) ?? n), o = we((r == null ? void 0 : r.color) ?? (r == null ? void 0 : r[1]) ?? r);
1767
- return !Number.isFinite(a) || !o ? null : { value: a, color: o };
1768
- }).filter(Boolean).sort((r, n) => r.value - n.value);
1769
- return s.length > 0 ? s : e;
1770
- }
1771
- function Te(i, e) {
1772
- if (!Array.isArray(i) || i.length === 0)
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);
2910
+ }
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);
2914
+ return !Number.isFinite(o) || !a ? null : { value: o, color: a };
2915
+ }).filter(Boolean).sort((s, i) => s.value - i.value);
2916
+ return n.length > 0 ? n : e;
2917
+ }
2918
+ function lr(t, e) {
2919
+ if (!Array.isArray(t) || t.length === 0)
1773
2920
  return [255, 255, 255];
1774
- if (e <= i[0].value)
1775
- return i[0].color;
1776
- for (let t = 1; t < i.length; t += 1) {
1777
- const s = i[t], r = i[t - 1];
1778
- if (e <= s.value) {
1779
- const n = Math.max(s.value - r.value, 1e-4), a = b((e - r.value) / n, 0, 1);
1780
- return r.color.map(
1781
- (o, l) => Math.round(o + (s.color[l] - o) * a)
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)
1782
2929
  );
1783
2930
  }
1784
2931
  }
1785
- return i[i.length - 1].color;
2932
+ return t[t.length - 1].color;
1786
2933
  }
1787
- function z(i, e) {
1788
- const [t, s, r] = i;
1789
- return `rgba(${t}, ${s}, ${r}, ${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)})`;
1790
2937
  }
1791
- function Me(i, e) {
1792
- if (!i || typeof i != "object")
2938
+ function ur(t, e) {
2939
+ if (!t || typeof t != "object")
1793
2940
  return e;
1794
- const t = Number(i.west), s = Number(i.south), r = Number(i.east), n = Number(i.north);
1795
- return [t, s, r, n].every(Number.isFinite) ? {
1796
- west: Math.min(t, r),
1797
- south: Math.min(s, n),
1798
- east: Math.max(t, r),
1799
- north: Math.max(s, n)
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)
1800
2947
  } : e;
1801
2948
  }
1802
- function xe(i, e) {
1803
- const t = {
1804
- west: Math.max(i.west, e.west),
1805
- south: Math.max(i.south, e.south),
1806
- east: Math.min(i.east, e.east),
1807
- 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)
1808
2955
  };
1809
- return t.west >= t.east || t.south >= t.north ? null : t;
2956
+ return r.west >= r.east || r.south >= r.north ? null : r;
1810
2957
  }
1811
- function _(i, e, t) {
1812
- 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;
1813
2960
  }
1814
- function Ae(i) {
1815
- 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);
1816
2963
  }
1817
- function Ne(i) {
1818
- return String(i || "").toLowerCase();
2964
+ function dr(t) {
2965
+ return String(t || "").toLowerCase();
1819
2966
  }
1820
- class Oe {
2967
+ class fr {
1821
2968
  constructor(e = {}) {
1822
- this.id = e.id || "wind-field-default", this.container = e.container || null, this.project = typeof e.project == "function" ? e.project : null, this.getViewBounds = typeof e.getViewBounds == "function" ? e.getViewBounds : null, this.getSceneMode = typeof e.getSceneMode == "function" ? e.getSceneMode : null, this.grid = e.grid instanceof V ? e.grid : new V(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 = {
1823
2970
  zIndex: Number(e.zIndex ?? 30),
1824
2971
  visible: e.visible !== !1,
1825
2972
  running: e.running !== !1,
@@ -1844,17 +2991,17 @@ class Oe {
1844
2991
  projectionGrid: e.projectionGrid !== !1,
1845
2992
  projectionGridCols: Number(e.projectionGridCols ?? 32),
1846
2993
  projectionGridRows: Number(e.projectionGridRows ?? 20)
1847
- }, this.colorScale = E(e.colorScale, ee), this.particleColorScale = E(
2994
+ }, this.colorScale = H(e.colorScale, xe), this.particleColorScale = H(
1848
2995
  e.particleColorScale,
1849
- te
2996
+ Ne
1850
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();
1851
2998
  }
1852
2999
  isReady() {
1853
3000
  return !!(this.container && this.project && this.grid.valid);
1854
3001
  }
1855
- createCanvas(e, t) {
1856
- const s = document.createElement("canvas");
1857
- 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;
1858
3005
  }
1859
3006
  mount() {
1860
3007
  if (!this.container || this.canvas)
@@ -1872,12 +3019,12 @@ class Oe {
1872
3019
  resize() {
1873
3020
  if (!this.canvas || !this.overlayCanvas || !this.container)
1874
3021
  return;
1875
- const e = this.container.getBoundingClientRect(), t = b(this.options.devicePixelRatio || 1, 1, 2), s = Math.max(1, Math.floor(e.width)), r = Math.max(1, Math.floor(e.height));
1876
- s === this.width && r === this.height || (this.width = s, this.height = r, [
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, [
1877
3024
  [this.canvas, this.ctx],
1878
3025
  [this.overlayCanvas, this.overlayCtx]
1879
- ].forEach(([n, a]) => {
1880
- n.width = Math.floor(s * t), n.height = Math.floor(r * t), a == null || a.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);
1881
3028
  }), this.overlayDirty = !0, this.invalidateProjectionGrid(), this.clear());
1882
3029
  }
1883
3030
  clear() {
@@ -1893,19 +3040,19 @@ class Oe {
1893
3040
  this.options = {
1894
3041
  ...this.options,
1895
3042
  ...e
1896
- }, e.colorScale !== void 0 && (this.colorScale = E(e.colorScale, ee), 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(
1897
3044
  e.particleColorScale,
1898
- te
1899
- )), this.canvas && (this.canvas.style.zIndex = String(this.options.zIndex + 1), this.canvas.style.display = this.options.visible ? "block" : "none"), this.overlayCanvas && (this.overlayCanvas.style.zIndex = String(this.options.zIndex), this.overlayCanvas.style.display = this.options.visible ? "block" : "none"), e.data && (this.grid = new V(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();
1900
3047
  }
1901
3048
  refreshSpawnBounds() {
1902
3049
  return this.spawnBoundsCache = this.getSpawnBounds(), this.invalidateProjectionGrid(), this.spawnBoundsCache;
1903
3050
  }
1904
3051
  shouldUseProjectionGrid() {
1905
- var t;
3052
+ var r;
1906
3053
  if (!this.options.projectionGrid)
1907
3054
  return !1;
1908
- const e = Ne((t = this.getSceneMode) == null ? void 0 : t.call(this));
3055
+ const e = dr((r = this.getSceneMode) == null ? void 0 : r.call(this));
1909
3056
  return e === "2d" || e === "2.5d";
1910
3057
  }
1911
3058
  invalidateProjectionGrid() {
@@ -1914,36 +3061,36 @@ class Oe {
1914
3061
  buildProjectionGrid(e = this.spawnBoundsCache) {
1915
3062
  if (!this.shouldUseProjectionGrid() || !e)
1916
3063
  return this.projectionGrid = null, null;
1917
- const t = b(Math.floor(this.options.projectionGridCols) || 32, 8, 96), s = b(Math.floor(this.options.projectionGridRows) || 20, 6, 64), r = [];
1918
- for (let n = 0; n <= s; n += 1)
1919
- for (let a = 0; a <= t; a += 1) {
1920
- const o = e.west + (e.east - e.west) * (a / t), l = e.south + (e.north - e.south) * (n / s);
1921
- r.push(this.project(o, 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));
1922
3069
  }
1923
3070
  return this.projectionGrid = {
1924
3071
  bounds: e,
1925
- cols: t,
1926
- rows: s,
1927
- nodes: r
3072
+ cols: r,
3073
+ rows: n,
3074
+ nodes: s
1928
3075
  }, this.projectionGrid;
1929
3076
  }
1930
- projectPoint(e, t) {
1931
- const s = this.projectionGrid || this.buildProjectionGrid(this.spawnBoundsCache);
1932
- if (!s || !s.bounds)
1933
- return this.project(e, t, this.options.height);
1934
- const { bounds: r, cols: n, rows: a, nodes: o } = s, l = Math.max(r.east - r.west, 1e-4), u = Math.max(r.north - r.south, 1e-4), h = (e - r.west) / l * n, I = (t - r.south) / u * a, d = b(Math.floor(h), 0, n - 1), f = b(Math.floor(I), 0, a - 1), g = d + 1, m = f + 1, p = b(h - d, 0, 1), v = b(I - f, 0, 1), C = n + 1, L = o[f * C + d], A = o[f * C + g], T = o[m * C + d], M = o[m * C + g];
1935
- if (![L, A, T, M].every(Ae))
1936
- return this.project(e, t, this.options.height);
1937
- 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;
1938
3085
  return {
1939
- x: L.x * R * F + A.x * p * F + T.x * R * v + M.x * p * v,
1940
- y: L.y * R * F + A.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
1941
3088
  };
1942
3089
  }
1943
3090
  getSpawnBounds() {
1944
- var s;
1945
- const e = this.grid.getBounds(), t = Me((s = this.getViewBounds) == null ? void 0 : s.call(this), e);
1946
- return xe(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;
1947
3094
  }
1948
3095
  createParticle(e = this.spawnBoundsCache || this.refreshSpawnBounds()) {
1949
3096
  if (!e)
@@ -1953,12 +3100,12 @@ class Oe {
1953
3100
  age: this.options.maxAge,
1954
3101
  maxAge: this.options.maxAge
1955
3102
  };
1956
- for (let t = 0; t < 8; t += 1) {
1957
- const s = e.west + Math.random() * (e.east - e.west), r = e.south + Math.random() * (e.north - e.south), n = this.grid.sample(s, r);
1958
- if (n && n.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)
1959
3106
  return {
1960
- lon: s,
1961
- lat: r,
3107
+ lon: n,
3108
+ lat: s,
1962
3109
  screenX: null,
1963
3110
  screenY: null,
1964
3111
  age: Math.floor(Math.random() * this.options.maxAge),
@@ -1983,16 +3130,16 @@ class Oe {
1983
3130
  if (!this.isReady())
1984
3131
  return;
1985
3132
  this.clear();
1986
- const e = b(Math.floor(this.options.particleCount), 1, 8e3), t = this.refreshSpawnBounds();
1987
- 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();
1988
3135
  }
1989
3136
  getParticleColorIndex(e) {
1990
3137
  if (!Array.isArray(this.particleColorScale) || this.particleColorScale.length <= 1)
1991
3138
  return 0;
1992
- for (let t = 1; t < this.particleColorScale.length; t += 1) {
1993
- const s = this.particleColorScale[t - 1], r = this.particleColorScale[t], n = s.value + (r.value - s.value) / 2;
1994
- if (e <= n)
1995
- 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;
1996
3143
  }
1997
3144
  return this.particleColorScale.length - 1;
1998
3145
  }
@@ -2002,32 +3149,32 @@ class Oe {
2002
3149
  const e = this.spawnBoundsCache || this.refreshSpawnBounds();
2003
3150
  if (!e)
2004
3151
  return;
2005
- const t = this.overlayCtx, s = b(Number(this.options.velocityOverlayCellSize) || 54, 28, 96), r = b(Math.ceil(this.width / s), 10, 64), n = b(Math.ceil(this.height / s), 8, 48), a = (e.east - e.west) / r, o = (e.north - e.south) / n, l = s * 1.25, u = this.grid.getBounds();
2006
- t.save(), t.globalCompositeOperation = "source-over";
2007
- for (let h = 0; h < n; h += 1) {
2008
- const I = e.south + (h + 0.5) * o;
2009
- for (let d = 0; d < r; d += 1) {
2010
- const f = e.west + (d + 0.5) * a, g = this.grid.sample(f, I);
2011
- if (!g || g.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)
2012
3159
  continue;
2013
- const m = this.projectPoint(f, I);
2014
- if (!_(m, this.width, this.height))
3160
+ const I = this.projectPoint(f, d);
3161
+ if (!te(I, this.width, this.height))
2015
3162
  continue;
2016
- const p = Te(this.colorScale, g.speed), v = this.getDataEdgeOpacity(f, I, u), C = this.options.velocityOverlayOpacity * v;
2017
- 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)
2018
3165
  continue;
2019
- const L = t.createRadialGradient(m.x, m.y, 0, m.x, m.y, l);
2020
- L.addColorStop(0, z(p, C)), L.addColorStop(1, z(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);
2021
3168
  }
2022
3169
  }
2023
- t.restore();
3170
+ r.restore();
2024
3171
  }
2025
- getDataEdgeOpacity(e, t, s) {
2026
- const r = b(this.options.velocityOverlayEdgeFade, 0, 0.35);
2027
- if (r <= 0 || !s)
3172
+ getDataEdgeOpacity(e, r, n) {
3173
+ const s = P(this.options.velocityOverlayEdgeFade, 0, 0.35);
3174
+ if (s <= 0 || !n)
2028
3175
  return 1;
2029
- const n = (e - s.west) / Math.max(s.east - s.west, 1e-4), a = (t - s.south) / Math.max(s.north - s.south, 1e-4), o = Math.min(n, 1 - n, a, 1 - a);
2030
- return b(o / r, 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);
2031
3178
  }
2032
3179
  start() {
2033
3180
  this.destroyed || (this.options.running = !0, this.interactionSuspended = !1, this.animationFrame || (this.lastFrameTime = performance.now(), this.animationFrame = requestAnimationFrame((e) => this.animate(e))));
@@ -2055,51 +3202,51 @@ class Oe {
2055
3202
  hide() {
2056
3203
  this.options.visible = !1, this.canvas && (this.canvas.style.display = "none"), this.overlayCanvas && (this.overlayCanvas.style.display = "none");
2057
3204
  }
2058
- stepParticle(e, t) {
2059
- const s = this.grid.sample(e.lon, e.lat), r = Number.isFinite(e.screenX) && Number.isFinite(e.screenY) ? { x: e.screenX, y: e.screenY } : this.projectPoint(e.lon, e.lat);
2060
- if (!s || s.speed <= 0 || !_(r, 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))
2061
3208
  return Object.assign(e, this.createParticle()), null;
2062
- const n = e.lat * Math.PI / 180, a = Math.max(Math.cos(n) * 111320, 1e3), o = 111320, l = this.options.velocityScale * t, u = e.lon + s.u * l / a, h = e.lat + s.v * l / o, I = this.grid.sample(u, h), d = this.projectPoint(u, h);
2063
- return !I || !_(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: r, to: d, speed: I.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 });
2064
3211
  }
2065
3212
  getFrameParticleCount(e) {
2066
- var n;
2067
- const t = b(
3213
+ var i;
3214
+ const r = P(
2068
3215
  Math.floor(this.options.maxFrameParticles || e),
2069
3216
  1,
2070
3217
  e
2071
- ), s = Math.floor(this.options.sceneModeMaxFrameParticles || 0), r = String(((n = this.getSceneMode) == null ? void 0 : n.call(this)) || "").toLowerCase();
2072
- return (r === "2d" || r === "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;
2073
3220
  }
2074
3221
  drawFrame(e) {
2075
3222
  if (!this.ctx || this.width <= 0 || this.height <= 0)
2076
3223
  return;
2077
- const t = this.ctx;
2078
- 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";
2079
- const s = this.particleColorScale.map(() => []), r = this.particles.length, n = this.getFrameParticleCount(r);
2080
- for (let a = 0; a < n; a += 1) {
2081
- const o = (this.particleCursor + a) % r, l = this.stepParticle(this.particles[o], e);
2082
- 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);
2083
3230
  }
2084
- this.particleCursor = (this.particleCursor + n) % r, s.forEach((a, o) => {
2085
- if (a.length === 0)
3231
+ this.particleCursor = (this.particleCursor + i) % s, n.forEach((o, a) => {
3232
+ if (o.length === 0)
2086
3233
  return;
2087
- const l = this.particleColorScale.length <= 1 ? 0 : o / (this.particleColorScale.length - 1);
2088
- t.lineWidth = this.options.lineWidth * (0.72 + l * 0.56), t.strokeStyle = this.particleColorScale[o] ? z(this.particleColorScale[o].color, this.options.particleOpacity) : this.options.color, t.beginPath(), a.forEach((u) => {
2089
- t.moveTo(u.from.x, u.from.y), t.lineTo(u.to.x, u.to.y);
2090
- }), t.stroke();
3234
+ const l = this.particleColorScale.length <= 1 ? 0 : a / (this.particleColorScale.length - 1);
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();
2091
3238
  });
2092
3239
  }
2093
3240
  animate(e) {
2094
3241
  if (this.animationFrame = null, !(this.destroyed || !this.options.running || this.interactionSuspended)) {
2095
3242
  if (this.options.visible && this.isReady()) {
2096
- const t = 1e3 / b(this.options.frameRate, 1, 60), s = e - this.lastFrameTime;
2097
- if (s >= t) {
2098
- const r = b(s / 16.67, 0.5, 2.5);
2099
- this.lastFrameTime = e, this.drawFrame(r);
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);
2100
3247
  }
2101
3248
  }
2102
- this.animationFrame = requestAnimationFrame((t) => this.animate(t));
3249
+ this.animationFrame = requestAnimationFrame((r) => this.animate(r));
2103
3250
  }
2104
3251
  }
2105
3252
  getState() {
@@ -2114,137 +3261,137 @@ class Oe {
2114
3261
  };
2115
3262
  }
2116
3263
  destroy() {
2117
- var e, t;
2118
- this.stop(), this.destroyed = !0, this.clearResumeTimer(), this.resizeObserver && (this.resizeObserver.disconnect(), this.resizeObserver = null), (e = this.canvas) != null && e.parentNode && this.canvas.parentNode.removeChild(this.canvas), (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 = [];
2119
3266
  }
2120
3267
  }
2121
- function x(i = {}) {
2122
- 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";
2123
3270
  }
2124
- function se(i = {}) {
3271
+ function Ae(t = {}) {
2125
3272
  const {
2126
3273
  id: e,
2127
- layerId: t,
2128
- data: s,
2129
- windData: r,
2130
- options: n,
2131
- container: a,
2132
- project: o,
3274
+ layerId: r,
3275
+ data: n,
3276
+ windData: s,
3277
+ options: i,
3278
+ container: o,
3279
+ project: a,
2133
3280
  getViewBounds: l,
2134
3281
  ...u
2135
- } = i || {};
3282
+ } = t || {};
2136
3283
  return {
2137
3284
  ...u,
2138
- ...n || {}
3285
+ ...i || {}
2139
3286
  };
2140
3287
  }
2141
- function ie(i) {
2142
- 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");
2143
3290
  }
2144
- class je {
3291
+ class Pr {
2145
3292
  constructor(e = {}) {
2146
3293
  this.baseGIS = null, this.layers = /* @__PURE__ */ new Map();
2147
- const t = (e == null ? void 0 : e.mapCore) || (e == null ? void 0 : e.baseGIS) || (ie(e) ? e : null);
2148
- 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);
2149
3296
  }
2150
3297
  mount(e) {
2151
- var t, s;
2152
- return ie(e) ? (this.baseGIS = e, y(
2153
- { 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" },
2154
3301
  "WindFieldMethods mounted with BaseGIS."
2155
- )) : c("WindFieldMethods mount requires BaseGIS instance.", "INVALID_MOUNT_TARGET");
3302
+ )) : b("WindFieldMethods mount requires BaseGIS instance.", "INVALID_MOUNT_TARGET");
2156
3303
  }
2157
3304
  resolveBaseGIS() {
2158
- var e, t;
2159
- return this.baseGIS ? (t = (e = this.baseGIS).getMapInstance) != null && t.call(e) ? y(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(
2160
3307
  "Map instance is not ready. Please call mapCore.init() first.",
2161
- G.NOT_INITIALIZED
2162
- ) : c("WindFieldMethods has not been mounted.", "NOT_MOUNTED");
3308
+ R.NOT_INITIALIZED
3309
+ ) : b("WindFieldMethods has not been mounted.", "NOT_MOUNTED");
2163
3310
  }
2164
3311
  addWindField(e = {}) {
2165
3312
  var l, u;
2166
- const t = this.resolveBaseGIS();
2167
- if (!t.success)
2168
- return t;
2169
- const s = (e == null ? void 0 : e.data) || (e == null ? void 0 : e.windData);
2170
- if (!s)
2171
- return c("Wind field data is required.", G.FAILED);
2172
- const r = this.baseGIS.getMapContainer();
2173
- if (!(r != null && r.success) || !((l = r.data) != null && l.container))
2174
- return (r == null ? void 0 : r.success) === !1 ? r : c("Map container is not available.", G.NOT_INITIALIZED);
2175
- const n = x(e);
2176
- this.removeWindField(n);
2177
- const a = new Oe({
2178
- id: n,
2179
- data: s,
2180
- container: r.data.container,
2181
- ...se(e),
2182
- project: (h, I, d = 0) => {
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) => {
2183
3330
  const f = this.baseGIS.projectToContainerPoint({
2184
- longitude: h,
2185
- latitude: I,
2186
- height: d
3331
+ longitude: c,
3332
+ latitude: d,
3333
+ height: h
2187
3334
  });
2188
3335
  return f != null && f.success ? f.data : null;
2189
3336
  },
2190
3337
  getViewBounds: () => {
2191
- const h = this.baseGIS.getViewBounds();
2192
- return h != null && h.success ? h.data : null;
3338
+ const c = this.baseGIS.getViewBounds();
3339
+ return c != null && c.success ? c.data : null;
2193
3340
  },
2194
3341
  getSceneMode: () => {
2195
- var I, d, f;
2196
- const h = (d = (I = this.baseGIS).getSceneMode) == null ? void 0 : d.call(I);
2197
- return h != null && h.success ? (f = h.data) == null ? void 0 : f.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 : "";
2198
3345
  }
2199
3346
  });
2200
- if (!a.grid.valid)
2201
- return a.destroy(), c(a.grid.errorMessage || "Invalid wind field data.", G.FAILED);
2202
- const o = this.baseGIS.onViewChange({
2203
- onStart: () => a.suspendForInteraction(),
2204
- onEnd: () => a.resumeAfterInteraction()
3347
+ if (!o.grid.valid)
3348
+ return o.destroy(), b(o.grid.errorMessage || "Invalid wind field data.", R.FAILED);
3349
+ const a = this.baseGIS.onViewChange({
3350
+ onStart: () => o.suspendForInteraction(),
3351
+ onEnd: () => o.resumeAfterInteraction()
2205
3352
  });
2206
- return o != null && o.success ? (this.layers.set(n, {
2207
- layer: a,
2208
- offViewChange: (u = o.data) == null ? void 0 : u.off
2209
- }), y(a.getState(), `Wind field "${n}" added.`)) : (a.destroy(), o || c("View change listener is not available."));
3353
+ return a != null && a.success ? (this.layers.set(i, {
3354
+ layer: o,
3355
+ offViewChange: (u = a.data) == null ? void 0 : u.off
3356
+ }), S(o.getState(), `Wind field "${i}" added.`)) : (o.destroy(), a || b("View change listener is not available."));
2210
3357
  }
2211
3358
  updateWindField(e = {}) {
2212
- const t = this.resolveBaseGIS();
2213
- if (!t.success)
2214
- return t;
2215
- const s = x(e), r = this.layers.get(s);
2216
- if (!r)
2217
- return c(`Wind field "${s}" not found.`, G.FAILED);
2218
- const n = se(e), a = (e == null ? void 0 : e.data) || (e == null ? void 0 : e.windData);
2219
- return a && (n.data = a), r.layer.updateOptions(n), y(r.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.`);
2220
3367
  }
2221
3368
  startWindField(e = {}) {
2222
- const t = x(e), s = this.layers.get(t);
2223
- return s ? (s.layer.start(), y(s.layer.getState(), `Wind field "${t}" started.`)) : c(`Wind field "${t}" not found.`, G.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);
2224
3371
  }
2225
3372
  stopWindField(e = {}) {
2226
- const t = x(e), s = this.layers.get(t);
2227
- return s ? (s.layer.stop(), y(s.layer.getState(), `Wind field "${t}" stopped.`)) : c(`Wind field "${t}" not found.`, G.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);
2228
3375
  }
2229
3376
  showWindField(e = {}) {
2230
- const t = x(e), s = this.layers.get(t);
2231
- return s ? (s.layer.show(), y(s.layer.getState(), `Wind field "${t}" shown.`)) : c(`Wind field "${t}" not found.`, G.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);
2232
3379
  }
2233
3380
  hideWindField(e = {}) {
2234
- const t = x(e), s = this.layers.get(t);
2235
- return s ? (s.layer.hide(), y(s.layer.getState(), `Wind field "${t}" hidden.`)) : c(`Wind field "${t}" not found.`, G.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);
2236
3383
  }
2237
3384
  removeWindField(e = {}) {
2238
- var r;
2239
- const t = x(e), s = this.layers.get(t);
2240
- return s ? ((r = s.offViewChange) == null || r.call(s), s.layer.destroy(), this.layers.delete(t), y({ layerId: t, removed: !0 }, `Wind field "${t}" removed.`)) : y({ 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.`);
2241
3388
  }
2242
3389
  clearWindFields() {
2243
3390
  const e = this.layers.size;
2244
- return this.layers.forEach((t) => {
2245
- var s;
2246
- (s = t.offViewChange) == null || s.call(t), t.layer.destroy();
2247
- }), this.layers.clear(), y({ 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}.`);
2248
3395
  }
2249
3396
  getState() {
2250
3397
  return {
@@ -2255,14 +3402,16 @@ class je {
2255
3402
  }
2256
3403
  }
2257
3404
  export {
2258
- oe as ContourLayerController,
2259
- Re as GraphicGroupController,
2260
- Fe as GridLayerController,
2261
- Ee as ImageLayerController,
2262
- Ve as PointDensityController,
2263
- ze as PointLargeLayerController,
2264
- Ue as PressureContourLayer,
2265
- je as WindFieldMethods,
2266
- Pe as buildPressureRenderData,
2267
- _e 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
2268
3417
  };