cesium-xs-sdk 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cesium-xs-sdk.cjs.js +1162 -548
- package/dist/cesium-xs-sdk.cjs.js.map +1 -1
- package/dist/cesium-xs-sdk.esm.js +1162 -548
- 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/controls/Zoom.js +5 -1
- package/src/core/ModuleManager.js +6 -0
- package/src/index.js +2 -1
- package/src/modules/EditorModule.js +65 -1
- package/src/modules/GraphicModule.js +1 -1
- package/src/modules/tools/DrawTool.js +28 -6
- package/src/modules/tools/MeasureTool.js +514 -0
- package/src/utils/PlotGeometryUtil.js +16 -8
- package/src/vue.d.ts +18 -18
- package/src/vue.js +70 -76
|
@@ -242,7 +242,7 @@ class Config {
|
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
-
const Cesium$
|
|
245
|
+
const Cesium$g = 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$g.UrlTemplateImageryProvider({ url, ...opts });
|
|
332
332
|
|
|
333
333
|
case LayerType.WMTS:
|
|
334
|
-
return new Cesium$
|
|
334
|
+
return new Cesium$g.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$g.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$g.SingleTileImageryProvider({
|
|
353
353
|
url,
|
|
354
|
-
rectangle: opts.extent ? Cesium$
|
|
354
|
+
rectangle: opts.extent ? Cesium$g.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$g.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$g.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$g.Math.toDegrees(rect.west),
|
|
476
|
+
south: Cesium$g.Math.toDegrees(rect.south),
|
|
477
|
+
east: Cesium$g.Math.toDegrees(rect.east),
|
|
478
|
+
north: Cesium$g.Math.toDegrees(rect.north)
|
|
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$g.Math.toDegrees(rect.west),
|
|
523
|
+
south: Cesium$g.Math.toDegrees(rect.south),
|
|
524
|
+
east: Cesium$g.Math.toDegrees(rect.east),
|
|
525
|
+
north: Cesium$g.Math.toDegrees(rect.north)
|
|
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$g.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$g.Math.toDegrees(rect.west),
|
|
569
|
+
south: Cesium$g.Math.toDegrees(rect.south),
|
|
570
|
+
east: Cesium$g.Math.toDegrees(rect.east),
|
|
571
|
+
north: Cesium$g.Math.toDegrees(rect.north),
|
|
572
572
|
center: [
|
|
573
|
-
Cesium$
|
|
574
|
-
Cesium$
|
|
573
|
+
Cesium$g.Math.toDegrees(cartographic.longitude),
|
|
574
|
+
Cesium$g.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$g.Cartesian3.fromDegrees(lon, lat, height);
|
|
613
613
|
}
|
|
614
614
|
|
|
615
615
|
worldToLonLat(cartesian) {
|
|
616
|
-
const cartographic = Cesium$
|
|
616
|
+
const cartographic = Cesium$g.Cartographic.fromCartesian(cartesian);
|
|
617
617
|
return [
|
|
618
|
-
Cesium$
|
|
619
|
-
Cesium$
|
|
618
|
+
Cesium$g.Math.toDegrees(cartographic.longitude),
|
|
619
|
+
Cesium$g.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$g.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$g.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$g.Cartographic(Cesium$g.Math.toRadians(lon), Cesium$g.Math.toRadians(lat), height);
|
|
652
652
|
}
|
|
653
653
|
|
|
654
654
|
cartographicToLonLat(cartographic) {
|
|
655
655
|
return [
|
|
656
|
-
Cesium$
|
|
657
|
-
Cesium$
|
|
656
|
+
Cesium$g.Math.toDegrees(cartographic.longitude),
|
|
657
|
+
Cesium$g.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$g.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$g.defined(lon) || !Cesium$g.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$g.Cartesian3.fromDegrees(lon, lat, height),
|
|
802
802
|
orientation: {
|
|
803
|
-
heading: Cesium$
|
|
804
|
-
pitch: Cesium$
|
|
805
|
-
roll: Cesium$
|
|
803
|
+
heading: Cesium$g.Math.toRadians(heading),
|
|
804
|
+
pitch: Cesium$g.Math.toRadians(pitch),
|
|
805
|
+
roll: Cesium$g.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$g.defined(lon) || !Cesium$g.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$g.Cartesian3.fromDegrees(lon, lat, height),
|
|
837
837
|
orientation: {
|
|
838
|
-
heading: Cesium$
|
|
839
|
-
pitch: Cesium$
|
|
840
|
-
roll: Cesium$
|
|
838
|
+
heading: Cesium$g.Math.toRadians(heading),
|
|
839
|
+
pitch: Cesium$g.Math.toRadians(pitch),
|
|
840
|
+
roll: Cesium$g.Math.toRadians(roll)
|
|
841
841
|
}
|
|
842
842
|
});
|
|
843
843
|
}
|
|
844
844
|
}
|
|
845
845
|
|
|
846
|
-
const Cesium$
|
|
846
|
+
const Cesium$f = 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$f.Cartesian3.fromDegreesArrayHeights(flat);
|
|
1136
1136
|
}
|
|
1137
1137
|
|
|
1138
1138
|
// ==================== 曲线/插值工具(复合箭头、曲线标绘需要)====================
|
|
@@ -1332,7 +1332,12 @@ class PlotGeometryUtil {
|
|
|
1332
1332
|
}
|
|
1333
1333
|
points.push(pnt2);
|
|
1334
1334
|
}
|
|
1335
|
-
|
|
1335
|
+
// 去除相邻重复点(首尾插值点与控制点重合),避免 Cesium polyline 出现零长度边
|
|
1336
|
+
return points.filter((p, i) => {
|
|
1337
|
+
if (i === 0) return true;
|
|
1338
|
+
const prev = points[i - 1];
|
|
1339
|
+
return p[0] !== prev[0] || p[1] !== prev[1];
|
|
1340
|
+
});
|
|
1336
1341
|
}
|
|
1337
1342
|
|
|
1338
1343
|
/**
|
|
@@ -1931,20 +1936,23 @@ class PlotGeometryUtil {
|
|
|
1931
1936
|
const lnglatPoints = points.map(p => this.toLonLat(p));
|
|
1932
1937
|
const height = points[0][2] || 0;
|
|
1933
1938
|
|
|
1939
|
+
const arrowLength = options.arrowLength ?? 0.05; // 箭头头部最大长度
|
|
1940
|
+
const arrowLengthScale = options.arrowLengthScale ?? 5; // 按拖动距离缩放的系数
|
|
1941
|
+
const distance = this.mathDistance(lnglatPoints[0], lnglatPoints[lnglatPoints.length - 1]);
|
|
1942
|
+
const len = Math.min(distance / arrowLengthScale, arrowLength);
|
|
1943
|
+
|
|
1934
1944
|
if (points.length === 2) {
|
|
1935
|
-
|
|
1945
|
+
// 2 个点时退化为细直箭头,按距离渐变但不超过 arrowLength
|
|
1946
|
+
const [p1, p2] = lnglatPoints;
|
|
1947
|
+
const leftPnt = this.getThirdPoint(p1, p2, Math.PI / 6, len / 2, false);
|
|
1948
|
+
const rightPnt = this.getThirdPoint(p1, p2, Math.PI / 6, len / 2, true);
|
|
1949
|
+
return this.toPositions([p1, p2, leftPnt, p2, rightPnt], height);
|
|
1936
1950
|
}
|
|
1937
1951
|
|
|
1938
1952
|
const t = options.t ?? 0.3;
|
|
1939
|
-
const arrowLengthScale = options.arrowLengthScale ?? 5;
|
|
1940
|
-
const maxArrowLength = options.maxArrowLength ?? 3000000;
|
|
1941
1953
|
|
|
1942
1954
|
const curvePoints = this.getCurvePoints(t, lnglatPoints);
|
|
1943
|
-
lnglatPoints[lnglatPoints.length - 2];
|
|
1944
1955
|
const pnt2 = lnglatPoints[lnglatPoints.length - 1];
|
|
1945
|
-
const distance = this.wholeDistance(lnglatPoints);
|
|
1946
|
-
let len = distance / arrowLengthScale;
|
|
1947
|
-
len = Math.min(len, maxArrowLength);
|
|
1948
1956
|
const leftPnt = this.getThirdPoint(
|
|
1949
1957
|
curvePoints[curvePoints.length - 2],
|
|
1950
1958
|
curvePoints[curvePoints.length - 1],
|
|
@@ -2020,7 +2028,7 @@ function isLinePlotType(plotType) {
|
|
|
2020
2028
|
].includes(plotType);
|
|
2021
2029
|
}
|
|
2022
2030
|
|
|
2023
|
-
const Cesium$
|
|
2031
|
+
const Cesium$e = getCesium();
|
|
2024
2032
|
|
|
2025
2033
|
/**
|
|
2026
2034
|
* 点图元包装器
|
|
@@ -2032,7 +2040,7 @@ class PointWrapper {
|
|
|
2032
2040
|
}
|
|
2033
2041
|
|
|
2034
2042
|
setPosition(coords) {
|
|
2035
|
-
this._entity.position = Cesium$
|
|
2043
|
+
this._entity.position = Cesium$e.Cartesian3.fromDegrees(...coords);
|
|
2036
2044
|
return this;
|
|
2037
2045
|
}
|
|
2038
2046
|
|
|
@@ -2080,7 +2088,7 @@ class PointWrapper {
|
|
|
2080
2088
|
// 名称标签相关
|
|
2081
2089
|
setNameVisible(visible) {
|
|
2082
2090
|
if (!this._entity.label) {
|
|
2083
|
-
this._entity.label = new Cesium$
|
|
2091
|
+
this._entity.label = new Cesium$e.LabelGraphics();
|
|
2084
2092
|
}
|
|
2085
2093
|
this._entity.label.show = visible;
|
|
2086
2094
|
return this;
|
|
@@ -2088,22 +2096,22 @@ class PointWrapper {
|
|
|
2088
2096
|
|
|
2089
2097
|
setText(text, options = {}) {
|
|
2090
2098
|
if (!this._entity.label) {
|
|
2091
|
-
this._entity.label = new Cesium$
|
|
2099
|
+
this._entity.label = new Cesium$e.LabelGraphics();
|
|
2092
2100
|
}
|
|
2093
2101
|
this._entity.label.text = text;
|
|
2094
2102
|
|
|
2095
2103
|
// 应用配置选项
|
|
2096
2104
|
this._entity.label.disableDepthTestDistance = options.disableDepthTestDistance ?? Number.POSITIVE_INFINITY;
|
|
2097
|
-
this._entity.label.verticalOrigin = options.verticalOrigin ?? Cesium$
|
|
2098
|
-
this._entity.label.eyeOffset = options.eyeOffset ?? new Cesium$
|
|
2099
|
-
this._entity.label.heightReference = options.heightReference ?? Cesium$
|
|
2105
|
+
this._entity.label.verticalOrigin = options.verticalOrigin ?? Cesium$e.VerticalOrigin.BOTTOM;
|
|
2106
|
+
this._entity.label.eyeOffset = options.eyeOffset ?? new Cesium$e.Cartesian3(0, 0, -10);
|
|
2107
|
+
this._entity.label.heightReference = options.heightReference ?? Cesium$e.HeightReference.RELATIVE_TO_GROUND;
|
|
2100
2108
|
|
|
2101
2109
|
return this;
|
|
2102
2110
|
}
|
|
2103
2111
|
|
|
2104
2112
|
setFont(font) {
|
|
2105
2113
|
if (!this._entity.label) {
|
|
2106
|
-
this._entity.label = new Cesium$
|
|
2114
|
+
this._entity.label = new Cesium$e.LabelGraphics();
|
|
2107
2115
|
}
|
|
2108
2116
|
this._entity.label.font = font;
|
|
2109
2117
|
return this;
|
|
@@ -2111,7 +2119,7 @@ class PointWrapper {
|
|
|
2111
2119
|
|
|
2112
2120
|
setTextColor(color) {
|
|
2113
2121
|
if (!this._entity.label) {
|
|
2114
|
-
this._entity.label = new Cesium$
|
|
2122
|
+
this._entity.label = new Cesium$e.LabelGraphics();
|
|
2115
2123
|
}
|
|
2116
2124
|
this._entity.label.fillColor = color;
|
|
2117
2125
|
return this;
|
|
@@ -2119,7 +2127,7 @@ class PointWrapper {
|
|
|
2119
2127
|
|
|
2120
2128
|
setTextOutlineColor(color) {
|
|
2121
2129
|
if (!this._entity.label) {
|
|
2122
|
-
this._entity.label = new Cesium$
|
|
2130
|
+
this._entity.label = new Cesium$e.LabelGraphics();
|
|
2123
2131
|
}
|
|
2124
2132
|
this._entity.label.outlineColor = color;
|
|
2125
2133
|
return this;
|
|
@@ -2127,7 +2135,7 @@ class PointWrapper {
|
|
|
2127
2135
|
|
|
2128
2136
|
setTextOutlineWidth(width) {
|
|
2129
2137
|
if (!this._entity.label) {
|
|
2130
|
-
this._entity.label = new Cesium$
|
|
2138
|
+
this._entity.label = new Cesium$e.LabelGraphics();
|
|
2131
2139
|
}
|
|
2132
2140
|
this._entity.label.outlineWidth = width;
|
|
2133
2141
|
return this;
|
|
@@ -2135,19 +2143,19 @@ class PointWrapper {
|
|
|
2135
2143
|
|
|
2136
2144
|
setAlignType(alignType) {
|
|
2137
2145
|
if (!this._entity.label) {
|
|
2138
|
-
this._entity.label = new Cesium$
|
|
2146
|
+
this._entity.label = new Cesium$e.LabelGraphics();
|
|
2139
2147
|
}
|
|
2140
2148
|
// alignType: 0=CENTER, 1=LEFT, 2=RIGHT, 3=TOP, 4=BOTTOM
|
|
2141
|
-
const horizontalOrigins = [Cesium$
|
|
2142
|
-
const verticalOrigins = [Cesium$
|
|
2143
|
-
this._entity.label.horizontalOrigin = horizontalOrigins[alignType] || Cesium$
|
|
2144
|
-
this._entity.label.verticalOrigin = verticalOrigins[alignType] || Cesium$
|
|
2149
|
+
const horizontalOrigins = [Cesium$e.HorizontalOrigin.CENTER, Cesium$e.HorizontalOrigin.LEFT, Cesium$e.HorizontalOrigin.RIGHT];
|
|
2150
|
+
const verticalOrigins = [Cesium$e.VerticalOrigin.CENTER, Cesium$e.VerticalOrigin.CENTER, Cesium$e.VerticalOrigin.CENTER, Cesium$e.VerticalOrigin.TOP, Cesium$e.VerticalOrigin.BOTTOM];
|
|
2151
|
+
this._entity.label.horizontalOrigin = horizontalOrigins[alignType] || Cesium$e.HorizontalOrigin.CENTER;
|
|
2152
|
+
this._entity.label.verticalOrigin = verticalOrigins[alignType] || Cesium$e.VerticalOrigin.CENTER;
|
|
2145
2153
|
return this;
|
|
2146
2154
|
}
|
|
2147
2155
|
|
|
2148
2156
|
setTextPixelOffset(offset) {
|
|
2149
2157
|
if (!this._entity.label) {
|
|
2150
|
-
this._entity.label = new Cesium$
|
|
2158
|
+
this._entity.label = new Cesium$e.LabelGraphics();
|
|
2151
2159
|
}
|
|
2152
2160
|
this._entity.label.pixelOffset = offset;
|
|
2153
2161
|
return this;
|
|
@@ -2155,7 +2163,7 @@ class PointWrapper {
|
|
|
2155
2163
|
|
|
2156
2164
|
setTextScale(scale) {
|
|
2157
2165
|
if (!this._entity.label) {
|
|
2158
|
-
this._entity.label = new Cesium$
|
|
2166
|
+
this._entity.label = new Cesium$e.LabelGraphics();
|
|
2159
2167
|
}
|
|
2160
2168
|
this._entity.label.scale = scale;
|
|
2161
2169
|
return this;
|
|
@@ -2177,7 +2185,7 @@ class LineWrapper {
|
|
|
2177
2185
|
}
|
|
2178
2186
|
|
|
2179
2187
|
setPositions(coords) {
|
|
2180
|
-
this._entity.polyline.positions = Cesium$
|
|
2188
|
+
this._entity.polyline.positions = Cesium$e.Cartesian3.fromDegreesArrayHeights(
|
|
2181
2189
|
coords.flatMap(coord => [coord[0], coord[1], coord[2] || 0])
|
|
2182
2190
|
);
|
|
2183
2191
|
return this;
|
|
@@ -2221,23 +2229,23 @@ class LineWrapper {
|
|
|
2221
2229
|
*/
|
|
2222
2230
|
setLabel(text, options = {}) {
|
|
2223
2231
|
if (!this._entity.label) {
|
|
2224
|
-
this._entity.label = new Cesium$
|
|
2232
|
+
this._entity.label = new Cesium$e.LabelGraphics();
|
|
2225
2233
|
}
|
|
2226
2234
|
this._entity.label.text = text;
|
|
2227
2235
|
this._entity.label.font = options.font || '14px Microsoft YaHei';
|
|
2228
|
-
this._entity.label.fillColor = options.color || Cesium$
|
|
2229
|
-
this._entity.label.outlineColor = options.outlineColor || Cesium$
|
|
2236
|
+
this._entity.label.fillColor = options.color || Cesium$e.Color.WHITE;
|
|
2237
|
+
this._entity.label.outlineColor = options.outlineColor || Cesium$e.Color.BLACK;
|
|
2230
2238
|
this._entity.label.outlineWidth = options.outlineWidth ?? 1;
|
|
2231
2239
|
this._entity.label.show = true;
|
|
2232
|
-
this._entity.label.pixelOffset = options.pixelOffset || new Cesium$
|
|
2233
|
-
this._entity.label.horizontalOrigin = options.horizontalOrigin ?? Cesium$
|
|
2234
|
-
this._entity.label.verticalOrigin = options.verticalOrigin ?? Cesium$
|
|
2240
|
+
this._entity.label.pixelOffset = options.pixelOffset || new Cesium$e.Cartesian2(0, -10);
|
|
2241
|
+
this._entity.label.horizontalOrigin = options.horizontalOrigin ?? Cesium$e.HorizontalOrigin.CENTER;
|
|
2242
|
+
this._entity.label.verticalOrigin = options.verticalOrigin ?? Cesium$e.VerticalOrigin.BOTTOM;
|
|
2235
2243
|
|
|
2236
2244
|
// 使用 CallbackProperty 动态计算标签锚点,随编辑/平移自动更新
|
|
2237
2245
|
const self = this;
|
|
2238
|
-
this._entity.position = new Cesium$
|
|
2246
|
+
this._entity.position = new Cesium$e.CallbackProperty(function () {
|
|
2239
2247
|
const anchor = self._computeLabelAnchor();
|
|
2240
|
-
return Cesium$
|
|
2248
|
+
return Cesium$e.Cartesian3.fromDegrees(anchor[0], anchor[1], anchor[2] || 0);
|
|
2241
2249
|
}, false);
|
|
2242
2250
|
|
|
2243
2251
|
return this;
|
|
@@ -2260,13 +2268,13 @@ class LineWrapper {
|
|
|
2260
2268
|
return [x / cps.length, y / cps.length, z / cps.length];
|
|
2261
2269
|
}
|
|
2262
2270
|
|
|
2263
|
-
const positions = this._entity.polyline?.positions?.getValue(Cesium$
|
|
2271
|
+
const positions = this._entity.polyline?.positions?.getValue(Cesium$e.JulianDate.now());
|
|
2264
2272
|
if (positions && positions.length > 0) {
|
|
2265
2273
|
let lon = 0, lat = 0, height = 0;
|
|
2266
2274
|
positions.forEach(p => {
|
|
2267
|
-
const c = Cesium$
|
|
2268
|
-
lon += Cesium$
|
|
2269
|
-
lat += Cesium$
|
|
2275
|
+
const c = Cesium$e.Cartographic.fromCartesian(p);
|
|
2276
|
+
lon += Cesium$e.Math.toDegrees(c.longitude);
|
|
2277
|
+
lat += Cesium$e.Math.toDegrees(c.latitude);
|
|
2270
2278
|
height += c.height || 0;
|
|
2271
2279
|
});
|
|
2272
2280
|
const count = positions.length;
|
|
@@ -2339,8 +2347,8 @@ class PolygonWrapper {
|
|
|
2339
2347
|
}
|
|
2340
2348
|
|
|
2341
2349
|
setPositions(coords) {
|
|
2342
|
-
this._entity.polygon.hierarchy = new Cesium$
|
|
2343
|
-
Cesium$
|
|
2350
|
+
this._entity.polygon.hierarchy = new Cesium$e.PolygonHierarchy(
|
|
2351
|
+
Cesium$e.Cartesian3.fromDegreesArrayHeights(
|
|
2344
2352
|
coords.flatMap(coord => [coord[0], coord[1], coord[2] || 0])
|
|
2345
2353
|
)
|
|
2346
2354
|
);
|
|
@@ -2390,23 +2398,23 @@ class PolygonWrapper {
|
|
|
2390
2398
|
*/
|
|
2391
2399
|
setLabel(text, options = {}) {
|
|
2392
2400
|
if (!this._entity.label) {
|
|
2393
|
-
this._entity.label = new Cesium$
|
|
2401
|
+
this._entity.label = new Cesium$e.LabelGraphics();
|
|
2394
2402
|
}
|
|
2395
2403
|
this._entity.label.text = text;
|
|
2396
2404
|
this._entity.label.font = options.font || '14px Microsoft YaHei';
|
|
2397
|
-
this._entity.label.fillColor = options.color || Cesium$
|
|
2398
|
-
this._entity.label.outlineColor = options.outlineColor || Cesium$
|
|
2405
|
+
this._entity.label.fillColor = options.color || Cesium$e.Color.WHITE;
|
|
2406
|
+
this._entity.label.outlineColor = options.outlineColor || Cesium$e.Color.BLACK;
|
|
2399
2407
|
this._entity.label.outlineWidth = options.outlineWidth ?? 1;
|
|
2400
2408
|
this._entity.label.show = true;
|
|
2401
|
-
this._entity.label.pixelOffset = options.pixelOffset || new Cesium$
|
|
2402
|
-
this._entity.label.horizontalOrigin = options.horizontalOrigin ?? Cesium$
|
|
2403
|
-
this._entity.label.verticalOrigin = options.verticalOrigin ?? Cesium$
|
|
2409
|
+
this._entity.label.pixelOffset = options.pixelOffset || new Cesium$e.Cartesian2(0, -10);
|
|
2410
|
+
this._entity.label.horizontalOrigin = options.horizontalOrigin ?? Cesium$e.HorizontalOrigin.CENTER;
|
|
2411
|
+
this._entity.label.verticalOrigin = options.verticalOrigin ?? Cesium$e.VerticalOrigin.BOTTOM;
|
|
2404
2412
|
|
|
2405
2413
|
// 使用 CallbackProperty 动态计算标签锚点,随编辑/平移自动更新
|
|
2406
2414
|
const self = this;
|
|
2407
|
-
this._entity.position = new Cesium$
|
|
2415
|
+
this._entity.position = new Cesium$e.CallbackProperty(function () {
|
|
2408
2416
|
const anchor = self._computeLabelAnchor();
|
|
2409
|
-
return Cesium$
|
|
2417
|
+
return Cesium$e.Cartesian3.fromDegrees(anchor[0], anchor[1], anchor[2] || 0);
|
|
2410
2418
|
}, false);
|
|
2411
2419
|
|
|
2412
2420
|
return this;
|
|
@@ -2433,13 +2441,13 @@ class PolygonWrapper {
|
|
|
2433
2441
|
return [x / cps.length, y / cps.length, z / cps.length];
|
|
2434
2442
|
}
|
|
2435
2443
|
|
|
2436
|
-
const hierarchy = this._entity.polygon?.hierarchy?.getValue(Cesium$
|
|
2444
|
+
const hierarchy = this._entity.polygon?.hierarchy?.getValue(Cesium$e.JulianDate.now());
|
|
2437
2445
|
if (hierarchy && hierarchy.positions && hierarchy.positions.length > 0) {
|
|
2438
2446
|
let lon = 0, lat = 0, height = 0;
|
|
2439
2447
|
hierarchy.positions.forEach(p => {
|
|
2440
|
-
const c = Cesium$
|
|
2441
|
-
lon += Cesium$
|
|
2442
|
-
lat += Cesium$
|
|
2448
|
+
const c = Cesium$e.Cartographic.fromCartesian(p);
|
|
2449
|
+
lon += Cesium$e.Math.toDegrees(c.longitude);
|
|
2450
|
+
lat += Cesium$e.Math.toDegrees(c.latitude);
|
|
2443
2451
|
height += c.height || 0;
|
|
2444
2452
|
});
|
|
2445
2453
|
const count = hierarchy.positions.length;
|
|
@@ -2512,7 +2520,7 @@ class ModelWrapper {
|
|
|
2512
2520
|
}
|
|
2513
2521
|
|
|
2514
2522
|
setPosition(coords) {
|
|
2515
|
-
this._entity.position = Cesium$
|
|
2523
|
+
this._entity.position = Cesium$e.Cartesian3.fromDegrees(...coords);
|
|
2516
2524
|
return this;
|
|
2517
2525
|
}
|
|
2518
2526
|
|
|
@@ -2562,7 +2570,7 @@ class TextWrapper {
|
|
|
2562
2570
|
}
|
|
2563
2571
|
|
|
2564
2572
|
setPosition(coords) {
|
|
2565
|
-
this._entity.position = Cesium$
|
|
2573
|
+
this._entity.position = Cesium$e.Cartesian3.fromDegrees(...coords);
|
|
2566
2574
|
return this;
|
|
2567
2575
|
}
|
|
2568
2576
|
|
|
@@ -2608,10 +2616,10 @@ class TextWrapper {
|
|
|
2608
2616
|
}
|
|
2609
2617
|
|
|
2610
2618
|
setAlignType(alignType) {
|
|
2611
|
-
const horizontalOrigins = [Cesium$
|
|
2612
|
-
const verticalOrigins = [Cesium$
|
|
2613
|
-
this._entity.label.horizontalOrigin = horizontalOrigins[alignType] || Cesium$
|
|
2614
|
-
this._entity.label.verticalOrigin = verticalOrigins[alignType] || Cesium$
|
|
2619
|
+
const horizontalOrigins = [Cesium$e.HorizontalOrigin.CENTER, Cesium$e.HorizontalOrigin.LEFT, Cesium$e.HorizontalOrigin.RIGHT];
|
|
2620
|
+
const verticalOrigins = [Cesium$e.VerticalOrigin.CENTER, Cesium$e.VerticalOrigin.CENTER, Cesium$e.VerticalOrigin.CENTER, Cesium$e.VerticalOrigin.TOP, Cesium$e.VerticalOrigin.BOTTOM];
|
|
2621
|
+
this._entity.label.horizontalOrigin = horizontalOrigins[alignType] || Cesium$e.HorizontalOrigin.CENTER;
|
|
2622
|
+
this._entity.label.verticalOrigin = verticalOrigins[alignType] || Cesium$e.VerticalOrigin.CENTER;
|
|
2615
2623
|
return this;
|
|
2616
2624
|
}
|
|
2617
2625
|
|
|
@@ -2649,14 +2657,14 @@ class GraphicModule {
|
|
|
2649
2657
|
return this.wrapperMap.get(graphicId);
|
|
2650
2658
|
}
|
|
2651
2659
|
|
|
2652
|
-
const defaultStyle = this.config.graphic?.point || { pixelSize: 8, color: Cesium$
|
|
2660
|
+
const defaultStyle = this.config.graphic?.point || { pixelSize: 8, color: Cesium$e.Color.RED };
|
|
2653
2661
|
|
|
2654
2662
|
const entityOptions = {
|
|
2655
2663
|
id: graphicId,
|
|
2656
|
-
position: Cesium$
|
|
2664
|
+
position: Cesium$e.Cartesian3.fromDegrees(0, 0, 0),
|
|
2657
2665
|
point: {
|
|
2658
2666
|
...defaultStyle,
|
|
2659
|
-
outlineColor: Cesium$
|
|
2667
|
+
outlineColor: Cesium$e.Color.WHITE,
|
|
2660
2668
|
outlineWidth: 1
|
|
2661
2669
|
}
|
|
2662
2670
|
};
|
|
@@ -2690,12 +2698,12 @@ class GraphicModule {
|
|
|
2690
2698
|
return this.wrapperMap.get(graphicId);
|
|
2691
2699
|
}
|
|
2692
2700
|
|
|
2693
|
-
const defaultStyle = this.config.graphic?.line || { width: 2, material: Cesium$
|
|
2701
|
+
const defaultStyle = this.config.graphic?.line || { width: 2, material: Cesium$e.Color.BLUE };
|
|
2694
2702
|
|
|
2695
2703
|
const entityOptions = {
|
|
2696
2704
|
id: graphicId,
|
|
2697
2705
|
polyline: {
|
|
2698
|
-
positions: Cesium$
|
|
2706
|
+
positions: Cesium$e.Cartesian3.fromDegreesArrayHeights([0, 0, 0, 0, 0, 0]),
|
|
2699
2707
|
clampToGround: true,
|
|
2700
2708
|
...defaultStyle
|
|
2701
2709
|
}
|
|
@@ -2730,14 +2738,14 @@ class GraphicModule {
|
|
|
2730
2738
|
return this.wrapperMap.get(graphicId);
|
|
2731
2739
|
}
|
|
2732
2740
|
|
|
2733
|
-
const defaultStyle = this.config.graphic?.polygon || { color: Cesium$
|
|
2741
|
+
const defaultStyle = this.config.graphic?.polygon || { color: Cesium$e.Color.GREEN.withAlpha(0.5) };
|
|
2734
2742
|
|
|
2735
2743
|
const entityOptions = {
|
|
2736
2744
|
id: graphicId,
|
|
2737
2745
|
polygon: {
|
|
2738
|
-
hierarchy: new Cesium$
|
|
2746
|
+
hierarchy: new Cesium$e.PolygonHierarchy([]),
|
|
2739
2747
|
clampToGround: true,
|
|
2740
|
-
outlineColor: Cesium$
|
|
2748
|
+
outlineColor: Cesium$e.Color.WHITE,
|
|
2741
2749
|
outlineWidth: 1,
|
|
2742
2750
|
...defaultStyle
|
|
2743
2751
|
}
|
|
@@ -2774,7 +2782,7 @@ class GraphicModule {
|
|
|
2774
2782
|
|
|
2775
2783
|
const entityOptions = {
|
|
2776
2784
|
id: graphicId,
|
|
2777
|
-
position: Cesium$
|
|
2785
|
+
position: Cesium$e.Cartesian3.fromDegrees(0, 0, 0),
|
|
2778
2786
|
model: {
|
|
2779
2787
|
uri: "",
|
|
2780
2788
|
scale: 1.0,
|
|
@@ -2813,16 +2821,16 @@ class GraphicModule {
|
|
|
2813
2821
|
|
|
2814
2822
|
const entityOptions = {
|
|
2815
2823
|
id: graphicId,
|
|
2816
|
-
position: Cesium$
|
|
2824
|
+
position: Cesium$e.Cartesian3.fromDegrees(0, 0, 0),
|
|
2817
2825
|
label: {
|
|
2818
2826
|
text: "",
|
|
2819
2827
|
font: "16px Microsoft YaHei",
|
|
2820
|
-
fillColor: Cesium$
|
|
2821
|
-
outlineColor: Cesium$
|
|
2828
|
+
fillColor: Cesium$e.Color.WHITE,
|
|
2829
|
+
outlineColor: Cesium$e.Color.BLACK,
|
|
2822
2830
|
outlineWidth: 2,
|
|
2823
|
-
style: Cesium$
|
|
2824
|
-
verticalOrigin: Cesium$
|
|
2825
|
-
horizontalOrigin: Cesium$
|
|
2831
|
+
style: Cesium$e.LabelStyle.FILL_AND_OUTLINE,
|
|
2832
|
+
verticalOrigin: Cesium$e.VerticalOrigin.BOTTOM,
|
|
2833
|
+
horizontalOrigin: Cesium$e.HorizontalOrigin.CENTER
|
|
2826
2834
|
}
|
|
2827
2835
|
};
|
|
2828
2836
|
|
|
@@ -3056,7 +3064,7 @@ class GraphicModule {
|
|
|
3056
3064
|
}
|
|
3057
3065
|
}
|
|
3058
3066
|
|
|
3059
|
-
const Cesium$
|
|
3067
|
+
const Cesium$d = getCesium();
|
|
3060
3068
|
|
|
3061
3069
|
/**
|
|
3062
3070
|
* 事件模块(对应平台 IEventModule)
|
|
@@ -3154,7 +3162,7 @@ class EventModule {
|
|
|
3154
3162
|
switch (baseType) {
|
|
3155
3163
|
// 鼠标事件
|
|
3156
3164
|
case 'mouse':
|
|
3157
|
-
this.handlers[eventKey] = new Cesium$
|
|
3165
|
+
this.handlers[eventKey] = new Cesium$d.ScreenSpaceEventHandler(this.viewer.scene.canvas);
|
|
3158
3166
|
// 绑定鼠标事件
|
|
3159
3167
|
const mouseEventType = this.getCesiumMouseEventType(subType);
|
|
3160
3168
|
this.handlers[eventKey].setInputAction((movement) => {
|
|
@@ -3175,10 +3183,10 @@ class EventModule {
|
|
|
3175
3183
|
const pickedEntity = this.viewer.scene.pick(screenPos);
|
|
3176
3184
|
|
|
3177
3185
|
if (position) {
|
|
3178
|
-
const cartographic = Cesium$
|
|
3186
|
+
const cartographic = Cesium$d.Cartographic.fromCartesian(position);
|
|
3179
3187
|
lngLat = [
|
|
3180
|
-
Cesium$
|
|
3181
|
-
Cesium$
|
|
3188
|
+
Cesium$d.Math.toDegrees(cartographic.longitude),
|
|
3189
|
+
Cesium$d.Math.toDegrees(cartographic.latitude),
|
|
3182
3190
|
cartographic.height
|
|
3183
3191
|
];
|
|
3184
3192
|
}
|
|
@@ -3244,12 +3252,12 @@ class EventModule {
|
|
|
3244
3252
|
// ========== 工具方法:映射 Cesium 鼠标事件类型 ==========
|
|
3245
3253
|
getCesiumMouseEventType(subType) {
|
|
3246
3254
|
switch (subType) {
|
|
3247
|
-
case 'click': return Cesium$
|
|
3248
|
-
case 'rightclick': return Cesium$
|
|
3249
|
-
case 'move': return Cesium$
|
|
3250
|
-
case 'down': return Cesium$
|
|
3251
|
-
case 'up': return Cesium$
|
|
3252
|
-
default: return Cesium$
|
|
3255
|
+
case 'click': return Cesium$d.ScreenSpaceEventType.LEFT_CLICK;
|
|
3256
|
+
case 'rightclick': return Cesium$d.ScreenSpaceEventType.RIGHT_CLICK;
|
|
3257
|
+
case 'move': return Cesium$d.ScreenSpaceEventType.MOUSE_MOVE;
|
|
3258
|
+
case 'down': return Cesium$d.ScreenSpaceEventType.LEFT_DOWN;
|
|
3259
|
+
case 'up': return Cesium$d.ScreenSpaceEventType.LEFT_UP;
|
|
3260
|
+
default: return Cesium$d.ScreenSpaceEventType.LEFT_CLICK;
|
|
3253
3261
|
}
|
|
3254
3262
|
}
|
|
3255
3263
|
|
|
@@ -3257,18 +3265,18 @@ class EventModule {
|
|
|
3257
3265
|
getZoomLevel() {
|
|
3258
3266
|
const camera = this.viewer.camera;
|
|
3259
3267
|
const positionCartographic = camera.positionCartographic;
|
|
3260
|
-
const positionCartesian = Cesium$
|
|
3268
|
+
const positionCartesian = Cesium$d.Cartesian3.fromRadians(
|
|
3261
3269
|
positionCartographic.longitude,
|
|
3262
3270
|
positionCartographic.latitude,
|
|
3263
3271
|
positionCartographic.height
|
|
3264
3272
|
);
|
|
3265
|
-
const distance = Cesium$
|
|
3273
|
+
const distance = Cesium$d.Cartesian3.distance(camera.position, positionCartesian);
|
|
3266
3274
|
// 映射为 0-20 级缩放(类似地图瓦片级别)
|
|
3267
3275
|
return Math.floor(Math.log2(6378137 * 2 * Math.PI / distance)) + 1;
|
|
3268
3276
|
}
|
|
3269
3277
|
}
|
|
3270
3278
|
|
|
3271
|
-
const Cesium$
|
|
3279
|
+
const Cesium$c = getCesium();
|
|
3272
3280
|
|
|
3273
3281
|
/**
|
|
3274
3282
|
* 工具基类
|
|
@@ -3363,17 +3371,17 @@ class BaseTool {
|
|
|
3363
3371
|
// 如果拾取失败(空白区域),fallback 到椭球体表面
|
|
3364
3372
|
if (!cartesian) {
|
|
3365
3373
|
cartesian = this._viewer.camera.pickEllipsoid(
|
|
3366
|
-
new Cesium$
|
|
3374
|
+
new Cesium$c.Cartesian3(screenPos.x, screenPos.y),
|
|
3367
3375
|
this._viewer.scene.globe.ellipsoid
|
|
3368
3376
|
);
|
|
3369
3377
|
}
|
|
3370
3378
|
|
|
3371
3379
|
if (!cartesian) return null;
|
|
3372
3380
|
|
|
3373
|
-
const cartographic = Cesium$
|
|
3381
|
+
const cartographic = Cesium$c.Cartographic.fromCartesian(cartesian);
|
|
3374
3382
|
return [
|
|
3375
|
-
Cesium$
|
|
3376
|
-
Cesium$
|
|
3383
|
+
Cesium$c.Math.toDegrees(cartographic.longitude),
|
|
3384
|
+
Cesium$c.Math.toDegrees(cartographic.latitude),
|
|
3377
3385
|
cartographic.height
|
|
3378
3386
|
];
|
|
3379
3387
|
}
|
|
@@ -3384,8 +3392,8 @@ class BaseTool {
|
|
|
3384
3392
|
* @returns {Promise<number>} 地形高度
|
|
3385
3393
|
*/
|
|
3386
3394
|
async getTerrainHeight(lonLat) {
|
|
3387
|
-
const cartographic = Cesium$
|
|
3388
|
-
const result = await Cesium$
|
|
3395
|
+
const cartographic = Cesium$c.Cartographic.fromDegrees(lonLat[0], lonLat[1]);
|
|
3396
|
+
const result = await Cesium$c.sampleTerrainMostDetailed(
|
|
3389
3397
|
this._viewer.terrainProvider,
|
|
3390
3398
|
[cartographic]
|
|
3391
3399
|
);
|
|
@@ -3426,7 +3434,7 @@ class BaseTool {
|
|
|
3426
3434
|
}
|
|
3427
3435
|
}
|
|
3428
3436
|
|
|
3429
|
-
const Cesium$
|
|
3437
|
+
const Cesium$b = getCesium();
|
|
3430
3438
|
|
|
3431
3439
|
/**
|
|
3432
3440
|
* 绘制类型枚举
|
|
@@ -3713,7 +3721,7 @@ class DrawTool extends BaseTool {
|
|
|
3713
3721
|
const id = this.generateId('point');
|
|
3714
3722
|
this._graphicModule.CreatePoint(id)
|
|
3715
3723
|
.setPosition(lonLat)
|
|
3716
|
-
.setColor(Cesium$
|
|
3724
|
+
.setColor(Cesium$b.Color.RED)
|
|
3717
3725
|
.setPixelSize(10);
|
|
3718
3726
|
|
|
3719
3727
|
this._emitGraphicCreated('point', id);
|
|
@@ -3725,9 +3733,9 @@ class DrawTool extends BaseTool {
|
|
|
3725
3733
|
|
|
3726
3734
|
// 创建辅助点
|
|
3727
3735
|
const tempPoint = this.createTempEntity(this.generateId('temp_point'), {
|
|
3728
|
-
position: Cesium$
|
|
3736
|
+
position: Cesium$b.Cartesian3.fromDegrees(...lonLat),
|
|
3729
3737
|
point: {
|
|
3730
|
-
color: Cesium$
|
|
3738
|
+
color: Cesium$b.Color.YELLOW,
|
|
3731
3739
|
pixelSize: 8
|
|
3732
3740
|
}
|
|
3733
3741
|
});
|
|
@@ -3747,9 +3755,9 @@ class DrawTool extends BaseTool {
|
|
|
3747
3755
|
|
|
3748
3756
|
// 创建辅助点
|
|
3749
3757
|
const tempPoint = this.createTempEntity(this.generateId('temp_point'), {
|
|
3750
|
-
position: Cesium$
|
|
3758
|
+
position: Cesium$b.Cartesian3.fromDegrees(...lonLat),
|
|
3751
3759
|
point: {
|
|
3752
|
-
color: Cesium$
|
|
3760
|
+
color: Cesium$b.Color.YELLOW,
|
|
3753
3761
|
pixelSize: 8
|
|
3754
3762
|
}
|
|
3755
3763
|
});
|
|
@@ -3769,9 +3777,9 @@ class DrawTool extends BaseTool {
|
|
|
3769
3777
|
this._startPos = lonLat;
|
|
3770
3778
|
// 创建起始点标记
|
|
3771
3779
|
const startMarker = this.createTempEntity(this.generateId('temp_start'), {
|
|
3772
|
-
position: Cesium$
|
|
3780
|
+
position: Cesium$b.Cartesian3.fromDegrees(...lonLat),
|
|
3773
3781
|
point: {
|
|
3774
|
-
color: Cesium$
|
|
3782
|
+
color: Cesium$b.Color.YELLOW,
|
|
3775
3783
|
pixelSize: 10
|
|
3776
3784
|
}
|
|
3777
3785
|
});
|
|
@@ -3786,9 +3794,9 @@ class DrawTool extends BaseTool {
|
|
|
3786
3794
|
if (!this._startPos) {
|
|
3787
3795
|
this._startPos = lonLat;
|
|
3788
3796
|
const startMarker = this.createTempEntity(this.generateId('temp_start'), {
|
|
3789
|
-
position: Cesium$
|
|
3797
|
+
position: Cesium$b.Cartesian3.fromDegrees(...lonLat),
|
|
3790
3798
|
point: {
|
|
3791
|
-
color: Cesium$
|
|
3799
|
+
color: Cesium$b.Color.YELLOW,
|
|
3792
3800
|
pixelSize: 10
|
|
3793
3801
|
}
|
|
3794
3802
|
});
|
|
@@ -3810,14 +3818,14 @@ class DrawTool extends BaseTool {
|
|
|
3810
3818
|
for (const c of previewPositions) {
|
|
3811
3819
|
flatCoords.push(c[0], c[1], c[2] || 0);
|
|
3812
3820
|
}
|
|
3813
|
-
const cartesians = Cesium$
|
|
3821
|
+
const cartesians = Cesium$b.Cartesian3.fromDegreesArrayHeights(flatCoords);
|
|
3814
3822
|
|
|
3815
3823
|
if (!this._previewLine) {
|
|
3816
3824
|
// 首次创建预览线
|
|
3817
3825
|
this._previewLine = this.createTempEntity(this.generateId('temp_line'), {
|
|
3818
3826
|
polyline: {
|
|
3819
3827
|
positions: cartesians,
|
|
3820
|
-
material: Cesium$
|
|
3828
|
+
material: Cesium$b.Color.YELLOW,
|
|
3821
3829
|
width: 2
|
|
3822
3830
|
}
|
|
3823
3831
|
});
|
|
@@ -3825,7 +3833,7 @@ class DrawTool extends BaseTool {
|
|
|
3825
3833
|
} else {
|
|
3826
3834
|
// 直接更新位置属性,避免重建实体
|
|
3827
3835
|
// this._previewLine.polyline.positions = cartesians;
|
|
3828
|
-
this._previewLine.polyline.positions = new Cesium$
|
|
3836
|
+
this._previewLine.polyline.positions = new Cesium$b.CallbackProperty(() => {
|
|
3829
3837
|
return cartesians;
|
|
3830
3838
|
}, false);
|
|
3831
3839
|
}
|
|
@@ -3845,23 +3853,23 @@ class DrawTool extends BaseTool {
|
|
|
3845
3853
|
for (const c of previewPositions) {
|
|
3846
3854
|
flatCoords.push(c[0], c[1], c[2] || 0);
|
|
3847
3855
|
}
|
|
3848
|
-
const cartesians = Cesium$
|
|
3856
|
+
const cartesians = Cesium$b.Cartesian3.fromDegreesArrayHeights(flatCoords);
|
|
3849
3857
|
|
|
3850
3858
|
if (!this._previewPolygon) {
|
|
3851
3859
|
// 首次创建预览面
|
|
3852
3860
|
this._previewPolygon = this.createTempEntity(this.generateId('temp_polygon'), {
|
|
3853
3861
|
polygon: {
|
|
3854
|
-
hierarchy: new Cesium$
|
|
3855
|
-
material: Cesium$
|
|
3862
|
+
hierarchy: new Cesium$b.PolygonHierarchy(cartesians),
|
|
3863
|
+
material: Cesium$b.Color.YELLOW.withAlpha(0.5),
|
|
3856
3864
|
outline: false,
|
|
3857
|
-
outlineColor: Cesium$
|
|
3865
|
+
outlineColor: Cesium$b.Color.YELLOW,
|
|
3858
3866
|
}
|
|
3859
3867
|
});
|
|
3860
3868
|
this._tempEntities.push(this._previewPolygon);
|
|
3861
3869
|
} else {
|
|
3862
3870
|
// 直接更新层级,避免重建实体,使用 CallbackProperty 防止闪烁
|
|
3863
|
-
this._previewPolygon.polygon.hierarchy = new Cesium$
|
|
3864
|
-
return new Cesium$
|
|
3871
|
+
this._previewPolygon.polygon.hierarchy = new Cesium$b.CallbackProperty(() => {
|
|
3872
|
+
return new Cesium$b.PolygonHierarchy(cartesians);
|
|
3865
3873
|
}, false);
|
|
3866
3874
|
}
|
|
3867
3875
|
}
|
|
@@ -3893,18 +3901,18 @@ class DrawTool extends BaseTool {
|
|
|
3893
3901
|
for (const c of positions) {
|
|
3894
3902
|
flatCoords.push(c[0], c[1], 0);
|
|
3895
3903
|
}
|
|
3896
|
-
const cartesians = Cesium$
|
|
3904
|
+
const cartesians = Cesium$b.Cartesian3.fromDegreesArrayHeights(flatCoords);
|
|
3897
3905
|
|
|
3898
3906
|
if (!this._previewRect) {
|
|
3899
3907
|
this._previewRect = this.createTempEntity(this.generateId('temp_rect'), {
|
|
3900
3908
|
polyline: {
|
|
3901
|
-
positions: new Cesium$
|
|
3902
|
-
material: Cesium$
|
|
3909
|
+
positions: new Cesium$b.CallbackProperty(() => cartesians, false),
|
|
3910
|
+
material: Cesium$b.Color.YELLOW.withAlpha(0.7),
|
|
3903
3911
|
width: 2
|
|
3904
3912
|
},
|
|
3905
3913
|
polygon: {
|
|
3906
|
-
hierarchy: new Cesium$
|
|
3907
|
-
material: Cesium$
|
|
3914
|
+
hierarchy: new Cesium$b.CallbackProperty(() => new Cesium$b.PolygonHierarchy(cartesians), false),
|
|
3915
|
+
material: Cesium$b.Color.YELLOW.withAlpha(0.2),
|
|
3908
3916
|
outline: false
|
|
3909
3917
|
}
|
|
3910
3918
|
});
|
|
@@ -3912,7 +3920,7 @@ class DrawTool extends BaseTool {
|
|
|
3912
3920
|
this._tempEntities.push(this._previewRect);
|
|
3913
3921
|
} else {
|
|
3914
3922
|
// 直接更新位置属性
|
|
3915
|
-
this._previewRect.polyline.positions = new Cesium$
|
|
3923
|
+
this._previewRect.polyline.positions = new Cesium$b.CallbackProperty(() => {
|
|
3916
3924
|
const c1 = this._startPos;
|
|
3917
3925
|
const c2 = this._currentMousePos;
|
|
3918
3926
|
if (!c1 || !c2) return cartesians;
|
|
@@ -3927,12 +3935,12 @@ class DrawTool extends BaseTool {
|
|
|
3927
3935
|
for (const p of pos) {
|
|
3928
3936
|
flat.push(p[0], p[1], 0);
|
|
3929
3937
|
}
|
|
3930
|
-
return Cesium$
|
|
3938
|
+
return Cesium$b.Cartesian3.fromDegreesArrayHeights(flat);
|
|
3931
3939
|
}, false);
|
|
3932
|
-
this._previewRect.polygon.hierarchy = new Cesium$
|
|
3940
|
+
this._previewRect.polygon.hierarchy = new Cesium$b.CallbackProperty(() => {
|
|
3933
3941
|
const c1 = this._startPos;
|
|
3934
3942
|
const c2 = this._currentMousePos;
|
|
3935
|
-
if (!c1 || !c2) return new Cesium$
|
|
3943
|
+
if (!c1 || !c2) return new Cesium$b.PolygonHierarchy(cartesians);
|
|
3936
3944
|
const pos = [
|
|
3937
3945
|
[c1[0], c1[1]],
|
|
3938
3946
|
[c2[0], c1[1]],
|
|
@@ -3944,7 +3952,7 @@ class DrawTool extends BaseTool {
|
|
|
3944
3952
|
for (const p of pos) {
|
|
3945
3953
|
flat.push(p[0], p[1], 0);
|
|
3946
3954
|
}
|
|
3947
|
-
return new Cesium$
|
|
3955
|
+
return new Cesium$b.PolygonHierarchy(Cesium$b.Cartesian3.fromDegreesArrayHeights(flat));
|
|
3948
3956
|
}, false);
|
|
3949
3957
|
}
|
|
3950
3958
|
}
|
|
@@ -3957,12 +3965,12 @@ class DrawTool extends BaseTool {
|
|
|
3957
3965
|
if (!this._previewCircle) {
|
|
3958
3966
|
this._previewCircle = this.createTempEntity(this.generateId('temp_circle'), {
|
|
3959
3967
|
polygon: {
|
|
3960
|
-
hierarchy: new Cesium$
|
|
3968
|
+
hierarchy: new Cesium$b.CallbackProperty(() => {
|
|
3961
3969
|
const positions = this._generateCirclePositions(center, radius, segments);
|
|
3962
3970
|
const flat = positions.flatMap(c => [c[0], c[1], 0]);
|
|
3963
|
-
return new Cesium$
|
|
3971
|
+
return new Cesium$b.PolygonHierarchy(Cesium$b.Cartesian3.fromDegreesArrayHeights(flat));
|
|
3964
3972
|
}, false),
|
|
3965
|
-
material: Cesium$
|
|
3973
|
+
material: Cesium$b.Color.YELLOW.withAlpha(0.2),
|
|
3966
3974
|
outline: false // 地形贴合时不支持 outline,设为 false 避免警告
|
|
3967
3975
|
}
|
|
3968
3976
|
});
|
|
@@ -3970,11 +3978,11 @@ class DrawTool extends BaseTool {
|
|
|
3970
3978
|
this._tempEntities.push(this._previewCircle);
|
|
3971
3979
|
} else {
|
|
3972
3980
|
// 直接更新
|
|
3973
|
-
this._previewCircle.polygon.hierarchy = new Cesium$
|
|
3981
|
+
this._previewCircle.polygon.hierarchy = new Cesium$b.CallbackProperty(() => {
|
|
3974
3982
|
const r = this._calcDistance(this._startPos, this._currentMousePos);
|
|
3975
3983
|
const pos = this._generateCirclePositions(this._startPos, r, 64);
|
|
3976
3984
|
const flat = pos.flatMap(c => [c[0], c[1], 0]);
|
|
3977
|
-
return new Cesium$
|
|
3985
|
+
return new Cesium$b.PolygonHierarchy(Cesium$b.Cartesian3.fromDegreesArrayHeights(flat));
|
|
3978
3986
|
}, false);
|
|
3979
3987
|
}
|
|
3980
3988
|
}
|
|
@@ -3991,10 +3999,10 @@ class DrawTool extends BaseTool {
|
|
|
3991
3999
|
const id = this.generateId('rectangle');
|
|
3992
4000
|
this._graphicModule.CreatePolygon(id)
|
|
3993
4001
|
.setPositions(positions)
|
|
3994
|
-
.setColor(Cesium$
|
|
3995
|
-
.setOutlineColor(Cesium$
|
|
4002
|
+
.setColor(Cesium$b.Color.BLUE.withAlpha(0.5))
|
|
4003
|
+
.setOutlineColor(Cesium$b.Color.BLUE)
|
|
3996
4004
|
.setOutlineWidth(2)
|
|
3997
|
-
.setHeightReference(Cesium$
|
|
4005
|
+
.setHeightReference(Cesium$b.HeightReference.NONE);
|
|
3998
4006
|
|
|
3999
4007
|
this.clearTempEntities();
|
|
4000
4008
|
this._startPos = null;
|
|
@@ -4012,8 +4020,8 @@ class DrawTool extends BaseTool {
|
|
|
4012
4020
|
// 创建圆并标记为圆形
|
|
4013
4021
|
const wrapper = this._graphicModule.CreatePolygon(id);
|
|
4014
4022
|
wrapper.setPositions(positions)
|
|
4015
|
-
.setColor(Cesium$
|
|
4016
|
-
.setOutlineColor(Cesium$
|
|
4023
|
+
.setColor(Cesium$b.Color.BLUE.withAlpha(0.5))
|
|
4024
|
+
.setOutlineColor(Cesium$b.Color.BLUE)
|
|
4017
4025
|
.setOutlineWidth(2);
|
|
4018
4026
|
|
|
4019
4027
|
// 给 entity 添加圆形标记(用于 EditTool 特殊处理)
|
|
@@ -4110,9 +4118,9 @@ class DrawTool extends BaseTool {
|
|
|
4110
4118
|
|
|
4111
4119
|
// 创建辅助点
|
|
4112
4120
|
const tempPoint = this.createTempEntity(this.generateId('temp_point'), {
|
|
4113
|
-
position: Cesium$
|
|
4121
|
+
position: Cesium$b.Cartesian3.fromDegrees(...lngLat),
|
|
4114
4122
|
point: {
|
|
4115
|
-
color: Cesium$
|
|
4123
|
+
color: Cesium$b.Color.YELLOW,
|
|
4116
4124
|
pixelSize: 8
|
|
4117
4125
|
}
|
|
4118
4126
|
});
|
|
@@ -4167,27 +4175,28 @@ class DrawTool extends BaseTool {
|
|
|
4167
4175
|
for (const c of positions) {
|
|
4168
4176
|
flatCoords.push(c[0], c[1], c[2] || 0);
|
|
4169
4177
|
}
|
|
4170
|
-
const cartesians = Cesium$
|
|
4178
|
+
const cartesians = Cesium$b.Cartesian3.fromDegreesArrayHeights(flatCoords);
|
|
4171
4179
|
|
|
4172
4180
|
if (!this._previewPlot) {
|
|
4173
4181
|
if (isLine) {
|
|
4174
4182
|
this._previewPlot = this.createTempEntity(this.generateId('temp_plot'), {
|
|
4175
4183
|
polyline: {
|
|
4176
|
-
positions: new Cesium$
|
|
4177
|
-
material: Cesium$
|
|
4178
|
-
width: 2
|
|
4184
|
+
positions: new Cesium$b.CallbackProperty(() => cartesians, false),
|
|
4185
|
+
material: Cesium$b.Color.YELLOW,
|
|
4186
|
+
width: 2,
|
|
4187
|
+
clampToGround: true
|
|
4179
4188
|
}
|
|
4180
4189
|
});
|
|
4181
4190
|
} else {
|
|
4182
4191
|
this._previewPlot = this.createTempEntity(this.generateId('temp_plot'), {
|
|
4183
4192
|
polygon: {
|
|
4184
|
-
hierarchy: new Cesium$
|
|
4185
|
-
material: Cesium$
|
|
4193
|
+
hierarchy: new Cesium$b.CallbackProperty(() => new Cesium$b.PolygonHierarchy(cartesians), false),
|
|
4194
|
+
material: Cesium$b.Color.YELLOW.withAlpha(0.3),
|
|
4186
4195
|
outline: false
|
|
4187
4196
|
},
|
|
4188
4197
|
polyline: {
|
|
4189
|
-
positions: new Cesium$
|
|
4190
|
-
material: Cesium$
|
|
4198
|
+
positions: new Cesium$b.CallbackProperty(() => [...cartesians, cartesians[0]], false),
|
|
4199
|
+
material: Cesium$b.Color.YELLOW,
|
|
4191
4200
|
width: 1
|
|
4192
4201
|
}
|
|
4193
4202
|
});
|
|
@@ -4197,7 +4206,7 @@ class DrawTool extends BaseTool {
|
|
|
4197
4206
|
} else {
|
|
4198
4207
|
const self = this;
|
|
4199
4208
|
if (isLine) {
|
|
4200
|
-
this._previewPlot.polyline.positions = new Cesium$
|
|
4209
|
+
this._previewPlot.polyline.positions = new Cesium$b.CallbackProperty(() => {
|
|
4201
4210
|
const dynamicPositions = [...self._tempPositions];
|
|
4202
4211
|
if (self._currentMousePos) {
|
|
4203
4212
|
dynamicPositions.push(self._currentMousePos);
|
|
@@ -4208,23 +4217,23 @@ class DrawTool extends BaseTool {
|
|
|
4208
4217
|
for (const c of pos) {
|
|
4209
4218
|
flat.push(c[0], c[1], c[2] || 0);
|
|
4210
4219
|
}
|
|
4211
|
-
return Cesium$
|
|
4220
|
+
return Cesium$b.Cartesian3.fromDegreesArrayHeights(flat);
|
|
4212
4221
|
}, false);
|
|
4213
4222
|
} else {
|
|
4214
|
-
this._previewPlot.polygon.hierarchy = new Cesium$
|
|
4223
|
+
this._previewPlot.polygon.hierarchy = new Cesium$b.CallbackProperty(() => {
|
|
4215
4224
|
const dynamicPositions = [...self._tempPositions];
|
|
4216
4225
|
if (self._currentMousePos) {
|
|
4217
4226
|
dynamicPositions.push(self._currentMousePos);
|
|
4218
4227
|
}
|
|
4219
|
-
if (dynamicPositions.length < config.minPoints) return new Cesium$
|
|
4228
|
+
if (dynamicPositions.length < config.minPoints) return new Cesium$b.PolygonHierarchy([]);
|
|
4220
4229
|
const pos = PlotGeometryUtil[factoryName](normalizeForEllipse(dynamicPositions));
|
|
4221
4230
|
const flat = [];
|
|
4222
4231
|
for (const c of pos) {
|
|
4223
4232
|
flat.push(c[0], c[1], c[2] || 0);
|
|
4224
4233
|
}
|
|
4225
|
-
return new Cesium$
|
|
4234
|
+
return new Cesium$b.PolygonHierarchy(Cesium$b.Cartesian3.fromDegreesArrayHeights(flat));
|
|
4226
4235
|
}, false);
|
|
4227
|
-
this._previewPlot.polyline.positions = new Cesium$
|
|
4236
|
+
this._previewPlot.polyline.positions = new Cesium$b.CallbackProperty(() => {
|
|
4228
4237
|
const dynamicPositions = [...self._tempPositions];
|
|
4229
4238
|
if (self._currentMousePos) {
|
|
4230
4239
|
dynamicPositions.push(self._currentMousePos);
|
|
@@ -4235,7 +4244,7 @@ class DrawTool extends BaseTool {
|
|
|
4235
4244
|
for (const c of pos) {
|
|
4236
4245
|
flat.push(c[0], c[1], c[2] || 0);
|
|
4237
4246
|
}
|
|
4238
|
-
const cart = Cesium$
|
|
4247
|
+
const cart = Cesium$b.Cartesian3.fromDegreesArrayHeights(flat);
|
|
4239
4248
|
return [...cart, cart[0]];
|
|
4240
4249
|
}, false);
|
|
4241
4250
|
}
|
|
@@ -4272,11 +4281,11 @@ class DrawTool extends BaseTool {
|
|
|
4272
4281
|
|
|
4273
4282
|
// 应用默认样式
|
|
4274
4283
|
if (isLine) {
|
|
4275
|
-
wrapper.setColor(Cesium$
|
|
4284
|
+
wrapper.setColor(Cesium$b.Color.BLUE).setWidth(2);
|
|
4276
4285
|
} else {
|
|
4277
4286
|
wrapper
|
|
4278
|
-
.setColor(Cesium$
|
|
4279
|
-
.setOutlineColor(Cesium$
|
|
4287
|
+
.setColor(Cesium$b.Color.BLUE.withAlpha(0.5))
|
|
4288
|
+
.setOutlineColor(Cesium$b.Color.BLUE)
|
|
4280
4289
|
.setOutlineWidth(2);
|
|
4281
4290
|
}
|
|
4282
4291
|
|
|
@@ -4329,7 +4338,7 @@ class DrawTool extends BaseTool {
|
|
|
4329
4338
|
const id = this.generateId('line');
|
|
4330
4339
|
this._graphicModule.CreateLine(id)
|
|
4331
4340
|
.setPositions(this._tempPositions)
|
|
4332
|
-
.setColor(Cesium$
|
|
4341
|
+
.setColor(Cesium$b.Color.BLUE)
|
|
4333
4342
|
.setWidth(2);
|
|
4334
4343
|
|
|
4335
4344
|
this._emitGraphicCreated('line', id);
|
|
@@ -4338,17 +4347,38 @@ class DrawTool extends BaseTool {
|
|
|
4338
4347
|
const id = this.generateId('polygon');
|
|
4339
4348
|
this._graphicModule.CreatePolygon(id)
|
|
4340
4349
|
.setPositions(positions)
|
|
4341
|
-
.setColor(Cesium$
|
|
4342
|
-
.setOutlineColor(Cesium$
|
|
4350
|
+
.setColor(Cesium$b.Color.BLUE.withAlpha(0.5))
|
|
4351
|
+
.setOutlineColor(Cesium$b.Color.BLUE);
|
|
4343
4352
|
|
|
4344
4353
|
this._emitGraphicCreated('polygon', id);
|
|
4345
4354
|
}
|
|
4346
4355
|
|
|
4356
|
+
// 线绘制结束时,把预览线样式切为最终样式并延迟一帧移除,
|
|
4357
|
+
// 避免新线图元异步初始化期间出现“预览线消失 -> 正式线出现”的闪烁
|
|
4358
|
+
let deferredPreviewLine = null;
|
|
4359
|
+
if (this._drawType === DrawType.LINE && this._previewLine) {
|
|
4360
|
+
const previewLine = this._previewLine;
|
|
4361
|
+
previewLine.polyline.material = Cesium$b.Color.BLUE;
|
|
4362
|
+
previewLine.polyline.width = 2;
|
|
4363
|
+
previewLine.polyline.positions = Cesium$b.Cartesian3.fromDegreesArrayHeights(
|
|
4364
|
+
this._tempPositions.flatMap((coord) => [coord[0], coord[1], coord[2] || 0])
|
|
4365
|
+
);
|
|
4366
|
+
|
|
4367
|
+
const idx = this._tempEntities.indexOf(previewLine);
|
|
4368
|
+
if (idx > -1) this._tempEntities.splice(idx, 1);
|
|
4369
|
+
this._previewLine = null;
|
|
4370
|
+
deferredPreviewLine = previewLine;
|
|
4371
|
+
}
|
|
4372
|
+
|
|
4347
4373
|
this.clearTempEntities();
|
|
4348
4374
|
this._tempPositions = [];
|
|
4349
4375
|
this._isDrawing = false;
|
|
4350
4376
|
this._clickCount = 0;
|
|
4351
4377
|
this._currentMousePos = null;
|
|
4378
|
+
|
|
4379
|
+
if (deferredPreviewLine) {
|
|
4380
|
+
requestAnimationFrame(() => this.removeTempEntity(deferredPreviewLine));
|
|
4381
|
+
}
|
|
4352
4382
|
}
|
|
4353
4383
|
|
|
4354
4384
|
/**
|
|
@@ -4386,7 +4416,7 @@ class DrawTool extends BaseTool {
|
|
|
4386
4416
|
}
|
|
4387
4417
|
}
|
|
4388
4418
|
|
|
4389
|
-
const Cesium$
|
|
4419
|
+
const Cesium$a = getCesium();
|
|
4390
4420
|
|
|
4391
4421
|
/**
|
|
4392
4422
|
* 编辑模式枚举
|
|
@@ -4471,7 +4501,7 @@ class EditTool extends BaseTool {
|
|
|
4471
4501
|
const picked = this._viewer.scene.pick(screenPos);
|
|
4472
4502
|
console.log('EditTool _onClick:', { picked, screenPos });
|
|
4473
4503
|
|
|
4474
|
-
if (Cesium$
|
|
4504
|
+
if (Cesium$a.defined(picked) && Cesium$a.defined(picked.id)) {
|
|
4475
4505
|
const entityId = picked.id.id;
|
|
4476
4506
|
console.log('EditTool picked entity:', entityId);
|
|
4477
4507
|
|
|
@@ -4507,7 +4537,7 @@ class EditTool extends BaseTool {
|
|
|
4507
4537
|
// 如果已经选中了图元,检查是否点击了控制点
|
|
4508
4538
|
if (this._selectedEntity && !this._isDragging) {
|
|
4509
4539
|
const picked = this._viewer.scene.pick(screenPos);
|
|
4510
|
-
if (Cesium$
|
|
4540
|
+
if (Cesium$a.defined(picked) && Cesium$a.defined(picked.id)) {
|
|
4511
4541
|
const entityId = picked.id.id;
|
|
4512
4542
|
if (entityId && (entityId.startsWith('__edit_handle_') || entityId.includes('__edit_handle_'))) {
|
|
4513
4543
|
// 直接在 _editHandles 中查找被点击的控制点
|
|
@@ -4560,7 +4590,7 @@ class EditTool extends BaseTool {
|
|
|
4560
4590
|
|
|
4561
4591
|
// 检测是否悬停在控制点上
|
|
4562
4592
|
const picked = this._viewer.scene.pick(screenPos);
|
|
4563
|
-
const isOverHandle = Cesium$
|
|
4593
|
+
const isOverHandle = Cesium$a.defined(picked) && Cesium$a.defined(picked.id) &&
|
|
4564
4594
|
picked.id.id && picked.id.id.startsWith('__edit_handle_');
|
|
4565
4595
|
this._setCursorStyle(isOverHandle ? 'move' : 'default');
|
|
4566
4596
|
}
|
|
@@ -4571,14 +4601,14 @@ class EditTool extends BaseTool {
|
|
|
4571
4601
|
// 拖拽时优先使用椭球面拾取,避免拾取到控制点句柄本身导致图元跟随滞后
|
|
4572
4602
|
let lonLat = null;
|
|
4573
4603
|
const cartesian = this._viewer.camera.pickEllipsoid(
|
|
4574
|
-
new Cesium$
|
|
4604
|
+
new Cesium$a.Cartesian2(screenPos.x, screenPos.y),
|
|
4575
4605
|
this._viewer.scene.globe.ellipsoid
|
|
4576
4606
|
);
|
|
4577
4607
|
if (cartesian) {
|
|
4578
|
-
const c = Cesium$
|
|
4608
|
+
const c = Cesium$a.Cartographic.fromCartesian(cartesian);
|
|
4579
4609
|
lonLat = [
|
|
4580
|
-
Cesium$
|
|
4581
|
-
Cesium$
|
|
4610
|
+
Cesium$a.Math.toDegrees(c.longitude),
|
|
4611
|
+
Cesium$a.Math.toDegrees(c.latitude),
|
|
4582
4612
|
c.height || 0
|
|
4583
4613
|
];
|
|
4584
4614
|
} else {
|
|
@@ -4602,16 +4632,16 @@ class EditTool extends BaseTool {
|
|
|
4602
4632
|
const deltaZ = newAnchorCartesian.z - oldAnchorCartesian.z;
|
|
4603
4633
|
|
|
4604
4634
|
const controlPoints = this._selectedEntity._controlPoints.map(cp => {
|
|
4605
|
-
const cpCart = Cesium$
|
|
4606
|
-
const newCpCart = new Cesium$
|
|
4635
|
+
const cpCart = Cesium$a.Cartesian3.fromDegrees(cp[0], cp[1], cp[2] || 0);
|
|
4636
|
+
const newCpCart = new Cesium$a.Cartesian3(
|
|
4607
4637
|
cpCart.x + deltaX,
|
|
4608
4638
|
cpCart.y + deltaY,
|
|
4609
4639
|
cpCart.z + deltaZ
|
|
4610
4640
|
);
|
|
4611
|
-
const newCpCarto = Cesium$
|
|
4641
|
+
const newCpCarto = Cesium$a.Cartographic.fromCartesian(newCpCart);
|
|
4612
4642
|
return [
|
|
4613
|
-
Cesium$
|
|
4614
|
-
Cesium$
|
|
4643
|
+
Cesium$a.Math.toDegrees(newCpCarto.longitude),
|
|
4644
|
+
Cesium$a.Math.toDegrees(newCpCarto.latitude),
|
|
4615
4645
|
newCpCarto.height || 0
|
|
4616
4646
|
];
|
|
4617
4647
|
});
|
|
@@ -4632,8 +4662,8 @@ class EditTool extends BaseTool {
|
|
|
4632
4662
|
const center = (plotType === PlotGraphicType.SECTOR || plotType === PlotGraphicType.ELLIPSE)
|
|
4633
4663
|
? controlPoints[0]
|
|
4634
4664
|
: this._getPlotControlPointsCenter(controlPoints);
|
|
4635
|
-
handle.position = new Cesium$
|
|
4636
|
-
this._clampPositionToGround(Cesium$
|
|
4665
|
+
handle.position = new Cesium$a.ConstantPositionProperty(
|
|
4666
|
+
this._clampPositionToGround(Cesium$a.Cartesian3.fromDegrees(center[0], center[1], center[2] || 0))
|
|
4637
4667
|
);
|
|
4638
4668
|
return;
|
|
4639
4669
|
}
|
|
@@ -4642,8 +4672,8 @@ class EditTool extends BaseTool {
|
|
|
4642
4672
|
if (match) {
|
|
4643
4673
|
const cpIndex = parseInt(match[1], 10);
|
|
4644
4674
|
const cp = controlPoints[cpIndex];
|
|
4645
|
-
handle.position = new Cesium$
|
|
4646
|
-
this._clampPositionToGround(Cesium$
|
|
4675
|
+
handle.position = new Cesium$a.ConstantPositionProperty(
|
|
4676
|
+
this._clampPositionToGround(Cesium$a.Cartesian3.fromDegrees(cp[0], cp[1], cp[2] || 0))
|
|
4647
4677
|
);
|
|
4648
4678
|
}
|
|
4649
4679
|
});
|
|
@@ -4711,10 +4741,10 @@ class EditTool extends BaseTool {
|
|
|
4711
4741
|
*/
|
|
4712
4742
|
_clampPositionToGround(position) {
|
|
4713
4743
|
if (!position) return position;
|
|
4714
|
-
const cartographic = Cesium$
|
|
4715
|
-
return Cesium$
|
|
4716
|
-
Cesium$
|
|
4717
|
-
Cesium$
|
|
4744
|
+
const cartographic = Cesium$a.Cartographic.fromCartesian(position);
|
|
4745
|
+
return Cesium$a.Cartesian3.fromDegrees(
|
|
4746
|
+
Cesium$a.Math.toDegrees(cartographic.longitude),
|
|
4747
|
+
Cesium$a.Math.toDegrees(cartographic.latitude),
|
|
4718
4748
|
0
|
|
4719
4749
|
);
|
|
4720
4750
|
}
|
|
@@ -4736,17 +4766,17 @@ class EditTool extends BaseTool {
|
|
|
4736
4766
|
if ((isSector || isEllipse) && index === 0) return; // 扇形/椭圆圆心/中心由中心控制点处理
|
|
4737
4767
|
|
|
4738
4768
|
const clampedPos = this._clampPositionToGround(
|
|
4739
|
-
Cesium$
|
|
4769
|
+
Cesium$a.Cartesian3.fromDegrees(cp[0], cp[1], cp[2] || 0)
|
|
4740
4770
|
);
|
|
4741
4771
|
const handle = this.createTempEntity(`__edit_handle_${index}`, {
|
|
4742
4772
|
position: clampedPos,
|
|
4743
4773
|
point: {
|
|
4744
|
-
color: Cesium$
|
|
4774
|
+
color: Cesium$a.Color.YELLOW,
|
|
4745
4775
|
pixelSize: 12,
|
|
4746
|
-
outlineColor: Cesium$
|
|
4776
|
+
outlineColor: Cesium$a.Color.RED,
|
|
4747
4777
|
outlineWidth: 2,
|
|
4748
4778
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
4749
|
-
heightReference: Cesium$
|
|
4779
|
+
heightReference: Cesium$a.HeightReference.CLAMP_TO_GROUND
|
|
4750
4780
|
}
|
|
4751
4781
|
});
|
|
4752
4782
|
this._editHandles.push(handle);
|
|
@@ -4783,18 +4813,18 @@ class EditTool extends BaseTool {
|
|
|
4783
4813
|
if (!center) return;
|
|
4784
4814
|
|
|
4785
4815
|
this._originalEntityCenter = this._clampPositionToGround(
|
|
4786
|
-
Cesium$
|
|
4816
|
+
Cesium$a.Cartesian3.fromDegrees(center[0], center[1], center[2] || 0)
|
|
4787
4817
|
);
|
|
4788
4818
|
|
|
4789
4819
|
const handle = this.createTempEntity('__edit_handle_center_plot', {
|
|
4790
4820
|
position: this._originalEntityCenter,
|
|
4791
4821
|
point: {
|
|
4792
|
-
color: Cesium$
|
|
4822
|
+
color: Cesium$a.Color.CYAN,
|
|
4793
4823
|
pixelSize: 14,
|
|
4794
|
-
outlineColor: Cesium$
|
|
4824
|
+
outlineColor: Cesium$a.Color.BLUE,
|
|
4795
4825
|
outlineWidth: 2,
|
|
4796
4826
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
4797
|
-
heightReference: Cesium$
|
|
4827
|
+
heightReference: Cesium$a.HeightReference.CLAMP_TO_GROUND
|
|
4798
4828
|
}
|
|
4799
4829
|
});
|
|
4800
4830
|
this._editHandles.push(handle);
|
|
@@ -4822,7 +4852,7 @@ class EditTool extends BaseTool {
|
|
|
4822
4852
|
_createPlotPositionOutline() {
|
|
4823
4853
|
const self = this;
|
|
4824
4854
|
const entity = this._selectedEntity;
|
|
4825
|
-
const isLine = Cesium$
|
|
4855
|
+
const isLine = Cesium$a.defined(entity.polyline);
|
|
4826
4856
|
|
|
4827
4857
|
// 以下标绘图元的控制点连线会干扰真实几何,不绘制轮廓辅助线
|
|
4828
4858
|
const skipOutlineTypes = new Set([
|
|
@@ -4839,7 +4869,7 @@ class EditTool extends BaseTool {
|
|
|
4839
4869
|
|
|
4840
4870
|
this._positionOutline = this.createTempEntity(this.generateId('temp_plot_outline'), {
|
|
4841
4871
|
polyline: {
|
|
4842
|
-
positions: new Cesium$
|
|
4872
|
+
positions: new Cesium$a.CallbackProperty(function () {
|
|
4843
4873
|
const handles = self._editHandles;
|
|
4844
4874
|
if (!handles || handles.length === 0) return [];
|
|
4845
4875
|
|
|
@@ -4854,7 +4884,7 @@ class EditTool extends BaseTool {
|
|
|
4854
4884
|
let positions = null;
|
|
4855
4885
|
if (hierarchy) {
|
|
4856
4886
|
if (typeof hierarchy.getValue === 'function') {
|
|
4857
|
-
const value = hierarchy.getValue(Cesium$
|
|
4887
|
+
const value = hierarchy.getValue(Cesium$a.JulianDate.now());
|
|
4858
4888
|
positions = value ? value.positions : null;
|
|
4859
4889
|
} else if (hierarchy.positions) {
|
|
4860
4890
|
positions = hierarchy.positions;
|
|
@@ -4874,24 +4904,24 @@ class EditTool extends BaseTool {
|
|
|
4874
4904
|
// 跳过中心平移控制点
|
|
4875
4905
|
if (handle.id && handle.id.includes('center')) return;
|
|
4876
4906
|
|
|
4877
|
-
const pos = handle.position.getValue(Cesium$
|
|
4907
|
+
const pos = handle.position.getValue(Cesium$a.JulianDate.now());
|
|
4878
4908
|
if (pos) {
|
|
4879
|
-
const c = Cesium$
|
|
4880
|
-
degrees.push(Cesium$
|
|
4881
|
-
degrees.push(Cesium$
|
|
4909
|
+
const c = Cesium$a.Cartographic.fromCartesian(pos);
|
|
4910
|
+
degrees.push(Cesium$a.Math.toDegrees(c.longitude));
|
|
4911
|
+
degrees.push(Cesium$a.Math.toDegrees(c.latitude));
|
|
4882
4912
|
degrees.push(c.height || 0);
|
|
4883
4913
|
}
|
|
4884
4914
|
});
|
|
4885
4915
|
|
|
4886
4916
|
if (degrees.length === 0) return [];
|
|
4887
4917
|
|
|
4888
|
-
const cartesians = Cesium$
|
|
4918
|
+
const cartesians = Cesium$a.Cartesian3.fromDegreesArrayHeights(degrees);
|
|
4889
4919
|
if (isLine) {
|
|
4890
4920
|
return cartesians;
|
|
4891
4921
|
}
|
|
4892
4922
|
return [...cartesians, cartesians[0]];
|
|
4893
4923
|
}, false),
|
|
4894
|
-
material: Cesium$
|
|
4924
|
+
material: Cesium$a.Color.YELLOW,
|
|
4895
4925
|
width: 2,
|
|
4896
4926
|
clampToGround: true
|
|
4897
4927
|
}
|
|
@@ -4907,17 +4937,17 @@ class EditTool extends BaseTool {
|
|
|
4907
4937
|
const self = this;
|
|
4908
4938
|
const axisLine = this.createTempEntity(this.generateId('temp_ellipse_axis'), {
|
|
4909
4939
|
polyline: {
|
|
4910
|
-
positions: new Cesium$
|
|
4940
|
+
positions: new Cesium$a.CallbackProperty(function () {
|
|
4911
4941
|
const entity = self._selectedEntity;
|
|
4912
4942
|
const cps = entity?._controlPoints;
|
|
4913
4943
|
if (!cps || cps.length < 3) return [];
|
|
4914
4944
|
|
|
4915
|
-
const center = Cesium$
|
|
4916
|
-
const major = Cesium$
|
|
4917
|
-
const minor = Cesium$
|
|
4945
|
+
const center = Cesium$a.Cartesian3.fromDegrees(cps[0][0], cps[0][1], cps[0][2] || 0);
|
|
4946
|
+
const major = Cesium$a.Cartesian3.fromDegrees(cps[1][0], cps[1][1], cps[1][2] || 0);
|
|
4947
|
+
const minor = Cesium$a.Cartesian3.fromDegrees(cps[2][0], cps[2][1], cps[2][2] || 0);
|
|
4918
4948
|
return [center, major, center, minor];
|
|
4919
4949
|
}, false),
|
|
4920
|
-
material: Cesium$
|
|
4950
|
+
material: Cesium$a.Color.YELLOW,
|
|
4921
4951
|
width: 2,
|
|
4922
4952
|
clampToGround: true
|
|
4923
4953
|
}
|
|
@@ -4932,7 +4962,7 @@ class EditTool extends BaseTool {
|
|
|
4932
4962
|
*/
|
|
4933
4963
|
_createVertexHandles(positions) {
|
|
4934
4964
|
// 判断是否是矩形(4个顶点形成矩形)
|
|
4935
|
-
const isRectangle = Cesium$
|
|
4965
|
+
const isRectangle = Cesium$a.defined(this._selectedEntity.polygon) && positions.length === 4 &&
|
|
4936
4966
|
this._isRectangle(positions);
|
|
4937
4967
|
|
|
4938
4968
|
if (isRectangle) {
|
|
@@ -4946,12 +4976,12 @@ class EditTool extends BaseTool {
|
|
|
4946
4976
|
const handle = this.createTempEntity(`__edit_handle_${handleIdx}`, {
|
|
4947
4977
|
position: clampedPos,
|
|
4948
4978
|
point: {
|
|
4949
|
-
color: Cesium$
|
|
4979
|
+
color: Cesium$a.Color.YELLOW,
|
|
4950
4980
|
pixelSize: 12,
|
|
4951
|
-
outlineColor: Cesium$
|
|
4981
|
+
outlineColor: Cesium$a.Color.RED,
|
|
4952
4982
|
outlineWidth: 2,
|
|
4953
4983
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
4954
|
-
heightReference: Cesium$
|
|
4984
|
+
heightReference: Cesium$a.HeightReference.CLAMP_TO_GROUND,
|
|
4955
4985
|
}
|
|
4956
4986
|
});
|
|
4957
4987
|
this._editHandles.push(handle);
|
|
@@ -4964,20 +4994,20 @@ class EditTool extends BaseTool {
|
|
|
4964
4994
|
|
|
4965
4995
|
const { center, radius } = circleInfo;
|
|
4966
4996
|
// 修复:圆心位置贴地
|
|
4967
|
-
const centerCartesian = Cesium$
|
|
4997
|
+
const centerCartesian = Cesium$a.Cartesian3.fromDegrees(center[0], center[1], 0);
|
|
4968
4998
|
const radiusPoint = this._getPointOnCircle(center, radius, 0);
|
|
4969
|
-
const radiusCartesian = Cesium$
|
|
4999
|
+
const radiusCartesian = Cesium$a.Cartesian3.fromDegrees(radiusPoint[0], radiusPoint[1], 0);
|
|
4970
5000
|
|
|
4971
5001
|
// 圆心控制点(可平移)- 使用与其他类型不同的ID格式
|
|
4972
5002
|
const centerHandle = this.createTempEntity('__edit_handle_center', {
|
|
4973
5003
|
position: centerCartesian,
|
|
4974
5004
|
point: {
|
|
4975
|
-
color: Cesium$
|
|
5005
|
+
color: Cesium$a.Color.CYAN,
|
|
4976
5006
|
pixelSize: 14,
|
|
4977
|
-
outlineColor: Cesium$
|
|
5007
|
+
outlineColor: Cesium$a.Color.BLUE,
|
|
4978
5008
|
outlineWidth: 2,
|
|
4979
5009
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
4980
|
-
heightReference: Cesium$
|
|
5010
|
+
heightReference: Cesium$a.HeightReference.CLAMP_TO_GROUND
|
|
4981
5011
|
}
|
|
4982
5012
|
});
|
|
4983
5013
|
this._editHandles.push(centerHandle);
|
|
@@ -4986,12 +5016,12 @@ class EditTool extends BaseTool {
|
|
|
4986
5016
|
const radiusHandle = this.createTempEntity('__edit_handle_radius', {
|
|
4987
5017
|
position: radiusCartesian,
|
|
4988
5018
|
point: {
|
|
4989
|
-
color: Cesium$
|
|
5019
|
+
color: Cesium$a.Color.RED,
|
|
4990
5020
|
pixelSize: 12,
|
|
4991
|
-
outlineColor: Cesium$
|
|
5021
|
+
outlineColor: Cesium$a.Color.YELLOW,
|
|
4992
5022
|
outlineWidth: 2,
|
|
4993
5023
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
4994
|
-
heightReference: Cesium$
|
|
5024
|
+
heightReference: Cesium$a.HeightReference.CLAMP_TO_GROUND
|
|
4995
5025
|
}
|
|
4996
5026
|
});
|
|
4997
5027
|
this._editHandles.push(radiusHandle);
|
|
@@ -5011,9 +5041,9 @@ class EditTool extends BaseTool {
|
|
|
5011
5041
|
const handle = this.createTempEntity(`__edit_handle_${index}`, {
|
|
5012
5042
|
position: clampedPos,
|
|
5013
5043
|
point: {
|
|
5014
|
-
color: Cesium$
|
|
5044
|
+
color: Cesium$a.Color.YELLOW,
|
|
5015
5045
|
pixelSize: 12,
|
|
5016
|
-
outlineColor: Cesium$
|
|
5046
|
+
outlineColor: Cesium$a.Color.RED,
|
|
5017
5047
|
outlineWidth: 2,
|
|
5018
5048
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
5019
5049
|
// heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
|
|
@@ -5053,12 +5083,12 @@ class EditTool extends BaseTool {
|
|
|
5053
5083
|
const handle = this.createTempEntity('__edit_handle_center_vertex', {
|
|
5054
5084
|
position: clampedCenter,
|
|
5055
5085
|
point: {
|
|
5056
|
-
color: Cesium$
|
|
5086
|
+
color: Cesium$a.Color.CYAN,
|
|
5057
5087
|
pixelSize: 14,
|
|
5058
|
-
outlineColor: Cesium$
|
|
5088
|
+
outlineColor: Cesium$a.Color.BLUE,
|
|
5059
5089
|
outlineWidth: 2,
|
|
5060
5090
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
5061
|
-
heightReference: Cesium$
|
|
5091
|
+
heightReference: Cesium$a.HeightReference.CLAMP_TO_GROUND
|
|
5062
5092
|
}
|
|
5063
5093
|
});
|
|
5064
5094
|
this._editHandles.push(handle);
|
|
@@ -5082,7 +5112,7 @@ class EditTool extends BaseTool {
|
|
|
5082
5112
|
const clampedCenter = this._clampPositionToGround(newCenter);
|
|
5083
5113
|
|
|
5084
5114
|
// 更新中心控制点位置
|
|
5085
|
-
centerHandle.position = new Cesium$
|
|
5115
|
+
centerHandle.position = new Cesium$a.ConstantPositionProperty(clampedCenter);
|
|
5086
5116
|
// 更新原始中心点缓存(用于下次平移计算)
|
|
5087
5117
|
this._originalEntityCenter = clampedCenter;
|
|
5088
5118
|
}
|
|
@@ -5090,11 +5120,11 @@ class EditTool extends BaseTool {
|
|
|
5090
5120
|
_createPositionOutline() {
|
|
5091
5121
|
// 从控制点获取位置,性能更好(避免每次从实体重新获取和转换)
|
|
5092
5122
|
const self = this;
|
|
5093
|
-
const isPolyline = Cesium$
|
|
5123
|
+
const isPolyline = Cesium$a.defined(this._selectedEntity.polyline);
|
|
5094
5124
|
|
|
5095
5125
|
this._positionOutline = this.createTempEntity(this.generateId('temp_outline'), {
|
|
5096
5126
|
polyline: {
|
|
5097
|
-
positions: new Cesium$
|
|
5127
|
+
positions: new Cesium$a.CallbackProperty(function () {
|
|
5098
5128
|
// 从控制点获取位置(已被更新),排除中心控制点
|
|
5099
5129
|
const handles = self._editHandles;
|
|
5100
5130
|
if (!handles || handles.length === 0) return [];
|
|
@@ -5105,11 +5135,11 @@ class EditTool extends BaseTool {
|
|
|
5105
5135
|
// 跳过所有中心控制点(用于平移)- 修复:统一使用 includes('center')
|
|
5106
5136
|
if (handle.id && handle.id.includes('center')) return;
|
|
5107
5137
|
|
|
5108
|
-
const pos = handle.position.getValue(Cesium$
|
|
5138
|
+
const pos = handle.position.getValue(Cesium$a.JulianDate.now());
|
|
5109
5139
|
if (pos) {
|
|
5110
|
-
const c = Cesium$
|
|
5111
|
-
degrees.push(Cesium$
|
|
5112
|
-
degrees.push(Cesium$
|
|
5140
|
+
const c = Cesium$a.Cartographic.fromCartesian(pos);
|
|
5141
|
+
degrees.push(Cesium$a.Math.toDegrees(c.longitude));
|
|
5142
|
+
degrees.push(Cesium$a.Math.toDegrees(c.latitude));
|
|
5113
5143
|
degrees.push(c.height || 0);
|
|
5114
5144
|
}
|
|
5115
5145
|
});
|
|
@@ -5118,12 +5148,12 @@ class EditTool extends BaseTool {
|
|
|
5118
5148
|
|
|
5119
5149
|
// 线不闭合,面需要闭合
|
|
5120
5150
|
if (isPolyline) {
|
|
5121
|
-
return Cesium$
|
|
5151
|
+
return Cesium$a.Cartesian3.fromDegreesArrayHeights(degrees);
|
|
5122
5152
|
}
|
|
5123
5153
|
// 闭合多边形(首尾点相同)
|
|
5124
|
-
return Cesium$
|
|
5154
|
+
return Cesium$a.Cartesian3.fromDegreesArrayHeights([...degrees, degrees[0], degrees[1], degrees[2] || 0]);
|
|
5125
5155
|
}, false),
|
|
5126
|
-
material: Cesium$
|
|
5156
|
+
material: Cesium$a.Color.YELLOW,
|
|
5127
5157
|
width: 2,
|
|
5128
5158
|
clampToGround: true
|
|
5129
5159
|
}
|
|
@@ -5155,12 +5185,12 @@ class EditTool extends BaseTool {
|
|
|
5155
5185
|
_getEditablePositions(entity) {
|
|
5156
5186
|
if (!entity) return [];
|
|
5157
5187
|
|
|
5158
|
-
if (Cesium$
|
|
5159
|
-
return entity.polyline.positions.getValue(Cesium$
|
|
5188
|
+
if (Cesium$a.defined(entity.polyline) && Cesium$a.defined(entity.polyline.positions)) {
|
|
5189
|
+
return entity.polyline.positions.getValue(Cesium$a.JulianDate.now());
|
|
5160
5190
|
}
|
|
5161
5191
|
|
|
5162
|
-
if (Cesium$
|
|
5163
|
-
const hierarchy = entity.polygon.hierarchy.getValue(Cesium$
|
|
5192
|
+
if (Cesium$a.defined(entity.polygon) && Cesium$a.defined(entity.polygon.hierarchy)) {
|
|
5193
|
+
const hierarchy = entity.polygon.hierarchy.getValue(Cesium$a.JulianDate.now());
|
|
5164
5194
|
if (hierarchy && hierarchy.positions) {
|
|
5165
5195
|
let positions = hierarchy.positions;
|
|
5166
5196
|
|
|
@@ -5169,7 +5199,7 @@ class EditTool extends BaseTool {
|
|
|
5169
5199
|
const first = positions[0];
|
|
5170
5200
|
const last = positions[positions.length - 1];
|
|
5171
5201
|
// 使用距离判断而不是精确相等(避免浮点误差)
|
|
5172
|
-
const distance = Cesium$
|
|
5202
|
+
const distance = Cesium$a.Cartesian3.distance(first, last);
|
|
5173
5203
|
if (distance < EditTool.CLOSE_POINT_TOLERANCE) {
|
|
5174
5204
|
positions = positions.slice(0, -1); // 移除最后一个点
|
|
5175
5205
|
}
|
|
@@ -5179,8 +5209,8 @@ class EditTool extends BaseTool {
|
|
|
5179
5209
|
}
|
|
5180
5210
|
}
|
|
5181
5211
|
|
|
5182
|
-
if (Cesium$
|
|
5183
|
-
return [entity.position.getValue(Cesium$
|
|
5212
|
+
if (Cesium$a.defined(entity.position)) {
|
|
5213
|
+
return [entity.position.getValue(Cesium$a.JulianDate.now())];
|
|
5184
5214
|
}
|
|
5185
5215
|
|
|
5186
5216
|
return [];
|
|
@@ -5204,7 +5234,7 @@ class EditTool extends BaseTool {
|
|
|
5204
5234
|
z += p.z;
|
|
5205
5235
|
});
|
|
5206
5236
|
const count = positions.length;
|
|
5207
|
-
return new Cesium$
|
|
5237
|
+
return new Cesium$a.Cartesian3(x / count, y / count, z / count);
|
|
5208
5238
|
}
|
|
5209
5239
|
|
|
5210
5240
|
/**
|
|
@@ -5229,7 +5259,7 @@ class EditTool extends BaseTool {
|
|
|
5229
5259
|
const deltaZ = clampedNewCenter.z - this._originalEntityCenter.z;
|
|
5230
5260
|
|
|
5231
5261
|
// 计算真正的新中心位置(不是鼠标位置)
|
|
5232
|
-
const actualNewCenter = new Cesium$
|
|
5262
|
+
const actualNewCenter = new Cesium$a.Cartesian3(
|
|
5233
5263
|
this._originalEntityCenter.x + deltaX,
|
|
5234
5264
|
this._originalEntityCenter.y + deltaY,
|
|
5235
5265
|
this._originalEntityCenter.z + deltaZ
|
|
@@ -5239,12 +5269,12 @@ class EditTool extends BaseTool {
|
|
|
5239
5269
|
this._originalEntityCenter = actualNewCenter;
|
|
5240
5270
|
|
|
5241
5271
|
// 更新中心控制点位置
|
|
5242
|
-
this._dragHandle.position = new Cesium$
|
|
5272
|
+
this._dragHandle.position = new Cesium$a.ConstantPositionProperty(actualNewCenter);
|
|
5243
5273
|
|
|
5244
|
-
if (Cesium$
|
|
5274
|
+
if (Cesium$a.defined(this._selectedEntity.polyline)) {
|
|
5245
5275
|
// 线图元:平移所有位置
|
|
5246
5276
|
const newPositions = this._originalPositions.map(p => {
|
|
5247
|
-
const newPos = new Cesium$
|
|
5277
|
+
const newPos = new Cesium$a.Cartesian3(p.x + deltaX, p.y + deltaY, p.z + deltaZ);
|
|
5248
5278
|
// 修复:贴地
|
|
5249
5279
|
return this._clampPositionToGround(newPos);
|
|
5250
5280
|
});
|
|
@@ -5262,32 +5292,32 @@ class EditTool extends BaseTool {
|
|
|
5262
5292
|
if (match) {
|
|
5263
5293
|
const index = parseInt(match[1], 10);
|
|
5264
5294
|
if (newPositions[index]) {
|
|
5265
|
-
handle.position = new Cesium$
|
|
5295
|
+
handle.position = new Cesium$a.ConstantPositionProperty(newPositions[index]);
|
|
5266
5296
|
}
|
|
5267
5297
|
}
|
|
5268
5298
|
});
|
|
5269
5299
|
|
|
5270
5300
|
// 更新原始位置缓存
|
|
5271
5301
|
this._originalPositions = newPositions;
|
|
5272
|
-
} else if (Cesium$
|
|
5302
|
+
} else if (Cesium$a.defined(this._selectedEntity.polygon)) {
|
|
5273
5303
|
if (this._isCircle(this._selectedEntity)) {
|
|
5274
5304
|
// 圆形平移
|
|
5275
5305
|
const oldCenter = this._selectedEntity._circleCenter; // [lon, lat]
|
|
5276
5306
|
|
|
5277
5307
|
// 将旧的圆心经纬度转为 Cartesian3
|
|
5278
|
-
const oldCenterCartesian = Cesium$
|
|
5308
|
+
const oldCenterCartesian = Cesium$a.Cartesian3.fromDegrees(oldCenter[0], oldCenter[1], 0);
|
|
5279
5309
|
|
|
5280
5310
|
// 应用偏移量计算新的 Cartesian3 位置
|
|
5281
|
-
const newCenterCartesian = new Cesium$
|
|
5311
|
+
const newCenterCartesian = new Cesium$a.Cartesian3(
|
|
5282
5312
|
oldCenterCartesian.x + deltaX,
|
|
5283
5313
|
oldCenterCartesian.y + deltaY,
|
|
5284
5314
|
oldCenterCartesian.z + deltaZ
|
|
5285
5315
|
);
|
|
5286
5316
|
|
|
5287
5317
|
// 将新的 Cartesian3 转回经纬度
|
|
5288
|
-
const newCenterCartographic = Cesium$
|
|
5289
|
-
const newCenterLon = Cesium$
|
|
5290
|
-
const newCenterLat = Cesium$
|
|
5318
|
+
const newCenterCartographic = Cesium$a.Cartographic.fromCartesian(newCenterCartesian);
|
|
5319
|
+
const newCenterLon = Cesium$a.Math.toDegrees(newCenterCartographic.longitude);
|
|
5320
|
+
const newCenterLat = Cesium$a.Math.toDegrees(newCenterCartographic.latitude);
|
|
5291
5321
|
|
|
5292
5322
|
this._selectedEntity._circleCenter = [newCenterLon, newCenterLat];
|
|
5293
5323
|
|
|
@@ -5298,25 +5328,25 @@ class EditTool extends BaseTool {
|
|
|
5298
5328
|
256
|
|
5299
5329
|
);
|
|
5300
5330
|
const flat = positions.flatMap(c => [c[0], c[1], 0]);
|
|
5301
|
-
this._selectedEntity.polygon.hierarchy = new Cesium$
|
|
5302
|
-
Cesium$
|
|
5331
|
+
this._selectedEntity.polygon.hierarchy = new Cesium$a.PolygonHierarchy(
|
|
5332
|
+
Cesium$a.Cartesian3.fromDegreesArrayHeights(flat)
|
|
5303
5333
|
);
|
|
5304
5334
|
|
|
5305
5335
|
// 更新圆心控制点位置
|
|
5306
5336
|
const centerHandle = this._editHandles.find(h => h.id && h.id.includes('__edit_handle_center'));
|
|
5307
5337
|
if (centerHandle) {
|
|
5308
|
-
centerHandle.position = new Cesium$
|
|
5338
|
+
centerHandle.position = new Cesium$a.ConstantPositionProperty(newCenterCartesian);
|
|
5309
5339
|
}
|
|
5310
5340
|
} else {
|
|
5311
5341
|
// 普通多边形:平移所有顶点
|
|
5312
5342
|
const newPositions = this._originalPositions.map(p => {
|
|
5313
|
-
const newPos = new Cesium$
|
|
5343
|
+
const newPos = new Cesium$a.Cartesian3(p.x + deltaX, p.y + deltaY, p.z + deltaZ);
|
|
5314
5344
|
// 修复:贴地
|
|
5315
5345
|
return this._clampPositionToGround(newPos);
|
|
5316
5346
|
});
|
|
5317
5347
|
// 添加闭合点
|
|
5318
5348
|
newPositions.push(newPositions[0].clone());
|
|
5319
|
-
this._selectedEntity.polygon.hierarchy = new Cesium$
|
|
5349
|
+
this._selectedEntity.polygon.hierarchy = new Cesium$a.PolygonHierarchy(newPositions);
|
|
5320
5350
|
|
|
5321
5351
|
// 修复:更新顶点控制点位置,使用更可靠的ID匹配
|
|
5322
5352
|
this._editHandles.forEach((handle) => {
|
|
@@ -5329,7 +5359,7 @@ class EditTool extends BaseTool {
|
|
|
5329
5359
|
if (match) {
|
|
5330
5360
|
const index = parseInt(match[1], 10);
|
|
5331
5361
|
if (newPositions[index]) {
|
|
5332
|
-
handle.position = new Cesium$
|
|
5362
|
+
handle.position = new Cesium$a.ConstantPositionProperty(newPositions[index]);
|
|
5333
5363
|
}
|
|
5334
5364
|
}
|
|
5335
5365
|
});
|
|
@@ -5337,9 +5367,9 @@ class EditTool extends BaseTool {
|
|
|
5337
5367
|
// 更新原始位置缓存
|
|
5338
5368
|
this._originalPositions = newPositions.slice(0, -1);
|
|
5339
5369
|
}
|
|
5340
|
-
} else if (Cesium$
|
|
5370
|
+
} else if (Cesium$a.defined(this._selectedEntity.position)) {
|
|
5341
5371
|
// 点/文本图元:平移位置
|
|
5342
|
-
this._selectedEntity.position = new Cesium$
|
|
5372
|
+
this._selectedEntity.position = new Cesium$a.ConstantPositionProperty(actualNewCenter);
|
|
5343
5373
|
this._originalPositions = [actualNewCenter];
|
|
5344
5374
|
}
|
|
5345
5375
|
}
|
|
@@ -5468,16 +5498,16 @@ class EditTool extends BaseTool {
|
|
|
5468
5498
|
// 圆周辅助线(黄色)
|
|
5469
5499
|
this._positionOutline = this.createTempEntity(this.generateId('temp_circle_outline'), {
|
|
5470
5500
|
polyline: {
|
|
5471
|
-
positions: new Cesium$
|
|
5501
|
+
positions: new Cesium$a.CallbackProperty(function () {
|
|
5472
5502
|
const circleInfo = self._getCircleInfo(self._selectedEntity);
|
|
5473
5503
|
if (!circleInfo) return [];
|
|
5474
5504
|
|
|
5475
5505
|
const { center, radius } = circleInfo;
|
|
5476
5506
|
const positions = self._generateCirclePositions(center, radius, 256);
|
|
5477
5507
|
const flat = positions.flatMap(c => [c[0], c[1], 0]);
|
|
5478
|
-
return Cesium$
|
|
5508
|
+
return Cesium$a.Cartesian3.fromDegreesArrayHeights(flat);
|
|
5479
5509
|
}, false),
|
|
5480
|
-
material: Cesium$
|
|
5510
|
+
material: Cesium$a.Color.YELLOW,
|
|
5481
5511
|
width: 2,
|
|
5482
5512
|
clampToGround: true
|
|
5483
5513
|
}
|
|
@@ -5489,7 +5519,7 @@ class EditTool extends BaseTool {
|
|
|
5489
5519
|
// 修复:正确获取半径控制点的位置
|
|
5490
5520
|
this._radiusLine = this.createTempEntity(this.generateId('temp_radius_line'), {
|
|
5491
5521
|
polyline: {
|
|
5492
|
-
positions: new Cesium$
|
|
5522
|
+
positions: new Cesium$a.CallbackProperty(function () {
|
|
5493
5523
|
const circleInfo = self._getCircleInfo(self._selectedEntity);
|
|
5494
5524
|
if (!circleInfo) return [];
|
|
5495
5525
|
|
|
@@ -5498,13 +5528,13 @@ class EditTool extends BaseTool {
|
|
|
5498
5528
|
const radiusHandle = self._editHandles.find(h => h.id && h.id.includes('__edit_handle_radius'));
|
|
5499
5529
|
if (!radiusHandle) return [];
|
|
5500
5530
|
|
|
5501
|
-
const radiusPos = radiusHandle.position.getValue(Cesium$
|
|
5531
|
+
const radiusPos = radiusHandle.position.getValue(Cesium$a.JulianDate.now());
|
|
5502
5532
|
if (!radiusPos) return [];
|
|
5503
5533
|
|
|
5504
|
-
const centerCart = Cesium$
|
|
5534
|
+
const centerCart = Cesium$a.Cartesian3.fromDegrees(center[0], center[1], 0);
|
|
5505
5535
|
return [centerCart, radiusPos];
|
|
5506
5536
|
}, false),
|
|
5507
|
-
material: Cesium$
|
|
5537
|
+
material: Cesium$a.Color.RED,
|
|
5508
5538
|
width: 3,
|
|
5509
5539
|
clampToGround: true
|
|
5510
5540
|
}
|
|
@@ -5544,8 +5574,8 @@ class EditTool extends BaseTool {
|
|
|
5544
5574
|
_computeRectangleNewPositions(newPos, originalPositions, draggedIndex) {
|
|
5545
5575
|
// 对角顶点索引:0->2, 1->3, 2->0, 3->1
|
|
5546
5576
|
const oppositeIndex = (draggedIndex + 2) % 4;
|
|
5547
|
-
const newP = Cesium$
|
|
5548
|
-
const currentPos = originalPositions.map(p => Cesium$
|
|
5577
|
+
const newP = Cesium$a.Cartographic.fromCartesian(newPos);
|
|
5578
|
+
const currentPos = originalPositions.map(p => Cesium$a.Cartographic.fromCartesian(p));
|
|
5549
5579
|
const oppositePos = currentPos[oppositeIndex];
|
|
5550
5580
|
|
|
5551
5581
|
const newPositions = new Array(4);
|
|
@@ -5558,14 +5588,14 @@ class EditTool extends BaseTool {
|
|
|
5558
5588
|
const neighbor2 = (draggedIndex + 3) % 4;
|
|
5559
5589
|
|
|
5560
5590
|
// neighbor1 使用 newPos 的 longitude 和 opposite 的 latitude
|
|
5561
|
-
newPositions[neighbor1] = Cesium$
|
|
5591
|
+
newPositions[neighbor1] = Cesium$a.Cartesian3.fromRadians(
|
|
5562
5592
|
newP.longitude,
|
|
5563
5593
|
oppositePos.latitude,
|
|
5564
5594
|
oppositePos.height
|
|
5565
5595
|
);
|
|
5566
5596
|
|
|
5567
5597
|
// neighbor2 使用 opposite 的 longitude 和 newPos 的 latitude
|
|
5568
|
-
newPositions[neighbor2] = Cesium$
|
|
5598
|
+
newPositions[neighbor2] = Cesium$a.Cartesian3.fromRadians(
|
|
5569
5599
|
oppositePos.longitude,
|
|
5570
5600
|
newP.latitude,
|
|
5571
5601
|
oppositePos.height
|
|
@@ -5581,7 +5611,7 @@ class EditTool extends BaseTool {
|
|
|
5581
5611
|
if (handleIndex === -1) return;
|
|
5582
5612
|
|
|
5583
5613
|
// 修复:新位置贴地(高度设为0)
|
|
5584
|
-
const newCartesian = Cesium$
|
|
5614
|
+
const newCartesian = Cesium$a.Cartesian3.fromDegrees(newLonLat[0], newLonLat[1], 0);
|
|
5585
5615
|
|
|
5586
5616
|
// 标绘图元:拖拽控制点重新生成几何
|
|
5587
5617
|
if (this._selectedEntity._isPlotGraphic) {
|
|
@@ -5604,12 +5634,12 @@ class EditTool extends BaseTool {
|
|
|
5604
5634
|
// 扇形:拖拽圆心(索引0)时整体平移,保持两半径等长
|
|
5605
5635
|
if (plotType === PlotGraphicType.SECTOR && index === 0) {
|
|
5606
5636
|
const oldCenter = this._selectedEntity._controlPoints[0];
|
|
5607
|
-
const oldCenterCart = Cesium$
|
|
5637
|
+
const oldCenterCart = Cesium$a.Cartesian3.fromDegrees(oldCenter[0], oldCenter[1], oldCenter[2] || 0);
|
|
5608
5638
|
const clampedNewCenter = this._clampPositionToGround(newCartesian);
|
|
5609
5639
|
this._translatePlotControlPoints(clampedNewCenter, oldCenterCart);
|
|
5610
5640
|
// 中心控制点固定在圆心
|
|
5611
5641
|
this._originalEntityCenter = this._clampPositionToGround(
|
|
5612
|
-
Cesium$
|
|
5642
|
+
Cesium$a.Cartesian3.fromDegrees(
|
|
5613
5643
|
this._selectedEntity._controlPoints[0][0],
|
|
5614
5644
|
this._selectedEntity._controlPoints[0][1],
|
|
5615
5645
|
this._selectedEntity._controlPoints[0][2] || 0
|
|
@@ -5685,8 +5715,8 @@ class EditTool extends BaseTool {
|
|
|
5685
5715
|
if (match) {
|
|
5686
5716
|
const cpIndex = parseInt(match[1], 10);
|
|
5687
5717
|
const cp = controlPoints[cpIndex];
|
|
5688
|
-
handle.position = new Cesium$
|
|
5689
|
-
this._clampPositionToGround(Cesium$
|
|
5718
|
+
handle.position = new Cesium$a.ConstantPositionProperty(
|
|
5719
|
+
this._clampPositionToGround(Cesium$a.Cartesian3.fromDegrees(cp[0], cp[1], cp[2] || 0))
|
|
5690
5720
|
);
|
|
5691
5721
|
}
|
|
5692
5722
|
});
|
|
@@ -5698,11 +5728,11 @@ class EditTool extends BaseTool {
|
|
|
5698
5728
|
const newCenter = (plotType === PlotGraphicType.SECTOR || plotType === PlotGraphicType.ELLIPSE)
|
|
5699
5729
|
? controlPoints[0]
|
|
5700
5730
|
: this._getPlotControlPointsCenter(controlPoints);
|
|
5701
|
-
centerHandle.position = new Cesium$
|
|
5702
|
-
this._clampPositionToGround(Cesium$
|
|
5731
|
+
centerHandle.position = new Cesium$a.ConstantPositionProperty(
|
|
5732
|
+
this._clampPositionToGround(Cesium$a.Cartesian3.fromDegrees(newCenter[0], newCenter[1], newCenter[2] || 0))
|
|
5703
5733
|
);
|
|
5704
5734
|
this._originalEntityCenter = this._clampPositionToGround(
|
|
5705
|
-
Cesium$
|
|
5735
|
+
Cesium$a.Cartesian3.fromDegrees(newCenter[0], newCenter[1], newCenter[2] || 0)
|
|
5706
5736
|
);
|
|
5707
5737
|
}
|
|
5708
5738
|
|
|
@@ -5711,7 +5741,7 @@ class EditTool extends BaseTool {
|
|
|
5711
5741
|
return;
|
|
5712
5742
|
}
|
|
5713
5743
|
|
|
5714
|
-
const hierarchy = this._selectedEntity.polygon?.hierarchy?.getValue(Cesium$
|
|
5744
|
+
const hierarchy = this._selectedEntity.polygon?.hierarchy?.getValue(Cesium$a.JulianDate.now());
|
|
5715
5745
|
|
|
5716
5746
|
// 拖动中心控制点:平移整个图元
|
|
5717
5747
|
// 修复:统一使用 includes('center') 来判断
|
|
@@ -5725,7 +5755,7 @@ class EditTool extends BaseTool {
|
|
|
5725
5755
|
if (this._handleVertexIndices &&
|
|
5726
5756
|
Array.isArray(this._handleVertexIndices) &&
|
|
5727
5757
|
typeof this._handleVertexIndices[0] === 'number' &&
|
|
5728
|
-
Cesium$
|
|
5758
|
+
Cesium$a.defined(this._selectedEntity.polygon)) {
|
|
5729
5759
|
if (!hierarchy || !hierarchy.positions || hierarchy.positions.length < 4) return;
|
|
5730
5760
|
|
|
5731
5761
|
const draggedVertexIndex = this._handleVertexIndices[handleIndex];
|
|
@@ -5735,13 +5765,13 @@ class EditTool extends BaseTool {
|
|
|
5735
5765
|
const clampedPositions = newPositions.map(pos => this._clampPositionToGround(pos));
|
|
5736
5766
|
|
|
5737
5767
|
// 更新多边形
|
|
5738
|
-
this._selectedEntity.polygon.hierarchy = new Cesium$
|
|
5768
|
+
this._selectedEntity.polygon.hierarchy = new Cesium$a.PolygonHierarchy(clampedPositions);
|
|
5739
5769
|
|
|
5740
5770
|
// 更新所有控制点位置(使用 ConstantPositionProperty 确保正确更新)
|
|
5741
5771
|
this._editHandles.forEach((handle, i) => {
|
|
5742
5772
|
// 修复:跳过中心控制点
|
|
5743
5773
|
if (handle.id && handle.id.includes('center')) return;
|
|
5744
|
-
handle.position = new Cesium$
|
|
5774
|
+
handle.position = new Cesium$a.ConstantPositionProperty(clampedPositions[i]);
|
|
5745
5775
|
});
|
|
5746
5776
|
|
|
5747
5777
|
// 修复:顶点编辑后重新计算并更新中心控制点位置
|
|
@@ -5774,16 +5804,16 @@ class EditTool extends BaseTool {
|
|
|
5774
5804
|
// 更新多边形顶点
|
|
5775
5805
|
const positions = this._generateCirclePositions(newCenterLonLat, circleInfo.radius, 256);
|
|
5776
5806
|
const flat = positions.flatMap(c => [c[0], c[1], 0]);
|
|
5777
|
-
this._selectedEntity.polygon.hierarchy = new Cesium$
|
|
5778
|
-
Cesium$
|
|
5807
|
+
this._selectedEntity.polygon.hierarchy = new Cesium$a.PolygonHierarchy(
|
|
5808
|
+
Cesium$a.Cartesian3.fromDegreesArrayHeights(flat)
|
|
5779
5809
|
);
|
|
5780
5810
|
|
|
5781
5811
|
// 更新半径控制点位置
|
|
5782
5812
|
const radiusHandle = this._editHandles.find(h => h.id && h.id.includes('radius'));
|
|
5783
5813
|
if (radiusHandle) {
|
|
5784
5814
|
const radiusPoint = this._getPointOnCircle(newCenterLonLat, circleInfo.radius, 0);
|
|
5785
|
-
radiusHandle.position = new Cesium$
|
|
5786
|
-
Cesium$
|
|
5815
|
+
radiusHandle.position = new Cesium$a.ConstantPositionProperty(
|
|
5816
|
+
Cesium$a.Cartesian3.fromDegrees(radiusPoint[0], radiusPoint[1], 0)
|
|
5787
5817
|
);
|
|
5788
5818
|
}
|
|
5789
5819
|
|
|
@@ -5795,8 +5825,8 @@ class EditTool extends BaseTool {
|
|
|
5795
5825
|
// 更新半径控制点位置(在圆周上)
|
|
5796
5826
|
const angle = Math.atan2(newLonLat[1] - circleInfo.center[1], newLonLat[0] - circleInfo.center[0]);
|
|
5797
5827
|
const radiusPoint = this._getPointOnCircle(circleInfo.center, newRadius, angle);
|
|
5798
|
-
this._dragHandle.position = new Cesium$
|
|
5799
|
-
Cesium$
|
|
5828
|
+
this._dragHandle.position = new Cesium$a.ConstantPositionProperty(
|
|
5829
|
+
Cesium$a.Cartesian3.fromDegrees(radiusPoint[0], radiusPoint[1], 0)
|
|
5800
5830
|
);
|
|
5801
5831
|
|
|
5802
5832
|
// 更新圆的实体属性
|
|
@@ -5806,25 +5836,25 @@ class EditTool extends BaseTool {
|
|
|
5806
5836
|
// 更新多边形顶点
|
|
5807
5837
|
const positions = this._generateCirclePositions(circleInfo.center, newRadius, 256);
|
|
5808
5838
|
const flat = positions.flatMap(c => [c[0], c[1], 0]);
|
|
5809
|
-
this._selectedEntity.polygon.hierarchy = new Cesium$
|
|
5810
|
-
Cesium$
|
|
5839
|
+
this._selectedEntity.polygon.hierarchy = new Cesium$a.PolygonHierarchy(
|
|
5840
|
+
Cesium$a.Cartesian3.fromDegreesArrayHeights(flat)
|
|
5811
5841
|
);
|
|
5812
5842
|
|
|
5813
5843
|
return;
|
|
5814
5844
|
}
|
|
5815
5845
|
|
|
5816
|
-
if (Cesium$
|
|
5817
|
-
const positions = this._selectedEntity.polyline.positions.getValue(Cesium$
|
|
5846
|
+
if (Cesium$a.defined(this._selectedEntity.polyline)) {
|
|
5847
|
+
const positions = this._selectedEntity.polyline.positions.getValue(Cesium$a.JulianDate.now());
|
|
5818
5848
|
if (positions && positions[handleIndex]) {
|
|
5819
5849
|
// 直接修改数组元素触发更新
|
|
5820
5850
|
positions[handleIndex] = newCartesian;
|
|
5821
5851
|
this._selectedEntity.polyline.positions = positions;
|
|
5822
|
-
this._dragHandle.position = new Cesium$
|
|
5852
|
+
this._dragHandle.position = new Cesium$a.ConstantPositionProperty(newCartesian);
|
|
5823
5853
|
|
|
5824
5854
|
// 修复:线编辑后重新计算并更新中心控制点位置
|
|
5825
5855
|
this._updateCenterHandlePosition();
|
|
5826
5856
|
}
|
|
5827
|
-
} else if (Cesium$
|
|
5857
|
+
} else if (Cesium$a.defined(this._selectedEntity.polygon)) {
|
|
5828
5858
|
// 获取当前实际顶点数(不包含闭合点)
|
|
5829
5859
|
this._editHandles.filter(h => !h.id.includes('center')).length;
|
|
5830
5860
|
|
|
@@ -5839,7 +5869,7 @@ class EditTool extends BaseTool {
|
|
|
5839
5869
|
newPositions.push(newCartesian);
|
|
5840
5870
|
} else {
|
|
5841
5871
|
// 从控制点获取当前位置
|
|
5842
|
-
const pos = handle.position.getValue(Cesium$
|
|
5872
|
+
const pos = handle.position.getValue(Cesium$a.JulianDate.now());
|
|
5843
5873
|
// 修复:确保位置贴地
|
|
5844
5874
|
newPositions.push(this._clampPositionToGround(pos));
|
|
5845
5875
|
}
|
|
@@ -5849,47 +5879,47 @@ class EditTool extends BaseTool {
|
|
|
5849
5879
|
newPositions.push(newPositions[0].clone());
|
|
5850
5880
|
|
|
5851
5881
|
// 更新多边形
|
|
5852
|
-
this._selectedEntity.polygon.hierarchy = new Cesium$
|
|
5882
|
+
this._selectedEntity.polygon.hierarchy = new Cesium$a.PolygonHierarchy(newPositions);
|
|
5853
5883
|
|
|
5854
5884
|
// 更新控制点
|
|
5855
|
-
this._dragHandle.position = new Cesium$
|
|
5885
|
+
this._dragHandle.position = new Cesium$a.ConstantPositionProperty(newCartesian);
|
|
5856
5886
|
|
|
5857
5887
|
// 修复:多边形编辑后重新计算并更新中心控制点位置
|
|
5858
5888
|
this._updateCenterHandlePosition();
|
|
5859
5889
|
|
|
5860
5890
|
return;
|
|
5861
|
-
} else if (Cesium$
|
|
5862
|
-
this._selectedEntity.position = new Cesium$
|
|
5863
|
-
this._dragHandle.position = new Cesium$
|
|
5891
|
+
} else if (Cesium$a.defined(this._selectedEntity.position)) {
|
|
5892
|
+
this._selectedEntity.position = new Cesium$a.ConstantPositionProperty(newCartesian);
|
|
5893
|
+
this._dragHandle.position = new Cesium$a.ConstantPositionProperty(newCartesian);
|
|
5864
5894
|
}
|
|
5865
5895
|
}
|
|
5866
5896
|
|
|
5867
5897
|
_highlightEntity(entity, highlight) {
|
|
5868
5898
|
if (!entity) return;
|
|
5869
5899
|
|
|
5870
|
-
if (Cesium$
|
|
5900
|
+
if (Cesium$a.defined(entity.point)) {
|
|
5871
5901
|
if (highlight) {
|
|
5872
|
-
entity.point.outlineColor = Cesium$
|
|
5902
|
+
entity.point.outlineColor = Cesium$a.Color.CYAN;
|
|
5873
5903
|
entity.point.outlineWidth = 3;
|
|
5874
5904
|
} else {
|
|
5875
|
-
entity.point.outlineColor = Cesium$
|
|
5905
|
+
entity.point.outlineColor = Cesium$a.Color.WHITE;
|
|
5876
5906
|
entity.point.outlineWidth = 1;
|
|
5877
5907
|
}
|
|
5878
5908
|
}
|
|
5879
5909
|
|
|
5880
|
-
if (Cesium$
|
|
5910
|
+
if (Cesium$a.defined(entity.polyline)) {
|
|
5881
5911
|
if (highlight) {
|
|
5882
|
-
entity.polyline.material = Cesium$
|
|
5912
|
+
entity.polyline.material = Cesium$a.Color.CYAN;
|
|
5883
5913
|
} else {
|
|
5884
|
-
entity.polyline.material = Cesium$
|
|
5914
|
+
entity.polyline.material = Cesium$a.Color.BLUE;
|
|
5885
5915
|
}
|
|
5886
5916
|
}
|
|
5887
5917
|
|
|
5888
|
-
if (Cesium$
|
|
5918
|
+
if (Cesium$a.defined(entity.polygon)) {
|
|
5889
5919
|
if (highlight) {
|
|
5890
|
-
entity.polygon.outlineColor = Cesium$
|
|
5920
|
+
entity.polygon.outlineColor = Cesium$a.Color.CYAN;
|
|
5891
5921
|
} else {
|
|
5892
|
-
entity.polygon.outlineColor = Cesium$
|
|
5922
|
+
entity.polygon.outlineColor = Cesium$a.Color.WHITE;
|
|
5893
5923
|
}
|
|
5894
5924
|
}
|
|
5895
5925
|
}
|
|
@@ -5926,8 +5956,8 @@ class EditTool extends BaseTool {
|
|
|
5926
5956
|
// 更新多边形顶点
|
|
5927
5957
|
const positions = this._generateCirclePositions(center, radius, 256);
|
|
5928
5958
|
const flat = positions.flatMap(c => [c[0], c[1], 0]);
|
|
5929
|
-
this._selectedEntity.polygon.hierarchy = new Cesium$
|
|
5930
|
-
Cesium$
|
|
5959
|
+
this._selectedEntity.polygon.hierarchy = new Cesium$a.PolygonHierarchy(
|
|
5960
|
+
Cesium$a.Cartesian3.fromDegreesArrayHeights(flat)
|
|
5931
5961
|
);
|
|
5932
5962
|
|
|
5933
5963
|
this._createEditHandles();
|
|
@@ -5942,10 +5972,10 @@ class EditTool extends BaseTool {
|
|
|
5942
5972
|
// 拷贝一份避免直接修改原始数据
|
|
5943
5973
|
const positionsCopy = originalPositions.map(p => p.clone ? p.clone() : p);
|
|
5944
5974
|
|
|
5945
|
-
if (Cesium$
|
|
5975
|
+
if (Cesium$a.defined(this._selectedEntity.polyline)) {
|
|
5946
5976
|
this._selectedEntity.polyline.positions = positionsCopy;
|
|
5947
|
-
} else if (Cesium$
|
|
5948
|
-
this._selectedEntity.polygon.hierarchy = new Cesium$
|
|
5977
|
+
} else if (Cesium$a.defined(this._selectedEntity.polygon)) {
|
|
5978
|
+
this._selectedEntity.polygon.hierarchy = new Cesium$a.PolygonHierarchy(positionsCopy);
|
|
5949
5979
|
}
|
|
5950
5980
|
|
|
5951
5981
|
this._createEditHandles();
|
|
@@ -5968,7 +5998,7 @@ class EditTool extends BaseTool {
|
|
|
5968
5998
|
}
|
|
5969
5999
|
}
|
|
5970
6000
|
|
|
5971
|
-
const Cesium$
|
|
6001
|
+
const Cesium$9 = getCesium();
|
|
5972
6002
|
|
|
5973
6003
|
/**
|
|
5974
6004
|
* 选择类型枚举
|
|
@@ -6055,7 +6085,7 @@ class SelectTool extends BaseTool {
|
|
|
6055
6085
|
|
|
6056
6086
|
const picked = this._viewer.scene.pick(screenPos);
|
|
6057
6087
|
|
|
6058
|
-
if (Cesium$
|
|
6088
|
+
if (Cesium$9.defined(picked) && Cesium$9.defined(picked.id)) {
|
|
6059
6089
|
const entityId = picked.id.id;
|
|
6060
6090
|
|
|
6061
6091
|
// 忽略临时图元
|
|
@@ -6097,9 +6127,9 @@ class SelectTool extends BaseTool {
|
|
|
6097
6127
|
|
|
6098
6128
|
_createSelectionStartMarker(pos) {
|
|
6099
6129
|
const marker = this.createTempEntity(this.generateId('sel_start'), {
|
|
6100
|
-
position: Cesium$
|
|
6130
|
+
position: Cesium$9.Cartesian3.fromDegrees(...pos),
|
|
6101
6131
|
point: {
|
|
6102
|
-
color: Cesium$
|
|
6132
|
+
color: Cesium$9.Color.GREEN,
|
|
6103
6133
|
pixelSize: 10
|
|
6104
6134
|
}
|
|
6105
6135
|
});
|
|
@@ -6124,27 +6154,27 @@ class SelectTool extends BaseTool {
|
|
|
6124
6154
|
if (!this._selectionRect) {
|
|
6125
6155
|
this._selectionRect = this.createTempEntity(this.generateId('sel_rect'), {
|
|
6126
6156
|
polyline: {
|
|
6127
|
-
positions: new Cesium$
|
|
6157
|
+
positions: new Cesium$9.CallbackProperty(() => {
|
|
6128
6158
|
const c1 = this._startPos;
|
|
6129
6159
|
const c2 = this._currentEndPos;
|
|
6130
6160
|
if (!c1 || !c2) return [];
|
|
6131
6161
|
const pos = this._getRectPositions(c1, c2);
|
|
6132
|
-
return Cesium$
|
|
6162
|
+
return Cesium$9.Cartesian3.fromDegreesArrayHeights(pos.flatMap(c => [c[0], c[1], 0]));
|
|
6133
6163
|
}, false),
|
|
6134
|
-
material: Cesium$
|
|
6164
|
+
material: Cesium$9.Color.CYAN,
|
|
6135
6165
|
width: 2
|
|
6136
6166
|
},
|
|
6137
6167
|
polygon: {
|
|
6138
|
-
hierarchy: new Cesium$
|
|
6168
|
+
hierarchy: new Cesium$9.CallbackProperty(() => {
|
|
6139
6169
|
const c1 = this._startPos;
|
|
6140
6170
|
const c2 = this._currentEndPos;
|
|
6141
|
-
if (!c1 || !c2) return new Cesium$
|
|
6171
|
+
if (!c1 || !c2) return new Cesium$9.PolygonHierarchy([]);
|
|
6142
6172
|
const pos = this._getRectPositions(c1, c2);
|
|
6143
|
-
return new Cesium$
|
|
6144
|
-
Cesium$
|
|
6173
|
+
return new Cesium$9.PolygonHierarchy(
|
|
6174
|
+
Cesium$9.Cartesian3.fromDegreesArrayHeights(pos.flatMap(c => [c[0], c[1], 0]))
|
|
6145
6175
|
);
|
|
6146
6176
|
}, false),
|
|
6147
|
-
material: Cesium$
|
|
6177
|
+
material: Cesium$9.Color.CYAN.withAlpha(0.2),
|
|
6148
6178
|
outline: false
|
|
6149
6179
|
}
|
|
6150
6180
|
});
|
|
@@ -6161,21 +6191,21 @@ class SelectTool extends BaseTool {
|
|
|
6161
6191
|
if (!this._selectionRect) {
|
|
6162
6192
|
this._selectionRect = this.createTempEntity(this.generateId('sel_circle'), {
|
|
6163
6193
|
polygon: {
|
|
6164
|
-
hierarchy: new Cesium$
|
|
6194
|
+
hierarchy: new Cesium$9.CallbackProperty(() => {
|
|
6165
6195
|
const c = this._startPos;
|
|
6166
6196
|
const edge = this._currentEndPos;
|
|
6167
|
-
if (!c || !edge) return new Cesium$
|
|
6197
|
+
if (!c || !edge) return new Cesium$9.PolygonHierarchy([]);
|
|
6168
6198
|
const radius = this._calcDistance(c, edge);
|
|
6169
6199
|
const positions = this._generateCirclePositions(c, radius, 36);
|
|
6170
|
-
return new Cesium$
|
|
6171
|
-
Cesium$
|
|
6200
|
+
return new Cesium$9.PolygonHierarchy(
|
|
6201
|
+
Cesium$9.Cartesian3.fromDegreesArrayHeights(
|
|
6172
6202
|
positions.flatMap(c => [c[0], c[1], 0])
|
|
6173
6203
|
)
|
|
6174
6204
|
);
|
|
6175
6205
|
}, false),
|
|
6176
|
-
material: Cesium$
|
|
6206
|
+
material: Cesium$9.Color.CYAN.withAlpha(0.2),
|
|
6177
6207
|
outline: true,
|
|
6178
|
-
outlineColor: Cesium$
|
|
6208
|
+
outlineColor: Cesium$9.Color.CYAN
|
|
6179
6209
|
}
|
|
6180
6210
|
});
|
|
6181
6211
|
this._selectionRect._isPreview = true;
|
|
@@ -6264,7 +6294,7 @@ class SelectTool extends BaseTool {
|
|
|
6264
6294
|
|
|
6265
6295
|
const styleKey = entityId;
|
|
6266
6296
|
|
|
6267
|
-
if (Cesium$
|
|
6297
|
+
if (Cesium$9.defined(entity.point)) {
|
|
6268
6298
|
if (highlight) {
|
|
6269
6299
|
if (!this._originalStyles.has(styleKey)) {
|
|
6270
6300
|
this._originalStyles.set(styleKey, {
|
|
@@ -6274,7 +6304,7 @@ class SelectTool extends BaseTool {
|
|
|
6274
6304
|
}
|
|
6275
6305
|
});
|
|
6276
6306
|
}
|
|
6277
|
-
entity.point.outlineColor = Cesium$
|
|
6307
|
+
entity.point.outlineColor = Cesium$9.Color.YELLOW;
|
|
6278
6308
|
entity.point.outlineWidth = 2;
|
|
6279
6309
|
} else {
|
|
6280
6310
|
const original = this._originalStyles.get(styleKey)?.point;
|
|
@@ -6282,13 +6312,13 @@ class SelectTool extends BaseTool {
|
|
|
6282
6312
|
entity.point.outlineColor = original.outlineColor;
|
|
6283
6313
|
entity.point.outlineWidth = original.outlineWidth;
|
|
6284
6314
|
} else {
|
|
6285
|
-
entity.point.outlineColor = Cesium$
|
|
6315
|
+
entity.point.outlineColor = Cesium$9.Color.WHITE;
|
|
6286
6316
|
entity.point.outlineWidth = 1;
|
|
6287
6317
|
}
|
|
6288
6318
|
}
|
|
6289
6319
|
}
|
|
6290
6320
|
|
|
6291
|
-
if (Cesium$
|
|
6321
|
+
if (Cesium$9.defined(entity.polyline)) {
|
|
6292
6322
|
if (highlight) {
|
|
6293
6323
|
if (!this._originalStyles.has(styleKey)) {
|
|
6294
6324
|
this._originalStyles.set(styleKey, {
|
|
@@ -6297,14 +6327,14 @@ class SelectTool extends BaseTool {
|
|
|
6297
6327
|
}
|
|
6298
6328
|
});
|
|
6299
6329
|
}
|
|
6300
|
-
entity.polyline.material = Cesium$
|
|
6330
|
+
entity.polyline.material = Cesium$9.Color.CYAN;
|
|
6301
6331
|
} else {
|
|
6302
6332
|
const original = this._originalStyles.get(styleKey)?.polyline;
|
|
6303
|
-
entity.polyline.material = original?.material || Cesium$
|
|
6333
|
+
entity.polyline.material = original?.material || Cesium$9.Color.BLUE;
|
|
6304
6334
|
}
|
|
6305
6335
|
}
|
|
6306
6336
|
|
|
6307
|
-
if (Cesium$
|
|
6337
|
+
if (Cesium$9.defined(entity.polygon)) {
|
|
6308
6338
|
if (highlight) {
|
|
6309
6339
|
if (!this._originalStyles.has(styleKey)) {
|
|
6310
6340
|
this._originalStyles.set(styleKey, {
|
|
@@ -6313,10 +6343,10 @@ class SelectTool extends BaseTool {
|
|
|
6313
6343
|
}
|
|
6314
6344
|
});
|
|
6315
6345
|
}
|
|
6316
|
-
entity.polygon.outlineColor = Cesium$
|
|
6346
|
+
entity.polygon.outlineColor = Cesium$9.Color.CYAN;
|
|
6317
6347
|
} else {
|
|
6318
6348
|
const original = this._originalStyles.get(styleKey)?.polygon;
|
|
6319
|
-
entity.polygon.outlineColor = original?.outlineColor || Cesium$
|
|
6349
|
+
entity.polygon.outlineColor = original?.outlineColor || Cesium$9.Color.WHITE;
|
|
6320
6350
|
}
|
|
6321
6351
|
}
|
|
6322
6352
|
|
|
@@ -6403,9 +6433,9 @@ class SelectTool extends BaseTool {
|
|
|
6403
6433
|
// 检查是否所有点都在范围内
|
|
6404
6434
|
let allInBounds = true;
|
|
6405
6435
|
for (const pos of positions) {
|
|
6406
|
-
const c = Cesium$
|
|
6407
|
-
const lon = Cesium$
|
|
6408
|
-
const lat = Cesium$
|
|
6436
|
+
const c = Cesium$9.Cartographic.fromCartesian(pos);
|
|
6437
|
+
const lon = Cesium$9.Math.toDegrees(c.longitude);
|
|
6438
|
+
const lat = Cesium$9.Math.toDegrees(c.latitude);
|
|
6409
6439
|
|
|
6410
6440
|
if (lon < minLon || lon > maxLon || lat < minLat || lat > maxLat) {
|
|
6411
6441
|
allInBounds = false;
|
|
@@ -6422,13 +6452,13 @@ class SelectTool extends BaseTool {
|
|
|
6422
6452
|
}
|
|
6423
6453
|
|
|
6424
6454
|
_getEntityPosition(entity) {
|
|
6425
|
-
if (Cesium$
|
|
6426
|
-
const pos = entity.position.getValue(Cesium$
|
|
6455
|
+
if (Cesium$9.defined(entity.position)) {
|
|
6456
|
+
const pos = entity.position.getValue(Cesium$9.JulianDate.now());
|
|
6427
6457
|
if (pos) {
|
|
6428
|
-
const c = Cesium$
|
|
6458
|
+
const c = Cesium$9.Cartographic.fromCartesian(pos);
|
|
6429
6459
|
return [
|
|
6430
|
-
Cesium$
|
|
6431
|
-
Cesium$
|
|
6460
|
+
Cesium$9.Math.toDegrees(c.longitude),
|
|
6461
|
+
Cesium$9.Math.toDegrees(c.latitude)
|
|
6432
6462
|
];
|
|
6433
6463
|
}
|
|
6434
6464
|
}
|
|
@@ -6436,11 +6466,11 @@ class SelectTool extends BaseTool {
|
|
|
6436
6466
|
}
|
|
6437
6467
|
|
|
6438
6468
|
_getEntityPositions(entity) {
|
|
6439
|
-
if (Cesium$
|
|
6440
|
-
return entity.polyline.positions.getValue(Cesium$
|
|
6469
|
+
if (Cesium$9.defined(entity.polyline) && Cesium$9.defined(entity.polyline.positions)) {
|
|
6470
|
+
return entity.polyline.positions.getValue(Cesium$9.JulianDate.now());
|
|
6441
6471
|
}
|
|
6442
|
-
if (Cesium$
|
|
6443
|
-
const hierarchy = entity.polygon.hierarchy.getValue(Cesium$
|
|
6472
|
+
if (Cesium$9.defined(entity.polygon) && Cesium$9.defined(entity.polygon.hierarchy)) {
|
|
6473
|
+
const hierarchy = entity.polygon.hierarchy.getValue(Cesium$9.JulianDate.now());
|
|
6444
6474
|
return hierarchy ? hierarchy.positions : [];
|
|
6445
6475
|
}
|
|
6446
6476
|
return [];
|
|
@@ -6505,7 +6535,7 @@ class SelectTool extends BaseTool {
|
|
|
6505
6535
|
}
|
|
6506
6536
|
}
|
|
6507
6537
|
|
|
6508
|
-
const Cesium$
|
|
6538
|
+
const Cesium$8 = getCesium();
|
|
6509
6539
|
|
|
6510
6540
|
/**
|
|
6511
6541
|
* 删除模式枚举
|
|
@@ -6556,7 +6586,7 @@ class DeleteTool extends BaseTool {
|
|
|
6556
6586
|
|
|
6557
6587
|
const picked = this._viewer.scene.pick(screenPos);
|
|
6558
6588
|
|
|
6559
|
-
if (Cesium$
|
|
6589
|
+
if (Cesium$8.defined(picked) && Cesium$8.defined(picked.id)) {
|
|
6560
6590
|
const entityId = picked.id.id;
|
|
6561
6591
|
|
|
6562
6592
|
// 忽略临时图元
|
|
@@ -6580,7 +6610,7 @@ class DeleteTool extends BaseTool {
|
|
|
6580
6610
|
|
|
6581
6611
|
let hoveredId = null;
|
|
6582
6612
|
|
|
6583
|
-
if (Cesium$
|
|
6613
|
+
if (Cesium$8.defined(picked) && Cesium$8.defined(picked.id)) {
|
|
6584
6614
|
const entityId = picked.id.id;
|
|
6585
6615
|
if (!entityId.startsWith('__temp_') && !entityId.startsWith('__edit_handle_')) {
|
|
6586
6616
|
hoveredId = entityId;
|
|
@@ -6660,7 +6690,7 @@ class DeleteTool extends BaseTool {
|
|
|
6660
6690
|
const styleKey = entityId;
|
|
6661
6691
|
|
|
6662
6692
|
// 红色高亮表示可删除,先保存原始样式
|
|
6663
|
-
if (Cesium$
|
|
6693
|
+
if (Cesium$8.defined(entity.point)) {
|
|
6664
6694
|
if (!this._originalStyles.has(styleKey)) {
|
|
6665
6695
|
this._originalStyles.set(styleKey, {
|
|
6666
6696
|
point: {
|
|
@@ -6669,11 +6699,11 @@ class DeleteTool extends BaseTool {
|
|
|
6669
6699
|
}
|
|
6670
6700
|
});
|
|
6671
6701
|
}
|
|
6672
|
-
entity.point.outlineColor = Cesium$
|
|
6702
|
+
entity.point.outlineColor = Cesium$8.Color.RED;
|
|
6673
6703
|
entity.point.outlineWidth = 3;
|
|
6674
6704
|
}
|
|
6675
6705
|
|
|
6676
|
-
if (Cesium$
|
|
6706
|
+
if (Cesium$8.defined(entity.polyline)) {
|
|
6677
6707
|
if (!this._originalStyles.has(styleKey)) {
|
|
6678
6708
|
this._originalStyles.set(styleKey, {
|
|
6679
6709
|
polyline: {
|
|
@@ -6681,10 +6711,10 @@ class DeleteTool extends BaseTool {
|
|
|
6681
6711
|
}
|
|
6682
6712
|
});
|
|
6683
6713
|
}
|
|
6684
|
-
entity.polyline.material = Cesium$
|
|
6714
|
+
entity.polyline.material = Cesium$8.Color.RED;
|
|
6685
6715
|
}
|
|
6686
6716
|
|
|
6687
|
-
if (Cesium$
|
|
6717
|
+
if (Cesium$8.defined(entity.polygon)) {
|
|
6688
6718
|
if (!this._originalStyles.has(styleKey)) {
|
|
6689
6719
|
this._originalStyles.set(styleKey, {
|
|
6690
6720
|
polygon: {
|
|
@@ -6692,7 +6722,7 @@ class DeleteTool extends BaseTool {
|
|
|
6692
6722
|
}
|
|
6693
6723
|
});
|
|
6694
6724
|
}
|
|
6695
|
-
entity.polygon.outlineColor = Cesium$
|
|
6725
|
+
entity.polygon.outlineColor = Cesium$8.Color.RED;
|
|
6696
6726
|
}
|
|
6697
6727
|
|
|
6698
6728
|
// 更改鼠标样式
|
|
@@ -6709,22 +6739,22 @@ class DeleteTool extends BaseTool {
|
|
|
6709
6739
|
const original = styleKey ? this._originalStyles.get(styleKey) : null;
|
|
6710
6740
|
|
|
6711
6741
|
// 恢复原始样式
|
|
6712
|
-
if (Cesium$
|
|
6742
|
+
if (Cesium$8.defined(entity.point)) {
|
|
6713
6743
|
if (original?.point) {
|
|
6714
6744
|
entity.point.outlineColor = original.point.outlineColor;
|
|
6715
6745
|
entity.point.outlineWidth = original.point.outlineWidth;
|
|
6716
6746
|
} else {
|
|
6717
|
-
entity.point.outlineColor = Cesium$
|
|
6747
|
+
entity.point.outlineColor = Cesium$8.Color.WHITE;
|
|
6718
6748
|
entity.point.outlineWidth = 1;
|
|
6719
6749
|
}
|
|
6720
6750
|
}
|
|
6721
6751
|
|
|
6722
|
-
if (Cesium$
|
|
6723
|
-
entity.polyline.material = original?.polyline?.material || Cesium$
|
|
6752
|
+
if (Cesium$8.defined(entity.polyline)) {
|
|
6753
|
+
entity.polyline.material = original?.polyline?.material || Cesium$8.Color.BLUE;
|
|
6724
6754
|
}
|
|
6725
6755
|
|
|
6726
|
-
if (Cesium$
|
|
6727
|
-
entity.polygon.outlineColor = original?.polygon?.outlineColor || Cesium$
|
|
6756
|
+
if (Cesium$8.defined(entity.polygon)) {
|
|
6757
|
+
entity.polygon.outlineColor = original?.polygon?.outlineColor || Cesium$8.Color.WHITE;
|
|
6728
6758
|
}
|
|
6729
6759
|
|
|
6730
6760
|
// 恢复鼠标样式
|
|
@@ -6758,6 +6788,615 @@ class DeleteTool extends BaseTool {
|
|
|
6758
6788
|
}
|
|
6759
6789
|
}
|
|
6760
6790
|
|
|
6791
|
+
const Cesium$7 = getCesium();
|
|
6792
|
+
|
|
6793
|
+
/**
|
|
6794
|
+
* 地理计算工具(距离、面积、高程)
|
|
6795
|
+
*/
|
|
6796
|
+
class GeoCalcUtil {
|
|
6797
|
+
/**
|
|
6798
|
+
* 计算两点地理坐标距离(米)
|
|
6799
|
+
* @param {Array<number>} point1 [lng, lat, height]
|
|
6800
|
+
* @param {Array<number>} point2 [lng, lat, height]
|
|
6801
|
+
* @returns {number} 距离
|
|
6802
|
+
*/
|
|
6803
|
+
static calcDistance(point1, point2) {
|
|
6804
|
+
const coord1 = Cesium$7.Cartesian3.fromDegrees(...point1);
|
|
6805
|
+
const coord2 = Cesium$7.Cartesian3.fromDegrees(...point2);
|
|
6806
|
+
return Cesium$7.Cartesian3.distance(coord1, coord2);
|
|
6807
|
+
}
|
|
6808
|
+
|
|
6809
|
+
/**
|
|
6810
|
+
* 计算多边形面积(平方米)
|
|
6811
|
+
* 使用球面多边形面积公式(基于 Cesium 几何顶点)
|
|
6812
|
+
* @param {Array<Array<number>>} points 地理坐标点集 [lon, lat, height?]
|
|
6813
|
+
* @returns {number} 面积
|
|
6814
|
+
*/
|
|
6815
|
+
static calcArea(points) {
|
|
6816
|
+
if (!points || points.length < 3) return 0;
|
|
6817
|
+
|
|
6818
|
+
const positions = points.map(p => Cesium$7.Cartesian3.fromDegrees(p[0], p[1], p[2] || 0));
|
|
6819
|
+
const polygon = new Cesium$7.PolygonGeometry({
|
|
6820
|
+
polygonHierarchy: new Cesium$7.PolygonHierarchy(positions)
|
|
6821
|
+
});
|
|
6822
|
+
const geometry = Cesium$7.PolygonGeometry.createGeometry(polygon);
|
|
6823
|
+
|
|
6824
|
+
if (!geometry || !geometry.attributes || !geometry.attributes.position) {
|
|
6825
|
+
return 0;
|
|
6826
|
+
}
|
|
6827
|
+
|
|
6828
|
+
const values = geometry.attributes.position.values;
|
|
6829
|
+
const vertexPositions = [];
|
|
6830
|
+
for (let i = 0; i < values.length; i += 3) {
|
|
6831
|
+
vertexPositions.push(new Cesium$7.Cartesian3(values[i], values[i + 1], values[i + 2]));
|
|
6832
|
+
}
|
|
6833
|
+
|
|
6834
|
+
// 球面多边形面积(基于单位球上的多边形面积公式)
|
|
6835
|
+
const area = GeoCalcUtil.#sphericalPolygonArea(vertexPositions);
|
|
6836
|
+
return Math.abs(area);
|
|
6837
|
+
}
|
|
6838
|
+
|
|
6839
|
+
/**
|
|
6840
|
+
* 单位球面上多边形的有向面积(平方米)
|
|
6841
|
+
* 采用局部切平面投影法:以多边形重心为原点建立切平面,投影后计算二维多边形面积。
|
|
6842
|
+
* 对于常规 GIS 多边形精度足够;极大规模多边形可后续替换为更严格的球面 excess 算法。
|
|
6843
|
+
* @param {Cesium.Cartesian3[]} positions 世界坐标顶点
|
|
6844
|
+
* @returns {number} 面积(平方米)
|
|
6845
|
+
*/
|
|
6846
|
+
static #sphericalPolygonArea(positions) {
|
|
6847
|
+
const ellipsoid = Cesium$7.Ellipsoid.WGS84;
|
|
6848
|
+
const n = positions.length;
|
|
6849
|
+
if (n < 3) return 0;
|
|
6850
|
+
|
|
6851
|
+
// 计算近似重心(归一化到椭球面)
|
|
6852
|
+
let center = new Cesium$7.Cartesian3(0, 0, 0);
|
|
6853
|
+
for (const p of positions) {
|
|
6854
|
+
center = Cesium$7.Cartesian3.add(center, p, center);
|
|
6855
|
+
}
|
|
6856
|
+
center = Cesium$7.Cartesian3.normalize(center, new Cesium$7.Cartesian3());
|
|
6857
|
+
center = ellipsoid.scaleToGeodeticSurface(center, new Cesium$7.Cartesian3()) || center;
|
|
6858
|
+
|
|
6859
|
+
// 在重心处建立东北天(ENU)局部坐标系
|
|
6860
|
+
const tangentPlane = new Cesium$7.EllipsoidTangentPlane(center, ellipsoid);
|
|
6861
|
+
|
|
6862
|
+
// 投影到切平面
|
|
6863
|
+
const projected = positions.map(p => tangentPlane.projectPointOntoPlane(p, new Cesium$7.Cartesian2()));
|
|
6864
|
+
|
|
6865
|
+
// 计算二维多边形面积(Shoelace 公式)
|
|
6866
|
+
let area2 = 0;
|
|
6867
|
+
for (let i = 0; i < n; i++) {
|
|
6868
|
+
const p1 = projected[i];
|
|
6869
|
+
const p2 = projected[(i + 1) % n];
|
|
6870
|
+
area2 += p1.x * p2.y - p2.x * p1.y;
|
|
6871
|
+
}
|
|
6872
|
+
|
|
6873
|
+
return Math.abs(area2) * 0.5;
|
|
6874
|
+
}
|
|
6875
|
+
|
|
6876
|
+
/**
|
|
6877
|
+
* 获取指定地理坐标的高程
|
|
6878
|
+
* @param {Cesium.Viewer} viewer Cesium 实例
|
|
6879
|
+
* @param {Array<number>} coord [lng, lat]
|
|
6880
|
+
* @returns {Promise<number>} 高程值
|
|
6881
|
+
*/
|
|
6882
|
+
static async getHeight(viewer, coord) {
|
|
6883
|
+
const cartographic = Cesium$7.Cartographic.fromDegrees(coord[0], coord[1]);
|
|
6884
|
+
const results = await Cesium$7.sampleTerrainMostDetailed(viewer.terrainProvider, [cartographic]);
|
|
6885
|
+
return results[0]?.height ?? 0;
|
|
6886
|
+
}
|
|
6887
|
+
}
|
|
6888
|
+
|
|
6889
|
+
const Cesium$6 = getCesium();
|
|
6890
|
+
|
|
6891
|
+
/**
|
|
6892
|
+
* 测量类型枚举
|
|
6893
|
+
*/
|
|
6894
|
+
const MeasureType = {
|
|
6895
|
+
DISTANCE: 'distance',
|
|
6896
|
+
AREA: 'area'
|
|
6897
|
+
};
|
|
6898
|
+
|
|
6899
|
+
/**
|
|
6900
|
+
* 测量工具
|
|
6901
|
+
* 支持交互式测距(折线)和测面积(多边形)。
|
|
6902
|
+
* 左键加点,右键 / Enter 完成,Esc 取消,Backspace 撤销上一点。
|
|
6903
|
+
*/
|
|
6904
|
+
class MeasureTool extends BaseTool {
|
|
6905
|
+
constructor(editorModule, options = {}) {
|
|
6906
|
+
super(editorModule, options);
|
|
6907
|
+
|
|
6908
|
+
this._measureType = options.measureType || MeasureType.DISTANCE;
|
|
6909
|
+
this._positions = []; // 已点击的经纬度点
|
|
6910
|
+
this._mousePos = null; // 当前鼠标位置(经纬度)
|
|
6911
|
+
this._isMeasuring = false; // 是否正在一次测量中
|
|
6912
|
+
this._lastResult = null; // 最后一次测量结果
|
|
6913
|
+
|
|
6914
|
+
// 临时图元引用
|
|
6915
|
+
this._pointEntities = []; // 点击点标记
|
|
6916
|
+
this._previewLine = null; // 测距预览线
|
|
6917
|
+
this._previewPolygon = null; // 测面积预览面
|
|
6918
|
+
this._previewOutline = null; // 测面积预览轮廓线
|
|
6919
|
+
this._previewCartesians = []; // 当前预览几何的笛卡尔坐标数组(CallbackProperty 共享引用)
|
|
6920
|
+
this._segmentLabelEntities = []; // 测距每段标注
|
|
6921
|
+
this._totalLabelEntity = null; // 总距离 / 面积标注
|
|
6922
|
+
|
|
6923
|
+
// 已完成的测量结果图元分组,支持一次激活中保留多个测量结果
|
|
6924
|
+
this._finishedResults = [];
|
|
6925
|
+
}
|
|
6926
|
+
|
|
6927
|
+
/**
|
|
6928
|
+
* 设置测量类型
|
|
6929
|
+
* @param {string} type MeasureType
|
|
6930
|
+
*/
|
|
6931
|
+
setMeasureType(type) {
|
|
6932
|
+
this._measureType = type;
|
|
6933
|
+
return this;
|
|
6934
|
+
}
|
|
6935
|
+
|
|
6936
|
+
/**
|
|
6937
|
+
* 获取当前测量类型
|
|
6938
|
+
*/
|
|
6939
|
+
getMeasureType() {
|
|
6940
|
+
return this._measureType;
|
|
6941
|
+
}
|
|
6942
|
+
|
|
6943
|
+
/**
|
|
6944
|
+
* 获取最后一次测量结果
|
|
6945
|
+
*/
|
|
6946
|
+
getLastResult() {
|
|
6947
|
+
return this._lastResult;
|
|
6948
|
+
}
|
|
6949
|
+
|
|
6950
|
+
onActivate() {
|
|
6951
|
+
this.registerObserver('mouse:click', this._onClick.bind(this));
|
|
6952
|
+
this.registerObserver('mouse:move', this._onMove.bind(this));
|
|
6953
|
+
this.registerObserver('mouse:rightclick', this._onRightClick.bind(this));
|
|
6954
|
+
this.registerObserver('keyboard:keydown', this._onKeyDown.bind(this));
|
|
6955
|
+
}
|
|
6956
|
+
|
|
6957
|
+
onDeactivate() {
|
|
6958
|
+
this.clearMeasurements();
|
|
6959
|
+
}
|
|
6960
|
+
|
|
6961
|
+
_onClick(lngLat) {
|
|
6962
|
+
if (!lngLat) return;
|
|
6963
|
+
|
|
6964
|
+
this._isMeasuring = true;
|
|
6965
|
+
this._positions.push(lngLat);
|
|
6966
|
+
this._addPointMarker(lngLat);
|
|
6967
|
+
this._updateMeasurement();
|
|
6968
|
+
}
|
|
6969
|
+
|
|
6970
|
+
_onMove(data) {
|
|
6971
|
+
const screenPos = data.position || data.endPosition;
|
|
6972
|
+
if (!screenPos) return;
|
|
6973
|
+
|
|
6974
|
+
const lonLat = this.screenToLonLat({ x: screenPos.x, y: screenPos.y });
|
|
6975
|
+
if (!lonLat) return;
|
|
6976
|
+
|
|
6977
|
+
this._mousePos = lonLat;
|
|
6978
|
+
if (this._isMeasuring) {
|
|
6979
|
+
this._updateMeasurement();
|
|
6980
|
+
}
|
|
6981
|
+
}
|
|
6982
|
+
|
|
6983
|
+
_onRightClick() {
|
|
6984
|
+
this._finishMeasurement();
|
|
6985
|
+
}
|
|
6986
|
+
|
|
6987
|
+
_onKeyDown(data) {
|
|
6988
|
+
if (data.key === 'Escape') {
|
|
6989
|
+
this.cancelMeasurement();
|
|
6990
|
+
return;
|
|
6991
|
+
}
|
|
6992
|
+
|
|
6993
|
+
if (data.key === 'Enter') {
|
|
6994
|
+
this._finishMeasurement();
|
|
6995
|
+
return;
|
|
6996
|
+
}
|
|
6997
|
+
|
|
6998
|
+
if (data.key === 'Backspace' && this._isMeasuring && this._positions.length > 0) {
|
|
6999
|
+
this._positions.pop();
|
|
7000
|
+
const lastPoint = this._pointEntities.pop();
|
|
7001
|
+
if (lastPoint) {
|
|
7002
|
+
this.removeTempEntity(lastPoint);
|
|
7003
|
+
}
|
|
7004
|
+
this._updateMeasurement();
|
|
7005
|
+
}
|
|
7006
|
+
}
|
|
7007
|
+
|
|
7008
|
+
/**
|
|
7009
|
+
* 完成当前测量
|
|
7010
|
+
*/
|
|
7011
|
+
_finishMeasurement() {
|
|
7012
|
+
const minPoints = this._measureType === MeasureType.AREA ? 3 : 2;
|
|
7013
|
+
if (this._positions.length < minPoints) return;
|
|
7014
|
+
|
|
7015
|
+
this._isMeasuring = false;
|
|
7016
|
+
this._mousePos = null;
|
|
7017
|
+
this._updateMeasurement();
|
|
7018
|
+
|
|
7019
|
+
const result = this._computeResult(this._positions);
|
|
7020
|
+
this._lastResult = result;
|
|
7021
|
+
|
|
7022
|
+
// 将当前测量结果保留在场景中,并清空工作态以便继续下一次测量
|
|
7023
|
+
this._commitCurrentResult();
|
|
7024
|
+
|
|
7025
|
+
this._emitMeasureComplete(result);
|
|
7026
|
+
}
|
|
7027
|
+
|
|
7028
|
+
/**
|
|
7029
|
+
* 把当前测量图元归档为已完成结果,重置工作态
|
|
7030
|
+
*/
|
|
7031
|
+
_commitCurrentResult() {
|
|
7032
|
+
const finalCartesians = this._previewCartesians.slice();
|
|
7033
|
+
|
|
7034
|
+
// 将动态 CallbackProperty 替换为常量几何,避免归档后随 _previewCartesians 变化而消失
|
|
7035
|
+
if (this._previewLine) {
|
|
7036
|
+
this._previewLine.polyline.positions = finalCartesians.length > 0 ? finalCartesians : [];
|
|
7037
|
+
}
|
|
7038
|
+
if (this._previewPolygon) {
|
|
7039
|
+
this._previewPolygon.polygon.hierarchy = finalCartesians.length >= 3
|
|
7040
|
+
? new Cesium$6.PolygonHierarchy(finalCartesians)
|
|
7041
|
+
: new Cesium$6.PolygonHierarchy([]);
|
|
7042
|
+
}
|
|
7043
|
+
if (this._previewOutline) {
|
|
7044
|
+
this._previewOutline.polyline.positions = finalCartesians.length >= 3
|
|
7045
|
+
? [...finalCartesians, finalCartesians[0]]
|
|
7046
|
+
: [];
|
|
7047
|
+
}
|
|
7048
|
+
|
|
7049
|
+
this._finishedResults.push({
|
|
7050
|
+
pointEntities: this._pointEntities,
|
|
7051
|
+
segmentLabels: this._segmentLabelEntities,
|
|
7052
|
+
totalLabel: this._totalLabelEntity,
|
|
7053
|
+
previewLine: this._previewLine,
|
|
7054
|
+
previewPolygon: this._previewPolygon,
|
|
7055
|
+
previewOutline: this._previewOutline
|
|
7056
|
+
});
|
|
7057
|
+
|
|
7058
|
+
this._positions = [];
|
|
7059
|
+
this._mousePos = null;
|
|
7060
|
+
this._isMeasuring = false;
|
|
7061
|
+
this._previewCartesians = [];
|
|
7062
|
+
|
|
7063
|
+
this._pointEntities = [];
|
|
7064
|
+
this._segmentLabelEntities = [];
|
|
7065
|
+
this._totalLabelEntity = null;
|
|
7066
|
+
this._previewLine = null;
|
|
7067
|
+
this._previewPolygon = null;
|
|
7068
|
+
this._previewOutline = null;
|
|
7069
|
+
}
|
|
7070
|
+
|
|
7071
|
+
/**
|
|
7072
|
+
* 取消当前测量
|
|
7073
|
+
*/
|
|
7074
|
+
cancelMeasurement() {
|
|
7075
|
+
this.clearMeasurements();
|
|
7076
|
+
this._emitMeasureCancel();
|
|
7077
|
+
}
|
|
7078
|
+
|
|
7079
|
+
/**
|
|
7080
|
+
* 清空所有测量结果与临时图元
|
|
7081
|
+
*/
|
|
7082
|
+
clearMeasurements() {
|
|
7083
|
+
this._positions = [];
|
|
7084
|
+
this._mousePos = null;
|
|
7085
|
+
this._isMeasuring = false;
|
|
7086
|
+
this._lastResult = null;
|
|
7087
|
+
this._previewCartesians = [];
|
|
7088
|
+
|
|
7089
|
+
this._pointEntities.forEach(e => this.removeTempEntity(e));
|
|
7090
|
+
this._pointEntities = [];
|
|
7091
|
+
|
|
7092
|
+
this._segmentLabelEntities.forEach(e => this.removeTempEntity(e));
|
|
7093
|
+
this._segmentLabelEntities = [];
|
|
7094
|
+
|
|
7095
|
+
if (this._totalLabelEntity) {
|
|
7096
|
+
this.removeTempEntity(this._totalLabelEntity);
|
|
7097
|
+
this._totalLabelEntity = null;
|
|
7098
|
+
}
|
|
7099
|
+
|
|
7100
|
+
if (this._previewLine) {
|
|
7101
|
+
this.removeTempEntity(this._previewLine);
|
|
7102
|
+
this._previewLine = null;
|
|
7103
|
+
}
|
|
7104
|
+
|
|
7105
|
+
if (this._previewPolygon) {
|
|
7106
|
+
this.removeTempEntity(this._previewPolygon);
|
|
7107
|
+
this._previewPolygon = null;
|
|
7108
|
+
}
|
|
7109
|
+
|
|
7110
|
+
if (this._previewOutline) {
|
|
7111
|
+
this.removeTempEntity(this._previewOutline);
|
|
7112
|
+
this._previewOutline = null;
|
|
7113
|
+
}
|
|
7114
|
+
|
|
7115
|
+
this._finishedResults.forEach(group => {
|
|
7116
|
+
group.pointEntities.forEach(e => this.removeTempEntity(e));
|
|
7117
|
+
group.segmentLabels.forEach(e => this.removeTempEntity(e));
|
|
7118
|
+
if (group.totalLabel) this.removeTempEntity(group.totalLabel);
|
|
7119
|
+
if (group.previewLine) this.removeTempEntity(group.previewLine);
|
|
7120
|
+
if (group.previewPolygon) this.removeTempEntity(group.previewPolygon);
|
|
7121
|
+
if (group.previewOutline) this.removeTempEntity(group.previewOutline);
|
|
7122
|
+
});
|
|
7123
|
+
this._finishedResults = [];
|
|
7124
|
+
}
|
|
7125
|
+
|
|
7126
|
+
/**
|
|
7127
|
+
* 更新预览几何与标注
|
|
7128
|
+
*/
|
|
7129
|
+
_updateMeasurement() {
|
|
7130
|
+
if (this._positions.length === 0) return;
|
|
7131
|
+
|
|
7132
|
+
const positions = [...this._positions];
|
|
7133
|
+
if (this._isMeasuring && this._mousePos) {
|
|
7134
|
+
positions.push(this._mousePos);
|
|
7135
|
+
}
|
|
7136
|
+
|
|
7137
|
+
if (this._measureType === MeasureType.DISTANCE) {
|
|
7138
|
+
this._updateDistancePreview(positions);
|
|
7139
|
+
} else {
|
|
7140
|
+
this._updateAreaPreview(positions);
|
|
7141
|
+
}
|
|
7142
|
+
|
|
7143
|
+
if (this._isMeasuring) {
|
|
7144
|
+
this._emitMeasureProgress(this._computeResult(positions));
|
|
7145
|
+
}
|
|
7146
|
+
}
|
|
7147
|
+
|
|
7148
|
+
_updateDistancePreview(positions) {
|
|
7149
|
+
const cartesians = positions.length >= 2
|
|
7150
|
+
? positions.map(p => Cesium$6.Cartesian3.fromDegrees(...p))
|
|
7151
|
+
: [];
|
|
7152
|
+
this._previewCartesians = cartesians;
|
|
7153
|
+
|
|
7154
|
+
// 预览线
|
|
7155
|
+
if (!this._previewLine) {
|
|
7156
|
+
this._previewLine = this.createTempEntity(this.generateId('measure_line'), {
|
|
7157
|
+
polyline: {
|
|
7158
|
+
positions: new Cesium$6.CallbackProperty(() => this._previewCartesians, false),
|
|
7159
|
+
material: Cesium$6.Color.YELLOW,
|
|
7160
|
+
width: 2,
|
|
7161
|
+
clampToGround: true
|
|
7162
|
+
}
|
|
7163
|
+
});
|
|
7164
|
+
}
|
|
7165
|
+
this._previewLine.show = cartesians.length >= 2;
|
|
7166
|
+
|
|
7167
|
+
// 每段标注
|
|
7168
|
+
const segmentCount = Math.max(0, positions.length - 1);
|
|
7169
|
+
this._ensureSegmentLabels(segmentCount);
|
|
7170
|
+
|
|
7171
|
+
let total = 0;
|
|
7172
|
+
for (let i = 0; i < segmentCount; i++) {
|
|
7173
|
+
const p1 = positions[i];
|
|
7174
|
+
const p2 = positions[i + 1];
|
|
7175
|
+
const dist = GeoCalcUtil.calcDistance(p1, p2);
|
|
7176
|
+
total += dist;
|
|
7177
|
+
|
|
7178
|
+
const mid = Cesium$6.Cartesian3.midpoint(
|
|
7179
|
+
Cesium$6.Cartesian3.fromDegrees(...p1),
|
|
7180
|
+
Cesium$6.Cartesian3.fromDegrees(...p2),
|
|
7181
|
+
new Cesium$6.Cartesian3()
|
|
7182
|
+
);
|
|
7183
|
+
|
|
7184
|
+
const label = this._segmentLabelEntities[i];
|
|
7185
|
+
label.position = mid;
|
|
7186
|
+
label.label.text = this._formatDistance(dist).text;
|
|
7187
|
+
label.show = true;
|
|
7188
|
+
}
|
|
7189
|
+
|
|
7190
|
+
// 总距离标注
|
|
7191
|
+
const lastCartesian = cartesians[cartesians.length - 1];
|
|
7192
|
+
if (positions.length >= 2) {
|
|
7193
|
+
if (!this._totalLabelEntity) {
|
|
7194
|
+
this._totalLabelEntity = this._createLabelEntity(
|
|
7195
|
+
this.generateId('measure_total'),
|
|
7196
|
+
lastCartesian,
|
|
7197
|
+
`总长:${this._formatDistance(total).text}`
|
|
7198
|
+
);
|
|
7199
|
+
} else {
|
|
7200
|
+
this._totalLabelEntity.position = lastCartesian;
|
|
7201
|
+
this._totalLabelEntity.label.text = `总长:${this._formatDistance(total).text}`;
|
|
7202
|
+
this._totalLabelEntity.show = true;
|
|
7203
|
+
}
|
|
7204
|
+
} else if (this._totalLabelEntity) {
|
|
7205
|
+
this._totalLabelEntity.show = false;
|
|
7206
|
+
}
|
|
7207
|
+
}
|
|
7208
|
+
|
|
7209
|
+
_updateAreaPreview(positions) {
|
|
7210
|
+
const cartesians = positions.map(p => Cesium$6.Cartesian3.fromDegrees(...p));
|
|
7211
|
+
this._previewCartesians = cartesians;
|
|
7212
|
+
|
|
7213
|
+
if (positions.length >= 3) {
|
|
7214
|
+
// 显示面 + 闭合轮廓
|
|
7215
|
+
if (!this._previewPolygon) {
|
|
7216
|
+
this._previewPolygon = this.createTempEntity(this.generateId('measure_polygon'), {
|
|
7217
|
+
polygon: {
|
|
7218
|
+
hierarchy: new Cesium$6.CallbackProperty(() => new Cesium$6.PolygonHierarchy(this._previewCartesians), false),
|
|
7219
|
+
material: Cesium$6.Color.YELLOW.withAlpha(0.2),
|
|
7220
|
+
outline: false
|
|
7221
|
+
}
|
|
7222
|
+
});
|
|
7223
|
+
this._previewOutline = this.createTempEntity(this.generateId('measure_outline'), {
|
|
7224
|
+
polyline: {
|
|
7225
|
+
positions: new Cesium$6.CallbackProperty(() => this._previewCartesians.length > 0
|
|
7226
|
+
? [...this._previewCartesians, this._previewCartesians[0]]
|
|
7227
|
+
: [], false),
|
|
7228
|
+
material: Cesium$6.Color.YELLOW,
|
|
7229
|
+
width: 2,
|
|
7230
|
+
clampToGround: true
|
|
7231
|
+
}
|
|
7232
|
+
});
|
|
7233
|
+
}
|
|
7234
|
+
this._previewPolygon.show = true;
|
|
7235
|
+
this._previewOutline.show = true;
|
|
7236
|
+
if (this._previewLine) {
|
|
7237
|
+
this._previewLine.show = false;
|
|
7238
|
+
}
|
|
7239
|
+
|
|
7240
|
+
const area = GeoCalcUtil.calcArea(positions);
|
|
7241
|
+
const centroid = this._computeCentroid(cartesians);
|
|
7242
|
+
|
|
7243
|
+
if (!this._totalLabelEntity) {
|
|
7244
|
+
this._totalLabelEntity = this._createLabelEntity(
|
|
7245
|
+
this.generateId('measure_area'),
|
|
7246
|
+
centroid,
|
|
7247
|
+
`面积:${this._formatArea(area).text}`
|
|
7248
|
+
);
|
|
7249
|
+
} else {
|
|
7250
|
+
this._totalLabelEntity.position = centroid;
|
|
7251
|
+
this._totalLabelEntity.label.text = `面积:${this._formatArea(area).text}`;
|
|
7252
|
+
this._totalLabelEntity.show = true;
|
|
7253
|
+
}
|
|
7254
|
+
} else {
|
|
7255
|
+
// 不足 3 点时只显示连线,并隐藏已有的面、轮廓、面积标注
|
|
7256
|
+
if (this._previewPolygon) {
|
|
7257
|
+
this._previewPolygon.show = false;
|
|
7258
|
+
}
|
|
7259
|
+
if (this._previewOutline) {
|
|
7260
|
+
this._previewOutline.show = false;
|
|
7261
|
+
}
|
|
7262
|
+
if (this._totalLabelEntity) {
|
|
7263
|
+
this._totalLabelEntity.show = false;
|
|
7264
|
+
}
|
|
7265
|
+
|
|
7266
|
+
if (!this._previewLine) {
|
|
7267
|
+
this._previewLine = this.createTempEntity(this.generateId('measure_line'), {
|
|
7268
|
+
polyline: {
|
|
7269
|
+
positions: new Cesium$6.CallbackProperty(() => this._previewCartesians, false),
|
|
7270
|
+
material: Cesium$6.Color.YELLOW,
|
|
7271
|
+
width: 2,
|
|
7272
|
+
clampToGround: true
|
|
7273
|
+
}
|
|
7274
|
+
});
|
|
7275
|
+
}
|
|
7276
|
+
this._previewLine.show = positions.length >= 2;
|
|
7277
|
+
}
|
|
7278
|
+
}
|
|
7279
|
+
|
|
7280
|
+
_ensureSegmentLabels(count) {
|
|
7281
|
+
// 移除多余的标注
|
|
7282
|
+
while (this._segmentLabelEntities.length > count) {
|
|
7283
|
+
const label = this._segmentLabelEntities.pop();
|
|
7284
|
+
this.removeTempEntity(label);
|
|
7285
|
+
}
|
|
7286
|
+
|
|
7287
|
+
// 创建缺少的标注
|
|
7288
|
+
while (this._segmentLabelEntities.length < count) {
|
|
7289
|
+
const label = this._createLabelEntity(
|
|
7290
|
+
this.generateId('measure_segment'),
|
|
7291
|
+
Cesium$6.Cartesian3.ZERO,
|
|
7292
|
+
''
|
|
7293
|
+
);
|
|
7294
|
+
this._segmentLabelEntities.push(label);
|
|
7295
|
+
}
|
|
7296
|
+
}
|
|
7297
|
+
|
|
7298
|
+
_createLabelEntity(id, position, text) {
|
|
7299
|
+
return this.createTempEntity(id, {
|
|
7300
|
+
position,
|
|
7301
|
+
label: {
|
|
7302
|
+
text,
|
|
7303
|
+
font: '14px Microsoft YaHei',
|
|
7304
|
+
fillColor: Cesium$6.Color.WHITE,
|
|
7305
|
+
outlineColor: Cesium$6.Color.BLACK,
|
|
7306
|
+
outlineWidth: 2,
|
|
7307
|
+
style: Cesium$6.LabelStyle.FILL_AND_OUTLINE,
|
|
7308
|
+
verticalOrigin: Cesium$6.VerticalOrigin.BOTTOM,
|
|
7309
|
+
horizontalOrigin: Cesium$6.HorizontalOrigin.CENTER,
|
|
7310
|
+
heightReference: Cesium$6.HeightReference.CLAMP_TO_GROUND,
|
|
7311
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
7312
|
+
pixelOffset: new Cesium$6.Cartesian2(0, -10)
|
|
7313
|
+
}
|
|
7314
|
+
});
|
|
7315
|
+
}
|
|
7316
|
+
|
|
7317
|
+
_addPointMarker(lonLat) {
|
|
7318
|
+
const point = this.createTempEntity(this.generateId('measure_point'), {
|
|
7319
|
+
position: Cesium$6.Cartesian3.fromDegrees(...lonLat),
|
|
7320
|
+
point: {
|
|
7321
|
+
color: Cesium$6.Color.YELLOW,
|
|
7322
|
+
pixelSize: 8,
|
|
7323
|
+
outlineColor: Cesium$6.Color.BLACK,
|
|
7324
|
+
outlineWidth: 1,
|
|
7325
|
+
heightReference: Cesium$6.HeightReference.CLAMP_TO_GROUND,
|
|
7326
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
7327
|
+
}
|
|
7328
|
+
});
|
|
7329
|
+
this._pointEntities.push(point);
|
|
7330
|
+
}
|
|
7331
|
+
|
|
7332
|
+
_computeResult(positions) {
|
|
7333
|
+
if (this._measureType === MeasureType.DISTANCE) {
|
|
7334
|
+
let total = 0;
|
|
7335
|
+
for (let i = 0; i < positions.length - 1; i++) {
|
|
7336
|
+
total += GeoCalcUtil.calcDistance(positions[i], positions[i + 1]);
|
|
7337
|
+
}
|
|
7338
|
+
const fmt = this._formatDistance(total);
|
|
7339
|
+
return {
|
|
7340
|
+
type: MeasureType.DISTANCE,
|
|
7341
|
+
value: total,
|
|
7342
|
+
unit: fmt.unit,
|
|
7343
|
+
formatted: fmt.text,
|
|
7344
|
+
positions: positions.slice()
|
|
7345
|
+
};
|
|
7346
|
+
}
|
|
7347
|
+
|
|
7348
|
+
const area = GeoCalcUtil.calcArea(positions);
|
|
7349
|
+
const fmt = this._formatArea(area);
|
|
7350
|
+
return {
|
|
7351
|
+
type: MeasureType.AREA,
|
|
7352
|
+
value: area,
|
|
7353
|
+
unit: fmt.unit,
|
|
7354
|
+
formatted: fmt.text,
|
|
7355
|
+
positions: positions.slice()
|
|
7356
|
+
};
|
|
7357
|
+
}
|
|
7358
|
+
|
|
7359
|
+
_computeCentroid(cartesians) {
|
|
7360
|
+
const center = new Cesium$6.Cartesian3(0, 0, 0);
|
|
7361
|
+
for (const c of cartesians) {
|
|
7362
|
+
Cesium$6.Cartesian3.add(center, c, center);
|
|
7363
|
+
}
|
|
7364
|
+
return Cesium$6.Cartesian3.multiplyByScalar(center, 1 / cartesians.length, center);
|
|
7365
|
+
}
|
|
7366
|
+
|
|
7367
|
+
_formatDistance(meters) {
|
|
7368
|
+
if (meters >= 1000) {
|
|
7369
|
+
return { text: `${(meters / 1000).toFixed(2)} km`, unit: 'km' };
|
|
7370
|
+
}
|
|
7371
|
+
return { text: `${meters.toFixed(2)} m`, unit: 'm' };
|
|
7372
|
+
}
|
|
7373
|
+
|
|
7374
|
+
_formatArea(squareMeters) {
|
|
7375
|
+
if (squareMeters >= 1000000) {
|
|
7376
|
+
return { text: `${(squareMeters / 1000000).toFixed(3)} km²`, unit: 'km²' };
|
|
7377
|
+
}
|
|
7378
|
+
return { text: `${squareMeters.toFixed(2)} m²`, unit: 'm²' };
|
|
7379
|
+
}
|
|
7380
|
+
|
|
7381
|
+
_emitMeasureProgress(result) {
|
|
7382
|
+
if (this._options.onMeasureProgress) {
|
|
7383
|
+
this._options.onMeasureProgress(result);
|
|
7384
|
+
}
|
|
7385
|
+
}
|
|
7386
|
+
|
|
7387
|
+
_emitMeasureComplete(result) {
|
|
7388
|
+
if (this._options.onMeasureComplete) {
|
|
7389
|
+
this._options.onMeasureComplete(result);
|
|
7390
|
+
}
|
|
7391
|
+
}
|
|
7392
|
+
|
|
7393
|
+
_emitMeasureCancel() {
|
|
7394
|
+
if (this._options.onMeasureCancel) {
|
|
7395
|
+
this._options.onMeasureCancel();
|
|
7396
|
+
}
|
|
7397
|
+
}
|
|
7398
|
+
}
|
|
7399
|
+
|
|
6761
7400
|
/**
|
|
6762
7401
|
* 工具名称枚举
|
|
6763
7402
|
*/
|
|
@@ -6765,7 +7404,8 @@ const ToolName = {
|
|
|
6765
7404
|
DRAW: 'draw',
|
|
6766
7405
|
EDIT: 'edit',
|
|
6767
7406
|
SELECT: 'select',
|
|
6768
|
-
DELETE: 'delete'
|
|
7407
|
+
DELETE: 'delete',
|
|
7408
|
+
MEASURE: 'measure'
|
|
6769
7409
|
};
|
|
6770
7410
|
|
|
6771
7411
|
/**
|
|
@@ -6803,6 +7443,7 @@ class EditorModule {
|
|
|
6803
7443
|
this.registerTool(ToolName.EDIT, new EditTool(this));
|
|
6804
7444
|
this.registerTool(ToolName.SELECT, new SelectTool(this));
|
|
6805
7445
|
this.registerTool(ToolName.DELETE, new DeleteTool(this));
|
|
7446
|
+
this.registerTool(ToolName.MEASURE, new MeasureTool(this));
|
|
6806
7447
|
|
|
6807
7448
|
return this;
|
|
6808
7449
|
}
|
|
@@ -6937,6 +7578,39 @@ class EditorModule {
|
|
|
6937
7578
|
return this.activateTool(ToolName.DELETE);
|
|
6938
7579
|
}
|
|
6939
7580
|
|
|
7581
|
+
/**
|
|
7582
|
+
* 激活测量工具并设置类型
|
|
7583
|
+
* @param {string} type 测量类型 MeasureType
|
|
7584
|
+
* @returns {EditorModule}
|
|
7585
|
+
*/
|
|
7586
|
+
activateMeasureTool(type = MeasureType.DISTANCE) {
|
|
7587
|
+
const measureTool = this.toolMap.get(ToolName.MEASURE);
|
|
7588
|
+
if (!measureTool) {
|
|
7589
|
+
return this;
|
|
7590
|
+
}
|
|
7591
|
+
|
|
7592
|
+
// 已经处于测量工具时:不要 deactivate(避免清空历史结果),
|
|
7593
|
+
// 直接切换类型并把正在进行的测量提交为已完成结果。
|
|
7594
|
+
if (this.currentToolName === ToolName.MEASURE) {
|
|
7595
|
+
measureTool.setMeasureType(type);
|
|
7596
|
+
if (measureTool._isMeasuring) {
|
|
7597
|
+
measureTool._finishMeasurement();
|
|
7598
|
+
}
|
|
7599
|
+
return this;
|
|
7600
|
+
}
|
|
7601
|
+
|
|
7602
|
+
measureTool.setMeasureType(type);
|
|
7603
|
+
return this.activateTool(ToolName.MEASURE);
|
|
7604
|
+
}
|
|
7605
|
+
|
|
7606
|
+
/**
|
|
7607
|
+
* 获取测量工具(快捷方法)
|
|
7608
|
+
* @returns {MeasureTool}
|
|
7609
|
+
*/
|
|
7610
|
+
getMeasureTool() {
|
|
7611
|
+
return this.toolMap.get(ToolName.MEASURE);
|
|
7612
|
+
}
|
|
7613
|
+
|
|
6940
7614
|
/**
|
|
6941
7615
|
* 获取绘制工具(快捷方法)
|
|
6942
7616
|
* @returns {DrawTool}
|
|
@@ -7043,6 +7717,33 @@ class EditorModule {
|
|
|
7043
7717
|
return this;
|
|
7044
7718
|
}
|
|
7045
7719
|
|
|
7720
|
+
/**
|
|
7721
|
+
* 设置测量进度回调
|
|
7722
|
+
* @param {Function} callback
|
|
7723
|
+
*/
|
|
7724
|
+
onMeasureProgress(callback) {
|
|
7725
|
+
this.getMeasureTool()._options.onMeasureProgress = callback;
|
|
7726
|
+
return this;
|
|
7727
|
+
}
|
|
7728
|
+
|
|
7729
|
+
/**
|
|
7730
|
+
* 设置测量完成回调
|
|
7731
|
+
* @param {Function} callback
|
|
7732
|
+
*/
|
|
7733
|
+
onMeasureComplete(callback) {
|
|
7734
|
+
this.getMeasureTool()._options.onMeasureComplete = callback;
|
|
7735
|
+
return this;
|
|
7736
|
+
}
|
|
7737
|
+
|
|
7738
|
+
/**
|
|
7739
|
+
* 设置测量取消回调
|
|
7740
|
+
* @param {Function} callback
|
|
7741
|
+
*/
|
|
7742
|
+
onMeasureCancel(callback) {
|
|
7743
|
+
this.getMeasureTool()._options.onMeasureCancel = callback;
|
|
7744
|
+
return this;
|
|
7745
|
+
}
|
|
7746
|
+
|
|
7046
7747
|
/**
|
|
7047
7748
|
* 设置删除前回调
|
|
7048
7749
|
* @param {Function} callback
|
|
@@ -7382,7 +8083,7 @@ class BaseControl {
|
|
|
7382
8083
|
_destroy() { }
|
|
7383
8084
|
}
|
|
7384
8085
|
|
|
7385
|
-
const Cesium$
|
|
8086
|
+
const Cesium$5 = getCesium();
|
|
7386
8087
|
|
|
7387
8088
|
/**
|
|
7388
8089
|
* 状态栏控件
|
|
@@ -7462,7 +8163,7 @@ class LocationBar extends BaseControl {
|
|
|
7462
8163
|
const rect = this._viewer.scene.canvas.getBoundingClientRect();
|
|
7463
8164
|
const x = e.clientX - rect.left;
|
|
7464
8165
|
const y = e.clientY - rect.top;
|
|
7465
|
-
const screenPos = new Cesium$
|
|
8166
|
+
const screenPos = new Cesium$5.Cartesian2(x, y);
|
|
7466
8167
|
|
|
7467
8168
|
let cartesian = null;
|
|
7468
8169
|
|
|
@@ -7478,10 +8179,10 @@ class LocationBar extends BaseControl {
|
|
|
7478
8179
|
}
|
|
7479
8180
|
|
|
7480
8181
|
if (cartesian) {
|
|
7481
|
-
const cartographic = Cesium$
|
|
8182
|
+
const cartographic = Cesium$5.Cartographic.fromCartesian(cartesian);
|
|
7482
8183
|
this._lastMouseData = {
|
|
7483
|
-
lng: Cesium$
|
|
7484
|
-
lat: Cesium$
|
|
8184
|
+
lng: Cesium$5.Math.toDegrees(cartographic.longitude).toFixed(this._lngDecimal),
|
|
8185
|
+
lat: Cesium$5.Math.toDegrees(cartographic.latitude).toFixed(this._latDecimal),
|
|
7485
8186
|
alt: cartographic.height.toFixed(2)
|
|
7486
8187
|
};
|
|
7487
8188
|
} else {
|
|
@@ -7501,8 +8202,8 @@ class LocationBar extends BaseControl {
|
|
|
7501
8202
|
const positionCartographic = camera.positionCartographic;
|
|
7502
8203
|
|
|
7503
8204
|
this._lastCameraData = {
|
|
7504
|
-
heading: Cesium$
|
|
7505
|
-
pitch: Cesium$
|
|
8205
|
+
heading: Cesium$5.Math.toDegrees(camera.heading).toFixed(2),
|
|
8206
|
+
pitch: Cesium$5.Math.toDegrees(camera.pitch).toFixed(2),
|
|
7506
8207
|
cameraHeight: positionCartographic.height.toFixed(2),
|
|
7507
8208
|
level: this._getZoomLevel().toFixed(0)
|
|
7508
8209
|
};
|
|
@@ -7528,12 +8229,12 @@ class LocationBar extends BaseControl {
|
|
|
7528
8229
|
const positionCartographic = camera.positionCartographic;
|
|
7529
8230
|
|
|
7530
8231
|
// 计算相机到正下方地表点的距离(视高),而不是到自己位置的距离
|
|
7531
|
-
const surfaceCartesian = Cesium$
|
|
8232
|
+
const surfaceCartesian = Cesium$5.Cartesian3.fromRadians(
|
|
7532
8233
|
positionCartographic.longitude,
|
|
7533
8234
|
positionCartographic.latitude,
|
|
7534
8235
|
0
|
|
7535
8236
|
);
|
|
7536
|
-
const distance = Cesium$
|
|
8237
|
+
const distance = Cesium$5.Cartesian3.distance(camera.position, surfaceCartesian);
|
|
7537
8238
|
|
|
7538
8239
|
if (!distance || distance <= 0 || !Number.isFinite(distance)) return 0;
|
|
7539
8240
|
|
|
@@ -7565,7 +8266,7 @@ class LocationBar extends BaseControl {
|
|
|
7565
8266
|
}
|
|
7566
8267
|
}
|
|
7567
8268
|
|
|
7568
|
-
const Cesium$
|
|
8269
|
+
const Cesium$4 = getCesium();
|
|
7569
8270
|
|
|
7570
8271
|
/**
|
|
7571
8272
|
* 缩放控件
|
|
@@ -7588,7 +8289,11 @@ class Zoom extends BaseControl {
|
|
|
7588
8289
|
_createContainer() {
|
|
7589
8290
|
const div = super._createContainer();
|
|
7590
8291
|
div.className += ' xs3d-zoom';
|
|
7591
|
-
|
|
8292
|
+
// 只有在统一工具栏内才使用 display: contents,让按钮直接参与工具栏 flex 布局;
|
|
8293
|
+
// 自定义容器挂载时保留正常 absolute 定位,支持 top/left/right/bottom。
|
|
8294
|
+
if (this._parentContainer?.classList?.contains('xs3d-viewer-toolbar')) {
|
|
8295
|
+
div.style.display = 'contents';
|
|
8296
|
+
}
|
|
7592
8297
|
return div;
|
|
7593
8298
|
}
|
|
7594
8299
|
|
|
@@ -7661,7 +8366,7 @@ class Zoom extends BaseControl {
|
|
|
7661
8366
|
const targetHeight = this._getHeightByZoomLevel(targetLevel);
|
|
7662
8367
|
|
|
7663
8368
|
camera.flyTo({
|
|
7664
|
-
destination: Cesium$
|
|
8369
|
+
destination: Cesium$4.Cartesian3.fromRadians(
|
|
7665
8370
|
cartographic.longitude,
|
|
7666
8371
|
cartographic.latitude,
|
|
7667
8372
|
targetHeight
|
|
@@ -7677,12 +8382,12 @@ class Zoom extends BaseControl {
|
|
|
7677
8382
|
|
|
7678
8383
|
_getZoomLevel() {
|
|
7679
8384
|
const positionCartographic = this._viewer.camera.positionCartographic;
|
|
7680
|
-
const surfaceCartesian = Cesium$
|
|
8385
|
+
const surfaceCartesian = Cesium$4.Cartesian3.fromRadians(
|
|
7681
8386
|
positionCartographic.longitude,
|
|
7682
8387
|
positionCartographic.latitude,
|
|
7683
8388
|
0
|
|
7684
8389
|
);
|
|
7685
|
-
const distance = Cesium$
|
|
8390
|
+
const distance = Cesium$4.Cartesian3.distance(this._viewer.camera.position, surfaceCartesian);
|
|
7686
8391
|
if (!distance || distance <= 0 || !Number.isFinite(distance)) return 0;
|
|
7687
8392
|
const equatorCircumference = 6378137 * 2 * Math.PI;
|
|
7688
8393
|
return Math.max(0, Math.floor(Math.log2(equatorCircumference / distance)) + 1);
|
|
@@ -7694,7 +8399,7 @@ class Zoom extends BaseControl {
|
|
|
7694
8399
|
}
|
|
7695
8400
|
}
|
|
7696
8401
|
|
|
7697
|
-
const Cesium$
|
|
8402
|
+
const Cesium$3 = getCesium();
|
|
7698
8403
|
|
|
7699
8404
|
/**
|
|
7700
8405
|
* 指南针控件
|
|
@@ -7845,7 +8550,7 @@ class Compass extends BaseControl {
|
|
|
7845
8550
|
|
|
7846
8551
|
_updateRotation() {
|
|
7847
8552
|
if (!this._outerEl) return;
|
|
7848
|
-
const heading = Cesium$
|
|
8553
|
+
const heading = Cesium$3.Math.toDegrees(this._viewer.camera.heading);
|
|
7849
8554
|
this._outerEl.style.transform = `rotate(${-heading}deg)`;
|
|
7850
8555
|
}
|
|
7851
8556
|
|
|
@@ -7898,7 +8603,7 @@ class Compass extends BaseControl {
|
|
|
7898
8603
|
|
|
7899
8604
|
const camera = this._viewer.camera;
|
|
7900
8605
|
if (this._rotateFrame) {
|
|
7901
|
-
const oldTransform = Cesium$
|
|
8606
|
+
const oldTransform = Cesium$3.Matrix4.clone(camera.transform);
|
|
7902
8607
|
camera.lookAtTransform(this._rotateFrame);
|
|
7903
8608
|
camera.rotateRight(delta);
|
|
7904
8609
|
camera.lookAtTransform(oldTransform);
|
|
@@ -7940,10 +8645,10 @@ class Compass extends BaseControl {
|
|
|
7940
8645
|
if (this._mode !== 'orbit') return;
|
|
7941
8646
|
const deltaY = this._startY - e.clientY;
|
|
7942
8647
|
const sensitivity = 0.004;
|
|
7943
|
-
const newPitch = Cesium$
|
|
8648
|
+
const newPitch = Cesium$3.Math.clamp(
|
|
7944
8649
|
this._startPitch + deltaY * sensitivity,
|
|
7945
|
-
-Cesium$
|
|
7946
|
-
Cesium$
|
|
8650
|
+
-Cesium$3.Math.PI_OVER_TWO + 0.01,
|
|
8651
|
+
Cesium$3.Math.PI_OVER_TWO - 0.01
|
|
7947
8652
|
);
|
|
7948
8653
|
this._viewer.camera.setView({
|
|
7949
8654
|
destination: this._viewer.camera.position,
|
|
@@ -7967,26 +8672,26 @@ class Compass extends BaseControl {
|
|
|
7967
8672
|
_getRotateFrame() {
|
|
7968
8673
|
const scene = this._viewer.scene;
|
|
7969
8674
|
const camera = this._viewer.camera;
|
|
7970
|
-
if (scene.mode === Cesium$
|
|
8675
|
+
if (scene.mode === Cesium$3.SceneMode.MORPHING) return null;
|
|
7971
8676
|
|
|
7972
8677
|
let center;
|
|
7973
8678
|
if (this._viewer.trackedEntity) {
|
|
7974
8679
|
center = this._viewer.trackedEntity.position.getValue(this._viewer.clock.currentTime);
|
|
7975
8680
|
} else {
|
|
7976
|
-
const ray = new Cesium$
|
|
8681
|
+
const ray = new Cesium$3.Ray(camera.positionWC, camera.directionWC);
|
|
7977
8682
|
center = scene.globe.pick(ray, scene);
|
|
7978
8683
|
}
|
|
7979
8684
|
if (!center) {
|
|
7980
8685
|
center = camera.positionWC;
|
|
7981
8686
|
}
|
|
7982
|
-
return Cesium$
|
|
8687
|
+
return Cesium$3.Transforms.eastNorthUpToFixedFrame(center, scene.globe.ellipsoid);
|
|
7983
8688
|
}
|
|
7984
8689
|
|
|
7985
8690
|
_onDoubleClick() {
|
|
7986
8691
|
const camera = this._viewer.camera;
|
|
7987
8692
|
const cartographic = camera.positionCartographic;
|
|
7988
8693
|
camera.flyTo({
|
|
7989
|
-
destination: Cesium$
|
|
8694
|
+
destination: Cesium$3.Cartesian3.fromRadians(
|
|
7990
8695
|
cartographic.longitude,
|
|
7991
8696
|
cartographic.latitude,
|
|
7992
8697
|
cartographic.height
|
|
@@ -8007,7 +8712,7 @@ class Compass extends BaseControl {
|
|
|
8007
8712
|
}
|
|
8008
8713
|
}
|
|
8009
8714
|
|
|
8010
|
-
const Cesium$
|
|
8715
|
+
const Cesium$2 = getCesium();
|
|
8011
8716
|
|
|
8012
8717
|
/**
|
|
8013
8718
|
* 比例尺控件
|
|
@@ -8039,7 +8744,7 @@ class DistanceLegend extends BaseControl {
|
|
|
8039
8744
|
base.forEach(b => this._distances.push(b * factor));
|
|
8040
8745
|
}
|
|
8041
8746
|
|
|
8042
|
-
this._geodesic = new Cesium$
|
|
8747
|
+
this._geodesic = new Cesium$2.EllipsoidGeodesic();
|
|
8043
8748
|
this._lastUpdate = 0;
|
|
8044
8749
|
}
|
|
8045
8750
|
|
|
@@ -8097,8 +8802,8 @@ class DistanceLegend extends BaseControl {
|
|
|
8097
8802
|
const x = Math.floor(width / 2);
|
|
8098
8803
|
const y = Math.max(0, height - 1);
|
|
8099
8804
|
|
|
8100
|
-
const leftRay = camera.getPickRay(new Cesium$
|
|
8101
|
-
const rightRay = camera.getPickRay(new Cesium$
|
|
8805
|
+
const leftRay = camera.getPickRay(new Cesium$2.Cartesian2(x, y));
|
|
8806
|
+
const rightRay = camera.getPickRay(new Cesium$2.Cartesian2(x + 1, y));
|
|
8102
8807
|
if (!leftRay || !rightRay) return;
|
|
8103
8808
|
|
|
8104
8809
|
const leftPosition = scene.globe.pick(leftRay, scene);
|
|
@@ -8337,7 +9042,7 @@ class ControlModule {
|
|
|
8337
9042
|
* 统一管理场景、图元、事件模块的实例
|
|
8338
9043
|
*/
|
|
8339
9044
|
|
|
8340
|
-
const Cesium$
|
|
9045
|
+
const Cesium$1 = getCesium();
|
|
8341
9046
|
|
|
8342
9047
|
class ModuleManager {
|
|
8343
9048
|
static instance = null;
|
|
@@ -8362,13 +9067,19 @@ class ModuleManager {
|
|
|
8362
9067
|
if (this.cesiumViewer) return this.cesiumViewer;
|
|
8363
9068
|
const config = Config.getInstance().getConfig();
|
|
8364
9069
|
|
|
8365
|
-
this.cesiumViewer = new Cesium$
|
|
9070
|
+
this.cesiumViewer = new Cesium$1.Viewer(container, config.scene);
|
|
8366
9071
|
// 隐藏版权信息(可选,对齐平台界面规范)
|
|
8367
9072
|
const creditContainer = this.cesiumViewer.cesiumWidget?.creditContainer;
|
|
8368
9073
|
if (creditContainer) {
|
|
8369
9074
|
creditContainer.style.display = 'none';
|
|
8370
9075
|
}
|
|
8371
9076
|
|
|
9077
|
+
// 禁用画布默认右键菜单,保证 Cesium 右键事件可被正常处理
|
|
9078
|
+
const canvas = this.cesiumViewer.scene?.canvas;
|
|
9079
|
+
if (canvas) {
|
|
9080
|
+
canvas.addEventListener('contextmenu', (e) => e.preventDefault(), false);
|
|
9081
|
+
}
|
|
9082
|
+
|
|
8372
9083
|
// 初始化所有模块(注入 Viewer 实例)
|
|
8373
9084
|
this.registerModule('SceneModule', new SceneModule(this.cesiumViewer));
|
|
8374
9085
|
this.registerModule('GraphicModule', new GraphicModule(this.cesiumViewer));
|
|
@@ -8514,7 +9225,7 @@ class ModuleManager {
|
|
|
8514
9225
|
}
|
|
8515
9226
|
}
|
|
8516
9227
|
|
|
8517
|
-
const Cesium
|
|
9228
|
+
const Cesium = getCesium();
|
|
8518
9229
|
|
|
8519
9230
|
/**
|
|
8520
9231
|
* 坐标转换工具(对齐平台 屏幕/世界/地理坐标转换)
|
|
@@ -8534,12 +9245,12 @@ class CoordinateUtil {
|
|
|
8534
9245
|
if (Array.isArray(coord)) {
|
|
8535
9246
|
if (from === 'scene') {
|
|
8536
9247
|
// 地理坐标转世界坐标
|
|
8537
|
-
sourceCoord = Cesium
|
|
9248
|
+
sourceCoord = Cesium.Cartesian3.fromDegrees(...coord);
|
|
8538
9249
|
} else if (from === 'world') {
|
|
8539
|
-
sourceCoord = new Cesium
|
|
9250
|
+
sourceCoord = new Cesium.Cartesian3(coord[0], coord[1], coord[2]);
|
|
8540
9251
|
} else if (from === 'screen') {
|
|
8541
9252
|
// 屏幕坐标数组需先转为 Cartesian2
|
|
8542
|
-
sourceCoord = new Cesium
|
|
9253
|
+
sourceCoord = new Cesium.Cartesian2(coord[0], coord[1]);
|
|
8543
9254
|
}
|
|
8544
9255
|
}
|
|
8545
9256
|
|
|
@@ -8551,21 +9262,21 @@ class CoordinateUtil {
|
|
|
8551
9262
|
// 屏幕坐标 -> 地理坐标
|
|
8552
9263
|
case 'screen_scene':
|
|
8553
9264
|
const worldCoord = viewer.camera.pickEllipsoid(sourceCoord);
|
|
8554
|
-
const cartographic = Cesium
|
|
9265
|
+
const cartographic = Cesium.Cartographic.fromCartesian(worldCoord);
|
|
8555
9266
|
return [
|
|
8556
|
-
Cesium
|
|
8557
|
-
Cesium
|
|
9267
|
+
Cesium.Math.toDegrees(cartographic.longitude),
|
|
9268
|
+
Cesium.Math.toDegrees(cartographic.latitude),
|
|
8558
9269
|
cartographic.height
|
|
8559
9270
|
];
|
|
8560
9271
|
// 世界坐标 -> 屏幕坐标
|
|
8561
9272
|
case 'world_screen':
|
|
8562
|
-
return Cesium
|
|
9273
|
+
return Cesium.SceneTransforms.wgs84ToWindowCoordinates(viewer.scene, sourceCoord);
|
|
8563
9274
|
// 世界坐标 -> 地理坐标
|
|
8564
9275
|
case 'world_scene':
|
|
8565
|
-
const carto = Cesium
|
|
9276
|
+
const carto = Cesium.Cartographic.fromCartesian(sourceCoord);
|
|
8566
9277
|
return [
|
|
8567
|
-
Cesium
|
|
8568
|
-
Cesium
|
|
9278
|
+
Cesium.Math.toDegrees(carto.longitude),
|
|
9279
|
+
Cesium.Math.toDegrees(carto.latitude),
|
|
8569
9280
|
carto.height
|
|
8570
9281
|
];
|
|
8571
9282
|
// 地理坐标 -> 世界坐标(已在入参处理)
|
|
@@ -8573,111 +9284,13 @@ class CoordinateUtil {
|
|
|
8573
9284
|
return sourceCoord;
|
|
8574
9285
|
// 地理坐标 -> 屏幕坐标
|
|
8575
9286
|
case 'scene_screen':
|
|
8576
|
-
return Cesium
|
|
9287
|
+
return Cesium.SceneTransforms.wgs84ToWindowCoordinates(viewer.scene, sourceCoord);
|
|
8577
9288
|
default:
|
|
8578
9289
|
return sourceCoord;
|
|
8579
9290
|
}
|
|
8580
9291
|
}
|
|
8581
9292
|
}
|
|
8582
9293
|
|
|
8583
|
-
const Cesium = getCesium();
|
|
8584
|
-
|
|
8585
|
-
/**
|
|
8586
|
-
* 地理计算工具(距离、面积、高程)
|
|
8587
|
-
*/
|
|
8588
|
-
class GeoCalcUtil {
|
|
8589
|
-
/**
|
|
8590
|
-
* 计算两点地理坐标距离(米)
|
|
8591
|
-
* @param {Array<number>} point1 [lng, lat, height]
|
|
8592
|
-
* @param {Array<number>} point2 [lng, lat, height]
|
|
8593
|
-
* @returns {number} 距离
|
|
8594
|
-
*/
|
|
8595
|
-
static calcDistance(point1, point2) {
|
|
8596
|
-
const coord1 = Cesium.Cartesian3.fromDegrees(...point1);
|
|
8597
|
-
const coord2 = Cesium.Cartesian3.fromDegrees(...point2);
|
|
8598
|
-
return Cesium.Cartesian3.distance(coord1, coord2);
|
|
8599
|
-
}
|
|
8600
|
-
|
|
8601
|
-
/**
|
|
8602
|
-
* 计算多边形面积(平方米)
|
|
8603
|
-
* 使用球面多边形面积公式(基于 Cesium 几何顶点)
|
|
8604
|
-
* @param {Array<Array<number>>} points 地理坐标点集 [lon, lat, height?]
|
|
8605
|
-
* @returns {number} 面积
|
|
8606
|
-
*/
|
|
8607
|
-
static calcArea(points) {
|
|
8608
|
-
if (!points || points.length < 3) return 0;
|
|
8609
|
-
|
|
8610
|
-
const positions = points.map(p => Cesium.Cartesian3.fromDegrees(p[0], p[1], p[2] || 0));
|
|
8611
|
-
const polygon = new Cesium.PolygonGeometry({
|
|
8612
|
-
polygonHierarchy: new Cesium.PolygonHierarchy(positions)
|
|
8613
|
-
});
|
|
8614
|
-
const geometry = Cesium.PolygonGeometry.createGeometry(polygon);
|
|
8615
|
-
|
|
8616
|
-
if (!geometry || !geometry.attributes || !geometry.attributes.position) {
|
|
8617
|
-
return 0;
|
|
8618
|
-
}
|
|
8619
|
-
|
|
8620
|
-
const values = geometry.attributes.position.values;
|
|
8621
|
-
const vertexPositions = [];
|
|
8622
|
-
for (let i = 0; i < values.length; i += 3) {
|
|
8623
|
-
vertexPositions.push(new Cesium.Cartesian3(values[i], values[i + 1], values[i + 2]));
|
|
8624
|
-
}
|
|
8625
|
-
|
|
8626
|
-
// 球面多边形面积(基于单位球上的多边形面积公式)
|
|
8627
|
-
const area = GeoCalcUtil.#sphericalPolygonArea(vertexPositions);
|
|
8628
|
-
return Math.abs(area);
|
|
8629
|
-
}
|
|
8630
|
-
|
|
8631
|
-
/**
|
|
8632
|
-
* 单位球面上多边形的有向面积(平方米)
|
|
8633
|
-
* 采用局部切平面投影法:以多边形重心为原点建立切平面,投影后计算二维多边形面积。
|
|
8634
|
-
* 对于常规 GIS 多边形精度足够;极大规模多边形可后续替换为更严格的球面 excess 算法。
|
|
8635
|
-
* @param {Cesium.Cartesian3[]} positions 世界坐标顶点
|
|
8636
|
-
* @returns {number} 面积(平方米)
|
|
8637
|
-
*/
|
|
8638
|
-
static #sphericalPolygonArea(positions) {
|
|
8639
|
-
const ellipsoid = Cesium.Ellipsoid.WGS84;
|
|
8640
|
-
const n = positions.length;
|
|
8641
|
-
if (n < 3) return 0;
|
|
8642
|
-
|
|
8643
|
-
// 计算近似重心(归一化到椭球面)
|
|
8644
|
-
let center = new Cesium.Cartesian3(0, 0, 0);
|
|
8645
|
-
for (const p of positions) {
|
|
8646
|
-
center = Cesium.Cartesian3.add(center, p, center);
|
|
8647
|
-
}
|
|
8648
|
-
center = Cesium.Cartesian3.normalize(center, new Cesium.Cartesian3());
|
|
8649
|
-
center = ellipsoid.scaleToGeodeticSurface(center, new Cesium.Cartesian3()) || center;
|
|
8650
|
-
|
|
8651
|
-
// 在重心处建立东北天(ENU)局部坐标系
|
|
8652
|
-
const tangentPlane = new Cesium.EllipsoidTangentPlane(center, ellipsoid);
|
|
8653
|
-
|
|
8654
|
-
// 投影到切平面
|
|
8655
|
-
const projected = positions.map(p => tangentPlane.projectPointOntoPlane(p, new Cesium.Cartesian2()));
|
|
8656
|
-
|
|
8657
|
-
// 计算二维多边形面积(Shoelace 公式)
|
|
8658
|
-
let area2 = 0;
|
|
8659
|
-
for (let i = 0; i < n; i++) {
|
|
8660
|
-
const p1 = projected[i];
|
|
8661
|
-
const p2 = projected[(i + 1) % n];
|
|
8662
|
-
area2 += p1.x * p2.y - p2.x * p1.y;
|
|
8663
|
-
}
|
|
8664
|
-
|
|
8665
|
-
return Math.abs(area2) * 0.5;
|
|
8666
|
-
}
|
|
8667
|
-
|
|
8668
|
-
/**
|
|
8669
|
-
* 获取指定地理坐标的高程
|
|
8670
|
-
* @param {Cesium.Viewer} viewer Cesium 实例
|
|
8671
|
-
* @param {Array<number>} coord [lng, lat]
|
|
8672
|
-
* @returns {Promise<number>} 高程值
|
|
8673
|
-
*/
|
|
8674
|
-
static async getHeight(viewer, coord) {
|
|
8675
|
-
const cartographic = Cesium.Cartographic.fromDegrees(coord[0], coord[1]);
|
|
8676
|
-
const results = await Cesium.sampleTerrainMostDetailed(viewer.terrainProvider, [cartographic]);
|
|
8677
|
-
return results[0]?.height ?? 0;
|
|
8678
|
-
}
|
|
8679
|
-
}
|
|
8680
|
-
|
|
8681
9294
|
// src/index.js
|
|
8682
9295
|
|
|
8683
9296
|
// 核心 SDK 实例(直接导出,无嵌套)
|
|
@@ -8731,6 +9344,7 @@ const xs3d = {
|
|
|
8731
9344
|
SelectType,
|
|
8732
9345
|
DeleteMode,
|
|
8733
9346
|
ToolName,
|
|
9347
|
+
MeasureType,
|
|
8734
9348
|
LayerType,
|
|
8735
9349
|
PlotGraphicType
|
|
8736
9350
|
};
|