@3clear/basegis 0.1.2 → 0.1.4

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