cesium-xs-sdk 1.0.9 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cesium-xs-sdk.cjs.js +1016 -484
- package/dist/cesium-xs-sdk.cjs.js.map +1 -1
- package/dist/cesium-xs-sdk.esm.js +1016 -484
- package/dist/cesium-xs-sdk.esm.js.map +1 -1
- package/dist/cesium-xs-sdk.umd.js +1 -1
- package/dist/cesium-xs-sdk.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/core/Config.js +4 -0
- package/src/core/ModuleManager.js +16 -0
- package/src/index.d.ts +51 -10
- package/src/index.js +2 -0
- package/src/modules/MilitarySymbolModule.js +504 -0
- package/src/modules/militarySymbolAssets.js +10 -0
- package/src/vue.d.ts +2 -1
- package/src/vue.js +3 -0
|
@@ -95,6 +95,10 @@ class Config {
|
|
|
95
95
|
navigationInstructionsInitiallyVisible: false,
|
|
96
96
|
depthTestAgainstTerrain: true, // 默认开启深度检测
|
|
97
97
|
},
|
|
98
|
+
// 军标模块默认配置
|
|
99
|
+
militarySymbol: {
|
|
100
|
+
defaultIconMode: 'default', // 'default' | 'custom' | 'overlay'
|
|
101
|
+
},
|
|
98
102
|
// 图元默认样式:延迟到 getConfig 时再构造,避免在 Cesium 未配置时崩溃
|
|
99
103
|
// (对 SSR 和单元测试更友好)
|
|
100
104
|
};
|
|
@@ -242,7 +246,7 @@ class Config {
|
|
|
242
246
|
}
|
|
243
247
|
}
|
|
244
248
|
|
|
245
|
-
const Cesium$
|
|
249
|
+
const Cesium$h = getCesium();
|
|
246
250
|
|
|
247
251
|
/**
|
|
248
252
|
* 图层类型枚举
|
|
@@ -328,10 +332,10 @@ function createProviderByType(type, url, opts) {
|
|
|
328
332
|
case LayerType.XYZ:
|
|
329
333
|
case LayerType.TMS:
|
|
330
334
|
// XYZ / TMS 均使用 UrlTemplateImageryProvider
|
|
331
|
-
return new Cesium$
|
|
335
|
+
return new Cesium$h.UrlTemplateImageryProvider({ url, ...opts });
|
|
332
336
|
|
|
333
337
|
case LayerType.WMTS:
|
|
334
|
-
return new Cesium$
|
|
338
|
+
return new Cesium$h.WebMapTileServiceImageryProvider({
|
|
335
339
|
url,
|
|
336
340
|
layer: opts.layer,
|
|
337
341
|
style: opts.style || 'default',
|
|
@@ -341,7 +345,7 @@ function createProviderByType(type, url, opts) {
|
|
|
341
345
|
});
|
|
342
346
|
|
|
343
347
|
case LayerType.WMS:
|
|
344
|
-
return new Cesium$
|
|
348
|
+
return new Cesium$h.WebMapServiceImageryProvider({
|
|
345
349
|
url,
|
|
346
350
|
layers: opts.layers || '',
|
|
347
351
|
parameters: { transparent: true, format: 'image/png', ...opts.parameters },
|
|
@@ -349,23 +353,23 @@ function createProviderByType(type, url, opts) {
|
|
|
349
353
|
});
|
|
350
354
|
|
|
351
355
|
case LayerType.SINGLE_IMAGE:
|
|
352
|
-
return new Cesium$
|
|
356
|
+
return new Cesium$h.SingleTileImageryProvider({
|
|
353
357
|
url,
|
|
354
|
-
rectangle: opts.extent ? Cesium$
|
|
358
|
+
rectangle: opts.extent ? Cesium$h.Rectangle.fromDegrees(...opts.extent) : undefined,
|
|
355
359
|
credit: opts.credit || '',
|
|
356
360
|
...opts
|
|
357
361
|
});
|
|
358
362
|
|
|
359
363
|
case LayerType.TERRAIN:
|
|
360
364
|
// fromUrl 返回 Promise,由 addProviderToViewer 统一 await
|
|
361
|
-
return Cesium$
|
|
365
|
+
return Cesium$h.CesiumTerrainProvider.fromUrl(url, {
|
|
362
366
|
requestWaterMask: opts.requestWaterMask ?? false,
|
|
363
367
|
requestVertexNormals: opts.requestVertexNormals ?? false,
|
|
364
368
|
...opts
|
|
365
369
|
});
|
|
366
370
|
|
|
367
371
|
case LayerType['3DTILES']:
|
|
368
|
-
return new Cesium$
|
|
372
|
+
return new Cesium$h.Cesium3DTileset({
|
|
369
373
|
url,
|
|
370
374
|
maximumScreenSpaceError: opts.maximumScreenSpaceError ?? 16,
|
|
371
375
|
maximumMemoryUsage: opts.maximumMemoryUsage ?? 512,
|
|
@@ -472,10 +476,10 @@ class ImageryLayerWrapper {
|
|
|
472
476
|
if (provider && provider.rectangle) {
|
|
473
477
|
const rect = provider.rectangle;
|
|
474
478
|
return {
|
|
475
|
-
west: Cesium$
|
|
476
|
-
south: Cesium$
|
|
477
|
-
east: Cesium$
|
|
478
|
-
north: Cesium$
|
|
479
|
+
west: Cesium$h.Math.toDegrees(rect.west),
|
|
480
|
+
south: Cesium$h.Math.toDegrees(rect.south),
|
|
481
|
+
east: Cesium$h.Math.toDegrees(rect.east),
|
|
482
|
+
north: Cesium$h.Math.toDegrees(rect.north)
|
|
479
483
|
};
|
|
480
484
|
}
|
|
481
485
|
return null;
|
|
@@ -519,10 +523,10 @@ class TerrainLayerWrapper {
|
|
|
519
523
|
if (this._provider.rectangle) {
|
|
520
524
|
const rect = this._provider.rectangle;
|
|
521
525
|
return {
|
|
522
|
-
west: Cesium$
|
|
523
|
-
south: Cesium$
|
|
524
|
-
east: Cesium$
|
|
525
|
-
north: Cesium$
|
|
526
|
+
west: Cesium$h.Math.toDegrees(rect.west),
|
|
527
|
+
south: Cesium$h.Math.toDegrees(rect.south),
|
|
528
|
+
east: Cesium$h.Math.toDegrees(rect.east),
|
|
529
|
+
north: Cesium$h.Math.toDegrees(rect.north)
|
|
526
530
|
};
|
|
527
531
|
}
|
|
528
532
|
return { west: -180, south: -85, east: 180, north: 85 };
|
|
@@ -561,17 +565,17 @@ class TilesetLayerWrapper {
|
|
|
561
565
|
getExtent() {
|
|
562
566
|
if (this._tileset.boundingSphere) {
|
|
563
567
|
const bs = this._tileset.boundingSphere;
|
|
564
|
-
const cartographic = Cesium$
|
|
568
|
+
const cartographic = Cesium$h.Cartographic.fromCartesian(bs.center);
|
|
565
569
|
const rect = this._tileset.rectangle;
|
|
566
570
|
if (rect) {
|
|
567
571
|
return {
|
|
568
|
-
west: Cesium$
|
|
569
|
-
south: Cesium$
|
|
570
|
-
east: Cesium$
|
|
571
|
-
north: Cesium$
|
|
572
|
+
west: Cesium$h.Math.toDegrees(rect.west),
|
|
573
|
+
south: Cesium$h.Math.toDegrees(rect.south),
|
|
574
|
+
east: Cesium$h.Math.toDegrees(rect.east),
|
|
575
|
+
north: Cesium$h.Math.toDegrees(rect.north),
|
|
572
576
|
center: [
|
|
573
|
-
Cesium$
|
|
574
|
-
Cesium$
|
|
577
|
+
Cesium$h.Math.toDegrees(cartographic.longitude),
|
|
578
|
+
Cesium$h.Math.toDegrees(cartographic.latitude)
|
|
575
579
|
]
|
|
576
580
|
};
|
|
577
581
|
}
|
|
@@ -609,20 +613,20 @@ class SceneModule {
|
|
|
609
613
|
// ========== 坐标转换 ==========
|
|
610
614
|
|
|
611
615
|
lonLatToWorld(lon, lat, height = 0) {
|
|
612
|
-
return Cesium$
|
|
616
|
+
return Cesium$h.Cartesian3.fromDegrees(lon, lat, height);
|
|
613
617
|
}
|
|
614
618
|
|
|
615
619
|
worldToLonLat(cartesian) {
|
|
616
|
-
const cartographic = Cesium$
|
|
620
|
+
const cartographic = Cesium$h.Cartographic.fromCartesian(cartesian);
|
|
617
621
|
return [
|
|
618
|
-
Cesium$
|
|
619
|
-
Cesium$
|
|
622
|
+
Cesium$h.Math.toDegrees(cartographic.longitude),
|
|
623
|
+
Cesium$h.Math.toDegrees(cartographic.latitude),
|
|
620
624
|
cartographic.height
|
|
621
625
|
];
|
|
622
626
|
}
|
|
623
627
|
|
|
624
628
|
screenToWorld(x, y) {
|
|
625
|
-
const screenPosition = new Cesium$
|
|
629
|
+
const screenPosition = new Cesium$h.Cartesian2(x, y);
|
|
626
630
|
if (this.viewer.scene.pickPositionSupported) {
|
|
627
631
|
const precisePosition = this.viewer.scene.pickPosition(screenPosition);
|
|
628
632
|
if (precisePosition) return precisePosition;
|
|
@@ -630,7 +634,7 @@ class SceneModule {
|
|
|
630
634
|
const ray = this.viewer.camera.getPickRay(screenPosition);
|
|
631
635
|
const globePosition = this.viewer.scene.globe.pick(ray, this.viewer.scene);
|
|
632
636
|
if (globePosition) return globePosition;
|
|
633
|
-
return this.viewer.camera.pickEllipsoid(screenPosition, Cesium$
|
|
637
|
+
return this.viewer.camera.pickEllipsoid(screenPosition, Cesium$h.Ellipsoid.WGS84);
|
|
634
638
|
}
|
|
635
639
|
|
|
636
640
|
worldToScreen(cartesian) {
|
|
@@ -648,13 +652,13 @@ class SceneModule {
|
|
|
648
652
|
}
|
|
649
653
|
|
|
650
654
|
lonLatToCartographic(lon, lat, height = 0) {
|
|
651
|
-
return new Cesium$
|
|
655
|
+
return new Cesium$h.Cartographic(Cesium$h.Math.toRadians(lon), Cesium$h.Math.toRadians(lat), height);
|
|
652
656
|
}
|
|
653
657
|
|
|
654
658
|
cartographicToLonLat(cartographic) {
|
|
655
659
|
return [
|
|
656
|
-
Cesium$
|
|
657
|
-
Cesium$
|
|
660
|
+
Cesium$h.Math.toDegrees(cartographic.longitude),
|
|
661
|
+
Cesium$h.Math.toDegrees(cartographic.latitude),
|
|
658
662
|
cartographic.height
|
|
659
663
|
];
|
|
660
664
|
}
|
|
@@ -750,7 +754,7 @@ class SceneModule {
|
|
|
750
754
|
this.viewer.imageryLayers.remove(layer.getLayer());
|
|
751
755
|
} else if (layer instanceof TerrainLayerWrapper) {
|
|
752
756
|
// 地形无法直接删除,重置为默认椭球地形
|
|
753
|
-
this.viewer.terrainProvider = new Cesium$
|
|
757
|
+
this.viewer.terrainProvider = new Cesium$h.EllipsoidTerrainProvider();
|
|
754
758
|
} else if (layer instanceof TilesetLayerWrapper) {
|
|
755
759
|
this.viewer.scene.primitives.remove(layer.getTileset());
|
|
756
760
|
}
|
|
@@ -792,17 +796,17 @@ class SceneModule {
|
|
|
792
796
|
duration = 3.0
|
|
793
797
|
} = params;
|
|
794
798
|
|
|
795
|
-
if (!Cesium$
|
|
799
|
+
if (!Cesium$h.defined(lon) || !Cesium$h.defined(lat)) {
|
|
796
800
|
console.warn('flyToLonLat: 必须提供 lon、lat');
|
|
797
801
|
return Promise.resolve(false);
|
|
798
802
|
}
|
|
799
803
|
|
|
800
804
|
return this.viewer.camera.flyTo({
|
|
801
|
-
destination: Cesium$
|
|
805
|
+
destination: Cesium$h.Cartesian3.fromDegrees(lon, lat, height),
|
|
802
806
|
orientation: {
|
|
803
|
-
heading: Cesium$
|
|
804
|
-
pitch: Cesium$
|
|
805
|
-
roll: Cesium$
|
|
807
|
+
heading: Cesium$h.Math.toRadians(heading),
|
|
808
|
+
pitch: Cesium$h.Math.toRadians(pitch),
|
|
809
|
+
roll: Cesium$h.Math.toRadians(roll)
|
|
806
810
|
},
|
|
807
811
|
duration
|
|
808
812
|
});
|
|
@@ -827,23 +831,23 @@ class SceneModule {
|
|
|
827
831
|
roll = 0
|
|
828
832
|
} = params;
|
|
829
833
|
|
|
830
|
-
if (!Cesium$
|
|
834
|
+
if (!Cesium$h.defined(lon) || !Cesium$h.defined(lat)) {
|
|
831
835
|
console.warn('setView: 必须提供 lon、lat');
|
|
832
836
|
return;
|
|
833
837
|
}
|
|
834
838
|
|
|
835
839
|
this.viewer.camera.setView({
|
|
836
|
-
destination: Cesium$
|
|
840
|
+
destination: Cesium$h.Cartesian3.fromDegrees(lon, lat, height),
|
|
837
841
|
orientation: {
|
|
838
|
-
heading: Cesium$
|
|
839
|
-
pitch: Cesium$
|
|
840
|
-
roll: Cesium$
|
|
842
|
+
heading: Cesium$h.Math.toRadians(heading),
|
|
843
|
+
pitch: Cesium$h.Math.toRadians(pitch),
|
|
844
|
+
roll: Cesium$h.Math.toRadians(roll)
|
|
841
845
|
}
|
|
842
846
|
});
|
|
843
847
|
}
|
|
844
848
|
}
|
|
845
849
|
|
|
846
|
-
const Cesium$
|
|
850
|
+
const Cesium$g = getCesium();
|
|
847
851
|
|
|
848
852
|
/**
|
|
849
853
|
* 标绘几何算法工具
|
|
@@ -1132,7 +1136,7 @@ class PlotGeometryUtil {
|
|
|
1132
1136
|
for (const p of points) {
|
|
1133
1137
|
flat.push(p[0], p[1], p[2] || 0);
|
|
1134
1138
|
}
|
|
1135
|
-
return Cesium$
|
|
1139
|
+
return Cesium$g.Cartesian3.fromDegreesArrayHeights(flat);
|
|
1136
1140
|
}
|
|
1137
1141
|
|
|
1138
1142
|
// ==================== 曲线/插值工具(复合箭头、曲线标绘需要)====================
|
|
@@ -2028,7 +2032,7 @@ function isLinePlotType(plotType) {
|
|
|
2028
2032
|
].includes(plotType);
|
|
2029
2033
|
}
|
|
2030
2034
|
|
|
2031
|
-
const Cesium$
|
|
2035
|
+
const Cesium$f = getCesium();
|
|
2032
2036
|
|
|
2033
2037
|
/**
|
|
2034
2038
|
* 点图元包装器
|
|
@@ -2040,7 +2044,7 @@ class PointWrapper {
|
|
|
2040
2044
|
}
|
|
2041
2045
|
|
|
2042
2046
|
setPosition(coords) {
|
|
2043
|
-
this._entity.position = Cesium$
|
|
2047
|
+
this._entity.position = Cesium$f.Cartesian3.fromDegrees(...coords);
|
|
2044
2048
|
return this;
|
|
2045
2049
|
}
|
|
2046
2050
|
|
|
@@ -2088,7 +2092,7 @@ class PointWrapper {
|
|
|
2088
2092
|
// 名称标签相关
|
|
2089
2093
|
setNameVisible(visible) {
|
|
2090
2094
|
if (!this._entity.label) {
|
|
2091
|
-
this._entity.label = new Cesium$
|
|
2095
|
+
this._entity.label = new Cesium$f.LabelGraphics();
|
|
2092
2096
|
}
|
|
2093
2097
|
this._entity.label.show = visible;
|
|
2094
2098
|
return this;
|
|
@@ -2096,22 +2100,22 @@ class PointWrapper {
|
|
|
2096
2100
|
|
|
2097
2101
|
setText(text, options = {}) {
|
|
2098
2102
|
if (!this._entity.label) {
|
|
2099
|
-
this._entity.label = new Cesium$
|
|
2103
|
+
this._entity.label = new Cesium$f.LabelGraphics();
|
|
2100
2104
|
}
|
|
2101
2105
|
this._entity.label.text = text;
|
|
2102
2106
|
|
|
2103
2107
|
// 应用配置选项
|
|
2104
2108
|
this._entity.label.disableDepthTestDistance = options.disableDepthTestDistance ?? Number.POSITIVE_INFINITY;
|
|
2105
|
-
this._entity.label.verticalOrigin = options.verticalOrigin ?? Cesium$
|
|
2106
|
-
this._entity.label.eyeOffset = options.eyeOffset ?? new Cesium$
|
|
2107
|
-
this._entity.label.heightReference = options.heightReference ?? Cesium$
|
|
2109
|
+
this._entity.label.verticalOrigin = options.verticalOrigin ?? Cesium$f.VerticalOrigin.BOTTOM;
|
|
2110
|
+
this._entity.label.eyeOffset = options.eyeOffset ?? new Cesium$f.Cartesian3(0, 0, -10);
|
|
2111
|
+
this._entity.label.heightReference = options.heightReference ?? Cesium$f.HeightReference.RELATIVE_TO_GROUND;
|
|
2108
2112
|
|
|
2109
2113
|
return this;
|
|
2110
2114
|
}
|
|
2111
2115
|
|
|
2112
2116
|
setFont(font) {
|
|
2113
2117
|
if (!this._entity.label) {
|
|
2114
|
-
this._entity.label = new Cesium$
|
|
2118
|
+
this._entity.label = new Cesium$f.LabelGraphics();
|
|
2115
2119
|
}
|
|
2116
2120
|
this._entity.label.font = font;
|
|
2117
2121
|
return this;
|
|
@@ -2119,7 +2123,7 @@ class PointWrapper {
|
|
|
2119
2123
|
|
|
2120
2124
|
setTextColor(color) {
|
|
2121
2125
|
if (!this._entity.label) {
|
|
2122
|
-
this._entity.label = new Cesium$
|
|
2126
|
+
this._entity.label = new Cesium$f.LabelGraphics();
|
|
2123
2127
|
}
|
|
2124
2128
|
this._entity.label.fillColor = color;
|
|
2125
2129
|
return this;
|
|
@@ -2127,7 +2131,7 @@ class PointWrapper {
|
|
|
2127
2131
|
|
|
2128
2132
|
setTextOutlineColor(color) {
|
|
2129
2133
|
if (!this._entity.label) {
|
|
2130
|
-
this._entity.label = new Cesium$
|
|
2134
|
+
this._entity.label = new Cesium$f.LabelGraphics();
|
|
2131
2135
|
}
|
|
2132
2136
|
this._entity.label.outlineColor = color;
|
|
2133
2137
|
return this;
|
|
@@ -2135,7 +2139,7 @@ class PointWrapper {
|
|
|
2135
2139
|
|
|
2136
2140
|
setTextOutlineWidth(width) {
|
|
2137
2141
|
if (!this._entity.label) {
|
|
2138
|
-
this._entity.label = new Cesium$
|
|
2142
|
+
this._entity.label = new Cesium$f.LabelGraphics();
|
|
2139
2143
|
}
|
|
2140
2144
|
this._entity.label.outlineWidth = width;
|
|
2141
2145
|
return this;
|
|
@@ -2143,19 +2147,19 @@ class PointWrapper {
|
|
|
2143
2147
|
|
|
2144
2148
|
setAlignType(alignType) {
|
|
2145
2149
|
if (!this._entity.label) {
|
|
2146
|
-
this._entity.label = new Cesium$
|
|
2150
|
+
this._entity.label = new Cesium$f.LabelGraphics();
|
|
2147
2151
|
}
|
|
2148
2152
|
// alignType: 0=CENTER, 1=LEFT, 2=RIGHT, 3=TOP, 4=BOTTOM
|
|
2149
|
-
const horizontalOrigins = [Cesium$
|
|
2150
|
-
const verticalOrigins = [Cesium$
|
|
2151
|
-
this._entity.label.horizontalOrigin = horizontalOrigins[alignType] || Cesium$
|
|
2152
|
-
this._entity.label.verticalOrigin = verticalOrigins[alignType] || Cesium$
|
|
2153
|
+
const horizontalOrigins = [Cesium$f.HorizontalOrigin.CENTER, Cesium$f.HorizontalOrigin.LEFT, Cesium$f.HorizontalOrigin.RIGHT];
|
|
2154
|
+
const verticalOrigins = [Cesium$f.VerticalOrigin.CENTER, Cesium$f.VerticalOrigin.CENTER, Cesium$f.VerticalOrigin.CENTER, Cesium$f.VerticalOrigin.TOP, Cesium$f.VerticalOrigin.BOTTOM];
|
|
2155
|
+
this._entity.label.horizontalOrigin = horizontalOrigins[alignType] || Cesium$f.HorizontalOrigin.CENTER;
|
|
2156
|
+
this._entity.label.verticalOrigin = verticalOrigins[alignType] || Cesium$f.VerticalOrigin.CENTER;
|
|
2153
2157
|
return this;
|
|
2154
2158
|
}
|
|
2155
2159
|
|
|
2156
2160
|
setTextPixelOffset(offset) {
|
|
2157
2161
|
if (!this._entity.label) {
|
|
2158
|
-
this._entity.label = new Cesium$
|
|
2162
|
+
this._entity.label = new Cesium$f.LabelGraphics();
|
|
2159
2163
|
}
|
|
2160
2164
|
this._entity.label.pixelOffset = offset;
|
|
2161
2165
|
return this;
|
|
@@ -2163,7 +2167,7 @@ class PointWrapper {
|
|
|
2163
2167
|
|
|
2164
2168
|
setTextScale(scale) {
|
|
2165
2169
|
if (!this._entity.label) {
|
|
2166
|
-
this._entity.label = new Cesium$
|
|
2170
|
+
this._entity.label = new Cesium$f.LabelGraphics();
|
|
2167
2171
|
}
|
|
2168
2172
|
this._entity.label.scale = scale;
|
|
2169
2173
|
return this;
|
|
@@ -2185,7 +2189,7 @@ class LineWrapper {
|
|
|
2185
2189
|
}
|
|
2186
2190
|
|
|
2187
2191
|
setPositions(coords) {
|
|
2188
|
-
this._entity.polyline.positions = Cesium$
|
|
2192
|
+
this._entity.polyline.positions = Cesium$f.Cartesian3.fromDegreesArrayHeights(
|
|
2189
2193
|
coords.flatMap(coord => [coord[0], coord[1], coord[2] || 0])
|
|
2190
2194
|
);
|
|
2191
2195
|
return this;
|
|
@@ -2229,23 +2233,23 @@ class LineWrapper {
|
|
|
2229
2233
|
*/
|
|
2230
2234
|
setLabel(text, options = {}) {
|
|
2231
2235
|
if (!this._entity.label) {
|
|
2232
|
-
this._entity.label = new Cesium$
|
|
2236
|
+
this._entity.label = new Cesium$f.LabelGraphics();
|
|
2233
2237
|
}
|
|
2234
2238
|
this._entity.label.text = text;
|
|
2235
2239
|
this._entity.label.font = options.font || '14px Microsoft YaHei';
|
|
2236
|
-
this._entity.label.fillColor = options.color || Cesium$
|
|
2237
|
-
this._entity.label.outlineColor = options.outlineColor || Cesium$
|
|
2240
|
+
this._entity.label.fillColor = options.color || Cesium$f.Color.WHITE;
|
|
2241
|
+
this._entity.label.outlineColor = options.outlineColor || Cesium$f.Color.BLACK;
|
|
2238
2242
|
this._entity.label.outlineWidth = options.outlineWidth ?? 1;
|
|
2239
2243
|
this._entity.label.show = true;
|
|
2240
|
-
this._entity.label.pixelOffset = options.pixelOffset || new Cesium$
|
|
2241
|
-
this._entity.label.horizontalOrigin = options.horizontalOrigin ?? Cesium$
|
|
2242
|
-
this._entity.label.verticalOrigin = options.verticalOrigin ?? Cesium$
|
|
2244
|
+
this._entity.label.pixelOffset = options.pixelOffset || new Cesium$f.Cartesian2(0, -10);
|
|
2245
|
+
this._entity.label.horizontalOrigin = options.horizontalOrigin ?? Cesium$f.HorizontalOrigin.CENTER;
|
|
2246
|
+
this._entity.label.verticalOrigin = options.verticalOrigin ?? Cesium$f.VerticalOrigin.BOTTOM;
|
|
2243
2247
|
|
|
2244
2248
|
// 使用 CallbackProperty 动态计算标签锚点,随编辑/平移自动更新
|
|
2245
2249
|
const self = this;
|
|
2246
|
-
this._entity.position = new Cesium$
|
|
2250
|
+
this._entity.position = new Cesium$f.CallbackProperty(function () {
|
|
2247
2251
|
const anchor = self._computeLabelAnchor();
|
|
2248
|
-
return Cesium$
|
|
2252
|
+
return Cesium$f.Cartesian3.fromDegrees(anchor[0], anchor[1], anchor[2] || 0);
|
|
2249
2253
|
}, false);
|
|
2250
2254
|
|
|
2251
2255
|
return this;
|
|
@@ -2268,13 +2272,13 @@ class LineWrapper {
|
|
|
2268
2272
|
return [x / cps.length, y / cps.length, z / cps.length];
|
|
2269
2273
|
}
|
|
2270
2274
|
|
|
2271
|
-
const positions = this._entity.polyline?.positions?.getValue(Cesium$
|
|
2275
|
+
const positions = this._entity.polyline?.positions?.getValue(Cesium$f.JulianDate.now());
|
|
2272
2276
|
if (positions && positions.length > 0) {
|
|
2273
2277
|
let lon = 0, lat = 0, height = 0;
|
|
2274
2278
|
positions.forEach(p => {
|
|
2275
|
-
const c = Cesium$
|
|
2276
|
-
lon += Cesium$
|
|
2277
|
-
lat += Cesium$
|
|
2279
|
+
const c = Cesium$f.Cartographic.fromCartesian(p);
|
|
2280
|
+
lon += Cesium$f.Math.toDegrees(c.longitude);
|
|
2281
|
+
lat += Cesium$f.Math.toDegrees(c.latitude);
|
|
2278
2282
|
height += c.height || 0;
|
|
2279
2283
|
});
|
|
2280
2284
|
const count = positions.length;
|
|
@@ -2347,8 +2351,8 @@ class PolygonWrapper {
|
|
|
2347
2351
|
}
|
|
2348
2352
|
|
|
2349
2353
|
setPositions(coords) {
|
|
2350
|
-
this._entity.polygon.hierarchy = new Cesium$
|
|
2351
|
-
Cesium$
|
|
2354
|
+
this._entity.polygon.hierarchy = new Cesium$f.PolygonHierarchy(
|
|
2355
|
+
Cesium$f.Cartesian3.fromDegreesArrayHeights(
|
|
2352
2356
|
coords.flatMap(coord => [coord[0], coord[1], coord[2] || 0])
|
|
2353
2357
|
)
|
|
2354
2358
|
);
|
|
@@ -2398,23 +2402,23 @@ class PolygonWrapper {
|
|
|
2398
2402
|
*/
|
|
2399
2403
|
setLabel(text, options = {}) {
|
|
2400
2404
|
if (!this._entity.label) {
|
|
2401
|
-
this._entity.label = new Cesium$
|
|
2405
|
+
this._entity.label = new Cesium$f.LabelGraphics();
|
|
2402
2406
|
}
|
|
2403
2407
|
this._entity.label.text = text;
|
|
2404
2408
|
this._entity.label.font = options.font || '14px Microsoft YaHei';
|
|
2405
|
-
this._entity.label.fillColor = options.color || Cesium$
|
|
2406
|
-
this._entity.label.outlineColor = options.outlineColor || Cesium$
|
|
2409
|
+
this._entity.label.fillColor = options.color || Cesium$f.Color.WHITE;
|
|
2410
|
+
this._entity.label.outlineColor = options.outlineColor || Cesium$f.Color.BLACK;
|
|
2407
2411
|
this._entity.label.outlineWidth = options.outlineWidth ?? 1;
|
|
2408
2412
|
this._entity.label.show = true;
|
|
2409
|
-
this._entity.label.pixelOffset = options.pixelOffset || new Cesium$
|
|
2410
|
-
this._entity.label.horizontalOrigin = options.horizontalOrigin ?? Cesium$
|
|
2411
|
-
this._entity.label.verticalOrigin = options.verticalOrigin ?? Cesium$
|
|
2413
|
+
this._entity.label.pixelOffset = options.pixelOffset || new Cesium$f.Cartesian2(0, -10);
|
|
2414
|
+
this._entity.label.horizontalOrigin = options.horizontalOrigin ?? Cesium$f.HorizontalOrigin.CENTER;
|
|
2415
|
+
this._entity.label.verticalOrigin = options.verticalOrigin ?? Cesium$f.VerticalOrigin.BOTTOM;
|
|
2412
2416
|
|
|
2413
2417
|
// 使用 CallbackProperty 动态计算标签锚点,随编辑/平移自动更新
|
|
2414
2418
|
const self = this;
|
|
2415
|
-
this._entity.position = new Cesium$
|
|
2419
|
+
this._entity.position = new Cesium$f.CallbackProperty(function () {
|
|
2416
2420
|
const anchor = self._computeLabelAnchor();
|
|
2417
|
-
return Cesium$
|
|
2421
|
+
return Cesium$f.Cartesian3.fromDegrees(anchor[0], anchor[1], anchor[2] || 0);
|
|
2418
2422
|
}, false);
|
|
2419
2423
|
|
|
2420
2424
|
return this;
|
|
@@ -2441,13 +2445,13 @@ class PolygonWrapper {
|
|
|
2441
2445
|
return [x / cps.length, y / cps.length, z / cps.length];
|
|
2442
2446
|
}
|
|
2443
2447
|
|
|
2444
|
-
const hierarchy = this._entity.polygon?.hierarchy?.getValue(Cesium$
|
|
2448
|
+
const hierarchy = this._entity.polygon?.hierarchy?.getValue(Cesium$f.JulianDate.now());
|
|
2445
2449
|
if (hierarchy && hierarchy.positions && hierarchy.positions.length > 0) {
|
|
2446
2450
|
let lon = 0, lat = 0, height = 0;
|
|
2447
2451
|
hierarchy.positions.forEach(p => {
|
|
2448
|
-
const c = Cesium$
|
|
2449
|
-
lon += Cesium$
|
|
2450
|
-
lat += Cesium$
|
|
2452
|
+
const c = Cesium$f.Cartographic.fromCartesian(p);
|
|
2453
|
+
lon += Cesium$f.Math.toDegrees(c.longitude);
|
|
2454
|
+
lat += Cesium$f.Math.toDegrees(c.latitude);
|
|
2451
2455
|
height += c.height || 0;
|
|
2452
2456
|
});
|
|
2453
2457
|
const count = hierarchy.positions.length;
|
|
@@ -2520,7 +2524,7 @@ class ModelWrapper {
|
|
|
2520
2524
|
}
|
|
2521
2525
|
|
|
2522
2526
|
setPosition(coords) {
|
|
2523
|
-
this._entity.position = Cesium$
|
|
2527
|
+
this._entity.position = Cesium$f.Cartesian3.fromDegrees(...coords);
|
|
2524
2528
|
return this;
|
|
2525
2529
|
}
|
|
2526
2530
|
|
|
@@ -2570,7 +2574,7 @@ class TextWrapper {
|
|
|
2570
2574
|
}
|
|
2571
2575
|
|
|
2572
2576
|
setPosition(coords) {
|
|
2573
|
-
this._entity.position = Cesium$
|
|
2577
|
+
this._entity.position = Cesium$f.Cartesian3.fromDegrees(...coords);
|
|
2574
2578
|
return this;
|
|
2575
2579
|
}
|
|
2576
2580
|
|
|
@@ -2616,10 +2620,10 @@ class TextWrapper {
|
|
|
2616
2620
|
}
|
|
2617
2621
|
|
|
2618
2622
|
setAlignType(alignType) {
|
|
2619
|
-
const horizontalOrigins = [Cesium$
|
|
2620
|
-
const verticalOrigins = [Cesium$
|
|
2621
|
-
this._entity.label.horizontalOrigin = horizontalOrigins[alignType] || Cesium$
|
|
2622
|
-
this._entity.label.verticalOrigin = verticalOrigins[alignType] || Cesium$
|
|
2623
|
+
const horizontalOrigins = [Cesium$f.HorizontalOrigin.CENTER, Cesium$f.HorizontalOrigin.LEFT, Cesium$f.HorizontalOrigin.RIGHT];
|
|
2624
|
+
const verticalOrigins = [Cesium$f.VerticalOrigin.CENTER, Cesium$f.VerticalOrigin.CENTER, Cesium$f.VerticalOrigin.CENTER, Cesium$f.VerticalOrigin.TOP, Cesium$f.VerticalOrigin.BOTTOM];
|
|
2625
|
+
this._entity.label.horizontalOrigin = horizontalOrigins[alignType] || Cesium$f.HorizontalOrigin.CENTER;
|
|
2626
|
+
this._entity.label.verticalOrigin = verticalOrigins[alignType] || Cesium$f.VerticalOrigin.CENTER;
|
|
2623
2627
|
return this;
|
|
2624
2628
|
}
|
|
2625
2629
|
|
|
@@ -2657,14 +2661,14 @@ class GraphicModule {
|
|
|
2657
2661
|
return this.wrapperMap.get(graphicId);
|
|
2658
2662
|
}
|
|
2659
2663
|
|
|
2660
|
-
const defaultStyle = this.config.graphic?.point || { pixelSize: 8, color: Cesium$
|
|
2664
|
+
const defaultStyle = this.config.graphic?.point || { pixelSize: 8, color: Cesium$f.Color.RED };
|
|
2661
2665
|
|
|
2662
2666
|
const entityOptions = {
|
|
2663
2667
|
id: graphicId,
|
|
2664
|
-
position: Cesium$
|
|
2668
|
+
position: Cesium$f.Cartesian3.fromDegrees(0, 0, 0),
|
|
2665
2669
|
point: {
|
|
2666
2670
|
...defaultStyle,
|
|
2667
|
-
outlineColor: Cesium$
|
|
2671
|
+
outlineColor: Cesium$f.Color.WHITE,
|
|
2668
2672
|
outlineWidth: 1
|
|
2669
2673
|
}
|
|
2670
2674
|
};
|
|
@@ -2698,12 +2702,12 @@ class GraphicModule {
|
|
|
2698
2702
|
return this.wrapperMap.get(graphicId);
|
|
2699
2703
|
}
|
|
2700
2704
|
|
|
2701
|
-
const defaultStyle = this.config.graphic?.line || { width: 2, material: Cesium$
|
|
2705
|
+
const defaultStyle = this.config.graphic?.line || { width: 2, material: Cesium$f.Color.BLUE };
|
|
2702
2706
|
|
|
2703
2707
|
const entityOptions = {
|
|
2704
2708
|
id: graphicId,
|
|
2705
2709
|
polyline: {
|
|
2706
|
-
positions: Cesium$
|
|
2710
|
+
positions: Cesium$f.Cartesian3.fromDegreesArrayHeights([0, 0, 0, 0, 0, 0]),
|
|
2707
2711
|
clampToGround: true,
|
|
2708
2712
|
...defaultStyle
|
|
2709
2713
|
}
|
|
@@ -2738,14 +2742,14 @@ class GraphicModule {
|
|
|
2738
2742
|
return this.wrapperMap.get(graphicId);
|
|
2739
2743
|
}
|
|
2740
2744
|
|
|
2741
|
-
const defaultStyle = this.config.graphic?.polygon || { color: Cesium$
|
|
2745
|
+
const defaultStyle = this.config.graphic?.polygon || { color: Cesium$f.Color.GREEN.withAlpha(0.5) };
|
|
2742
2746
|
|
|
2743
2747
|
const entityOptions = {
|
|
2744
2748
|
id: graphicId,
|
|
2745
2749
|
polygon: {
|
|
2746
|
-
hierarchy: new Cesium$
|
|
2750
|
+
hierarchy: new Cesium$f.PolygonHierarchy([]),
|
|
2747
2751
|
clampToGround: true,
|
|
2748
|
-
outlineColor: Cesium$
|
|
2752
|
+
outlineColor: Cesium$f.Color.WHITE,
|
|
2749
2753
|
outlineWidth: 1,
|
|
2750
2754
|
...defaultStyle
|
|
2751
2755
|
}
|
|
@@ -2782,7 +2786,7 @@ class GraphicModule {
|
|
|
2782
2786
|
|
|
2783
2787
|
const entityOptions = {
|
|
2784
2788
|
id: graphicId,
|
|
2785
|
-
position: Cesium$
|
|
2789
|
+
position: Cesium$f.Cartesian3.fromDegrees(0, 0, 0),
|
|
2786
2790
|
model: {
|
|
2787
2791
|
uri: "",
|
|
2788
2792
|
scale: 1.0,
|
|
@@ -2821,16 +2825,16 @@ class GraphicModule {
|
|
|
2821
2825
|
|
|
2822
2826
|
const entityOptions = {
|
|
2823
2827
|
id: graphicId,
|
|
2824
|
-
position: Cesium$
|
|
2828
|
+
position: Cesium$f.Cartesian3.fromDegrees(0, 0, 0),
|
|
2825
2829
|
label: {
|
|
2826
2830
|
text: "",
|
|
2827
2831
|
font: "16px Microsoft YaHei",
|
|
2828
|
-
fillColor: Cesium$
|
|
2829
|
-
outlineColor: Cesium$
|
|
2832
|
+
fillColor: Cesium$f.Color.WHITE,
|
|
2833
|
+
outlineColor: Cesium$f.Color.BLACK,
|
|
2830
2834
|
outlineWidth: 2,
|
|
2831
|
-
style: Cesium$
|
|
2832
|
-
verticalOrigin: Cesium$
|
|
2833
|
-
horizontalOrigin: Cesium$
|
|
2835
|
+
style: Cesium$f.LabelStyle.FILL_AND_OUTLINE,
|
|
2836
|
+
verticalOrigin: Cesium$f.VerticalOrigin.BOTTOM,
|
|
2837
|
+
horizontalOrigin: Cesium$f.HorizontalOrigin.CENTER
|
|
2834
2838
|
}
|
|
2835
2839
|
};
|
|
2836
2840
|
|
|
@@ -3076,7 +3080,7 @@ class GraphicModule {
|
|
|
3076
3080
|
_getEntityPositions(entity) {
|
|
3077
3081
|
const getValue = (prop) => {
|
|
3078
3082
|
if (prop == null) return undefined;
|
|
3079
|
-
return typeof prop.getValue === 'function' ? prop.getValue(Cesium$
|
|
3083
|
+
return typeof prop.getValue === 'function' ? prop.getValue(Cesium$f.JulianDate.now()) : prop;
|
|
3080
3084
|
};
|
|
3081
3085
|
|
|
3082
3086
|
// 优先按 geometry 类型取顶点,避免 polygon/polyline 也带 position 时只拿到中心点
|
|
@@ -3117,7 +3121,7 @@ class GraphicModule {
|
|
|
3117
3121
|
const positions = this.getPositions(graphicIdOrEntity);
|
|
3118
3122
|
if (!positions.length) return null;
|
|
3119
3123
|
|
|
3120
|
-
const sphere = Cesium$
|
|
3124
|
+
const sphere = Cesium$f.BoundingSphere.fromPoints(positions);
|
|
3121
3125
|
// 点图元只有单个坐标,radius 为 0,给一个最小可视半径避免相机钻进点里
|
|
3122
3126
|
if (positions.length === 1 && sphere.radius === 0) {
|
|
3123
3127
|
sphere.radius = 5000;
|
|
@@ -3140,14 +3144,14 @@ class GraphicModule {
|
|
|
3140
3144
|
const sphere = this.getBoundingSphere(entity);
|
|
3141
3145
|
if (!sphere) return Promise.resolve(false);
|
|
3142
3146
|
|
|
3143
|
-
const pitch = options.pitch ?? -Cesium$
|
|
3147
|
+
const pitch = options.pitch ?? -Cesium$f.Math.PI_OVER_TWO;
|
|
3144
3148
|
const padding = options.padding ?? 2;
|
|
3145
3149
|
const fovy = this.viewer.camera.frustum.fovy;
|
|
3146
3150
|
const range = (sphere.radius / Math.tan(fovy / 2)) * padding;
|
|
3147
3151
|
|
|
3148
3152
|
return this.viewer.camera.flyToBoundingSphere(sphere, {
|
|
3149
3153
|
duration: options.duration ?? 1.5,
|
|
3150
|
-
offset: new Cesium$
|
|
3154
|
+
offset: new Cesium$f.HeadingPitchRange(0, pitch, range),
|
|
3151
3155
|
}).then(() => true).catch((err) => {
|
|
3152
3156
|
console.error('图元定位失败', err);
|
|
3153
3157
|
return false;
|
|
@@ -3168,12 +3172,12 @@ class GraphicModule {
|
|
|
3168
3172
|
const sphere = this.getBoundingSphere(entity);
|
|
3169
3173
|
if (!sphere) return;
|
|
3170
3174
|
|
|
3171
|
-
const pitch = options.pitch ?? -Cesium$
|
|
3175
|
+
const pitch = options.pitch ?? -Cesium$f.Math.PI_OVER_TWO;
|
|
3172
3176
|
const padding = options.padding ?? 2;
|
|
3173
3177
|
const fovy = this.viewer.camera.frustum.fovy;
|
|
3174
3178
|
const range = (sphere.radius / Math.tan(fovy / 2)) * padding;
|
|
3175
3179
|
|
|
3176
|
-
this.viewer.camera.viewBoundingSphere(sphere, new Cesium$
|
|
3180
|
+
this.viewer.camera.viewBoundingSphere(sphere, new Cesium$f.HeadingPitchRange(0, pitch, range));
|
|
3177
3181
|
}
|
|
3178
3182
|
|
|
3179
3183
|
/**
|
|
@@ -3196,7 +3200,7 @@ class GraphicModule {
|
|
|
3196
3200
|
|
|
3197
3201
|
const closedPositions = [...positions, positions[0]];
|
|
3198
3202
|
const outlineId = `${graphicId}_outline`;
|
|
3199
|
-
const color = options.color ?? Cesium$
|
|
3203
|
+
const color = options.color ?? Cesium$f.Color.WHITE;
|
|
3200
3204
|
const width = options.width ?? 2;
|
|
3201
3205
|
|
|
3202
3206
|
this.viewer.entities.add({
|
|
@@ -3221,7 +3225,7 @@ class GraphicModule {
|
|
|
3221
3225
|
}
|
|
3222
3226
|
}
|
|
3223
3227
|
|
|
3224
|
-
const Cesium$
|
|
3228
|
+
const Cesium$e = getCesium();
|
|
3225
3229
|
|
|
3226
3230
|
/**
|
|
3227
3231
|
* 事件模块(对应平台 IEventModule)
|
|
@@ -3319,7 +3323,7 @@ class EventModule {
|
|
|
3319
3323
|
switch (baseType) {
|
|
3320
3324
|
// 鼠标事件
|
|
3321
3325
|
case 'mouse':
|
|
3322
|
-
this.handlers[eventKey] = new Cesium$
|
|
3326
|
+
this.handlers[eventKey] = new Cesium$e.ScreenSpaceEventHandler(this.viewer.scene.canvas);
|
|
3323
3327
|
// 绑定鼠标事件
|
|
3324
3328
|
const mouseEventType = this.getCesiumMouseEventType(subType);
|
|
3325
3329
|
this.handlers[eventKey].setInputAction((movement) => {
|
|
@@ -3340,10 +3344,10 @@ class EventModule {
|
|
|
3340
3344
|
const pickedEntity = this.viewer.scene.pick(screenPos);
|
|
3341
3345
|
|
|
3342
3346
|
if (position) {
|
|
3343
|
-
const cartographic = Cesium$
|
|
3347
|
+
const cartographic = Cesium$e.Cartographic.fromCartesian(position);
|
|
3344
3348
|
lngLat = [
|
|
3345
|
-
Cesium$
|
|
3346
|
-
Cesium$
|
|
3349
|
+
Cesium$e.Math.toDegrees(cartographic.longitude),
|
|
3350
|
+
Cesium$e.Math.toDegrees(cartographic.latitude),
|
|
3347
3351
|
cartographic.height
|
|
3348
3352
|
];
|
|
3349
3353
|
}
|
|
@@ -3409,12 +3413,12 @@ class EventModule {
|
|
|
3409
3413
|
// ========== 工具方法:映射 Cesium 鼠标事件类型 ==========
|
|
3410
3414
|
getCesiumMouseEventType(subType) {
|
|
3411
3415
|
switch (subType) {
|
|
3412
|
-
case 'click': return Cesium$
|
|
3413
|
-
case 'rightclick': return Cesium$
|
|
3414
|
-
case 'move': return Cesium$
|
|
3415
|
-
case 'down': return Cesium$
|
|
3416
|
-
case 'up': return Cesium$
|
|
3417
|
-
default: return Cesium$
|
|
3416
|
+
case 'click': return Cesium$e.ScreenSpaceEventType.LEFT_CLICK;
|
|
3417
|
+
case 'rightclick': return Cesium$e.ScreenSpaceEventType.RIGHT_CLICK;
|
|
3418
|
+
case 'move': return Cesium$e.ScreenSpaceEventType.MOUSE_MOVE;
|
|
3419
|
+
case 'down': return Cesium$e.ScreenSpaceEventType.LEFT_DOWN;
|
|
3420
|
+
case 'up': return Cesium$e.ScreenSpaceEventType.LEFT_UP;
|
|
3421
|
+
default: return Cesium$e.ScreenSpaceEventType.LEFT_CLICK;
|
|
3418
3422
|
}
|
|
3419
3423
|
}
|
|
3420
3424
|
|
|
@@ -3422,18 +3426,18 @@ class EventModule {
|
|
|
3422
3426
|
getZoomLevel() {
|
|
3423
3427
|
const camera = this.viewer.camera;
|
|
3424
3428
|
const positionCartographic = camera.positionCartographic;
|
|
3425
|
-
const positionCartesian = Cesium$
|
|
3429
|
+
const positionCartesian = Cesium$e.Cartesian3.fromRadians(
|
|
3426
3430
|
positionCartographic.longitude,
|
|
3427
3431
|
positionCartographic.latitude,
|
|
3428
3432
|
positionCartographic.height
|
|
3429
3433
|
);
|
|
3430
|
-
const distance = Cesium$
|
|
3434
|
+
const distance = Cesium$e.Cartesian3.distance(camera.position, positionCartesian);
|
|
3431
3435
|
// 映射为 0-20 级缩放(类似地图瓦片级别)
|
|
3432
3436
|
return Math.floor(Math.log2(6378137 * 2 * Math.PI / distance)) + 1;
|
|
3433
3437
|
}
|
|
3434
3438
|
}
|
|
3435
3439
|
|
|
3436
|
-
const Cesium$
|
|
3440
|
+
const Cesium$d = getCesium();
|
|
3437
3441
|
|
|
3438
3442
|
/**
|
|
3439
3443
|
* 工具基类
|
|
@@ -3528,17 +3532,17 @@ class BaseTool {
|
|
|
3528
3532
|
// 如果拾取失败(空白区域),fallback 到椭球体表面
|
|
3529
3533
|
if (!cartesian) {
|
|
3530
3534
|
cartesian = this._viewer.camera.pickEllipsoid(
|
|
3531
|
-
new Cesium$
|
|
3535
|
+
new Cesium$d.Cartesian3(screenPos.x, screenPos.y),
|
|
3532
3536
|
this._viewer.scene.globe.ellipsoid
|
|
3533
3537
|
);
|
|
3534
3538
|
}
|
|
3535
3539
|
|
|
3536
3540
|
if (!cartesian) return null;
|
|
3537
3541
|
|
|
3538
|
-
const cartographic = Cesium$
|
|
3542
|
+
const cartographic = Cesium$d.Cartographic.fromCartesian(cartesian);
|
|
3539
3543
|
return [
|
|
3540
|
-
Cesium$
|
|
3541
|
-
Cesium$
|
|
3544
|
+
Cesium$d.Math.toDegrees(cartographic.longitude),
|
|
3545
|
+
Cesium$d.Math.toDegrees(cartographic.latitude),
|
|
3542
3546
|
cartographic.height
|
|
3543
3547
|
];
|
|
3544
3548
|
}
|
|
@@ -3549,8 +3553,8 @@ class BaseTool {
|
|
|
3549
3553
|
* @returns {Promise<number>} 地形高度
|
|
3550
3554
|
*/
|
|
3551
3555
|
async getTerrainHeight(lonLat) {
|
|
3552
|
-
const cartographic = Cesium$
|
|
3553
|
-
const result = await Cesium$
|
|
3556
|
+
const cartographic = Cesium$d.Cartographic.fromDegrees(lonLat[0], lonLat[1]);
|
|
3557
|
+
const result = await Cesium$d.sampleTerrainMostDetailed(
|
|
3554
3558
|
this._viewer.terrainProvider,
|
|
3555
3559
|
[cartographic]
|
|
3556
3560
|
);
|
|
@@ -3591,7 +3595,7 @@ class BaseTool {
|
|
|
3591
3595
|
}
|
|
3592
3596
|
}
|
|
3593
3597
|
|
|
3594
|
-
const Cesium$
|
|
3598
|
+
const Cesium$c = getCesium();
|
|
3595
3599
|
|
|
3596
3600
|
/**
|
|
3597
3601
|
* 绘制类型枚举
|
|
@@ -3878,7 +3882,7 @@ class DrawTool extends BaseTool {
|
|
|
3878
3882
|
const id = this.generateId('point');
|
|
3879
3883
|
this._graphicModule.CreatePoint(id)
|
|
3880
3884
|
.setPosition(lonLat)
|
|
3881
|
-
.setColor(Cesium$
|
|
3885
|
+
.setColor(Cesium$c.Color.RED)
|
|
3882
3886
|
.setPixelSize(10);
|
|
3883
3887
|
|
|
3884
3888
|
this._emitGraphicCreated('point', id);
|
|
@@ -3890,9 +3894,9 @@ class DrawTool extends BaseTool {
|
|
|
3890
3894
|
|
|
3891
3895
|
// 创建辅助点
|
|
3892
3896
|
const tempPoint = this.createTempEntity(this.generateId('temp_point'), {
|
|
3893
|
-
position: Cesium$
|
|
3897
|
+
position: Cesium$c.Cartesian3.fromDegrees(...lonLat),
|
|
3894
3898
|
point: {
|
|
3895
|
-
color: Cesium$
|
|
3899
|
+
color: Cesium$c.Color.YELLOW,
|
|
3896
3900
|
pixelSize: 8
|
|
3897
3901
|
}
|
|
3898
3902
|
});
|
|
@@ -3912,9 +3916,9 @@ class DrawTool extends BaseTool {
|
|
|
3912
3916
|
|
|
3913
3917
|
// 创建辅助点
|
|
3914
3918
|
const tempPoint = this.createTempEntity(this.generateId('temp_point'), {
|
|
3915
|
-
position: Cesium$
|
|
3919
|
+
position: Cesium$c.Cartesian3.fromDegrees(...lonLat),
|
|
3916
3920
|
point: {
|
|
3917
|
-
color: Cesium$
|
|
3921
|
+
color: Cesium$c.Color.YELLOW,
|
|
3918
3922
|
pixelSize: 8
|
|
3919
3923
|
}
|
|
3920
3924
|
});
|
|
@@ -3934,9 +3938,9 @@ class DrawTool extends BaseTool {
|
|
|
3934
3938
|
this._startPos = lonLat;
|
|
3935
3939
|
// 创建起始点标记
|
|
3936
3940
|
const startMarker = this.createTempEntity(this.generateId('temp_start'), {
|
|
3937
|
-
position: Cesium$
|
|
3941
|
+
position: Cesium$c.Cartesian3.fromDegrees(...lonLat),
|
|
3938
3942
|
point: {
|
|
3939
|
-
color: Cesium$
|
|
3943
|
+
color: Cesium$c.Color.YELLOW,
|
|
3940
3944
|
pixelSize: 10
|
|
3941
3945
|
}
|
|
3942
3946
|
});
|
|
@@ -3951,9 +3955,9 @@ class DrawTool extends BaseTool {
|
|
|
3951
3955
|
if (!this._startPos) {
|
|
3952
3956
|
this._startPos = lonLat;
|
|
3953
3957
|
const startMarker = this.createTempEntity(this.generateId('temp_start'), {
|
|
3954
|
-
position: Cesium$
|
|
3958
|
+
position: Cesium$c.Cartesian3.fromDegrees(...lonLat),
|
|
3955
3959
|
point: {
|
|
3956
|
-
color: Cesium$
|
|
3960
|
+
color: Cesium$c.Color.YELLOW,
|
|
3957
3961
|
pixelSize: 10
|
|
3958
3962
|
}
|
|
3959
3963
|
});
|
|
@@ -3975,14 +3979,14 @@ class DrawTool extends BaseTool {
|
|
|
3975
3979
|
for (const c of previewPositions) {
|
|
3976
3980
|
flatCoords.push(c[0], c[1], c[2] || 0);
|
|
3977
3981
|
}
|
|
3978
|
-
const cartesians = Cesium$
|
|
3982
|
+
const cartesians = Cesium$c.Cartesian3.fromDegreesArrayHeights(flatCoords);
|
|
3979
3983
|
|
|
3980
3984
|
if (!this._previewLine) {
|
|
3981
3985
|
// 首次创建预览线
|
|
3982
3986
|
this._previewLine = this.createTempEntity(this.generateId('temp_line'), {
|
|
3983
3987
|
polyline: {
|
|
3984
3988
|
positions: cartesians,
|
|
3985
|
-
material: Cesium$
|
|
3989
|
+
material: Cesium$c.Color.YELLOW,
|
|
3986
3990
|
width: 2
|
|
3987
3991
|
}
|
|
3988
3992
|
});
|
|
@@ -3990,7 +3994,7 @@ class DrawTool extends BaseTool {
|
|
|
3990
3994
|
} else {
|
|
3991
3995
|
// 直接更新位置属性,避免重建实体
|
|
3992
3996
|
// this._previewLine.polyline.positions = cartesians;
|
|
3993
|
-
this._previewLine.polyline.positions = new Cesium$
|
|
3997
|
+
this._previewLine.polyline.positions = new Cesium$c.CallbackProperty(() => {
|
|
3994
3998
|
return cartesians;
|
|
3995
3999
|
}, false);
|
|
3996
4000
|
}
|
|
@@ -4010,23 +4014,23 @@ class DrawTool extends BaseTool {
|
|
|
4010
4014
|
for (const c of previewPositions) {
|
|
4011
4015
|
flatCoords.push(c[0], c[1], c[2] || 0);
|
|
4012
4016
|
}
|
|
4013
|
-
const cartesians = Cesium$
|
|
4017
|
+
const cartesians = Cesium$c.Cartesian3.fromDegreesArrayHeights(flatCoords);
|
|
4014
4018
|
|
|
4015
4019
|
if (!this._previewPolygon) {
|
|
4016
4020
|
// 首次创建预览面
|
|
4017
4021
|
this._previewPolygon = this.createTempEntity(this.generateId('temp_polygon'), {
|
|
4018
4022
|
polygon: {
|
|
4019
|
-
hierarchy: new Cesium$
|
|
4020
|
-
material: Cesium$
|
|
4023
|
+
hierarchy: new Cesium$c.PolygonHierarchy(cartesians),
|
|
4024
|
+
material: Cesium$c.Color.YELLOW.withAlpha(0.5),
|
|
4021
4025
|
outline: false,
|
|
4022
|
-
outlineColor: Cesium$
|
|
4026
|
+
outlineColor: Cesium$c.Color.YELLOW,
|
|
4023
4027
|
}
|
|
4024
4028
|
});
|
|
4025
4029
|
this._tempEntities.push(this._previewPolygon);
|
|
4026
4030
|
} else {
|
|
4027
4031
|
// 直接更新层级,避免重建实体,使用 CallbackProperty 防止闪烁
|
|
4028
|
-
this._previewPolygon.polygon.hierarchy = new Cesium$
|
|
4029
|
-
return new Cesium$
|
|
4032
|
+
this._previewPolygon.polygon.hierarchy = new Cesium$c.CallbackProperty(() => {
|
|
4033
|
+
return new Cesium$c.PolygonHierarchy(cartesians);
|
|
4030
4034
|
}, false);
|
|
4031
4035
|
}
|
|
4032
4036
|
}
|
|
@@ -4058,18 +4062,18 @@ class DrawTool extends BaseTool {
|
|
|
4058
4062
|
for (const c of positions) {
|
|
4059
4063
|
flatCoords.push(c[0], c[1], 0);
|
|
4060
4064
|
}
|
|
4061
|
-
const cartesians = Cesium$
|
|
4065
|
+
const cartesians = Cesium$c.Cartesian3.fromDegreesArrayHeights(flatCoords);
|
|
4062
4066
|
|
|
4063
4067
|
if (!this._previewRect) {
|
|
4064
4068
|
this._previewRect = this.createTempEntity(this.generateId('temp_rect'), {
|
|
4065
4069
|
polyline: {
|
|
4066
|
-
positions: new Cesium$
|
|
4067
|
-
material: Cesium$
|
|
4070
|
+
positions: new Cesium$c.CallbackProperty(() => cartesians, false),
|
|
4071
|
+
material: Cesium$c.Color.YELLOW.withAlpha(0.7),
|
|
4068
4072
|
width: 2
|
|
4069
4073
|
},
|
|
4070
4074
|
polygon: {
|
|
4071
|
-
hierarchy: new Cesium$
|
|
4072
|
-
material: Cesium$
|
|
4075
|
+
hierarchy: new Cesium$c.CallbackProperty(() => new Cesium$c.PolygonHierarchy(cartesians), false),
|
|
4076
|
+
material: Cesium$c.Color.YELLOW.withAlpha(0.2),
|
|
4073
4077
|
outline: false
|
|
4074
4078
|
}
|
|
4075
4079
|
});
|
|
@@ -4077,7 +4081,7 @@ class DrawTool extends BaseTool {
|
|
|
4077
4081
|
this._tempEntities.push(this._previewRect);
|
|
4078
4082
|
} else {
|
|
4079
4083
|
// 直接更新位置属性
|
|
4080
|
-
this._previewRect.polyline.positions = new Cesium$
|
|
4084
|
+
this._previewRect.polyline.positions = new Cesium$c.CallbackProperty(() => {
|
|
4081
4085
|
const c1 = this._startPos;
|
|
4082
4086
|
const c2 = this._currentMousePos;
|
|
4083
4087
|
if (!c1 || !c2) return cartesians;
|
|
@@ -4092,12 +4096,12 @@ class DrawTool extends BaseTool {
|
|
|
4092
4096
|
for (const p of pos) {
|
|
4093
4097
|
flat.push(p[0], p[1], 0);
|
|
4094
4098
|
}
|
|
4095
|
-
return Cesium$
|
|
4099
|
+
return Cesium$c.Cartesian3.fromDegreesArrayHeights(flat);
|
|
4096
4100
|
}, false);
|
|
4097
|
-
this._previewRect.polygon.hierarchy = new Cesium$
|
|
4101
|
+
this._previewRect.polygon.hierarchy = new Cesium$c.CallbackProperty(() => {
|
|
4098
4102
|
const c1 = this._startPos;
|
|
4099
4103
|
const c2 = this._currentMousePos;
|
|
4100
|
-
if (!c1 || !c2) return new Cesium$
|
|
4104
|
+
if (!c1 || !c2) return new Cesium$c.PolygonHierarchy(cartesians);
|
|
4101
4105
|
const pos = [
|
|
4102
4106
|
[c1[0], c1[1]],
|
|
4103
4107
|
[c2[0], c1[1]],
|
|
@@ -4109,7 +4113,7 @@ class DrawTool extends BaseTool {
|
|
|
4109
4113
|
for (const p of pos) {
|
|
4110
4114
|
flat.push(p[0], p[1], 0);
|
|
4111
4115
|
}
|
|
4112
|
-
return new Cesium$
|
|
4116
|
+
return new Cesium$c.PolygonHierarchy(Cesium$c.Cartesian3.fromDegreesArrayHeights(flat));
|
|
4113
4117
|
}, false);
|
|
4114
4118
|
}
|
|
4115
4119
|
}
|
|
@@ -4122,12 +4126,12 @@ class DrawTool extends BaseTool {
|
|
|
4122
4126
|
if (!this._previewCircle) {
|
|
4123
4127
|
this._previewCircle = this.createTempEntity(this.generateId('temp_circle'), {
|
|
4124
4128
|
polygon: {
|
|
4125
|
-
hierarchy: new Cesium$
|
|
4129
|
+
hierarchy: new Cesium$c.CallbackProperty(() => {
|
|
4126
4130
|
const positions = this._generateCirclePositions(center, radius, segments);
|
|
4127
4131
|
const flat = positions.flatMap(c => [c[0], c[1], 0]);
|
|
4128
|
-
return new Cesium$
|
|
4132
|
+
return new Cesium$c.PolygonHierarchy(Cesium$c.Cartesian3.fromDegreesArrayHeights(flat));
|
|
4129
4133
|
}, false),
|
|
4130
|
-
material: Cesium$
|
|
4134
|
+
material: Cesium$c.Color.YELLOW.withAlpha(0.2),
|
|
4131
4135
|
outline: false // 地形贴合时不支持 outline,设为 false 避免警告
|
|
4132
4136
|
}
|
|
4133
4137
|
});
|
|
@@ -4135,11 +4139,11 @@ class DrawTool extends BaseTool {
|
|
|
4135
4139
|
this._tempEntities.push(this._previewCircle);
|
|
4136
4140
|
} else {
|
|
4137
4141
|
// 直接更新
|
|
4138
|
-
this._previewCircle.polygon.hierarchy = new Cesium$
|
|
4142
|
+
this._previewCircle.polygon.hierarchy = new Cesium$c.CallbackProperty(() => {
|
|
4139
4143
|
const r = this._calcDistance(this._startPos, this._currentMousePos);
|
|
4140
4144
|
const pos = this._generateCirclePositions(this._startPos, r, 64);
|
|
4141
4145
|
const flat = pos.flatMap(c => [c[0], c[1], 0]);
|
|
4142
|
-
return new Cesium$
|
|
4146
|
+
return new Cesium$c.PolygonHierarchy(Cesium$c.Cartesian3.fromDegreesArrayHeights(flat));
|
|
4143
4147
|
}, false);
|
|
4144
4148
|
}
|
|
4145
4149
|
}
|
|
@@ -4156,10 +4160,10 @@ class DrawTool extends BaseTool {
|
|
|
4156
4160
|
const id = this.generateId('rectangle');
|
|
4157
4161
|
this._graphicModule.CreatePolygon(id)
|
|
4158
4162
|
.setPositions(positions)
|
|
4159
|
-
.setColor(Cesium$
|
|
4160
|
-
.setOutlineColor(Cesium$
|
|
4163
|
+
.setColor(Cesium$c.Color.BLUE.withAlpha(0.5))
|
|
4164
|
+
.setOutlineColor(Cesium$c.Color.BLUE)
|
|
4161
4165
|
.setOutlineWidth(2)
|
|
4162
|
-
.setHeightReference(Cesium$
|
|
4166
|
+
.setHeightReference(Cesium$c.HeightReference.NONE);
|
|
4163
4167
|
|
|
4164
4168
|
this.clearTempEntities();
|
|
4165
4169
|
this._startPos = null;
|
|
@@ -4177,8 +4181,8 @@ class DrawTool extends BaseTool {
|
|
|
4177
4181
|
// 创建圆并标记为圆形
|
|
4178
4182
|
const wrapper = this._graphicModule.CreatePolygon(id);
|
|
4179
4183
|
wrapper.setPositions(positions)
|
|
4180
|
-
.setColor(Cesium$
|
|
4181
|
-
.setOutlineColor(Cesium$
|
|
4184
|
+
.setColor(Cesium$c.Color.BLUE.withAlpha(0.5))
|
|
4185
|
+
.setOutlineColor(Cesium$c.Color.BLUE)
|
|
4182
4186
|
.setOutlineWidth(2);
|
|
4183
4187
|
|
|
4184
4188
|
// 给 entity 添加圆形标记(用于 EditTool 特殊处理)
|
|
@@ -4275,9 +4279,9 @@ class DrawTool extends BaseTool {
|
|
|
4275
4279
|
|
|
4276
4280
|
// 创建辅助点
|
|
4277
4281
|
const tempPoint = this.createTempEntity(this.generateId('temp_point'), {
|
|
4278
|
-
position: Cesium$
|
|
4282
|
+
position: Cesium$c.Cartesian3.fromDegrees(...lngLat),
|
|
4279
4283
|
point: {
|
|
4280
|
-
color: Cesium$
|
|
4284
|
+
color: Cesium$c.Color.YELLOW,
|
|
4281
4285
|
pixelSize: 8
|
|
4282
4286
|
}
|
|
4283
4287
|
});
|
|
@@ -4332,14 +4336,14 @@ class DrawTool extends BaseTool {
|
|
|
4332
4336
|
for (const c of positions) {
|
|
4333
4337
|
flatCoords.push(c[0], c[1], c[2] || 0);
|
|
4334
4338
|
}
|
|
4335
|
-
const cartesians = Cesium$
|
|
4339
|
+
const cartesians = Cesium$c.Cartesian3.fromDegreesArrayHeights(flatCoords);
|
|
4336
4340
|
|
|
4337
4341
|
if (!this._previewPlot) {
|
|
4338
4342
|
if (isLine) {
|
|
4339
4343
|
this._previewPlot = this.createTempEntity(this.generateId('temp_plot'), {
|
|
4340
4344
|
polyline: {
|
|
4341
|
-
positions: new Cesium$
|
|
4342
|
-
material: Cesium$
|
|
4345
|
+
positions: new Cesium$c.CallbackProperty(() => cartesians, false),
|
|
4346
|
+
material: Cesium$c.Color.YELLOW,
|
|
4343
4347
|
width: 2,
|
|
4344
4348
|
clampToGround: true
|
|
4345
4349
|
}
|
|
@@ -4347,13 +4351,13 @@ class DrawTool extends BaseTool {
|
|
|
4347
4351
|
} else {
|
|
4348
4352
|
this._previewPlot = this.createTempEntity(this.generateId('temp_plot'), {
|
|
4349
4353
|
polygon: {
|
|
4350
|
-
hierarchy: new Cesium$
|
|
4351
|
-
material: Cesium$
|
|
4354
|
+
hierarchy: new Cesium$c.CallbackProperty(() => new Cesium$c.PolygonHierarchy(cartesians), false),
|
|
4355
|
+
material: Cesium$c.Color.YELLOW.withAlpha(0.3),
|
|
4352
4356
|
outline: false
|
|
4353
4357
|
},
|
|
4354
4358
|
polyline: {
|
|
4355
|
-
positions: new Cesium$
|
|
4356
|
-
material: Cesium$
|
|
4359
|
+
positions: new Cesium$c.CallbackProperty(() => [...cartesians, cartesians[0]], false),
|
|
4360
|
+
material: Cesium$c.Color.YELLOW,
|
|
4357
4361
|
width: 1
|
|
4358
4362
|
}
|
|
4359
4363
|
});
|
|
@@ -4363,7 +4367,7 @@ class DrawTool extends BaseTool {
|
|
|
4363
4367
|
} else {
|
|
4364
4368
|
const self = this;
|
|
4365
4369
|
if (isLine) {
|
|
4366
|
-
this._previewPlot.polyline.positions = new Cesium$
|
|
4370
|
+
this._previewPlot.polyline.positions = new Cesium$c.CallbackProperty(() => {
|
|
4367
4371
|
const dynamicPositions = [...self._tempPositions];
|
|
4368
4372
|
if (self._currentMousePos) {
|
|
4369
4373
|
dynamicPositions.push(self._currentMousePos);
|
|
@@ -4374,23 +4378,23 @@ class DrawTool extends BaseTool {
|
|
|
4374
4378
|
for (const c of pos) {
|
|
4375
4379
|
flat.push(c[0], c[1], c[2] || 0);
|
|
4376
4380
|
}
|
|
4377
|
-
return Cesium$
|
|
4381
|
+
return Cesium$c.Cartesian3.fromDegreesArrayHeights(flat);
|
|
4378
4382
|
}, false);
|
|
4379
4383
|
} else {
|
|
4380
|
-
this._previewPlot.polygon.hierarchy = new Cesium$
|
|
4384
|
+
this._previewPlot.polygon.hierarchy = new Cesium$c.CallbackProperty(() => {
|
|
4381
4385
|
const dynamicPositions = [...self._tempPositions];
|
|
4382
4386
|
if (self._currentMousePos) {
|
|
4383
4387
|
dynamicPositions.push(self._currentMousePos);
|
|
4384
4388
|
}
|
|
4385
|
-
if (dynamicPositions.length < config.minPoints) return new Cesium$
|
|
4389
|
+
if (dynamicPositions.length < config.minPoints) return new Cesium$c.PolygonHierarchy([]);
|
|
4386
4390
|
const pos = PlotGeometryUtil[factoryName](normalizeForEllipse(dynamicPositions));
|
|
4387
4391
|
const flat = [];
|
|
4388
4392
|
for (const c of pos) {
|
|
4389
4393
|
flat.push(c[0], c[1], c[2] || 0);
|
|
4390
4394
|
}
|
|
4391
|
-
return new Cesium$
|
|
4395
|
+
return new Cesium$c.PolygonHierarchy(Cesium$c.Cartesian3.fromDegreesArrayHeights(flat));
|
|
4392
4396
|
}, false);
|
|
4393
|
-
this._previewPlot.polyline.positions = new Cesium$
|
|
4397
|
+
this._previewPlot.polyline.positions = new Cesium$c.CallbackProperty(() => {
|
|
4394
4398
|
const dynamicPositions = [...self._tempPositions];
|
|
4395
4399
|
if (self._currentMousePos) {
|
|
4396
4400
|
dynamicPositions.push(self._currentMousePos);
|
|
@@ -4401,7 +4405,7 @@ class DrawTool extends BaseTool {
|
|
|
4401
4405
|
for (const c of pos) {
|
|
4402
4406
|
flat.push(c[0], c[1], c[2] || 0);
|
|
4403
4407
|
}
|
|
4404
|
-
const cart = Cesium$
|
|
4408
|
+
const cart = Cesium$c.Cartesian3.fromDegreesArrayHeights(flat);
|
|
4405
4409
|
return [...cart, cart[0]];
|
|
4406
4410
|
}, false);
|
|
4407
4411
|
}
|
|
@@ -4438,11 +4442,11 @@ class DrawTool extends BaseTool {
|
|
|
4438
4442
|
|
|
4439
4443
|
// 应用默认样式
|
|
4440
4444
|
if (isLine) {
|
|
4441
|
-
wrapper.setColor(Cesium$
|
|
4445
|
+
wrapper.setColor(Cesium$c.Color.BLUE).setWidth(2);
|
|
4442
4446
|
} else {
|
|
4443
4447
|
wrapper
|
|
4444
|
-
.setColor(Cesium$
|
|
4445
|
-
.setOutlineColor(Cesium$
|
|
4448
|
+
.setColor(Cesium$c.Color.BLUE.withAlpha(0.5))
|
|
4449
|
+
.setOutlineColor(Cesium$c.Color.BLUE)
|
|
4446
4450
|
.setOutlineWidth(2);
|
|
4447
4451
|
}
|
|
4448
4452
|
|
|
@@ -4495,7 +4499,7 @@ class DrawTool extends BaseTool {
|
|
|
4495
4499
|
const id = this.generateId('line');
|
|
4496
4500
|
this._graphicModule.CreateLine(id)
|
|
4497
4501
|
.setPositions(this._tempPositions)
|
|
4498
|
-
.setColor(Cesium$
|
|
4502
|
+
.setColor(Cesium$c.Color.BLUE)
|
|
4499
4503
|
.setWidth(2);
|
|
4500
4504
|
|
|
4501
4505
|
this._emitGraphicCreated('line', id);
|
|
@@ -4504,8 +4508,8 @@ class DrawTool extends BaseTool {
|
|
|
4504
4508
|
const id = this.generateId('polygon');
|
|
4505
4509
|
this._graphicModule.CreatePolygon(id)
|
|
4506
4510
|
.setPositions(positions)
|
|
4507
|
-
.setColor(Cesium$
|
|
4508
|
-
.setOutlineColor(Cesium$
|
|
4511
|
+
.setColor(Cesium$c.Color.BLUE.withAlpha(0.5))
|
|
4512
|
+
.setOutlineColor(Cesium$c.Color.BLUE);
|
|
4509
4513
|
|
|
4510
4514
|
this._emitGraphicCreated('polygon', id);
|
|
4511
4515
|
}
|
|
@@ -4515,9 +4519,9 @@ class DrawTool extends BaseTool {
|
|
|
4515
4519
|
let deferredPreviewLine = null;
|
|
4516
4520
|
if (this._drawType === DrawType.LINE && this._previewLine) {
|
|
4517
4521
|
const previewLine = this._previewLine;
|
|
4518
|
-
previewLine.polyline.material = Cesium$
|
|
4522
|
+
previewLine.polyline.material = Cesium$c.Color.BLUE;
|
|
4519
4523
|
previewLine.polyline.width = 2;
|
|
4520
|
-
previewLine.polyline.positions = Cesium$
|
|
4524
|
+
previewLine.polyline.positions = Cesium$c.Cartesian3.fromDegreesArrayHeights(
|
|
4521
4525
|
this._tempPositions.flatMap((coord) => [coord[0], coord[1], coord[2] || 0])
|
|
4522
4526
|
);
|
|
4523
4527
|
|
|
@@ -4573,7 +4577,7 @@ class DrawTool extends BaseTool {
|
|
|
4573
4577
|
}
|
|
4574
4578
|
}
|
|
4575
4579
|
|
|
4576
|
-
const Cesium$
|
|
4580
|
+
const Cesium$b = getCesium();
|
|
4577
4581
|
|
|
4578
4582
|
/**
|
|
4579
4583
|
* 编辑模式枚举
|
|
@@ -4658,7 +4662,7 @@ class EditTool extends BaseTool {
|
|
|
4658
4662
|
const picked = this._viewer.scene.pick(screenPos);
|
|
4659
4663
|
console.log('EditTool _onClick:', { picked, screenPos });
|
|
4660
4664
|
|
|
4661
|
-
if (Cesium$
|
|
4665
|
+
if (Cesium$b.defined(picked) && Cesium$b.defined(picked.id)) {
|
|
4662
4666
|
const entityId = picked.id.id;
|
|
4663
4667
|
console.log('EditTool picked entity:', entityId);
|
|
4664
4668
|
|
|
@@ -4694,7 +4698,7 @@ class EditTool extends BaseTool {
|
|
|
4694
4698
|
// 如果已经选中了图元,检查是否点击了控制点
|
|
4695
4699
|
if (this._selectedEntity && !this._isDragging) {
|
|
4696
4700
|
const picked = this._viewer.scene.pick(screenPos);
|
|
4697
|
-
if (Cesium$
|
|
4701
|
+
if (Cesium$b.defined(picked) && Cesium$b.defined(picked.id)) {
|
|
4698
4702
|
const entityId = picked.id.id;
|
|
4699
4703
|
if (entityId && (entityId.startsWith('__edit_handle_') || entityId.includes('__edit_handle_'))) {
|
|
4700
4704
|
// 直接在 _editHandles 中查找被点击的控制点
|
|
@@ -4747,7 +4751,7 @@ class EditTool extends BaseTool {
|
|
|
4747
4751
|
|
|
4748
4752
|
// 检测是否悬停在控制点上
|
|
4749
4753
|
const picked = this._viewer.scene.pick(screenPos);
|
|
4750
|
-
const isOverHandle = Cesium$
|
|
4754
|
+
const isOverHandle = Cesium$b.defined(picked) && Cesium$b.defined(picked.id) &&
|
|
4751
4755
|
picked.id.id && picked.id.id.startsWith('__edit_handle_');
|
|
4752
4756
|
this._setCursorStyle(isOverHandle ? 'move' : 'default');
|
|
4753
4757
|
}
|
|
@@ -4758,14 +4762,14 @@ class EditTool extends BaseTool {
|
|
|
4758
4762
|
// 拖拽时优先使用椭球面拾取,避免拾取到控制点句柄本身导致图元跟随滞后
|
|
4759
4763
|
let lonLat = null;
|
|
4760
4764
|
const cartesian = this._viewer.camera.pickEllipsoid(
|
|
4761
|
-
new Cesium$
|
|
4765
|
+
new Cesium$b.Cartesian2(screenPos.x, screenPos.y),
|
|
4762
4766
|
this._viewer.scene.globe.ellipsoid
|
|
4763
4767
|
);
|
|
4764
4768
|
if (cartesian) {
|
|
4765
|
-
const c = Cesium$
|
|
4769
|
+
const c = Cesium$b.Cartographic.fromCartesian(cartesian);
|
|
4766
4770
|
lonLat = [
|
|
4767
|
-
Cesium$
|
|
4768
|
-
Cesium$
|
|
4771
|
+
Cesium$b.Math.toDegrees(c.longitude),
|
|
4772
|
+
Cesium$b.Math.toDegrees(c.latitude),
|
|
4769
4773
|
c.height || 0
|
|
4770
4774
|
];
|
|
4771
4775
|
} else {
|
|
@@ -4789,16 +4793,16 @@ class EditTool extends BaseTool {
|
|
|
4789
4793
|
const deltaZ = newAnchorCartesian.z - oldAnchorCartesian.z;
|
|
4790
4794
|
|
|
4791
4795
|
const controlPoints = this._selectedEntity._controlPoints.map(cp => {
|
|
4792
|
-
const cpCart = Cesium$
|
|
4793
|
-
const newCpCart = new Cesium$
|
|
4796
|
+
const cpCart = Cesium$b.Cartesian3.fromDegrees(cp[0], cp[1], cp[2] || 0);
|
|
4797
|
+
const newCpCart = new Cesium$b.Cartesian3(
|
|
4794
4798
|
cpCart.x + deltaX,
|
|
4795
4799
|
cpCart.y + deltaY,
|
|
4796
4800
|
cpCart.z + deltaZ
|
|
4797
4801
|
);
|
|
4798
|
-
const newCpCarto = Cesium$
|
|
4802
|
+
const newCpCarto = Cesium$b.Cartographic.fromCartesian(newCpCart);
|
|
4799
4803
|
return [
|
|
4800
|
-
Cesium$
|
|
4801
|
-
Cesium$
|
|
4804
|
+
Cesium$b.Math.toDegrees(newCpCarto.longitude),
|
|
4805
|
+
Cesium$b.Math.toDegrees(newCpCarto.latitude),
|
|
4802
4806
|
newCpCarto.height || 0
|
|
4803
4807
|
];
|
|
4804
4808
|
});
|
|
@@ -4819,8 +4823,8 @@ class EditTool extends BaseTool {
|
|
|
4819
4823
|
const center = (plotType === PlotGraphicType.SECTOR || plotType === PlotGraphicType.ELLIPSE)
|
|
4820
4824
|
? controlPoints[0]
|
|
4821
4825
|
: this._getPlotControlPointsCenter(controlPoints);
|
|
4822
|
-
handle.position = new Cesium$
|
|
4823
|
-
this._clampPositionToGround(Cesium$
|
|
4826
|
+
handle.position = new Cesium$b.ConstantPositionProperty(
|
|
4827
|
+
this._clampPositionToGround(Cesium$b.Cartesian3.fromDegrees(center[0], center[1], center[2] || 0))
|
|
4824
4828
|
);
|
|
4825
4829
|
return;
|
|
4826
4830
|
}
|
|
@@ -4829,8 +4833,8 @@ class EditTool extends BaseTool {
|
|
|
4829
4833
|
if (match) {
|
|
4830
4834
|
const cpIndex = parseInt(match[1], 10);
|
|
4831
4835
|
const cp = controlPoints[cpIndex];
|
|
4832
|
-
handle.position = new Cesium$
|
|
4833
|
-
this._clampPositionToGround(Cesium$
|
|
4836
|
+
handle.position = new Cesium$b.ConstantPositionProperty(
|
|
4837
|
+
this._clampPositionToGround(Cesium$b.Cartesian3.fromDegrees(cp[0], cp[1], cp[2] || 0))
|
|
4834
4838
|
);
|
|
4835
4839
|
}
|
|
4836
4840
|
});
|
|
@@ -4898,10 +4902,10 @@ class EditTool extends BaseTool {
|
|
|
4898
4902
|
*/
|
|
4899
4903
|
_clampPositionToGround(position) {
|
|
4900
4904
|
if (!position) return position;
|
|
4901
|
-
const cartographic = Cesium$
|
|
4902
|
-
return Cesium$
|
|
4903
|
-
Cesium$
|
|
4904
|
-
Cesium$
|
|
4905
|
+
const cartographic = Cesium$b.Cartographic.fromCartesian(position);
|
|
4906
|
+
return Cesium$b.Cartesian3.fromDegrees(
|
|
4907
|
+
Cesium$b.Math.toDegrees(cartographic.longitude),
|
|
4908
|
+
Cesium$b.Math.toDegrees(cartographic.latitude),
|
|
4905
4909
|
0
|
|
4906
4910
|
);
|
|
4907
4911
|
}
|
|
@@ -4923,17 +4927,17 @@ class EditTool extends BaseTool {
|
|
|
4923
4927
|
if ((isSector || isEllipse) && index === 0) return; // 扇形/椭圆圆心/中心由中心控制点处理
|
|
4924
4928
|
|
|
4925
4929
|
const clampedPos = this._clampPositionToGround(
|
|
4926
|
-
Cesium$
|
|
4930
|
+
Cesium$b.Cartesian3.fromDegrees(cp[0], cp[1], cp[2] || 0)
|
|
4927
4931
|
);
|
|
4928
4932
|
const handle = this.createTempEntity(`__edit_handle_${index}`, {
|
|
4929
4933
|
position: clampedPos,
|
|
4930
4934
|
point: {
|
|
4931
|
-
color: Cesium$
|
|
4935
|
+
color: Cesium$b.Color.YELLOW,
|
|
4932
4936
|
pixelSize: 12,
|
|
4933
|
-
outlineColor: Cesium$
|
|
4937
|
+
outlineColor: Cesium$b.Color.RED,
|
|
4934
4938
|
outlineWidth: 2,
|
|
4935
4939
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
4936
|
-
heightReference: Cesium$
|
|
4940
|
+
heightReference: Cesium$b.HeightReference.CLAMP_TO_GROUND
|
|
4937
4941
|
}
|
|
4938
4942
|
});
|
|
4939
4943
|
this._editHandles.push(handle);
|
|
@@ -4970,18 +4974,18 @@ class EditTool extends BaseTool {
|
|
|
4970
4974
|
if (!center) return;
|
|
4971
4975
|
|
|
4972
4976
|
this._originalEntityCenter = this._clampPositionToGround(
|
|
4973
|
-
Cesium$
|
|
4977
|
+
Cesium$b.Cartesian3.fromDegrees(center[0], center[1], center[2] || 0)
|
|
4974
4978
|
);
|
|
4975
4979
|
|
|
4976
4980
|
const handle = this.createTempEntity('__edit_handle_center_plot', {
|
|
4977
4981
|
position: this._originalEntityCenter,
|
|
4978
4982
|
point: {
|
|
4979
|
-
color: Cesium$
|
|
4983
|
+
color: Cesium$b.Color.CYAN,
|
|
4980
4984
|
pixelSize: 14,
|
|
4981
|
-
outlineColor: Cesium$
|
|
4985
|
+
outlineColor: Cesium$b.Color.BLUE,
|
|
4982
4986
|
outlineWidth: 2,
|
|
4983
4987
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
4984
|
-
heightReference: Cesium$
|
|
4988
|
+
heightReference: Cesium$b.HeightReference.CLAMP_TO_GROUND
|
|
4985
4989
|
}
|
|
4986
4990
|
});
|
|
4987
4991
|
this._editHandles.push(handle);
|
|
@@ -5009,7 +5013,7 @@ class EditTool extends BaseTool {
|
|
|
5009
5013
|
_createPlotPositionOutline() {
|
|
5010
5014
|
const self = this;
|
|
5011
5015
|
const entity = this._selectedEntity;
|
|
5012
|
-
const isLine = Cesium$
|
|
5016
|
+
const isLine = Cesium$b.defined(entity.polyline);
|
|
5013
5017
|
|
|
5014
5018
|
// 以下标绘图元的控制点连线会干扰真实几何,不绘制轮廓辅助线
|
|
5015
5019
|
const skipOutlineTypes = new Set([
|
|
@@ -5026,7 +5030,7 @@ class EditTool extends BaseTool {
|
|
|
5026
5030
|
|
|
5027
5031
|
this._positionOutline = this.createTempEntity(this.generateId('temp_plot_outline'), {
|
|
5028
5032
|
polyline: {
|
|
5029
|
-
positions: new Cesium$
|
|
5033
|
+
positions: new Cesium$b.CallbackProperty(function () {
|
|
5030
5034
|
const handles = self._editHandles;
|
|
5031
5035
|
if (!handles || handles.length === 0) return [];
|
|
5032
5036
|
|
|
@@ -5041,7 +5045,7 @@ class EditTool extends BaseTool {
|
|
|
5041
5045
|
let positions = null;
|
|
5042
5046
|
if (hierarchy) {
|
|
5043
5047
|
if (typeof hierarchy.getValue === 'function') {
|
|
5044
|
-
const value = hierarchy.getValue(Cesium$
|
|
5048
|
+
const value = hierarchy.getValue(Cesium$b.JulianDate.now());
|
|
5045
5049
|
positions = value ? value.positions : null;
|
|
5046
5050
|
} else if (hierarchy.positions) {
|
|
5047
5051
|
positions = hierarchy.positions;
|
|
@@ -5061,24 +5065,24 @@ class EditTool extends BaseTool {
|
|
|
5061
5065
|
// 跳过中心平移控制点
|
|
5062
5066
|
if (handle.id && handle.id.includes('center')) return;
|
|
5063
5067
|
|
|
5064
|
-
const pos = handle.position.getValue(Cesium$
|
|
5068
|
+
const pos = handle.position.getValue(Cesium$b.JulianDate.now());
|
|
5065
5069
|
if (pos) {
|
|
5066
|
-
const c = Cesium$
|
|
5067
|
-
degrees.push(Cesium$
|
|
5068
|
-
degrees.push(Cesium$
|
|
5070
|
+
const c = Cesium$b.Cartographic.fromCartesian(pos);
|
|
5071
|
+
degrees.push(Cesium$b.Math.toDegrees(c.longitude));
|
|
5072
|
+
degrees.push(Cesium$b.Math.toDegrees(c.latitude));
|
|
5069
5073
|
degrees.push(c.height || 0);
|
|
5070
5074
|
}
|
|
5071
5075
|
});
|
|
5072
5076
|
|
|
5073
5077
|
if (degrees.length === 0) return [];
|
|
5074
5078
|
|
|
5075
|
-
const cartesians = Cesium$
|
|
5079
|
+
const cartesians = Cesium$b.Cartesian3.fromDegreesArrayHeights(degrees);
|
|
5076
5080
|
if (isLine) {
|
|
5077
5081
|
return cartesians;
|
|
5078
5082
|
}
|
|
5079
5083
|
return [...cartesians, cartesians[0]];
|
|
5080
5084
|
}, false),
|
|
5081
|
-
material: Cesium$
|
|
5085
|
+
material: Cesium$b.Color.YELLOW,
|
|
5082
5086
|
width: 2,
|
|
5083
5087
|
clampToGround: true
|
|
5084
5088
|
}
|
|
@@ -5094,17 +5098,17 @@ class EditTool extends BaseTool {
|
|
|
5094
5098
|
const self = this;
|
|
5095
5099
|
const axisLine = this.createTempEntity(this.generateId('temp_ellipse_axis'), {
|
|
5096
5100
|
polyline: {
|
|
5097
|
-
positions: new Cesium$
|
|
5101
|
+
positions: new Cesium$b.CallbackProperty(function () {
|
|
5098
5102
|
const entity = self._selectedEntity;
|
|
5099
5103
|
const cps = entity?._controlPoints;
|
|
5100
5104
|
if (!cps || cps.length < 3) return [];
|
|
5101
5105
|
|
|
5102
|
-
const center = Cesium$
|
|
5103
|
-
const major = Cesium$
|
|
5104
|
-
const minor = Cesium$
|
|
5106
|
+
const center = Cesium$b.Cartesian3.fromDegrees(cps[0][0], cps[0][1], cps[0][2] || 0);
|
|
5107
|
+
const major = Cesium$b.Cartesian3.fromDegrees(cps[1][0], cps[1][1], cps[1][2] || 0);
|
|
5108
|
+
const minor = Cesium$b.Cartesian3.fromDegrees(cps[2][0], cps[2][1], cps[2][2] || 0);
|
|
5105
5109
|
return [center, major, center, minor];
|
|
5106
5110
|
}, false),
|
|
5107
|
-
material: Cesium$
|
|
5111
|
+
material: Cesium$b.Color.YELLOW,
|
|
5108
5112
|
width: 2,
|
|
5109
5113
|
clampToGround: true
|
|
5110
5114
|
}
|
|
@@ -5119,7 +5123,7 @@ class EditTool extends BaseTool {
|
|
|
5119
5123
|
*/
|
|
5120
5124
|
_createVertexHandles(positions) {
|
|
5121
5125
|
// 判断是否是矩形(4个顶点形成矩形)
|
|
5122
|
-
const isRectangle = Cesium$
|
|
5126
|
+
const isRectangle = Cesium$b.defined(this._selectedEntity.polygon) && positions.length === 4 &&
|
|
5123
5127
|
this._isRectangle(positions);
|
|
5124
5128
|
|
|
5125
5129
|
if (isRectangle) {
|
|
@@ -5133,12 +5137,12 @@ class EditTool extends BaseTool {
|
|
|
5133
5137
|
const handle = this.createTempEntity(`__edit_handle_${handleIdx}`, {
|
|
5134
5138
|
position: clampedPos,
|
|
5135
5139
|
point: {
|
|
5136
|
-
color: Cesium$
|
|
5140
|
+
color: Cesium$b.Color.YELLOW,
|
|
5137
5141
|
pixelSize: 12,
|
|
5138
|
-
outlineColor: Cesium$
|
|
5142
|
+
outlineColor: Cesium$b.Color.RED,
|
|
5139
5143
|
outlineWidth: 2,
|
|
5140
5144
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
5141
|
-
heightReference: Cesium$
|
|
5145
|
+
heightReference: Cesium$b.HeightReference.CLAMP_TO_GROUND,
|
|
5142
5146
|
}
|
|
5143
5147
|
});
|
|
5144
5148
|
this._editHandles.push(handle);
|
|
@@ -5151,20 +5155,20 @@ class EditTool extends BaseTool {
|
|
|
5151
5155
|
|
|
5152
5156
|
const { center, radius } = circleInfo;
|
|
5153
5157
|
// 修复:圆心位置贴地
|
|
5154
|
-
const centerCartesian = Cesium$
|
|
5158
|
+
const centerCartesian = Cesium$b.Cartesian3.fromDegrees(center[0], center[1], 0);
|
|
5155
5159
|
const radiusPoint = this._getPointOnCircle(center, radius, 0);
|
|
5156
|
-
const radiusCartesian = Cesium$
|
|
5160
|
+
const radiusCartesian = Cesium$b.Cartesian3.fromDegrees(radiusPoint[0], radiusPoint[1], 0);
|
|
5157
5161
|
|
|
5158
5162
|
// 圆心控制点(可平移)- 使用与其他类型不同的ID格式
|
|
5159
5163
|
const centerHandle = this.createTempEntity('__edit_handle_center', {
|
|
5160
5164
|
position: centerCartesian,
|
|
5161
5165
|
point: {
|
|
5162
|
-
color: Cesium$
|
|
5166
|
+
color: Cesium$b.Color.CYAN,
|
|
5163
5167
|
pixelSize: 14,
|
|
5164
|
-
outlineColor: Cesium$
|
|
5168
|
+
outlineColor: Cesium$b.Color.BLUE,
|
|
5165
5169
|
outlineWidth: 2,
|
|
5166
5170
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
5167
|
-
heightReference: Cesium$
|
|
5171
|
+
heightReference: Cesium$b.HeightReference.CLAMP_TO_GROUND
|
|
5168
5172
|
}
|
|
5169
5173
|
});
|
|
5170
5174
|
this._editHandles.push(centerHandle);
|
|
@@ -5173,12 +5177,12 @@ class EditTool extends BaseTool {
|
|
|
5173
5177
|
const radiusHandle = this.createTempEntity('__edit_handle_radius', {
|
|
5174
5178
|
position: radiusCartesian,
|
|
5175
5179
|
point: {
|
|
5176
|
-
color: Cesium$
|
|
5180
|
+
color: Cesium$b.Color.RED,
|
|
5177
5181
|
pixelSize: 12,
|
|
5178
|
-
outlineColor: Cesium$
|
|
5182
|
+
outlineColor: Cesium$b.Color.YELLOW,
|
|
5179
5183
|
outlineWidth: 2,
|
|
5180
5184
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
5181
|
-
heightReference: Cesium$
|
|
5185
|
+
heightReference: Cesium$b.HeightReference.CLAMP_TO_GROUND
|
|
5182
5186
|
}
|
|
5183
5187
|
});
|
|
5184
5188
|
this._editHandles.push(radiusHandle);
|
|
@@ -5198,9 +5202,9 @@ class EditTool extends BaseTool {
|
|
|
5198
5202
|
const handle = this.createTempEntity(`__edit_handle_${index}`, {
|
|
5199
5203
|
position: clampedPos,
|
|
5200
5204
|
point: {
|
|
5201
|
-
color: Cesium$
|
|
5205
|
+
color: Cesium$b.Color.YELLOW,
|
|
5202
5206
|
pixelSize: 12,
|
|
5203
|
-
outlineColor: Cesium$
|
|
5207
|
+
outlineColor: Cesium$b.Color.RED,
|
|
5204
5208
|
outlineWidth: 2,
|
|
5205
5209
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
5206
5210
|
// heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
|
|
@@ -5240,12 +5244,12 @@ class EditTool extends BaseTool {
|
|
|
5240
5244
|
const handle = this.createTempEntity('__edit_handle_center_vertex', {
|
|
5241
5245
|
position: clampedCenter,
|
|
5242
5246
|
point: {
|
|
5243
|
-
color: Cesium$
|
|
5247
|
+
color: Cesium$b.Color.CYAN,
|
|
5244
5248
|
pixelSize: 14,
|
|
5245
|
-
outlineColor: Cesium$
|
|
5249
|
+
outlineColor: Cesium$b.Color.BLUE,
|
|
5246
5250
|
outlineWidth: 2,
|
|
5247
5251
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
5248
|
-
heightReference: Cesium$
|
|
5252
|
+
heightReference: Cesium$b.HeightReference.CLAMP_TO_GROUND
|
|
5249
5253
|
}
|
|
5250
5254
|
});
|
|
5251
5255
|
this._editHandles.push(handle);
|
|
@@ -5269,7 +5273,7 @@ class EditTool extends BaseTool {
|
|
|
5269
5273
|
const clampedCenter = this._clampPositionToGround(newCenter);
|
|
5270
5274
|
|
|
5271
5275
|
// 更新中心控制点位置
|
|
5272
|
-
centerHandle.position = new Cesium$
|
|
5276
|
+
centerHandle.position = new Cesium$b.ConstantPositionProperty(clampedCenter);
|
|
5273
5277
|
// 更新原始中心点缓存(用于下次平移计算)
|
|
5274
5278
|
this._originalEntityCenter = clampedCenter;
|
|
5275
5279
|
}
|
|
@@ -5277,11 +5281,11 @@ class EditTool extends BaseTool {
|
|
|
5277
5281
|
_createPositionOutline() {
|
|
5278
5282
|
// 从控制点获取位置,性能更好(避免每次从实体重新获取和转换)
|
|
5279
5283
|
const self = this;
|
|
5280
|
-
const isPolyline = Cesium$
|
|
5284
|
+
const isPolyline = Cesium$b.defined(this._selectedEntity.polyline);
|
|
5281
5285
|
|
|
5282
5286
|
this._positionOutline = this.createTempEntity(this.generateId('temp_outline'), {
|
|
5283
5287
|
polyline: {
|
|
5284
|
-
positions: new Cesium$
|
|
5288
|
+
positions: new Cesium$b.CallbackProperty(function () {
|
|
5285
5289
|
// 从控制点获取位置(已被更新),排除中心控制点
|
|
5286
5290
|
const handles = self._editHandles;
|
|
5287
5291
|
if (!handles || handles.length === 0) return [];
|
|
@@ -5292,11 +5296,11 @@ class EditTool extends BaseTool {
|
|
|
5292
5296
|
// 跳过所有中心控制点(用于平移)- 修复:统一使用 includes('center')
|
|
5293
5297
|
if (handle.id && handle.id.includes('center')) return;
|
|
5294
5298
|
|
|
5295
|
-
const pos = handle.position.getValue(Cesium$
|
|
5299
|
+
const pos = handle.position.getValue(Cesium$b.JulianDate.now());
|
|
5296
5300
|
if (pos) {
|
|
5297
|
-
const c = Cesium$
|
|
5298
|
-
degrees.push(Cesium$
|
|
5299
|
-
degrees.push(Cesium$
|
|
5301
|
+
const c = Cesium$b.Cartographic.fromCartesian(pos);
|
|
5302
|
+
degrees.push(Cesium$b.Math.toDegrees(c.longitude));
|
|
5303
|
+
degrees.push(Cesium$b.Math.toDegrees(c.latitude));
|
|
5300
5304
|
degrees.push(c.height || 0);
|
|
5301
5305
|
}
|
|
5302
5306
|
});
|
|
@@ -5305,12 +5309,12 @@ class EditTool extends BaseTool {
|
|
|
5305
5309
|
|
|
5306
5310
|
// 线不闭合,面需要闭合
|
|
5307
5311
|
if (isPolyline) {
|
|
5308
|
-
return Cesium$
|
|
5312
|
+
return Cesium$b.Cartesian3.fromDegreesArrayHeights(degrees);
|
|
5309
5313
|
}
|
|
5310
5314
|
// 闭合多边形(首尾点相同)
|
|
5311
|
-
return Cesium$
|
|
5315
|
+
return Cesium$b.Cartesian3.fromDegreesArrayHeights([...degrees, degrees[0], degrees[1], degrees[2] || 0]);
|
|
5312
5316
|
}, false),
|
|
5313
|
-
material: Cesium$
|
|
5317
|
+
material: Cesium$b.Color.YELLOW,
|
|
5314
5318
|
width: 2,
|
|
5315
5319
|
clampToGround: true
|
|
5316
5320
|
}
|
|
@@ -5342,12 +5346,12 @@ class EditTool extends BaseTool {
|
|
|
5342
5346
|
_getEditablePositions(entity) {
|
|
5343
5347
|
if (!entity) return [];
|
|
5344
5348
|
|
|
5345
|
-
if (Cesium$
|
|
5346
|
-
return entity.polyline.positions.getValue(Cesium$
|
|
5349
|
+
if (Cesium$b.defined(entity.polyline) && Cesium$b.defined(entity.polyline.positions)) {
|
|
5350
|
+
return entity.polyline.positions.getValue(Cesium$b.JulianDate.now());
|
|
5347
5351
|
}
|
|
5348
5352
|
|
|
5349
|
-
if (Cesium$
|
|
5350
|
-
const hierarchy = entity.polygon.hierarchy.getValue(Cesium$
|
|
5353
|
+
if (Cesium$b.defined(entity.polygon) && Cesium$b.defined(entity.polygon.hierarchy)) {
|
|
5354
|
+
const hierarchy = entity.polygon.hierarchy.getValue(Cesium$b.JulianDate.now());
|
|
5351
5355
|
if (hierarchy && hierarchy.positions) {
|
|
5352
5356
|
let positions = hierarchy.positions;
|
|
5353
5357
|
|
|
@@ -5356,7 +5360,7 @@ class EditTool extends BaseTool {
|
|
|
5356
5360
|
const first = positions[0];
|
|
5357
5361
|
const last = positions[positions.length - 1];
|
|
5358
5362
|
// 使用距离判断而不是精确相等(避免浮点误差)
|
|
5359
|
-
const distance = Cesium$
|
|
5363
|
+
const distance = Cesium$b.Cartesian3.distance(first, last);
|
|
5360
5364
|
if (distance < EditTool.CLOSE_POINT_TOLERANCE) {
|
|
5361
5365
|
positions = positions.slice(0, -1); // 移除最后一个点
|
|
5362
5366
|
}
|
|
@@ -5366,8 +5370,8 @@ class EditTool extends BaseTool {
|
|
|
5366
5370
|
}
|
|
5367
5371
|
}
|
|
5368
5372
|
|
|
5369
|
-
if (Cesium$
|
|
5370
|
-
return [entity.position.getValue(Cesium$
|
|
5373
|
+
if (Cesium$b.defined(entity.position)) {
|
|
5374
|
+
return [entity.position.getValue(Cesium$b.JulianDate.now())];
|
|
5371
5375
|
}
|
|
5372
5376
|
|
|
5373
5377
|
return [];
|
|
@@ -5391,7 +5395,7 @@ class EditTool extends BaseTool {
|
|
|
5391
5395
|
z += p.z;
|
|
5392
5396
|
});
|
|
5393
5397
|
const count = positions.length;
|
|
5394
|
-
return new Cesium$
|
|
5398
|
+
return new Cesium$b.Cartesian3(x / count, y / count, z / count);
|
|
5395
5399
|
}
|
|
5396
5400
|
|
|
5397
5401
|
/**
|
|
@@ -5416,7 +5420,7 @@ class EditTool extends BaseTool {
|
|
|
5416
5420
|
const deltaZ = clampedNewCenter.z - this._originalEntityCenter.z;
|
|
5417
5421
|
|
|
5418
5422
|
// 计算真正的新中心位置(不是鼠标位置)
|
|
5419
|
-
const actualNewCenter = new Cesium$
|
|
5423
|
+
const actualNewCenter = new Cesium$b.Cartesian3(
|
|
5420
5424
|
this._originalEntityCenter.x + deltaX,
|
|
5421
5425
|
this._originalEntityCenter.y + deltaY,
|
|
5422
5426
|
this._originalEntityCenter.z + deltaZ
|
|
@@ -5426,12 +5430,12 @@ class EditTool extends BaseTool {
|
|
|
5426
5430
|
this._originalEntityCenter = actualNewCenter;
|
|
5427
5431
|
|
|
5428
5432
|
// 更新中心控制点位置
|
|
5429
|
-
this._dragHandle.position = new Cesium$
|
|
5433
|
+
this._dragHandle.position = new Cesium$b.ConstantPositionProperty(actualNewCenter);
|
|
5430
5434
|
|
|
5431
|
-
if (Cesium$
|
|
5435
|
+
if (Cesium$b.defined(this._selectedEntity.polyline)) {
|
|
5432
5436
|
// 线图元:平移所有位置
|
|
5433
5437
|
const newPositions = this._originalPositions.map(p => {
|
|
5434
|
-
const newPos = new Cesium$
|
|
5438
|
+
const newPos = new Cesium$b.Cartesian3(p.x + deltaX, p.y + deltaY, p.z + deltaZ);
|
|
5435
5439
|
// 修复:贴地
|
|
5436
5440
|
return this._clampPositionToGround(newPos);
|
|
5437
5441
|
});
|
|
@@ -5449,32 +5453,32 @@ class EditTool extends BaseTool {
|
|
|
5449
5453
|
if (match) {
|
|
5450
5454
|
const index = parseInt(match[1], 10);
|
|
5451
5455
|
if (newPositions[index]) {
|
|
5452
|
-
handle.position = new Cesium$
|
|
5456
|
+
handle.position = new Cesium$b.ConstantPositionProperty(newPositions[index]);
|
|
5453
5457
|
}
|
|
5454
5458
|
}
|
|
5455
5459
|
});
|
|
5456
5460
|
|
|
5457
5461
|
// 更新原始位置缓存
|
|
5458
5462
|
this._originalPositions = newPositions;
|
|
5459
|
-
} else if (Cesium$
|
|
5463
|
+
} else if (Cesium$b.defined(this._selectedEntity.polygon)) {
|
|
5460
5464
|
if (this._isCircle(this._selectedEntity)) {
|
|
5461
5465
|
// 圆形平移
|
|
5462
5466
|
const oldCenter = this._selectedEntity._circleCenter; // [lon, lat]
|
|
5463
5467
|
|
|
5464
5468
|
// 将旧的圆心经纬度转为 Cartesian3
|
|
5465
|
-
const oldCenterCartesian = Cesium$
|
|
5469
|
+
const oldCenterCartesian = Cesium$b.Cartesian3.fromDegrees(oldCenter[0], oldCenter[1], 0);
|
|
5466
5470
|
|
|
5467
5471
|
// 应用偏移量计算新的 Cartesian3 位置
|
|
5468
|
-
const newCenterCartesian = new Cesium$
|
|
5472
|
+
const newCenterCartesian = new Cesium$b.Cartesian3(
|
|
5469
5473
|
oldCenterCartesian.x + deltaX,
|
|
5470
5474
|
oldCenterCartesian.y + deltaY,
|
|
5471
5475
|
oldCenterCartesian.z + deltaZ
|
|
5472
5476
|
);
|
|
5473
5477
|
|
|
5474
5478
|
// 将新的 Cartesian3 转回经纬度
|
|
5475
|
-
const newCenterCartographic = Cesium$
|
|
5476
|
-
const newCenterLon = Cesium$
|
|
5477
|
-
const newCenterLat = Cesium$
|
|
5479
|
+
const newCenterCartographic = Cesium$b.Cartographic.fromCartesian(newCenterCartesian);
|
|
5480
|
+
const newCenterLon = Cesium$b.Math.toDegrees(newCenterCartographic.longitude);
|
|
5481
|
+
const newCenterLat = Cesium$b.Math.toDegrees(newCenterCartographic.latitude);
|
|
5478
5482
|
|
|
5479
5483
|
this._selectedEntity._circleCenter = [newCenterLon, newCenterLat];
|
|
5480
5484
|
|
|
@@ -5485,25 +5489,25 @@ class EditTool extends BaseTool {
|
|
|
5485
5489
|
256
|
|
5486
5490
|
);
|
|
5487
5491
|
const flat = positions.flatMap(c => [c[0], c[1], 0]);
|
|
5488
|
-
this._selectedEntity.polygon.hierarchy = new Cesium$
|
|
5489
|
-
Cesium$
|
|
5492
|
+
this._selectedEntity.polygon.hierarchy = new Cesium$b.PolygonHierarchy(
|
|
5493
|
+
Cesium$b.Cartesian3.fromDegreesArrayHeights(flat)
|
|
5490
5494
|
);
|
|
5491
5495
|
|
|
5492
5496
|
// 更新圆心控制点位置
|
|
5493
5497
|
const centerHandle = this._editHandles.find(h => h.id && h.id.includes('__edit_handle_center'));
|
|
5494
5498
|
if (centerHandle) {
|
|
5495
|
-
centerHandle.position = new Cesium$
|
|
5499
|
+
centerHandle.position = new Cesium$b.ConstantPositionProperty(newCenterCartesian);
|
|
5496
5500
|
}
|
|
5497
5501
|
} else {
|
|
5498
5502
|
// 普通多边形:平移所有顶点
|
|
5499
5503
|
const newPositions = this._originalPositions.map(p => {
|
|
5500
|
-
const newPos = new Cesium$
|
|
5504
|
+
const newPos = new Cesium$b.Cartesian3(p.x + deltaX, p.y + deltaY, p.z + deltaZ);
|
|
5501
5505
|
// 修复:贴地
|
|
5502
5506
|
return this._clampPositionToGround(newPos);
|
|
5503
5507
|
});
|
|
5504
5508
|
// 添加闭合点
|
|
5505
5509
|
newPositions.push(newPositions[0].clone());
|
|
5506
|
-
this._selectedEntity.polygon.hierarchy = new Cesium$
|
|
5510
|
+
this._selectedEntity.polygon.hierarchy = new Cesium$b.PolygonHierarchy(newPositions);
|
|
5507
5511
|
|
|
5508
5512
|
// 修复:更新顶点控制点位置,使用更可靠的ID匹配
|
|
5509
5513
|
this._editHandles.forEach((handle) => {
|
|
@@ -5516,7 +5520,7 @@ class EditTool extends BaseTool {
|
|
|
5516
5520
|
if (match) {
|
|
5517
5521
|
const index = parseInt(match[1], 10);
|
|
5518
5522
|
if (newPositions[index]) {
|
|
5519
|
-
handle.position = new Cesium$
|
|
5523
|
+
handle.position = new Cesium$b.ConstantPositionProperty(newPositions[index]);
|
|
5520
5524
|
}
|
|
5521
5525
|
}
|
|
5522
5526
|
});
|
|
@@ -5524,9 +5528,9 @@ class EditTool extends BaseTool {
|
|
|
5524
5528
|
// 更新原始位置缓存
|
|
5525
5529
|
this._originalPositions = newPositions.slice(0, -1);
|
|
5526
5530
|
}
|
|
5527
|
-
} else if (Cesium$
|
|
5531
|
+
} else if (Cesium$b.defined(this._selectedEntity.position)) {
|
|
5528
5532
|
// 点/文本图元:平移位置
|
|
5529
|
-
this._selectedEntity.position = new Cesium$
|
|
5533
|
+
this._selectedEntity.position = new Cesium$b.ConstantPositionProperty(actualNewCenter);
|
|
5530
5534
|
this._originalPositions = [actualNewCenter];
|
|
5531
5535
|
}
|
|
5532
5536
|
}
|
|
@@ -5655,16 +5659,16 @@ class EditTool extends BaseTool {
|
|
|
5655
5659
|
// 圆周辅助线(黄色)
|
|
5656
5660
|
this._positionOutline = this.createTempEntity(this.generateId('temp_circle_outline'), {
|
|
5657
5661
|
polyline: {
|
|
5658
|
-
positions: new Cesium$
|
|
5662
|
+
positions: new Cesium$b.CallbackProperty(function () {
|
|
5659
5663
|
const circleInfo = self._getCircleInfo(self._selectedEntity);
|
|
5660
5664
|
if (!circleInfo) return [];
|
|
5661
5665
|
|
|
5662
5666
|
const { center, radius } = circleInfo;
|
|
5663
5667
|
const positions = self._generateCirclePositions(center, radius, 256);
|
|
5664
5668
|
const flat = positions.flatMap(c => [c[0], c[1], 0]);
|
|
5665
|
-
return Cesium$
|
|
5669
|
+
return Cesium$b.Cartesian3.fromDegreesArrayHeights(flat);
|
|
5666
5670
|
}, false),
|
|
5667
|
-
material: Cesium$
|
|
5671
|
+
material: Cesium$b.Color.YELLOW,
|
|
5668
5672
|
width: 2,
|
|
5669
5673
|
clampToGround: true
|
|
5670
5674
|
}
|
|
@@ -5676,7 +5680,7 @@ class EditTool extends BaseTool {
|
|
|
5676
5680
|
// 修复:正确获取半径控制点的位置
|
|
5677
5681
|
this._radiusLine = this.createTempEntity(this.generateId('temp_radius_line'), {
|
|
5678
5682
|
polyline: {
|
|
5679
|
-
positions: new Cesium$
|
|
5683
|
+
positions: new Cesium$b.CallbackProperty(function () {
|
|
5680
5684
|
const circleInfo = self._getCircleInfo(self._selectedEntity);
|
|
5681
5685
|
if (!circleInfo) return [];
|
|
5682
5686
|
|
|
@@ -5685,13 +5689,13 @@ class EditTool extends BaseTool {
|
|
|
5685
5689
|
const radiusHandle = self._editHandles.find(h => h.id && h.id.includes('__edit_handle_radius'));
|
|
5686
5690
|
if (!radiusHandle) return [];
|
|
5687
5691
|
|
|
5688
|
-
const radiusPos = radiusHandle.position.getValue(Cesium$
|
|
5692
|
+
const radiusPos = radiusHandle.position.getValue(Cesium$b.JulianDate.now());
|
|
5689
5693
|
if (!radiusPos) return [];
|
|
5690
5694
|
|
|
5691
|
-
const centerCart = Cesium$
|
|
5695
|
+
const centerCart = Cesium$b.Cartesian3.fromDegrees(center[0], center[1], 0);
|
|
5692
5696
|
return [centerCart, radiusPos];
|
|
5693
5697
|
}, false),
|
|
5694
|
-
material: Cesium$
|
|
5698
|
+
material: Cesium$b.Color.RED,
|
|
5695
5699
|
width: 3,
|
|
5696
5700
|
clampToGround: true
|
|
5697
5701
|
}
|
|
@@ -5731,8 +5735,8 @@ class EditTool extends BaseTool {
|
|
|
5731
5735
|
_computeRectangleNewPositions(newPos, originalPositions, draggedIndex) {
|
|
5732
5736
|
// 对角顶点索引:0->2, 1->3, 2->0, 3->1
|
|
5733
5737
|
const oppositeIndex = (draggedIndex + 2) % 4;
|
|
5734
|
-
const newP = Cesium$
|
|
5735
|
-
const currentPos = originalPositions.map(p => Cesium$
|
|
5738
|
+
const newP = Cesium$b.Cartographic.fromCartesian(newPos);
|
|
5739
|
+
const currentPos = originalPositions.map(p => Cesium$b.Cartographic.fromCartesian(p));
|
|
5736
5740
|
const oppositePos = currentPos[oppositeIndex];
|
|
5737
5741
|
|
|
5738
5742
|
const newPositions = new Array(4);
|
|
@@ -5745,14 +5749,14 @@ class EditTool extends BaseTool {
|
|
|
5745
5749
|
const neighbor2 = (draggedIndex + 3) % 4;
|
|
5746
5750
|
|
|
5747
5751
|
// neighbor1 使用 newPos 的 longitude 和 opposite 的 latitude
|
|
5748
|
-
newPositions[neighbor1] = Cesium$
|
|
5752
|
+
newPositions[neighbor1] = Cesium$b.Cartesian3.fromRadians(
|
|
5749
5753
|
newP.longitude,
|
|
5750
5754
|
oppositePos.latitude,
|
|
5751
5755
|
oppositePos.height
|
|
5752
5756
|
);
|
|
5753
5757
|
|
|
5754
5758
|
// neighbor2 使用 opposite 的 longitude 和 newPos 的 latitude
|
|
5755
|
-
newPositions[neighbor2] = Cesium$
|
|
5759
|
+
newPositions[neighbor2] = Cesium$b.Cartesian3.fromRadians(
|
|
5756
5760
|
oppositePos.longitude,
|
|
5757
5761
|
newP.latitude,
|
|
5758
5762
|
oppositePos.height
|
|
@@ -5768,7 +5772,7 @@ class EditTool extends BaseTool {
|
|
|
5768
5772
|
if (handleIndex === -1) return;
|
|
5769
5773
|
|
|
5770
5774
|
// 修复:新位置贴地(高度设为0)
|
|
5771
|
-
const newCartesian = Cesium$
|
|
5775
|
+
const newCartesian = Cesium$b.Cartesian3.fromDegrees(newLonLat[0], newLonLat[1], 0);
|
|
5772
5776
|
|
|
5773
5777
|
// 标绘图元:拖拽控制点重新生成几何
|
|
5774
5778
|
if (this._selectedEntity._isPlotGraphic) {
|
|
@@ -5791,12 +5795,12 @@ class EditTool extends BaseTool {
|
|
|
5791
5795
|
// 扇形:拖拽圆心(索引0)时整体平移,保持两半径等长
|
|
5792
5796
|
if (plotType === PlotGraphicType.SECTOR && index === 0) {
|
|
5793
5797
|
const oldCenter = this._selectedEntity._controlPoints[0];
|
|
5794
|
-
const oldCenterCart = Cesium$
|
|
5798
|
+
const oldCenterCart = Cesium$b.Cartesian3.fromDegrees(oldCenter[0], oldCenter[1], oldCenter[2] || 0);
|
|
5795
5799
|
const clampedNewCenter = this._clampPositionToGround(newCartesian);
|
|
5796
5800
|
this._translatePlotControlPoints(clampedNewCenter, oldCenterCart);
|
|
5797
5801
|
// 中心控制点固定在圆心
|
|
5798
5802
|
this._originalEntityCenter = this._clampPositionToGround(
|
|
5799
|
-
Cesium$
|
|
5803
|
+
Cesium$b.Cartesian3.fromDegrees(
|
|
5800
5804
|
this._selectedEntity._controlPoints[0][0],
|
|
5801
5805
|
this._selectedEntity._controlPoints[0][1],
|
|
5802
5806
|
this._selectedEntity._controlPoints[0][2] || 0
|
|
@@ -5872,8 +5876,8 @@ class EditTool extends BaseTool {
|
|
|
5872
5876
|
if (match) {
|
|
5873
5877
|
const cpIndex = parseInt(match[1], 10);
|
|
5874
5878
|
const cp = controlPoints[cpIndex];
|
|
5875
|
-
handle.position = new Cesium$
|
|
5876
|
-
this._clampPositionToGround(Cesium$
|
|
5879
|
+
handle.position = new Cesium$b.ConstantPositionProperty(
|
|
5880
|
+
this._clampPositionToGround(Cesium$b.Cartesian3.fromDegrees(cp[0], cp[1], cp[2] || 0))
|
|
5877
5881
|
);
|
|
5878
5882
|
}
|
|
5879
5883
|
});
|
|
@@ -5885,11 +5889,11 @@ class EditTool extends BaseTool {
|
|
|
5885
5889
|
const newCenter = (plotType === PlotGraphicType.SECTOR || plotType === PlotGraphicType.ELLIPSE)
|
|
5886
5890
|
? controlPoints[0]
|
|
5887
5891
|
: this._getPlotControlPointsCenter(controlPoints);
|
|
5888
|
-
centerHandle.position = new Cesium$
|
|
5889
|
-
this._clampPositionToGround(Cesium$
|
|
5892
|
+
centerHandle.position = new Cesium$b.ConstantPositionProperty(
|
|
5893
|
+
this._clampPositionToGround(Cesium$b.Cartesian3.fromDegrees(newCenter[0], newCenter[1], newCenter[2] || 0))
|
|
5890
5894
|
);
|
|
5891
5895
|
this._originalEntityCenter = this._clampPositionToGround(
|
|
5892
|
-
Cesium$
|
|
5896
|
+
Cesium$b.Cartesian3.fromDegrees(newCenter[0], newCenter[1], newCenter[2] || 0)
|
|
5893
5897
|
);
|
|
5894
5898
|
}
|
|
5895
5899
|
|
|
@@ -5898,7 +5902,7 @@ class EditTool extends BaseTool {
|
|
|
5898
5902
|
return;
|
|
5899
5903
|
}
|
|
5900
5904
|
|
|
5901
|
-
const hierarchy = this._selectedEntity.polygon?.hierarchy?.getValue(Cesium$
|
|
5905
|
+
const hierarchy = this._selectedEntity.polygon?.hierarchy?.getValue(Cesium$b.JulianDate.now());
|
|
5902
5906
|
|
|
5903
5907
|
// 拖动中心控制点:平移整个图元
|
|
5904
5908
|
// 修复:统一使用 includes('center') 来判断
|
|
@@ -5912,7 +5916,7 @@ class EditTool extends BaseTool {
|
|
|
5912
5916
|
if (this._handleVertexIndices &&
|
|
5913
5917
|
Array.isArray(this._handleVertexIndices) &&
|
|
5914
5918
|
typeof this._handleVertexIndices[0] === 'number' &&
|
|
5915
|
-
Cesium$
|
|
5919
|
+
Cesium$b.defined(this._selectedEntity.polygon)) {
|
|
5916
5920
|
if (!hierarchy || !hierarchy.positions || hierarchy.positions.length < 4) return;
|
|
5917
5921
|
|
|
5918
5922
|
const draggedVertexIndex = this._handleVertexIndices[handleIndex];
|
|
@@ -5922,13 +5926,13 @@ class EditTool extends BaseTool {
|
|
|
5922
5926
|
const clampedPositions = newPositions.map(pos => this._clampPositionToGround(pos));
|
|
5923
5927
|
|
|
5924
5928
|
// 更新多边形
|
|
5925
|
-
this._selectedEntity.polygon.hierarchy = new Cesium$
|
|
5929
|
+
this._selectedEntity.polygon.hierarchy = new Cesium$b.PolygonHierarchy(clampedPositions);
|
|
5926
5930
|
|
|
5927
5931
|
// 更新所有控制点位置(使用 ConstantPositionProperty 确保正确更新)
|
|
5928
5932
|
this._editHandles.forEach((handle, i) => {
|
|
5929
5933
|
// 修复:跳过中心控制点
|
|
5930
5934
|
if (handle.id && handle.id.includes('center')) return;
|
|
5931
|
-
handle.position = new Cesium$
|
|
5935
|
+
handle.position = new Cesium$b.ConstantPositionProperty(clampedPositions[i]);
|
|
5932
5936
|
});
|
|
5933
5937
|
|
|
5934
5938
|
// 修复:顶点编辑后重新计算并更新中心控制点位置
|
|
@@ -5961,16 +5965,16 @@ class EditTool extends BaseTool {
|
|
|
5961
5965
|
// 更新多边形顶点
|
|
5962
5966
|
const positions = this._generateCirclePositions(newCenterLonLat, circleInfo.radius, 256);
|
|
5963
5967
|
const flat = positions.flatMap(c => [c[0], c[1], 0]);
|
|
5964
|
-
this._selectedEntity.polygon.hierarchy = new Cesium$
|
|
5965
|
-
Cesium$
|
|
5968
|
+
this._selectedEntity.polygon.hierarchy = new Cesium$b.PolygonHierarchy(
|
|
5969
|
+
Cesium$b.Cartesian3.fromDegreesArrayHeights(flat)
|
|
5966
5970
|
);
|
|
5967
5971
|
|
|
5968
5972
|
// 更新半径控制点位置
|
|
5969
5973
|
const radiusHandle = this._editHandles.find(h => h.id && h.id.includes('radius'));
|
|
5970
5974
|
if (radiusHandle) {
|
|
5971
5975
|
const radiusPoint = this._getPointOnCircle(newCenterLonLat, circleInfo.radius, 0);
|
|
5972
|
-
radiusHandle.position = new Cesium$
|
|
5973
|
-
Cesium$
|
|
5976
|
+
radiusHandle.position = new Cesium$b.ConstantPositionProperty(
|
|
5977
|
+
Cesium$b.Cartesian3.fromDegrees(radiusPoint[0], radiusPoint[1], 0)
|
|
5974
5978
|
);
|
|
5975
5979
|
}
|
|
5976
5980
|
|
|
@@ -5982,8 +5986,8 @@ class EditTool extends BaseTool {
|
|
|
5982
5986
|
// 更新半径控制点位置(在圆周上)
|
|
5983
5987
|
const angle = Math.atan2(newLonLat[1] - circleInfo.center[1], newLonLat[0] - circleInfo.center[0]);
|
|
5984
5988
|
const radiusPoint = this._getPointOnCircle(circleInfo.center, newRadius, angle);
|
|
5985
|
-
this._dragHandle.position = new Cesium$
|
|
5986
|
-
Cesium$
|
|
5989
|
+
this._dragHandle.position = new Cesium$b.ConstantPositionProperty(
|
|
5990
|
+
Cesium$b.Cartesian3.fromDegrees(radiusPoint[0], radiusPoint[1], 0)
|
|
5987
5991
|
);
|
|
5988
5992
|
|
|
5989
5993
|
// 更新圆的实体属性
|
|
@@ -5993,25 +5997,25 @@ class EditTool extends BaseTool {
|
|
|
5993
5997
|
// 更新多边形顶点
|
|
5994
5998
|
const positions = this._generateCirclePositions(circleInfo.center, newRadius, 256);
|
|
5995
5999
|
const flat = positions.flatMap(c => [c[0], c[1], 0]);
|
|
5996
|
-
this._selectedEntity.polygon.hierarchy = new Cesium$
|
|
5997
|
-
Cesium$
|
|
6000
|
+
this._selectedEntity.polygon.hierarchy = new Cesium$b.PolygonHierarchy(
|
|
6001
|
+
Cesium$b.Cartesian3.fromDegreesArrayHeights(flat)
|
|
5998
6002
|
);
|
|
5999
6003
|
|
|
6000
6004
|
return;
|
|
6001
6005
|
}
|
|
6002
6006
|
|
|
6003
|
-
if (Cesium$
|
|
6004
|
-
const positions = this._selectedEntity.polyline.positions.getValue(Cesium$
|
|
6007
|
+
if (Cesium$b.defined(this._selectedEntity.polyline)) {
|
|
6008
|
+
const positions = this._selectedEntity.polyline.positions.getValue(Cesium$b.JulianDate.now());
|
|
6005
6009
|
if (positions && positions[handleIndex]) {
|
|
6006
6010
|
// 直接修改数组元素触发更新
|
|
6007
6011
|
positions[handleIndex] = newCartesian;
|
|
6008
6012
|
this._selectedEntity.polyline.positions = positions;
|
|
6009
|
-
this._dragHandle.position = new Cesium$
|
|
6013
|
+
this._dragHandle.position = new Cesium$b.ConstantPositionProperty(newCartesian);
|
|
6010
6014
|
|
|
6011
6015
|
// 修复:线编辑后重新计算并更新中心控制点位置
|
|
6012
6016
|
this._updateCenterHandlePosition();
|
|
6013
6017
|
}
|
|
6014
|
-
} else if (Cesium$
|
|
6018
|
+
} else if (Cesium$b.defined(this._selectedEntity.polygon)) {
|
|
6015
6019
|
// 获取当前实际顶点数(不包含闭合点)
|
|
6016
6020
|
this._editHandles.filter(h => !h.id.includes('center')).length;
|
|
6017
6021
|
|
|
@@ -6026,7 +6030,7 @@ class EditTool extends BaseTool {
|
|
|
6026
6030
|
newPositions.push(newCartesian);
|
|
6027
6031
|
} else {
|
|
6028
6032
|
// 从控制点获取当前位置
|
|
6029
|
-
const pos = handle.position.getValue(Cesium$
|
|
6033
|
+
const pos = handle.position.getValue(Cesium$b.JulianDate.now());
|
|
6030
6034
|
// 修复:确保位置贴地
|
|
6031
6035
|
newPositions.push(this._clampPositionToGround(pos));
|
|
6032
6036
|
}
|
|
@@ -6036,47 +6040,47 @@ class EditTool extends BaseTool {
|
|
|
6036
6040
|
newPositions.push(newPositions[0].clone());
|
|
6037
6041
|
|
|
6038
6042
|
// 更新多边形
|
|
6039
|
-
this._selectedEntity.polygon.hierarchy = new Cesium$
|
|
6043
|
+
this._selectedEntity.polygon.hierarchy = new Cesium$b.PolygonHierarchy(newPositions);
|
|
6040
6044
|
|
|
6041
6045
|
// 更新控制点
|
|
6042
|
-
this._dragHandle.position = new Cesium$
|
|
6046
|
+
this._dragHandle.position = new Cesium$b.ConstantPositionProperty(newCartesian);
|
|
6043
6047
|
|
|
6044
6048
|
// 修复:多边形编辑后重新计算并更新中心控制点位置
|
|
6045
6049
|
this._updateCenterHandlePosition();
|
|
6046
6050
|
|
|
6047
6051
|
return;
|
|
6048
|
-
} else if (Cesium$
|
|
6049
|
-
this._selectedEntity.position = new Cesium$
|
|
6050
|
-
this._dragHandle.position = new Cesium$
|
|
6052
|
+
} else if (Cesium$b.defined(this._selectedEntity.position)) {
|
|
6053
|
+
this._selectedEntity.position = new Cesium$b.ConstantPositionProperty(newCartesian);
|
|
6054
|
+
this._dragHandle.position = new Cesium$b.ConstantPositionProperty(newCartesian);
|
|
6051
6055
|
}
|
|
6052
6056
|
}
|
|
6053
6057
|
|
|
6054
6058
|
_highlightEntity(entity, highlight) {
|
|
6055
6059
|
if (!entity) return;
|
|
6056
6060
|
|
|
6057
|
-
if (Cesium$
|
|
6061
|
+
if (Cesium$b.defined(entity.point)) {
|
|
6058
6062
|
if (highlight) {
|
|
6059
|
-
entity.point.outlineColor = Cesium$
|
|
6063
|
+
entity.point.outlineColor = Cesium$b.Color.CYAN;
|
|
6060
6064
|
entity.point.outlineWidth = 3;
|
|
6061
6065
|
} else {
|
|
6062
|
-
entity.point.outlineColor = Cesium$
|
|
6066
|
+
entity.point.outlineColor = Cesium$b.Color.WHITE;
|
|
6063
6067
|
entity.point.outlineWidth = 1;
|
|
6064
6068
|
}
|
|
6065
6069
|
}
|
|
6066
6070
|
|
|
6067
|
-
if (Cesium$
|
|
6071
|
+
if (Cesium$b.defined(entity.polyline)) {
|
|
6068
6072
|
if (highlight) {
|
|
6069
|
-
entity.polyline.material = Cesium$
|
|
6073
|
+
entity.polyline.material = Cesium$b.Color.CYAN;
|
|
6070
6074
|
} else {
|
|
6071
|
-
entity.polyline.material = Cesium$
|
|
6075
|
+
entity.polyline.material = Cesium$b.Color.BLUE;
|
|
6072
6076
|
}
|
|
6073
6077
|
}
|
|
6074
6078
|
|
|
6075
|
-
if (Cesium$
|
|
6079
|
+
if (Cesium$b.defined(entity.polygon)) {
|
|
6076
6080
|
if (highlight) {
|
|
6077
|
-
entity.polygon.outlineColor = Cesium$
|
|
6081
|
+
entity.polygon.outlineColor = Cesium$b.Color.CYAN;
|
|
6078
6082
|
} else {
|
|
6079
|
-
entity.polygon.outlineColor = Cesium$
|
|
6083
|
+
entity.polygon.outlineColor = Cesium$b.Color.WHITE;
|
|
6080
6084
|
}
|
|
6081
6085
|
}
|
|
6082
6086
|
}
|
|
@@ -6113,8 +6117,8 @@ class EditTool extends BaseTool {
|
|
|
6113
6117
|
// 更新多边形顶点
|
|
6114
6118
|
const positions = this._generateCirclePositions(center, radius, 256);
|
|
6115
6119
|
const flat = positions.flatMap(c => [c[0], c[1], 0]);
|
|
6116
|
-
this._selectedEntity.polygon.hierarchy = new Cesium$
|
|
6117
|
-
Cesium$
|
|
6120
|
+
this._selectedEntity.polygon.hierarchy = new Cesium$b.PolygonHierarchy(
|
|
6121
|
+
Cesium$b.Cartesian3.fromDegreesArrayHeights(flat)
|
|
6118
6122
|
);
|
|
6119
6123
|
|
|
6120
6124
|
this._createEditHandles();
|
|
@@ -6129,10 +6133,10 @@ class EditTool extends BaseTool {
|
|
|
6129
6133
|
// 拷贝一份避免直接修改原始数据
|
|
6130
6134
|
const positionsCopy = originalPositions.map(p => p.clone ? p.clone() : p);
|
|
6131
6135
|
|
|
6132
|
-
if (Cesium$
|
|
6136
|
+
if (Cesium$b.defined(this._selectedEntity.polyline)) {
|
|
6133
6137
|
this._selectedEntity.polyline.positions = positionsCopy;
|
|
6134
|
-
} else if (Cesium$
|
|
6135
|
-
this._selectedEntity.polygon.hierarchy = new Cesium$
|
|
6138
|
+
} else if (Cesium$b.defined(this._selectedEntity.polygon)) {
|
|
6139
|
+
this._selectedEntity.polygon.hierarchy = new Cesium$b.PolygonHierarchy(positionsCopy);
|
|
6136
6140
|
}
|
|
6137
6141
|
|
|
6138
6142
|
this._createEditHandles();
|
|
@@ -6155,7 +6159,7 @@ class EditTool extends BaseTool {
|
|
|
6155
6159
|
}
|
|
6156
6160
|
}
|
|
6157
6161
|
|
|
6158
|
-
const Cesium$
|
|
6162
|
+
const Cesium$a = getCesium();
|
|
6159
6163
|
|
|
6160
6164
|
/**
|
|
6161
6165
|
* 选择类型枚举
|
|
@@ -6242,7 +6246,7 @@ class SelectTool extends BaseTool {
|
|
|
6242
6246
|
|
|
6243
6247
|
const picked = this._viewer.scene.pick(screenPos);
|
|
6244
6248
|
|
|
6245
|
-
if (Cesium$
|
|
6249
|
+
if (Cesium$a.defined(picked) && Cesium$a.defined(picked.id)) {
|
|
6246
6250
|
const entityId = picked.id.id;
|
|
6247
6251
|
|
|
6248
6252
|
// 忽略临时图元
|
|
@@ -6284,9 +6288,9 @@ class SelectTool extends BaseTool {
|
|
|
6284
6288
|
|
|
6285
6289
|
_createSelectionStartMarker(pos) {
|
|
6286
6290
|
const marker = this.createTempEntity(this.generateId('sel_start'), {
|
|
6287
|
-
position: Cesium$
|
|
6291
|
+
position: Cesium$a.Cartesian3.fromDegrees(...pos),
|
|
6288
6292
|
point: {
|
|
6289
|
-
color: Cesium$
|
|
6293
|
+
color: Cesium$a.Color.GREEN,
|
|
6290
6294
|
pixelSize: 10
|
|
6291
6295
|
}
|
|
6292
6296
|
});
|
|
@@ -6311,27 +6315,27 @@ class SelectTool extends BaseTool {
|
|
|
6311
6315
|
if (!this._selectionRect) {
|
|
6312
6316
|
this._selectionRect = this.createTempEntity(this.generateId('sel_rect'), {
|
|
6313
6317
|
polyline: {
|
|
6314
|
-
positions: new Cesium$
|
|
6318
|
+
positions: new Cesium$a.CallbackProperty(() => {
|
|
6315
6319
|
const c1 = this._startPos;
|
|
6316
6320
|
const c2 = this._currentEndPos;
|
|
6317
6321
|
if (!c1 || !c2) return [];
|
|
6318
6322
|
const pos = this._getRectPositions(c1, c2);
|
|
6319
|
-
return Cesium$
|
|
6323
|
+
return Cesium$a.Cartesian3.fromDegreesArrayHeights(pos.flatMap(c => [c[0], c[1], 0]));
|
|
6320
6324
|
}, false),
|
|
6321
|
-
material: Cesium$
|
|
6325
|
+
material: Cesium$a.Color.CYAN,
|
|
6322
6326
|
width: 2
|
|
6323
6327
|
},
|
|
6324
6328
|
polygon: {
|
|
6325
|
-
hierarchy: new Cesium$
|
|
6329
|
+
hierarchy: new Cesium$a.CallbackProperty(() => {
|
|
6326
6330
|
const c1 = this._startPos;
|
|
6327
6331
|
const c2 = this._currentEndPos;
|
|
6328
|
-
if (!c1 || !c2) return new Cesium$
|
|
6332
|
+
if (!c1 || !c2) return new Cesium$a.PolygonHierarchy([]);
|
|
6329
6333
|
const pos = this._getRectPositions(c1, c2);
|
|
6330
|
-
return new Cesium$
|
|
6331
|
-
Cesium$
|
|
6334
|
+
return new Cesium$a.PolygonHierarchy(
|
|
6335
|
+
Cesium$a.Cartesian3.fromDegreesArrayHeights(pos.flatMap(c => [c[0], c[1], 0]))
|
|
6332
6336
|
);
|
|
6333
6337
|
}, false),
|
|
6334
|
-
material: Cesium$
|
|
6338
|
+
material: Cesium$a.Color.CYAN.withAlpha(0.2),
|
|
6335
6339
|
outline: false
|
|
6336
6340
|
}
|
|
6337
6341
|
});
|
|
@@ -6348,21 +6352,21 @@ class SelectTool extends BaseTool {
|
|
|
6348
6352
|
if (!this._selectionRect) {
|
|
6349
6353
|
this._selectionRect = this.createTempEntity(this.generateId('sel_circle'), {
|
|
6350
6354
|
polygon: {
|
|
6351
|
-
hierarchy: new Cesium$
|
|
6355
|
+
hierarchy: new Cesium$a.CallbackProperty(() => {
|
|
6352
6356
|
const c = this._startPos;
|
|
6353
6357
|
const edge = this._currentEndPos;
|
|
6354
|
-
if (!c || !edge) return new Cesium$
|
|
6358
|
+
if (!c || !edge) return new Cesium$a.PolygonHierarchy([]);
|
|
6355
6359
|
const radius = this._calcDistance(c, edge);
|
|
6356
6360
|
const positions = this._generateCirclePositions(c, radius, 36);
|
|
6357
|
-
return new Cesium$
|
|
6358
|
-
Cesium$
|
|
6361
|
+
return new Cesium$a.PolygonHierarchy(
|
|
6362
|
+
Cesium$a.Cartesian3.fromDegreesArrayHeights(
|
|
6359
6363
|
positions.flatMap(c => [c[0], c[1], 0])
|
|
6360
6364
|
)
|
|
6361
6365
|
);
|
|
6362
6366
|
}, false),
|
|
6363
|
-
material: Cesium$
|
|
6367
|
+
material: Cesium$a.Color.CYAN.withAlpha(0.2),
|
|
6364
6368
|
outline: true,
|
|
6365
|
-
outlineColor: Cesium$
|
|
6369
|
+
outlineColor: Cesium$a.Color.CYAN
|
|
6366
6370
|
}
|
|
6367
6371
|
});
|
|
6368
6372
|
this._selectionRect._isPreview = true;
|
|
@@ -6451,7 +6455,7 @@ class SelectTool extends BaseTool {
|
|
|
6451
6455
|
|
|
6452
6456
|
const styleKey = entityId;
|
|
6453
6457
|
|
|
6454
|
-
if (Cesium$
|
|
6458
|
+
if (Cesium$a.defined(entity.point)) {
|
|
6455
6459
|
if (highlight) {
|
|
6456
6460
|
if (!this._originalStyles.has(styleKey)) {
|
|
6457
6461
|
this._originalStyles.set(styleKey, {
|
|
@@ -6461,7 +6465,7 @@ class SelectTool extends BaseTool {
|
|
|
6461
6465
|
}
|
|
6462
6466
|
});
|
|
6463
6467
|
}
|
|
6464
|
-
entity.point.outlineColor = Cesium$
|
|
6468
|
+
entity.point.outlineColor = Cesium$a.Color.YELLOW;
|
|
6465
6469
|
entity.point.outlineWidth = 2;
|
|
6466
6470
|
} else {
|
|
6467
6471
|
const original = this._originalStyles.get(styleKey)?.point;
|
|
@@ -6469,13 +6473,13 @@ class SelectTool extends BaseTool {
|
|
|
6469
6473
|
entity.point.outlineColor = original.outlineColor;
|
|
6470
6474
|
entity.point.outlineWidth = original.outlineWidth;
|
|
6471
6475
|
} else {
|
|
6472
|
-
entity.point.outlineColor = Cesium$
|
|
6476
|
+
entity.point.outlineColor = Cesium$a.Color.WHITE;
|
|
6473
6477
|
entity.point.outlineWidth = 1;
|
|
6474
6478
|
}
|
|
6475
6479
|
}
|
|
6476
6480
|
}
|
|
6477
6481
|
|
|
6478
|
-
if (Cesium$
|
|
6482
|
+
if (Cesium$a.defined(entity.polyline)) {
|
|
6479
6483
|
if (highlight) {
|
|
6480
6484
|
if (!this._originalStyles.has(styleKey)) {
|
|
6481
6485
|
this._originalStyles.set(styleKey, {
|
|
@@ -6484,14 +6488,14 @@ class SelectTool extends BaseTool {
|
|
|
6484
6488
|
}
|
|
6485
6489
|
});
|
|
6486
6490
|
}
|
|
6487
|
-
entity.polyline.material = Cesium$
|
|
6491
|
+
entity.polyline.material = Cesium$a.Color.CYAN;
|
|
6488
6492
|
} else {
|
|
6489
6493
|
const original = this._originalStyles.get(styleKey)?.polyline;
|
|
6490
|
-
entity.polyline.material = original?.material || Cesium$
|
|
6494
|
+
entity.polyline.material = original?.material || Cesium$a.Color.BLUE;
|
|
6491
6495
|
}
|
|
6492
6496
|
}
|
|
6493
6497
|
|
|
6494
|
-
if (Cesium$
|
|
6498
|
+
if (Cesium$a.defined(entity.polygon)) {
|
|
6495
6499
|
if (highlight) {
|
|
6496
6500
|
if (!this._originalStyles.has(styleKey)) {
|
|
6497
6501
|
this._originalStyles.set(styleKey, {
|
|
@@ -6500,10 +6504,10 @@ class SelectTool extends BaseTool {
|
|
|
6500
6504
|
}
|
|
6501
6505
|
});
|
|
6502
6506
|
}
|
|
6503
|
-
entity.polygon.outlineColor = Cesium$
|
|
6507
|
+
entity.polygon.outlineColor = Cesium$a.Color.CYAN;
|
|
6504
6508
|
} else {
|
|
6505
6509
|
const original = this._originalStyles.get(styleKey)?.polygon;
|
|
6506
|
-
entity.polygon.outlineColor = original?.outlineColor || Cesium$
|
|
6510
|
+
entity.polygon.outlineColor = original?.outlineColor || Cesium$a.Color.WHITE;
|
|
6507
6511
|
}
|
|
6508
6512
|
}
|
|
6509
6513
|
|
|
@@ -6590,9 +6594,9 @@ class SelectTool extends BaseTool {
|
|
|
6590
6594
|
// 检查是否所有点都在范围内
|
|
6591
6595
|
let allInBounds = true;
|
|
6592
6596
|
for (const pos of positions) {
|
|
6593
|
-
const c = Cesium$
|
|
6594
|
-
const lon = Cesium$
|
|
6595
|
-
const lat = Cesium$
|
|
6597
|
+
const c = Cesium$a.Cartographic.fromCartesian(pos);
|
|
6598
|
+
const lon = Cesium$a.Math.toDegrees(c.longitude);
|
|
6599
|
+
const lat = Cesium$a.Math.toDegrees(c.latitude);
|
|
6596
6600
|
|
|
6597
6601
|
if (lon < minLon || lon > maxLon || lat < minLat || lat > maxLat) {
|
|
6598
6602
|
allInBounds = false;
|
|
@@ -6609,13 +6613,13 @@ class SelectTool extends BaseTool {
|
|
|
6609
6613
|
}
|
|
6610
6614
|
|
|
6611
6615
|
_getEntityPosition(entity) {
|
|
6612
|
-
if (Cesium$
|
|
6613
|
-
const pos = entity.position.getValue(Cesium$
|
|
6616
|
+
if (Cesium$a.defined(entity.position)) {
|
|
6617
|
+
const pos = entity.position.getValue(Cesium$a.JulianDate.now());
|
|
6614
6618
|
if (pos) {
|
|
6615
|
-
const c = Cesium$
|
|
6619
|
+
const c = Cesium$a.Cartographic.fromCartesian(pos);
|
|
6616
6620
|
return [
|
|
6617
|
-
Cesium$
|
|
6618
|
-
Cesium$
|
|
6621
|
+
Cesium$a.Math.toDegrees(c.longitude),
|
|
6622
|
+
Cesium$a.Math.toDegrees(c.latitude)
|
|
6619
6623
|
];
|
|
6620
6624
|
}
|
|
6621
6625
|
}
|
|
@@ -6623,11 +6627,11 @@ class SelectTool extends BaseTool {
|
|
|
6623
6627
|
}
|
|
6624
6628
|
|
|
6625
6629
|
_getEntityPositions(entity) {
|
|
6626
|
-
if (Cesium$
|
|
6627
|
-
return entity.polyline.positions.getValue(Cesium$
|
|
6630
|
+
if (Cesium$a.defined(entity.polyline) && Cesium$a.defined(entity.polyline.positions)) {
|
|
6631
|
+
return entity.polyline.positions.getValue(Cesium$a.JulianDate.now());
|
|
6628
6632
|
}
|
|
6629
|
-
if (Cesium$
|
|
6630
|
-
const hierarchy = entity.polygon.hierarchy.getValue(Cesium$
|
|
6633
|
+
if (Cesium$a.defined(entity.polygon) && Cesium$a.defined(entity.polygon.hierarchy)) {
|
|
6634
|
+
const hierarchy = entity.polygon.hierarchy.getValue(Cesium$a.JulianDate.now());
|
|
6631
6635
|
return hierarchy ? hierarchy.positions : [];
|
|
6632
6636
|
}
|
|
6633
6637
|
return [];
|
|
@@ -6692,7 +6696,7 @@ class SelectTool extends BaseTool {
|
|
|
6692
6696
|
}
|
|
6693
6697
|
}
|
|
6694
6698
|
|
|
6695
|
-
const Cesium$
|
|
6699
|
+
const Cesium$9 = getCesium();
|
|
6696
6700
|
|
|
6697
6701
|
/**
|
|
6698
6702
|
* 删除模式枚举
|
|
@@ -6743,7 +6747,7 @@ class DeleteTool extends BaseTool {
|
|
|
6743
6747
|
|
|
6744
6748
|
const picked = this._viewer.scene.pick(screenPos);
|
|
6745
6749
|
|
|
6746
|
-
if (Cesium$
|
|
6750
|
+
if (Cesium$9.defined(picked) && Cesium$9.defined(picked.id)) {
|
|
6747
6751
|
const entityId = picked.id.id;
|
|
6748
6752
|
|
|
6749
6753
|
// 忽略临时图元
|
|
@@ -6767,7 +6771,7 @@ class DeleteTool extends BaseTool {
|
|
|
6767
6771
|
|
|
6768
6772
|
let hoveredId = null;
|
|
6769
6773
|
|
|
6770
|
-
if (Cesium$
|
|
6774
|
+
if (Cesium$9.defined(picked) && Cesium$9.defined(picked.id)) {
|
|
6771
6775
|
const entityId = picked.id.id;
|
|
6772
6776
|
if (!entityId.startsWith('__temp_') && !entityId.startsWith('__edit_handle_')) {
|
|
6773
6777
|
hoveredId = entityId;
|
|
@@ -6847,7 +6851,7 @@ class DeleteTool extends BaseTool {
|
|
|
6847
6851
|
const styleKey = entityId;
|
|
6848
6852
|
|
|
6849
6853
|
// 红色高亮表示可删除,先保存原始样式
|
|
6850
|
-
if (Cesium$
|
|
6854
|
+
if (Cesium$9.defined(entity.point)) {
|
|
6851
6855
|
if (!this._originalStyles.has(styleKey)) {
|
|
6852
6856
|
this._originalStyles.set(styleKey, {
|
|
6853
6857
|
point: {
|
|
@@ -6856,11 +6860,11 @@ class DeleteTool extends BaseTool {
|
|
|
6856
6860
|
}
|
|
6857
6861
|
});
|
|
6858
6862
|
}
|
|
6859
|
-
entity.point.outlineColor = Cesium$
|
|
6863
|
+
entity.point.outlineColor = Cesium$9.Color.RED;
|
|
6860
6864
|
entity.point.outlineWidth = 3;
|
|
6861
6865
|
}
|
|
6862
6866
|
|
|
6863
|
-
if (Cesium$
|
|
6867
|
+
if (Cesium$9.defined(entity.polyline)) {
|
|
6864
6868
|
if (!this._originalStyles.has(styleKey)) {
|
|
6865
6869
|
this._originalStyles.set(styleKey, {
|
|
6866
6870
|
polyline: {
|
|
@@ -6868,10 +6872,10 @@ class DeleteTool extends BaseTool {
|
|
|
6868
6872
|
}
|
|
6869
6873
|
});
|
|
6870
6874
|
}
|
|
6871
|
-
entity.polyline.material = Cesium$
|
|
6875
|
+
entity.polyline.material = Cesium$9.Color.RED;
|
|
6872
6876
|
}
|
|
6873
6877
|
|
|
6874
|
-
if (Cesium$
|
|
6878
|
+
if (Cesium$9.defined(entity.polygon)) {
|
|
6875
6879
|
if (!this._originalStyles.has(styleKey)) {
|
|
6876
6880
|
this._originalStyles.set(styleKey, {
|
|
6877
6881
|
polygon: {
|
|
@@ -6879,7 +6883,7 @@ class DeleteTool extends BaseTool {
|
|
|
6879
6883
|
}
|
|
6880
6884
|
});
|
|
6881
6885
|
}
|
|
6882
|
-
entity.polygon.outlineColor = Cesium$
|
|
6886
|
+
entity.polygon.outlineColor = Cesium$9.Color.RED;
|
|
6883
6887
|
}
|
|
6884
6888
|
|
|
6885
6889
|
// 更改鼠标样式
|
|
@@ -6896,22 +6900,22 @@ class DeleteTool extends BaseTool {
|
|
|
6896
6900
|
const original = styleKey ? this._originalStyles.get(styleKey) : null;
|
|
6897
6901
|
|
|
6898
6902
|
// 恢复原始样式
|
|
6899
|
-
if (Cesium$
|
|
6903
|
+
if (Cesium$9.defined(entity.point)) {
|
|
6900
6904
|
if (original?.point) {
|
|
6901
6905
|
entity.point.outlineColor = original.point.outlineColor;
|
|
6902
6906
|
entity.point.outlineWidth = original.point.outlineWidth;
|
|
6903
6907
|
} else {
|
|
6904
|
-
entity.point.outlineColor = Cesium$
|
|
6908
|
+
entity.point.outlineColor = Cesium$9.Color.WHITE;
|
|
6905
6909
|
entity.point.outlineWidth = 1;
|
|
6906
6910
|
}
|
|
6907
6911
|
}
|
|
6908
6912
|
|
|
6909
|
-
if (Cesium$
|
|
6910
|
-
entity.polyline.material = original?.polyline?.material || Cesium$
|
|
6913
|
+
if (Cesium$9.defined(entity.polyline)) {
|
|
6914
|
+
entity.polyline.material = original?.polyline?.material || Cesium$9.Color.BLUE;
|
|
6911
6915
|
}
|
|
6912
6916
|
|
|
6913
|
-
if (Cesium$
|
|
6914
|
-
entity.polygon.outlineColor = original?.polygon?.outlineColor || Cesium$
|
|
6917
|
+
if (Cesium$9.defined(entity.polygon)) {
|
|
6918
|
+
entity.polygon.outlineColor = original?.polygon?.outlineColor || Cesium$9.Color.WHITE;
|
|
6915
6919
|
}
|
|
6916
6920
|
|
|
6917
6921
|
// 恢复鼠标样式
|
|
@@ -6945,7 +6949,7 @@ class DeleteTool extends BaseTool {
|
|
|
6945
6949
|
}
|
|
6946
6950
|
}
|
|
6947
6951
|
|
|
6948
|
-
const Cesium$
|
|
6952
|
+
const Cesium$8 = getCesium();
|
|
6949
6953
|
|
|
6950
6954
|
/**
|
|
6951
6955
|
* 地理计算工具(距离、面积、高程)
|
|
@@ -6958,9 +6962,9 @@ class GeoCalcUtil {
|
|
|
6958
6962
|
* @returns {number} 距离
|
|
6959
6963
|
*/
|
|
6960
6964
|
static calcDistance(point1, point2) {
|
|
6961
|
-
const coord1 = Cesium$
|
|
6962
|
-
const coord2 = Cesium$
|
|
6963
|
-
return Cesium$
|
|
6965
|
+
const coord1 = Cesium$8.Cartesian3.fromDegrees(...point1);
|
|
6966
|
+
const coord2 = Cesium$8.Cartesian3.fromDegrees(...point2);
|
|
6967
|
+
return Cesium$8.Cartesian3.distance(coord1, coord2);
|
|
6964
6968
|
}
|
|
6965
6969
|
|
|
6966
6970
|
/**
|
|
@@ -6972,11 +6976,11 @@ class GeoCalcUtil {
|
|
|
6972
6976
|
static calcArea(points) {
|
|
6973
6977
|
if (!points || points.length < 3) return 0;
|
|
6974
6978
|
|
|
6975
|
-
const positions = points.map(p => Cesium$
|
|
6976
|
-
const polygon = new Cesium$
|
|
6977
|
-
polygonHierarchy: new Cesium$
|
|
6979
|
+
const positions = points.map(p => Cesium$8.Cartesian3.fromDegrees(p[0], p[1], p[2] || 0));
|
|
6980
|
+
const polygon = new Cesium$8.PolygonGeometry({
|
|
6981
|
+
polygonHierarchy: new Cesium$8.PolygonHierarchy(positions)
|
|
6978
6982
|
});
|
|
6979
|
-
const geometry = Cesium$
|
|
6983
|
+
const geometry = Cesium$8.PolygonGeometry.createGeometry(polygon);
|
|
6980
6984
|
|
|
6981
6985
|
if (!geometry || !geometry.attributes || !geometry.attributes.position) {
|
|
6982
6986
|
return 0;
|
|
@@ -6985,7 +6989,7 @@ class GeoCalcUtil {
|
|
|
6985
6989
|
const values = geometry.attributes.position.values;
|
|
6986
6990
|
const vertexPositions = [];
|
|
6987
6991
|
for (let i = 0; i < values.length; i += 3) {
|
|
6988
|
-
vertexPositions.push(new Cesium$
|
|
6992
|
+
vertexPositions.push(new Cesium$8.Cartesian3(values[i], values[i + 1], values[i + 2]));
|
|
6989
6993
|
}
|
|
6990
6994
|
|
|
6991
6995
|
// 球面多边形面积(基于单位球上的多边形面积公式)
|
|
@@ -7001,23 +7005,23 @@ class GeoCalcUtil {
|
|
|
7001
7005
|
* @returns {number} 面积(平方米)
|
|
7002
7006
|
*/
|
|
7003
7007
|
static #sphericalPolygonArea(positions) {
|
|
7004
|
-
const ellipsoid = Cesium$
|
|
7008
|
+
const ellipsoid = Cesium$8.Ellipsoid.WGS84;
|
|
7005
7009
|
const n = positions.length;
|
|
7006
7010
|
if (n < 3) return 0;
|
|
7007
7011
|
|
|
7008
7012
|
// 计算近似重心(归一化到椭球面)
|
|
7009
|
-
let center = new Cesium$
|
|
7013
|
+
let center = new Cesium$8.Cartesian3(0, 0, 0);
|
|
7010
7014
|
for (const p of positions) {
|
|
7011
|
-
center = Cesium$
|
|
7015
|
+
center = Cesium$8.Cartesian3.add(center, p, center);
|
|
7012
7016
|
}
|
|
7013
|
-
center = Cesium$
|
|
7014
|
-
center = ellipsoid.scaleToGeodeticSurface(center, new Cesium$
|
|
7017
|
+
center = Cesium$8.Cartesian3.normalize(center, new Cesium$8.Cartesian3());
|
|
7018
|
+
center = ellipsoid.scaleToGeodeticSurface(center, new Cesium$8.Cartesian3()) || center;
|
|
7015
7019
|
|
|
7016
7020
|
// 在重心处建立东北天(ENU)局部坐标系
|
|
7017
|
-
const tangentPlane = new Cesium$
|
|
7021
|
+
const tangentPlane = new Cesium$8.EllipsoidTangentPlane(center, ellipsoid);
|
|
7018
7022
|
|
|
7019
7023
|
// 投影到切平面
|
|
7020
|
-
const projected = positions.map(p => tangentPlane.projectPointOntoPlane(p, new Cesium$
|
|
7024
|
+
const projected = positions.map(p => tangentPlane.projectPointOntoPlane(p, new Cesium$8.Cartesian2()));
|
|
7021
7025
|
|
|
7022
7026
|
// 计算二维多边形面积(Shoelace 公式)
|
|
7023
7027
|
let area2 = 0;
|
|
@@ -7037,13 +7041,13 @@ class GeoCalcUtil {
|
|
|
7037
7041
|
* @returns {Promise<number>} 高程值
|
|
7038
7042
|
*/
|
|
7039
7043
|
static async getHeight(viewer, coord) {
|
|
7040
|
-
const cartographic = Cesium$
|
|
7041
|
-
const results = await Cesium$
|
|
7044
|
+
const cartographic = Cesium$8.Cartographic.fromDegrees(coord[0], coord[1]);
|
|
7045
|
+
const results = await Cesium$8.sampleTerrainMostDetailed(viewer.terrainProvider, [cartographic]);
|
|
7042
7046
|
return results[0]?.height ?? 0;
|
|
7043
7047
|
}
|
|
7044
7048
|
}
|
|
7045
7049
|
|
|
7046
|
-
const Cesium$
|
|
7050
|
+
const Cesium$7 = getCesium();
|
|
7047
7051
|
|
|
7048
7052
|
/**
|
|
7049
7053
|
* 测量类型枚举
|
|
@@ -7194,8 +7198,8 @@ class MeasureTool extends BaseTool {
|
|
|
7194
7198
|
}
|
|
7195
7199
|
if (this._previewPolygon) {
|
|
7196
7200
|
this._previewPolygon.polygon.hierarchy = finalCartesians.length >= 3
|
|
7197
|
-
? new Cesium$
|
|
7198
|
-
: new Cesium$
|
|
7201
|
+
? new Cesium$7.PolygonHierarchy(finalCartesians)
|
|
7202
|
+
: new Cesium$7.PolygonHierarchy([]);
|
|
7199
7203
|
}
|
|
7200
7204
|
if (this._previewOutline) {
|
|
7201
7205
|
this._previewOutline.polyline.positions = finalCartesians.length >= 3
|
|
@@ -7304,7 +7308,7 @@ class MeasureTool extends BaseTool {
|
|
|
7304
7308
|
|
|
7305
7309
|
_updateDistancePreview(positions) {
|
|
7306
7310
|
const cartesians = positions.length >= 2
|
|
7307
|
-
? positions.map(p => Cesium$
|
|
7311
|
+
? positions.map(p => Cesium$7.Cartesian3.fromDegrees(...p))
|
|
7308
7312
|
: [];
|
|
7309
7313
|
this._previewCartesians = cartesians;
|
|
7310
7314
|
|
|
@@ -7312,8 +7316,8 @@ class MeasureTool extends BaseTool {
|
|
|
7312
7316
|
if (!this._previewLine) {
|
|
7313
7317
|
this._previewLine = this.createTempEntity(this.generateId('measure_line'), {
|
|
7314
7318
|
polyline: {
|
|
7315
|
-
positions: new Cesium$
|
|
7316
|
-
material: Cesium$
|
|
7319
|
+
positions: new Cesium$7.CallbackProperty(() => this._previewCartesians, false),
|
|
7320
|
+
material: Cesium$7.Color.YELLOW,
|
|
7317
7321
|
width: 2,
|
|
7318
7322
|
clampToGround: true
|
|
7319
7323
|
}
|
|
@@ -7332,10 +7336,10 @@ class MeasureTool extends BaseTool {
|
|
|
7332
7336
|
const dist = GeoCalcUtil.calcDistance(p1, p2);
|
|
7333
7337
|
total += dist;
|
|
7334
7338
|
|
|
7335
|
-
const mid = Cesium$
|
|
7336
|
-
Cesium$
|
|
7337
|
-
Cesium$
|
|
7338
|
-
new Cesium$
|
|
7339
|
+
const mid = Cesium$7.Cartesian3.midpoint(
|
|
7340
|
+
Cesium$7.Cartesian3.fromDegrees(...p1),
|
|
7341
|
+
Cesium$7.Cartesian3.fromDegrees(...p2),
|
|
7342
|
+
new Cesium$7.Cartesian3()
|
|
7339
7343
|
);
|
|
7340
7344
|
|
|
7341
7345
|
const label = this._segmentLabelEntities[i];
|
|
@@ -7364,7 +7368,7 @@ class MeasureTool extends BaseTool {
|
|
|
7364
7368
|
}
|
|
7365
7369
|
|
|
7366
7370
|
_updateAreaPreview(positions) {
|
|
7367
|
-
const cartesians = positions.map(p => Cesium$
|
|
7371
|
+
const cartesians = positions.map(p => Cesium$7.Cartesian3.fromDegrees(...p));
|
|
7368
7372
|
this._previewCartesians = cartesians;
|
|
7369
7373
|
|
|
7370
7374
|
if (positions.length >= 3) {
|
|
@@ -7372,17 +7376,17 @@ class MeasureTool extends BaseTool {
|
|
|
7372
7376
|
if (!this._previewPolygon) {
|
|
7373
7377
|
this._previewPolygon = this.createTempEntity(this.generateId('measure_polygon'), {
|
|
7374
7378
|
polygon: {
|
|
7375
|
-
hierarchy: new Cesium$
|
|
7376
|
-
material: Cesium$
|
|
7379
|
+
hierarchy: new Cesium$7.CallbackProperty(() => new Cesium$7.PolygonHierarchy(this._previewCartesians), false),
|
|
7380
|
+
material: Cesium$7.Color.YELLOW.withAlpha(0.2),
|
|
7377
7381
|
outline: false
|
|
7378
7382
|
}
|
|
7379
7383
|
});
|
|
7380
7384
|
this._previewOutline = this.createTempEntity(this.generateId('measure_outline'), {
|
|
7381
7385
|
polyline: {
|
|
7382
|
-
positions: new Cesium$
|
|
7386
|
+
positions: new Cesium$7.CallbackProperty(() => this._previewCartesians.length > 0
|
|
7383
7387
|
? [...this._previewCartesians, this._previewCartesians[0]]
|
|
7384
7388
|
: [], false),
|
|
7385
|
-
material: Cesium$
|
|
7389
|
+
material: Cesium$7.Color.YELLOW,
|
|
7386
7390
|
width: 2,
|
|
7387
7391
|
clampToGround: true
|
|
7388
7392
|
}
|
|
@@ -7423,8 +7427,8 @@ class MeasureTool extends BaseTool {
|
|
|
7423
7427
|
if (!this._previewLine) {
|
|
7424
7428
|
this._previewLine = this.createTempEntity(this.generateId('measure_line'), {
|
|
7425
7429
|
polyline: {
|
|
7426
|
-
positions: new Cesium$
|
|
7427
|
-
material: Cesium$
|
|
7430
|
+
positions: new Cesium$7.CallbackProperty(() => this._previewCartesians, false),
|
|
7431
|
+
material: Cesium$7.Color.YELLOW,
|
|
7428
7432
|
width: 2,
|
|
7429
7433
|
clampToGround: true
|
|
7430
7434
|
}
|
|
@@ -7445,7 +7449,7 @@ class MeasureTool extends BaseTool {
|
|
|
7445
7449
|
while (this._segmentLabelEntities.length < count) {
|
|
7446
7450
|
const label = this._createLabelEntity(
|
|
7447
7451
|
this.generateId('measure_segment'),
|
|
7448
|
-
Cesium$
|
|
7452
|
+
Cesium$7.Cartesian3.ZERO,
|
|
7449
7453
|
''
|
|
7450
7454
|
);
|
|
7451
7455
|
this._segmentLabelEntities.push(label);
|
|
@@ -7458,28 +7462,28 @@ class MeasureTool extends BaseTool {
|
|
|
7458
7462
|
label: {
|
|
7459
7463
|
text,
|
|
7460
7464
|
font: '14px Microsoft YaHei',
|
|
7461
|
-
fillColor: Cesium$
|
|
7462
|
-
outlineColor: Cesium$
|
|
7465
|
+
fillColor: Cesium$7.Color.WHITE,
|
|
7466
|
+
outlineColor: Cesium$7.Color.BLACK,
|
|
7463
7467
|
outlineWidth: 2,
|
|
7464
|
-
style: Cesium$
|
|
7465
|
-
verticalOrigin: Cesium$
|
|
7466
|
-
horizontalOrigin: Cesium$
|
|
7467
|
-
heightReference: Cesium$
|
|
7468
|
+
style: Cesium$7.LabelStyle.FILL_AND_OUTLINE,
|
|
7469
|
+
verticalOrigin: Cesium$7.VerticalOrigin.BOTTOM,
|
|
7470
|
+
horizontalOrigin: Cesium$7.HorizontalOrigin.CENTER,
|
|
7471
|
+
heightReference: Cesium$7.HeightReference.CLAMP_TO_GROUND,
|
|
7468
7472
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
7469
|
-
pixelOffset: new Cesium$
|
|
7473
|
+
pixelOffset: new Cesium$7.Cartesian2(0, -10)
|
|
7470
7474
|
}
|
|
7471
7475
|
});
|
|
7472
7476
|
}
|
|
7473
7477
|
|
|
7474
7478
|
_addPointMarker(lonLat) {
|
|
7475
7479
|
const point = this.createTempEntity(this.generateId('measure_point'), {
|
|
7476
|
-
position: Cesium$
|
|
7480
|
+
position: Cesium$7.Cartesian3.fromDegrees(...lonLat),
|
|
7477
7481
|
point: {
|
|
7478
|
-
color: Cesium$
|
|
7482
|
+
color: Cesium$7.Color.YELLOW,
|
|
7479
7483
|
pixelSize: 8,
|
|
7480
|
-
outlineColor: Cesium$
|
|
7484
|
+
outlineColor: Cesium$7.Color.BLACK,
|
|
7481
7485
|
outlineWidth: 1,
|
|
7482
|
-
heightReference: Cesium$
|
|
7486
|
+
heightReference: Cesium$7.HeightReference.CLAMP_TO_GROUND,
|
|
7483
7487
|
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
7484
7488
|
}
|
|
7485
7489
|
});
|
|
@@ -7514,11 +7518,11 @@ class MeasureTool extends BaseTool {
|
|
|
7514
7518
|
}
|
|
7515
7519
|
|
|
7516
7520
|
_computeCentroid(cartesians) {
|
|
7517
|
-
const center = new Cesium$
|
|
7521
|
+
const center = new Cesium$7.Cartesian3(0, 0, 0);
|
|
7518
7522
|
for (const c of cartesians) {
|
|
7519
|
-
Cesium$
|
|
7523
|
+
Cesium$7.Cartesian3.add(center, c, center);
|
|
7520
7524
|
}
|
|
7521
|
-
return Cesium$
|
|
7525
|
+
return Cesium$7.Cartesian3.multiplyByScalar(center, 1 / cartesians.length, center);
|
|
7522
7526
|
}
|
|
7523
7527
|
|
|
7524
7528
|
_formatDistance(meters) {
|
|
@@ -8240,7 +8244,7 @@ class BaseControl {
|
|
|
8240
8244
|
_destroy() { }
|
|
8241
8245
|
}
|
|
8242
8246
|
|
|
8243
|
-
const Cesium$
|
|
8247
|
+
const Cesium$6 = getCesium();
|
|
8244
8248
|
|
|
8245
8249
|
/**
|
|
8246
8250
|
* 状态栏控件
|
|
@@ -8320,7 +8324,7 @@ class LocationBar extends BaseControl {
|
|
|
8320
8324
|
const rect = this._viewer.scene.canvas.getBoundingClientRect();
|
|
8321
8325
|
const x = e.clientX - rect.left;
|
|
8322
8326
|
const y = e.clientY - rect.top;
|
|
8323
|
-
const screenPos = new Cesium$
|
|
8327
|
+
const screenPos = new Cesium$6.Cartesian2(x, y);
|
|
8324
8328
|
|
|
8325
8329
|
let cartesian = null;
|
|
8326
8330
|
|
|
@@ -8336,10 +8340,10 @@ class LocationBar extends BaseControl {
|
|
|
8336
8340
|
}
|
|
8337
8341
|
|
|
8338
8342
|
if (cartesian) {
|
|
8339
|
-
const cartographic = Cesium$
|
|
8343
|
+
const cartographic = Cesium$6.Cartographic.fromCartesian(cartesian);
|
|
8340
8344
|
this._lastMouseData = {
|
|
8341
|
-
lng: Cesium$
|
|
8342
|
-
lat: Cesium$
|
|
8345
|
+
lng: Cesium$6.Math.toDegrees(cartographic.longitude).toFixed(this._lngDecimal),
|
|
8346
|
+
lat: Cesium$6.Math.toDegrees(cartographic.latitude).toFixed(this._latDecimal),
|
|
8343
8347
|
alt: cartographic.height.toFixed(2)
|
|
8344
8348
|
};
|
|
8345
8349
|
} else {
|
|
@@ -8359,8 +8363,8 @@ class LocationBar extends BaseControl {
|
|
|
8359
8363
|
const positionCartographic = camera.positionCartographic;
|
|
8360
8364
|
|
|
8361
8365
|
this._lastCameraData = {
|
|
8362
|
-
heading: Cesium$
|
|
8363
|
-
pitch: Cesium$
|
|
8366
|
+
heading: Cesium$6.Math.toDegrees(camera.heading).toFixed(2),
|
|
8367
|
+
pitch: Cesium$6.Math.toDegrees(camera.pitch).toFixed(2),
|
|
8364
8368
|
cameraHeight: positionCartographic.height.toFixed(2),
|
|
8365
8369
|
level: this._getZoomLevel().toFixed(0)
|
|
8366
8370
|
};
|
|
@@ -8386,12 +8390,12 @@ class LocationBar extends BaseControl {
|
|
|
8386
8390
|
const positionCartographic = camera.positionCartographic;
|
|
8387
8391
|
|
|
8388
8392
|
// 计算相机到正下方地表点的距离(视高),而不是到自己位置的距离
|
|
8389
|
-
const surfaceCartesian = Cesium$
|
|
8393
|
+
const surfaceCartesian = Cesium$6.Cartesian3.fromRadians(
|
|
8390
8394
|
positionCartographic.longitude,
|
|
8391
8395
|
positionCartographic.latitude,
|
|
8392
8396
|
0
|
|
8393
8397
|
);
|
|
8394
|
-
const distance = Cesium$
|
|
8398
|
+
const distance = Cesium$6.Cartesian3.distance(camera.position, surfaceCartesian);
|
|
8395
8399
|
|
|
8396
8400
|
if (!distance || distance <= 0 || !Number.isFinite(distance)) return 0;
|
|
8397
8401
|
|
|
@@ -8423,7 +8427,7 @@ class LocationBar extends BaseControl {
|
|
|
8423
8427
|
}
|
|
8424
8428
|
}
|
|
8425
8429
|
|
|
8426
|
-
const Cesium$
|
|
8430
|
+
const Cesium$5 = getCesium();
|
|
8427
8431
|
|
|
8428
8432
|
/**
|
|
8429
8433
|
* 缩放控件
|
|
@@ -8523,7 +8527,7 @@ class Zoom extends BaseControl {
|
|
|
8523
8527
|
const targetHeight = this._getHeightByZoomLevel(targetLevel);
|
|
8524
8528
|
|
|
8525
8529
|
camera.flyTo({
|
|
8526
|
-
destination: Cesium$
|
|
8530
|
+
destination: Cesium$5.Cartesian3.fromRadians(
|
|
8527
8531
|
cartographic.longitude,
|
|
8528
8532
|
cartographic.latitude,
|
|
8529
8533
|
targetHeight
|
|
@@ -8539,12 +8543,12 @@ class Zoom extends BaseControl {
|
|
|
8539
8543
|
|
|
8540
8544
|
_getZoomLevel() {
|
|
8541
8545
|
const positionCartographic = this._viewer.camera.positionCartographic;
|
|
8542
|
-
const surfaceCartesian = Cesium$
|
|
8546
|
+
const surfaceCartesian = Cesium$5.Cartesian3.fromRadians(
|
|
8543
8547
|
positionCartographic.longitude,
|
|
8544
8548
|
positionCartographic.latitude,
|
|
8545
8549
|
0
|
|
8546
8550
|
);
|
|
8547
|
-
const distance = Cesium$
|
|
8551
|
+
const distance = Cesium$5.Cartesian3.distance(this._viewer.camera.position, surfaceCartesian);
|
|
8548
8552
|
if (!distance || distance <= 0 || !Number.isFinite(distance)) return 0;
|
|
8549
8553
|
const equatorCircumference = 6378137 * 2 * Math.PI;
|
|
8550
8554
|
return Math.max(0, Math.floor(Math.log2(equatorCircumference / distance)) + 1);
|
|
@@ -8556,7 +8560,7 @@ class Zoom extends BaseControl {
|
|
|
8556
8560
|
}
|
|
8557
8561
|
}
|
|
8558
8562
|
|
|
8559
|
-
const Cesium$
|
|
8563
|
+
const Cesium$4 = getCesium();
|
|
8560
8564
|
|
|
8561
8565
|
/**
|
|
8562
8566
|
* 指南针控件
|
|
@@ -8707,7 +8711,7 @@ class Compass extends BaseControl {
|
|
|
8707
8711
|
|
|
8708
8712
|
_updateRotation() {
|
|
8709
8713
|
if (!this._outerEl) return;
|
|
8710
|
-
const heading = Cesium$
|
|
8714
|
+
const heading = Cesium$4.Math.toDegrees(this._viewer.camera.heading);
|
|
8711
8715
|
this._outerEl.style.transform = `rotate(${-heading}deg)`;
|
|
8712
8716
|
}
|
|
8713
8717
|
|
|
@@ -8760,7 +8764,7 @@ class Compass extends BaseControl {
|
|
|
8760
8764
|
|
|
8761
8765
|
const camera = this._viewer.camera;
|
|
8762
8766
|
if (this._rotateFrame) {
|
|
8763
|
-
const oldTransform = Cesium$
|
|
8767
|
+
const oldTransform = Cesium$4.Matrix4.clone(camera.transform);
|
|
8764
8768
|
camera.lookAtTransform(this._rotateFrame);
|
|
8765
8769
|
camera.rotateRight(delta);
|
|
8766
8770
|
camera.lookAtTransform(oldTransform);
|
|
@@ -8802,10 +8806,10 @@ class Compass extends BaseControl {
|
|
|
8802
8806
|
if (this._mode !== 'orbit') return;
|
|
8803
8807
|
const deltaY = this._startY - e.clientY;
|
|
8804
8808
|
const sensitivity = 0.004;
|
|
8805
|
-
const newPitch = Cesium$
|
|
8809
|
+
const newPitch = Cesium$4.Math.clamp(
|
|
8806
8810
|
this._startPitch + deltaY * sensitivity,
|
|
8807
|
-
-Cesium$
|
|
8808
|
-
Cesium$
|
|
8811
|
+
-Cesium$4.Math.PI_OVER_TWO + 0.01,
|
|
8812
|
+
Cesium$4.Math.PI_OVER_TWO - 0.01
|
|
8809
8813
|
);
|
|
8810
8814
|
this._viewer.camera.setView({
|
|
8811
8815
|
destination: this._viewer.camera.position,
|
|
@@ -8829,26 +8833,26 @@ class Compass extends BaseControl {
|
|
|
8829
8833
|
_getRotateFrame() {
|
|
8830
8834
|
const scene = this._viewer.scene;
|
|
8831
8835
|
const camera = this._viewer.camera;
|
|
8832
|
-
if (scene.mode === Cesium$
|
|
8836
|
+
if (scene.mode === Cesium$4.SceneMode.MORPHING) return null;
|
|
8833
8837
|
|
|
8834
8838
|
let center;
|
|
8835
8839
|
if (this._viewer.trackedEntity) {
|
|
8836
8840
|
center = this._viewer.trackedEntity.position.getValue(this._viewer.clock.currentTime);
|
|
8837
8841
|
} else {
|
|
8838
|
-
const ray = new Cesium$
|
|
8842
|
+
const ray = new Cesium$4.Ray(camera.positionWC, camera.directionWC);
|
|
8839
8843
|
center = scene.globe.pick(ray, scene);
|
|
8840
8844
|
}
|
|
8841
8845
|
if (!center) {
|
|
8842
8846
|
center = camera.positionWC;
|
|
8843
8847
|
}
|
|
8844
|
-
return Cesium$
|
|
8848
|
+
return Cesium$4.Transforms.eastNorthUpToFixedFrame(center, scene.globe.ellipsoid);
|
|
8845
8849
|
}
|
|
8846
8850
|
|
|
8847
8851
|
_onDoubleClick() {
|
|
8848
8852
|
const camera = this._viewer.camera;
|
|
8849
8853
|
const cartographic = camera.positionCartographic;
|
|
8850
8854
|
camera.flyTo({
|
|
8851
|
-
destination: Cesium$
|
|
8855
|
+
destination: Cesium$4.Cartesian3.fromRadians(
|
|
8852
8856
|
cartographic.longitude,
|
|
8853
8857
|
cartographic.latitude,
|
|
8854
8858
|
cartographic.height
|
|
@@ -8869,7 +8873,7 @@ class Compass extends BaseControl {
|
|
|
8869
8873
|
}
|
|
8870
8874
|
}
|
|
8871
8875
|
|
|
8872
|
-
const Cesium$
|
|
8876
|
+
const Cesium$3 = getCesium();
|
|
8873
8877
|
|
|
8874
8878
|
/**
|
|
8875
8879
|
* 比例尺控件
|
|
@@ -8901,7 +8905,7 @@ class DistanceLegend extends BaseControl {
|
|
|
8901
8905
|
base.forEach(b => this._distances.push(b * factor));
|
|
8902
8906
|
}
|
|
8903
8907
|
|
|
8904
|
-
this._geodesic = new Cesium$
|
|
8908
|
+
this._geodesic = new Cesium$3.EllipsoidGeodesic();
|
|
8905
8909
|
this._lastUpdate = 0;
|
|
8906
8910
|
}
|
|
8907
8911
|
|
|
@@ -8959,8 +8963,8 @@ class DistanceLegend extends BaseControl {
|
|
|
8959
8963
|
const x = Math.floor(width / 2);
|
|
8960
8964
|
const y = Math.max(0, height - 1);
|
|
8961
8965
|
|
|
8962
|
-
const leftRay = camera.getPickRay(new Cesium$
|
|
8963
|
-
const rightRay = camera.getPickRay(new Cesium$
|
|
8966
|
+
const leftRay = camera.getPickRay(new Cesium$3.Cartesian2(x, y));
|
|
8967
|
+
const rightRay = camera.getPickRay(new Cesium$3.Cartesian2(x + 1, y));
|
|
8964
8968
|
if (!leftRay || !rightRay) return;
|
|
8965
8969
|
|
|
8966
8970
|
const leftPosition = scene.globe.pick(leftRay, scene);
|
|
@@ -9194,6 +9198,518 @@ class ControlModule {
|
|
|
9194
9198
|
}
|
|
9195
9199
|
}
|
|
9196
9200
|
|
|
9201
|
+
const toDataUri = (svg) => `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;
|
|
9202
|
+
|
|
9203
|
+
/**
|
|
9204
|
+
* 军标内置默认图标。
|
|
9205
|
+
* SDK 内置常见军标类型的默认图标,业务层可通过 imgUrl / useDefaultIcon 参数覆盖或追加。
|
|
9206
|
+
*/
|
|
9207
|
+
const DEFAULT_SYMBOL_IMAGES = {
|
|
9208
|
+
'small-radio': toDataUri(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 80 80" width="80" height="80"><g id="图层_2" data-name="图层 2"><g id="图层_1-2" data-name="图层 1"><circle cx="36.93" cy="48.5" r="22" style="fill:none;stroke:red;stroke-miterlimit:10;stroke-width:4.535433070866142px"/><polyline points="42.56 25.87 53.06 9.51 54.06 27.5 65.07 10.37" style="fill:none;stroke:red;stroke-linejoin:bevel;stroke-width:4.535433070866142px"/><rect width="80" height="80" style="fill:red;opacity:0"/></g></g></svg>`),
|
|
9209
|
+
'large-radio': toDataUri(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 80 80" width="80" height="80"><g id="图层_2" data-name="图层 2"><g id="图层_1-2" data-name="图层 1"><polygon points="39.96 28.87 51.18 48.3 62.4 67.73 39.96 67.73 17.53 67.73 28.75 48.3 39.96 28.87" style="fill:none;stroke:red;stroke-miterlimit:10;stroke-width:4.535433070866142px"/><polyline points="39.96 28.64 50.46 12.27 51.46 30.27 62.47 13.14" style="fill:none;stroke:red;stroke-linejoin:bevel;stroke-width:4.535433070866142px"/><rect width="80" height="80" style="fill:red;opacity:0"/></g></g></svg>`),
|
|
9210
|
+
};
|
|
9211
|
+
|
|
9212
|
+
const Cesium$2 = getCesium();
|
|
9213
|
+
|
|
9214
|
+
/**
|
|
9215
|
+
* 军标模块
|
|
9216
|
+
* 封装军标图元的创建、更新、删除、可见性控制及拖拽编辑位置能力。
|
|
9217
|
+
* SDK 内部维护军标状态,业务层只需传入类型、位置等渲染元数据。
|
|
9218
|
+
*/
|
|
9219
|
+
class MilitarySymbolModule {
|
|
9220
|
+
constructor(viewer) {
|
|
9221
|
+
this.viewer = viewer;
|
|
9222
|
+
this.config = Config.getInstance().getConfig();
|
|
9223
|
+
/** @type {Map<string, {entity: Cesium.Entity, metadata: object}>} */
|
|
9224
|
+
this.symbolMap = new Map();
|
|
9225
|
+
/** @type {Map<string, string>} 业务自定义的默认图标(按 type) */
|
|
9226
|
+
this.defaultImageMap = new Map();
|
|
9227
|
+
this.eventModule = null;
|
|
9228
|
+
|
|
9229
|
+
this._editMode = false;
|
|
9230
|
+
this._draggingId = null;
|
|
9231
|
+
this._dragObserverIds = [];
|
|
9232
|
+
/** @type {Set<Function>} */
|
|
9233
|
+
this._positionChangedCallbacks = new Set();
|
|
9234
|
+
}
|
|
9235
|
+
|
|
9236
|
+
/**
|
|
9237
|
+
* 注入依赖模块
|
|
9238
|
+
* @param {Object} deps
|
|
9239
|
+
* @param {EventModule} deps.eventModule 事件模块,用于拖拽交互
|
|
9240
|
+
* @returns {MilitarySymbolModule}
|
|
9241
|
+
*/
|
|
9242
|
+
setDependencies(deps = {}) {
|
|
9243
|
+
this.eventModule = deps.eventModule || null;
|
|
9244
|
+
return this;
|
|
9245
|
+
}
|
|
9246
|
+
|
|
9247
|
+
/**
|
|
9248
|
+
* 设置全局默认图标模式
|
|
9249
|
+
* @param {'default'|'custom'|'overlay'} mode 默认图标模式
|
|
9250
|
+
* @returns {MilitarySymbolModule}
|
|
9251
|
+
*/
|
|
9252
|
+
setDefaultIconMode(mode) {
|
|
9253
|
+
this._defaultIconMode = mode;
|
|
9254
|
+
return this;
|
|
9255
|
+
}
|
|
9256
|
+
|
|
9257
|
+
/**
|
|
9258
|
+
* 注册某个军标类型的默认图标
|
|
9259
|
+
* @param {string} type 军标类型
|
|
9260
|
+
* @param {string} imgUrl 图标 URL / dataURL
|
|
9261
|
+
* @returns {MilitarySymbolModule}
|
|
9262
|
+
*/
|
|
9263
|
+
registerDefaultImage(type, imgUrl) {
|
|
9264
|
+
this.defaultImageMap.set(type, imgUrl);
|
|
9265
|
+
return this;
|
|
9266
|
+
}
|
|
9267
|
+
|
|
9268
|
+
/**
|
|
9269
|
+
* 批量注册军标默认图标
|
|
9270
|
+
* @param {Record<string, string>} map { type: imgUrl }
|
|
9271
|
+
* @returns {MilitarySymbolModule}
|
|
9272
|
+
*/
|
|
9273
|
+
registerDefaultImages(map) {
|
|
9274
|
+
Object.entries(map).forEach(([type, imgUrl]) => {
|
|
9275
|
+
this.registerDefaultImage(type, imgUrl);
|
|
9276
|
+
});
|
|
9277
|
+
return this;
|
|
9278
|
+
}
|
|
9279
|
+
|
|
9280
|
+
/**
|
|
9281
|
+
* 解析军标图标
|
|
9282
|
+
* - iconMode = 'default':使用 SDK 内置默认图标;没有默认图标时回退到 imgUrl
|
|
9283
|
+
* - iconMode = 'custom':使用业务层传入的 imgUrl
|
|
9284
|
+
* - iconMode = 'overlay':在 SDK 默认图标上叠加业务层 imgUrl
|
|
9285
|
+
* @private
|
|
9286
|
+
*/
|
|
9287
|
+
_resolveImage(id, options) {
|
|
9288
|
+
const globalMode = this._defaultIconMode || this.config.militarySymbol?.defaultIconMode;
|
|
9289
|
+
const mode = options.iconMode || globalMode || 'default';
|
|
9290
|
+
const defaultImage = DEFAULT_SYMBOL_IMAGES[options.type];
|
|
9291
|
+
const registeredImage = this.defaultImageMap.get(options.type);
|
|
9292
|
+
const imgUrl = options.imgUrl || registeredImage || null;
|
|
9293
|
+
|
|
9294
|
+
if (mode === 'custom') {
|
|
9295
|
+
if (!imgUrl) {
|
|
9296
|
+
console.warn(`iconMode 为 custom 时未找到可用图标,将尝试使用默认图标`);
|
|
9297
|
+
return defaultImage || null;
|
|
9298
|
+
}
|
|
9299
|
+
return imgUrl;
|
|
9300
|
+
}
|
|
9301
|
+
|
|
9302
|
+
if (mode === 'overlay') {
|
|
9303
|
+
const overlayImage = imgUrl;
|
|
9304
|
+
if (!overlayImage || !defaultImage) {
|
|
9305
|
+
return overlayImage || defaultImage || null;
|
|
9306
|
+
}
|
|
9307
|
+
// 异步合成叠加图标,创建时先返回默认图标,合成完成后再替换
|
|
9308
|
+
this._composeOverlayImage(defaultImage, overlayImage).then((compositeUrl) => {
|
|
9309
|
+
const symbol = this.symbolMap.get(id);
|
|
9310
|
+
if (symbol?.entity?.billboard) {
|
|
9311
|
+
symbol.entity.billboard.image = compositeUrl;
|
|
9312
|
+
}
|
|
9313
|
+
}).catch((err) => {
|
|
9314
|
+
console.warn('军标叠加图标合成失败', err);
|
|
9315
|
+
});
|
|
9316
|
+
return defaultImage;
|
|
9317
|
+
}
|
|
9318
|
+
|
|
9319
|
+
// 默认模式:优先 SDK 内置图标,其次注册图标 / imgUrl
|
|
9320
|
+
if (defaultImage) return defaultImage;
|
|
9321
|
+
if (imgUrl) return imgUrl;
|
|
9322
|
+
console.warn(`军标类型 ${options.type} 未提供图标,也未找到内置默认图标`);
|
|
9323
|
+
return null;
|
|
9324
|
+
}
|
|
9325
|
+
|
|
9326
|
+
/**
|
|
9327
|
+
* 加载图片
|
|
9328
|
+
* @private
|
|
9329
|
+
*/
|
|
9330
|
+
_loadImage(url) {
|
|
9331
|
+
return new Promise((resolve, reject) => {
|
|
9332
|
+
const img = new Image();
|
|
9333
|
+
img.crossOrigin = 'anonymous';
|
|
9334
|
+
img.onload = () => resolve(img);
|
|
9335
|
+
img.onerror = (e) => reject(e);
|
|
9336
|
+
img.src = url;
|
|
9337
|
+
});
|
|
9338
|
+
}
|
|
9339
|
+
|
|
9340
|
+
/**
|
|
9341
|
+
* 把业务图标叠加到默认图标上,返回合成后的 dataURL
|
|
9342
|
+
* @private
|
|
9343
|
+
*/
|
|
9344
|
+
async _composeOverlayImage(defaultUrl, overlayUrl, size = 64) {
|
|
9345
|
+
if (typeof document === 'undefined') return defaultUrl;
|
|
9346
|
+
const [baseImg, overlayImg] = await Promise.all([
|
|
9347
|
+
this._loadImage(defaultUrl),
|
|
9348
|
+
this._loadImage(overlayUrl),
|
|
9349
|
+
]);
|
|
9350
|
+
const canvas = document.createElement('canvas');
|
|
9351
|
+
canvas.width = size;
|
|
9352
|
+
canvas.height = size;
|
|
9353
|
+
const ctx = canvas.getContext('2d');
|
|
9354
|
+
ctx.drawImage(baseImg, 0, 0, size, size);
|
|
9355
|
+
ctx.drawImage(overlayImg, 0, 0, size, size);
|
|
9356
|
+
return canvas.toDataURL('image/png');
|
|
9357
|
+
}
|
|
9358
|
+
|
|
9359
|
+
/**
|
|
9360
|
+
* 从军标实体中提取经纬高
|
|
9361
|
+
* @private
|
|
9362
|
+
*/
|
|
9363
|
+
_getPositionFromEntity(entity) {
|
|
9364
|
+
if (!entity?.position) return null;
|
|
9365
|
+
const pos = typeof entity.position.getValue === 'function'
|
|
9366
|
+
? entity.position.getValue(Cesium$2.JulianDate.now())
|
|
9367
|
+
: entity.position;
|
|
9368
|
+
if (!pos) return null;
|
|
9369
|
+
const c = Cesium$2.Cartographic.fromCartesian(pos);
|
|
9370
|
+
return [
|
|
9371
|
+
Cesium$2.Math.toDegrees(c.longitude),
|
|
9372
|
+
Cesium$2.Math.toDegrees(c.latitude),
|
|
9373
|
+
c.height
|
|
9374
|
+
];
|
|
9375
|
+
}
|
|
9376
|
+
|
|
9377
|
+
/**
|
|
9378
|
+
* 根据鼠标拾取结果判断是否为当前模块管理的军标
|
|
9379
|
+
* @private
|
|
9380
|
+
*/
|
|
9381
|
+
_getSymbolIdFromPick(pickedEntity) {
|
|
9382
|
+
if (!pickedEntity) return null;
|
|
9383
|
+
const id = typeof pickedEntity.id === 'string' ? pickedEntity.id : pickedEntity.id?.id;
|
|
9384
|
+
return this.symbolMap.has(id) ? id : null;
|
|
9385
|
+
}
|
|
9386
|
+
|
|
9387
|
+
/**
|
|
9388
|
+
* 创建军标图元
|
|
9389
|
+
* @param {string} id 军标唯一ID
|
|
9390
|
+
* @param {Object} options
|
|
9391
|
+
* @param {number[]} options.position 经纬高 [lon, lat, height]
|
|
9392
|
+
* @param {string} options.type 军标类型,如 small-radio / large-radio
|
|
9393
|
+
* @param {string} [options.name] 显示名称,默认使用 id
|
|
9394
|
+
* @param {string} [options.imgUrl] 自定义图标 URL
|
|
9395
|
+
* @param {'default'|'custom'|'overlay'} [options.iconMode] 图标模式,默认 'default'
|
|
9396
|
+
* @param {number} [options.scale] billboard 缩放,默认 0.6
|
|
9397
|
+
* @param {boolean} [options.visible] 是否可见,默认 true
|
|
9398
|
+
* @returns {{id: string, entity: Cesium.Entity, metadata: object}}
|
|
9399
|
+
*/
|
|
9400
|
+
create(id, options = {}) {
|
|
9401
|
+
if (this.symbolMap.has(id)) {
|
|
9402
|
+
console.warn(`军标 ${id} 已存在`);
|
|
9403
|
+
return this.getById(id);
|
|
9404
|
+
}
|
|
9405
|
+
|
|
9406
|
+
const position = options.position || [0, 0, 0];
|
|
9407
|
+
const image = this._resolveImage(id, options);
|
|
9408
|
+
const scale = options.scale ?? 0.6;
|
|
9409
|
+
const visible = options.visible !== false;
|
|
9410
|
+
const name = options.name ?? id;
|
|
9411
|
+
const iconMode = options.iconMode || 'default';
|
|
9412
|
+
|
|
9413
|
+
const entity = this.viewer.entities.add({
|
|
9414
|
+
id,
|
|
9415
|
+
position: Cesium$2.Cartesian3.fromDegrees(position[0], position[1], position[2] || 0),
|
|
9416
|
+
billboard: {
|
|
9417
|
+
image,
|
|
9418
|
+
scale,
|
|
9419
|
+
verticalOrigin: Cesium$2.VerticalOrigin.BOTTOM,
|
|
9420
|
+
horizontalOrigin: Cesium$2.HorizontalOrigin.CENTER,
|
|
9421
|
+
heightReference: Cesium$2.HeightReference.CLAMP_TO_GROUND,
|
|
9422
|
+
disableDepthTestDistance: 100000,
|
|
9423
|
+
},
|
|
9424
|
+
label: {
|
|
9425
|
+
text: name,
|
|
9426
|
+
font: '12px Microsoft YaHei',
|
|
9427
|
+
fillColor: Cesium$2.Color.WHITE,
|
|
9428
|
+
outlineColor: Cesium$2.Color.BLACK,
|
|
9429
|
+
outlineWidth: 2,
|
|
9430
|
+
style: Cesium$2.LabelStyle.FILL_AND_OUTLINE,
|
|
9431
|
+
verticalOrigin: Cesium$2.VerticalOrigin.TOP,
|
|
9432
|
+
horizontalOrigin: Cesium$2.HorizontalOrigin.CENTER,
|
|
9433
|
+
pixelOffset: new Cesium$2.Cartesian2(0, 4),
|
|
9434
|
+
heightReference: Cesium$2.HeightReference.CLAMP_TO_GROUND,
|
|
9435
|
+
disableDepthTestDistance: 100000,
|
|
9436
|
+
show: true,
|
|
9437
|
+
},
|
|
9438
|
+
show: visible,
|
|
9439
|
+
});
|
|
9440
|
+
|
|
9441
|
+
const metadata = {
|
|
9442
|
+
id,
|
|
9443
|
+
type: options.type || 'custom',
|
|
9444
|
+
name,
|
|
9445
|
+
position: [position[0], position[1], position[2] || 0],
|
|
9446
|
+
scale,
|
|
9447
|
+
visible,
|
|
9448
|
+
iconMode,
|
|
9449
|
+
imgUrl: options.imgUrl || null,
|
|
9450
|
+
};
|
|
9451
|
+
|
|
9452
|
+
this.symbolMap.set(id, { entity, metadata });
|
|
9453
|
+
return { id, entity, metadata };
|
|
9454
|
+
}
|
|
9455
|
+
|
|
9456
|
+
/**
|
|
9457
|
+
* 删除军标
|
|
9458
|
+
* @param {string} id 军标ID
|
|
9459
|
+
* @returns {boolean} 是否删除成功
|
|
9460
|
+
*/
|
|
9461
|
+
remove(id) {
|
|
9462
|
+
const symbol = this.symbolMap.get(id);
|
|
9463
|
+
if (!symbol) {
|
|
9464
|
+
console.warn(`军标 ${id} 不存在`);
|
|
9465
|
+
return false;
|
|
9466
|
+
}
|
|
9467
|
+
this.viewer.entities.remove(symbol.entity);
|
|
9468
|
+
this.symbolMap.delete(id);
|
|
9469
|
+
if (this._draggingId === id) {
|
|
9470
|
+
this._draggingId = null;
|
|
9471
|
+
this.viewer.scene.screenSpaceCameraController.enableInputs = true;
|
|
9472
|
+
}
|
|
9473
|
+
return true;
|
|
9474
|
+
}
|
|
9475
|
+
|
|
9476
|
+
/**
|
|
9477
|
+
* 删除所有军标
|
|
9478
|
+
*/
|
|
9479
|
+
removeAll() {
|
|
9480
|
+
this.symbolMap.forEach((symbol) => {
|
|
9481
|
+
this.viewer.entities.remove(symbol.entity);
|
|
9482
|
+
});
|
|
9483
|
+
this.symbolMap.clear();
|
|
9484
|
+
this._draggingId = null;
|
|
9485
|
+
this.viewer.scene.screenSpaceCameraController.enableInputs = true;
|
|
9486
|
+
}
|
|
9487
|
+
|
|
9488
|
+
/**
|
|
9489
|
+
* 更新军标属性
|
|
9490
|
+
* @param {string} id 军标ID
|
|
9491
|
+
* @param {Object} fields 支持 position / name / scale / imgUrl / visible
|
|
9492
|
+
* @returns {boolean} 是否更新成功
|
|
9493
|
+
*/
|
|
9494
|
+
update(id, fields = {}) {
|
|
9495
|
+
const symbol = this.symbolMap.get(id);
|
|
9496
|
+
if (!symbol) {
|
|
9497
|
+
console.warn(`军标 ${id} 不存在`);
|
|
9498
|
+
return false;
|
|
9499
|
+
}
|
|
9500
|
+
|
|
9501
|
+
const { entity, metadata } = symbol;
|
|
9502
|
+
|
|
9503
|
+
if (fields.position) {
|
|
9504
|
+
const pos = fields.position;
|
|
9505
|
+
entity.position = Cesium$2.Cartesian3.fromDegrees(pos[0], pos[1], pos[2] || 0);
|
|
9506
|
+
metadata.position = [pos[0], pos[1], pos[2] || 0];
|
|
9507
|
+
}
|
|
9508
|
+
|
|
9509
|
+
if (fields.name !== undefined) {
|
|
9510
|
+
entity.label.text = fields.name;
|
|
9511
|
+
metadata.name = fields.name;
|
|
9512
|
+
}
|
|
9513
|
+
|
|
9514
|
+
if (fields.scale !== undefined) {
|
|
9515
|
+
entity.billboard.scale = fields.scale;
|
|
9516
|
+
metadata.scale = fields.scale;
|
|
9517
|
+
}
|
|
9518
|
+
|
|
9519
|
+
if (fields.imgUrl !== undefined || fields.iconMode !== undefined) {
|
|
9520
|
+
const newIconMode = fields.iconMode || metadata.iconMode;
|
|
9521
|
+
const newImgUrl = fields.imgUrl !== undefined ? fields.imgUrl : metadata.imgUrl;
|
|
9522
|
+
entity.billboard.image = this._resolveImage(id, {
|
|
9523
|
+
type: metadata.type,
|
|
9524
|
+
iconMode: newIconMode,
|
|
9525
|
+
imgUrl: newImgUrl,
|
|
9526
|
+
});
|
|
9527
|
+
metadata.imgUrl = newImgUrl;
|
|
9528
|
+
metadata.iconMode = newIconMode;
|
|
9529
|
+
}
|
|
9530
|
+
|
|
9531
|
+
if (fields.visible !== undefined) {
|
|
9532
|
+
entity.show = fields.visible;
|
|
9533
|
+
metadata.visible = fields.visible;
|
|
9534
|
+
}
|
|
9535
|
+
|
|
9536
|
+
return true;
|
|
9537
|
+
}
|
|
9538
|
+
|
|
9539
|
+
/**
|
|
9540
|
+
* 设置军标可见性
|
|
9541
|
+
* @param {string} id 军标ID
|
|
9542
|
+
* @param {boolean} visible 是否可见
|
|
9543
|
+
* @returns {boolean}
|
|
9544
|
+
*/
|
|
9545
|
+
setVisible(id, visible) {
|
|
9546
|
+
return this.update(id, { visible });
|
|
9547
|
+
}
|
|
9548
|
+
|
|
9549
|
+
/**
|
|
9550
|
+
* 获取军标信息
|
|
9551
|
+
* @param {string} id 军标ID
|
|
9552
|
+
* @returns {{id: string, entity: Cesium.Entity, metadata: object} | undefined}
|
|
9553
|
+
*/
|
|
9554
|
+
getById(id) {
|
|
9555
|
+
const symbol = this.symbolMap.get(id);
|
|
9556
|
+
if (!symbol) return undefined;
|
|
9557
|
+
return { id, entity: symbol.entity, metadata: { ...symbol.metadata } };
|
|
9558
|
+
}
|
|
9559
|
+
|
|
9560
|
+
/**
|
|
9561
|
+
* 获取军标实体
|
|
9562
|
+
* @param {string} id 军标ID
|
|
9563
|
+
* @returns {Cesium.Entity | undefined}
|
|
9564
|
+
*/
|
|
9565
|
+
getEntity(id) {
|
|
9566
|
+
return this.symbolMap.get(id)?.entity;
|
|
9567
|
+
}
|
|
9568
|
+
|
|
9569
|
+
/**
|
|
9570
|
+
* 获取全部军标信息
|
|
9571
|
+
* @returns {Array<{id: string, entity: Cesium.Entity, metadata: object}>}
|
|
9572
|
+
*/
|
|
9573
|
+
getAll() {
|
|
9574
|
+
const result = [];
|
|
9575
|
+
this.symbolMap.forEach((symbol, id) => {
|
|
9576
|
+
result.push({ id, entity: symbol.entity, metadata: { ...symbol.metadata } });
|
|
9577
|
+
});
|
|
9578
|
+
return result;
|
|
9579
|
+
}
|
|
9580
|
+
|
|
9581
|
+
/**
|
|
9582
|
+
* 飞行定位到军标
|
|
9583
|
+
* @param {string} id 军标ID
|
|
9584
|
+
* @param {Object} options { duration?, pitch?, range? }
|
|
9585
|
+
* @returns {Promise<boolean>}
|
|
9586
|
+
*/
|
|
9587
|
+
flyTo(id, options = {}) {
|
|
9588
|
+
const entity = this.getEntity(id);
|
|
9589
|
+
if (!entity || !this.viewer) return Promise.resolve(false);
|
|
9590
|
+
|
|
9591
|
+
const position = this._getPositionFromEntity(entity);
|
|
9592
|
+
if (!position) return Promise.resolve(false);
|
|
9593
|
+
|
|
9594
|
+
const duration = options.duration ?? 1.5;
|
|
9595
|
+
const pitch = options.pitch ?? -Cesium$2.Math.PI_OVER_TWO;
|
|
9596
|
+
const range = options.range ?? 5000;
|
|
9597
|
+
|
|
9598
|
+
return this.viewer.camera.flyTo({
|
|
9599
|
+
destination: Cesium$2.Cartesian3.fromDegrees(position[0], position[1], (position[2] || 0) + range),
|
|
9600
|
+
orientation: { heading: 0, pitch, roll: 0 },
|
|
9601
|
+
duration,
|
|
9602
|
+
}).then(() => true).catch((err) => {
|
|
9603
|
+
console.error('军标定位失败', err);
|
|
9604
|
+
return false;
|
|
9605
|
+
});
|
|
9606
|
+
}
|
|
9607
|
+
|
|
9608
|
+
/**
|
|
9609
|
+
* 瞬间定位到军标
|
|
9610
|
+
* @param {string} id 军标ID
|
|
9611
|
+
* @param {Object} options { pitch?, range? }
|
|
9612
|
+
*/
|
|
9613
|
+
zoomTo(id, options = {}) {
|
|
9614
|
+
const entity = this.getEntity(id);
|
|
9615
|
+
if (!entity || !this.viewer) return;
|
|
9616
|
+
|
|
9617
|
+
const position = this._getPositionFromEntity(entity);
|
|
9618
|
+
if (!position) return;
|
|
9619
|
+
|
|
9620
|
+
const pitch = options.pitch ?? -Cesium$2.Math.PI_OVER_TWO;
|
|
9621
|
+
const range = options.range ?? 5000;
|
|
9622
|
+
|
|
9623
|
+
this.viewer.camera.setView({
|
|
9624
|
+
destination: Cesium$2.Cartesian3.fromDegrees(position[0], position[1], (position[2] || 0) + range),
|
|
9625
|
+
orientation: { heading: 0, pitch, roll: 0 },
|
|
9626
|
+
});
|
|
9627
|
+
}
|
|
9628
|
+
|
|
9629
|
+
/**
|
|
9630
|
+
* 启用拖拽编辑模式
|
|
9631
|
+
* 鼠标在军标上按下即可拖拽,拖拽结束后触发 onPositionChanged 回调。
|
|
9632
|
+
*/
|
|
9633
|
+
enableEditMode() {
|
|
9634
|
+
if (this._editMode) return;
|
|
9635
|
+
if (!this.eventModule) {
|
|
9636
|
+
console.warn('MilitarySymbolModule 未注入 EventModule,无法启用拖拽编辑');
|
|
9637
|
+
return;
|
|
9638
|
+
}
|
|
9639
|
+
|
|
9640
|
+
this._editMode = true;
|
|
9641
|
+
|
|
9642
|
+
const downId = this.eventModule.registerObserver('mouse:down', (lngLat, pickedEntity) => {
|
|
9643
|
+
const symbolId = this._getSymbolIdFromPick(pickedEntity);
|
|
9644
|
+
if (!symbolId) return;
|
|
9645
|
+
this._draggingId = symbolId;
|
|
9646
|
+
this.viewer.scene.screenSpaceCameraController.enableInputs = false;
|
|
9647
|
+
});
|
|
9648
|
+
|
|
9649
|
+
const moveId = this.eventModule.registerObserver('mouse:move', (lngLat, pickedEntity, movement) => {
|
|
9650
|
+
if (!this._draggingId || !movement?.endPosition) return;
|
|
9651
|
+
|
|
9652
|
+
const cartesian = this.viewer.scene.pickPosition(movement.endPosition)
|
|
9653
|
+
|| this.viewer.scene.camera.pickEllipsoid(movement.endPosition, this.viewer.scene.globe.ellipsoid);
|
|
9654
|
+
if (!cartesian) return;
|
|
9655
|
+
|
|
9656
|
+
const carto = Cesium$2.Cartographic.fromCartesian(cartesian);
|
|
9657
|
+
const position = [
|
|
9658
|
+
Cesium$2.Math.toDegrees(carto.longitude),
|
|
9659
|
+
Cesium$2.Math.toDegrees(carto.latitude),
|
|
9660
|
+
carto.height,
|
|
9661
|
+
];
|
|
9662
|
+
this.update(this._draggingId, { position });
|
|
9663
|
+
});
|
|
9664
|
+
|
|
9665
|
+
const upId = this.eventModule.registerObserver('mouse:up', () => {
|
|
9666
|
+
if (!this._draggingId) return;
|
|
9667
|
+
const symbol = this.symbolMap.get(this._draggingId);
|
|
9668
|
+
const payload = symbol ? { id: this._draggingId, position: [...symbol.metadata.position] } : null;
|
|
9669
|
+
this._draggingId = null;
|
|
9670
|
+
this.viewer.scene.screenSpaceCameraController.enableInputs = true;
|
|
9671
|
+
if (payload) {
|
|
9672
|
+
this._positionChangedCallbacks.forEach((callback) => callback(payload));
|
|
9673
|
+
}
|
|
9674
|
+
});
|
|
9675
|
+
|
|
9676
|
+
this._dragObserverIds = [downId, moveId, upId];
|
|
9677
|
+
}
|
|
9678
|
+
|
|
9679
|
+
/**
|
|
9680
|
+
* 禁用拖拽编辑模式
|
|
9681
|
+
*/
|
|
9682
|
+
disableEditMode() {
|
|
9683
|
+
if (!this._editMode) return;
|
|
9684
|
+
if (this.eventModule) {
|
|
9685
|
+
this._dragObserverIds.forEach((observerId) => {
|
|
9686
|
+
// 每个观察者注册时的事件类型固定,分别注销
|
|
9687
|
+
['mouse:down', 'mouse:move', 'mouse:up'].forEach((eventType) => {
|
|
9688
|
+
try {
|
|
9689
|
+
this.eventModule.unregisterObserver(eventType, observerId);
|
|
9690
|
+
} catch (e) {
|
|
9691
|
+
// 忽略跨事件类型注销失败
|
|
9692
|
+
}
|
|
9693
|
+
});
|
|
9694
|
+
});
|
|
9695
|
+
}
|
|
9696
|
+
this._dragObserverIds = [];
|
|
9697
|
+
this._draggingId = null;
|
|
9698
|
+
this.viewer.scene.screenSpaceCameraController.enableInputs = true;
|
|
9699
|
+
this._editMode = false;
|
|
9700
|
+
}
|
|
9701
|
+
|
|
9702
|
+
/**
|
|
9703
|
+
* 注册位置变化回调
|
|
9704
|
+
* @param {Function} callback 回调参数 { id, position }
|
|
9705
|
+
* @returns {Function} 注销函数
|
|
9706
|
+
*/
|
|
9707
|
+
onPositionChanged(callback) {
|
|
9708
|
+
this._positionChangedCallbacks.add(callback);
|
|
9709
|
+
return () => this._positionChangedCallbacks.delete(callback);
|
|
9710
|
+
}
|
|
9711
|
+
}
|
|
9712
|
+
|
|
9197
9713
|
/**
|
|
9198
9714
|
* 模块管理器(对应平台 GetModule 逻辑)
|
|
9199
9715
|
* 统一管理场景、图元、事件模块的实例
|
|
@@ -9250,6 +9766,13 @@ class ModuleManager {
|
|
|
9250
9766
|
}).init();
|
|
9251
9767
|
this.registerModule('EditorModule', editorModule);
|
|
9252
9768
|
|
|
9769
|
+
// 初始化军标模块(依赖事件模块)
|
|
9770
|
+
const militarySymbolModule = new MilitarySymbolModule(this.cesiumViewer);
|
|
9771
|
+
militarySymbolModule.setDependencies({
|
|
9772
|
+
eventModule: this.getModule('EventModule')
|
|
9773
|
+
});
|
|
9774
|
+
this.registerModule('MilitarySymbolModule', militarySymbolModule);
|
|
9775
|
+
|
|
9253
9776
|
// 初始化控件模块
|
|
9254
9777
|
const controlModule = new ControlModule(this.cesiumViewer);
|
|
9255
9778
|
this.registerModule('ControlModule', controlModule);
|
|
@@ -9315,6 +9838,14 @@ class ModuleManager {
|
|
|
9315
9838
|
return this.getModule('EditorModule');
|
|
9316
9839
|
}
|
|
9317
9840
|
|
|
9841
|
+
/**
|
|
9842
|
+
* 军标模块快捷访问
|
|
9843
|
+
* @returns {MilitarySymbolModule}
|
|
9844
|
+
*/
|
|
9845
|
+
get militarySymbolModule() {
|
|
9846
|
+
return this.getModule('MilitarySymbolModule');
|
|
9847
|
+
}
|
|
9848
|
+
|
|
9318
9849
|
/**
|
|
9319
9850
|
* 控件模块快捷访问
|
|
9320
9851
|
* @returns {ControlModule}
|
|
@@ -9487,6 +10018,7 @@ const xs3d = {
|
|
|
9487
10018
|
EventModule,
|
|
9488
10019
|
EditorModule,
|
|
9489
10020
|
ControlModule,
|
|
10021
|
+
MilitarySymbolModule,
|
|
9490
10022
|
CoordinateUtil,
|
|
9491
10023
|
GeoCalcUtil,
|
|
9492
10024
|
// 导出控件类
|