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