cesium-xs-sdk 1.0.6 → 1.0.8

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.
@@ -2,6 +2,36 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ /**
6
+ * Cesium 实例提供者
7
+ * 用于解耦 Config 与 getCesium 之间的循环依赖。
8
+ */
9
+ let cesiumInstance = null;
10
+
11
+ /**
12
+ * 设置当前 SDK 使用的 Cesium 实例
13
+ * @param {object} cesium Cesium 库实例
14
+ */
15
+ function setCesiumInstance(cesium) {
16
+ cesiumInstance = cesium;
17
+ }
18
+
19
+ /**
20
+ * 获取当前 SDK 使用的 Cesium 实例
21
+ * @returns {object}
22
+ * @throws {Error} 若未设置 Cesium 实例
23
+ */
24
+ function getCesiumInstance() {
25
+ if (!cesiumInstance) {
26
+ throw new Error(
27
+ 'Cesium 未提供。请在 xs3d.init 时传入 cesium 实例:\n' +
28
+ ' import * as Cesium from "cesium";\n' +
29
+ ' xs3d.init("container", { cesium: Cesium, ... });'
30
+ );
31
+ }
32
+ return cesiumInstance;
33
+ }
34
+
5
35
  /**
6
36
  * 获取通过 xs3d.init({ cesium }) 传入的 Cesium 实例。
7
37
  *
@@ -9,34 +39,22 @@ Object.defineProperty(exports, '__esModule', { value: true });
9
39
  * 避免模块加载时 config 尚未初始化的问题。
10
40
  */
11
41
 
12
- function resolveCesium() {
13
- const cfg = Config.getInstance().config;
14
- if (cfg.cesium) {
15
- return cfg.cesium;
16
- }
17
- throw new Error(
18
- 'Cesium 未提供。请在 xs3d.init 时传入 cesium 实例:\n' +
19
- ' import * as Cesium from "cesium";\n' +
20
- ' xs3d.init("container", { cesium: Cesium, ... });'
21
- );
22
- }
23
-
24
42
  function getCesium() {
25
43
  return new Proxy(function () {}, {
26
44
  apply(_target, _thisArg, args) {
27
- const Cesium = resolveCesium();
45
+ const Cesium = getCesiumInstance();
28
46
  return Cesium(...args);
29
47
  },
30
48
  construct(_target, args) {
31
- const Cesium = resolveCesium();
49
+ const Cesium = getCesiumInstance();
32
50
  return new Cesium(...args);
33
51
  },
34
52
  get(_target, prop) {
35
- const Cesium = resolveCesium();
53
+ const Cesium = getCesiumInstance();
36
54
  return Cesium[prop];
37
55
  },
38
56
  set(_target, prop, value) {
39
- const Cesium = resolveCesium();
57
+ const Cesium = getCesiumInstance();
40
58
  Cesium[prop] = value;
41
59
  return true;
42
60
  }
@@ -150,6 +168,10 @@ class Config {
150
168
 
151
169
  console.log('config', this.config);
152
170
 
171
+ // 将 Cesium 实例同步到 Provider,避免 Config 与 getCesium 循环依赖
172
+ if (options.cesium) {
173
+ setCesiumInstance(options.cesium);
174
+ }
153
175
 
154
176
  // Token 同步到 Cesium
155
177
  if (options.cesiumToken && this.config.cesium) {
@@ -220,7 +242,7 @@ class Config {
220
242
  }
221
243
  }
222
244
 
223
- const Cesium$f = getCesium();
245
+ const Cesium$g = getCesium();
224
246
 
225
247
  /**
226
248
  * 图层类型枚举
@@ -306,10 +328,10 @@ function createProviderByType(type, url, opts) {
306
328
  case LayerType.XYZ:
307
329
  case LayerType.TMS:
308
330
  // XYZ / TMS 均使用 UrlTemplateImageryProvider
309
- return new Cesium$f.UrlTemplateImageryProvider({ url, ...opts });
331
+ return new Cesium$g.UrlTemplateImageryProvider({ url, ...opts });
310
332
 
311
333
  case LayerType.WMTS:
312
- return new Cesium$f.WebMapTileServiceImageryProvider({
334
+ return new Cesium$g.WebMapTileServiceImageryProvider({
313
335
  url,
314
336
  layer: opts.layer,
315
337
  style: opts.style || 'default',
@@ -319,7 +341,7 @@ function createProviderByType(type, url, opts) {
319
341
  });
320
342
 
321
343
  case LayerType.WMS:
322
- return new Cesium$f.WebMapServiceImageryProvider({
344
+ return new Cesium$g.WebMapServiceImageryProvider({
323
345
  url,
324
346
  layers: opts.layers || '',
325
347
  parameters: { transparent: true, format: 'image/png', ...opts.parameters },
@@ -327,23 +349,23 @@ function createProviderByType(type, url, opts) {
327
349
  });
328
350
 
329
351
  case LayerType.SINGLE_IMAGE:
330
- return new Cesium$f.SingleTileImageryProvider({
352
+ return new Cesium$g.SingleTileImageryProvider({
331
353
  url,
332
- rectangle: opts.extent ? Cesium$f.Rectangle.fromDegrees(...opts.extent) : undefined,
354
+ rectangle: opts.extent ? Cesium$g.Rectangle.fromDegrees(...opts.extent) : undefined,
333
355
  credit: opts.credit || '',
334
356
  ...opts
335
357
  });
336
358
 
337
359
  case LayerType.TERRAIN:
338
360
  // fromUrl 返回 Promise,由 addProviderToViewer 统一 await
339
- return Cesium$f.CesiumTerrainProvider.fromUrl(url, {
361
+ return Cesium$g.CesiumTerrainProvider.fromUrl(url, {
340
362
  requestWaterMask: opts.requestWaterMask ?? false,
341
363
  requestVertexNormals: opts.requestVertexNormals ?? false,
342
364
  ...opts
343
365
  });
344
366
 
345
367
  case LayerType['3DTILES']:
346
- return new Cesium$f.Cesium3DTileset({
368
+ return new Cesium$g.Cesium3DTileset({
347
369
  url,
348
370
  maximumScreenSpaceError: opts.maximumScreenSpaceError ?? 16,
349
371
  maximumMemoryUsage: opts.maximumMemoryUsage ?? 512,
@@ -450,10 +472,10 @@ class ImageryLayerWrapper {
450
472
  if (provider && provider.rectangle) {
451
473
  const rect = provider.rectangle;
452
474
  return {
453
- west: Cesium$f.Math.toDegrees(rect.west),
454
- south: Cesium$f.Math.toDegrees(rect.south),
455
- east: Cesium$f.Math.toDegrees(rect.east),
456
- north: Cesium$f.Math.toDegrees(rect.north)
475
+ west: Cesium$g.Math.toDegrees(rect.west),
476
+ south: Cesium$g.Math.toDegrees(rect.south),
477
+ east: Cesium$g.Math.toDegrees(rect.east),
478
+ north: Cesium$g.Math.toDegrees(rect.north)
457
479
  };
458
480
  }
459
481
  return null;
@@ -497,10 +519,10 @@ class TerrainLayerWrapper {
497
519
  if (this._provider.rectangle) {
498
520
  const rect = this._provider.rectangle;
499
521
  return {
500
- west: Cesium$f.Math.toDegrees(rect.west),
501
- south: Cesium$f.Math.toDegrees(rect.south),
502
- east: Cesium$f.Math.toDegrees(rect.east),
503
- north: Cesium$f.Math.toDegrees(rect.north)
522
+ west: Cesium$g.Math.toDegrees(rect.west),
523
+ south: Cesium$g.Math.toDegrees(rect.south),
524
+ east: Cesium$g.Math.toDegrees(rect.east),
525
+ north: Cesium$g.Math.toDegrees(rect.north)
504
526
  };
505
527
  }
506
528
  return { west: -180, south: -85, east: 180, north: 85 };
@@ -539,17 +561,17 @@ class TilesetLayerWrapper {
539
561
  getExtent() {
540
562
  if (this._tileset.boundingSphere) {
541
563
  const bs = this._tileset.boundingSphere;
542
- const cartographic = Cesium$f.Cartographic.fromCartesian(bs.center);
564
+ const cartographic = Cesium$g.Cartographic.fromCartesian(bs.center);
543
565
  const rect = this._tileset.rectangle;
544
566
  if (rect) {
545
567
  return {
546
- west: Cesium$f.Math.toDegrees(rect.west),
547
- south: Cesium$f.Math.toDegrees(rect.south),
548
- east: Cesium$f.Math.toDegrees(rect.east),
549
- north: Cesium$f.Math.toDegrees(rect.north),
568
+ west: Cesium$g.Math.toDegrees(rect.west),
569
+ south: Cesium$g.Math.toDegrees(rect.south),
570
+ east: Cesium$g.Math.toDegrees(rect.east),
571
+ north: Cesium$g.Math.toDegrees(rect.north),
550
572
  center: [
551
- Cesium$f.Math.toDegrees(cartographic.longitude),
552
- Cesium$f.Math.toDegrees(cartographic.latitude)
573
+ Cesium$g.Math.toDegrees(cartographic.longitude),
574
+ Cesium$g.Math.toDegrees(cartographic.latitude)
553
575
  ]
554
576
  };
555
577
  }
@@ -587,20 +609,20 @@ class SceneModule {
587
609
  // ========== 坐标转换 ==========
588
610
 
589
611
  lonLatToWorld(lon, lat, height = 0) {
590
- return Cesium$f.Cartesian3.fromDegrees(lon, lat, height);
612
+ return Cesium$g.Cartesian3.fromDegrees(lon, lat, height);
591
613
  }
592
614
 
593
615
  worldToLonLat(cartesian) {
594
- const cartographic = Cesium$f.Cartographic.fromCartesian(cartesian);
616
+ const cartographic = Cesium$g.Cartographic.fromCartesian(cartesian);
595
617
  return [
596
- Cesium$f.Math.toDegrees(cartographic.longitude),
597
- Cesium$f.Math.toDegrees(cartographic.latitude),
618
+ Cesium$g.Math.toDegrees(cartographic.longitude),
619
+ Cesium$g.Math.toDegrees(cartographic.latitude),
598
620
  cartographic.height
599
621
  ];
600
622
  }
601
623
 
602
624
  screenToWorld(x, y) {
603
- const screenPosition = new Cesium$f.Cartesian2(x, y);
625
+ const screenPosition = new Cesium$g.Cartesian2(x, y);
604
626
  if (this.viewer.scene.pickPositionSupported) {
605
627
  const precisePosition = this.viewer.scene.pickPosition(screenPosition);
606
628
  if (precisePosition) return precisePosition;
@@ -608,7 +630,7 @@ class SceneModule {
608
630
  const ray = this.viewer.camera.getPickRay(screenPosition);
609
631
  const globePosition = this.viewer.scene.globe.pick(ray, this.viewer.scene);
610
632
  if (globePosition) return globePosition;
611
- return this.viewer.camera.pickEllipsoid(screenPosition, Cesium$f.Ellipsoid.WGS84);
633
+ return this.viewer.camera.pickEllipsoid(screenPosition, Cesium$g.Ellipsoid.WGS84);
612
634
  }
613
635
 
614
636
  worldToScreen(cartesian) {
@@ -626,13 +648,13 @@ class SceneModule {
626
648
  }
627
649
 
628
650
  lonLatToCartographic(lon, lat, height = 0) {
629
- return new Cesium$f.Cartographic(Cesium$f.Math.toRadians(lon), Cesium$f.Math.toRadians(lat), height);
651
+ return new Cesium$g.Cartographic(Cesium$g.Math.toRadians(lon), Cesium$g.Math.toRadians(lat), height);
630
652
  }
631
653
 
632
654
  cartographicToLonLat(cartographic) {
633
655
  return [
634
- Cesium$f.Math.toDegrees(cartographic.longitude),
635
- Cesium$f.Math.toDegrees(cartographic.latitude),
656
+ Cesium$g.Math.toDegrees(cartographic.longitude),
657
+ Cesium$g.Math.toDegrees(cartographic.latitude),
636
658
  cartographic.height
637
659
  ];
638
660
  }
@@ -728,7 +750,7 @@ class SceneModule {
728
750
  this.viewer.imageryLayers.remove(layer.getLayer());
729
751
  } else if (layer instanceof TerrainLayerWrapper) {
730
752
  // 地形无法直接删除,重置为默认椭球地形
731
- this.viewer.terrainProvider = new Cesium$f.EllipsoidTerrainProvider();
753
+ this.viewer.terrainProvider = new Cesium$g.EllipsoidTerrainProvider();
732
754
  } else if (layer instanceof TilesetLayerWrapper) {
733
755
  this.viewer.scene.primitives.remove(layer.getTileset());
734
756
  }
@@ -770,17 +792,17 @@ class SceneModule {
770
792
  duration = 3.0
771
793
  } = params;
772
794
 
773
- if (!Cesium$f.defined(lon) || !Cesium$f.defined(lat)) {
795
+ if (!Cesium$g.defined(lon) || !Cesium$g.defined(lat)) {
774
796
  console.warn('flyToLonLat: 必须提供 lon、lat');
775
797
  return Promise.resolve(false);
776
798
  }
777
799
 
778
800
  return this.viewer.camera.flyTo({
779
- destination: Cesium$f.Cartesian3.fromDegrees(lon, lat, height),
801
+ destination: Cesium$g.Cartesian3.fromDegrees(lon, lat, height),
780
802
  orientation: {
781
- heading: Cesium$f.Math.toRadians(heading),
782
- pitch: Cesium$f.Math.toRadians(pitch),
783
- roll: Cesium$f.Math.toRadians(roll)
803
+ heading: Cesium$g.Math.toRadians(heading),
804
+ pitch: Cesium$g.Math.toRadians(pitch),
805
+ roll: Cesium$g.Math.toRadians(roll)
784
806
  },
785
807
  duration
786
808
  });
@@ -805,23 +827,23 @@ class SceneModule {
805
827
  roll = 0
806
828
  } = params;
807
829
 
808
- if (!Cesium$f.defined(lon) || !Cesium$f.defined(lat)) {
830
+ if (!Cesium$g.defined(lon) || !Cesium$g.defined(lat)) {
809
831
  console.warn('setView: 必须提供 lon、lat');
810
832
  return;
811
833
  }
812
834
 
813
835
  this.viewer.camera.setView({
814
- destination: Cesium$f.Cartesian3.fromDegrees(lon, lat, height),
836
+ destination: Cesium$g.Cartesian3.fromDegrees(lon, lat, height),
815
837
  orientation: {
816
- heading: Cesium$f.Math.toRadians(heading),
817
- pitch: Cesium$f.Math.toRadians(pitch),
818
- roll: Cesium$f.Math.toRadians(roll)
838
+ heading: Cesium$g.Math.toRadians(heading),
839
+ pitch: Cesium$g.Math.toRadians(pitch),
840
+ roll: Cesium$g.Math.toRadians(roll)
819
841
  }
820
842
  });
821
843
  }
822
844
  }
823
845
 
824
- const Cesium$e = getCesium();
846
+ const Cesium$f = getCesium();
825
847
 
826
848
  /**
827
849
  * 标绘几何算法工具
@@ -1110,7 +1132,7 @@ class PlotGeometryUtil {
1110
1132
  for (const p of points) {
1111
1133
  flat.push(p[0], p[1], p[2] || 0);
1112
1134
  }
1113
- return Cesium$e.Cartesian3.fromDegreesArrayHeights(flat);
1135
+ return Cesium$f.Cartesian3.fromDegreesArrayHeights(flat);
1114
1136
  }
1115
1137
 
1116
1138
  // ==================== 曲线/插值工具(复合箭头、曲线标绘需要)====================
@@ -1310,7 +1332,12 @@ class PlotGeometryUtil {
1310
1332
  }
1311
1333
  points.push(pnt2);
1312
1334
  }
1313
- return points;
1335
+ // 去除相邻重复点(首尾插值点与控制点重合),避免 Cesium polyline 出现零长度边
1336
+ return points.filter((p, i) => {
1337
+ if (i === 0) return true;
1338
+ const prev = points[i - 1];
1339
+ return p[0] !== prev[0] || p[1] !== prev[1];
1340
+ });
1314
1341
  }
1315
1342
 
1316
1343
  /**
@@ -1909,20 +1936,23 @@ class PlotGeometryUtil {
1909
1936
  const lnglatPoints = points.map(p => this.toLonLat(p));
1910
1937
  const height = points[0][2] || 0;
1911
1938
 
1939
+ const arrowLength = options.arrowLength ?? 0.05; // 箭头头部最大长度
1940
+ const arrowLengthScale = options.arrowLengthScale ?? 5; // 按拖动距离缩放的系数
1941
+ const distance = this.mathDistance(lnglatPoints[0], lnglatPoints[lnglatPoints.length - 1]);
1942
+ const len = Math.min(distance / arrowLengthScale, arrowLength);
1943
+
1912
1944
  if (points.length === 2) {
1913
- return this.createStraightArrow(points, options);
1945
+ // 2 个点时退化为细直箭头,按距离渐变但不超过 arrowLength
1946
+ const [p1, p2] = lnglatPoints;
1947
+ const leftPnt = this.getThirdPoint(p1, p2, Math.PI / 6, len / 2, false);
1948
+ const rightPnt = this.getThirdPoint(p1, p2, Math.PI / 6, len / 2, true);
1949
+ return this.toPositions([p1, p2, leftPnt, p2, rightPnt], height);
1914
1950
  }
1915
1951
 
1916
1952
  const t = options.t ?? 0.3;
1917
- const arrowLengthScale = options.arrowLengthScale ?? 5;
1918
- const maxArrowLength = options.maxArrowLength ?? 3000000;
1919
1953
 
1920
1954
  const curvePoints = this.getCurvePoints(t, lnglatPoints);
1921
- lnglatPoints[lnglatPoints.length - 2];
1922
1955
  const pnt2 = lnglatPoints[lnglatPoints.length - 1];
1923
- const distance = this.wholeDistance(lnglatPoints);
1924
- let len = distance / arrowLengthScale;
1925
- len = Math.min(len, maxArrowLength);
1926
1956
  const leftPnt = this.getThirdPoint(
1927
1957
  curvePoints[curvePoints.length - 2],
1928
1958
  curvePoints[curvePoints.length - 1],
@@ -1998,7 +2028,7 @@ function isLinePlotType(plotType) {
1998
2028
  ].includes(plotType);
1999
2029
  }
2000
2030
 
2001
- const Cesium$d = getCesium();
2031
+ const Cesium$e = getCesium();
2002
2032
 
2003
2033
  /**
2004
2034
  * 点图元包装器
@@ -2010,7 +2040,7 @@ class PointWrapper {
2010
2040
  }
2011
2041
 
2012
2042
  setPosition(coords) {
2013
- this._entity.position = Cesium$d.Cartesian3.fromDegrees(...coords);
2043
+ this._entity.position = Cesium$e.Cartesian3.fromDegrees(...coords);
2014
2044
  return this;
2015
2045
  }
2016
2046
 
@@ -2058,7 +2088,7 @@ class PointWrapper {
2058
2088
  // 名称标签相关
2059
2089
  setNameVisible(visible) {
2060
2090
  if (!this._entity.label) {
2061
- this._entity.label = new Cesium$d.LabelGraphics();
2091
+ this._entity.label = new Cesium$e.LabelGraphics();
2062
2092
  }
2063
2093
  this._entity.label.show = visible;
2064
2094
  return this;
@@ -2066,22 +2096,22 @@ class PointWrapper {
2066
2096
 
2067
2097
  setText(text, options = {}) {
2068
2098
  if (!this._entity.label) {
2069
- this._entity.label = new Cesium$d.LabelGraphics();
2099
+ this._entity.label = new Cesium$e.LabelGraphics();
2070
2100
  }
2071
2101
  this._entity.label.text = text;
2072
2102
 
2073
2103
  // 应用配置选项
2074
2104
  this._entity.label.disableDepthTestDistance = options.disableDepthTestDistance ?? Number.POSITIVE_INFINITY;
2075
- this._entity.label.verticalOrigin = options.verticalOrigin ?? Cesium$d.VerticalOrigin.BOTTOM;
2076
- this._entity.label.eyeOffset = options.eyeOffset ?? new Cesium$d.Cartesian3(0, 0, -10);
2077
- this._entity.label.heightReference = options.heightReference ?? Cesium$d.HeightReference.RELATIVE_TO_GROUND;
2105
+ this._entity.label.verticalOrigin = options.verticalOrigin ?? Cesium$e.VerticalOrigin.BOTTOM;
2106
+ this._entity.label.eyeOffset = options.eyeOffset ?? new Cesium$e.Cartesian3(0, 0, -10);
2107
+ this._entity.label.heightReference = options.heightReference ?? Cesium$e.HeightReference.RELATIVE_TO_GROUND;
2078
2108
 
2079
2109
  return this;
2080
2110
  }
2081
2111
 
2082
2112
  setFont(font) {
2083
2113
  if (!this._entity.label) {
2084
- this._entity.label = new Cesium$d.LabelGraphics();
2114
+ this._entity.label = new Cesium$e.LabelGraphics();
2085
2115
  }
2086
2116
  this._entity.label.font = font;
2087
2117
  return this;
@@ -2089,7 +2119,7 @@ class PointWrapper {
2089
2119
 
2090
2120
  setTextColor(color) {
2091
2121
  if (!this._entity.label) {
2092
- this._entity.label = new Cesium$d.LabelGraphics();
2122
+ this._entity.label = new Cesium$e.LabelGraphics();
2093
2123
  }
2094
2124
  this._entity.label.fillColor = color;
2095
2125
  return this;
@@ -2097,7 +2127,7 @@ class PointWrapper {
2097
2127
 
2098
2128
  setTextOutlineColor(color) {
2099
2129
  if (!this._entity.label) {
2100
- this._entity.label = new Cesium$d.LabelGraphics();
2130
+ this._entity.label = new Cesium$e.LabelGraphics();
2101
2131
  }
2102
2132
  this._entity.label.outlineColor = color;
2103
2133
  return this;
@@ -2105,7 +2135,7 @@ class PointWrapper {
2105
2135
 
2106
2136
  setTextOutlineWidth(width) {
2107
2137
  if (!this._entity.label) {
2108
- this._entity.label = new Cesium$d.LabelGraphics();
2138
+ this._entity.label = new Cesium$e.LabelGraphics();
2109
2139
  }
2110
2140
  this._entity.label.outlineWidth = width;
2111
2141
  return this;
@@ -2113,19 +2143,19 @@ class PointWrapper {
2113
2143
 
2114
2144
  setAlignType(alignType) {
2115
2145
  if (!this._entity.label) {
2116
- this._entity.label = new Cesium$d.LabelGraphics();
2146
+ this._entity.label = new Cesium$e.LabelGraphics();
2117
2147
  }
2118
2148
  // alignType: 0=CENTER, 1=LEFT, 2=RIGHT, 3=TOP, 4=BOTTOM
2119
- const horizontalOrigins = [Cesium$d.HorizontalOrigin.CENTER, Cesium$d.HorizontalOrigin.LEFT, Cesium$d.HorizontalOrigin.RIGHT];
2120
- const verticalOrigins = [Cesium$d.VerticalOrigin.CENTER, Cesium$d.VerticalOrigin.CENTER, Cesium$d.VerticalOrigin.CENTER, Cesium$d.VerticalOrigin.TOP, Cesium$d.VerticalOrigin.BOTTOM];
2121
- this._entity.label.horizontalOrigin = horizontalOrigins[alignType] || Cesium$d.HorizontalOrigin.CENTER;
2122
- this._entity.label.verticalOrigin = verticalOrigins[alignType] || Cesium$d.VerticalOrigin.CENTER;
2149
+ const horizontalOrigins = [Cesium$e.HorizontalOrigin.CENTER, Cesium$e.HorizontalOrigin.LEFT, Cesium$e.HorizontalOrigin.RIGHT];
2150
+ const verticalOrigins = [Cesium$e.VerticalOrigin.CENTER, Cesium$e.VerticalOrigin.CENTER, Cesium$e.VerticalOrigin.CENTER, Cesium$e.VerticalOrigin.TOP, Cesium$e.VerticalOrigin.BOTTOM];
2151
+ this._entity.label.horizontalOrigin = horizontalOrigins[alignType] || Cesium$e.HorizontalOrigin.CENTER;
2152
+ this._entity.label.verticalOrigin = verticalOrigins[alignType] || Cesium$e.VerticalOrigin.CENTER;
2123
2153
  return this;
2124
2154
  }
2125
2155
 
2126
2156
  setTextPixelOffset(offset) {
2127
2157
  if (!this._entity.label) {
2128
- this._entity.label = new Cesium$d.LabelGraphics();
2158
+ this._entity.label = new Cesium$e.LabelGraphics();
2129
2159
  }
2130
2160
  this._entity.label.pixelOffset = offset;
2131
2161
  return this;
@@ -2133,7 +2163,7 @@ class PointWrapper {
2133
2163
 
2134
2164
  setTextScale(scale) {
2135
2165
  if (!this._entity.label) {
2136
- this._entity.label = new Cesium$d.LabelGraphics();
2166
+ this._entity.label = new Cesium$e.LabelGraphics();
2137
2167
  }
2138
2168
  this._entity.label.scale = scale;
2139
2169
  return this;
@@ -2155,7 +2185,7 @@ class LineWrapper {
2155
2185
  }
2156
2186
 
2157
2187
  setPositions(coords) {
2158
- this._entity.polyline.positions = Cesium$d.Cartesian3.fromDegreesArrayHeights(
2188
+ this._entity.polyline.positions = Cesium$e.Cartesian3.fromDegreesArrayHeights(
2159
2189
  coords.flatMap(coord => [coord[0], coord[1], coord[2] || 0])
2160
2190
  );
2161
2191
  return this;
@@ -2199,23 +2229,23 @@ class LineWrapper {
2199
2229
  */
2200
2230
  setLabel(text, options = {}) {
2201
2231
  if (!this._entity.label) {
2202
- this._entity.label = new Cesium$d.LabelGraphics();
2232
+ this._entity.label = new Cesium$e.LabelGraphics();
2203
2233
  }
2204
2234
  this._entity.label.text = text;
2205
2235
  this._entity.label.font = options.font || '14px Microsoft YaHei';
2206
- this._entity.label.fillColor = options.color || Cesium$d.Color.WHITE;
2207
- this._entity.label.outlineColor = options.outlineColor || Cesium$d.Color.BLACK;
2236
+ this._entity.label.fillColor = options.color || Cesium$e.Color.WHITE;
2237
+ this._entity.label.outlineColor = options.outlineColor || Cesium$e.Color.BLACK;
2208
2238
  this._entity.label.outlineWidth = options.outlineWidth ?? 1;
2209
2239
  this._entity.label.show = true;
2210
- this._entity.label.pixelOffset = options.pixelOffset || new Cesium$d.Cartesian2(0, -10);
2211
- this._entity.label.horizontalOrigin = options.horizontalOrigin ?? Cesium$d.HorizontalOrigin.CENTER;
2212
- this._entity.label.verticalOrigin = options.verticalOrigin ?? Cesium$d.VerticalOrigin.BOTTOM;
2240
+ this._entity.label.pixelOffset = options.pixelOffset || new Cesium$e.Cartesian2(0, -10);
2241
+ this._entity.label.horizontalOrigin = options.horizontalOrigin ?? Cesium$e.HorizontalOrigin.CENTER;
2242
+ this._entity.label.verticalOrigin = options.verticalOrigin ?? Cesium$e.VerticalOrigin.BOTTOM;
2213
2243
 
2214
2244
  // 使用 CallbackProperty 动态计算标签锚点,随编辑/平移自动更新
2215
2245
  const self = this;
2216
- this._entity.position = new Cesium$d.CallbackProperty(function () {
2246
+ this._entity.position = new Cesium$e.CallbackProperty(function () {
2217
2247
  const anchor = self._computeLabelAnchor();
2218
- return Cesium$d.Cartesian3.fromDegrees(anchor[0], anchor[1], anchor[2] || 0);
2248
+ return Cesium$e.Cartesian3.fromDegrees(anchor[0], anchor[1], anchor[2] || 0);
2219
2249
  }, false);
2220
2250
 
2221
2251
  return this;
@@ -2238,13 +2268,13 @@ class LineWrapper {
2238
2268
  return [x / cps.length, y / cps.length, z / cps.length];
2239
2269
  }
2240
2270
 
2241
- const positions = this._entity.polyline?.positions?.getValue(Cesium$d.JulianDate.now());
2271
+ const positions = this._entity.polyline?.positions?.getValue(Cesium$e.JulianDate.now());
2242
2272
  if (positions && positions.length > 0) {
2243
2273
  let lon = 0, lat = 0, height = 0;
2244
2274
  positions.forEach(p => {
2245
- const c = Cesium$d.Cartographic.fromCartesian(p);
2246
- lon += Cesium$d.Math.toDegrees(c.longitude);
2247
- lat += Cesium$d.Math.toDegrees(c.latitude);
2275
+ const c = Cesium$e.Cartographic.fromCartesian(p);
2276
+ lon += Cesium$e.Math.toDegrees(c.longitude);
2277
+ lat += Cesium$e.Math.toDegrees(c.latitude);
2248
2278
  height += c.height || 0;
2249
2279
  });
2250
2280
  const count = positions.length;
@@ -2317,8 +2347,8 @@ class PolygonWrapper {
2317
2347
  }
2318
2348
 
2319
2349
  setPositions(coords) {
2320
- this._entity.polygon.hierarchy = new Cesium$d.PolygonHierarchy(
2321
- Cesium$d.Cartesian3.fromDegreesArrayHeights(
2350
+ this._entity.polygon.hierarchy = new Cesium$e.PolygonHierarchy(
2351
+ Cesium$e.Cartesian3.fromDegreesArrayHeights(
2322
2352
  coords.flatMap(coord => [coord[0], coord[1], coord[2] || 0])
2323
2353
  )
2324
2354
  );
@@ -2368,23 +2398,23 @@ class PolygonWrapper {
2368
2398
  */
2369
2399
  setLabel(text, options = {}) {
2370
2400
  if (!this._entity.label) {
2371
- this._entity.label = new Cesium$d.LabelGraphics();
2401
+ this._entity.label = new Cesium$e.LabelGraphics();
2372
2402
  }
2373
2403
  this._entity.label.text = text;
2374
2404
  this._entity.label.font = options.font || '14px Microsoft YaHei';
2375
- this._entity.label.fillColor = options.color || Cesium$d.Color.WHITE;
2376
- this._entity.label.outlineColor = options.outlineColor || Cesium$d.Color.BLACK;
2405
+ this._entity.label.fillColor = options.color || Cesium$e.Color.WHITE;
2406
+ this._entity.label.outlineColor = options.outlineColor || Cesium$e.Color.BLACK;
2377
2407
  this._entity.label.outlineWidth = options.outlineWidth ?? 1;
2378
2408
  this._entity.label.show = true;
2379
- this._entity.label.pixelOffset = options.pixelOffset || new Cesium$d.Cartesian2(0, -10);
2380
- this._entity.label.horizontalOrigin = options.horizontalOrigin ?? Cesium$d.HorizontalOrigin.CENTER;
2381
- this._entity.label.verticalOrigin = options.verticalOrigin ?? Cesium$d.VerticalOrigin.BOTTOM;
2409
+ this._entity.label.pixelOffset = options.pixelOffset || new Cesium$e.Cartesian2(0, -10);
2410
+ this._entity.label.horizontalOrigin = options.horizontalOrigin ?? Cesium$e.HorizontalOrigin.CENTER;
2411
+ this._entity.label.verticalOrigin = options.verticalOrigin ?? Cesium$e.VerticalOrigin.BOTTOM;
2382
2412
 
2383
2413
  // 使用 CallbackProperty 动态计算标签锚点,随编辑/平移自动更新
2384
2414
  const self = this;
2385
- this._entity.position = new Cesium$d.CallbackProperty(function () {
2415
+ this._entity.position = new Cesium$e.CallbackProperty(function () {
2386
2416
  const anchor = self._computeLabelAnchor();
2387
- return Cesium$d.Cartesian3.fromDegrees(anchor[0], anchor[1], anchor[2] || 0);
2417
+ return Cesium$e.Cartesian3.fromDegrees(anchor[0], anchor[1], anchor[2] || 0);
2388
2418
  }, false);
2389
2419
 
2390
2420
  return this;
@@ -2411,13 +2441,13 @@ class PolygonWrapper {
2411
2441
  return [x / cps.length, y / cps.length, z / cps.length];
2412
2442
  }
2413
2443
 
2414
- const hierarchy = this._entity.polygon?.hierarchy?.getValue(Cesium$d.JulianDate.now());
2444
+ const hierarchy = this._entity.polygon?.hierarchy?.getValue(Cesium$e.JulianDate.now());
2415
2445
  if (hierarchy && hierarchy.positions && hierarchy.positions.length > 0) {
2416
2446
  let lon = 0, lat = 0, height = 0;
2417
2447
  hierarchy.positions.forEach(p => {
2418
- const c = Cesium$d.Cartographic.fromCartesian(p);
2419
- lon += Cesium$d.Math.toDegrees(c.longitude);
2420
- lat += Cesium$d.Math.toDegrees(c.latitude);
2448
+ const c = Cesium$e.Cartographic.fromCartesian(p);
2449
+ lon += Cesium$e.Math.toDegrees(c.longitude);
2450
+ lat += Cesium$e.Math.toDegrees(c.latitude);
2421
2451
  height += c.height || 0;
2422
2452
  });
2423
2453
  const count = hierarchy.positions.length;
@@ -2490,7 +2520,7 @@ class ModelWrapper {
2490
2520
  }
2491
2521
 
2492
2522
  setPosition(coords) {
2493
- this._entity.position = Cesium$d.Cartesian3.fromDegrees(...coords);
2523
+ this._entity.position = Cesium$e.Cartesian3.fromDegrees(...coords);
2494
2524
  return this;
2495
2525
  }
2496
2526
 
@@ -2540,7 +2570,7 @@ class TextWrapper {
2540
2570
  }
2541
2571
 
2542
2572
  setPosition(coords) {
2543
- this._entity.position = Cesium$d.Cartesian3.fromDegrees(...coords);
2573
+ this._entity.position = Cesium$e.Cartesian3.fromDegrees(...coords);
2544
2574
  return this;
2545
2575
  }
2546
2576
 
@@ -2586,10 +2616,10 @@ class TextWrapper {
2586
2616
  }
2587
2617
 
2588
2618
  setAlignType(alignType) {
2589
- const horizontalOrigins = [Cesium$d.HorizontalOrigin.CENTER, Cesium$d.HorizontalOrigin.LEFT, Cesium$d.HorizontalOrigin.RIGHT];
2590
- const verticalOrigins = [Cesium$d.VerticalOrigin.CENTER, Cesium$d.VerticalOrigin.CENTER, Cesium$d.VerticalOrigin.CENTER, Cesium$d.VerticalOrigin.TOP, Cesium$d.VerticalOrigin.BOTTOM];
2591
- this._entity.label.horizontalOrigin = horizontalOrigins[alignType] || Cesium$d.HorizontalOrigin.CENTER;
2592
- this._entity.label.verticalOrigin = verticalOrigins[alignType] || Cesium$d.VerticalOrigin.CENTER;
2619
+ const horizontalOrigins = [Cesium$e.HorizontalOrigin.CENTER, Cesium$e.HorizontalOrigin.LEFT, Cesium$e.HorizontalOrigin.RIGHT];
2620
+ const verticalOrigins = [Cesium$e.VerticalOrigin.CENTER, Cesium$e.VerticalOrigin.CENTER, Cesium$e.VerticalOrigin.CENTER, Cesium$e.VerticalOrigin.TOP, Cesium$e.VerticalOrigin.BOTTOM];
2621
+ this._entity.label.horizontalOrigin = horizontalOrigins[alignType] || Cesium$e.HorizontalOrigin.CENTER;
2622
+ this._entity.label.verticalOrigin = verticalOrigins[alignType] || Cesium$e.VerticalOrigin.CENTER;
2593
2623
  return this;
2594
2624
  }
2595
2625
 
@@ -2627,14 +2657,14 @@ class GraphicModule {
2627
2657
  return this.wrapperMap.get(graphicId);
2628
2658
  }
2629
2659
 
2630
- const defaultStyle = this.config.graphic?.point || { pixelSize: 8, color: Cesium$d.Color.RED };
2660
+ const defaultStyle = this.config.graphic?.point || { pixelSize: 8, color: Cesium$e.Color.RED };
2631
2661
 
2632
2662
  const entityOptions = {
2633
2663
  id: graphicId,
2634
- position: Cesium$d.Cartesian3.fromDegrees(0, 0, 0),
2664
+ position: Cesium$e.Cartesian3.fromDegrees(0, 0, 0),
2635
2665
  point: {
2636
2666
  ...defaultStyle,
2637
- outlineColor: Cesium$d.Color.WHITE,
2667
+ outlineColor: Cesium$e.Color.WHITE,
2638
2668
  outlineWidth: 1
2639
2669
  }
2640
2670
  };
@@ -2668,12 +2698,12 @@ class GraphicModule {
2668
2698
  return this.wrapperMap.get(graphicId);
2669
2699
  }
2670
2700
 
2671
- const defaultStyle = this.config.graphic?.line || { width: 2, material: Cesium$d.Color.BLUE };
2701
+ const defaultStyle = this.config.graphic?.line || { width: 2, material: Cesium$e.Color.BLUE };
2672
2702
 
2673
2703
  const entityOptions = {
2674
2704
  id: graphicId,
2675
2705
  polyline: {
2676
- positions: Cesium$d.Cartesian3.fromDegreesArrayHeights([]),
2706
+ positions: Cesium$e.Cartesian3.fromDegreesArrayHeights([0, 0, 0, 0, 0, 0]),
2677
2707
  clampToGround: true,
2678
2708
  ...defaultStyle
2679
2709
  }
@@ -2708,14 +2738,14 @@ class GraphicModule {
2708
2738
  return this.wrapperMap.get(graphicId);
2709
2739
  }
2710
2740
 
2711
- const defaultStyle = this.config.graphic?.polygon || { color: Cesium$d.Color.GREEN.withAlpha(0.5) };
2741
+ const defaultStyle = this.config.graphic?.polygon || { color: Cesium$e.Color.GREEN.withAlpha(0.5) };
2712
2742
 
2713
2743
  const entityOptions = {
2714
2744
  id: graphicId,
2715
2745
  polygon: {
2716
- hierarchy: new Cesium$d.PolygonHierarchy([]),
2746
+ hierarchy: new Cesium$e.PolygonHierarchy([]),
2717
2747
  clampToGround: true,
2718
- outlineColor: Cesium$d.Color.WHITE,
2748
+ outlineColor: Cesium$e.Color.WHITE,
2719
2749
  outlineWidth: 1,
2720
2750
  ...defaultStyle
2721
2751
  }
@@ -2752,7 +2782,7 @@ class GraphicModule {
2752
2782
 
2753
2783
  const entityOptions = {
2754
2784
  id: graphicId,
2755
- position: Cesium$d.Cartesian3.fromDegrees(0, 0, 0),
2785
+ position: Cesium$e.Cartesian3.fromDegrees(0, 0, 0),
2756
2786
  model: {
2757
2787
  uri: "",
2758
2788
  scale: 1.0,
@@ -2791,16 +2821,16 @@ class GraphicModule {
2791
2821
 
2792
2822
  const entityOptions = {
2793
2823
  id: graphicId,
2794
- position: Cesium$d.Cartesian3.fromDegrees(0, 0, 0),
2824
+ position: Cesium$e.Cartesian3.fromDegrees(0, 0, 0),
2795
2825
  label: {
2796
2826
  text: "",
2797
2827
  font: "16px Microsoft YaHei",
2798
- fillColor: Cesium$d.Color.WHITE,
2799
- outlineColor: Cesium$d.Color.BLACK,
2828
+ fillColor: Cesium$e.Color.WHITE,
2829
+ outlineColor: Cesium$e.Color.BLACK,
2800
2830
  outlineWidth: 2,
2801
- style: Cesium$d.LabelStyle.FILL_AND_OUTLINE,
2802
- verticalOrigin: Cesium$d.VerticalOrigin.BOTTOM,
2803
- horizontalOrigin: Cesium$d.HorizontalOrigin.CENTER
2831
+ style: Cesium$e.LabelStyle.FILL_AND_OUTLINE,
2832
+ verticalOrigin: Cesium$e.VerticalOrigin.BOTTOM,
2833
+ horizontalOrigin: Cesium$e.HorizontalOrigin.CENTER
2804
2834
  }
2805
2835
  };
2806
2836
 
@@ -3034,7 +3064,7 @@ class GraphicModule {
3034
3064
  }
3035
3065
  }
3036
3066
 
3037
- const Cesium$c = getCesium();
3067
+ const Cesium$d = getCesium();
3038
3068
 
3039
3069
  /**
3040
3070
  * 事件模块(对应平台 IEventModule)
@@ -3132,7 +3162,7 @@ class EventModule {
3132
3162
  switch (baseType) {
3133
3163
  // 鼠标事件
3134
3164
  case 'mouse':
3135
- this.handlers[eventKey] = new Cesium$c.ScreenSpaceEventHandler(this.viewer.scene.canvas);
3165
+ this.handlers[eventKey] = new Cesium$d.ScreenSpaceEventHandler(this.viewer.scene.canvas);
3136
3166
  // 绑定鼠标事件
3137
3167
  const mouseEventType = this.getCesiumMouseEventType(subType);
3138
3168
  this.handlers[eventKey].setInputAction((movement) => {
@@ -3153,10 +3183,10 @@ class EventModule {
3153
3183
  const pickedEntity = this.viewer.scene.pick(screenPos);
3154
3184
 
3155
3185
  if (position) {
3156
- const cartographic = Cesium$c.Cartographic.fromCartesian(position);
3186
+ const cartographic = Cesium$d.Cartographic.fromCartesian(position);
3157
3187
  lngLat = [
3158
- Cesium$c.Math.toDegrees(cartographic.longitude),
3159
- Cesium$c.Math.toDegrees(cartographic.latitude),
3188
+ Cesium$d.Math.toDegrees(cartographic.longitude),
3189
+ Cesium$d.Math.toDegrees(cartographic.latitude),
3160
3190
  cartographic.height
3161
3191
  ];
3162
3192
  }
@@ -3222,12 +3252,12 @@ class EventModule {
3222
3252
  // ========== 工具方法:映射 Cesium 鼠标事件类型 ==========
3223
3253
  getCesiumMouseEventType(subType) {
3224
3254
  switch (subType) {
3225
- case 'click': return Cesium$c.ScreenSpaceEventType.LEFT_CLICK;
3226
- case 'rightclick': return Cesium$c.ScreenSpaceEventType.RIGHT_CLICK;
3227
- case 'move': return Cesium$c.ScreenSpaceEventType.MOUSE_MOVE;
3228
- case 'down': return Cesium$c.ScreenSpaceEventType.LEFT_DOWN;
3229
- case 'up': return Cesium$c.ScreenSpaceEventType.LEFT_UP;
3230
- default: return Cesium$c.ScreenSpaceEventType.LEFT_CLICK;
3255
+ case 'click': return Cesium$d.ScreenSpaceEventType.LEFT_CLICK;
3256
+ case 'rightclick': return Cesium$d.ScreenSpaceEventType.RIGHT_CLICK;
3257
+ case 'move': return Cesium$d.ScreenSpaceEventType.MOUSE_MOVE;
3258
+ case 'down': return Cesium$d.ScreenSpaceEventType.LEFT_DOWN;
3259
+ case 'up': return Cesium$d.ScreenSpaceEventType.LEFT_UP;
3260
+ default: return Cesium$d.ScreenSpaceEventType.LEFT_CLICK;
3231
3261
  }
3232
3262
  }
3233
3263
 
@@ -3235,18 +3265,18 @@ class EventModule {
3235
3265
  getZoomLevel() {
3236
3266
  const camera = this.viewer.camera;
3237
3267
  const positionCartographic = camera.positionCartographic;
3238
- const positionCartesian = Cesium$c.Cartesian3.fromRadians(
3268
+ const positionCartesian = Cesium$d.Cartesian3.fromRadians(
3239
3269
  positionCartographic.longitude,
3240
3270
  positionCartographic.latitude,
3241
3271
  positionCartographic.height
3242
3272
  );
3243
- const distance = Cesium$c.Cartesian3.distance(camera.position, positionCartesian);
3273
+ const distance = Cesium$d.Cartesian3.distance(camera.position, positionCartesian);
3244
3274
  // 映射为 0-20 级缩放(类似地图瓦片级别)
3245
3275
  return Math.floor(Math.log2(6378137 * 2 * Math.PI / distance)) + 1;
3246
3276
  }
3247
3277
  }
3248
3278
 
3249
- const Cesium$b = getCesium();
3279
+ const Cesium$c = getCesium();
3250
3280
 
3251
3281
  /**
3252
3282
  * 工具基类
@@ -3341,17 +3371,17 @@ class BaseTool {
3341
3371
  // 如果拾取失败(空白区域),fallback 到椭球体表面
3342
3372
  if (!cartesian) {
3343
3373
  cartesian = this._viewer.camera.pickEllipsoid(
3344
- new Cesium$b.Cartesian3(screenPos.x, screenPos.y),
3374
+ new Cesium$c.Cartesian3(screenPos.x, screenPos.y),
3345
3375
  this._viewer.scene.globe.ellipsoid
3346
3376
  );
3347
3377
  }
3348
3378
 
3349
3379
  if (!cartesian) return null;
3350
3380
 
3351
- const cartographic = Cesium$b.Cartographic.fromCartesian(cartesian);
3381
+ const cartographic = Cesium$c.Cartographic.fromCartesian(cartesian);
3352
3382
  return [
3353
- Cesium$b.Math.toDegrees(cartographic.longitude),
3354
- Cesium$b.Math.toDegrees(cartographic.latitude),
3383
+ Cesium$c.Math.toDegrees(cartographic.longitude),
3384
+ Cesium$c.Math.toDegrees(cartographic.latitude),
3355
3385
  cartographic.height
3356
3386
  ];
3357
3387
  }
@@ -3362,8 +3392,8 @@ class BaseTool {
3362
3392
  * @returns {Promise<number>} 地形高度
3363
3393
  */
3364
3394
  async getTerrainHeight(lonLat) {
3365
- const cartographic = Cesium$b.Cartographic.fromDegrees(lonLat[0], lonLat[1]);
3366
- const result = await Cesium$b.sampleTerrainMostDetailed(
3395
+ const cartographic = Cesium$c.Cartographic.fromDegrees(lonLat[0], lonLat[1]);
3396
+ const result = await Cesium$c.sampleTerrainMostDetailed(
3367
3397
  this._viewer.terrainProvider,
3368
3398
  [cartographic]
3369
3399
  );
@@ -3404,7 +3434,7 @@ class BaseTool {
3404
3434
  }
3405
3435
  }
3406
3436
 
3407
- const Cesium$a = getCesium();
3437
+ const Cesium$b = getCesium();
3408
3438
 
3409
3439
  /**
3410
3440
  * 绘制类型枚举
@@ -3691,7 +3721,7 @@ class DrawTool extends BaseTool {
3691
3721
  const id = this.generateId('point');
3692
3722
  this._graphicModule.CreatePoint(id)
3693
3723
  .setPosition(lonLat)
3694
- .setColor(Cesium$a.Color.RED)
3724
+ .setColor(Cesium$b.Color.RED)
3695
3725
  .setPixelSize(10);
3696
3726
 
3697
3727
  this._emitGraphicCreated('point', id);
@@ -3703,9 +3733,9 @@ class DrawTool extends BaseTool {
3703
3733
 
3704
3734
  // 创建辅助点
3705
3735
  const tempPoint = this.createTempEntity(this.generateId('temp_point'), {
3706
- position: Cesium$a.Cartesian3.fromDegrees(...lonLat),
3736
+ position: Cesium$b.Cartesian3.fromDegrees(...lonLat),
3707
3737
  point: {
3708
- color: Cesium$a.Color.YELLOW,
3738
+ color: Cesium$b.Color.YELLOW,
3709
3739
  pixelSize: 8
3710
3740
  }
3711
3741
  });
@@ -3725,9 +3755,9 @@ class DrawTool extends BaseTool {
3725
3755
 
3726
3756
  // 创建辅助点
3727
3757
  const tempPoint = this.createTempEntity(this.generateId('temp_point'), {
3728
- position: Cesium$a.Cartesian3.fromDegrees(...lonLat),
3758
+ position: Cesium$b.Cartesian3.fromDegrees(...lonLat),
3729
3759
  point: {
3730
- color: Cesium$a.Color.YELLOW,
3760
+ color: Cesium$b.Color.YELLOW,
3731
3761
  pixelSize: 8
3732
3762
  }
3733
3763
  });
@@ -3747,9 +3777,9 @@ class DrawTool extends BaseTool {
3747
3777
  this._startPos = lonLat;
3748
3778
  // 创建起始点标记
3749
3779
  const startMarker = this.createTempEntity(this.generateId('temp_start'), {
3750
- position: Cesium$a.Cartesian3.fromDegrees(...lonLat),
3780
+ position: Cesium$b.Cartesian3.fromDegrees(...lonLat),
3751
3781
  point: {
3752
- color: Cesium$a.Color.YELLOW,
3782
+ color: Cesium$b.Color.YELLOW,
3753
3783
  pixelSize: 10
3754
3784
  }
3755
3785
  });
@@ -3764,9 +3794,9 @@ class DrawTool extends BaseTool {
3764
3794
  if (!this._startPos) {
3765
3795
  this._startPos = lonLat;
3766
3796
  const startMarker = this.createTempEntity(this.generateId('temp_start'), {
3767
- position: Cesium$a.Cartesian3.fromDegrees(...lonLat),
3797
+ position: Cesium$b.Cartesian3.fromDegrees(...lonLat),
3768
3798
  point: {
3769
- color: Cesium$a.Color.YELLOW,
3799
+ color: Cesium$b.Color.YELLOW,
3770
3800
  pixelSize: 10
3771
3801
  }
3772
3802
  });
@@ -3788,14 +3818,14 @@ class DrawTool extends BaseTool {
3788
3818
  for (const c of previewPositions) {
3789
3819
  flatCoords.push(c[0], c[1], c[2] || 0);
3790
3820
  }
3791
- const cartesians = Cesium$a.Cartesian3.fromDegreesArrayHeights(flatCoords);
3821
+ const cartesians = Cesium$b.Cartesian3.fromDegreesArrayHeights(flatCoords);
3792
3822
 
3793
3823
  if (!this._previewLine) {
3794
3824
  // 首次创建预览线
3795
3825
  this._previewLine = this.createTempEntity(this.generateId('temp_line'), {
3796
3826
  polyline: {
3797
3827
  positions: cartesians,
3798
- material: Cesium$a.Color.YELLOW,
3828
+ material: Cesium$b.Color.YELLOW,
3799
3829
  width: 2
3800
3830
  }
3801
3831
  });
@@ -3803,7 +3833,7 @@ class DrawTool extends BaseTool {
3803
3833
  } else {
3804
3834
  // 直接更新位置属性,避免重建实体
3805
3835
  // this._previewLine.polyline.positions = cartesians;
3806
- this._previewLine.polyline.positions = new Cesium$a.CallbackProperty(() => {
3836
+ this._previewLine.polyline.positions = new Cesium$b.CallbackProperty(() => {
3807
3837
  return cartesians;
3808
3838
  }, false);
3809
3839
  }
@@ -3823,23 +3853,23 @@ class DrawTool extends BaseTool {
3823
3853
  for (const c of previewPositions) {
3824
3854
  flatCoords.push(c[0], c[1], c[2] || 0);
3825
3855
  }
3826
- const cartesians = Cesium$a.Cartesian3.fromDegreesArrayHeights(flatCoords);
3856
+ const cartesians = Cesium$b.Cartesian3.fromDegreesArrayHeights(flatCoords);
3827
3857
 
3828
3858
  if (!this._previewPolygon) {
3829
3859
  // 首次创建预览面
3830
3860
  this._previewPolygon = this.createTempEntity(this.generateId('temp_polygon'), {
3831
3861
  polygon: {
3832
- hierarchy: new Cesium$a.PolygonHierarchy(cartesians),
3833
- material: Cesium$a.Color.YELLOW.withAlpha(0.5),
3862
+ hierarchy: new Cesium$b.PolygonHierarchy(cartesians),
3863
+ material: Cesium$b.Color.YELLOW.withAlpha(0.5),
3834
3864
  outline: false,
3835
- outlineColor: Cesium$a.Color.YELLOW,
3865
+ outlineColor: Cesium$b.Color.YELLOW,
3836
3866
  }
3837
3867
  });
3838
3868
  this._tempEntities.push(this._previewPolygon);
3839
3869
  } else {
3840
3870
  // 直接更新层级,避免重建实体,使用 CallbackProperty 防止闪烁
3841
- this._previewPolygon.polygon.hierarchy = new Cesium$a.CallbackProperty(() => {
3842
- return new Cesium$a.PolygonHierarchy(cartesians);
3871
+ this._previewPolygon.polygon.hierarchy = new Cesium$b.CallbackProperty(() => {
3872
+ return new Cesium$b.PolygonHierarchy(cartesians);
3843
3873
  }, false);
3844
3874
  }
3845
3875
  }
@@ -3871,18 +3901,18 @@ class DrawTool extends BaseTool {
3871
3901
  for (const c of positions) {
3872
3902
  flatCoords.push(c[0], c[1], 0);
3873
3903
  }
3874
- const cartesians = Cesium$a.Cartesian3.fromDegreesArrayHeights(flatCoords);
3904
+ const cartesians = Cesium$b.Cartesian3.fromDegreesArrayHeights(flatCoords);
3875
3905
 
3876
3906
  if (!this._previewRect) {
3877
3907
  this._previewRect = this.createTempEntity(this.generateId('temp_rect'), {
3878
3908
  polyline: {
3879
- positions: new Cesium$a.CallbackProperty(() => cartesians, false),
3880
- material: Cesium$a.Color.YELLOW.withAlpha(0.7),
3909
+ positions: new Cesium$b.CallbackProperty(() => cartesians, false),
3910
+ material: Cesium$b.Color.YELLOW.withAlpha(0.7),
3881
3911
  width: 2
3882
3912
  },
3883
3913
  polygon: {
3884
- hierarchy: new Cesium$a.CallbackProperty(() => new Cesium$a.PolygonHierarchy(cartesians), false),
3885
- material: Cesium$a.Color.YELLOW.withAlpha(0.2),
3914
+ hierarchy: new Cesium$b.CallbackProperty(() => new Cesium$b.PolygonHierarchy(cartesians), false),
3915
+ material: Cesium$b.Color.YELLOW.withAlpha(0.2),
3886
3916
  outline: false
3887
3917
  }
3888
3918
  });
@@ -3890,7 +3920,7 @@ class DrawTool extends BaseTool {
3890
3920
  this._tempEntities.push(this._previewRect);
3891
3921
  } else {
3892
3922
  // 直接更新位置属性
3893
- this._previewRect.polyline.positions = new Cesium$a.CallbackProperty(() => {
3923
+ this._previewRect.polyline.positions = new Cesium$b.CallbackProperty(() => {
3894
3924
  const c1 = this._startPos;
3895
3925
  const c2 = this._currentMousePos;
3896
3926
  if (!c1 || !c2) return cartesians;
@@ -3905,12 +3935,12 @@ class DrawTool extends BaseTool {
3905
3935
  for (const p of pos) {
3906
3936
  flat.push(p[0], p[1], 0);
3907
3937
  }
3908
- return Cesium$a.Cartesian3.fromDegreesArrayHeights(flat);
3938
+ return Cesium$b.Cartesian3.fromDegreesArrayHeights(flat);
3909
3939
  }, false);
3910
- this._previewRect.polygon.hierarchy = new Cesium$a.CallbackProperty(() => {
3940
+ this._previewRect.polygon.hierarchy = new Cesium$b.CallbackProperty(() => {
3911
3941
  const c1 = this._startPos;
3912
3942
  const c2 = this._currentMousePos;
3913
- if (!c1 || !c2) return new Cesium$a.PolygonHierarchy(cartesians);
3943
+ if (!c1 || !c2) return new Cesium$b.PolygonHierarchy(cartesians);
3914
3944
  const pos = [
3915
3945
  [c1[0], c1[1]],
3916
3946
  [c2[0], c1[1]],
@@ -3922,7 +3952,7 @@ class DrawTool extends BaseTool {
3922
3952
  for (const p of pos) {
3923
3953
  flat.push(p[0], p[1], 0);
3924
3954
  }
3925
- return new Cesium$a.PolygonHierarchy(Cesium$a.Cartesian3.fromDegreesArrayHeights(flat));
3955
+ return new Cesium$b.PolygonHierarchy(Cesium$b.Cartesian3.fromDegreesArrayHeights(flat));
3926
3956
  }, false);
3927
3957
  }
3928
3958
  }
@@ -3935,12 +3965,12 @@ class DrawTool extends BaseTool {
3935
3965
  if (!this._previewCircle) {
3936
3966
  this._previewCircle = this.createTempEntity(this.generateId('temp_circle'), {
3937
3967
  polygon: {
3938
- hierarchy: new Cesium$a.CallbackProperty(() => {
3968
+ hierarchy: new Cesium$b.CallbackProperty(() => {
3939
3969
  const positions = this._generateCirclePositions(center, radius, segments);
3940
3970
  const flat = positions.flatMap(c => [c[0], c[1], 0]);
3941
- return new Cesium$a.PolygonHierarchy(Cesium$a.Cartesian3.fromDegreesArrayHeights(flat));
3971
+ return new Cesium$b.PolygonHierarchy(Cesium$b.Cartesian3.fromDegreesArrayHeights(flat));
3942
3972
  }, false),
3943
- material: Cesium$a.Color.YELLOW.withAlpha(0.2),
3973
+ material: Cesium$b.Color.YELLOW.withAlpha(0.2),
3944
3974
  outline: false // 地形贴合时不支持 outline,设为 false 避免警告
3945
3975
  }
3946
3976
  });
@@ -3948,11 +3978,11 @@ class DrawTool extends BaseTool {
3948
3978
  this._tempEntities.push(this._previewCircle);
3949
3979
  } else {
3950
3980
  // 直接更新
3951
- this._previewCircle.polygon.hierarchy = new Cesium$a.CallbackProperty(() => {
3981
+ this._previewCircle.polygon.hierarchy = new Cesium$b.CallbackProperty(() => {
3952
3982
  const r = this._calcDistance(this._startPos, this._currentMousePos);
3953
3983
  const pos = this._generateCirclePositions(this._startPos, r, 64);
3954
3984
  const flat = pos.flatMap(c => [c[0], c[1], 0]);
3955
- return new Cesium$a.PolygonHierarchy(Cesium$a.Cartesian3.fromDegreesArrayHeights(flat));
3985
+ return new Cesium$b.PolygonHierarchy(Cesium$b.Cartesian3.fromDegreesArrayHeights(flat));
3956
3986
  }, false);
3957
3987
  }
3958
3988
  }
@@ -3969,10 +3999,10 @@ class DrawTool extends BaseTool {
3969
3999
  const id = this.generateId('rectangle');
3970
4000
  this._graphicModule.CreatePolygon(id)
3971
4001
  .setPositions(positions)
3972
- .setColor(Cesium$a.Color.BLUE.withAlpha(0.5))
3973
- .setOutlineColor(Cesium$a.Color.BLUE)
4002
+ .setColor(Cesium$b.Color.BLUE.withAlpha(0.5))
4003
+ .setOutlineColor(Cesium$b.Color.BLUE)
3974
4004
  .setOutlineWidth(2)
3975
- .setHeightReference(Cesium$a.HeightReference.NONE);
4005
+ .setHeightReference(Cesium$b.HeightReference.NONE);
3976
4006
 
3977
4007
  this.clearTempEntities();
3978
4008
  this._startPos = null;
@@ -3990,8 +4020,8 @@ class DrawTool extends BaseTool {
3990
4020
  // 创建圆并标记为圆形
3991
4021
  const wrapper = this._graphicModule.CreatePolygon(id);
3992
4022
  wrapper.setPositions(positions)
3993
- .setColor(Cesium$a.Color.BLUE.withAlpha(0.5))
3994
- .setOutlineColor(Cesium$a.Color.BLUE)
4023
+ .setColor(Cesium$b.Color.BLUE.withAlpha(0.5))
4024
+ .setOutlineColor(Cesium$b.Color.BLUE)
3995
4025
  .setOutlineWidth(2);
3996
4026
 
3997
4027
  // 给 entity 添加圆形标记(用于 EditTool 特殊处理)
@@ -4088,9 +4118,9 @@ class DrawTool extends BaseTool {
4088
4118
 
4089
4119
  // 创建辅助点
4090
4120
  const tempPoint = this.createTempEntity(this.generateId('temp_point'), {
4091
- position: Cesium$a.Cartesian3.fromDegrees(...lngLat),
4121
+ position: Cesium$b.Cartesian3.fromDegrees(...lngLat),
4092
4122
  point: {
4093
- color: Cesium$a.Color.YELLOW,
4123
+ color: Cesium$b.Color.YELLOW,
4094
4124
  pixelSize: 8
4095
4125
  }
4096
4126
  });
@@ -4145,27 +4175,28 @@ class DrawTool extends BaseTool {
4145
4175
  for (const c of positions) {
4146
4176
  flatCoords.push(c[0], c[1], c[2] || 0);
4147
4177
  }
4148
- const cartesians = Cesium$a.Cartesian3.fromDegreesArrayHeights(flatCoords);
4178
+ const cartesians = Cesium$b.Cartesian3.fromDegreesArrayHeights(flatCoords);
4149
4179
 
4150
4180
  if (!this._previewPlot) {
4151
4181
  if (isLine) {
4152
4182
  this._previewPlot = this.createTempEntity(this.generateId('temp_plot'), {
4153
4183
  polyline: {
4154
- positions: new Cesium$a.CallbackProperty(() => cartesians, false),
4155
- material: Cesium$a.Color.YELLOW,
4156
- width: 2
4184
+ positions: new Cesium$b.CallbackProperty(() => cartesians, false),
4185
+ material: Cesium$b.Color.YELLOW,
4186
+ width: 2,
4187
+ clampToGround: true
4157
4188
  }
4158
4189
  });
4159
4190
  } else {
4160
4191
  this._previewPlot = this.createTempEntity(this.generateId('temp_plot'), {
4161
4192
  polygon: {
4162
- hierarchy: new Cesium$a.CallbackProperty(() => new Cesium$a.PolygonHierarchy(cartesians), false),
4163
- material: Cesium$a.Color.YELLOW.withAlpha(0.3),
4193
+ hierarchy: new Cesium$b.CallbackProperty(() => new Cesium$b.PolygonHierarchy(cartesians), false),
4194
+ material: Cesium$b.Color.YELLOW.withAlpha(0.3),
4164
4195
  outline: false
4165
4196
  },
4166
4197
  polyline: {
4167
- positions: new Cesium$a.CallbackProperty(() => [...cartesians, cartesians[0]], false),
4168
- material: Cesium$a.Color.YELLOW,
4198
+ positions: new Cesium$b.CallbackProperty(() => [...cartesians, cartesians[0]], false),
4199
+ material: Cesium$b.Color.YELLOW,
4169
4200
  width: 1
4170
4201
  }
4171
4202
  });
@@ -4175,7 +4206,7 @@ class DrawTool extends BaseTool {
4175
4206
  } else {
4176
4207
  const self = this;
4177
4208
  if (isLine) {
4178
- this._previewPlot.polyline.positions = new Cesium$a.CallbackProperty(() => {
4209
+ this._previewPlot.polyline.positions = new Cesium$b.CallbackProperty(() => {
4179
4210
  const dynamicPositions = [...self._tempPositions];
4180
4211
  if (self._currentMousePos) {
4181
4212
  dynamicPositions.push(self._currentMousePos);
@@ -4186,23 +4217,23 @@ class DrawTool extends BaseTool {
4186
4217
  for (const c of pos) {
4187
4218
  flat.push(c[0], c[1], c[2] || 0);
4188
4219
  }
4189
- return Cesium$a.Cartesian3.fromDegreesArrayHeights(flat);
4220
+ return Cesium$b.Cartesian3.fromDegreesArrayHeights(flat);
4190
4221
  }, false);
4191
4222
  } else {
4192
- this._previewPlot.polygon.hierarchy = new Cesium$a.CallbackProperty(() => {
4223
+ this._previewPlot.polygon.hierarchy = new Cesium$b.CallbackProperty(() => {
4193
4224
  const dynamicPositions = [...self._tempPositions];
4194
4225
  if (self._currentMousePos) {
4195
4226
  dynamicPositions.push(self._currentMousePos);
4196
4227
  }
4197
- if (dynamicPositions.length < config.minPoints) return new Cesium$a.PolygonHierarchy([]);
4228
+ if (dynamicPositions.length < config.minPoints) return new Cesium$b.PolygonHierarchy([]);
4198
4229
  const pos = PlotGeometryUtil[factoryName](normalizeForEllipse(dynamicPositions));
4199
4230
  const flat = [];
4200
4231
  for (const c of pos) {
4201
4232
  flat.push(c[0], c[1], c[2] || 0);
4202
4233
  }
4203
- return new Cesium$a.PolygonHierarchy(Cesium$a.Cartesian3.fromDegreesArrayHeights(flat));
4234
+ return new Cesium$b.PolygonHierarchy(Cesium$b.Cartesian3.fromDegreesArrayHeights(flat));
4204
4235
  }, false);
4205
- this._previewPlot.polyline.positions = new Cesium$a.CallbackProperty(() => {
4236
+ this._previewPlot.polyline.positions = new Cesium$b.CallbackProperty(() => {
4206
4237
  const dynamicPositions = [...self._tempPositions];
4207
4238
  if (self._currentMousePos) {
4208
4239
  dynamicPositions.push(self._currentMousePos);
@@ -4213,7 +4244,7 @@ class DrawTool extends BaseTool {
4213
4244
  for (const c of pos) {
4214
4245
  flat.push(c[0], c[1], c[2] || 0);
4215
4246
  }
4216
- const cart = Cesium$a.Cartesian3.fromDegreesArrayHeights(flat);
4247
+ const cart = Cesium$b.Cartesian3.fromDegreesArrayHeights(flat);
4217
4248
  return [...cart, cart[0]];
4218
4249
  }, false);
4219
4250
  }
@@ -4250,11 +4281,11 @@ class DrawTool extends BaseTool {
4250
4281
 
4251
4282
  // 应用默认样式
4252
4283
  if (isLine) {
4253
- wrapper.setColor(Cesium$a.Color.BLUE).setWidth(2);
4284
+ wrapper.setColor(Cesium$b.Color.BLUE).setWidth(2);
4254
4285
  } else {
4255
4286
  wrapper
4256
- .setColor(Cesium$a.Color.BLUE.withAlpha(0.5))
4257
- .setOutlineColor(Cesium$a.Color.BLUE)
4287
+ .setColor(Cesium$b.Color.BLUE.withAlpha(0.5))
4288
+ .setOutlineColor(Cesium$b.Color.BLUE)
4258
4289
  .setOutlineWidth(2);
4259
4290
  }
4260
4291
 
@@ -4307,7 +4338,7 @@ class DrawTool extends BaseTool {
4307
4338
  const id = this.generateId('line');
4308
4339
  this._graphicModule.CreateLine(id)
4309
4340
  .setPositions(this._tempPositions)
4310
- .setColor(Cesium$a.Color.BLUE)
4341
+ .setColor(Cesium$b.Color.BLUE)
4311
4342
  .setWidth(2);
4312
4343
 
4313
4344
  this._emitGraphicCreated('line', id);
@@ -4316,17 +4347,38 @@ class DrawTool extends BaseTool {
4316
4347
  const id = this.generateId('polygon');
4317
4348
  this._graphicModule.CreatePolygon(id)
4318
4349
  .setPositions(positions)
4319
- .setColor(Cesium$a.Color.BLUE.withAlpha(0.5))
4320
- .setOutlineColor(Cesium$a.Color.BLUE);
4350
+ .setColor(Cesium$b.Color.BLUE.withAlpha(0.5))
4351
+ .setOutlineColor(Cesium$b.Color.BLUE);
4321
4352
 
4322
4353
  this._emitGraphicCreated('polygon', id);
4323
4354
  }
4324
4355
 
4356
+ // 线绘制结束时,把预览线样式切为最终样式并延迟一帧移除,
4357
+ // 避免新线图元异步初始化期间出现“预览线消失 -> 正式线出现”的闪烁
4358
+ let deferredPreviewLine = null;
4359
+ if (this._drawType === DrawType.LINE && this._previewLine) {
4360
+ const previewLine = this._previewLine;
4361
+ previewLine.polyline.material = Cesium$b.Color.BLUE;
4362
+ previewLine.polyline.width = 2;
4363
+ previewLine.polyline.positions = Cesium$b.Cartesian3.fromDegreesArrayHeights(
4364
+ this._tempPositions.flatMap((coord) => [coord[0], coord[1], coord[2] || 0])
4365
+ );
4366
+
4367
+ const idx = this._tempEntities.indexOf(previewLine);
4368
+ if (idx > -1) this._tempEntities.splice(idx, 1);
4369
+ this._previewLine = null;
4370
+ deferredPreviewLine = previewLine;
4371
+ }
4372
+
4325
4373
  this.clearTempEntities();
4326
4374
  this._tempPositions = [];
4327
4375
  this._isDrawing = false;
4328
4376
  this._clickCount = 0;
4329
4377
  this._currentMousePos = null;
4378
+
4379
+ if (deferredPreviewLine) {
4380
+ requestAnimationFrame(() => this.removeTempEntity(deferredPreviewLine));
4381
+ }
4330
4382
  }
4331
4383
 
4332
4384
  /**
@@ -4364,7 +4416,7 @@ class DrawTool extends BaseTool {
4364
4416
  }
4365
4417
  }
4366
4418
 
4367
- const Cesium$9 = getCesium();
4419
+ const Cesium$a = getCesium();
4368
4420
 
4369
4421
  /**
4370
4422
  * 编辑模式枚举
@@ -4449,7 +4501,7 @@ class EditTool extends BaseTool {
4449
4501
  const picked = this._viewer.scene.pick(screenPos);
4450
4502
  console.log('EditTool _onClick:', { picked, screenPos });
4451
4503
 
4452
- if (Cesium$9.defined(picked) && Cesium$9.defined(picked.id)) {
4504
+ if (Cesium$a.defined(picked) && Cesium$a.defined(picked.id)) {
4453
4505
  const entityId = picked.id.id;
4454
4506
  console.log('EditTool picked entity:', entityId);
4455
4507
 
@@ -4485,7 +4537,7 @@ class EditTool extends BaseTool {
4485
4537
  // 如果已经选中了图元,检查是否点击了控制点
4486
4538
  if (this._selectedEntity && !this._isDragging) {
4487
4539
  const picked = this._viewer.scene.pick(screenPos);
4488
- if (Cesium$9.defined(picked) && Cesium$9.defined(picked.id)) {
4540
+ if (Cesium$a.defined(picked) && Cesium$a.defined(picked.id)) {
4489
4541
  const entityId = picked.id.id;
4490
4542
  if (entityId && (entityId.startsWith('__edit_handle_') || entityId.includes('__edit_handle_'))) {
4491
4543
  // 直接在 _editHandles 中查找被点击的控制点
@@ -4538,7 +4590,7 @@ class EditTool extends BaseTool {
4538
4590
 
4539
4591
  // 检测是否悬停在控制点上
4540
4592
  const picked = this._viewer.scene.pick(screenPos);
4541
- const isOverHandle = Cesium$9.defined(picked) && Cesium$9.defined(picked.id) &&
4593
+ const isOverHandle = Cesium$a.defined(picked) && Cesium$a.defined(picked.id) &&
4542
4594
  picked.id.id && picked.id.id.startsWith('__edit_handle_');
4543
4595
  this._setCursorStyle(isOverHandle ? 'move' : 'default');
4544
4596
  }
@@ -4549,14 +4601,14 @@ class EditTool extends BaseTool {
4549
4601
  // 拖拽时优先使用椭球面拾取,避免拾取到控制点句柄本身导致图元跟随滞后
4550
4602
  let lonLat = null;
4551
4603
  const cartesian = this._viewer.camera.pickEllipsoid(
4552
- new Cesium$9.Cartesian2(screenPos.x, screenPos.y),
4604
+ new Cesium$a.Cartesian2(screenPos.x, screenPos.y),
4553
4605
  this._viewer.scene.globe.ellipsoid
4554
4606
  );
4555
4607
  if (cartesian) {
4556
- const c = Cesium$9.Cartographic.fromCartesian(cartesian);
4608
+ const c = Cesium$a.Cartographic.fromCartesian(cartesian);
4557
4609
  lonLat = [
4558
- Cesium$9.Math.toDegrees(c.longitude),
4559
- Cesium$9.Math.toDegrees(c.latitude),
4610
+ Cesium$a.Math.toDegrees(c.longitude),
4611
+ Cesium$a.Math.toDegrees(c.latitude),
4560
4612
  c.height || 0
4561
4613
  ];
4562
4614
  } else {
@@ -4580,16 +4632,16 @@ class EditTool extends BaseTool {
4580
4632
  const deltaZ = newAnchorCartesian.z - oldAnchorCartesian.z;
4581
4633
 
4582
4634
  const controlPoints = this._selectedEntity._controlPoints.map(cp => {
4583
- const cpCart = Cesium$9.Cartesian3.fromDegrees(cp[0], cp[1], cp[2] || 0);
4584
- const newCpCart = new Cesium$9.Cartesian3(
4635
+ const cpCart = Cesium$a.Cartesian3.fromDegrees(cp[0], cp[1], cp[2] || 0);
4636
+ const newCpCart = new Cesium$a.Cartesian3(
4585
4637
  cpCart.x + deltaX,
4586
4638
  cpCart.y + deltaY,
4587
4639
  cpCart.z + deltaZ
4588
4640
  );
4589
- const newCpCarto = Cesium$9.Cartographic.fromCartesian(newCpCart);
4641
+ const newCpCarto = Cesium$a.Cartographic.fromCartesian(newCpCart);
4590
4642
  return [
4591
- Cesium$9.Math.toDegrees(newCpCarto.longitude),
4592
- Cesium$9.Math.toDegrees(newCpCarto.latitude),
4643
+ Cesium$a.Math.toDegrees(newCpCarto.longitude),
4644
+ Cesium$a.Math.toDegrees(newCpCarto.latitude),
4593
4645
  newCpCarto.height || 0
4594
4646
  ];
4595
4647
  });
@@ -4610,8 +4662,8 @@ class EditTool extends BaseTool {
4610
4662
  const center = (plotType === PlotGraphicType.SECTOR || plotType === PlotGraphicType.ELLIPSE)
4611
4663
  ? controlPoints[0]
4612
4664
  : this._getPlotControlPointsCenter(controlPoints);
4613
- handle.position = new Cesium$9.ConstantPositionProperty(
4614
- this._clampPositionToGround(Cesium$9.Cartesian3.fromDegrees(center[0], center[1], center[2] || 0))
4665
+ handle.position = new Cesium$a.ConstantPositionProperty(
4666
+ this._clampPositionToGround(Cesium$a.Cartesian3.fromDegrees(center[0], center[1], center[2] || 0))
4615
4667
  );
4616
4668
  return;
4617
4669
  }
@@ -4620,8 +4672,8 @@ class EditTool extends BaseTool {
4620
4672
  if (match) {
4621
4673
  const cpIndex = parseInt(match[1], 10);
4622
4674
  const cp = controlPoints[cpIndex];
4623
- handle.position = new Cesium$9.ConstantPositionProperty(
4624
- this._clampPositionToGround(Cesium$9.Cartesian3.fromDegrees(cp[0], cp[1], cp[2] || 0))
4675
+ handle.position = new Cesium$a.ConstantPositionProperty(
4676
+ this._clampPositionToGround(Cesium$a.Cartesian3.fromDegrees(cp[0], cp[1], cp[2] || 0))
4625
4677
  );
4626
4678
  }
4627
4679
  });
@@ -4689,10 +4741,10 @@ class EditTool extends BaseTool {
4689
4741
  */
4690
4742
  _clampPositionToGround(position) {
4691
4743
  if (!position) return position;
4692
- const cartographic = Cesium$9.Cartographic.fromCartesian(position);
4693
- return Cesium$9.Cartesian3.fromDegrees(
4694
- Cesium$9.Math.toDegrees(cartographic.longitude),
4695
- Cesium$9.Math.toDegrees(cartographic.latitude),
4744
+ const cartographic = Cesium$a.Cartographic.fromCartesian(position);
4745
+ return Cesium$a.Cartesian3.fromDegrees(
4746
+ Cesium$a.Math.toDegrees(cartographic.longitude),
4747
+ Cesium$a.Math.toDegrees(cartographic.latitude),
4696
4748
  0
4697
4749
  );
4698
4750
  }
@@ -4714,17 +4766,17 @@ class EditTool extends BaseTool {
4714
4766
  if ((isSector || isEllipse) && index === 0) return; // 扇形/椭圆圆心/中心由中心控制点处理
4715
4767
 
4716
4768
  const clampedPos = this._clampPositionToGround(
4717
- Cesium$9.Cartesian3.fromDegrees(cp[0], cp[1], cp[2] || 0)
4769
+ Cesium$a.Cartesian3.fromDegrees(cp[0], cp[1], cp[2] || 0)
4718
4770
  );
4719
4771
  const handle = this.createTempEntity(`__edit_handle_${index}`, {
4720
4772
  position: clampedPos,
4721
4773
  point: {
4722
- color: Cesium$9.Color.YELLOW,
4774
+ color: Cesium$a.Color.YELLOW,
4723
4775
  pixelSize: 12,
4724
- outlineColor: Cesium$9.Color.RED,
4776
+ outlineColor: Cesium$a.Color.RED,
4725
4777
  outlineWidth: 2,
4726
4778
  disableDepthTestDistance: Number.POSITIVE_INFINITY,
4727
- heightReference: Cesium$9.HeightReference.CLAMP_TO_GROUND
4779
+ heightReference: Cesium$a.HeightReference.CLAMP_TO_GROUND
4728
4780
  }
4729
4781
  });
4730
4782
  this._editHandles.push(handle);
@@ -4761,18 +4813,18 @@ class EditTool extends BaseTool {
4761
4813
  if (!center) return;
4762
4814
 
4763
4815
  this._originalEntityCenter = this._clampPositionToGround(
4764
- Cesium$9.Cartesian3.fromDegrees(center[0], center[1], center[2] || 0)
4816
+ Cesium$a.Cartesian3.fromDegrees(center[0], center[1], center[2] || 0)
4765
4817
  );
4766
4818
 
4767
4819
  const handle = this.createTempEntity('__edit_handle_center_plot', {
4768
4820
  position: this._originalEntityCenter,
4769
4821
  point: {
4770
- color: Cesium$9.Color.CYAN,
4822
+ color: Cesium$a.Color.CYAN,
4771
4823
  pixelSize: 14,
4772
- outlineColor: Cesium$9.Color.BLUE,
4824
+ outlineColor: Cesium$a.Color.BLUE,
4773
4825
  outlineWidth: 2,
4774
4826
  disableDepthTestDistance: Number.POSITIVE_INFINITY,
4775
- heightReference: Cesium$9.HeightReference.CLAMP_TO_GROUND
4827
+ heightReference: Cesium$a.HeightReference.CLAMP_TO_GROUND
4776
4828
  }
4777
4829
  });
4778
4830
  this._editHandles.push(handle);
@@ -4800,7 +4852,7 @@ class EditTool extends BaseTool {
4800
4852
  _createPlotPositionOutline() {
4801
4853
  const self = this;
4802
4854
  const entity = this._selectedEntity;
4803
- const isLine = Cesium$9.defined(entity.polyline);
4855
+ const isLine = Cesium$a.defined(entity.polyline);
4804
4856
 
4805
4857
  // 以下标绘图元的控制点连线会干扰真实几何,不绘制轮廓辅助线
4806
4858
  const skipOutlineTypes = new Set([
@@ -4817,7 +4869,7 @@ class EditTool extends BaseTool {
4817
4869
 
4818
4870
  this._positionOutline = this.createTempEntity(this.generateId('temp_plot_outline'), {
4819
4871
  polyline: {
4820
- positions: new Cesium$9.CallbackProperty(function () {
4872
+ positions: new Cesium$a.CallbackProperty(function () {
4821
4873
  const handles = self._editHandles;
4822
4874
  if (!handles || handles.length === 0) return [];
4823
4875
 
@@ -4832,7 +4884,7 @@ class EditTool extends BaseTool {
4832
4884
  let positions = null;
4833
4885
  if (hierarchy) {
4834
4886
  if (typeof hierarchy.getValue === 'function') {
4835
- const value = hierarchy.getValue(Cesium$9.JulianDate.now());
4887
+ const value = hierarchy.getValue(Cesium$a.JulianDate.now());
4836
4888
  positions = value ? value.positions : null;
4837
4889
  } else if (hierarchy.positions) {
4838
4890
  positions = hierarchy.positions;
@@ -4852,24 +4904,24 @@ class EditTool extends BaseTool {
4852
4904
  // 跳过中心平移控制点
4853
4905
  if (handle.id && handle.id.includes('center')) return;
4854
4906
 
4855
- const pos = handle.position.getValue(Cesium$9.JulianDate.now());
4907
+ const pos = handle.position.getValue(Cesium$a.JulianDate.now());
4856
4908
  if (pos) {
4857
- const c = Cesium$9.Cartographic.fromCartesian(pos);
4858
- degrees.push(Cesium$9.Math.toDegrees(c.longitude));
4859
- degrees.push(Cesium$9.Math.toDegrees(c.latitude));
4909
+ const c = Cesium$a.Cartographic.fromCartesian(pos);
4910
+ degrees.push(Cesium$a.Math.toDegrees(c.longitude));
4911
+ degrees.push(Cesium$a.Math.toDegrees(c.latitude));
4860
4912
  degrees.push(c.height || 0);
4861
4913
  }
4862
4914
  });
4863
4915
 
4864
4916
  if (degrees.length === 0) return [];
4865
4917
 
4866
- const cartesians = Cesium$9.Cartesian3.fromDegreesArrayHeights(degrees);
4918
+ const cartesians = Cesium$a.Cartesian3.fromDegreesArrayHeights(degrees);
4867
4919
  if (isLine) {
4868
4920
  return cartesians;
4869
4921
  }
4870
4922
  return [...cartesians, cartesians[0]];
4871
4923
  }, false),
4872
- material: Cesium$9.Color.YELLOW,
4924
+ material: Cesium$a.Color.YELLOW,
4873
4925
  width: 2,
4874
4926
  clampToGround: true
4875
4927
  }
@@ -4885,17 +4937,17 @@ class EditTool extends BaseTool {
4885
4937
  const self = this;
4886
4938
  const axisLine = this.createTempEntity(this.generateId('temp_ellipse_axis'), {
4887
4939
  polyline: {
4888
- positions: new Cesium$9.CallbackProperty(function () {
4940
+ positions: new Cesium$a.CallbackProperty(function () {
4889
4941
  const entity = self._selectedEntity;
4890
4942
  const cps = entity?._controlPoints;
4891
4943
  if (!cps || cps.length < 3) return [];
4892
4944
 
4893
- const center = Cesium$9.Cartesian3.fromDegrees(cps[0][0], cps[0][1], cps[0][2] || 0);
4894
- const major = Cesium$9.Cartesian3.fromDegrees(cps[1][0], cps[1][1], cps[1][2] || 0);
4895
- const minor = Cesium$9.Cartesian3.fromDegrees(cps[2][0], cps[2][1], cps[2][2] || 0);
4945
+ const center = Cesium$a.Cartesian3.fromDegrees(cps[0][0], cps[0][1], cps[0][2] || 0);
4946
+ const major = Cesium$a.Cartesian3.fromDegrees(cps[1][0], cps[1][1], cps[1][2] || 0);
4947
+ const minor = Cesium$a.Cartesian3.fromDegrees(cps[2][0], cps[2][1], cps[2][2] || 0);
4896
4948
  return [center, major, center, minor];
4897
4949
  }, false),
4898
- material: Cesium$9.Color.YELLOW,
4950
+ material: Cesium$a.Color.YELLOW,
4899
4951
  width: 2,
4900
4952
  clampToGround: true
4901
4953
  }
@@ -4910,7 +4962,7 @@ class EditTool extends BaseTool {
4910
4962
  */
4911
4963
  _createVertexHandles(positions) {
4912
4964
  // 判断是否是矩形(4个顶点形成矩形)
4913
- const isRectangle = Cesium$9.defined(this._selectedEntity.polygon) && positions.length === 4 &&
4965
+ const isRectangle = Cesium$a.defined(this._selectedEntity.polygon) && positions.length === 4 &&
4914
4966
  this._isRectangle(positions);
4915
4967
 
4916
4968
  if (isRectangle) {
@@ -4924,12 +4976,12 @@ class EditTool extends BaseTool {
4924
4976
  const handle = this.createTempEntity(`__edit_handle_${handleIdx}`, {
4925
4977
  position: clampedPos,
4926
4978
  point: {
4927
- color: Cesium$9.Color.YELLOW,
4979
+ color: Cesium$a.Color.YELLOW,
4928
4980
  pixelSize: 12,
4929
- outlineColor: Cesium$9.Color.RED,
4981
+ outlineColor: Cesium$a.Color.RED,
4930
4982
  outlineWidth: 2,
4931
4983
  disableDepthTestDistance: Number.POSITIVE_INFINITY,
4932
- heightReference: Cesium$9.HeightReference.CLAMP_TO_GROUND,
4984
+ heightReference: Cesium$a.HeightReference.CLAMP_TO_GROUND,
4933
4985
  }
4934
4986
  });
4935
4987
  this._editHandles.push(handle);
@@ -4942,20 +4994,20 @@ class EditTool extends BaseTool {
4942
4994
 
4943
4995
  const { center, radius } = circleInfo;
4944
4996
  // 修复:圆心位置贴地
4945
- const centerCartesian = Cesium$9.Cartesian3.fromDegrees(center[0], center[1], 0);
4997
+ const centerCartesian = Cesium$a.Cartesian3.fromDegrees(center[0], center[1], 0);
4946
4998
  const radiusPoint = this._getPointOnCircle(center, radius, 0);
4947
- const radiusCartesian = Cesium$9.Cartesian3.fromDegrees(radiusPoint[0], radiusPoint[1], 0);
4999
+ const radiusCartesian = Cesium$a.Cartesian3.fromDegrees(radiusPoint[0], radiusPoint[1], 0);
4948
5000
 
4949
5001
  // 圆心控制点(可平移)- 使用与其他类型不同的ID格式
4950
5002
  const centerHandle = this.createTempEntity('__edit_handle_center', {
4951
5003
  position: centerCartesian,
4952
5004
  point: {
4953
- color: Cesium$9.Color.CYAN,
5005
+ color: Cesium$a.Color.CYAN,
4954
5006
  pixelSize: 14,
4955
- outlineColor: Cesium$9.Color.BLUE,
5007
+ outlineColor: Cesium$a.Color.BLUE,
4956
5008
  outlineWidth: 2,
4957
5009
  disableDepthTestDistance: Number.POSITIVE_INFINITY,
4958
- heightReference: Cesium$9.HeightReference.CLAMP_TO_GROUND
5010
+ heightReference: Cesium$a.HeightReference.CLAMP_TO_GROUND
4959
5011
  }
4960
5012
  });
4961
5013
  this._editHandles.push(centerHandle);
@@ -4964,12 +5016,12 @@ class EditTool extends BaseTool {
4964
5016
  const radiusHandle = this.createTempEntity('__edit_handle_radius', {
4965
5017
  position: radiusCartesian,
4966
5018
  point: {
4967
- color: Cesium$9.Color.RED,
5019
+ color: Cesium$a.Color.RED,
4968
5020
  pixelSize: 12,
4969
- outlineColor: Cesium$9.Color.YELLOW,
5021
+ outlineColor: Cesium$a.Color.YELLOW,
4970
5022
  outlineWidth: 2,
4971
5023
  disableDepthTestDistance: Number.POSITIVE_INFINITY,
4972
- heightReference: Cesium$9.HeightReference.CLAMP_TO_GROUND
5024
+ heightReference: Cesium$a.HeightReference.CLAMP_TO_GROUND
4973
5025
  }
4974
5026
  });
4975
5027
  this._editHandles.push(radiusHandle);
@@ -4989,9 +5041,9 @@ class EditTool extends BaseTool {
4989
5041
  const handle = this.createTempEntity(`__edit_handle_${index}`, {
4990
5042
  position: clampedPos,
4991
5043
  point: {
4992
- color: Cesium$9.Color.YELLOW,
5044
+ color: Cesium$a.Color.YELLOW,
4993
5045
  pixelSize: 12,
4994
- outlineColor: Cesium$9.Color.RED,
5046
+ outlineColor: Cesium$a.Color.RED,
4995
5047
  outlineWidth: 2,
4996
5048
  disableDepthTestDistance: Number.POSITIVE_INFINITY,
4997
5049
  // heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
@@ -5031,12 +5083,12 @@ class EditTool extends BaseTool {
5031
5083
  const handle = this.createTempEntity('__edit_handle_center_vertex', {
5032
5084
  position: clampedCenter,
5033
5085
  point: {
5034
- color: Cesium$9.Color.CYAN,
5086
+ color: Cesium$a.Color.CYAN,
5035
5087
  pixelSize: 14,
5036
- outlineColor: Cesium$9.Color.BLUE,
5088
+ outlineColor: Cesium$a.Color.BLUE,
5037
5089
  outlineWidth: 2,
5038
5090
  disableDepthTestDistance: Number.POSITIVE_INFINITY,
5039
- heightReference: Cesium$9.HeightReference.CLAMP_TO_GROUND
5091
+ heightReference: Cesium$a.HeightReference.CLAMP_TO_GROUND
5040
5092
  }
5041
5093
  });
5042
5094
  this._editHandles.push(handle);
@@ -5060,7 +5112,7 @@ class EditTool extends BaseTool {
5060
5112
  const clampedCenter = this._clampPositionToGround(newCenter);
5061
5113
 
5062
5114
  // 更新中心控制点位置
5063
- centerHandle.position = new Cesium$9.ConstantPositionProperty(clampedCenter);
5115
+ centerHandle.position = new Cesium$a.ConstantPositionProperty(clampedCenter);
5064
5116
  // 更新原始中心点缓存(用于下次平移计算)
5065
5117
  this._originalEntityCenter = clampedCenter;
5066
5118
  }
@@ -5068,11 +5120,11 @@ class EditTool extends BaseTool {
5068
5120
  _createPositionOutline() {
5069
5121
  // 从控制点获取位置,性能更好(避免每次从实体重新获取和转换)
5070
5122
  const self = this;
5071
- const isPolyline = Cesium$9.defined(this._selectedEntity.polyline);
5123
+ const isPolyline = Cesium$a.defined(this._selectedEntity.polyline);
5072
5124
 
5073
5125
  this._positionOutline = this.createTempEntity(this.generateId('temp_outline'), {
5074
5126
  polyline: {
5075
- positions: new Cesium$9.CallbackProperty(function () {
5127
+ positions: new Cesium$a.CallbackProperty(function () {
5076
5128
  // 从控制点获取位置(已被更新),排除中心控制点
5077
5129
  const handles = self._editHandles;
5078
5130
  if (!handles || handles.length === 0) return [];
@@ -5083,11 +5135,11 @@ class EditTool extends BaseTool {
5083
5135
  // 跳过所有中心控制点(用于平移)- 修复:统一使用 includes('center')
5084
5136
  if (handle.id && handle.id.includes('center')) return;
5085
5137
 
5086
- const pos = handle.position.getValue(Cesium$9.JulianDate.now());
5138
+ const pos = handle.position.getValue(Cesium$a.JulianDate.now());
5087
5139
  if (pos) {
5088
- const c = Cesium$9.Cartographic.fromCartesian(pos);
5089
- degrees.push(Cesium$9.Math.toDegrees(c.longitude));
5090
- degrees.push(Cesium$9.Math.toDegrees(c.latitude));
5140
+ const c = Cesium$a.Cartographic.fromCartesian(pos);
5141
+ degrees.push(Cesium$a.Math.toDegrees(c.longitude));
5142
+ degrees.push(Cesium$a.Math.toDegrees(c.latitude));
5091
5143
  degrees.push(c.height || 0);
5092
5144
  }
5093
5145
  });
@@ -5096,12 +5148,12 @@ class EditTool extends BaseTool {
5096
5148
 
5097
5149
  // 线不闭合,面需要闭合
5098
5150
  if (isPolyline) {
5099
- return Cesium$9.Cartesian3.fromDegreesArrayHeights(degrees);
5151
+ return Cesium$a.Cartesian3.fromDegreesArrayHeights(degrees);
5100
5152
  }
5101
5153
  // 闭合多边形(首尾点相同)
5102
- return Cesium$9.Cartesian3.fromDegreesArrayHeights([...degrees, degrees[0], degrees[1], degrees[2] || 0]);
5154
+ return Cesium$a.Cartesian3.fromDegreesArrayHeights([...degrees, degrees[0], degrees[1], degrees[2] || 0]);
5103
5155
  }, false),
5104
- material: Cesium$9.Color.YELLOW,
5156
+ material: Cesium$a.Color.YELLOW,
5105
5157
  width: 2,
5106
5158
  clampToGround: true
5107
5159
  }
@@ -5133,12 +5185,12 @@ class EditTool extends BaseTool {
5133
5185
  _getEditablePositions(entity) {
5134
5186
  if (!entity) return [];
5135
5187
 
5136
- if (Cesium$9.defined(entity.polyline) && Cesium$9.defined(entity.polyline.positions)) {
5137
- return entity.polyline.positions.getValue(Cesium$9.JulianDate.now());
5188
+ if (Cesium$a.defined(entity.polyline) && Cesium$a.defined(entity.polyline.positions)) {
5189
+ return entity.polyline.positions.getValue(Cesium$a.JulianDate.now());
5138
5190
  }
5139
5191
 
5140
- if (Cesium$9.defined(entity.polygon) && Cesium$9.defined(entity.polygon.hierarchy)) {
5141
- const hierarchy = entity.polygon.hierarchy.getValue(Cesium$9.JulianDate.now());
5192
+ if (Cesium$a.defined(entity.polygon) && Cesium$a.defined(entity.polygon.hierarchy)) {
5193
+ const hierarchy = entity.polygon.hierarchy.getValue(Cesium$a.JulianDate.now());
5142
5194
  if (hierarchy && hierarchy.positions) {
5143
5195
  let positions = hierarchy.positions;
5144
5196
 
@@ -5147,7 +5199,7 @@ class EditTool extends BaseTool {
5147
5199
  const first = positions[0];
5148
5200
  const last = positions[positions.length - 1];
5149
5201
  // 使用距离判断而不是精确相等(避免浮点误差)
5150
- const distance = Cesium$9.Cartesian3.distance(first, last);
5202
+ const distance = Cesium$a.Cartesian3.distance(first, last);
5151
5203
  if (distance < EditTool.CLOSE_POINT_TOLERANCE) {
5152
5204
  positions = positions.slice(0, -1); // 移除最后一个点
5153
5205
  }
@@ -5157,8 +5209,8 @@ class EditTool extends BaseTool {
5157
5209
  }
5158
5210
  }
5159
5211
 
5160
- if (Cesium$9.defined(entity.position)) {
5161
- return [entity.position.getValue(Cesium$9.JulianDate.now())];
5212
+ if (Cesium$a.defined(entity.position)) {
5213
+ return [entity.position.getValue(Cesium$a.JulianDate.now())];
5162
5214
  }
5163
5215
 
5164
5216
  return [];
@@ -5182,7 +5234,7 @@ class EditTool extends BaseTool {
5182
5234
  z += p.z;
5183
5235
  });
5184
5236
  const count = positions.length;
5185
- return new Cesium$9.Cartesian3(x / count, y / count, z / count);
5237
+ return new Cesium$a.Cartesian3(x / count, y / count, z / count);
5186
5238
  }
5187
5239
 
5188
5240
  /**
@@ -5207,7 +5259,7 @@ class EditTool extends BaseTool {
5207
5259
  const deltaZ = clampedNewCenter.z - this._originalEntityCenter.z;
5208
5260
 
5209
5261
  // 计算真正的新中心位置(不是鼠标位置)
5210
- const actualNewCenter = new Cesium$9.Cartesian3(
5262
+ const actualNewCenter = new Cesium$a.Cartesian3(
5211
5263
  this._originalEntityCenter.x + deltaX,
5212
5264
  this._originalEntityCenter.y + deltaY,
5213
5265
  this._originalEntityCenter.z + deltaZ
@@ -5217,12 +5269,12 @@ class EditTool extends BaseTool {
5217
5269
  this._originalEntityCenter = actualNewCenter;
5218
5270
 
5219
5271
  // 更新中心控制点位置
5220
- this._dragHandle.position = new Cesium$9.ConstantPositionProperty(actualNewCenter);
5272
+ this._dragHandle.position = new Cesium$a.ConstantPositionProperty(actualNewCenter);
5221
5273
 
5222
- if (Cesium$9.defined(this._selectedEntity.polyline)) {
5274
+ if (Cesium$a.defined(this._selectedEntity.polyline)) {
5223
5275
  // 线图元:平移所有位置
5224
5276
  const newPositions = this._originalPositions.map(p => {
5225
- const newPos = new Cesium$9.Cartesian3(p.x + deltaX, p.y + deltaY, p.z + deltaZ);
5277
+ const newPos = new Cesium$a.Cartesian3(p.x + deltaX, p.y + deltaY, p.z + deltaZ);
5226
5278
  // 修复:贴地
5227
5279
  return this._clampPositionToGround(newPos);
5228
5280
  });
@@ -5240,32 +5292,32 @@ class EditTool extends BaseTool {
5240
5292
  if (match) {
5241
5293
  const index = parseInt(match[1], 10);
5242
5294
  if (newPositions[index]) {
5243
- handle.position = new Cesium$9.ConstantPositionProperty(newPositions[index]);
5295
+ handle.position = new Cesium$a.ConstantPositionProperty(newPositions[index]);
5244
5296
  }
5245
5297
  }
5246
5298
  });
5247
5299
 
5248
5300
  // 更新原始位置缓存
5249
5301
  this._originalPositions = newPositions;
5250
- } else if (Cesium$9.defined(this._selectedEntity.polygon)) {
5302
+ } else if (Cesium$a.defined(this._selectedEntity.polygon)) {
5251
5303
  if (this._isCircle(this._selectedEntity)) {
5252
5304
  // 圆形平移
5253
5305
  const oldCenter = this._selectedEntity._circleCenter; // [lon, lat]
5254
5306
 
5255
5307
  // 将旧的圆心经纬度转为 Cartesian3
5256
- const oldCenterCartesian = Cesium$9.Cartesian3.fromDegrees(oldCenter[0], oldCenter[1], 0);
5308
+ const oldCenterCartesian = Cesium$a.Cartesian3.fromDegrees(oldCenter[0], oldCenter[1], 0);
5257
5309
 
5258
5310
  // 应用偏移量计算新的 Cartesian3 位置
5259
- const newCenterCartesian = new Cesium$9.Cartesian3(
5311
+ const newCenterCartesian = new Cesium$a.Cartesian3(
5260
5312
  oldCenterCartesian.x + deltaX,
5261
5313
  oldCenterCartesian.y + deltaY,
5262
5314
  oldCenterCartesian.z + deltaZ
5263
5315
  );
5264
5316
 
5265
5317
  // 将新的 Cartesian3 转回经纬度
5266
- const newCenterCartographic = Cesium$9.Cartographic.fromCartesian(newCenterCartesian);
5267
- const newCenterLon = Cesium$9.Math.toDegrees(newCenterCartographic.longitude);
5268
- const newCenterLat = Cesium$9.Math.toDegrees(newCenterCartographic.latitude);
5318
+ const newCenterCartographic = Cesium$a.Cartographic.fromCartesian(newCenterCartesian);
5319
+ const newCenterLon = Cesium$a.Math.toDegrees(newCenterCartographic.longitude);
5320
+ const newCenterLat = Cesium$a.Math.toDegrees(newCenterCartographic.latitude);
5269
5321
 
5270
5322
  this._selectedEntity._circleCenter = [newCenterLon, newCenterLat];
5271
5323
 
@@ -5276,25 +5328,25 @@ class EditTool extends BaseTool {
5276
5328
  256
5277
5329
  );
5278
5330
  const flat = positions.flatMap(c => [c[0], c[1], 0]);
5279
- this._selectedEntity.polygon.hierarchy = new Cesium$9.PolygonHierarchy(
5280
- Cesium$9.Cartesian3.fromDegreesArrayHeights(flat)
5331
+ this._selectedEntity.polygon.hierarchy = new Cesium$a.PolygonHierarchy(
5332
+ Cesium$a.Cartesian3.fromDegreesArrayHeights(flat)
5281
5333
  );
5282
5334
 
5283
5335
  // 更新圆心控制点位置
5284
5336
  const centerHandle = this._editHandles.find(h => h.id && h.id.includes('__edit_handle_center'));
5285
5337
  if (centerHandle) {
5286
- centerHandle.position = new Cesium$9.ConstantPositionProperty(newCenterCartesian);
5338
+ centerHandle.position = new Cesium$a.ConstantPositionProperty(newCenterCartesian);
5287
5339
  }
5288
5340
  } else {
5289
5341
  // 普通多边形:平移所有顶点
5290
5342
  const newPositions = this._originalPositions.map(p => {
5291
- const newPos = new Cesium$9.Cartesian3(p.x + deltaX, p.y + deltaY, p.z + deltaZ);
5343
+ const newPos = new Cesium$a.Cartesian3(p.x + deltaX, p.y + deltaY, p.z + deltaZ);
5292
5344
  // 修复:贴地
5293
5345
  return this._clampPositionToGround(newPos);
5294
5346
  });
5295
5347
  // 添加闭合点
5296
5348
  newPositions.push(newPositions[0].clone());
5297
- this._selectedEntity.polygon.hierarchy = new Cesium$9.PolygonHierarchy(newPositions);
5349
+ this._selectedEntity.polygon.hierarchy = new Cesium$a.PolygonHierarchy(newPositions);
5298
5350
 
5299
5351
  // 修复:更新顶点控制点位置,使用更可靠的ID匹配
5300
5352
  this._editHandles.forEach((handle) => {
@@ -5307,7 +5359,7 @@ class EditTool extends BaseTool {
5307
5359
  if (match) {
5308
5360
  const index = parseInt(match[1], 10);
5309
5361
  if (newPositions[index]) {
5310
- handle.position = new Cesium$9.ConstantPositionProperty(newPositions[index]);
5362
+ handle.position = new Cesium$a.ConstantPositionProperty(newPositions[index]);
5311
5363
  }
5312
5364
  }
5313
5365
  });
@@ -5315,9 +5367,9 @@ class EditTool extends BaseTool {
5315
5367
  // 更新原始位置缓存
5316
5368
  this._originalPositions = newPositions.slice(0, -1);
5317
5369
  }
5318
- } else if (Cesium$9.defined(this._selectedEntity.position)) {
5370
+ } else if (Cesium$a.defined(this._selectedEntity.position)) {
5319
5371
  // 点/文本图元:平移位置
5320
- this._selectedEntity.position = new Cesium$9.ConstantPositionProperty(actualNewCenter);
5372
+ this._selectedEntity.position = new Cesium$a.ConstantPositionProperty(actualNewCenter);
5321
5373
  this._originalPositions = [actualNewCenter];
5322
5374
  }
5323
5375
  }
@@ -5446,16 +5498,16 @@ class EditTool extends BaseTool {
5446
5498
  // 圆周辅助线(黄色)
5447
5499
  this._positionOutline = this.createTempEntity(this.generateId('temp_circle_outline'), {
5448
5500
  polyline: {
5449
- positions: new Cesium$9.CallbackProperty(function () {
5501
+ positions: new Cesium$a.CallbackProperty(function () {
5450
5502
  const circleInfo = self._getCircleInfo(self._selectedEntity);
5451
5503
  if (!circleInfo) return [];
5452
5504
 
5453
5505
  const { center, radius } = circleInfo;
5454
5506
  const positions = self._generateCirclePositions(center, radius, 256);
5455
5507
  const flat = positions.flatMap(c => [c[0], c[1], 0]);
5456
- return Cesium$9.Cartesian3.fromDegreesArrayHeights(flat);
5508
+ return Cesium$a.Cartesian3.fromDegreesArrayHeights(flat);
5457
5509
  }, false),
5458
- material: Cesium$9.Color.YELLOW,
5510
+ material: Cesium$a.Color.YELLOW,
5459
5511
  width: 2,
5460
5512
  clampToGround: true
5461
5513
  }
@@ -5467,7 +5519,7 @@ class EditTool extends BaseTool {
5467
5519
  // 修复:正确获取半径控制点的位置
5468
5520
  this._radiusLine = this.createTempEntity(this.generateId('temp_radius_line'), {
5469
5521
  polyline: {
5470
- positions: new Cesium$9.CallbackProperty(function () {
5522
+ positions: new Cesium$a.CallbackProperty(function () {
5471
5523
  const circleInfo = self._getCircleInfo(self._selectedEntity);
5472
5524
  if (!circleInfo) return [];
5473
5525
 
@@ -5476,13 +5528,13 @@ class EditTool extends BaseTool {
5476
5528
  const radiusHandle = self._editHandles.find(h => h.id && h.id.includes('__edit_handle_radius'));
5477
5529
  if (!radiusHandle) return [];
5478
5530
 
5479
- const radiusPos = radiusHandle.position.getValue(Cesium$9.JulianDate.now());
5531
+ const radiusPos = radiusHandle.position.getValue(Cesium$a.JulianDate.now());
5480
5532
  if (!radiusPos) return [];
5481
5533
 
5482
- const centerCart = Cesium$9.Cartesian3.fromDegrees(center[0], center[1], 0);
5534
+ const centerCart = Cesium$a.Cartesian3.fromDegrees(center[0], center[1], 0);
5483
5535
  return [centerCart, radiusPos];
5484
5536
  }, false),
5485
- material: Cesium$9.Color.RED,
5537
+ material: Cesium$a.Color.RED,
5486
5538
  width: 3,
5487
5539
  clampToGround: true
5488
5540
  }
@@ -5522,8 +5574,8 @@ class EditTool extends BaseTool {
5522
5574
  _computeRectangleNewPositions(newPos, originalPositions, draggedIndex) {
5523
5575
  // 对角顶点索引:0->2, 1->3, 2->0, 3->1
5524
5576
  const oppositeIndex = (draggedIndex + 2) % 4;
5525
- const newP = Cesium$9.Cartographic.fromCartesian(newPos);
5526
- const currentPos = originalPositions.map(p => Cesium$9.Cartographic.fromCartesian(p));
5577
+ const newP = Cesium$a.Cartographic.fromCartesian(newPos);
5578
+ const currentPos = originalPositions.map(p => Cesium$a.Cartographic.fromCartesian(p));
5527
5579
  const oppositePos = currentPos[oppositeIndex];
5528
5580
 
5529
5581
  const newPositions = new Array(4);
@@ -5536,14 +5588,14 @@ class EditTool extends BaseTool {
5536
5588
  const neighbor2 = (draggedIndex + 3) % 4;
5537
5589
 
5538
5590
  // neighbor1 使用 newPos 的 longitude 和 opposite 的 latitude
5539
- newPositions[neighbor1] = Cesium$9.Cartesian3.fromRadians(
5591
+ newPositions[neighbor1] = Cesium$a.Cartesian3.fromRadians(
5540
5592
  newP.longitude,
5541
5593
  oppositePos.latitude,
5542
5594
  oppositePos.height
5543
5595
  );
5544
5596
 
5545
5597
  // neighbor2 使用 opposite 的 longitude 和 newPos 的 latitude
5546
- newPositions[neighbor2] = Cesium$9.Cartesian3.fromRadians(
5598
+ newPositions[neighbor2] = Cesium$a.Cartesian3.fromRadians(
5547
5599
  oppositePos.longitude,
5548
5600
  newP.latitude,
5549
5601
  oppositePos.height
@@ -5559,7 +5611,7 @@ class EditTool extends BaseTool {
5559
5611
  if (handleIndex === -1) return;
5560
5612
 
5561
5613
  // 修复:新位置贴地(高度设为0)
5562
- const newCartesian = Cesium$9.Cartesian3.fromDegrees(newLonLat[0], newLonLat[1], 0);
5614
+ const newCartesian = Cesium$a.Cartesian3.fromDegrees(newLonLat[0], newLonLat[1], 0);
5563
5615
 
5564
5616
  // 标绘图元:拖拽控制点重新生成几何
5565
5617
  if (this._selectedEntity._isPlotGraphic) {
@@ -5582,12 +5634,12 @@ class EditTool extends BaseTool {
5582
5634
  // 扇形:拖拽圆心(索引0)时整体平移,保持两半径等长
5583
5635
  if (plotType === PlotGraphicType.SECTOR && index === 0) {
5584
5636
  const oldCenter = this._selectedEntity._controlPoints[0];
5585
- const oldCenterCart = Cesium$9.Cartesian3.fromDegrees(oldCenter[0], oldCenter[1], oldCenter[2] || 0);
5637
+ const oldCenterCart = Cesium$a.Cartesian3.fromDegrees(oldCenter[0], oldCenter[1], oldCenter[2] || 0);
5586
5638
  const clampedNewCenter = this._clampPositionToGround(newCartesian);
5587
5639
  this._translatePlotControlPoints(clampedNewCenter, oldCenterCart);
5588
5640
  // 中心控制点固定在圆心
5589
5641
  this._originalEntityCenter = this._clampPositionToGround(
5590
- Cesium$9.Cartesian3.fromDegrees(
5642
+ Cesium$a.Cartesian3.fromDegrees(
5591
5643
  this._selectedEntity._controlPoints[0][0],
5592
5644
  this._selectedEntity._controlPoints[0][1],
5593
5645
  this._selectedEntity._controlPoints[0][2] || 0
@@ -5663,8 +5715,8 @@ class EditTool extends BaseTool {
5663
5715
  if (match) {
5664
5716
  const cpIndex = parseInt(match[1], 10);
5665
5717
  const cp = controlPoints[cpIndex];
5666
- handle.position = new Cesium$9.ConstantPositionProperty(
5667
- this._clampPositionToGround(Cesium$9.Cartesian3.fromDegrees(cp[0], cp[1], cp[2] || 0))
5718
+ handle.position = new Cesium$a.ConstantPositionProperty(
5719
+ this._clampPositionToGround(Cesium$a.Cartesian3.fromDegrees(cp[0], cp[1], cp[2] || 0))
5668
5720
  );
5669
5721
  }
5670
5722
  });
@@ -5676,11 +5728,11 @@ class EditTool extends BaseTool {
5676
5728
  const newCenter = (plotType === PlotGraphicType.SECTOR || plotType === PlotGraphicType.ELLIPSE)
5677
5729
  ? controlPoints[0]
5678
5730
  : this._getPlotControlPointsCenter(controlPoints);
5679
- centerHandle.position = new Cesium$9.ConstantPositionProperty(
5680
- this._clampPositionToGround(Cesium$9.Cartesian3.fromDegrees(newCenter[0], newCenter[1], newCenter[2] || 0))
5731
+ centerHandle.position = new Cesium$a.ConstantPositionProperty(
5732
+ this._clampPositionToGround(Cesium$a.Cartesian3.fromDegrees(newCenter[0], newCenter[1], newCenter[2] || 0))
5681
5733
  );
5682
5734
  this._originalEntityCenter = this._clampPositionToGround(
5683
- Cesium$9.Cartesian3.fromDegrees(newCenter[0], newCenter[1], newCenter[2] || 0)
5735
+ Cesium$a.Cartesian3.fromDegrees(newCenter[0], newCenter[1], newCenter[2] || 0)
5684
5736
  );
5685
5737
  }
5686
5738
 
@@ -5689,7 +5741,7 @@ class EditTool extends BaseTool {
5689
5741
  return;
5690
5742
  }
5691
5743
 
5692
- const hierarchy = this._selectedEntity.polygon?.hierarchy?.getValue(Cesium$9.JulianDate.now());
5744
+ const hierarchy = this._selectedEntity.polygon?.hierarchy?.getValue(Cesium$a.JulianDate.now());
5693
5745
 
5694
5746
  // 拖动中心控制点:平移整个图元
5695
5747
  // 修复:统一使用 includes('center') 来判断
@@ -5703,7 +5755,7 @@ class EditTool extends BaseTool {
5703
5755
  if (this._handleVertexIndices &&
5704
5756
  Array.isArray(this._handleVertexIndices) &&
5705
5757
  typeof this._handleVertexIndices[0] === 'number' &&
5706
- Cesium$9.defined(this._selectedEntity.polygon)) {
5758
+ Cesium$a.defined(this._selectedEntity.polygon)) {
5707
5759
  if (!hierarchy || !hierarchy.positions || hierarchy.positions.length < 4) return;
5708
5760
 
5709
5761
  const draggedVertexIndex = this._handleVertexIndices[handleIndex];
@@ -5713,13 +5765,13 @@ class EditTool extends BaseTool {
5713
5765
  const clampedPositions = newPositions.map(pos => this._clampPositionToGround(pos));
5714
5766
 
5715
5767
  // 更新多边形
5716
- this._selectedEntity.polygon.hierarchy = new Cesium$9.PolygonHierarchy(clampedPositions);
5768
+ this._selectedEntity.polygon.hierarchy = new Cesium$a.PolygonHierarchy(clampedPositions);
5717
5769
 
5718
5770
  // 更新所有控制点位置(使用 ConstantPositionProperty 确保正确更新)
5719
5771
  this._editHandles.forEach((handle, i) => {
5720
5772
  // 修复:跳过中心控制点
5721
5773
  if (handle.id && handle.id.includes('center')) return;
5722
- handle.position = new Cesium$9.ConstantPositionProperty(clampedPositions[i]);
5774
+ handle.position = new Cesium$a.ConstantPositionProperty(clampedPositions[i]);
5723
5775
  });
5724
5776
 
5725
5777
  // 修复:顶点编辑后重新计算并更新中心控制点位置
@@ -5752,16 +5804,16 @@ class EditTool extends BaseTool {
5752
5804
  // 更新多边形顶点
5753
5805
  const positions = this._generateCirclePositions(newCenterLonLat, circleInfo.radius, 256);
5754
5806
  const flat = positions.flatMap(c => [c[0], c[1], 0]);
5755
- this._selectedEntity.polygon.hierarchy = new Cesium$9.PolygonHierarchy(
5756
- Cesium$9.Cartesian3.fromDegreesArrayHeights(flat)
5807
+ this._selectedEntity.polygon.hierarchy = new Cesium$a.PolygonHierarchy(
5808
+ Cesium$a.Cartesian3.fromDegreesArrayHeights(flat)
5757
5809
  );
5758
5810
 
5759
5811
  // 更新半径控制点位置
5760
5812
  const radiusHandle = this._editHandles.find(h => h.id && h.id.includes('radius'));
5761
5813
  if (radiusHandle) {
5762
5814
  const radiusPoint = this._getPointOnCircle(newCenterLonLat, circleInfo.radius, 0);
5763
- radiusHandle.position = new Cesium$9.ConstantPositionProperty(
5764
- Cesium$9.Cartesian3.fromDegrees(radiusPoint[0], radiusPoint[1], 0)
5815
+ radiusHandle.position = new Cesium$a.ConstantPositionProperty(
5816
+ Cesium$a.Cartesian3.fromDegrees(radiusPoint[0], radiusPoint[1], 0)
5765
5817
  );
5766
5818
  }
5767
5819
 
@@ -5773,8 +5825,8 @@ class EditTool extends BaseTool {
5773
5825
  // 更新半径控制点位置(在圆周上)
5774
5826
  const angle = Math.atan2(newLonLat[1] - circleInfo.center[1], newLonLat[0] - circleInfo.center[0]);
5775
5827
  const radiusPoint = this._getPointOnCircle(circleInfo.center, newRadius, angle);
5776
- this._dragHandle.position = new Cesium$9.ConstantPositionProperty(
5777
- Cesium$9.Cartesian3.fromDegrees(radiusPoint[0], radiusPoint[1], 0)
5828
+ this._dragHandle.position = new Cesium$a.ConstantPositionProperty(
5829
+ Cesium$a.Cartesian3.fromDegrees(radiusPoint[0], radiusPoint[1], 0)
5778
5830
  );
5779
5831
 
5780
5832
  // 更新圆的实体属性
@@ -5784,25 +5836,25 @@ class EditTool extends BaseTool {
5784
5836
  // 更新多边形顶点
5785
5837
  const positions = this._generateCirclePositions(circleInfo.center, newRadius, 256);
5786
5838
  const flat = positions.flatMap(c => [c[0], c[1], 0]);
5787
- this._selectedEntity.polygon.hierarchy = new Cesium$9.PolygonHierarchy(
5788
- Cesium$9.Cartesian3.fromDegreesArrayHeights(flat)
5839
+ this._selectedEntity.polygon.hierarchy = new Cesium$a.PolygonHierarchy(
5840
+ Cesium$a.Cartesian3.fromDegreesArrayHeights(flat)
5789
5841
  );
5790
5842
 
5791
5843
  return;
5792
5844
  }
5793
5845
 
5794
- if (Cesium$9.defined(this._selectedEntity.polyline)) {
5795
- const positions = this._selectedEntity.polyline.positions.getValue(Cesium$9.JulianDate.now());
5846
+ if (Cesium$a.defined(this._selectedEntity.polyline)) {
5847
+ const positions = this._selectedEntity.polyline.positions.getValue(Cesium$a.JulianDate.now());
5796
5848
  if (positions && positions[handleIndex]) {
5797
5849
  // 直接修改数组元素触发更新
5798
5850
  positions[handleIndex] = newCartesian;
5799
5851
  this._selectedEntity.polyline.positions = positions;
5800
- this._dragHandle.position = new Cesium$9.ConstantPositionProperty(newCartesian);
5852
+ this._dragHandle.position = new Cesium$a.ConstantPositionProperty(newCartesian);
5801
5853
 
5802
5854
  // 修复:线编辑后重新计算并更新中心控制点位置
5803
5855
  this._updateCenterHandlePosition();
5804
5856
  }
5805
- } else if (Cesium$9.defined(this._selectedEntity.polygon)) {
5857
+ } else if (Cesium$a.defined(this._selectedEntity.polygon)) {
5806
5858
  // 获取当前实际顶点数(不包含闭合点)
5807
5859
  this._editHandles.filter(h => !h.id.includes('center')).length;
5808
5860
 
@@ -5817,7 +5869,7 @@ class EditTool extends BaseTool {
5817
5869
  newPositions.push(newCartesian);
5818
5870
  } else {
5819
5871
  // 从控制点获取当前位置
5820
- const pos = handle.position.getValue(Cesium$9.JulianDate.now());
5872
+ const pos = handle.position.getValue(Cesium$a.JulianDate.now());
5821
5873
  // 修复:确保位置贴地
5822
5874
  newPositions.push(this._clampPositionToGround(pos));
5823
5875
  }
@@ -5827,47 +5879,47 @@ class EditTool extends BaseTool {
5827
5879
  newPositions.push(newPositions[0].clone());
5828
5880
 
5829
5881
  // 更新多边形
5830
- this._selectedEntity.polygon.hierarchy = new Cesium$9.PolygonHierarchy(newPositions);
5882
+ this._selectedEntity.polygon.hierarchy = new Cesium$a.PolygonHierarchy(newPositions);
5831
5883
 
5832
5884
  // 更新控制点
5833
- this._dragHandle.position = new Cesium$9.ConstantPositionProperty(newCartesian);
5885
+ this._dragHandle.position = new Cesium$a.ConstantPositionProperty(newCartesian);
5834
5886
 
5835
5887
  // 修复:多边形编辑后重新计算并更新中心控制点位置
5836
5888
  this._updateCenterHandlePosition();
5837
5889
 
5838
5890
  return;
5839
- } else if (Cesium$9.defined(this._selectedEntity.position)) {
5840
- this._selectedEntity.position = new Cesium$9.ConstantPositionProperty(newCartesian);
5841
- this._dragHandle.position = new Cesium$9.ConstantPositionProperty(newCartesian);
5891
+ } else if (Cesium$a.defined(this._selectedEntity.position)) {
5892
+ this._selectedEntity.position = new Cesium$a.ConstantPositionProperty(newCartesian);
5893
+ this._dragHandle.position = new Cesium$a.ConstantPositionProperty(newCartesian);
5842
5894
  }
5843
5895
  }
5844
5896
 
5845
5897
  _highlightEntity(entity, highlight) {
5846
5898
  if (!entity) return;
5847
5899
 
5848
- if (Cesium$9.defined(entity.point)) {
5900
+ if (Cesium$a.defined(entity.point)) {
5849
5901
  if (highlight) {
5850
- entity.point.outlineColor = Cesium$9.Color.CYAN;
5902
+ entity.point.outlineColor = Cesium$a.Color.CYAN;
5851
5903
  entity.point.outlineWidth = 3;
5852
5904
  } else {
5853
- entity.point.outlineColor = Cesium$9.Color.WHITE;
5905
+ entity.point.outlineColor = Cesium$a.Color.WHITE;
5854
5906
  entity.point.outlineWidth = 1;
5855
5907
  }
5856
5908
  }
5857
5909
 
5858
- if (Cesium$9.defined(entity.polyline)) {
5910
+ if (Cesium$a.defined(entity.polyline)) {
5859
5911
  if (highlight) {
5860
- entity.polyline.material = Cesium$9.Color.CYAN;
5912
+ entity.polyline.material = Cesium$a.Color.CYAN;
5861
5913
  } else {
5862
- entity.polyline.material = Cesium$9.Color.BLUE;
5914
+ entity.polyline.material = Cesium$a.Color.BLUE;
5863
5915
  }
5864
5916
  }
5865
5917
 
5866
- if (Cesium$9.defined(entity.polygon)) {
5918
+ if (Cesium$a.defined(entity.polygon)) {
5867
5919
  if (highlight) {
5868
- entity.polygon.outlineColor = Cesium$9.Color.CYAN;
5920
+ entity.polygon.outlineColor = Cesium$a.Color.CYAN;
5869
5921
  } else {
5870
- entity.polygon.outlineColor = Cesium$9.Color.WHITE;
5922
+ entity.polygon.outlineColor = Cesium$a.Color.WHITE;
5871
5923
  }
5872
5924
  }
5873
5925
  }
@@ -5904,8 +5956,8 @@ class EditTool extends BaseTool {
5904
5956
  // 更新多边形顶点
5905
5957
  const positions = this._generateCirclePositions(center, radius, 256);
5906
5958
  const flat = positions.flatMap(c => [c[0], c[1], 0]);
5907
- this._selectedEntity.polygon.hierarchy = new Cesium$9.PolygonHierarchy(
5908
- Cesium$9.Cartesian3.fromDegreesArrayHeights(flat)
5959
+ this._selectedEntity.polygon.hierarchy = new Cesium$a.PolygonHierarchy(
5960
+ Cesium$a.Cartesian3.fromDegreesArrayHeights(flat)
5909
5961
  );
5910
5962
 
5911
5963
  this._createEditHandles();
@@ -5920,10 +5972,10 @@ class EditTool extends BaseTool {
5920
5972
  // 拷贝一份避免直接修改原始数据
5921
5973
  const positionsCopy = originalPositions.map(p => p.clone ? p.clone() : p);
5922
5974
 
5923
- if (Cesium$9.defined(this._selectedEntity.polyline)) {
5975
+ if (Cesium$a.defined(this._selectedEntity.polyline)) {
5924
5976
  this._selectedEntity.polyline.positions = positionsCopy;
5925
- } else if (Cesium$9.defined(this._selectedEntity.polygon)) {
5926
- this._selectedEntity.polygon.hierarchy = new Cesium$9.PolygonHierarchy(positionsCopy);
5977
+ } else if (Cesium$a.defined(this._selectedEntity.polygon)) {
5978
+ this._selectedEntity.polygon.hierarchy = new Cesium$a.PolygonHierarchy(positionsCopy);
5927
5979
  }
5928
5980
 
5929
5981
  this._createEditHandles();
@@ -5946,7 +5998,7 @@ class EditTool extends BaseTool {
5946
5998
  }
5947
5999
  }
5948
6000
 
5949
- const Cesium$8 = getCesium();
6001
+ const Cesium$9 = getCesium();
5950
6002
 
5951
6003
  /**
5952
6004
  * 选择类型枚举
@@ -6033,7 +6085,7 @@ class SelectTool extends BaseTool {
6033
6085
 
6034
6086
  const picked = this._viewer.scene.pick(screenPos);
6035
6087
 
6036
- if (Cesium$8.defined(picked) && Cesium$8.defined(picked.id)) {
6088
+ if (Cesium$9.defined(picked) && Cesium$9.defined(picked.id)) {
6037
6089
  const entityId = picked.id.id;
6038
6090
 
6039
6091
  // 忽略临时图元
@@ -6075,9 +6127,9 @@ class SelectTool extends BaseTool {
6075
6127
 
6076
6128
  _createSelectionStartMarker(pos) {
6077
6129
  const marker = this.createTempEntity(this.generateId('sel_start'), {
6078
- position: Cesium$8.Cartesian3.fromDegrees(...pos),
6130
+ position: Cesium$9.Cartesian3.fromDegrees(...pos),
6079
6131
  point: {
6080
- color: Cesium$8.Color.GREEN,
6132
+ color: Cesium$9.Color.GREEN,
6081
6133
  pixelSize: 10
6082
6134
  }
6083
6135
  });
@@ -6102,27 +6154,27 @@ class SelectTool extends BaseTool {
6102
6154
  if (!this._selectionRect) {
6103
6155
  this._selectionRect = this.createTempEntity(this.generateId('sel_rect'), {
6104
6156
  polyline: {
6105
- positions: new Cesium$8.CallbackProperty(() => {
6157
+ positions: new Cesium$9.CallbackProperty(() => {
6106
6158
  const c1 = this._startPos;
6107
6159
  const c2 = this._currentEndPos;
6108
6160
  if (!c1 || !c2) return [];
6109
6161
  const pos = this._getRectPositions(c1, c2);
6110
- return Cesium$8.Cartesian3.fromDegreesArrayHeights(pos.flatMap(c => [c[0], c[1], 0]));
6162
+ return Cesium$9.Cartesian3.fromDegreesArrayHeights(pos.flatMap(c => [c[0], c[1], 0]));
6111
6163
  }, false),
6112
- material: Cesium$8.Color.CYAN,
6164
+ material: Cesium$9.Color.CYAN,
6113
6165
  width: 2
6114
6166
  },
6115
6167
  polygon: {
6116
- hierarchy: new Cesium$8.CallbackProperty(() => {
6168
+ hierarchy: new Cesium$9.CallbackProperty(() => {
6117
6169
  const c1 = this._startPos;
6118
6170
  const c2 = this._currentEndPos;
6119
- if (!c1 || !c2) return new Cesium$8.PolygonHierarchy([]);
6171
+ if (!c1 || !c2) return new Cesium$9.PolygonHierarchy([]);
6120
6172
  const pos = this._getRectPositions(c1, c2);
6121
- return new Cesium$8.PolygonHierarchy(
6122
- Cesium$8.Cartesian3.fromDegreesArrayHeights(pos.flatMap(c => [c[0], c[1], 0]))
6173
+ return new Cesium$9.PolygonHierarchy(
6174
+ Cesium$9.Cartesian3.fromDegreesArrayHeights(pos.flatMap(c => [c[0], c[1], 0]))
6123
6175
  );
6124
6176
  }, false),
6125
- material: Cesium$8.Color.CYAN.withAlpha(0.2),
6177
+ material: Cesium$9.Color.CYAN.withAlpha(0.2),
6126
6178
  outline: false
6127
6179
  }
6128
6180
  });
@@ -6139,21 +6191,21 @@ class SelectTool extends BaseTool {
6139
6191
  if (!this._selectionRect) {
6140
6192
  this._selectionRect = this.createTempEntity(this.generateId('sel_circle'), {
6141
6193
  polygon: {
6142
- hierarchy: new Cesium$8.CallbackProperty(() => {
6194
+ hierarchy: new Cesium$9.CallbackProperty(() => {
6143
6195
  const c = this._startPos;
6144
6196
  const edge = this._currentEndPos;
6145
- if (!c || !edge) return new Cesium$8.PolygonHierarchy([]);
6197
+ if (!c || !edge) return new Cesium$9.PolygonHierarchy([]);
6146
6198
  const radius = this._calcDistance(c, edge);
6147
6199
  const positions = this._generateCirclePositions(c, radius, 36);
6148
- return new Cesium$8.PolygonHierarchy(
6149
- Cesium$8.Cartesian3.fromDegreesArrayHeights(
6200
+ return new Cesium$9.PolygonHierarchy(
6201
+ Cesium$9.Cartesian3.fromDegreesArrayHeights(
6150
6202
  positions.flatMap(c => [c[0], c[1], 0])
6151
6203
  )
6152
6204
  );
6153
6205
  }, false),
6154
- material: Cesium$8.Color.CYAN.withAlpha(0.2),
6206
+ material: Cesium$9.Color.CYAN.withAlpha(0.2),
6155
6207
  outline: true,
6156
- outlineColor: Cesium$8.Color.CYAN
6208
+ outlineColor: Cesium$9.Color.CYAN
6157
6209
  }
6158
6210
  });
6159
6211
  this._selectionRect._isPreview = true;
@@ -6242,7 +6294,7 @@ class SelectTool extends BaseTool {
6242
6294
 
6243
6295
  const styleKey = entityId;
6244
6296
 
6245
- if (Cesium$8.defined(entity.point)) {
6297
+ if (Cesium$9.defined(entity.point)) {
6246
6298
  if (highlight) {
6247
6299
  if (!this._originalStyles.has(styleKey)) {
6248
6300
  this._originalStyles.set(styleKey, {
@@ -6252,7 +6304,7 @@ class SelectTool extends BaseTool {
6252
6304
  }
6253
6305
  });
6254
6306
  }
6255
- entity.point.outlineColor = Cesium$8.Color.YELLOW;
6307
+ entity.point.outlineColor = Cesium$9.Color.YELLOW;
6256
6308
  entity.point.outlineWidth = 2;
6257
6309
  } else {
6258
6310
  const original = this._originalStyles.get(styleKey)?.point;
@@ -6260,13 +6312,13 @@ class SelectTool extends BaseTool {
6260
6312
  entity.point.outlineColor = original.outlineColor;
6261
6313
  entity.point.outlineWidth = original.outlineWidth;
6262
6314
  } else {
6263
- entity.point.outlineColor = Cesium$8.Color.WHITE;
6315
+ entity.point.outlineColor = Cesium$9.Color.WHITE;
6264
6316
  entity.point.outlineWidth = 1;
6265
6317
  }
6266
6318
  }
6267
6319
  }
6268
6320
 
6269
- if (Cesium$8.defined(entity.polyline)) {
6321
+ if (Cesium$9.defined(entity.polyline)) {
6270
6322
  if (highlight) {
6271
6323
  if (!this._originalStyles.has(styleKey)) {
6272
6324
  this._originalStyles.set(styleKey, {
@@ -6275,14 +6327,14 @@ class SelectTool extends BaseTool {
6275
6327
  }
6276
6328
  });
6277
6329
  }
6278
- entity.polyline.material = Cesium$8.Color.CYAN;
6330
+ entity.polyline.material = Cesium$9.Color.CYAN;
6279
6331
  } else {
6280
6332
  const original = this._originalStyles.get(styleKey)?.polyline;
6281
- entity.polyline.material = original?.material || Cesium$8.Color.BLUE;
6333
+ entity.polyline.material = original?.material || Cesium$9.Color.BLUE;
6282
6334
  }
6283
6335
  }
6284
6336
 
6285
- if (Cesium$8.defined(entity.polygon)) {
6337
+ if (Cesium$9.defined(entity.polygon)) {
6286
6338
  if (highlight) {
6287
6339
  if (!this._originalStyles.has(styleKey)) {
6288
6340
  this._originalStyles.set(styleKey, {
@@ -6291,10 +6343,10 @@ class SelectTool extends BaseTool {
6291
6343
  }
6292
6344
  });
6293
6345
  }
6294
- entity.polygon.outlineColor = Cesium$8.Color.CYAN;
6346
+ entity.polygon.outlineColor = Cesium$9.Color.CYAN;
6295
6347
  } else {
6296
6348
  const original = this._originalStyles.get(styleKey)?.polygon;
6297
- entity.polygon.outlineColor = original?.outlineColor || Cesium$8.Color.WHITE;
6349
+ entity.polygon.outlineColor = original?.outlineColor || Cesium$9.Color.WHITE;
6298
6350
  }
6299
6351
  }
6300
6352
 
@@ -6381,9 +6433,9 @@ class SelectTool extends BaseTool {
6381
6433
  // 检查是否所有点都在范围内
6382
6434
  let allInBounds = true;
6383
6435
  for (const pos of positions) {
6384
- const c = Cesium$8.Cartographic.fromCartesian(pos);
6385
- const lon = Cesium$8.Math.toDegrees(c.longitude);
6386
- const lat = Cesium$8.Math.toDegrees(c.latitude);
6436
+ const c = Cesium$9.Cartographic.fromCartesian(pos);
6437
+ const lon = Cesium$9.Math.toDegrees(c.longitude);
6438
+ const lat = Cesium$9.Math.toDegrees(c.latitude);
6387
6439
 
6388
6440
  if (lon < minLon || lon > maxLon || lat < minLat || lat > maxLat) {
6389
6441
  allInBounds = false;
@@ -6400,13 +6452,13 @@ class SelectTool extends BaseTool {
6400
6452
  }
6401
6453
 
6402
6454
  _getEntityPosition(entity) {
6403
- if (Cesium$8.defined(entity.position)) {
6404
- const pos = entity.position.getValue(Cesium$8.JulianDate.now());
6455
+ if (Cesium$9.defined(entity.position)) {
6456
+ const pos = entity.position.getValue(Cesium$9.JulianDate.now());
6405
6457
  if (pos) {
6406
- const c = Cesium$8.Cartographic.fromCartesian(pos);
6458
+ const c = Cesium$9.Cartographic.fromCartesian(pos);
6407
6459
  return [
6408
- Cesium$8.Math.toDegrees(c.longitude),
6409
- Cesium$8.Math.toDegrees(c.latitude)
6460
+ Cesium$9.Math.toDegrees(c.longitude),
6461
+ Cesium$9.Math.toDegrees(c.latitude)
6410
6462
  ];
6411
6463
  }
6412
6464
  }
@@ -6414,11 +6466,11 @@ class SelectTool extends BaseTool {
6414
6466
  }
6415
6467
 
6416
6468
  _getEntityPositions(entity) {
6417
- if (Cesium$8.defined(entity.polyline) && Cesium$8.defined(entity.polyline.positions)) {
6418
- return entity.polyline.positions.getValue(Cesium$8.JulianDate.now());
6469
+ if (Cesium$9.defined(entity.polyline) && Cesium$9.defined(entity.polyline.positions)) {
6470
+ return entity.polyline.positions.getValue(Cesium$9.JulianDate.now());
6419
6471
  }
6420
- if (Cesium$8.defined(entity.polygon) && Cesium$8.defined(entity.polygon.hierarchy)) {
6421
- const hierarchy = entity.polygon.hierarchy.getValue(Cesium$8.JulianDate.now());
6472
+ if (Cesium$9.defined(entity.polygon) && Cesium$9.defined(entity.polygon.hierarchy)) {
6473
+ const hierarchy = entity.polygon.hierarchy.getValue(Cesium$9.JulianDate.now());
6422
6474
  return hierarchy ? hierarchy.positions : [];
6423
6475
  }
6424
6476
  return [];
@@ -6483,7 +6535,7 @@ class SelectTool extends BaseTool {
6483
6535
  }
6484
6536
  }
6485
6537
 
6486
- const Cesium$7 = getCesium();
6538
+ const Cesium$8 = getCesium();
6487
6539
 
6488
6540
  /**
6489
6541
  * 删除模式枚举
@@ -6534,7 +6586,7 @@ class DeleteTool extends BaseTool {
6534
6586
 
6535
6587
  const picked = this._viewer.scene.pick(screenPos);
6536
6588
 
6537
- if (Cesium$7.defined(picked) && Cesium$7.defined(picked.id)) {
6589
+ if (Cesium$8.defined(picked) && Cesium$8.defined(picked.id)) {
6538
6590
  const entityId = picked.id.id;
6539
6591
 
6540
6592
  // 忽略临时图元
@@ -6558,7 +6610,7 @@ class DeleteTool extends BaseTool {
6558
6610
 
6559
6611
  let hoveredId = null;
6560
6612
 
6561
- if (Cesium$7.defined(picked) && Cesium$7.defined(picked.id)) {
6613
+ if (Cesium$8.defined(picked) && Cesium$8.defined(picked.id)) {
6562
6614
  const entityId = picked.id.id;
6563
6615
  if (!entityId.startsWith('__temp_') && !entityId.startsWith('__edit_handle_')) {
6564
6616
  hoveredId = entityId;
@@ -6638,7 +6690,7 @@ class DeleteTool extends BaseTool {
6638
6690
  const styleKey = entityId;
6639
6691
 
6640
6692
  // 红色高亮表示可删除,先保存原始样式
6641
- if (Cesium$7.defined(entity.point)) {
6693
+ if (Cesium$8.defined(entity.point)) {
6642
6694
  if (!this._originalStyles.has(styleKey)) {
6643
6695
  this._originalStyles.set(styleKey, {
6644
6696
  point: {
@@ -6647,11 +6699,11 @@ class DeleteTool extends BaseTool {
6647
6699
  }
6648
6700
  });
6649
6701
  }
6650
- entity.point.outlineColor = Cesium$7.Color.RED;
6702
+ entity.point.outlineColor = Cesium$8.Color.RED;
6651
6703
  entity.point.outlineWidth = 3;
6652
6704
  }
6653
6705
 
6654
- if (Cesium$7.defined(entity.polyline)) {
6706
+ if (Cesium$8.defined(entity.polyline)) {
6655
6707
  if (!this._originalStyles.has(styleKey)) {
6656
6708
  this._originalStyles.set(styleKey, {
6657
6709
  polyline: {
@@ -6659,10 +6711,10 @@ class DeleteTool extends BaseTool {
6659
6711
  }
6660
6712
  });
6661
6713
  }
6662
- entity.polyline.material = Cesium$7.Color.RED;
6714
+ entity.polyline.material = Cesium$8.Color.RED;
6663
6715
  }
6664
6716
 
6665
- if (Cesium$7.defined(entity.polygon)) {
6717
+ if (Cesium$8.defined(entity.polygon)) {
6666
6718
  if (!this._originalStyles.has(styleKey)) {
6667
6719
  this._originalStyles.set(styleKey, {
6668
6720
  polygon: {
@@ -6670,7 +6722,7 @@ class DeleteTool extends BaseTool {
6670
6722
  }
6671
6723
  });
6672
6724
  }
6673
- entity.polygon.outlineColor = Cesium$7.Color.RED;
6725
+ entity.polygon.outlineColor = Cesium$8.Color.RED;
6674
6726
  }
6675
6727
 
6676
6728
  // 更改鼠标样式
@@ -6687,22 +6739,22 @@ class DeleteTool extends BaseTool {
6687
6739
  const original = styleKey ? this._originalStyles.get(styleKey) : null;
6688
6740
 
6689
6741
  // 恢复原始样式
6690
- if (Cesium$7.defined(entity.point)) {
6742
+ if (Cesium$8.defined(entity.point)) {
6691
6743
  if (original?.point) {
6692
6744
  entity.point.outlineColor = original.point.outlineColor;
6693
6745
  entity.point.outlineWidth = original.point.outlineWidth;
6694
6746
  } else {
6695
- entity.point.outlineColor = Cesium$7.Color.WHITE;
6747
+ entity.point.outlineColor = Cesium$8.Color.WHITE;
6696
6748
  entity.point.outlineWidth = 1;
6697
6749
  }
6698
6750
  }
6699
6751
 
6700
- if (Cesium$7.defined(entity.polyline)) {
6701
- entity.polyline.material = original?.polyline?.material || Cesium$7.Color.BLUE;
6752
+ if (Cesium$8.defined(entity.polyline)) {
6753
+ entity.polyline.material = original?.polyline?.material || Cesium$8.Color.BLUE;
6702
6754
  }
6703
6755
 
6704
- if (Cesium$7.defined(entity.polygon)) {
6705
- entity.polygon.outlineColor = original?.polygon?.outlineColor || Cesium$7.Color.WHITE;
6756
+ if (Cesium$8.defined(entity.polygon)) {
6757
+ entity.polygon.outlineColor = original?.polygon?.outlineColor || Cesium$8.Color.WHITE;
6706
6758
  }
6707
6759
 
6708
6760
  // 恢复鼠标样式
@@ -6736,6 +6788,615 @@ class DeleteTool extends BaseTool {
6736
6788
  }
6737
6789
  }
6738
6790
 
6791
+ const Cesium$7 = getCesium();
6792
+
6793
+ /**
6794
+ * 地理计算工具(距离、面积、高程)
6795
+ */
6796
+ class GeoCalcUtil {
6797
+ /**
6798
+ * 计算两点地理坐标距离(米)
6799
+ * @param {Array<number>} point1 [lng, lat, height]
6800
+ * @param {Array<number>} point2 [lng, lat, height]
6801
+ * @returns {number} 距离
6802
+ */
6803
+ static calcDistance(point1, point2) {
6804
+ const coord1 = Cesium$7.Cartesian3.fromDegrees(...point1);
6805
+ const coord2 = Cesium$7.Cartesian3.fromDegrees(...point2);
6806
+ return Cesium$7.Cartesian3.distance(coord1, coord2);
6807
+ }
6808
+
6809
+ /**
6810
+ * 计算多边形面积(平方米)
6811
+ * 使用球面多边形面积公式(基于 Cesium 几何顶点)
6812
+ * @param {Array<Array<number>>} points 地理坐标点集 [lon, lat, height?]
6813
+ * @returns {number} 面积
6814
+ */
6815
+ static calcArea(points) {
6816
+ if (!points || points.length < 3) return 0;
6817
+
6818
+ const positions = points.map(p => Cesium$7.Cartesian3.fromDegrees(p[0], p[1], p[2] || 0));
6819
+ const polygon = new Cesium$7.PolygonGeometry({
6820
+ polygonHierarchy: new Cesium$7.PolygonHierarchy(positions)
6821
+ });
6822
+ const geometry = Cesium$7.PolygonGeometry.createGeometry(polygon);
6823
+
6824
+ if (!geometry || !geometry.attributes || !geometry.attributes.position) {
6825
+ return 0;
6826
+ }
6827
+
6828
+ const values = geometry.attributes.position.values;
6829
+ const vertexPositions = [];
6830
+ for (let i = 0; i < values.length; i += 3) {
6831
+ vertexPositions.push(new Cesium$7.Cartesian3(values[i], values[i + 1], values[i + 2]));
6832
+ }
6833
+
6834
+ // 球面多边形面积(基于单位球上的多边形面积公式)
6835
+ const area = GeoCalcUtil.#sphericalPolygonArea(vertexPositions);
6836
+ return Math.abs(area);
6837
+ }
6838
+
6839
+ /**
6840
+ * 单位球面上多边形的有向面积(平方米)
6841
+ * 采用局部切平面投影法:以多边形重心为原点建立切平面,投影后计算二维多边形面积。
6842
+ * 对于常规 GIS 多边形精度足够;极大规模多边形可后续替换为更严格的球面 excess 算法。
6843
+ * @param {Cesium.Cartesian3[]} positions 世界坐标顶点
6844
+ * @returns {number} 面积(平方米)
6845
+ */
6846
+ static #sphericalPolygonArea(positions) {
6847
+ const ellipsoid = Cesium$7.Ellipsoid.WGS84;
6848
+ const n = positions.length;
6849
+ if (n < 3) return 0;
6850
+
6851
+ // 计算近似重心(归一化到椭球面)
6852
+ let center = new Cesium$7.Cartesian3(0, 0, 0);
6853
+ for (const p of positions) {
6854
+ center = Cesium$7.Cartesian3.add(center, p, center);
6855
+ }
6856
+ center = Cesium$7.Cartesian3.normalize(center, new Cesium$7.Cartesian3());
6857
+ center = ellipsoid.scaleToGeodeticSurface(center, new Cesium$7.Cartesian3()) || center;
6858
+
6859
+ // 在重心处建立东北天(ENU)局部坐标系
6860
+ const tangentPlane = new Cesium$7.EllipsoidTangentPlane(center, ellipsoid);
6861
+
6862
+ // 投影到切平面
6863
+ const projected = positions.map(p => tangentPlane.projectPointOntoPlane(p, new Cesium$7.Cartesian2()));
6864
+
6865
+ // 计算二维多边形面积(Shoelace 公式)
6866
+ let area2 = 0;
6867
+ for (let i = 0; i < n; i++) {
6868
+ const p1 = projected[i];
6869
+ const p2 = projected[(i + 1) % n];
6870
+ area2 += p1.x * p2.y - p2.x * p1.y;
6871
+ }
6872
+
6873
+ return Math.abs(area2) * 0.5;
6874
+ }
6875
+
6876
+ /**
6877
+ * 获取指定地理坐标的高程
6878
+ * @param {Cesium.Viewer} viewer Cesium 实例
6879
+ * @param {Array<number>} coord [lng, lat]
6880
+ * @returns {Promise<number>} 高程值
6881
+ */
6882
+ static async getHeight(viewer, coord) {
6883
+ const cartographic = Cesium$7.Cartographic.fromDegrees(coord[0], coord[1]);
6884
+ const results = await Cesium$7.sampleTerrainMostDetailed(viewer.terrainProvider, [cartographic]);
6885
+ return results[0]?.height ?? 0;
6886
+ }
6887
+ }
6888
+
6889
+ const Cesium$6 = getCesium();
6890
+
6891
+ /**
6892
+ * 测量类型枚举
6893
+ */
6894
+ const MeasureType = {
6895
+ DISTANCE: 'distance',
6896
+ AREA: 'area'
6897
+ };
6898
+
6899
+ /**
6900
+ * 测量工具
6901
+ * 支持交互式测距(折线)和测面积(多边形)。
6902
+ * 左键加点,右键 / Enter 完成,Esc 取消,Backspace 撤销上一点。
6903
+ */
6904
+ class MeasureTool extends BaseTool {
6905
+ constructor(editorModule, options = {}) {
6906
+ super(editorModule, options);
6907
+
6908
+ this._measureType = options.measureType || MeasureType.DISTANCE;
6909
+ this._positions = []; // 已点击的经纬度点
6910
+ this._mousePos = null; // 当前鼠标位置(经纬度)
6911
+ this._isMeasuring = false; // 是否正在一次测量中
6912
+ this._lastResult = null; // 最后一次测量结果
6913
+
6914
+ // 临时图元引用
6915
+ this._pointEntities = []; // 点击点标记
6916
+ this._previewLine = null; // 测距预览线
6917
+ this._previewPolygon = null; // 测面积预览面
6918
+ this._previewOutline = null; // 测面积预览轮廓线
6919
+ this._previewCartesians = []; // 当前预览几何的笛卡尔坐标数组(CallbackProperty 共享引用)
6920
+ this._segmentLabelEntities = []; // 测距每段标注
6921
+ this._totalLabelEntity = null; // 总距离 / 面积标注
6922
+
6923
+ // 已完成的测量结果图元分组,支持一次激活中保留多个测量结果
6924
+ this._finishedResults = [];
6925
+ }
6926
+
6927
+ /**
6928
+ * 设置测量类型
6929
+ * @param {string} type MeasureType
6930
+ */
6931
+ setMeasureType(type) {
6932
+ this._measureType = type;
6933
+ return this;
6934
+ }
6935
+
6936
+ /**
6937
+ * 获取当前测量类型
6938
+ */
6939
+ getMeasureType() {
6940
+ return this._measureType;
6941
+ }
6942
+
6943
+ /**
6944
+ * 获取最后一次测量结果
6945
+ */
6946
+ getLastResult() {
6947
+ return this._lastResult;
6948
+ }
6949
+
6950
+ onActivate() {
6951
+ this.registerObserver('mouse:click', this._onClick.bind(this));
6952
+ this.registerObserver('mouse:move', this._onMove.bind(this));
6953
+ this.registerObserver('mouse:rightclick', this._onRightClick.bind(this));
6954
+ this.registerObserver('keyboard:keydown', this._onKeyDown.bind(this));
6955
+ }
6956
+
6957
+ onDeactivate() {
6958
+ this.clearMeasurements();
6959
+ }
6960
+
6961
+ _onClick(lngLat) {
6962
+ if (!lngLat) return;
6963
+
6964
+ this._isMeasuring = true;
6965
+ this._positions.push(lngLat);
6966
+ this._addPointMarker(lngLat);
6967
+ this._updateMeasurement();
6968
+ }
6969
+
6970
+ _onMove(data) {
6971
+ const screenPos = data.position || data.endPosition;
6972
+ if (!screenPos) return;
6973
+
6974
+ const lonLat = this.screenToLonLat({ x: screenPos.x, y: screenPos.y });
6975
+ if (!lonLat) return;
6976
+
6977
+ this._mousePos = lonLat;
6978
+ if (this._isMeasuring) {
6979
+ this._updateMeasurement();
6980
+ }
6981
+ }
6982
+
6983
+ _onRightClick() {
6984
+ this._finishMeasurement();
6985
+ }
6986
+
6987
+ _onKeyDown(data) {
6988
+ if (data.key === 'Escape') {
6989
+ this.cancelMeasurement();
6990
+ return;
6991
+ }
6992
+
6993
+ if (data.key === 'Enter') {
6994
+ this._finishMeasurement();
6995
+ return;
6996
+ }
6997
+
6998
+ if (data.key === 'Backspace' && this._isMeasuring && this._positions.length > 0) {
6999
+ this._positions.pop();
7000
+ const lastPoint = this._pointEntities.pop();
7001
+ if (lastPoint) {
7002
+ this.removeTempEntity(lastPoint);
7003
+ }
7004
+ this._updateMeasurement();
7005
+ }
7006
+ }
7007
+
7008
+ /**
7009
+ * 完成当前测量
7010
+ */
7011
+ _finishMeasurement() {
7012
+ const minPoints = this._measureType === MeasureType.AREA ? 3 : 2;
7013
+ if (this._positions.length < minPoints) return;
7014
+
7015
+ this._isMeasuring = false;
7016
+ this._mousePos = null;
7017
+ this._updateMeasurement();
7018
+
7019
+ const result = this._computeResult(this._positions);
7020
+ this._lastResult = result;
7021
+
7022
+ // 将当前测量结果保留在场景中,并清空工作态以便继续下一次测量
7023
+ this._commitCurrentResult();
7024
+
7025
+ this._emitMeasureComplete(result);
7026
+ }
7027
+
7028
+ /**
7029
+ * 把当前测量图元归档为已完成结果,重置工作态
7030
+ */
7031
+ _commitCurrentResult() {
7032
+ const finalCartesians = this._previewCartesians.slice();
7033
+
7034
+ // 将动态 CallbackProperty 替换为常量几何,避免归档后随 _previewCartesians 变化而消失
7035
+ if (this._previewLine) {
7036
+ this._previewLine.polyline.positions = finalCartesians.length > 0 ? finalCartesians : [];
7037
+ }
7038
+ if (this._previewPolygon) {
7039
+ this._previewPolygon.polygon.hierarchy = finalCartesians.length >= 3
7040
+ ? new Cesium$6.PolygonHierarchy(finalCartesians)
7041
+ : new Cesium$6.PolygonHierarchy([]);
7042
+ }
7043
+ if (this._previewOutline) {
7044
+ this._previewOutline.polyline.positions = finalCartesians.length >= 3
7045
+ ? [...finalCartesians, finalCartesians[0]]
7046
+ : [];
7047
+ }
7048
+
7049
+ this._finishedResults.push({
7050
+ pointEntities: this._pointEntities,
7051
+ segmentLabels: this._segmentLabelEntities,
7052
+ totalLabel: this._totalLabelEntity,
7053
+ previewLine: this._previewLine,
7054
+ previewPolygon: this._previewPolygon,
7055
+ previewOutline: this._previewOutline
7056
+ });
7057
+
7058
+ this._positions = [];
7059
+ this._mousePos = null;
7060
+ this._isMeasuring = false;
7061
+ this._previewCartesians = [];
7062
+
7063
+ this._pointEntities = [];
7064
+ this._segmentLabelEntities = [];
7065
+ this._totalLabelEntity = null;
7066
+ this._previewLine = null;
7067
+ this._previewPolygon = null;
7068
+ this._previewOutline = null;
7069
+ }
7070
+
7071
+ /**
7072
+ * 取消当前测量
7073
+ */
7074
+ cancelMeasurement() {
7075
+ this.clearMeasurements();
7076
+ this._emitMeasureCancel();
7077
+ }
7078
+
7079
+ /**
7080
+ * 清空所有测量结果与临时图元
7081
+ */
7082
+ clearMeasurements() {
7083
+ this._positions = [];
7084
+ this._mousePos = null;
7085
+ this._isMeasuring = false;
7086
+ this._lastResult = null;
7087
+ this._previewCartesians = [];
7088
+
7089
+ this._pointEntities.forEach(e => this.removeTempEntity(e));
7090
+ this._pointEntities = [];
7091
+
7092
+ this._segmentLabelEntities.forEach(e => this.removeTempEntity(e));
7093
+ this._segmentLabelEntities = [];
7094
+
7095
+ if (this._totalLabelEntity) {
7096
+ this.removeTempEntity(this._totalLabelEntity);
7097
+ this._totalLabelEntity = null;
7098
+ }
7099
+
7100
+ if (this._previewLine) {
7101
+ this.removeTempEntity(this._previewLine);
7102
+ this._previewLine = null;
7103
+ }
7104
+
7105
+ if (this._previewPolygon) {
7106
+ this.removeTempEntity(this._previewPolygon);
7107
+ this._previewPolygon = null;
7108
+ }
7109
+
7110
+ if (this._previewOutline) {
7111
+ this.removeTempEntity(this._previewOutline);
7112
+ this._previewOutline = null;
7113
+ }
7114
+
7115
+ this._finishedResults.forEach(group => {
7116
+ group.pointEntities.forEach(e => this.removeTempEntity(e));
7117
+ group.segmentLabels.forEach(e => this.removeTempEntity(e));
7118
+ if (group.totalLabel) this.removeTempEntity(group.totalLabel);
7119
+ if (group.previewLine) this.removeTempEntity(group.previewLine);
7120
+ if (group.previewPolygon) this.removeTempEntity(group.previewPolygon);
7121
+ if (group.previewOutline) this.removeTempEntity(group.previewOutline);
7122
+ });
7123
+ this._finishedResults = [];
7124
+ }
7125
+
7126
+ /**
7127
+ * 更新预览几何与标注
7128
+ */
7129
+ _updateMeasurement() {
7130
+ if (this._positions.length === 0) return;
7131
+
7132
+ const positions = [...this._positions];
7133
+ if (this._isMeasuring && this._mousePos) {
7134
+ positions.push(this._mousePos);
7135
+ }
7136
+
7137
+ if (this._measureType === MeasureType.DISTANCE) {
7138
+ this._updateDistancePreview(positions);
7139
+ } else {
7140
+ this._updateAreaPreview(positions);
7141
+ }
7142
+
7143
+ if (this._isMeasuring) {
7144
+ this._emitMeasureProgress(this._computeResult(positions));
7145
+ }
7146
+ }
7147
+
7148
+ _updateDistancePreview(positions) {
7149
+ const cartesians = positions.length >= 2
7150
+ ? positions.map(p => Cesium$6.Cartesian3.fromDegrees(...p))
7151
+ : [];
7152
+ this._previewCartesians = cartesians;
7153
+
7154
+ // 预览线
7155
+ if (!this._previewLine) {
7156
+ this._previewLine = this.createTempEntity(this.generateId('measure_line'), {
7157
+ polyline: {
7158
+ positions: new Cesium$6.CallbackProperty(() => this._previewCartesians, false),
7159
+ material: Cesium$6.Color.YELLOW,
7160
+ width: 2,
7161
+ clampToGround: true
7162
+ }
7163
+ });
7164
+ }
7165
+ this._previewLine.show = cartesians.length >= 2;
7166
+
7167
+ // 每段标注
7168
+ const segmentCount = Math.max(0, positions.length - 1);
7169
+ this._ensureSegmentLabels(segmentCount);
7170
+
7171
+ let total = 0;
7172
+ for (let i = 0; i < segmentCount; i++) {
7173
+ const p1 = positions[i];
7174
+ const p2 = positions[i + 1];
7175
+ const dist = GeoCalcUtil.calcDistance(p1, p2);
7176
+ total += dist;
7177
+
7178
+ const mid = Cesium$6.Cartesian3.midpoint(
7179
+ Cesium$6.Cartesian3.fromDegrees(...p1),
7180
+ Cesium$6.Cartesian3.fromDegrees(...p2),
7181
+ new Cesium$6.Cartesian3()
7182
+ );
7183
+
7184
+ const label = this._segmentLabelEntities[i];
7185
+ label.position = mid;
7186
+ label.label.text = this._formatDistance(dist).text;
7187
+ label.show = true;
7188
+ }
7189
+
7190
+ // 总距离标注
7191
+ const lastCartesian = cartesians[cartesians.length - 1];
7192
+ if (positions.length >= 2) {
7193
+ if (!this._totalLabelEntity) {
7194
+ this._totalLabelEntity = this._createLabelEntity(
7195
+ this.generateId('measure_total'),
7196
+ lastCartesian,
7197
+ `总长:${this._formatDistance(total).text}`
7198
+ );
7199
+ } else {
7200
+ this._totalLabelEntity.position = lastCartesian;
7201
+ this._totalLabelEntity.label.text = `总长:${this._formatDistance(total).text}`;
7202
+ this._totalLabelEntity.show = true;
7203
+ }
7204
+ } else if (this._totalLabelEntity) {
7205
+ this._totalLabelEntity.show = false;
7206
+ }
7207
+ }
7208
+
7209
+ _updateAreaPreview(positions) {
7210
+ const cartesians = positions.map(p => Cesium$6.Cartesian3.fromDegrees(...p));
7211
+ this._previewCartesians = cartesians;
7212
+
7213
+ if (positions.length >= 3) {
7214
+ // 显示面 + 闭合轮廓
7215
+ if (!this._previewPolygon) {
7216
+ this._previewPolygon = this.createTempEntity(this.generateId('measure_polygon'), {
7217
+ polygon: {
7218
+ hierarchy: new Cesium$6.CallbackProperty(() => new Cesium$6.PolygonHierarchy(this._previewCartesians), false),
7219
+ material: Cesium$6.Color.YELLOW.withAlpha(0.2),
7220
+ outline: false
7221
+ }
7222
+ });
7223
+ this._previewOutline = this.createTempEntity(this.generateId('measure_outline'), {
7224
+ polyline: {
7225
+ positions: new Cesium$6.CallbackProperty(() => this._previewCartesians.length > 0
7226
+ ? [...this._previewCartesians, this._previewCartesians[0]]
7227
+ : [], false),
7228
+ material: Cesium$6.Color.YELLOW,
7229
+ width: 2,
7230
+ clampToGround: true
7231
+ }
7232
+ });
7233
+ }
7234
+ this._previewPolygon.show = true;
7235
+ this._previewOutline.show = true;
7236
+ if (this._previewLine) {
7237
+ this._previewLine.show = false;
7238
+ }
7239
+
7240
+ const area = GeoCalcUtil.calcArea(positions);
7241
+ const centroid = this._computeCentroid(cartesians);
7242
+
7243
+ if (!this._totalLabelEntity) {
7244
+ this._totalLabelEntity = this._createLabelEntity(
7245
+ this.generateId('measure_area'),
7246
+ centroid,
7247
+ `面积:${this._formatArea(area).text}`
7248
+ );
7249
+ } else {
7250
+ this._totalLabelEntity.position = centroid;
7251
+ this._totalLabelEntity.label.text = `面积:${this._formatArea(area).text}`;
7252
+ this._totalLabelEntity.show = true;
7253
+ }
7254
+ } else {
7255
+ // 不足 3 点时只显示连线,并隐藏已有的面、轮廓、面积标注
7256
+ if (this._previewPolygon) {
7257
+ this._previewPolygon.show = false;
7258
+ }
7259
+ if (this._previewOutline) {
7260
+ this._previewOutline.show = false;
7261
+ }
7262
+ if (this._totalLabelEntity) {
7263
+ this._totalLabelEntity.show = false;
7264
+ }
7265
+
7266
+ if (!this._previewLine) {
7267
+ this._previewLine = this.createTempEntity(this.generateId('measure_line'), {
7268
+ polyline: {
7269
+ positions: new Cesium$6.CallbackProperty(() => this._previewCartesians, false),
7270
+ material: Cesium$6.Color.YELLOW,
7271
+ width: 2,
7272
+ clampToGround: true
7273
+ }
7274
+ });
7275
+ }
7276
+ this._previewLine.show = positions.length >= 2;
7277
+ }
7278
+ }
7279
+
7280
+ _ensureSegmentLabels(count) {
7281
+ // 移除多余的标注
7282
+ while (this._segmentLabelEntities.length > count) {
7283
+ const label = this._segmentLabelEntities.pop();
7284
+ this.removeTempEntity(label);
7285
+ }
7286
+
7287
+ // 创建缺少的标注
7288
+ while (this._segmentLabelEntities.length < count) {
7289
+ const label = this._createLabelEntity(
7290
+ this.generateId('measure_segment'),
7291
+ Cesium$6.Cartesian3.ZERO,
7292
+ ''
7293
+ );
7294
+ this._segmentLabelEntities.push(label);
7295
+ }
7296
+ }
7297
+
7298
+ _createLabelEntity(id, position, text) {
7299
+ return this.createTempEntity(id, {
7300
+ position,
7301
+ label: {
7302
+ text,
7303
+ font: '14px Microsoft YaHei',
7304
+ fillColor: Cesium$6.Color.WHITE,
7305
+ outlineColor: Cesium$6.Color.BLACK,
7306
+ outlineWidth: 2,
7307
+ style: Cesium$6.LabelStyle.FILL_AND_OUTLINE,
7308
+ verticalOrigin: Cesium$6.VerticalOrigin.BOTTOM,
7309
+ horizontalOrigin: Cesium$6.HorizontalOrigin.CENTER,
7310
+ heightReference: Cesium$6.HeightReference.CLAMP_TO_GROUND,
7311
+ disableDepthTestDistance: Number.POSITIVE_INFINITY,
7312
+ pixelOffset: new Cesium$6.Cartesian2(0, -10)
7313
+ }
7314
+ });
7315
+ }
7316
+
7317
+ _addPointMarker(lonLat) {
7318
+ const point = this.createTempEntity(this.generateId('measure_point'), {
7319
+ position: Cesium$6.Cartesian3.fromDegrees(...lonLat),
7320
+ point: {
7321
+ color: Cesium$6.Color.YELLOW,
7322
+ pixelSize: 8,
7323
+ outlineColor: Cesium$6.Color.BLACK,
7324
+ outlineWidth: 1,
7325
+ heightReference: Cesium$6.HeightReference.CLAMP_TO_GROUND,
7326
+ disableDepthTestDistance: Number.POSITIVE_INFINITY
7327
+ }
7328
+ });
7329
+ this._pointEntities.push(point);
7330
+ }
7331
+
7332
+ _computeResult(positions) {
7333
+ if (this._measureType === MeasureType.DISTANCE) {
7334
+ let total = 0;
7335
+ for (let i = 0; i < positions.length - 1; i++) {
7336
+ total += GeoCalcUtil.calcDistance(positions[i], positions[i + 1]);
7337
+ }
7338
+ const fmt = this._formatDistance(total);
7339
+ return {
7340
+ type: MeasureType.DISTANCE,
7341
+ value: total,
7342
+ unit: fmt.unit,
7343
+ formatted: fmt.text,
7344
+ positions: positions.slice()
7345
+ };
7346
+ }
7347
+
7348
+ const area = GeoCalcUtil.calcArea(positions);
7349
+ const fmt = this._formatArea(area);
7350
+ return {
7351
+ type: MeasureType.AREA,
7352
+ value: area,
7353
+ unit: fmt.unit,
7354
+ formatted: fmt.text,
7355
+ positions: positions.slice()
7356
+ };
7357
+ }
7358
+
7359
+ _computeCentroid(cartesians) {
7360
+ const center = new Cesium$6.Cartesian3(0, 0, 0);
7361
+ for (const c of cartesians) {
7362
+ Cesium$6.Cartesian3.add(center, c, center);
7363
+ }
7364
+ return Cesium$6.Cartesian3.multiplyByScalar(center, 1 / cartesians.length, center);
7365
+ }
7366
+
7367
+ _formatDistance(meters) {
7368
+ if (meters >= 1000) {
7369
+ return { text: `${(meters / 1000).toFixed(2)} km`, unit: 'km' };
7370
+ }
7371
+ return { text: `${meters.toFixed(2)} m`, unit: 'm' };
7372
+ }
7373
+
7374
+ _formatArea(squareMeters) {
7375
+ if (squareMeters >= 1000000) {
7376
+ return { text: `${(squareMeters / 1000000).toFixed(3)} km²`, unit: 'km²' };
7377
+ }
7378
+ return { text: `${squareMeters.toFixed(2)} m²`, unit: 'm²' };
7379
+ }
7380
+
7381
+ _emitMeasureProgress(result) {
7382
+ if (this._options.onMeasureProgress) {
7383
+ this._options.onMeasureProgress(result);
7384
+ }
7385
+ }
7386
+
7387
+ _emitMeasureComplete(result) {
7388
+ if (this._options.onMeasureComplete) {
7389
+ this._options.onMeasureComplete(result);
7390
+ }
7391
+ }
7392
+
7393
+ _emitMeasureCancel() {
7394
+ if (this._options.onMeasureCancel) {
7395
+ this._options.onMeasureCancel();
7396
+ }
7397
+ }
7398
+ }
7399
+
6739
7400
  /**
6740
7401
  * 工具名称枚举
6741
7402
  */
@@ -6743,7 +7404,8 @@ const ToolName = {
6743
7404
  DRAW: 'draw',
6744
7405
  EDIT: 'edit',
6745
7406
  SELECT: 'select',
6746
- DELETE: 'delete'
7407
+ DELETE: 'delete',
7408
+ MEASURE: 'measure'
6747
7409
  };
6748
7410
 
6749
7411
  /**
@@ -6781,6 +7443,7 @@ class EditorModule {
6781
7443
  this.registerTool(ToolName.EDIT, new EditTool(this));
6782
7444
  this.registerTool(ToolName.SELECT, new SelectTool(this));
6783
7445
  this.registerTool(ToolName.DELETE, new DeleteTool(this));
7446
+ this.registerTool(ToolName.MEASURE, new MeasureTool(this));
6784
7447
 
6785
7448
  return this;
6786
7449
  }
@@ -6915,6 +7578,39 @@ class EditorModule {
6915
7578
  return this.activateTool(ToolName.DELETE);
6916
7579
  }
6917
7580
 
7581
+ /**
7582
+ * 激活测量工具并设置类型
7583
+ * @param {string} type 测量类型 MeasureType
7584
+ * @returns {EditorModule}
7585
+ */
7586
+ activateMeasureTool(type = MeasureType.DISTANCE) {
7587
+ const measureTool = this.toolMap.get(ToolName.MEASURE);
7588
+ if (!measureTool) {
7589
+ return this;
7590
+ }
7591
+
7592
+ // 已经处于测量工具时:不要 deactivate(避免清空历史结果),
7593
+ // 直接切换类型并把正在进行的测量提交为已完成结果。
7594
+ if (this.currentToolName === ToolName.MEASURE) {
7595
+ measureTool.setMeasureType(type);
7596
+ if (measureTool._isMeasuring) {
7597
+ measureTool._finishMeasurement();
7598
+ }
7599
+ return this;
7600
+ }
7601
+
7602
+ measureTool.setMeasureType(type);
7603
+ return this.activateTool(ToolName.MEASURE);
7604
+ }
7605
+
7606
+ /**
7607
+ * 获取测量工具(快捷方法)
7608
+ * @returns {MeasureTool}
7609
+ */
7610
+ getMeasureTool() {
7611
+ return this.toolMap.get(ToolName.MEASURE);
7612
+ }
7613
+
6918
7614
  /**
6919
7615
  * 获取绘制工具(快捷方法)
6920
7616
  * @returns {DrawTool}
@@ -7021,6 +7717,33 @@ class EditorModule {
7021
7717
  return this;
7022
7718
  }
7023
7719
 
7720
+ /**
7721
+ * 设置测量进度回调
7722
+ * @param {Function} callback
7723
+ */
7724
+ onMeasureProgress(callback) {
7725
+ this.getMeasureTool()._options.onMeasureProgress = callback;
7726
+ return this;
7727
+ }
7728
+
7729
+ /**
7730
+ * 设置测量完成回调
7731
+ * @param {Function} callback
7732
+ */
7733
+ onMeasureComplete(callback) {
7734
+ this.getMeasureTool()._options.onMeasureComplete = callback;
7735
+ return this;
7736
+ }
7737
+
7738
+ /**
7739
+ * 设置测量取消回调
7740
+ * @param {Function} callback
7741
+ */
7742
+ onMeasureCancel(callback) {
7743
+ this.getMeasureTool()._options.onMeasureCancel = callback;
7744
+ return this;
7745
+ }
7746
+
7024
7747
  /**
7025
7748
  * 设置删除前回调
7026
7749
  * @param {Function} callback
@@ -7360,7 +8083,7 @@ class BaseControl {
7360
8083
  _destroy() { }
7361
8084
  }
7362
8085
 
7363
- const Cesium$6 = getCesium();
8086
+ const Cesium$5 = getCesium();
7364
8087
 
7365
8088
  /**
7366
8089
  * 状态栏控件
@@ -7440,7 +8163,7 @@ class LocationBar extends BaseControl {
7440
8163
  const rect = this._viewer.scene.canvas.getBoundingClientRect();
7441
8164
  const x = e.clientX - rect.left;
7442
8165
  const y = e.clientY - rect.top;
7443
- const screenPos = new Cesium$6.Cartesian2(x, y);
8166
+ const screenPos = new Cesium$5.Cartesian2(x, y);
7444
8167
 
7445
8168
  let cartesian = null;
7446
8169
 
@@ -7456,10 +8179,10 @@ class LocationBar extends BaseControl {
7456
8179
  }
7457
8180
 
7458
8181
  if (cartesian) {
7459
- const cartographic = Cesium$6.Cartographic.fromCartesian(cartesian);
8182
+ const cartographic = Cesium$5.Cartographic.fromCartesian(cartesian);
7460
8183
  this._lastMouseData = {
7461
- lng: Cesium$6.Math.toDegrees(cartographic.longitude).toFixed(this._lngDecimal),
7462
- lat: Cesium$6.Math.toDegrees(cartographic.latitude).toFixed(this._latDecimal),
8184
+ lng: Cesium$5.Math.toDegrees(cartographic.longitude).toFixed(this._lngDecimal),
8185
+ lat: Cesium$5.Math.toDegrees(cartographic.latitude).toFixed(this._latDecimal),
7463
8186
  alt: cartographic.height.toFixed(2)
7464
8187
  };
7465
8188
  } else {
@@ -7479,8 +8202,8 @@ class LocationBar extends BaseControl {
7479
8202
  const positionCartographic = camera.positionCartographic;
7480
8203
 
7481
8204
  this._lastCameraData = {
7482
- heading: Cesium$6.Math.toDegrees(camera.heading).toFixed(2),
7483
- pitch: Cesium$6.Math.toDegrees(camera.pitch).toFixed(2),
8205
+ heading: Cesium$5.Math.toDegrees(camera.heading).toFixed(2),
8206
+ pitch: Cesium$5.Math.toDegrees(camera.pitch).toFixed(2),
7484
8207
  cameraHeight: positionCartographic.height.toFixed(2),
7485
8208
  level: this._getZoomLevel().toFixed(0)
7486
8209
  };
@@ -7506,12 +8229,12 @@ class LocationBar extends BaseControl {
7506
8229
  const positionCartographic = camera.positionCartographic;
7507
8230
 
7508
8231
  // 计算相机到正下方地表点的距离(视高),而不是到自己位置的距离
7509
- const surfaceCartesian = Cesium$6.Cartesian3.fromRadians(
8232
+ const surfaceCartesian = Cesium$5.Cartesian3.fromRadians(
7510
8233
  positionCartographic.longitude,
7511
8234
  positionCartographic.latitude,
7512
8235
  0
7513
8236
  );
7514
- const distance = Cesium$6.Cartesian3.distance(camera.position, surfaceCartesian);
8237
+ const distance = Cesium$5.Cartesian3.distance(camera.position, surfaceCartesian);
7515
8238
 
7516
8239
  if (!distance || distance <= 0 || !Number.isFinite(distance)) return 0;
7517
8240
 
@@ -7543,7 +8266,7 @@ class LocationBar extends BaseControl {
7543
8266
  }
7544
8267
  }
7545
8268
 
7546
- const Cesium$5 = getCesium();
8269
+ const Cesium$4 = getCesium();
7547
8270
 
7548
8271
  /**
7549
8272
  * 缩放控件
@@ -7566,7 +8289,11 @@ class Zoom extends BaseControl {
7566
8289
  _createContainer() {
7567
8290
  const div = super._createContainer();
7568
8291
  div.className += ' xs3d-zoom';
7569
- div.style.display = 'contents';
8292
+ // 只有在统一工具栏内才使用 display: contents,让按钮直接参与工具栏 flex 布局;
8293
+ // 自定义容器挂载时保留正常 absolute 定位,支持 top/left/right/bottom。
8294
+ if (this._parentContainer?.classList?.contains('xs3d-viewer-toolbar')) {
8295
+ div.style.display = 'contents';
8296
+ }
7570
8297
  return div;
7571
8298
  }
7572
8299
 
@@ -7639,7 +8366,7 @@ class Zoom extends BaseControl {
7639
8366
  const targetHeight = this._getHeightByZoomLevel(targetLevel);
7640
8367
 
7641
8368
  camera.flyTo({
7642
- destination: Cesium$5.Cartesian3.fromRadians(
8369
+ destination: Cesium$4.Cartesian3.fromRadians(
7643
8370
  cartographic.longitude,
7644
8371
  cartographic.latitude,
7645
8372
  targetHeight
@@ -7655,12 +8382,12 @@ class Zoom extends BaseControl {
7655
8382
 
7656
8383
  _getZoomLevel() {
7657
8384
  const positionCartographic = this._viewer.camera.positionCartographic;
7658
- const surfaceCartesian = Cesium$5.Cartesian3.fromRadians(
8385
+ const surfaceCartesian = Cesium$4.Cartesian3.fromRadians(
7659
8386
  positionCartographic.longitude,
7660
8387
  positionCartographic.latitude,
7661
8388
  0
7662
8389
  );
7663
- const distance = Cesium$5.Cartesian3.distance(this._viewer.camera.position, surfaceCartesian);
8390
+ const distance = Cesium$4.Cartesian3.distance(this._viewer.camera.position, surfaceCartesian);
7664
8391
  if (!distance || distance <= 0 || !Number.isFinite(distance)) return 0;
7665
8392
  const equatorCircumference = 6378137 * 2 * Math.PI;
7666
8393
  return Math.max(0, Math.floor(Math.log2(equatorCircumference / distance)) + 1);
@@ -7672,7 +8399,7 @@ class Zoom extends BaseControl {
7672
8399
  }
7673
8400
  }
7674
8401
 
7675
- const Cesium$4 = getCesium();
8402
+ const Cesium$3 = getCesium();
7676
8403
 
7677
8404
  /**
7678
8405
  * 指南针控件
@@ -7823,7 +8550,7 @@ class Compass extends BaseControl {
7823
8550
 
7824
8551
  _updateRotation() {
7825
8552
  if (!this._outerEl) return;
7826
- const heading = Cesium$4.Math.toDegrees(this._viewer.camera.heading);
8553
+ const heading = Cesium$3.Math.toDegrees(this._viewer.camera.heading);
7827
8554
  this._outerEl.style.transform = `rotate(${-heading}deg)`;
7828
8555
  }
7829
8556
 
@@ -7876,7 +8603,7 @@ class Compass extends BaseControl {
7876
8603
 
7877
8604
  const camera = this._viewer.camera;
7878
8605
  if (this._rotateFrame) {
7879
- const oldTransform = Cesium$4.Matrix4.clone(camera.transform);
8606
+ const oldTransform = Cesium$3.Matrix4.clone(camera.transform);
7880
8607
  camera.lookAtTransform(this._rotateFrame);
7881
8608
  camera.rotateRight(delta);
7882
8609
  camera.lookAtTransform(oldTransform);
@@ -7918,10 +8645,10 @@ class Compass extends BaseControl {
7918
8645
  if (this._mode !== 'orbit') return;
7919
8646
  const deltaY = this._startY - e.clientY;
7920
8647
  const sensitivity = 0.004;
7921
- const newPitch = Cesium$4.Math.clamp(
8648
+ const newPitch = Cesium$3.Math.clamp(
7922
8649
  this._startPitch + deltaY * sensitivity,
7923
- -Cesium$4.Math.PI_OVER_TWO + 0.01,
7924
- Cesium$4.Math.PI_OVER_TWO - 0.01
8650
+ -Cesium$3.Math.PI_OVER_TWO + 0.01,
8651
+ Cesium$3.Math.PI_OVER_TWO - 0.01
7925
8652
  );
7926
8653
  this._viewer.camera.setView({
7927
8654
  destination: this._viewer.camera.position,
@@ -7945,26 +8672,26 @@ class Compass extends BaseControl {
7945
8672
  _getRotateFrame() {
7946
8673
  const scene = this._viewer.scene;
7947
8674
  const camera = this._viewer.camera;
7948
- if (scene.mode === Cesium$4.SceneMode.MORPHING) return null;
8675
+ if (scene.mode === Cesium$3.SceneMode.MORPHING) return null;
7949
8676
 
7950
8677
  let center;
7951
8678
  if (this._viewer.trackedEntity) {
7952
8679
  center = this._viewer.trackedEntity.position.getValue(this._viewer.clock.currentTime);
7953
8680
  } else {
7954
- const ray = new Cesium$4.Ray(camera.positionWC, camera.directionWC);
8681
+ const ray = new Cesium$3.Ray(camera.positionWC, camera.directionWC);
7955
8682
  center = scene.globe.pick(ray, scene);
7956
8683
  }
7957
8684
  if (!center) {
7958
8685
  center = camera.positionWC;
7959
8686
  }
7960
- return Cesium$4.Transforms.eastNorthUpToFixedFrame(center, scene.globe.ellipsoid);
8687
+ return Cesium$3.Transforms.eastNorthUpToFixedFrame(center, scene.globe.ellipsoid);
7961
8688
  }
7962
8689
 
7963
8690
  _onDoubleClick() {
7964
8691
  const camera = this._viewer.camera;
7965
8692
  const cartographic = camera.positionCartographic;
7966
8693
  camera.flyTo({
7967
- destination: Cesium$4.Cartesian3.fromRadians(
8694
+ destination: Cesium$3.Cartesian3.fromRadians(
7968
8695
  cartographic.longitude,
7969
8696
  cartographic.latitude,
7970
8697
  cartographic.height
@@ -7985,7 +8712,7 @@ class Compass extends BaseControl {
7985
8712
  }
7986
8713
  }
7987
8714
 
7988
- const Cesium$3 = getCesium();
8715
+ const Cesium$2 = getCesium();
7989
8716
 
7990
8717
  /**
7991
8718
  * 比例尺控件
@@ -8017,7 +8744,7 @@ class DistanceLegend extends BaseControl {
8017
8744
  base.forEach(b => this._distances.push(b * factor));
8018
8745
  }
8019
8746
 
8020
- this._geodesic = new Cesium$3.EllipsoidGeodesic();
8747
+ this._geodesic = new Cesium$2.EllipsoidGeodesic();
8021
8748
  this._lastUpdate = 0;
8022
8749
  }
8023
8750
 
@@ -8075,8 +8802,8 @@ class DistanceLegend extends BaseControl {
8075
8802
  const x = Math.floor(width / 2);
8076
8803
  const y = Math.max(0, height - 1);
8077
8804
 
8078
- const leftRay = camera.getPickRay(new Cesium$3.Cartesian2(x, y));
8079
- const rightRay = camera.getPickRay(new Cesium$3.Cartesian2(x + 1, y));
8805
+ const leftRay = camera.getPickRay(new Cesium$2.Cartesian2(x, y));
8806
+ const rightRay = camera.getPickRay(new Cesium$2.Cartesian2(x + 1, y));
8080
8807
  if (!leftRay || !rightRay) return;
8081
8808
 
8082
8809
  const leftPosition = scene.globe.pick(leftRay, scene);
@@ -8315,7 +9042,7 @@ class ControlModule {
8315
9042
  * 统一管理场景、图元、事件模块的实例
8316
9043
  */
8317
9044
 
8318
- const Cesium$2 = getCesium();
9045
+ const Cesium$1 = getCesium();
8319
9046
 
8320
9047
  class ModuleManager {
8321
9048
  static instance = null;
@@ -8340,13 +9067,19 @@ class ModuleManager {
8340
9067
  if (this.cesiumViewer) return this.cesiumViewer;
8341
9068
  const config = Config.getInstance().getConfig();
8342
9069
 
8343
- this.cesiumViewer = new Cesium$2.Viewer(container, config.scene);
9070
+ this.cesiumViewer = new Cesium$1.Viewer(container, config.scene);
8344
9071
  // 隐藏版权信息(可选,对齐平台界面规范)
8345
9072
  const creditContainer = this.cesiumViewer.cesiumWidget?.creditContainer;
8346
9073
  if (creditContainer) {
8347
9074
  creditContainer.style.display = 'none';
8348
9075
  }
8349
9076
 
9077
+ // 禁用画布默认右键菜单,保证 Cesium 右键事件可被正常处理
9078
+ const canvas = this.cesiumViewer.scene?.canvas;
9079
+ if (canvas) {
9080
+ canvas.addEventListener('contextmenu', (e) => e.preventDefault(), false);
9081
+ }
9082
+
8350
9083
  // 初始化所有模块(注入 Viewer 实例)
8351
9084
  this.registerModule('SceneModule', new SceneModule(this.cesiumViewer));
8352
9085
  this.registerModule('GraphicModule', new GraphicModule(this.cesiumViewer));
@@ -8492,7 +9225,7 @@ class ModuleManager {
8492
9225
  }
8493
9226
  }
8494
9227
 
8495
- const Cesium$1 = getCesium();
9228
+ const Cesium = getCesium();
8496
9229
 
8497
9230
  /**
8498
9231
  * 坐标转换工具(对齐平台 屏幕/世界/地理坐标转换)
@@ -8512,12 +9245,12 @@ class CoordinateUtil {
8512
9245
  if (Array.isArray(coord)) {
8513
9246
  if (from === 'scene') {
8514
9247
  // 地理坐标转世界坐标
8515
- sourceCoord = Cesium$1.Cartesian3.fromDegrees(...coord);
9248
+ sourceCoord = Cesium.Cartesian3.fromDegrees(...coord);
8516
9249
  } else if (from === 'world') {
8517
- sourceCoord = new Cesium$1.Cartesian3(coord[0], coord[1], coord[2]);
9250
+ sourceCoord = new Cesium.Cartesian3(coord[0], coord[1], coord[2]);
8518
9251
  } else if (from === 'screen') {
8519
9252
  // 屏幕坐标数组需先转为 Cartesian2
8520
- sourceCoord = new Cesium$1.Cartesian2(coord[0], coord[1]);
9253
+ sourceCoord = new Cesium.Cartesian2(coord[0], coord[1]);
8521
9254
  }
8522
9255
  }
8523
9256
 
@@ -8529,21 +9262,21 @@ class CoordinateUtil {
8529
9262
  // 屏幕坐标 -> 地理坐标
8530
9263
  case 'screen_scene':
8531
9264
  const worldCoord = viewer.camera.pickEllipsoid(sourceCoord);
8532
- const cartographic = Cesium$1.Cartographic.fromCartesian(worldCoord);
9265
+ const cartographic = Cesium.Cartographic.fromCartesian(worldCoord);
8533
9266
  return [
8534
- Cesium$1.Math.toDegrees(cartographic.longitude),
8535
- Cesium$1.Math.toDegrees(cartographic.latitude),
9267
+ Cesium.Math.toDegrees(cartographic.longitude),
9268
+ Cesium.Math.toDegrees(cartographic.latitude),
8536
9269
  cartographic.height
8537
9270
  ];
8538
9271
  // 世界坐标 -> 屏幕坐标
8539
9272
  case 'world_screen':
8540
- return Cesium$1.SceneTransforms.wgs84ToWindowCoordinates(viewer.scene, sourceCoord);
9273
+ return Cesium.SceneTransforms.wgs84ToWindowCoordinates(viewer.scene, sourceCoord);
8541
9274
  // 世界坐标 -> 地理坐标
8542
9275
  case 'world_scene':
8543
- const carto = Cesium$1.Cartographic.fromCartesian(sourceCoord);
9276
+ const carto = Cesium.Cartographic.fromCartesian(sourceCoord);
8544
9277
  return [
8545
- Cesium$1.Math.toDegrees(carto.longitude),
8546
- Cesium$1.Math.toDegrees(carto.latitude),
9278
+ Cesium.Math.toDegrees(carto.longitude),
9279
+ Cesium.Math.toDegrees(carto.latitude),
8547
9280
  carto.height
8548
9281
  ];
8549
9282
  // 地理坐标 -> 世界坐标(已在入参处理)
@@ -8551,111 +9284,13 @@ class CoordinateUtil {
8551
9284
  return sourceCoord;
8552
9285
  // 地理坐标 -> 屏幕坐标
8553
9286
  case 'scene_screen':
8554
- return Cesium$1.SceneTransforms.wgs84ToWindowCoordinates(viewer.scene, sourceCoord);
9287
+ return Cesium.SceneTransforms.wgs84ToWindowCoordinates(viewer.scene, sourceCoord);
8555
9288
  default:
8556
9289
  return sourceCoord;
8557
9290
  }
8558
9291
  }
8559
9292
  }
8560
9293
 
8561
- const Cesium = getCesium();
8562
-
8563
- /**
8564
- * 地理计算工具(距离、面积、高程)
8565
- */
8566
- class GeoCalcUtil {
8567
- /**
8568
- * 计算两点地理坐标距离(米)
8569
- * @param {Array<number>} point1 [lng, lat, height]
8570
- * @param {Array<number>} point2 [lng, lat, height]
8571
- * @returns {number} 距离
8572
- */
8573
- static calcDistance(point1, point2) {
8574
- const coord1 = Cesium.Cartesian3.fromDegrees(...point1);
8575
- const coord2 = Cesium.Cartesian3.fromDegrees(...point2);
8576
- return Cesium.Cartesian3.distance(coord1, coord2);
8577
- }
8578
-
8579
- /**
8580
- * 计算多边形面积(平方米)
8581
- * 使用球面多边形面积公式(基于 Cesium 几何顶点)
8582
- * @param {Array<Array<number>>} points 地理坐标点集 [lon, lat, height?]
8583
- * @returns {number} 面积
8584
- */
8585
- static calcArea(points) {
8586
- if (!points || points.length < 3) return 0;
8587
-
8588
- const positions = points.map(p => Cesium.Cartesian3.fromDegrees(p[0], p[1], p[2] || 0));
8589
- const polygon = new Cesium.PolygonGeometry({
8590
- polygonHierarchy: new Cesium.PolygonHierarchy(positions)
8591
- });
8592
- const geometry = Cesium.PolygonGeometry.createGeometry(polygon);
8593
-
8594
- if (!geometry || !geometry.attributes || !geometry.attributes.position) {
8595
- return 0;
8596
- }
8597
-
8598
- const values = geometry.attributes.position.values;
8599
- const vertexPositions = [];
8600
- for (let i = 0; i < values.length; i += 3) {
8601
- vertexPositions.push(new Cesium.Cartesian3(values[i], values[i + 1], values[i + 2]));
8602
- }
8603
-
8604
- // 球面多边形面积(基于单位球上的多边形面积公式)
8605
- const area = GeoCalcUtil.#sphericalPolygonArea(vertexPositions);
8606
- return Math.abs(area);
8607
- }
8608
-
8609
- /**
8610
- * 单位球面上多边形的有向面积(平方米)
8611
- * 采用局部切平面投影法:以多边形重心为原点建立切平面,投影后计算二维多边形面积。
8612
- * 对于常规 GIS 多边形精度足够;极大规模多边形可后续替换为更严格的球面 excess 算法。
8613
- * @param {Cesium.Cartesian3[]} positions 世界坐标顶点
8614
- * @returns {number} 面积(平方米)
8615
- */
8616
- static #sphericalPolygonArea(positions) {
8617
- const ellipsoid = Cesium.Ellipsoid.WGS84;
8618
- const n = positions.length;
8619
- if (n < 3) return 0;
8620
-
8621
- // 计算近似重心(归一化到椭球面)
8622
- let center = new Cesium.Cartesian3(0, 0, 0);
8623
- for (const p of positions) {
8624
- center = Cesium.Cartesian3.add(center, p, center);
8625
- }
8626
- center = Cesium.Cartesian3.normalize(center, new Cesium.Cartesian3());
8627
- center = ellipsoid.scaleToGeodeticSurface(center, new Cesium.Cartesian3()) || center;
8628
-
8629
- // 在重心处建立东北天(ENU)局部坐标系
8630
- const tangentPlane = new Cesium.EllipsoidTangentPlane(center, ellipsoid);
8631
-
8632
- // 投影到切平面
8633
- const projected = positions.map(p => tangentPlane.projectPointOntoPlane(p, new Cesium.Cartesian2()));
8634
-
8635
- // 计算二维多边形面积(Shoelace 公式)
8636
- let area2 = 0;
8637
- for (let i = 0; i < n; i++) {
8638
- const p1 = projected[i];
8639
- const p2 = projected[(i + 1) % n];
8640
- area2 += p1.x * p2.y - p2.x * p1.y;
8641
- }
8642
-
8643
- return Math.abs(area2) * 0.5;
8644
- }
8645
-
8646
- /**
8647
- * 获取指定地理坐标的高程
8648
- * @param {Cesium.Viewer} viewer Cesium 实例
8649
- * @param {Array<number>} coord [lng, lat]
8650
- * @returns {Promise<number>} 高程值
8651
- */
8652
- static async getHeight(viewer, coord) {
8653
- const cartographic = Cesium.Cartographic.fromDegrees(coord[0], coord[1]);
8654
- const results = await Cesium.sampleTerrainMostDetailed(viewer.terrainProvider, [cartographic]);
8655
- return results[0]?.height ?? 0;
8656
- }
8657
- }
8658
-
8659
9294
  // src/index.js
8660
9295
 
8661
9296
  // 核心 SDK 实例(直接导出,无嵌套)
@@ -8709,6 +9344,7 @@ const xs3d = {
8709
9344
  SelectType,
8710
9345
  DeleteMode,
8711
9346
  ToolName,
9347
+ MeasureType,
8712
9348
  LayerType,
8713
9349
  PlotGraphicType
8714
9350
  };