cesium-xs-sdk 1.0.7 → 1.0.9
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 +1483 -712
- package/dist/cesium-xs-sdk.cjs.js.map +1 -1
- package/dist/cesium-xs-sdk.esm.js +1483 -712
- 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 +135 -131
- package/src/core/ModuleManager.js +6 -0
- package/src/index.d.ts +6 -0
- package/src/index.js +2 -1
- package/src/modules/EditorModule.js +65 -1
- package/src/modules/GraphicModule.js +158 -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 +6 -6
- package/src/vue.js +29 -35
|
@@ -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
|
|
|
@@ -3039,6 +3047,9 @@ class GraphicModule {
|
|
|
3039
3047
|
return false;
|
|
3040
3048
|
}
|
|
3041
3049
|
|
|
3050
|
+
// 清理可能存在的 outline 等关联 entity
|
|
3051
|
+
this.removeOutline(graphicId);
|
|
3052
|
+
|
|
3042
3053
|
const entity = this.graphicMap.get(graphicId);
|
|
3043
3054
|
this.viewer.entities.remove(entity);
|
|
3044
3055
|
this.graphicMap.delete(graphicId);
|
|
@@ -3054,9 +3065,163 @@ class GraphicModule {
|
|
|
3054
3065
|
getGraphic(graphicId) {
|
|
3055
3066
|
return this.graphicMap.get(graphicId);
|
|
3056
3067
|
}
|
|
3068
|
+
|
|
3069
|
+
/**
|
|
3070
|
+
* 从 entity 中提取顶点坐标
|
|
3071
|
+
* 支持 point / polyline / polygon
|
|
3072
|
+
* @private
|
|
3073
|
+
* @param {Cesium.Entity} entity 图元实体
|
|
3074
|
+
* @returns {Cesium.Cartesian3[]} 顶点坐标数组
|
|
3075
|
+
*/
|
|
3076
|
+
_getEntityPositions(entity) {
|
|
3077
|
+
const getValue = (prop) => {
|
|
3078
|
+
if (prop == null) return undefined;
|
|
3079
|
+
return typeof prop.getValue === 'function' ? prop.getValue(Cesium$e.JulianDate.now()) : prop;
|
|
3080
|
+
};
|
|
3081
|
+
|
|
3082
|
+
// 优先按 geometry 类型取顶点,避免 polygon/polyline 也带 position 时只拿到中心点
|
|
3083
|
+
if (entity.polygon?.hierarchy) {
|
|
3084
|
+
const hierarchy = getValue(entity.polygon.hierarchy);
|
|
3085
|
+
if (Array.isArray(hierarchy)) return hierarchy;
|
|
3086
|
+
if (Array.isArray(hierarchy?.positions)) return hierarchy.positions;
|
|
3087
|
+
return [];
|
|
3088
|
+
}
|
|
3089
|
+
if (entity.polyline?.positions) {
|
|
3090
|
+
return getValue(entity.polyline.positions) ?? [];
|
|
3091
|
+
}
|
|
3092
|
+
if (entity.position) {
|
|
3093
|
+
const p = getValue(entity.position);
|
|
3094
|
+
return p ? [p] : [];
|
|
3095
|
+
}
|
|
3096
|
+
return [];
|
|
3097
|
+
}
|
|
3098
|
+
|
|
3099
|
+
/**
|
|
3100
|
+
* 获取图元顶点坐标
|
|
3101
|
+
* @param {string|Cesium.Entity} graphicIdOrEntity 图元ID或实体
|
|
3102
|
+
* @returns {Cesium.Cartesian3[]} 顶点坐标数组
|
|
3103
|
+
*/
|
|
3104
|
+
getPositions(graphicIdOrEntity) {
|
|
3105
|
+
const entity = typeof graphicIdOrEntity === 'string'
|
|
3106
|
+
? this.getGraphic(graphicIdOrEntity)
|
|
3107
|
+
: graphicIdOrEntity;
|
|
3108
|
+
return entity ? this._getEntityPositions(entity) : [];
|
|
3109
|
+
}
|
|
3110
|
+
|
|
3111
|
+
/**
|
|
3112
|
+
* 获取图元包围球
|
|
3113
|
+
* @param {string|Cesium.Entity} graphicIdOrEntity 图元ID或实体
|
|
3114
|
+
* @returns {Cesium.BoundingSphere|null} 包围球
|
|
3115
|
+
*/
|
|
3116
|
+
getBoundingSphere(graphicIdOrEntity) {
|
|
3117
|
+
const positions = this.getPositions(graphicIdOrEntity);
|
|
3118
|
+
if (!positions.length) return null;
|
|
3119
|
+
|
|
3120
|
+
const sphere = Cesium$e.BoundingSphere.fromPoints(positions);
|
|
3121
|
+
// 点图元只有单个坐标,radius 为 0,给一个最小可视半径避免相机钻进点里
|
|
3122
|
+
if (positions.length === 1 && sphere.radius === 0) {
|
|
3123
|
+
sphere.radius = 5000;
|
|
3124
|
+
}
|
|
3125
|
+
return sphere;
|
|
3126
|
+
}
|
|
3127
|
+
|
|
3128
|
+
/**
|
|
3129
|
+
* 飞行定位到图元
|
|
3130
|
+
* @param {string|Cesium.Entity} graphicIdOrEntity 图元ID或实体
|
|
3131
|
+
* @param {object} options 配置项 { pitch?, padding?, duration? }
|
|
3132
|
+
* @returns {Promise<boolean>}
|
|
3133
|
+
*/
|
|
3134
|
+
flyTo(graphicIdOrEntity, options = {}) {
|
|
3135
|
+
const entity = typeof graphicIdOrEntity === 'string'
|
|
3136
|
+
? this.getGraphic(graphicIdOrEntity)
|
|
3137
|
+
: graphicIdOrEntity;
|
|
3138
|
+
if (!entity || !this.viewer) return Promise.resolve(false);
|
|
3139
|
+
|
|
3140
|
+
const sphere = this.getBoundingSphere(entity);
|
|
3141
|
+
if (!sphere) return Promise.resolve(false);
|
|
3142
|
+
|
|
3143
|
+
const pitch = options.pitch ?? -Cesium$e.Math.PI_OVER_TWO;
|
|
3144
|
+
const padding = options.padding ?? 2;
|
|
3145
|
+
const fovy = this.viewer.camera.frustum.fovy;
|
|
3146
|
+
const range = (sphere.radius / Math.tan(fovy / 2)) * padding;
|
|
3147
|
+
|
|
3148
|
+
return this.viewer.camera.flyToBoundingSphere(sphere, {
|
|
3149
|
+
duration: options.duration ?? 1.5,
|
|
3150
|
+
offset: new Cesium$e.HeadingPitchRange(0, pitch, range),
|
|
3151
|
+
}).then(() => true).catch((err) => {
|
|
3152
|
+
console.error('图元定位失败', err);
|
|
3153
|
+
return false;
|
|
3154
|
+
});
|
|
3155
|
+
}
|
|
3156
|
+
|
|
3157
|
+
/**
|
|
3158
|
+
* 瞬间定位到图元(无动画)
|
|
3159
|
+
* @param {string|Cesium.Entity} graphicIdOrEntity 图元ID或实体
|
|
3160
|
+
* @param {object} options 配置项 { pitch?, padding? }
|
|
3161
|
+
*/
|
|
3162
|
+
zoomTo(graphicIdOrEntity, options = {}) {
|
|
3163
|
+
const entity = typeof graphicIdOrEntity === 'string'
|
|
3164
|
+
? this.getGraphic(graphicIdOrEntity)
|
|
3165
|
+
: graphicIdOrEntity;
|
|
3166
|
+
if (!entity || !this.viewer) return;
|
|
3167
|
+
|
|
3168
|
+
const sphere = this.getBoundingSphere(entity);
|
|
3169
|
+
if (!sphere) return;
|
|
3170
|
+
|
|
3171
|
+
const pitch = options.pitch ?? -Cesium$e.Math.PI_OVER_TWO;
|
|
3172
|
+
const padding = options.padding ?? 2;
|
|
3173
|
+
const fovy = this.viewer.camera.frustum.fovy;
|
|
3174
|
+
const range = (sphere.radius / Math.tan(fovy / 2)) * padding;
|
|
3175
|
+
|
|
3176
|
+
this.viewer.camera.viewBoundingSphere(sphere, new Cesium$e.HeadingPitchRange(0, pitch, range));
|
|
3177
|
+
}
|
|
3178
|
+
|
|
3179
|
+
/**
|
|
3180
|
+
* 为面图元设置/移除外边框(用 polyline 模拟,解决 Cesium 贴地 polygon 不支持 outline 的问题)
|
|
3181
|
+
* @param {string} graphicId 图元ID
|
|
3182
|
+
* @param {object} options 配置项 { enabled, color, width }
|
|
3183
|
+
* @returns {boolean} 是否设置成功
|
|
3184
|
+
*/
|
|
3185
|
+
setOutline(graphicId, options = {}) {
|
|
3186
|
+
const entity = this.getGraphic(graphicId);
|
|
3187
|
+
if (!entity || !entity.polygon || !this.viewer) return false;
|
|
3188
|
+
|
|
3189
|
+
// 先移除旧的
|
|
3190
|
+
this.removeOutline(graphicId);
|
|
3191
|
+
|
|
3192
|
+
if (!options.enabled) return true;
|
|
3193
|
+
|
|
3194
|
+
const positions = this._getEntityPositions(entity);
|
|
3195
|
+
if (positions.length < 3) return false;
|
|
3196
|
+
|
|
3197
|
+
const closedPositions = [...positions, positions[0]];
|
|
3198
|
+
const outlineId = `${graphicId}_outline`;
|
|
3199
|
+
const color = options.color ?? Cesium$e.Color.WHITE;
|
|
3200
|
+
const width = options.width ?? 2;
|
|
3201
|
+
|
|
3202
|
+
this.viewer.entities.add({
|
|
3203
|
+
id: outlineId,
|
|
3204
|
+
polyline: {
|
|
3205
|
+
positions: closedPositions,
|
|
3206
|
+
width,
|
|
3207
|
+
material: color,
|
|
3208
|
+
clampToGround: true,
|
|
3209
|
+
},
|
|
3210
|
+
});
|
|
3211
|
+
return true;
|
|
3212
|
+
}
|
|
3213
|
+
|
|
3214
|
+
/**
|
|
3215
|
+
* 移除面图元的外边框
|
|
3216
|
+
* @param {string} graphicId 图元ID
|
|
3217
|
+
*/
|
|
3218
|
+
removeOutline(graphicId) {
|
|
3219
|
+
if (!this.viewer) return;
|
|
3220
|
+
this.viewer.entities.removeById(`${graphicId}_outline`);
|
|
3221
|
+
}
|
|
3057
3222
|
}
|
|
3058
3223
|
|
|
3059
|
-
const Cesium$
|
|
3224
|
+
const Cesium$d = getCesium();
|
|
3060
3225
|
|
|
3061
3226
|
/**
|
|
3062
3227
|
* 事件模块(对应平台 IEventModule)
|
|
@@ -3154,7 +3319,7 @@ class EventModule {
|
|
|
3154
3319
|
switch (baseType) {
|
|
3155
3320
|
// 鼠标事件
|
|
3156
3321
|
case 'mouse':
|
|
3157
|
-
this.handlers[eventKey] = new Cesium$
|
|
3322
|
+
this.handlers[eventKey] = new Cesium$d.ScreenSpaceEventHandler(this.viewer.scene.canvas);
|
|
3158
3323
|
// 绑定鼠标事件
|
|
3159
3324
|
const mouseEventType = this.getCesiumMouseEventType(subType);
|
|
3160
3325
|
this.handlers[eventKey].setInputAction((movement) => {
|
|
@@ -3175,10 +3340,10 @@ class EventModule {
|
|
|
3175
3340
|
const pickedEntity = this.viewer.scene.pick(screenPos);
|
|
3176
3341
|
|
|
3177
3342
|
if (position) {
|
|
3178
|
-
const cartographic = Cesium$
|
|
3343
|
+
const cartographic = Cesium$d.Cartographic.fromCartesian(position);
|
|
3179
3344
|
lngLat = [
|
|
3180
|
-
Cesium$
|
|
3181
|
-
Cesium$
|
|
3345
|
+
Cesium$d.Math.toDegrees(cartographic.longitude),
|
|
3346
|
+
Cesium$d.Math.toDegrees(cartographic.latitude),
|
|
3182
3347
|
cartographic.height
|
|
3183
3348
|
];
|
|
3184
3349
|
}
|
|
@@ -3244,12 +3409,12 @@ class EventModule {
|
|
|
3244
3409
|
// ========== 工具方法:映射 Cesium 鼠标事件类型 ==========
|
|
3245
3410
|
getCesiumMouseEventType(subType) {
|
|
3246
3411
|
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$
|
|
3412
|
+
case 'click': return Cesium$d.ScreenSpaceEventType.LEFT_CLICK;
|
|
3413
|
+
case 'rightclick': return Cesium$d.ScreenSpaceEventType.RIGHT_CLICK;
|
|
3414
|
+
case 'move': return Cesium$d.ScreenSpaceEventType.MOUSE_MOVE;
|
|
3415
|
+
case 'down': return Cesium$d.ScreenSpaceEventType.LEFT_DOWN;
|
|
3416
|
+
case 'up': return Cesium$d.ScreenSpaceEventType.LEFT_UP;
|
|
3417
|
+
default: return Cesium$d.ScreenSpaceEventType.LEFT_CLICK;
|
|
3253
3418
|
}
|
|
3254
3419
|
}
|
|
3255
3420
|
|
|
@@ -3257,18 +3422,18 @@ class EventModule {
|
|
|
3257
3422
|
getZoomLevel() {
|
|
3258
3423
|
const camera = this.viewer.camera;
|
|
3259
3424
|
const positionCartographic = camera.positionCartographic;
|
|
3260
|
-
const positionCartesian = Cesium$
|
|
3425
|
+
const positionCartesian = Cesium$d.Cartesian3.fromRadians(
|
|
3261
3426
|
positionCartographic.longitude,
|
|
3262
3427
|
positionCartographic.latitude,
|
|
3263
3428
|
positionCartographic.height
|
|
3264
3429
|
);
|
|
3265
|
-
const distance = Cesium$
|
|
3430
|
+
const distance = Cesium$d.Cartesian3.distance(camera.position, positionCartesian);
|
|
3266
3431
|
// 映射为 0-20 级缩放(类似地图瓦片级别)
|
|
3267
3432
|
return Math.floor(Math.log2(6378137 * 2 * Math.PI / distance)) + 1;
|
|
3268
3433
|
}
|
|
3269
3434
|
}
|
|
3270
3435
|
|
|
3271
|
-
const Cesium$
|
|
3436
|
+
const Cesium$c = getCesium();
|
|
3272
3437
|
|
|
3273
3438
|
/**
|
|
3274
3439
|
* 工具基类
|
|
@@ -3363,17 +3528,17 @@ class BaseTool {
|
|
|
3363
3528
|
// 如果拾取失败(空白区域),fallback 到椭球体表面
|
|
3364
3529
|
if (!cartesian) {
|
|
3365
3530
|
cartesian = this._viewer.camera.pickEllipsoid(
|
|
3366
|
-
new Cesium$
|
|
3531
|
+
new Cesium$c.Cartesian3(screenPos.x, screenPos.y),
|
|
3367
3532
|
this._viewer.scene.globe.ellipsoid
|
|
3368
3533
|
);
|
|
3369
3534
|
}
|
|
3370
3535
|
|
|
3371
3536
|
if (!cartesian) return null;
|
|
3372
3537
|
|
|
3373
|
-
const cartographic = Cesium$
|
|
3538
|
+
const cartographic = Cesium$c.Cartographic.fromCartesian(cartesian);
|
|
3374
3539
|
return [
|
|
3375
|
-
Cesium$
|
|
3376
|
-
Cesium$
|
|
3540
|
+
Cesium$c.Math.toDegrees(cartographic.longitude),
|
|
3541
|
+
Cesium$c.Math.toDegrees(cartographic.latitude),
|
|
3377
3542
|
cartographic.height
|
|
3378
3543
|
];
|
|
3379
3544
|
}
|
|
@@ -3384,8 +3549,8 @@ class BaseTool {
|
|
|
3384
3549
|
* @returns {Promise<number>} 地形高度
|
|
3385
3550
|
*/
|
|
3386
3551
|
async getTerrainHeight(lonLat) {
|
|
3387
|
-
const cartographic = Cesium$
|
|
3388
|
-
const result = await Cesium$
|
|
3552
|
+
const cartographic = Cesium$c.Cartographic.fromDegrees(lonLat[0], lonLat[1]);
|
|
3553
|
+
const result = await Cesium$c.sampleTerrainMostDetailed(
|
|
3389
3554
|
this._viewer.terrainProvider,
|
|
3390
3555
|
[cartographic]
|
|
3391
3556
|
);
|
|
@@ -3426,7 +3591,7 @@ class BaseTool {
|
|
|
3426
3591
|
}
|
|
3427
3592
|
}
|
|
3428
3593
|
|
|
3429
|
-
const Cesium$
|
|
3594
|
+
const Cesium$b = getCesium();
|
|
3430
3595
|
|
|
3431
3596
|
/**
|
|
3432
3597
|
* 绘制类型枚举
|
|
@@ -3713,7 +3878,7 @@ class DrawTool extends BaseTool {
|
|
|
3713
3878
|
const id = this.generateId('point');
|
|
3714
3879
|
this._graphicModule.CreatePoint(id)
|
|
3715
3880
|
.setPosition(lonLat)
|
|
3716
|
-
.setColor(Cesium$
|
|
3881
|
+
.setColor(Cesium$b.Color.RED)
|
|
3717
3882
|
.setPixelSize(10);
|
|
3718
3883
|
|
|
3719
3884
|
this._emitGraphicCreated('point', id);
|
|
@@ -3725,9 +3890,9 @@ class DrawTool extends BaseTool {
|
|
|
3725
3890
|
|
|
3726
3891
|
// 创建辅助点
|
|
3727
3892
|
const tempPoint = this.createTempEntity(this.generateId('temp_point'), {
|
|
3728
|
-
position: Cesium$
|
|
3893
|
+
position: Cesium$b.Cartesian3.fromDegrees(...lonLat),
|
|
3729
3894
|
point: {
|
|
3730
|
-
color: Cesium$
|
|
3895
|
+
color: Cesium$b.Color.YELLOW,
|
|
3731
3896
|
pixelSize: 8
|
|
3732
3897
|
}
|
|
3733
3898
|
});
|
|
@@ -3747,9 +3912,9 @@ class DrawTool extends BaseTool {
|
|
|
3747
3912
|
|
|
3748
3913
|
// 创建辅助点
|
|
3749
3914
|
const tempPoint = this.createTempEntity(this.generateId('temp_point'), {
|
|
3750
|
-
position: Cesium$
|
|
3915
|
+
position: Cesium$b.Cartesian3.fromDegrees(...lonLat),
|
|
3751
3916
|
point: {
|
|
3752
|
-
color: Cesium$
|
|
3917
|
+
color: Cesium$b.Color.YELLOW,
|
|
3753
3918
|
pixelSize: 8
|
|
3754
3919
|
}
|
|
3755
3920
|
});
|
|
@@ -3769,9 +3934,9 @@ class DrawTool extends BaseTool {
|
|
|
3769
3934
|
this._startPos = lonLat;
|
|
3770
3935
|
// 创建起始点标记
|
|
3771
3936
|
const startMarker = this.createTempEntity(this.generateId('temp_start'), {
|
|
3772
|
-
position: Cesium$
|
|
3937
|
+
position: Cesium$b.Cartesian3.fromDegrees(...lonLat),
|
|
3773
3938
|
point: {
|
|
3774
|
-
color: Cesium$
|
|
3939
|
+
color: Cesium$b.Color.YELLOW,
|
|
3775
3940
|
pixelSize: 10
|
|
3776
3941
|
}
|
|
3777
3942
|
});
|
|
@@ -3786,9 +3951,9 @@ class DrawTool extends BaseTool {
|
|
|
3786
3951
|
if (!this._startPos) {
|
|
3787
3952
|
this._startPos = lonLat;
|
|
3788
3953
|
const startMarker = this.createTempEntity(this.generateId('temp_start'), {
|
|
3789
|
-
position: Cesium$
|
|
3954
|
+
position: Cesium$b.Cartesian3.fromDegrees(...lonLat),
|
|
3790
3955
|
point: {
|
|
3791
|
-
color: Cesium$
|
|
3956
|
+
color: Cesium$b.Color.YELLOW,
|
|
3792
3957
|
pixelSize: 10
|
|
3793
3958
|
}
|
|
3794
3959
|
});
|
|
@@ -3810,14 +3975,14 @@ class DrawTool extends BaseTool {
|
|
|
3810
3975
|
for (const c of previewPositions) {
|
|
3811
3976
|
flatCoords.push(c[0], c[1], c[2] || 0);
|
|
3812
3977
|
}
|
|
3813
|
-
const cartesians = Cesium$
|
|
3978
|
+
const cartesians = Cesium$b.Cartesian3.fromDegreesArrayHeights(flatCoords);
|
|
3814
3979
|
|
|
3815
3980
|
if (!this._previewLine) {
|
|
3816
3981
|
// 首次创建预览线
|
|
3817
3982
|
this._previewLine = this.createTempEntity(this.generateId('temp_line'), {
|
|
3818
3983
|
polyline: {
|
|
3819
3984
|
positions: cartesians,
|
|
3820
|
-
material: Cesium$
|
|
3985
|
+
material: Cesium$b.Color.YELLOW,
|
|
3821
3986
|
width: 2
|
|
3822
3987
|
}
|
|
3823
3988
|
});
|
|
@@ -3825,7 +3990,7 @@ class DrawTool extends BaseTool {
|
|
|
3825
3990
|
} else {
|
|
3826
3991
|
// 直接更新位置属性,避免重建实体
|
|
3827
3992
|
// this._previewLine.polyline.positions = cartesians;
|
|
3828
|
-
this._previewLine.polyline.positions = new Cesium$
|
|
3993
|
+
this._previewLine.polyline.positions = new Cesium$b.CallbackProperty(() => {
|
|
3829
3994
|
return cartesians;
|
|
3830
3995
|
}, false);
|
|
3831
3996
|
}
|
|
@@ -3845,23 +4010,23 @@ class DrawTool extends BaseTool {
|
|
|
3845
4010
|
for (const c of previewPositions) {
|
|
3846
4011
|
flatCoords.push(c[0], c[1], c[2] || 0);
|
|
3847
4012
|
}
|
|
3848
|
-
const cartesians = Cesium$
|
|
4013
|
+
const cartesians = Cesium$b.Cartesian3.fromDegreesArrayHeights(flatCoords);
|
|
3849
4014
|
|
|
3850
4015
|
if (!this._previewPolygon) {
|
|
3851
4016
|
// 首次创建预览面
|
|
3852
4017
|
this._previewPolygon = this.createTempEntity(this.generateId('temp_polygon'), {
|
|
3853
4018
|
polygon: {
|
|
3854
|
-
hierarchy: new Cesium$
|
|
3855
|
-
material: Cesium$
|
|
4019
|
+
hierarchy: new Cesium$b.PolygonHierarchy(cartesians),
|
|
4020
|
+
material: Cesium$b.Color.YELLOW.withAlpha(0.5),
|
|
3856
4021
|
outline: false,
|
|
3857
|
-
outlineColor: Cesium$
|
|
4022
|
+
outlineColor: Cesium$b.Color.YELLOW,
|
|
3858
4023
|
}
|
|
3859
4024
|
});
|
|
3860
4025
|
this._tempEntities.push(this._previewPolygon);
|
|
3861
4026
|
} else {
|
|
3862
4027
|
// 直接更新层级,避免重建实体,使用 CallbackProperty 防止闪烁
|
|
3863
|
-
this._previewPolygon.polygon.hierarchy = new Cesium$
|
|
3864
|
-
return new Cesium$
|
|
4028
|
+
this._previewPolygon.polygon.hierarchy = new Cesium$b.CallbackProperty(() => {
|
|
4029
|
+
return new Cesium$b.PolygonHierarchy(cartesians);
|
|
3865
4030
|
}, false);
|
|
3866
4031
|
}
|
|
3867
4032
|
}
|
|
@@ -3893,18 +4058,18 @@ class DrawTool extends BaseTool {
|
|
|
3893
4058
|
for (const c of positions) {
|
|
3894
4059
|
flatCoords.push(c[0], c[1], 0);
|
|
3895
4060
|
}
|
|
3896
|
-
const cartesians = Cesium$
|
|
4061
|
+
const cartesians = Cesium$b.Cartesian3.fromDegreesArrayHeights(flatCoords);
|
|
3897
4062
|
|
|
3898
4063
|
if (!this._previewRect) {
|
|
3899
4064
|
this._previewRect = this.createTempEntity(this.generateId('temp_rect'), {
|
|
3900
4065
|
polyline: {
|
|
3901
|
-
positions: new Cesium$
|
|
3902
|
-
material: Cesium$
|
|
4066
|
+
positions: new Cesium$b.CallbackProperty(() => cartesians, false),
|
|
4067
|
+
material: Cesium$b.Color.YELLOW.withAlpha(0.7),
|
|
3903
4068
|
width: 2
|
|
3904
4069
|
},
|
|
3905
4070
|
polygon: {
|
|
3906
|
-
hierarchy: new Cesium$
|
|
3907
|
-
material: Cesium$
|
|
4071
|
+
hierarchy: new Cesium$b.CallbackProperty(() => new Cesium$b.PolygonHierarchy(cartesians), false),
|
|
4072
|
+
material: Cesium$b.Color.YELLOW.withAlpha(0.2),
|
|
3908
4073
|
outline: false
|
|
3909
4074
|
}
|
|
3910
4075
|
});
|
|
@@ -3912,7 +4077,7 @@ class DrawTool extends BaseTool {
|
|
|
3912
4077
|
this._tempEntities.push(this._previewRect);
|
|
3913
4078
|
} else {
|
|
3914
4079
|
// 直接更新位置属性
|
|
3915
|
-
this._previewRect.polyline.positions = new Cesium$
|
|
4080
|
+
this._previewRect.polyline.positions = new Cesium$b.CallbackProperty(() => {
|
|
3916
4081
|
const c1 = this._startPos;
|
|
3917
4082
|
const c2 = this._currentMousePos;
|
|
3918
4083
|
if (!c1 || !c2) return cartesians;
|
|
@@ -3927,12 +4092,12 @@ class DrawTool extends BaseTool {
|
|
|
3927
4092
|
for (const p of pos) {
|
|
3928
4093
|
flat.push(p[0], p[1], 0);
|
|
3929
4094
|
}
|
|
3930
|
-
return Cesium$
|
|
4095
|
+
return Cesium$b.Cartesian3.fromDegreesArrayHeights(flat);
|
|
3931
4096
|
}, false);
|
|
3932
|
-
this._previewRect.polygon.hierarchy = new Cesium$
|
|
4097
|
+
this._previewRect.polygon.hierarchy = new Cesium$b.CallbackProperty(() => {
|
|
3933
4098
|
const c1 = this._startPos;
|
|
3934
4099
|
const c2 = this._currentMousePos;
|
|
3935
|
-
if (!c1 || !c2) return new Cesium$
|
|
4100
|
+
if (!c1 || !c2) return new Cesium$b.PolygonHierarchy(cartesians);
|
|
3936
4101
|
const pos = [
|
|
3937
4102
|
[c1[0], c1[1]],
|
|
3938
4103
|
[c2[0], c1[1]],
|
|
@@ -3944,7 +4109,7 @@ class DrawTool extends BaseTool {
|
|
|
3944
4109
|
for (const p of pos) {
|
|
3945
4110
|
flat.push(p[0], p[1], 0);
|
|
3946
4111
|
}
|
|
3947
|
-
return new Cesium$
|
|
4112
|
+
return new Cesium$b.PolygonHierarchy(Cesium$b.Cartesian3.fromDegreesArrayHeights(flat));
|
|
3948
4113
|
}, false);
|
|
3949
4114
|
}
|
|
3950
4115
|
}
|
|
@@ -3957,12 +4122,12 @@ class DrawTool extends BaseTool {
|
|
|
3957
4122
|
if (!this._previewCircle) {
|
|
3958
4123
|
this._previewCircle = this.createTempEntity(this.generateId('temp_circle'), {
|
|
3959
4124
|
polygon: {
|
|
3960
|
-
hierarchy: new Cesium$
|
|
4125
|
+
hierarchy: new Cesium$b.CallbackProperty(() => {
|
|
3961
4126
|
const positions = this._generateCirclePositions(center, radius, segments);
|
|
3962
4127
|
const flat = positions.flatMap(c => [c[0], c[1], 0]);
|
|
3963
|
-
return new Cesium$
|
|
4128
|
+
return new Cesium$b.PolygonHierarchy(Cesium$b.Cartesian3.fromDegreesArrayHeights(flat));
|
|
3964
4129
|
}, false),
|
|
3965
|
-
material: Cesium$
|
|
4130
|
+
material: Cesium$b.Color.YELLOW.withAlpha(0.2),
|
|
3966
4131
|
outline: false // 地形贴合时不支持 outline,设为 false 避免警告
|
|
3967
4132
|
}
|
|
3968
4133
|
});
|
|
@@ -3970,11 +4135,11 @@ class DrawTool extends BaseTool {
|
|
|
3970
4135
|
this._tempEntities.push(this._previewCircle);
|
|
3971
4136
|
} else {
|
|
3972
4137
|
// 直接更新
|
|
3973
|
-
this._previewCircle.polygon.hierarchy = new Cesium$
|
|
4138
|
+
this._previewCircle.polygon.hierarchy = new Cesium$b.CallbackProperty(() => {
|
|
3974
4139
|
const r = this._calcDistance(this._startPos, this._currentMousePos);
|
|
3975
4140
|
const pos = this._generateCirclePositions(this._startPos, r, 64);
|
|
3976
4141
|
const flat = pos.flatMap(c => [c[0], c[1], 0]);
|
|
3977
|
-
return new Cesium$
|
|
4142
|
+
return new Cesium$b.PolygonHierarchy(Cesium$b.Cartesian3.fromDegreesArrayHeights(flat));
|
|
3978
4143
|
}, false);
|
|
3979
4144
|
}
|
|
3980
4145
|
}
|
|
@@ -3991,10 +4156,10 @@ class DrawTool extends BaseTool {
|
|
|
3991
4156
|
const id = this.generateId('rectangle');
|
|
3992
4157
|
this._graphicModule.CreatePolygon(id)
|
|
3993
4158
|
.setPositions(positions)
|
|
3994
|
-
.setColor(Cesium$
|
|
3995
|
-
.setOutlineColor(Cesium$
|
|
4159
|
+
.setColor(Cesium$b.Color.BLUE.withAlpha(0.5))
|
|
4160
|
+
.setOutlineColor(Cesium$b.Color.BLUE)
|
|
3996
4161
|
.setOutlineWidth(2)
|
|
3997
|
-
.setHeightReference(Cesium$
|
|
4162
|
+
.setHeightReference(Cesium$b.HeightReference.NONE);
|
|
3998
4163
|
|
|
3999
4164
|
this.clearTempEntities();
|
|
4000
4165
|
this._startPos = null;
|
|
@@ -4012,8 +4177,8 @@ class DrawTool extends BaseTool {
|
|
|
4012
4177
|
// 创建圆并标记为圆形
|
|
4013
4178
|
const wrapper = this._graphicModule.CreatePolygon(id);
|
|
4014
4179
|
wrapper.setPositions(positions)
|
|
4015
|
-
.setColor(Cesium$
|
|
4016
|
-
.setOutlineColor(Cesium$
|
|
4180
|
+
.setColor(Cesium$b.Color.BLUE.withAlpha(0.5))
|
|
4181
|
+
.setOutlineColor(Cesium$b.Color.BLUE)
|
|
4017
4182
|
.setOutlineWidth(2);
|
|
4018
4183
|
|
|
4019
4184
|
// 给 entity 添加圆形标记(用于 EditTool 特殊处理)
|
|
@@ -4110,9 +4275,9 @@ class DrawTool extends BaseTool {
|
|
|
4110
4275
|
|
|
4111
4276
|
// 创建辅助点
|
|
4112
4277
|
const tempPoint = this.createTempEntity(this.generateId('temp_point'), {
|
|
4113
|
-
position: Cesium$
|
|
4278
|
+
position: Cesium$b.Cartesian3.fromDegrees(...lngLat),
|
|
4114
4279
|
point: {
|
|
4115
|
-
color: Cesium$
|
|
4280
|
+
color: Cesium$b.Color.YELLOW,
|
|
4116
4281
|
pixelSize: 8
|
|
4117
4282
|
}
|
|
4118
4283
|
});
|
|
@@ -4167,27 +4332,28 @@ class DrawTool extends BaseTool {
|
|
|
4167
4332
|
for (const c of positions) {
|
|
4168
4333
|
flatCoords.push(c[0], c[1], c[2] || 0);
|
|
4169
4334
|
}
|
|
4170
|
-
const cartesians = Cesium$
|
|
4335
|
+
const cartesians = Cesium$b.Cartesian3.fromDegreesArrayHeights(flatCoords);
|
|
4171
4336
|
|
|
4172
4337
|
if (!this._previewPlot) {
|
|
4173
4338
|
if (isLine) {
|
|
4174
4339
|
this._previewPlot = this.createTempEntity(this.generateId('temp_plot'), {
|
|
4175
4340
|
polyline: {
|
|
4176
|
-
positions: new Cesium$
|
|
4177
|
-
material: Cesium$
|
|
4178
|
-
width: 2
|
|
4341
|
+
positions: new Cesium$b.CallbackProperty(() => cartesians, false),
|
|
4342
|
+
material: Cesium$b.Color.YELLOW,
|
|
4343
|
+
width: 2,
|
|
4344
|
+
clampToGround: true
|
|
4179
4345
|
}
|
|
4180
4346
|
});
|
|
4181
4347
|
} else {
|
|
4182
4348
|
this._previewPlot = this.createTempEntity(this.generateId('temp_plot'), {
|
|
4183
4349
|
polygon: {
|
|
4184
|
-
hierarchy: new Cesium$
|
|
4185
|
-
material: Cesium$
|
|
4350
|
+
hierarchy: new Cesium$b.CallbackProperty(() => new Cesium$b.PolygonHierarchy(cartesians), false),
|
|
4351
|
+
material: Cesium$b.Color.YELLOW.withAlpha(0.3),
|
|
4186
4352
|
outline: false
|
|
4187
4353
|
},
|
|
4188
4354
|
polyline: {
|
|
4189
|
-
positions: new Cesium$
|
|
4190
|
-
material: Cesium$
|
|
4355
|
+
positions: new Cesium$b.CallbackProperty(() => [...cartesians, cartesians[0]], false),
|
|
4356
|
+
material: Cesium$b.Color.YELLOW,
|
|
4191
4357
|
width: 1
|
|
4192
4358
|
}
|
|
4193
4359
|
});
|
|
@@ -4197,7 +4363,7 @@ class DrawTool extends BaseTool {
|
|
|
4197
4363
|
} else {
|
|
4198
4364
|
const self = this;
|
|
4199
4365
|
if (isLine) {
|
|
4200
|
-
this._previewPlot.polyline.positions = new Cesium$
|
|
4366
|
+
this._previewPlot.polyline.positions = new Cesium$b.CallbackProperty(() => {
|
|
4201
4367
|
const dynamicPositions = [...self._tempPositions];
|
|
4202
4368
|
if (self._currentMousePos) {
|
|
4203
4369
|
dynamicPositions.push(self._currentMousePos);
|
|
@@ -4208,23 +4374,23 @@ class DrawTool extends BaseTool {
|
|
|
4208
4374
|
for (const c of pos) {
|
|
4209
4375
|
flat.push(c[0], c[1], c[2] || 0);
|
|
4210
4376
|
}
|
|
4211
|
-
return Cesium$
|
|
4377
|
+
return Cesium$b.Cartesian3.fromDegreesArrayHeights(flat);
|
|
4212
4378
|
}, false);
|
|
4213
4379
|
} else {
|
|
4214
|
-
this._previewPlot.polygon.hierarchy = new Cesium$
|
|
4380
|
+
this._previewPlot.polygon.hierarchy = new Cesium$b.CallbackProperty(() => {
|
|
4215
4381
|
const dynamicPositions = [...self._tempPositions];
|
|
4216
4382
|
if (self._currentMousePos) {
|
|
4217
4383
|
dynamicPositions.push(self._currentMousePos);
|
|
4218
4384
|
}
|
|
4219
|
-
if (dynamicPositions.length < config.minPoints) return new Cesium$
|
|
4385
|
+
if (dynamicPositions.length < config.minPoints) return new Cesium$b.PolygonHierarchy([]);
|
|
4220
4386
|
const pos = PlotGeometryUtil[factoryName](normalizeForEllipse(dynamicPositions));
|
|
4221
4387
|
const flat = [];
|
|
4222
4388
|
for (const c of pos) {
|
|
4223
4389
|
flat.push(c[0], c[1], c[2] || 0);
|
|
4224
4390
|
}
|
|
4225
|
-
return new Cesium$
|
|
4391
|
+
return new Cesium$b.PolygonHierarchy(Cesium$b.Cartesian3.fromDegreesArrayHeights(flat));
|
|
4226
4392
|
}, false);
|
|
4227
|
-
this._previewPlot.polyline.positions = new Cesium$
|
|
4393
|
+
this._previewPlot.polyline.positions = new Cesium$b.CallbackProperty(() => {
|
|
4228
4394
|
const dynamicPositions = [...self._tempPositions];
|
|
4229
4395
|
if (self._currentMousePos) {
|
|
4230
4396
|
dynamicPositions.push(self._currentMousePos);
|
|
@@ -4235,7 +4401,7 @@ class DrawTool extends BaseTool {
|
|
|
4235
4401
|
for (const c of pos) {
|
|
4236
4402
|
flat.push(c[0], c[1], c[2] || 0);
|
|
4237
4403
|
}
|
|
4238
|
-
const cart = Cesium$
|
|
4404
|
+
const cart = Cesium$b.Cartesian3.fromDegreesArrayHeights(flat);
|
|
4239
4405
|
return [...cart, cart[0]];
|
|
4240
4406
|
}, false);
|
|
4241
4407
|
}
|
|
@@ -4272,11 +4438,11 @@ class DrawTool extends BaseTool {
|
|
|
4272
4438
|
|
|
4273
4439
|
// 应用默认样式
|
|
4274
4440
|
if (isLine) {
|
|
4275
|
-
wrapper.setColor(Cesium$
|
|
4441
|
+
wrapper.setColor(Cesium$b.Color.BLUE).setWidth(2);
|
|
4276
4442
|
} else {
|
|
4277
4443
|
wrapper
|
|
4278
|
-
.setColor(Cesium$
|
|
4279
|
-
.setOutlineColor(Cesium$
|
|
4444
|
+
.setColor(Cesium$b.Color.BLUE.withAlpha(0.5))
|
|
4445
|
+
.setOutlineColor(Cesium$b.Color.BLUE)
|
|
4280
4446
|
.setOutlineWidth(2);
|
|
4281
4447
|
}
|
|
4282
4448
|
|
|
@@ -4329,7 +4495,7 @@ class DrawTool extends BaseTool {
|
|
|
4329
4495
|
const id = this.generateId('line');
|
|
4330
4496
|
this._graphicModule.CreateLine(id)
|
|
4331
4497
|
.setPositions(this._tempPositions)
|
|
4332
|
-
.setColor(Cesium$
|
|
4498
|
+
.setColor(Cesium$b.Color.BLUE)
|
|
4333
4499
|
.setWidth(2);
|
|
4334
4500
|
|
|
4335
4501
|
this._emitGraphicCreated('line', id);
|
|
@@ -4338,17 +4504,38 @@ class DrawTool extends BaseTool {
|
|
|
4338
4504
|
const id = this.generateId('polygon');
|
|
4339
4505
|
this._graphicModule.CreatePolygon(id)
|
|
4340
4506
|
.setPositions(positions)
|
|
4341
|
-
.setColor(Cesium$
|
|
4342
|
-
.setOutlineColor(Cesium$
|
|
4507
|
+
.setColor(Cesium$b.Color.BLUE.withAlpha(0.5))
|
|
4508
|
+
.setOutlineColor(Cesium$b.Color.BLUE);
|
|
4343
4509
|
|
|
4344
4510
|
this._emitGraphicCreated('polygon', id);
|
|
4345
4511
|
}
|
|
4346
4512
|
|
|
4513
|
+
// 线绘制结束时,把预览线样式切为最终样式并延迟一帧移除,
|
|
4514
|
+
// 避免新线图元异步初始化期间出现“预览线消失 -> 正式线出现”的闪烁
|
|
4515
|
+
let deferredPreviewLine = null;
|
|
4516
|
+
if (this._drawType === DrawType.LINE && this._previewLine) {
|
|
4517
|
+
const previewLine = this._previewLine;
|
|
4518
|
+
previewLine.polyline.material = Cesium$b.Color.BLUE;
|
|
4519
|
+
previewLine.polyline.width = 2;
|
|
4520
|
+
previewLine.polyline.positions = Cesium$b.Cartesian3.fromDegreesArrayHeights(
|
|
4521
|
+
this._tempPositions.flatMap((coord) => [coord[0], coord[1], coord[2] || 0])
|
|
4522
|
+
);
|
|
4523
|
+
|
|
4524
|
+
const idx = this._tempEntities.indexOf(previewLine);
|
|
4525
|
+
if (idx > -1) this._tempEntities.splice(idx, 1);
|
|
4526
|
+
this._previewLine = null;
|
|
4527
|
+
deferredPreviewLine = previewLine;
|
|
4528
|
+
}
|
|
4529
|
+
|
|
4347
4530
|
this.clearTempEntities();
|
|
4348
4531
|
this._tempPositions = [];
|
|
4349
4532
|
this._isDrawing = false;
|
|
4350
4533
|
this._clickCount = 0;
|
|
4351
4534
|
this._currentMousePos = null;
|
|
4535
|
+
|
|
4536
|
+
if (deferredPreviewLine) {
|
|
4537
|
+
requestAnimationFrame(() => this.removeTempEntity(deferredPreviewLine));
|
|
4538
|
+
}
|
|
4352
4539
|
}
|
|
4353
4540
|
|
|
4354
4541
|
/**
|
|
@@ -4386,7 +4573,7 @@ class DrawTool extends BaseTool {
|
|
|
4386
4573
|
}
|
|
4387
4574
|
}
|
|
4388
4575
|
|
|
4389
|
-
const Cesium$
|
|
4576
|
+
const Cesium$a = getCesium();
|
|
4390
4577
|
|
|
4391
4578
|
/**
|
|
4392
4579
|
* 编辑模式枚举
|
|
@@ -4471,7 +4658,7 @@ class EditTool extends BaseTool {
|
|
|
4471
4658
|
const picked = this._viewer.scene.pick(screenPos);
|
|
4472
4659
|
console.log('EditTool _onClick:', { picked, screenPos });
|
|
4473
4660
|
|
|
4474
|
-
if (Cesium$
|
|
4661
|
+
if (Cesium$a.defined(picked) && Cesium$a.defined(picked.id)) {
|
|
4475
4662
|
const entityId = picked.id.id;
|
|
4476
4663
|
console.log('EditTool picked entity:', entityId);
|
|
4477
4664
|
|
|
@@ -4507,7 +4694,7 @@ class EditTool extends BaseTool {
|
|
|
4507
4694
|
// 如果已经选中了图元,检查是否点击了控制点
|
|
4508
4695
|
if (this._selectedEntity && !this._isDragging) {
|
|
4509
4696
|
const picked = this._viewer.scene.pick(screenPos);
|
|
4510
|
-
if (Cesium$
|
|
4697
|
+
if (Cesium$a.defined(picked) && Cesium$a.defined(picked.id)) {
|
|
4511
4698
|
const entityId = picked.id.id;
|
|
4512
4699
|
if (entityId && (entityId.startsWith('__edit_handle_') || entityId.includes('__edit_handle_'))) {
|
|
4513
4700
|
// 直接在 _editHandles 中查找被点击的控制点
|
|
@@ -4560,7 +4747,7 @@ class EditTool extends BaseTool {
|
|
|
4560
4747
|
|
|
4561
4748
|
// 检测是否悬停在控制点上
|
|
4562
4749
|
const picked = this._viewer.scene.pick(screenPos);
|
|
4563
|
-
const isOverHandle = Cesium$
|
|
4750
|
+
const isOverHandle = Cesium$a.defined(picked) && Cesium$a.defined(picked.id) &&
|
|
4564
4751
|
picked.id.id && picked.id.id.startsWith('__edit_handle_');
|
|
4565
4752
|
this._setCursorStyle(isOverHandle ? 'move' : 'default');
|
|
4566
4753
|
}
|
|
@@ -4571,14 +4758,14 @@ class EditTool extends BaseTool {
|
|
|
4571
4758
|
// 拖拽时优先使用椭球面拾取,避免拾取到控制点句柄本身导致图元跟随滞后
|
|
4572
4759
|
let lonLat = null;
|
|
4573
4760
|
const cartesian = this._viewer.camera.pickEllipsoid(
|
|
4574
|
-
new Cesium$
|
|
4761
|
+
new Cesium$a.Cartesian2(screenPos.x, screenPos.y),
|
|
4575
4762
|
this._viewer.scene.globe.ellipsoid
|
|
4576
4763
|
);
|
|
4577
4764
|
if (cartesian) {
|
|
4578
|
-
const c = Cesium$
|
|
4765
|
+
const c = Cesium$a.Cartographic.fromCartesian(cartesian);
|
|
4579
4766
|
lonLat = [
|
|
4580
|
-
Cesium$
|
|
4581
|
-
Cesium$
|
|
4767
|
+
Cesium$a.Math.toDegrees(c.longitude),
|
|
4768
|
+
Cesium$a.Math.toDegrees(c.latitude),
|
|
4582
4769
|
c.height || 0
|
|
4583
4770
|
];
|
|
4584
4771
|
} else {
|
|
@@ -4602,16 +4789,16 @@ class EditTool extends BaseTool {
|
|
|
4602
4789
|
const deltaZ = newAnchorCartesian.z - oldAnchorCartesian.z;
|
|
4603
4790
|
|
|
4604
4791
|
const controlPoints = this._selectedEntity._controlPoints.map(cp => {
|
|
4605
|
-
const cpCart = Cesium$
|
|
4606
|
-
const newCpCart = new Cesium$
|
|
4792
|
+
const cpCart = Cesium$a.Cartesian3.fromDegrees(cp[0], cp[1], cp[2] || 0);
|
|
4793
|
+
const newCpCart = new Cesium$a.Cartesian3(
|
|
4607
4794
|
cpCart.x + deltaX,
|
|
4608
4795
|
cpCart.y + deltaY,
|
|
4609
4796
|
cpCart.z + deltaZ
|
|
4610
4797
|
);
|
|
4611
|
-
const newCpCarto = Cesium$
|
|
4798
|
+
const newCpCarto = Cesium$a.Cartographic.fromCartesian(newCpCart);
|
|
4612
4799
|
return [
|
|
4613
|
-
Cesium$
|
|
4614
|
-
Cesium$
|
|
4800
|
+
Cesium$a.Math.toDegrees(newCpCarto.longitude),
|
|
4801
|
+
Cesium$a.Math.toDegrees(newCpCarto.latitude),
|
|
4615
4802
|
newCpCarto.height || 0
|
|
4616
4803
|
];
|
|
4617
4804
|
});
|
|
@@ -4632,8 +4819,8 @@ class EditTool extends BaseTool {
|
|
|
4632
4819
|
const center = (plotType === PlotGraphicType.SECTOR || plotType === PlotGraphicType.ELLIPSE)
|
|
4633
4820
|
? controlPoints[0]
|
|
4634
4821
|
: this._getPlotControlPointsCenter(controlPoints);
|
|
4635
|
-
handle.position = new Cesium$
|
|
4636
|
-
this._clampPositionToGround(Cesium$
|
|
4822
|
+
handle.position = new Cesium$a.ConstantPositionProperty(
|
|
4823
|
+
this._clampPositionToGround(Cesium$a.Cartesian3.fromDegrees(center[0], center[1], center[2] || 0))
|
|
4637
4824
|
);
|
|
4638
4825
|
return;
|
|
4639
4826
|
}
|
|
@@ -4642,8 +4829,8 @@ class EditTool extends BaseTool {
|
|
|
4642
4829
|
if (match) {
|
|
4643
4830
|
const cpIndex = parseInt(match[1], 10);
|
|
4644
4831
|
const cp = controlPoints[cpIndex];
|
|
4645
|
-
handle.position = new Cesium$
|
|
4646
|
-
this._clampPositionToGround(Cesium$
|
|
4832
|
+
handle.position = new Cesium$a.ConstantPositionProperty(
|
|
4833
|
+
this._clampPositionToGround(Cesium$a.Cartesian3.fromDegrees(cp[0], cp[1], cp[2] || 0))
|
|
4647
4834
|
);
|
|
4648
4835
|
}
|
|
4649
4836
|
});
|
|
@@ -4711,10 +4898,10 @@ class EditTool extends BaseTool {
|
|
|
4711
4898
|
*/
|
|
4712
4899
|
_clampPositionToGround(position) {
|
|
4713
4900
|
if (!position) return position;
|
|
4714
|
-
const cartographic = Cesium$
|
|
4715
|
-
return Cesium$
|
|
4716
|
-
Cesium$
|
|
4717
|
-
Cesium$
|
|
4901
|
+
const cartographic = Cesium$a.Cartographic.fromCartesian(position);
|
|
4902
|
+
return Cesium$a.Cartesian3.fromDegrees(
|
|
4903
|
+
Cesium$a.Math.toDegrees(cartographic.longitude),
|
|
4904
|
+
Cesium$a.Math.toDegrees(cartographic.latitude),
|
|
4718
4905
|
0
|
|
4719
4906
|
);
|
|
4720
4907
|
}
|
|
@@ -4736,17 +4923,17 @@ class EditTool extends BaseTool {
|
|
|
4736
4923
|
if ((isSector || isEllipse) && index === 0) return; // 扇形/椭圆圆心/中心由中心控制点处理
|
|
4737
4924
|
|
|
4738
4925
|
const clampedPos = this._clampPositionToGround(
|
|
4739
|
-
Cesium$
|
|
4926
|
+
Cesium$a.Cartesian3.fromDegrees(cp[0], cp[1], cp[2] || 0)
|
|
4740
4927
|
);
|
|
4741
4928
|
const handle = this.createTempEntity(`__edit_handle_${index}`, {
|
|
4742
4929
|
position: clampedPos,
|
|
4743
4930
|
point: {
|
|
4744
|
-
color: Cesium$
|
|
4931
|
+
color: Cesium$a.Color.YELLOW,
|
|
4745
4932
|
pixelSize: 12,
|
|
4746
|
-
outlineColor: Cesium$
|
|
4933
|
+
outlineColor: Cesium$a.Color.RED,
|
|
4747
4934
|
outlineWidth: 2,
|
|
4748
4935
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
4749
|
-
heightReference: Cesium$
|
|
4936
|
+
heightReference: Cesium$a.HeightReference.CLAMP_TO_GROUND
|
|
4750
4937
|
}
|
|
4751
4938
|
});
|
|
4752
4939
|
this._editHandles.push(handle);
|
|
@@ -4783,18 +4970,18 @@ class EditTool extends BaseTool {
|
|
|
4783
4970
|
if (!center) return;
|
|
4784
4971
|
|
|
4785
4972
|
this._originalEntityCenter = this._clampPositionToGround(
|
|
4786
|
-
Cesium$
|
|
4973
|
+
Cesium$a.Cartesian3.fromDegrees(center[0], center[1], center[2] || 0)
|
|
4787
4974
|
);
|
|
4788
4975
|
|
|
4789
4976
|
const handle = this.createTempEntity('__edit_handle_center_plot', {
|
|
4790
4977
|
position: this._originalEntityCenter,
|
|
4791
4978
|
point: {
|
|
4792
|
-
color: Cesium$
|
|
4979
|
+
color: Cesium$a.Color.CYAN,
|
|
4793
4980
|
pixelSize: 14,
|
|
4794
|
-
outlineColor: Cesium$
|
|
4981
|
+
outlineColor: Cesium$a.Color.BLUE,
|
|
4795
4982
|
outlineWidth: 2,
|
|
4796
4983
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
4797
|
-
heightReference: Cesium$
|
|
4984
|
+
heightReference: Cesium$a.HeightReference.CLAMP_TO_GROUND
|
|
4798
4985
|
}
|
|
4799
4986
|
});
|
|
4800
4987
|
this._editHandles.push(handle);
|
|
@@ -4822,7 +5009,7 @@ class EditTool extends BaseTool {
|
|
|
4822
5009
|
_createPlotPositionOutline() {
|
|
4823
5010
|
const self = this;
|
|
4824
5011
|
const entity = this._selectedEntity;
|
|
4825
|
-
const isLine = Cesium$
|
|
5012
|
+
const isLine = Cesium$a.defined(entity.polyline);
|
|
4826
5013
|
|
|
4827
5014
|
// 以下标绘图元的控制点连线会干扰真实几何,不绘制轮廓辅助线
|
|
4828
5015
|
const skipOutlineTypes = new Set([
|
|
@@ -4839,7 +5026,7 @@ class EditTool extends BaseTool {
|
|
|
4839
5026
|
|
|
4840
5027
|
this._positionOutline = this.createTempEntity(this.generateId('temp_plot_outline'), {
|
|
4841
5028
|
polyline: {
|
|
4842
|
-
positions: new Cesium$
|
|
5029
|
+
positions: new Cesium$a.CallbackProperty(function () {
|
|
4843
5030
|
const handles = self._editHandles;
|
|
4844
5031
|
if (!handles || handles.length === 0) return [];
|
|
4845
5032
|
|
|
@@ -4854,7 +5041,7 @@ class EditTool extends BaseTool {
|
|
|
4854
5041
|
let positions = null;
|
|
4855
5042
|
if (hierarchy) {
|
|
4856
5043
|
if (typeof hierarchy.getValue === 'function') {
|
|
4857
|
-
const value = hierarchy.getValue(Cesium$
|
|
5044
|
+
const value = hierarchy.getValue(Cesium$a.JulianDate.now());
|
|
4858
5045
|
positions = value ? value.positions : null;
|
|
4859
5046
|
} else if (hierarchy.positions) {
|
|
4860
5047
|
positions = hierarchy.positions;
|
|
@@ -4874,24 +5061,24 @@ class EditTool extends BaseTool {
|
|
|
4874
5061
|
// 跳过中心平移控制点
|
|
4875
5062
|
if (handle.id && handle.id.includes('center')) return;
|
|
4876
5063
|
|
|
4877
|
-
const pos = handle.position.getValue(Cesium$
|
|
5064
|
+
const pos = handle.position.getValue(Cesium$a.JulianDate.now());
|
|
4878
5065
|
if (pos) {
|
|
4879
|
-
const c = Cesium$
|
|
4880
|
-
degrees.push(Cesium$
|
|
4881
|
-
degrees.push(Cesium$
|
|
5066
|
+
const c = Cesium$a.Cartographic.fromCartesian(pos);
|
|
5067
|
+
degrees.push(Cesium$a.Math.toDegrees(c.longitude));
|
|
5068
|
+
degrees.push(Cesium$a.Math.toDegrees(c.latitude));
|
|
4882
5069
|
degrees.push(c.height || 0);
|
|
4883
5070
|
}
|
|
4884
5071
|
});
|
|
4885
5072
|
|
|
4886
5073
|
if (degrees.length === 0) return [];
|
|
4887
5074
|
|
|
4888
|
-
const cartesians = Cesium$
|
|
5075
|
+
const cartesians = Cesium$a.Cartesian3.fromDegreesArrayHeights(degrees);
|
|
4889
5076
|
if (isLine) {
|
|
4890
5077
|
return cartesians;
|
|
4891
5078
|
}
|
|
4892
5079
|
return [...cartesians, cartesians[0]];
|
|
4893
5080
|
}, false),
|
|
4894
|
-
material: Cesium$
|
|
5081
|
+
material: Cesium$a.Color.YELLOW,
|
|
4895
5082
|
width: 2,
|
|
4896
5083
|
clampToGround: true
|
|
4897
5084
|
}
|
|
@@ -4907,17 +5094,17 @@ class EditTool extends BaseTool {
|
|
|
4907
5094
|
const self = this;
|
|
4908
5095
|
const axisLine = this.createTempEntity(this.generateId('temp_ellipse_axis'), {
|
|
4909
5096
|
polyline: {
|
|
4910
|
-
positions: new Cesium$
|
|
5097
|
+
positions: new Cesium$a.CallbackProperty(function () {
|
|
4911
5098
|
const entity = self._selectedEntity;
|
|
4912
5099
|
const cps = entity?._controlPoints;
|
|
4913
5100
|
if (!cps || cps.length < 3) return [];
|
|
4914
5101
|
|
|
4915
|
-
const center = Cesium$
|
|
4916
|
-
const major = Cesium$
|
|
4917
|
-
const minor = Cesium$
|
|
5102
|
+
const center = Cesium$a.Cartesian3.fromDegrees(cps[0][0], cps[0][1], cps[0][2] || 0);
|
|
5103
|
+
const major = Cesium$a.Cartesian3.fromDegrees(cps[1][0], cps[1][1], cps[1][2] || 0);
|
|
5104
|
+
const minor = Cesium$a.Cartesian3.fromDegrees(cps[2][0], cps[2][1], cps[2][2] || 0);
|
|
4918
5105
|
return [center, major, center, minor];
|
|
4919
5106
|
}, false),
|
|
4920
|
-
material: Cesium$
|
|
5107
|
+
material: Cesium$a.Color.YELLOW,
|
|
4921
5108
|
width: 2,
|
|
4922
5109
|
clampToGround: true
|
|
4923
5110
|
}
|
|
@@ -4932,7 +5119,7 @@ class EditTool extends BaseTool {
|
|
|
4932
5119
|
*/
|
|
4933
5120
|
_createVertexHandles(positions) {
|
|
4934
5121
|
// 判断是否是矩形(4个顶点形成矩形)
|
|
4935
|
-
const isRectangle = Cesium$
|
|
5122
|
+
const isRectangle = Cesium$a.defined(this._selectedEntity.polygon) && positions.length === 4 &&
|
|
4936
5123
|
this._isRectangle(positions);
|
|
4937
5124
|
|
|
4938
5125
|
if (isRectangle) {
|
|
@@ -4946,12 +5133,12 @@ class EditTool extends BaseTool {
|
|
|
4946
5133
|
const handle = this.createTempEntity(`__edit_handle_${handleIdx}`, {
|
|
4947
5134
|
position: clampedPos,
|
|
4948
5135
|
point: {
|
|
4949
|
-
color: Cesium$
|
|
5136
|
+
color: Cesium$a.Color.YELLOW,
|
|
4950
5137
|
pixelSize: 12,
|
|
4951
|
-
outlineColor: Cesium$
|
|
5138
|
+
outlineColor: Cesium$a.Color.RED,
|
|
4952
5139
|
outlineWidth: 2,
|
|
4953
5140
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
4954
|
-
heightReference: Cesium$
|
|
5141
|
+
heightReference: Cesium$a.HeightReference.CLAMP_TO_GROUND,
|
|
4955
5142
|
}
|
|
4956
5143
|
});
|
|
4957
5144
|
this._editHandles.push(handle);
|
|
@@ -4964,20 +5151,20 @@ class EditTool extends BaseTool {
|
|
|
4964
5151
|
|
|
4965
5152
|
const { center, radius } = circleInfo;
|
|
4966
5153
|
// 修复:圆心位置贴地
|
|
4967
|
-
const centerCartesian = Cesium$
|
|
5154
|
+
const centerCartesian = Cesium$a.Cartesian3.fromDegrees(center[0], center[1], 0);
|
|
4968
5155
|
const radiusPoint = this._getPointOnCircle(center, radius, 0);
|
|
4969
|
-
const radiusCartesian = Cesium$
|
|
5156
|
+
const radiusCartesian = Cesium$a.Cartesian3.fromDegrees(radiusPoint[0], radiusPoint[1], 0);
|
|
4970
5157
|
|
|
4971
5158
|
// 圆心控制点(可平移)- 使用与其他类型不同的ID格式
|
|
4972
5159
|
const centerHandle = this.createTempEntity('__edit_handle_center', {
|
|
4973
5160
|
position: centerCartesian,
|
|
4974
5161
|
point: {
|
|
4975
|
-
color: Cesium$
|
|
5162
|
+
color: Cesium$a.Color.CYAN,
|
|
4976
5163
|
pixelSize: 14,
|
|
4977
|
-
outlineColor: Cesium$
|
|
5164
|
+
outlineColor: Cesium$a.Color.BLUE,
|
|
4978
5165
|
outlineWidth: 2,
|
|
4979
5166
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
4980
|
-
heightReference: Cesium$
|
|
5167
|
+
heightReference: Cesium$a.HeightReference.CLAMP_TO_GROUND
|
|
4981
5168
|
}
|
|
4982
5169
|
});
|
|
4983
5170
|
this._editHandles.push(centerHandle);
|
|
@@ -4986,12 +5173,12 @@ class EditTool extends BaseTool {
|
|
|
4986
5173
|
const radiusHandle = this.createTempEntity('__edit_handle_radius', {
|
|
4987
5174
|
position: radiusCartesian,
|
|
4988
5175
|
point: {
|
|
4989
|
-
color: Cesium$
|
|
5176
|
+
color: Cesium$a.Color.RED,
|
|
4990
5177
|
pixelSize: 12,
|
|
4991
|
-
outlineColor: Cesium$
|
|
5178
|
+
outlineColor: Cesium$a.Color.YELLOW,
|
|
4992
5179
|
outlineWidth: 2,
|
|
4993
5180
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
4994
|
-
heightReference: Cesium$
|
|
5181
|
+
heightReference: Cesium$a.HeightReference.CLAMP_TO_GROUND
|
|
4995
5182
|
}
|
|
4996
5183
|
});
|
|
4997
5184
|
this._editHandles.push(radiusHandle);
|
|
@@ -5011,9 +5198,9 @@ class EditTool extends BaseTool {
|
|
|
5011
5198
|
const handle = this.createTempEntity(`__edit_handle_${index}`, {
|
|
5012
5199
|
position: clampedPos,
|
|
5013
5200
|
point: {
|
|
5014
|
-
color: Cesium$
|
|
5201
|
+
color: Cesium$a.Color.YELLOW,
|
|
5015
5202
|
pixelSize: 12,
|
|
5016
|
-
outlineColor: Cesium$
|
|
5203
|
+
outlineColor: Cesium$a.Color.RED,
|
|
5017
5204
|
outlineWidth: 2,
|
|
5018
5205
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
5019
5206
|
// heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
|
|
@@ -5053,12 +5240,12 @@ class EditTool extends BaseTool {
|
|
|
5053
5240
|
const handle = this.createTempEntity('__edit_handle_center_vertex', {
|
|
5054
5241
|
position: clampedCenter,
|
|
5055
5242
|
point: {
|
|
5056
|
-
color: Cesium$
|
|
5243
|
+
color: Cesium$a.Color.CYAN,
|
|
5057
5244
|
pixelSize: 14,
|
|
5058
|
-
outlineColor: Cesium$
|
|
5245
|
+
outlineColor: Cesium$a.Color.BLUE,
|
|
5059
5246
|
outlineWidth: 2,
|
|
5060
5247
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
5061
|
-
heightReference: Cesium$
|
|
5248
|
+
heightReference: Cesium$a.HeightReference.CLAMP_TO_GROUND
|
|
5062
5249
|
}
|
|
5063
5250
|
});
|
|
5064
5251
|
this._editHandles.push(handle);
|
|
@@ -5082,7 +5269,7 @@ class EditTool extends BaseTool {
|
|
|
5082
5269
|
const clampedCenter = this._clampPositionToGround(newCenter);
|
|
5083
5270
|
|
|
5084
5271
|
// 更新中心控制点位置
|
|
5085
|
-
centerHandle.position = new Cesium$
|
|
5272
|
+
centerHandle.position = new Cesium$a.ConstantPositionProperty(clampedCenter);
|
|
5086
5273
|
// 更新原始中心点缓存(用于下次平移计算)
|
|
5087
5274
|
this._originalEntityCenter = clampedCenter;
|
|
5088
5275
|
}
|
|
@@ -5090,11 +5277,11 @@ class EditTool extends BaseTool {
|
|
|
5090
5277
|
_createPositionOutline() {
|
|
5091
5278
|
// 从控制点获取位置,性能更好(避免每次从实体重新获取和转换)
|
|
5092
5279
|
const self = this;
|
|
5093
|
-
const isPolyline = Cesium$
|
|
5280
|
+
const isPolyline = Cesium$a.defined(this._selectedEntity.polyline);
|
|
5094
5281
|
|
|
5095
5282
|
this._positionOutline = this.createTempEntity(this.generateId('temp_outline'), {
|
|
5096
5283
|
polyline: {
|
|
5097
|
-
positions: new Cesium$
|
|
5284
|
+
positions: new Cesium$a.CallbackProperty(function () {
|
|
5098
5285
|
// 从控制点获取位置(已被更新),排除中心控制点
|
|
5099
5286
|
const handles = self._editHandles;
|
|
5100
5287
|
if (!handles || handles.length === 0) return [];
|
|
@@ -5105,11 +5292,11 @@ class EditTool extends BaseTool {
|
|
|
5105
5292
|
// 跳过所有中心控制点(用于平移)- 修复:统一使用 includes('center')
|
|
5106
5293
|
if (handle.id && handle.id.includes('center')) return;
|
|
5107
5294
|
|
|
5108
|
-
const pos = handle.position.getValue(Cesium$
|
|
5295
|
+
const pos = handle.position.getValue(Cesium$a.JulianDate.now());
|
|
5109
5296
|
if (pos) {
|
|
5110
|
-
const c = Cesium$
|
|
5111
|
-
degrees.push(Cesium$
|
|
5112
|
-
degrees.push(Cesium$
|
|
5297
|
+
const c = Cesium$a.Cartographic.fromCartesian(pos);
|
|
5298
|
+
degrees.push(Cesium$a.Math.toDegrees(c.longitude));
|
|
5299
|
+
degrees.push(Cesium$a.Math.toDegrees(c.latitude));
|
|
5113
5300
|
degrees.push(c.height || 0);
|
|
5114
5301
|
}
|
|
5115
5302
|
});
|
|
@@ -5118,12 +5305,12 @@ class EditTool extends BaseTool {
|
|
|
5118
5305
|
|
|
5119
5306
|
// 线不闭合,面需要闭合
|
|
5120
5307
|
if (isPolyline) {
|
|
5121
|
-
return Cesium$
|
|
5308
|
+
return Cesium$a.Cartesian3.fromDegreesArrayHeights(degrees);
|
|
5122
5309
|
}
|
|
5123
5310
|
// 闭合多边形(首尾点相同)
|
|
5124
|
-
return Cesium$
|
|
5311
|
+
return Cesium$a.Cartesian3.fromDegreesArrayHeights([...degrees, degrees[0], degrees[1], degrees[2] || 0]);
|
|
5125
5312
|
}, false),
|
|
5126
|
-
material: Cesium$
|
|
5313
|
+
material: Cesium$a.Color.YELLOW,
|
|
5127
5314
|
width: 2,
|
|
5128
5315
|
clampToGround: true
|
|
5129
5316
|
}
|
|
@@ -5155,12 +5342,12 @@ class EditTool extends BaseTool {
|
|
|
5155
5342
|
_getEditablePositions(entity) {
|
|
5156
5343
|
if (!entity) return [];
|
|
5157
5344
|
|
|
5158
|
-
if (Cesium$
|
|
5159
|
-
return entity.polyline.positions.getValue(Cesium$
|
|
5345
|
+
if (Cesium$a.defined(entity.polyline) && Cesium$a.defined(entity.polyline.positions)) {
|
|
5346
|
+
return entity.polyline.positions.getValue(Cesium$a.JulianDate.now());
|
|
5160
5347
|
}
|
|
5161
5348
|
|
|
5162
|
-
if (Cesium$
|
|
5163
|
-
const hierarchy = entity.polygon.hierarchy.getValue(Cesium$
|
|
5349
|
+
if (Cesium$a.defined(entity.polygon) && Cesium$a.defined(entity.polygon.hierarchy)) {
|
|
5350
|
+
const hierarchy = entity.polygon.hierarchy.getValue(Cesium$a.JulianDate.now());
|
|
5164
5351
|
if (hierarchy && hierarchy.positions) {
|
|
5165
5352
|
let positions = hierarchy.positions;
|
|
5166
5353
|
|
|
@@ -5169,7 +5356,7 @@ class EditTool extends BaseTool {
|
|
|
5169
5356
|
const first = positions[0];
|
|
5170
5357
|
const last = positions[positions.length - 1];
|
|
5171
5358
|
// 使用距离判断而不是精确相等(避免浮点误差)
|
|
5172
|
-
const distance = Cesium$
|
|
5359
|
+
const distance = Cesium$a.Cartesian3.distance(first, last);
|
|
5173
5360
|
if (distance < EditTool.CLOSE_POINT_TOLERANCE) {
|
|
5174
5361
|
positions = positions.slice(0, -1); // 移除最后一个点
|
|
5175
5362
|
}
|
|
@@ -5179,8 +5366,8 @@ class EditTool extends BaseTool {
|
|
|
5179
5366
|
}
|
|
5180
5367
|
}
|
|
5181
5368
|
|
|
5182
|
-
if (Cesium$
|
|
5183
|
-
return [entity.position.getValue(Cesium$
|
|
5369
|
+
if (Cesium$a.defined(entity.position)) {
|
|
5370
|
+
return [entity.position.getValue(Cesium$a.JulianDate.now())];
|
|
5184
5371
|
}
|
|
5185
5372
|
|
|
5186
5373
|
return [];
|
|
@@ -5204,7 +5391,7 @@ class EditTool extends BaseTool {
|
|
|
5204
5391
|
z += p.z;
|
|
5205
5392
|
});
|
|
5206
5393
|
const count = positions.length;
|
|
5207
|
-
return new Cesium$
|
|
5394
|
+
return new Cesium$a.Cartesian3(x / count, y / count, z / count);
|
|
5208
5395
|
}
|
|
5209
5396
|
|
|
5210
5397
|
/**
|
|
@@ -5229,7 +5416,7 @@ class EditTool extends BaseTool {
|
|
|
5229
5416
|
const deltaZ = clampedNewCenter.z - this._originalEntityCenter.z;
|
|
5230
5417
|
|
|
5231
5418
|
// 计算真正的新中心位置(不是鼠标位置)
|
|
5232
|
-
const actualNewCenter = new Cesium$
|
|
5419
|
+
const actualNewCenter = new Cesium$a.Cartesian3(
|
|
5233
5420
|
this._originalEntityCenter.x + deltaX,
|
|
5234
5421
|
this._originalEntityCenter.y + deltaY,
|
|
5235
5422
|
this._originalEntityCenter.z + deltaZ
|
|
@@ -5239,12 +5426,12 @@ class EditTool extends BaseTool {
|
|
|
5239
5426
|
this._originalEntityCenter = actualNewCenter;
|
|
5240
5427
|
|
|
5241
5428
|
// 更新中心控制点位置
|
|
5242
|
-
this._dragHandle.position = new Cesium$
|
|
5429
|
+
this._dragHandle.position = new Cesium$a.ConstantPositionProperty(actualNewCenter);
|
|
5243
5430
|
|
|
5244
|
-
if (Cesium$
|
|
5431
|
+
if (Cesium$a.defined(this._selectedEntity.polyline)) {
|
|
5245
5432
|
// 线图元:平移所有位置
|
|
5246
5433
|
const newPositions = this._originalPositions.map(p => {
|
|
5247
|
-
const newPos = new Cesium$
|
|
5434
|
+
const newPos = new Cesium$a.Cartesian3(p.x + deltaX, p.y + deltaY, p.z + deltaZ);
|
|
5248
5435
|
// 修复:贴地
|
|
5249
5436
|
return this._clampPositionToGround(newPos);
|
|
5250
5437
|
});
|
|
@@ -5262,32 +5449,32 @@ class EditTool extends BaseTool {
|
|
|
5262
5449
|
if (match) {
|
|
5263
5450
|
const index = parseInt(match[1], 10);
|
|
5264
5451
|
if (newPositions[index]) {
|
|
5265
|
-
handle.position = new Cesium$
|
|
5452
|
+
handle.position = new Cesium$a.ConstantPositionProperty(newPositions[index]);
|
|
5266
5453
|
}
|
|
5267
5454
|
}
|
|
5268
5455
|
});
|
|
5269
5456
|
|
|
5270
5457
|
// 更新原始位置缓存
|
|
5271
5458
|
this._originalPositions = newPositions;
|
|
5272
|
-
} else if (Cesium$
|
|
5459
|
+
} else if (Cesium$a.defined(this._selectedEntity.polygon)) {
|
|
5273
5460
|
if (this._isCircle(this._selectedEntity)) {
|
|
5274
5461
|
// 圆形平移
|
|
5275
5462
|
const oldCenter = this._selectedEntity._circleCenter; // [lon, lat]
|
|
5276
5463
|
|
|
5277
5464
|
// 将旧的圆心经纬度转为 Cartesian3
|
|
5278
|
-
const oldCenterCartesian = Cesium$
|
|
5465
|
+
const oldCenterCartesian = Cesium$a.Cartesian3.fromDegrees(oldCenter[0], oldCenter[1], 0);
|
|
5279
5466
|
|
|
5280
5467
|
// 应用偏移量计算新的 Cartesian3 位置
|
|
5281
|
-
const newCenterCartesian = new Cesium$
|
|
5468
|
+
const newCenterCartesian = new Cesium$a.Cartesian3(
|
|
5282
5469
|
oldCenterCartesian.x + deltaX,
|
|
5283
5470
|
oldCenterCartesian.y + deltaY,
|
|
5284
5471
|
oldCenterCartesian.z + deltaZ
|
|
5285
5472
|
);
|
|
5286
5473
|
|
|
5287
5474
|
// 将新的 Cartesian3 转回经纬度
|
|
5288
|
-
const newCenterCartographic = Cesium$
|
|
5289
|
-
const newCenterLon = Cesium$
|
|
5290
|
-
const newCenterLat = Cesium$
|
|
5475
|
+
const newCenterCartographic = Cesium$a.Cartographic.fromCartesian(newCenterCartesian);
|
|
5476
|
+
const newCenterLon = Cesium$a.Math.toDegrees(newCenterCartographic.longitude);
|
|
5477
|
+
const newCenterLat = Cesium$a.Math.toDegrees(newCenterCartographic.latitude);
|
|
5291
5478
|
|
|
5292
5479
|
this._selectedEntity._circleCenter = [newCenterLon, newCenterLat];
|
|
5293
5480
|
|
|
@@ -5298,25 +5485,25 @@ class EditTool extends BaseTool {
|
|
|
5298
5485
|
256
|
|
5299
5486
|
);
|
|
5300
5487
|
const flat = positions.flatMap(c => [c[0], c[1], 0]);
|
|
5301
|
-
this._selectedEntity.polygon.hierarchy = new Cesium$
|
|
5302
|
-
Cesium$
|
|
5488
|
+
this._selectedEntity.polygon.hierarchy = new Cesium$a.PolygonHierarchy(
|
|
5489
|
+
Cesium$a.Cartesian3.fromDegreesArrayHeights(flat)
|
|
5303
5490
|
);
|
|
5304
5491
|
|
|
5305
5492
|
// 更新圆心控制点位置
|
|
5306
5493
|
const centerHandle = this._editHandles.find(h => h.id && h.id.includes('__edit_handle_center'));
|
|
5307
5494
|
if (centerHandle) {
|
|
5308
|
-
centerHandle.position = new Cesium$
|
|
5495
|
+
centerHandle.position = new Cesium$a.ConstantPositionProperty(newCenterCartesian);
|
|
5309
5496
|
}
|
|
5310
5497
|
} else {
|
|
5311
5498
|
// 普通多边形:平移所有顶点
|
|
5312
5499
|
const newPositions = this._originalPositions.map(p => {
|
|
5313
|
-
const newPos = new Cesium$
|
|
5500
|
+
const newPos = new Cesium$a.Cartesian3(p.x + deltaX, p.y + deltaY, p.z + deltaZ);
|
|
5314
5501
|
// 修复:贴地
|
|
5315
5502
|
return this._clampPositionToGround(newPos);
|
|
5316
5503
|
});
|
|
5317
5504
|
// 添加闭合点
|
|
5318
5505
|
newPositions.push(newPositions[0].clone());
|
|
5319
|
-
this._selectedEntity.polygon.hierarchy = new Cesium$
|
|
5506
|
+
this._selectedEntity.polygon.hierarchy = new Cesium$a.PolygonHierarchy(newPositions);
|
|
5320
5507
|
|
|
5321
5508
|
// 修复:更新顶点控制点位置,使用更可靠的ID匹配
|
|
5322
5509
|
this._editHandles.forEach((handle) => {
|
|
@@ -5329,7 +5516,7 @@ class EditTool extends BaseTool {
|
|
|
5329
5516
|
if (match) {
|
|
5330
5517
|
const index = parseInt(match[1], 10);
|
|
5331
5518
|
if (newPositions[index]) {
|
|
5332
|
-
handle.position = new Cesium$
|
|
5519
|
+
handle.position = new Cesium$a.ConstantPositionProperty(newPositions[index]);
|
|
5333
5520
|
}
|
|
5334
5521
|
}
|
|
5335
5522
|
});
|
|
@@ -5337,9 +5524,9 @@ class EditTool extends BaseTool {
|
|
|
5337
5524
|
// 更新原始位置缓存
|
|
5338
5525
|
this._originalPositions = newPositions.slice(0, -1);
|
|
5339
5526
|
}
|
|
5340
|
-
} else if (Cesium$
|
|
5527
|
+
} else if (Cesium$a.defined(this._selectedEntity.position)) {
|
|
5341
5528
|
// 点/文本图元:平移位置
|
|
5342
|
-
this._selectedEntity.position = new Cesium$
|
|
5529
|
+
this._selectedEntity.position = new Cesium$a.ConstantPositionProperty(actualNewCenter);
|
|
5343
5530
|
this._originalPositions = [actualNewCenter];
|
|
5344
5531
|
}
|
|
5345
5532
|
}
|
|
@@ -5468,16 +5655,16 @@ class EditTool extends BaseTool {
|
|
|
5468
5655
|
// 圆周辅助线(黄色)
|
|
5469
5656
|
this._positionOutline = this.createTempEntity(this.generateId('temp_circle_outline'), {
|
|
5470
5657
|
polyline: {
|
|
5471
|
-
positions: new Cesium$
|
|
5658
|
+
positions: new Cesium$a.CallbackProperty(function () {
|
|
5472
5659
|
const circleInfo = self._getCircleInfo(self._selectedEntity);
|
|
5473
5660
|
if (!circleInfo) return [];
|
|
5474
5661
|
|
|
5475
5662
|
const { center, radius } = circleInfo;
|
|
5476
5663
|
const positions = self._generateCirclePositions(center, radius, 256);
|
|
5477
5664
|
const flat = positions.flatMap(c => [c[0], c[1], 0]);
|
|
5478
|
-
return Cesium$
|
|
5665
|
+
return Cesium$a.Cartesian3.fromDegreesArrayHeights(flat);
|
|
5479
5666
|
}, false),
|
|
5480
|
-
material: Cesium$
|
|
5667
|
+
material: Cesium$a.Color.YELLOW,
|
|
5481
5668
|
width: 2,
|
|
5482
5669
|
clampToGround: true
|
|
5483
5670
|
}
|
|
@@ -5489,7 +5676,7 @@ class EditTool extends BaseTool {
|
|
|
5489
5676
|
// 修复:正确获取半径控制点的位置
|
|
5490
5677
|
this._radiusLine = this.createTempEntity(this.generateId('temp_radius_line'), {
|
|
5491
5678
|
polyline: {
|
|
5492
|
-
positions: new Cesium$
|
|
5679
|
+
positions: new Cesium$a.CallbackProperty(function () {
|
|
5493
5680
|
const circleInfo = self._getCircleInfo(self._selectedEntity);
|
|
5494
5681
|
if (!circleInfo) return [];
|
|
5495
5682
|
|
|
@@ -5498,13 +5685,13 @@ class EditTool extends BaseTool {
|
|
|
5498
5685
|
const radiusHandle = self._editHandles.find(h => h.id && h.id.includes('__edit_handle_radius'));
|
|
5499
5686
|
if (!radiusHandle) return [];
|
|
5500
5687
|
|
|
5501
|
-
const radiusPos = radiusHandle.position.getValue(Cesium$
|
|
5688
|
+
const radiusPos = radiusHandle.position.getValue(Cesium$a.JulianDate.now());
|
|
5502
5689
|
if (!radiusPos) return [];
|
|
5503
5690
|
|
|
5504
|
-
const centerCart = Cesium$
|
|
5691
|
+
const centerCart = Cesium$a.Cartesian3.fromDegrees(center[0], center[1], 0);
|
|
5505
5692
|
return [centerCart, radiusPos];
|
|
5506
5693
|
}, false),
|
|
5507
|
-
material: Cesium$
|
|
5694
|
+
material: Cesium$a.Color.RED,
|
|
5508
5695
|
width: 3,
|
|
5509
5696
|
clampToGround: true
|
|
5510
5697
|
}
|
|
@@ -5544,8 +5731,8 @@ class EditTool extends BaseTool {
|
|
|
5544
5731
|
_computeRectangleNewPositions(newPos, originalPositions, draggedIndex) {
|
|
5545
5732
|
// 对角顶点索引:0->2, 1->3, 2->0, 3->1
|
|
5546
5733
|
const oppositeIndex = (draggedIndex + 2) % 4;
|
|
5547
|
-
const newP = Cesium$
|
|
5548
|
-
const currentPos = originalPositions.map(p => Cesium$
|
|
5734
|
+
const newP = Cesium$a.Cartographic.fromCartesian(newPos);
|
|
5735
|
+
const currentPos = originalPositions.map(p => Cesium$a.Cartographic.fromCartesian(p));
|
|
5549
5736
|
const oppositePos = currentPos[oppositeIndex];
|
|
5550
5737
|
|
|
5551
5738
|
const newPositions = new Array(4);
|
|
@@ -5558,14 +5745,14 @@ class EditTool extends BaseTool {
|
|
|
5558
5745
|
const neighbor2 = (draggedIndex + 3) % 4;
|
|
5559
5746
|
|
|
5560
5747
|
// neighbor1 使用 newPos 的 longitude 和 opposite 的 latitude
|
|
5561
|
-
newPositions[neighbor1] = Cesium$
|
|
5748
|
+
newPositions[neighbor1] = Cesium$a.Cartesian3.fromRadians(
|
|
5562
5749
|
newP.longitude,
|
|
5563
5750
|
oppositePos.latitude,
|
|
5564
5751
|
oppositePos.height
|
|
5565
5752
|
);
|
|
5566
5753
|
|
|
5567
5754
|
// neighbor2 使用 opposite 的 longitude 和 newPos 的 latitude
|
|
5568
|
-
newPositions[neighbor2] = Cesium$
|
|
5755
|
+
newPositions[neighbor2] = Cesium$a.Cartesian3.fromRadians(
|
|
5569
5756
|
oppositePos.longitude,
|
|
5570
5757
|
newP.latitude,
|
|
5571
5758
|
oppositePos.height
|
|
@@ -5581,7 +5768,7 @@ class EditTool extends BaseTool {
|
|
|
5581
5768
|
if (handleIndex === -1) return;
|
|
5582
5769
|
|
|
5583
5770
|
// 修复:新位置贴地(高度设为0)
|
|
5584
|
-
const newCartesian = Cesium$
|
|
5771
|
+
const newCartesian = Cesium$a.Cartesian3.fromDegrees(newLonLat[0], newLonLat[1], 0);
|
|
5585
5772
|
|
|
5586
5773
|
// 标绘图元:拖拽控制点重新生成几何
|
|
5587
5774
|
if (this._selectedEntity._isPlotGraphic) {
|
|
@@ -5604,12 +5791,12 @@ class EditTool extends BaseTool {
|
|
|
5604
5791
|
// 扇形:拖拽圆心(索引0)时整体平移,保持两半径等长
|
|
5605
5792
|
if (plotType === PlotGraphicType.SECTOR && index === 0) {
|
|
5606
5793
|
const oldCenter = this._selectedEntity._controlPoints[0];
|
|
5607
|
-
const oldCenterCart = Cesium$
|
|
5794
|
+
const oldCenterCart = Cesium$a.Cartesian3.fromDegrees(oldCenter[0], oldCenter[1], oldCenter[2] || 0);
|
|
5608
5795
|
const clampedNewCenter = this._clampPositionToGround(newCartesian);
|
|
5609
5796
|
this._translatePlotControlPoints(clampedNewCenter, oldCenterCart);
|
|
5610
5797
|
// 中心控制点固定在圆心
|
|
5611
5798
|
this._originalEntityCenter = this._clampPositionToGround(
|
|
5612
|
-
Cesium$
|
|
5799
|
+
Cesium$a.Cartesian3.fromDegrees(
|
|
5613
5800
|
this._selectedEntity._controlPoints[0][0],
|
|
5614
5801
|
this._selectedEntity._controlPoints[0][1],
|
|
5615
5802
|
this._selectedEntity._controlPoints[0][2] || 0
|
|
@@ -5685,8 +5872,8 @@ class EditTool extends BaseTool {
|
|
|
5685
5872
|
if (match) {
|
|
5686
5873
|
const cpIndex = parseInt(match[1], 10);
|
|
5687
5874
|
const cp = controlPoints[cpIndex];
|
|
5688
|
-
handle.position = new Cesium$
|
|
5689
|
-
this._clampPositionToGround(Cesium$
|
|
5875
|
+
handle.position = new Cesium$a.ConstantPositionProperty(
|
|
5876
|
+
this._clampPositionToGround(Cesium$a.Cartesian3.fromDegrees(cp[0], cp[1], cp[2] || 0))
|
|
5690
5877
|
);
|
|
5691
5878
|
}
|
|
5692
5879
|
});
|
|
@@ -5698,11 +5885,11 @@ class EditTool extends BaseTool {
|
|
|
5698
5885
|
const newCenter = (plotType === PlotGraphicType.SECTOR || plotType === PlotGraphicType.ELLIPSE)
|
|
5699
5886
|
? controlPoints[0]
|
|
5700
5887
|
: this._getPlotControlPointsCenter(controlPoints);
|
|
5701
|
-
centerHandle.position = new Cesium$
|
|
5702
|
-
this._clampPositionToGround(Cesium$
|
|
5888
|
+
centerHandle.position = new Cesium$a.ConstantPositionProperty(
|
|
5889
|
+
this._clampPositionToGround(Cesium$a.Cartesian3.fromDegrees(newCenter[0], newCenter[1], newCenter[2] || 0))
|
|
5703
5890
|
);
|
|
5704
5891
|
this._originalEntityCenter = this._clampPositionToGround(
|
|
5705
|
-
Cesium$
|
|
5892
|
+
Cesium$a.Cartesian3.fromDegrees(newCenter[0], newCenter[1], newCenter[2] || 0)
|
|
5706
5893
|
);
|
|
5707
5894
|
}
|
|
5708
5895
|
|
|
@@ -5711,7 +5898,7 @@ class EditTool extends BaseTool {
|
|
|
5711
5898
|
return;
|
|
5712
5899
|
}
|
|
5713
5900
|
|
|
5714
|
-
const hierarchy = this._selectedEntity.polygon?.hierarchy?.getValue(Cesium$
|
|
5901
|
+
const hierarchy = this._selectedEntity.polygon?.hierarchy?.getValue(Cesium$a.JulianDate.now());
|
|
5715
5902
|
|
|
5716
5903
|
// 拖动中心控制点:平移整个图元
|
|
5717
5904
|
// 修复:统一使用 includes('center') 来判断
|
|
@@ -5725,7 +5912,7 @@ class EditTool extends BaseTool {
|
|
|
5725
5912
|
if (this._handleVertexIndices &&
|
|
5726
5913
|
Array.isArray(this._handleVertexIndices) &&
|
|
5727
5914
|
typeof this._handleVertexIndices[0] === 'number' &&
|
|
5728
|
-
Cesium$
|
|
5915
|
+
Cesium$a.defined(this._selectedEntity.polygon)) {
|
|
5729
5916
|
if (!hierarchy || !hierarchy.positions || hierarchy.positions.length < 4) return;
|
|
5730
5917
|
|
|
5731
5918
|
const draggedVertexIndex = this._handleVertexIndices[handleIndex];
|
|
@@ -5735,13 +5922,13 @@ class EditTool extends BaseTool {
|
|
|
5735
5922
|
const clampedPositions = newPositions.map(pos => this._clampPositionToGround(pos));
|
|
5736
5923
|
|
|
5737
5924
|
// 更新多边形
|
|
5738
|
-
this._selectedEntity.polygon.hierarchy = new Cesium$
|
|
5925
|
+
this._selectedEntity.polygon.hierarchy = new Cesium$a.PolygonHierarchy(clampedPositions);
|
|
5739
5926
|
|
|
5740
5927
|
// 更新所有控制点位置(使用 ConstantPositionProperty 确保正确更新)
|
|
5741
5928
|
this._editHandles.forEach((handle, i) => {
|
|
5742
5929
|
// 修复:跳过中心控制点
|
|
5743
5930
|
if (handle.id && handle.id.includes('center')) return;
|
|
5744
|
-
handle.position = new Cesium$
|
|
5931
|
+
handle.position = new Cesium$a.ConstantPositionProperty(clampedPositions[i]);
|
|
5745
5932
|
});
|
|
5746
5933
|
|
|
5747
5934
|
// 修复:顶点编辑后重新计算并更新中心控制点位置
|
|
@@ -5774,16 +5961,16 @@ class EditTool extends BaseTool {
|
|
|
5774
5961
|
// 更新多边形顶点
|
|
5775
5962
|
const positions = this._generateCirclePositions(newCenterLonLat, circleInfo.radius, 256);
|
|
5776
5963
|
const flat = positions.flatMap(c => [c[0], c[1], 0]);
|
|
5777
|
-
this._selectedEntity.polygon.hierarchy = new Cesium$
|
|
5778
|
-
Cesium$
|
|
5964
|
+
this._selectedEntity.polygon.hierarchy = new Cesium$a.PolygonHierarchy(
|
|
5965
|
+
Cesium$a.Cartesian3.fromDegreesArrayHeights(flat)
|
|
5779
5966
|
);
|
|
5780
5967
|
|
|
5781
5968
|
// 更新半径控制点位置
|
|
5782
5969
|
const radiusHandle = this._editHandles.find(h => h.id && h.id.includes('radius'));
|
|
5783
5970
|
if (radiusHandle) {
|
|
5784
5971
|
const radiusPoint = this._getPointOnCircle(newCenterLonLat, circleInfo.radius, 0);
|
|
5785
|
-
radiusHandle.position = new Cesium$
|
|
5786
|
-
Cesium$
|
|
5972
|
+
radiusHandle.position = new Cesium$a.ConstantPositionProperty(
|
|
5973
|
+
Cesium$a.Cartesian3.fromDegrees(radiusPoint[0], radiusPoint[1], 0)
|
|
5787
5974
|
);
|
|
5788
5975
|
}
|
|
5789
5976
|
|
|
@@ -5795,8 +5982,8 @@ class EditTool extends BaseTool {
|
|
|
5795
5982
|
// 更新半径控制点位置(在圆周上)
|
|
5796
5983
|
const angle = Math.atan2(newLonLat[1] - circleInfo.center[1], newLonLat[0] - circleInfo.center[0]);
|
|
5797
5984
|
const radiusPoint = this._getPointOnCircle(circleInfo.center, newRadius, angle);
|
|
5798
|
-
this._dragHandle.position = new Cesium$
|
|
5799
|
-
Cesium$
|
|
5985
|
+
this._dragHandle.position = new Cesium$a.ConstantPositionProperty(
|
|
5986
|
+
Cesium$a.Cartesian3.fromDegrees(radiusPoint[0], radiusPoint[1], 0)
|
|
5800
5987
|
);
|
|
5801
5988
|
|
|
5802
5989
|
// 更新圆的实体属性
|
|
@@ -5806,25 +5993,25 @@ class EditTool extends BaseTool {
|
|
|
5806
5993
|
// 更新多边形顶点
|
|
5807
5994
|
const positions = this._generateCirclePositions(circleInfo.center, newRadius, 256);
|
|
5808
5995
|
const flat = positions.flatMap(c => [c[0], c[1], 0]);
|
|
5809
|
-
this._selectedEntity.polygon.hierarchy = new Cesium$
|
|
5810
|
-
Cesium$
|
|
5996
|
+
this._selectedEntity.polygon.hierarchy = new Cesium$a.PolygonHierarchy(
|
|
5997
|
+
Cesium$a.Cartesian3.fromDegreesArrayHeights(flat)
|
|
5811
5998
|
);
|
|
5812
5999
|
|
|
5813
6000
|
return;
|
|
5814
6001
|
}
|
|
5815
6002
|
|
|
5816
|
-
if (Cesium$
|
|
5817
|
-
const positions = this._selectedEntity.polyline.positions.getValue(Cesium$
|
|
6003
|
+
if (Cesium$a.defined(this._selectedEntity.polyline)) {
|
|
6004
|
+
const positions = this._selectedEntity.polyline.positions.getValue(Cesium$a.JulianDate.now());
|
|
5818
6005
|
if (positions && positions[handleIndex]) {
|
|
5819
6006
|
// 直接修改数组元素触发更新
|
|
5820
6007
|
positions[handleIndex] = newCartesian;
|
|
5821
6008
|
this._selectedEntity.polyline.positions = positions;
|
|
5822
|
-
this._dragHandle.position = new Cesium$
|
|
6009
|
+
this._dragHandle.position = new Cesium$a.ConstantPositionProperty(newCartesian);
|
|
5823
6010
|
|
|
5824
6011
|
// 修复:线编辑后重新计算并更新中心控制点位置
|
|
5825
6012
|
this._updateCenterHandlePosition();
|
|
5826
6013
|
}
|
|
5827
|
-
} else if (Cesium$
|
|
6014
|
+
} else if (Cesium$a.defined(this._selectedEntity.polygon)) {
|
|
5828
6015
|
// 获取当前实际顶点数(不包含闭合点)
|
|
5829
6016
|
this._editHandles.filter(h => !h.id.includes('center')).length;
|
|
5830
6017
|
|
|
@@ -5839,7 +6026,7 @@ class EditTool extends BaseTool {
|
|
|
5839
6026
|
newPositions.push(newCartesian);
|
|
5840
6027
|
} else {
|
|
5841
6028
|
// 从控制点获取当前位置
|
|
5842
|
-
const pos = handle.position.getValue(Cesium$
|
|
6029
|
+
const pos = handle.position.getValue(Cesium$a.JulianDate.now());
|
|
5843
6030
|
// 修复:确保位置贴地
|
|
5844
6031
|
newPositions.push(this._clampPositionToGround(pos));
|
|
5845
6032
|
}
|
|
@@ -5849,47 +6036,47 @@ class EditTool extends BaseTool {
|
|
|
5849
6036
|
newPositions.push(newPositions[0].clone());
|
|
5850
6037
|
|
|
5851
6038
|
// 更新多边形
|
|
5852
|
-
this._selectedEntity.polygon.hierarchy = new Cesium$
|
|
6039
|
+
this._selectedEntity.polygon.hierarchy = new Cesium$a.PolygonHierarchy(newPositions);
|
|
5853
6040
|
|
|
5854
6041
|
// 更新控制点
|
|
5855
|
-
this._dragHandle.position = new Cesium$
|
|
6042
|
+
this._dragHandle.position = new Cesium$a.ConstantPositionProperty(newCartesian);
|
|
5856
6043
|
|
|
5857
6044
|
// 修复:多边形编辑后重新计算并更新中心控制点位置
|
|
5858
6045
|
this._updateCenterHandlePosition();
|
|
5859
6046
|
|
|
5860
6047
|
return;
|
|
5861
|
-
} else if (Cesium$
|
|
5862
|
-
this._selectedEntity.position = new Cesium$
|
|
5863
|
-
this._dragHandle.position = new Cesium$
|
|
6048
|
+
} else if (Cesium$a.defined(this._selectedEntity.position)) {
|
|
6049
|
+
this._selectedEntity.position = new Cesium$a.ConstantPositionProperty(newCartesian);
|
|
6050
|
+
this._dragHandle.position = new Cesium$a.ConstantPositionProperty(newCartesian);
|
|
5864
6051
|
}
|
|
5865
6052
|
}
|
|
5866
6053
|
|
|
5867
6054
|
_highlightEntity(entity, highlight) {
|
|
5868
6055
|
if (!entity) return;
|
|
5869
6056
|
|
|
5870
|
-
if (Cesium$
|
|
6057
|
+
if (Cesium$a.defined(entity.point)) {
|
|
5871
6058
|
if (highlight) {
|
|
5872
|
-
entity.point.outlineColor = Cesium$
|
|
6059
|
+
entity.point.outlineColor = Cesium$a.Color.CYAN;
|
|
5873
6060
|
entity.point.outlineWidth = 3;
|
|
5874
6061
|
} else {
|
|
5875
|
-
entity.point.outlineColor = Cesium$
|
|
6062
|
+
entity.point.outlineColor = Cesium$a.Color.WHITE;
|
|
5876
6063
|
entity.point.outlineWidth = 1;
|
|
5877
6064
|
}
|
|
5878
6065
|
}
|
|
5879
6066
|
|
|
5880
|
-
if (Cesium$
|
|
6067
|
+
if (Cesium$a.defined(entity.polyline)) {
|
|
5881
6068
|
if (highlight) {
|
|
5882
|
-
entity.polyline.material = Cesium$
|
|
6069
|
+
entity.polyline.material = Cesium$a.Color.CYAN;
|
|
5883
6070
|
} else {
|
|
5884
|
-
entity.polyline.material = Cesium$
|
|
6071
|
+
entity.polyline.material = Cesium$a.Color.BLUE;
|
|
5885
6072
|
}
|
|
5886
6073
|
}
|
|
5887
6074
|
|
|
5888
|
-
if (Cesium$
|
|
6075
|
+
if (Cesium$a.defined(entity.polygon)) {
|
|
5889
6076
|
if (highlight) {
|
|
5890
|
-
entity.polygon.outlineColor = Cesium$
|
|
6077
|
+
entity.polygon.outlineColor = Cesium$a.Color.CYAN;
|
|
5891
6078
|
} else {
|
|
5892
|
-
entity.polygon.outlineColor = Cesium$
|
|
6079
|
+
entity.polygon.outlineColor = Cesium$a.Color.WHITE;
|
|
5893
6080
|
}
|
|
5894
6081
|
}
|
|
5895
6082
|
}
|
|
@@ -5926,8 +6113,8 @@ class EditTool extends BaseTool {
|
|
|
5926
6113
|
// 更新多边形顶点
|
|
5927
6114
|
const positions = this._generateCirclePositions(center, radius, 256);
|
|
5928
6115
|
const flat = positions.flatMap(c => [c[0], c[1], 0]);
|
|
5929
|
-
this._selectedEntity.polygon.hierarchy = new Cesium$
|
|
5930
|
-
Cesium$
|
|
6116
|
+
this._selectedEntity.polygon.hierarchy = new Cesium$a.PolygonHierarchy(
|
|
6117
|
+
Cesium$a.Cartesian3.fromDegreesArrayHeights(flat)
|
|
5931
6118
|
);
|
|
5932
6119
|
|
|
5933
6120
|
this._createEditHandles();
|
|
@@ -5942,10 +6129,10 @@ class EditTool extends BaseTool {
|
|
|
5942
6129
|
// 拷贝一份避免直接修改原始数据
|
|
5943
6130
|
const positionsCopy = originalPositions.map(p => p.clone ? p.clone() : p);
|
|
5944
6131
|
|
|
5945
|
-
if (Cesium$
|
|
6132
|
+
if (Cesium$a.defined(this._selectedEntity.polyline)) {
|
|
5946
6133
|
this._selectedEntity.polyline.positions = positionsCopy;
|
|
5947
|
-
} else if (Cesium$
|
|
5948
|
-
this._selectedEntity.polygon.hierarchy = new Cesium$
|
|
6134
|
+
} else if (Cesium$a.defined(this._selectedEntity.polygon)) {
|
|
6135
|
+
this._selectedEntity.polygon.hierarchy = new Cesium$a.PolygonHierarchy(positionsCopy);
|
|
5949
6136
|
}
|
|
5950
6137
|
|
|
5951
6138
|
this._createEditHandles();
|
|
@@ -5968,7 +6155,7 @@ class EditTool extends BaseTool {
|
|
|
5968
6155
|
}
|
|
5969
6156
|
}
|
|
5970
6157
|
|
|
5971
|
-
const Cesium$
|
|
6158
|
+
const Cesium$9 = getCesium();
|
|
5972
6159
|
|
|
5973
6160
|
/**
|
|
5974
6161
|
* 选择类型枚举
|
|
@@ -6055,7 +6242,7 @@ class SelectTool extends BaseTool {
|
|
|
6055
6242
|
|
|
6056
6243
|
const picked = this._viewer.scene.pick(screenPos);
|
|
6057
6244
|
|
|
6058
|
-
if (Cesium$
|
|
6245
|
+
if (Cesium$9.defined(picked) && Cesium$9.defined(picked.id)) {
|
|
6059
6246
|
const entityId = picked.id.id;
|
|
6060
6247
|
|
|
6061
6248
|
// 忽略临时图元
|
|
@@ -6097,9 +6284,9 @@ class SelectTool extends BaseTool {
|
|
|
6097
6284
|
|
|
6098
6285
|
_createSelectionStartMarker(pos) {
|
|
6099
6286
|
const marker = this.createTempEntity(this.generateId('sel_start'), {
|
|
6100
|
-
position: Cesium$
|
|
6287
|
+
position: Cesium$9.Cartesian3.fromDegrees(...pos),
|
|
6101
6288
|
point: {
|
|
6102
|
-
color: Cesium$
|
|
6289
|
+
color: Cesium$9.Color.GREEN,
|
|
6103
6290
|
pixelSize: 10
|
|
6104
6291
|
}
|
|
6105
6292
|
});
|
|
@@ -6124,27 +6311,27 @@ class SelectTool extends BaseTool {
|
|
|
6124
6311
|
if (!this._selectionRect) {
|
|
6125
6312
|
this._selectionRect = this.createTempEntity(this.generateId('sel_rect'), {
|
|
6126
6313
|
polyline: {
|
|
6127
|
-
positions: new Cesium$
|
|
6314
|
+
positions: new Cesium$9.CallbackProperty(() => {
|
|
6128
6315
|
const c1 = this._startPos;
|
|
6129
6316
|
const c2 = this._currentEndPos;
|
|
6130
6317
|
if (!c1 || !c2) return [];
|
|
6131
6318
|
const pos = this._getRectPositions(c1, c2);
|
|
6132
|
-
return Cesium$
|
|
6319
|
+
return Cesium$9.Cartesian3.fromDegreesArrayHeights(pos.flatMap(c => [c[0], c[1], 0]));
|
|
6133
6320
|
}, false),
|
|
6134
|
-
material: Cesium$
|
|
6321
|
+
material: Cesium$9.Color.CYAN,
|
|
6135
6322
|
width: 2
|
|
6136
6323
|
},
|
|
6137
6324
|
polygon: {
|
|
6138
|
-
hierarchy: new Cesium$
|
|
6325
|
+
hierarchy: new Cesium$9.CallbackProperty(() => {
|
|
6139
6326
|
const c1 = this._startPos;
|
|
6140
6327
|
const c2 = this._currentEndPos;
|
|
6141
|
-
if (!c1 || !c2) return new Cesium$
|
|
6328
|
+
if (!c1 || !c2) return new Cesium$9.PolygonHierarchy([]);
|
|
6142
6329
|
const pos = this._getRectPositions(c1, c2);
|
|
6143
|
-
return new Cesium$
|
|
6144
|
-
Cesium$
|
|
6330
|
+
return new Cesium$9.PolygonHierarchy(
|
|
6331
|
+
Cesium$9.Cartesian3.fromDegreesArrayHeights(pos.flatMap(c => [c[0], c[1], 0]))
|
|
6145
6332
|
);
|
|
6146
6333
|
}, false),
|
|
6147
|
-
material: Cesium$
|
|
6334
|
+
material: Cesium$9.Color.CYAN.withAlpha(0.2),
|
|
6148
6335
|
outline: false
|
|
6149
6336
|
}
|
|
6150
6337
|
});
|
|
@@ -6161,21 +6348,21 @@ class SelectTool extends BaseTool {
|
|
|
6161
6348
|
if (!this._selectionRect) {
|
|
6162
6349
|
this._selectionRect = this.createTempEntity(this.generateId('sel_circle'), {
|
|
6163
6350
|
polygon: {
|
|
6164
|
-
hierarchy: new Cesium$
|
|
6351
|
+
hierarchy: new Cesium$9.CallbackProperty(() => {
|
|
6165
6352
|
const c = this._startPos;
|
|
6166
6353
|
const edge = this._currentEndPos;
|
|
6167
|
-
if (!c || !edge) return new Cesium$
|
|
6354
|
+
if (!c || !edge) return new Cesium$9.PolygonHierarchy([]);
|
|
6168
6355
|
const radius = this._calcDistance(c, edge);
|
|
6169
6356
|
const positions = this._generateCirclePositions(c, radius, 36);
|
|
6170
|
-
return new Cesium$
|
|
6171
|
-
Cesium$
|
|
6357
|
+
return new Cesium$9.PolygonHierarchy(
|
|
6358
|
+
Cesium$9.Cartesian3.fromDegreesArrayHeights(
|
|
6172
6359
|
positions.flatMap(c => [c[0], c[1], 0])
|
|
6173
6360
|
)
|
|
6174
6361
|
);
|
|
6175
6362
|
}, false),
|
|
6176
|
-
material: Cesium$
|
|
6363
|
+
material: Cesium$9.Color.CYAN.withAlpha(0.2),
|
|
6177
6364
|
outline: true,
|
|
6178
|
-
outlineColor: Cesium$
|
|
6365
|
+
outlineColor: Cesium$9.Color.CYAN
|
|
6179
6366
|
}
|
|
6180
6367
|
});
|
|
6181
6368
|
this._selectionRect._isPreview = true;
|
|
@@ -6264,7 +6451,7 @@ class SelectTool extends BaseTool {
|
|
|
6264
6451
|
|
|
6265
6452
|
const styleKey = entityId;
|
|
6266
6453
|
|
|
6267
|
-
if (Cesium$
|
|
6454
|
+
if (Cesium$9.defined(entity.point)) {
|
|
6268
6455
|
if (highlight) {
|
|
6269
6456
|
if (!this._originalStyles.has(styleKey)) {
|
|
6270
6457
|
this._originalStyles.set(styleKey, {
|
|
@@ -6274,7 +6461,7 @@ class SelectTool extends BaseTool {
|
|
|
6274
6461
|
}
|
|
6275
6462
|
});
|
|
6276
6463
|
}
|
|
6277
|
-
entity.point.outlineColor = Cesium$
|
|
6464
|
+
entity.point.outlineColor = Cesium$9.Color.YELLOW;
|
|
6278
6465
|
entity.point.outlineWidth = 2;
|
|
6279
6466
|
} else {
|
|
6280
6467
|
const original = this._originalStyles.get(styleKey)?.point;
|
|
@@ -6282,13 +6469,13 @@ class SelectTool extends BaseTool {
|
|
|
6282
6469
|
entity.point.outlineColor = original.outlineColor;
|
|
6283
6470
|
entity.point.outlineWidth = original.outlineWidth;
|
|
6284
6471
|
} else {
|
|
6285
|
-
entity.point.outlineColor = Cesium$
|
|
6472
|
+
entity.point.outlineColor = Cesium$9.Color.WHITE;
|
|
6286
6473
|
entity.point.outlineWidth = 1;
|
|
6287
6474
|
}
|
|
6288
6475
|
}
|
|
6289
6476
|
}
|
|
6290
6477
|
|
|
6291
|
-
if (Cesium$
|
|
6478
|
+
if (Cesium$9.defined(entity.polyline)) {
|
|
6292
6479
|
if (highlight) {
|
|
6293
6480
|
if (!this._originalStyles.has(styleKey)) {
|
|
6294
6481
|
this._originalStyles.set(styleKey, {
|
|
@@ -6297,14 +6484,14 @@ class SelectTool extends BaseTool {
|
|
|
6297
6484
|
}
|
|
6298
6485
|
});
|
|
6299
6486
|
}
|
|
6300
|
-
entity.polyline.material = Cesium$
|
|
6487
|
+
entity.polyline.material = Cesium$9.Color.CYAN;
|
|
6301
6488
|
} else {
|
|
6302
6489
|
const original = this._originalStyles.get(styleKey)?.polyline;
|
|
6303
|
-
entity.polyline.material = original?.material || Cesium$
|
|
6490
|
+
entity.polyline.material = original?.material || Cesium$9.Color.BLUE;
|
|
6304
6491
|
}
|
|
6305
6492
|
}
|
|
6306
6493
|
|
|
6307
|
-
if (Cesium$
|
|
6494
|
+
if (Cesium$9.defined(entity.polygon)) {
|
|
6308
6495
|
if (highlight) {
|
|
6309
6496
|
if (!this._originalStyles.has(styleKey)) {
|
|
6310
6497
|
this._originalStyles.set(styleKey, {
|
|
@@ -6313,10 +6500,10 @@ class SelectTool extends BaseTool {
|
|
|
6313
6500
|
}
|
|
6314
6501
|
});
|
|
6315
6502
|
}
|
|
6316
|
-
entity.polygon.outlineColor = Cesium$
|
|
6503
|
+
entity.polygon.outlineColor = Cesium$9.Color.CYAN;
|
|
6317
6504
|
} else {
|
|
6318
6505
|
const original = this._originalStyles.get(styleKey)?.polygon;
|
|
6319
|
-
entity.polygon.outlineColor = original?.outlineColor || Cesium$
|
|
6506
|
+
entity.polygon.outlineColor = original?.outlineColor || Cesium$9.Color.WHITE;
|
|
6320
6507
|
}
|
|
6321
6508
|
}
|
|
6322
6509
|
|
|
@@ -6403,9 +6590,9 @@ class SelectTool extends BaseTool {
|
|
|
6403
6590
|
// 检查是否所有点都在范围内
|
|
6404
6591
|
let allInBounds = true;
|
|
6405
6592
|
for (const pos of positions) {
|
|
6406
|
-
const c = Cesium$
|
|
6407
|
-
const lon = Cesium$
|
|
6408
|
-
const lat = Cesium$
|
|
6593
|
+
const c = Cesium$9.Cartographic.fromCartesian(pos);
|
|
6594
|
+
const lon = Cesium$9.Math.toDegrees(c.longitude);
|
|
6595
|
+
const lat = Cesium$9.Math.toDegrees(c.latitude);
|
|
6409
6596
|
|
|
6410
6597
|
if (lon < minLon || lon > maxLon || lat < minLat || lat > maxLat) {
|
|
6411
6598
|
allInBounds = false;
|
|
@@ -6422,13 +6609,13 @@ class SelectTool extends BaseTool {
|
|
|
6422
6609
|
}
|
|
6423
6610
|
|
|
6424
6611
|
_getEntityPosition(entity) {
|
|
6425
|
-
if (Cesium$
|
|
6426
|
-
const pos = entity.position.getValue(Cesium$
|
|
6612
|
+
if (Cesium$9.defined(entity.position)) {
|
|
6613
|
+
const pos = entity.position.getValue(Cesium$9.JulianDate.now());
|
|
6427
6614
|
if (pos) {
|
|
6428
|
-
const c = Cesium$
|
|
6615
|
+
const c = Cesium$9.Cartographic.fromCartesian(pos);
|
|
6429
6616
|
return [
|
|
6430
|
-
Cesium$
|
|
6431
|
-
Cesium$
|
|
6617
|
+
Cesium$9.Math.toDegrees(c.longitude),
|
|
6618
|
+
Cesium$9.Math.toDegrees(c.latitude)
|
|
6432
6619
|
];
|
|
6433
6620
|
}
|
|
6434
6621
|
}
|
|
@@ -6436,11 +6623,11 @@ class SelectTool extends BaseTool {
|
|
|
6436
6623
|
}
|
|
6437
6624
|
|
|
6438
6625
|
_getEntityPositions(entity) {
|
|
6439
|
-
if (Cesium$
|
|
6440
|
-
return entity.polyline.positions.getValue(Cesium$
|
|
6626
|
+
if (Cesium$9.defined(entity.polyline) && Cesium$9.defined(entity.polyline.positions)) {
|
|
6627
|
+
return entity.polyline.positions.getValue(Cesium$9.JulianDate.now());
|
|
6441
6628
|
}
|
|
6442
|
-
if (Cesium$
|
|
6443
|
-
const hierarchy = entity.polygon.hierarchy.getValue(Cesium$
|
|
6629
|
+
if (Cesium$9.defined(entity.polygon) && Cesium$9.defined(entity.polygon.hierarchy)) {
|
|
6630
|
+
const hierarchy = entity.polygon.hierarchy.getValue(Cesium$9.JulianDate.now());
|
|
6444
6631
|
return hierarchy ? hierarchy.positions : [];
|
|
6445
6632
|
}
|
|
6446
6633
|
return [];
|
|
@@ -6505,7 +6692,7 @@ class SelectTool extends BaseTool {
|
|
|
6505
6692
|
}
|
|
6506
6693
|
}
|
|
6507
6694
|
|
|
6508
|
-
const Cesium$
|
|
6695
|
+
const Cesium$8 = getCesium();
|
|
6509
6696
|
|
|
6510
6697
|
/**
|
|
6511
6698
|
* 删除模式枚举
|
|
@@ -6556,7 +6743,7 @@ class DeleteTool extends BaseTool {
|
|
|
6556
6743
|
|
|
6557
6744
|
const picked = this._viewer.scene.pick(screenPos);
|
|
6558
6745
|
|
|
6559
|
-
if (Cesium$
|
|
6746
|
+
if (Cesium$8.defined(picked) && Cesium$8.defined(picked.id)) {
|
|
6560
6747
|
const entityId = picked.id.id;
|
|
6561
6748
|
|
|
6562
6749
|
// 忽略临时图元
|
|
@@ -6580,7 +6767,7 @@ class DeleteTool extends BaseTool {
|
|
|
6580
6767
|
|
|
6581
6768
|
let hoveredId = null;
|
|
6582
6769
|
|
|
6583
|
-
if (Cesium$
|
|
6770
|
+
if (Cesium$8.defined(picked) && Cesium$8.defined(picked.id)) {
|
|
6584
6771
|
const entityId = picked.id.id;
|
|
6585
6772
|
if (!entityId.startsWith('__temp_') && !entityId.startsWith('__edit_handle_')) {
|
|
6586
6773
|
hoveredId = entityId;
|
|
@@ -6660,7 +6847,7 @@ class DeleteTool extends BaseTool {
|
|
|
6660
6847
|
const styleKey = entityId;
|
|
6661
6848
|
|
|
6662
6849
|
// 红色高亮表示可删除,先保存原始样式
|
|
6663
|
-
if (Cesium$
|
|
6850
|
+
if (Cesium$8.defined(entity.point)) {
|
|
6664
6851
|
if (!this._originalStyles.has(styleKey)) {
|
|
6665
6852
|
this._originalStyles.set(styleKey, {
|
|
6666
6853
|
point: {
|
|
@@ -6669,11 +6856,11 @@ class DeleteTool extends BaseTool {
|
|
|
6669
6856
|
}
|
|
6670
6857
|
});
|
|
6671
6858
|
}
|
|
6672
|
-
entity.point.outlineColor = Cesium$
|
|
6859
|
+
entity.point.outlineColor = Cesium$8.Color.RED;
|
|
6673
6860
|
entity.point.outlineWidth = 3;
|
|
6674
6861
|
}
|
|
6675
6862
|
|
|
6676
|
-
if (Cesium$
|
|
6863
|
+
if (Cesium$8.defined(entity.polyline)) {
|
|
6677
6864
|
if (!this._originalStyles.has(styleKey)) {
|
|
6678
6865
|
this._originalStyles.set(styleKey, {
|
|
6679
6866
|
polyline: {
|
|
@@ -6681,10 +6868,10 @@ class DeleteTool extends BaseTool {
|
|
|
6681
6868
|
}
|
|
6682
6869
|
});
|
|
6683
6870
|
}
|
|
6684
|
-
entity.polyline.material = Cesium$
|
|
6871
|
+
entity.polyline.material = Cesium$8.Color.RED;
|
|
6685
6872
|
}
|
|
6686
6873
|
|
|
6687
|
-
if (Cesium$
|
|
6874
|
+
if (Cesium$8.defined(entity.polygon)) {
|
|
6688
6875
|
if (!this._originalStyles.has(styleKey)) {
|
|
6689
6876
|
this._originalStyles.set(styleKey, {
|
|
6690
6877
|
polygon: {
|
|
@@ -6692,7 +6879,7 @@ class DeleteTool extends BaseTool {
|
|
|
6692
6879
|
}
|
|
6693
6880
|
});
|
|
6694
6881
|
}
|
|
6695
|
-
entity.polygon.outlineColor = Cesium$
|
|
6882
|
+
entity.polygon.outlineColor = Cesium$8.Color.RED;
|
|
6696
6883
|
}
|
|
6697
6884
|
|
|
6698
6885
|
// 更改鼠标样式
|
|
@@ -6709,22 +6896,22 @@ class DeleteTool extends BaseTool {
|
|
|
6709
6896
|
const original = styleKey ? this._originalStyles.get(styleKey) : null;
|
|
6710
6897
|
|
|
6711
6898
|
// 恢复原始样式
|
|
6712
|
-
if (Cesium$
|
|
6899
|
+
if (Cesium$8.defined(entity.point)) {
|
|
6713
6900
|
if (original?.point) {
|
|
6714
6901
|
entity.point.outlineColor = original.point.outlineColor;
|
|
6715
6902
|
entity.point.outlineWidth = original.point.outlineWidth;
|
|
6716
6903
|
} else {
|
|
6717
|
-
entity.point.outlineColor = Cesium$
|
|
6904
|
+
entity.point.outlineColor = Cesium$8.Color.WHITE;
|
|
6718
6905
|
entity.point.outlineWidth = 1;
|
|
6719
6906
|
}
|
|
6720
6907
|
}
|
|
6721
6908
|
|
|
6722
|
-
if (Cesium$
|
|
6723
|
-
entity.polyline.material = original?.polyline?.material || Cesium$
|
|
6909
|
+
if (Cesium$8.defined(entity.polyline)) {
|
|
6910
|
+
entity.polyline.material = original?.polyline?.material || Cesium$8.Color.BLUE;
|
|
6724
6911
|
}
|
|
6725
6912
|
|
|
6726
|
-
if (Cesium$
|
|
6727
|
-
entity.polygon.outlineColor = original?.polygon?.outlineColor || Cesium$
|
|
6913
|
+
if (Cesium$8.defined(entity.polygon)) {
|
|
6914
|
+
entity.polygon.outlineColor = original?.polygon?.outlineColor || Cesium$8.Color.WHITE;
|
|
6728
6915
|
}
|
|
6729
6916
|
|
|
6730
6917
|
// 恢复鼠标样式
|
|
@@ -6758,70 +6945,681 @@ class DeleteTool extends BaseTool {
|
|
|
6758
6945
|
}
|
|
6759
6946
|
}
|
|
6760
6947
|
|
|
6948
|
+
const Cesium$7 = getCesium();
|
|
6949
|
+
|
|
6950
|
+
/**
|
|
6951
|
+
* 地理计算工具(距离、面积、高程)
|
|
6952
|
+
*/
|
|
6953
|
+
class GeoCalcUtil {
|
|
6954
|
+
/**
|
|
6955
|
+
* 计算两点地理坐标距离(米)
|
|
6956
|
+
* @param {Array<number>} point1 [lng, lat, height]
|
|
6957
|
+
* @param {Array<number>} point2 [lng, lat, height]
|
|
6958
|
+
* @returns {number} 距离
|
|
6959
|
+
*/
|
|
6960
|
+
static calcDistance(point1, point2) {
|
|
6961
|
+
const coord1 = Cesium$7.Cartesian3.fromDegrees(...point1);
|
|
6962
|
+
const coord2 = Cesium$7.Cartesian3.fromDegrees(...point2);
|
|
6963
|
+
return Cesium$7.Cartesian3.distance(coord1, coord2);
|
|
6964
|
+
}
|
|
6965
|
+
|
|
6966
|
+
/**
|
|
6967
|
+
* 计算多边形面积(平方米)
|
|
6968
|
+
* 使用球面多边形面积公式(基于 Cesium 几何顶点)
|
|
6969
|
+
* @param {Array<Array<number>>} points 地理坐标点集 [lon, lat, height?]
|
|
6970
|
+
* @returns {number} 面积
|
|
6971
|
+
*/
|
|
6972
|
+
static calcArea(points) {
|
|
6973
|
+
if (!points || points.length < 3) return 0;
|
|
6974
|
+
|
|
6975
|
+
const positions = points.map(p => Cesium$7.Cartesian3.fromDegrees(p[0], p[1], p[2] || 0));
|
|
6976
|
+
const polygon = new Cesium$7.PolygonGeometry({
|
|
6977
|
+
polygonHierarchy: new Cesium$7.PolygonHierarchy(positions)
|
|
6978
|
+
});
|
|
6979
|
+
const geometry = Cesium$7.PolygonGeometry.createGeometry(polygon);
|
|
6980
|
+
|
|
6981
|
+
if (!geometry || !geometry.attributes || !geometry.attributes.position) {
|
|
6982
|
+
return 0;
|
|
6983
|
+
}
|
|
6984
|
+
|
|
6985
|
+
const values = geometry.attributes.position.values;
|
|
6986
|
+
const vertexPositions = [];
|
|
6987
|
+
for (let i = 0; i < values.length; i += 3) {
|
|
6988
|
+
vertexPositions.push(new Cesium$7.Cartesian3(values[i], values[i + 1], values[i + 2]));
|
|
6989
|
+
}
|
|
6990
|
+
|
|
6991
|
+
// 球面多边形面积(基于单位球上的多边形面积公式)
|
|
6992
|
+
const area = GeoCalcUtil.#sphericalPolygonArea(vertexPositions);
|
|
6993
|
+
return Math.abs(area);
|
|
6994
|
+
}
|
|
6995
|
+
|
|
6996
|
+
/**
|
|
6997
|
+
* 单位球面上多边形的有向面积(平方米)
|
|
6998
|
+
* 采用局部切平面投影法:以多边形重心为原点建立切平面,投影后计算二维多边形面积。
|
|
6999
|
+
* 对于常规 GIS 多边形精度足够;极大规模多边形可后续替换为更严格的球面 excess 算法。
|
|
7000
|
+
* @param {Cesium.Cartesian3[]} positions 世界坐标顶点
|
|
7001
|
+
* @returns {number} 面积(平方米)
|
|
7002
|
+
*/
|
|
7003
|
+
static #sphericalPolygonArea(positions) {
|
|
7004
|
+
const ellipsoid = Cesium$7.Ellipsoid.WGS84;
|
|
7005
|
+
const n = positions.length;
|
|
7006
|
+
if (n < 3) return 0;
|
|
7007
|
+
|
|
7008
|
+
// 计算近似重心(归一化到椭球面)
|
|
7009
|
+
let center = new Cesium$7.Cartesian3(0, 0, 0);
|
|
7010
|
+
for (const p of positions) {
|
|
7011
|
+
center = Cesium$7.Cartesian3.add(center, p, center);
|
|
7012
|
+
}
|
|
7013
|
+
center = Cesium$7.Cartesian3.normalize(center, new Cesium$7.Cartesian3());
|
|
7014
|
+
center = ellipsoid.scaleToGeodeticSurface(center, new Cesium$7.Cartesian3()) || center;
|
|
7015
|
+
|
|
7016
|
+
// 在重心处建立东北天(ENU)局部坐标系
|
|
7017
|
+
const tangentPlane = new Cesium$7.EllipsoidTangentPlane(center, ellipsoid);
|
|
7018
|
+
|
|
7019
|
+
// 投影到切平面
|
|
7020
|
+
const projected = positions.map(p => tangentPlane.projectPointOntoPlane(p, new Cesium$7.Cartesian2()));
|
|
7021
|
+
|
|
7022
|
+
// 计算二维多边形面积(Shoelace 公式)
|
|
7023
|
+
let area2 = 0;
|
|
7024
|
+
for (let i = 0; i < n; i++) {
|
|
7025
|
+
const p1 = projected[i];
|
|
7026
|
+
const p2 = projected[(i + 1) % n];
|
|
7027
|
+
area2 += p1.x * p2.y - p2.x * p1.y;
|
|
7028
|
+
}
|
|
7029
|
+
|
|
7030
|
+
return Math.abs(area2) * 0.5;
|
|
7031
|
+
}
|
|
7032
|
+
|
|
7033
|
+
/**
|
|
7034
|
+
* 获取指定地理坐标的高程
|
|
7035
|
+
* @param {Cesium.Viewer} viewer Cesium 实例
|
|
7036
|
+
* @param {Array<number>} coord [lng, lat]
|
|
7037
|
+
* @returns {Promise<number>} 高程值
|
|
7038
|
+
*/
|
|
7039
|
+
static async getHeight(viewer, coord) {
|
|
7040
|
+
const cartographic = Cesium$7.Cartographic.fromDegrees(coord[0], coord[1]);
|
|
7041
|
+
const results = await Cesium$7.sampleTerrainMostDetailed(viewer.terrainProvider, [cartographic]);
|
|
7042
|
+
return results[0]?.height ?? 0;
|
|
7043
|
+
}
|
|
7044
|
+
}
|
|
7045
|
+
|
|
7046
|
+
const Cesium$6 = getCesium();
|
|
7047
|
+
|
|
6761
7048
|
/**
|
|
6762
|
-
*
|
|
7049
|
+
* 测量类型枚举
|
|
6763
7050
|
*/
|
|
6764
|
-
const
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
SELECT: 'select',
|
|
6768
|
-
DELETE: 'delete'
|
|
7051
|
+
const MeasureType = {
|
|
7052
|
+
DISTANCE: 'distance',
|
|
7053
|
+
AREA: 'area'
|
|
6769
7054
|
};
|
|
6770
7055
|
|
|
6771
7056
|
/**
|
|
6772
|
-
*
|
|
6773
|
-
*
|
|
7057
|
+
* 测量工具
|
|
7058
|
+
* 支持交互式测距(折线)和测面积(多边形)。
|
|
7059
|
+
* 左键加点,右键 / Enter 完成,Esc 取消,Backspace 撤销上一点。
|
|
6774
7060
|
*/
|
|
6775
|
-
class
|
|
6776
|
-
constructor(
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
this.
|
|
6780
|
-
this.
|
|
6781
|
-
this.
|
|
6782
|
-
this.
|
|
6783
|
-
this.
|
|
6784
|
-
|
|
7061
|
+
class MeasureTool extends BaseTool {
|
|
7062
|
+
constructor(editorModule, options = {}) {
|
|
7063
|
+
super(editorModule, options);
|
|
7064
|
+
|
|
7065
|
+
this._measureType = options.measureType || MeasureType.DISTANCE;
|
|
7066
|
+
this._positions = []; // 已点击的经纬度点
|
|
7067
|
+
this._mousePos = null; // 当前鼠标位置(经纬度)
|
|
7068
|
+
this._isMeasuring = false; // 是否正在一次测量中
|
|
7069
|
+
this._lastResult = null; // 最后一次测量结果
|
|
7070
|
+
|
|
7071
|
+
// 临时图元引用
|
|
7072
|
+
this._pointEntities = []; // 点击点标记
|
|
7073
|
+
this._previewLine = null; // 测距预览线
|
|
7074
|
+
this._previewPolygon = null; // 测面积预览面
|
|
7075
|
+
this._previewOutline = null; // 测面积预览轮廓线
|
|
7076
|
+
this._previewCartesians = []; // 当前预览几何的笛卡尔坐标数组(CallbackProperty 共享引用)
|
|
7077
|
+
this._segmentLabelEntities = []; // 测距每段标注
|
|
7078
|
+
this._totalLabelEntity = null; // 总距离 / 面积标注
|
|
7079
|
+
|
|
7080
|
+
// 已完成的测量结果图元分组,支持一次激活中保留多个测量结果
|
|
7081
|
+
this._finishedResults = [];
|
|
6785
7082
|
}
|
|
6786
7083
|
|
|
6787
7084
|
/**
|
|
6788
|
-
*
|
|
6789
|
-
* @param {
|
|
7085
|
+
* 设置测量类型
|
|
7086
|
+
* @param {string} type MeasureType
|
|
6790
7087
|
*/
|
|
6791
|
-
|
|
6792
|
-
this.
|
|
6793
|
-
this.eventModule = deps.eventModule;
|
|
7088
|
+
setMeasureType(type) {
|
|
7089
|
+
this._measureType = type;
|
|
6794
7090
|
return this;
|
|
6795
7091
|
}
|
|
6796
7092
|
|
|
6797
7093
|
/**
|
|
6798
|
-
*
|
|
7094
|
+
* 获取当前测量类型
|
|
6799
7095
|
*/
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
this.registerTool(ToolName.DRAW, new DrawTool(this));
|
|
6803
|
-
this.registerTool(ToolName.EDIT, new EditTool(this));
|
|
6804
|
-
this.registerTool(ToolName.SELECT, new SelectTool(this));
|
|
6805
|
-
this.registerTool(ToolName.DELETE, new DeleteTool(this));
|
|
6806
|
-
|
|
6807
|
-
return this;
|
|
7096
|
+
getMeasureType() {
|
|
7097
|
+
return this._measureType;
|
|
6808
7098
|
}
|
|
6809
7099
|
|
|
6810
7100
|
/**
|
|
6811
|
-
*
|
|
6812
|
-
* @param {string} name 工具名称
|
|
6813
|
-
* @param {BaseTool} tool 工具实例
|
|
6814
|
-
* @returns {EditorModule}
|
|
7101
|
+
* 获取最后一次测量结果
|
|
6815
7102
|
*/
|
|
6816
|
-
|
|
6817
|
-
this.
|
|
6818
|
-
return this;
|
|
7103
|
+
getLastResult() {
|
|
7104
|
+
return this._lastResult;
|
|
6819
7105
|
}
|
|
6820
7106
|
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
|
|
7107
|
+
onActivate() {
|
|
7108
|
+
this.registerObserver('mouse:click', this._onClick.bind(this));
|
|
7109
|
+
this.registerObserver('mouse:move', this._onMove.bind(this));
|
|
7110
|
+
this.registerObserver('mouse:rightclick', this._onRightClick.bind(this));
|
|
7111
|
+
this.registerObserver('keyboard:keydown', this._onKeyDown.bind(this));
|
|
7112
|
+
}
|
|
7113
|
+
|
|
7114
|
+
onDeactivate() {
|
|
7115
|
+
this.clearMeasurements();
|
|
7116
|
+
}
|
|
7117
|
+
|
|
7118
|
+
_onClick(lngLat) {
|
|
7119
|
+
if (!lngLat) return;
|
|
7120
|
+
|
|
7121
|
+
this._isMeasuring = true;
|
|
7122
|
+
this._positions.push(lngLat);
|
|
7123
|
+
this._addPointMarker(lngLat);
|
|
7124
|
+
this._updateMeasurement();
|
|
7125
|
+
}
|
|
7126
|
+
|
|
7127
|
+
_onMove(data) {
|
|
7128
|
+
const screenPos = data.position || data.endPosition;
|
|
7129
|
+
if (!screenPos) return;
|
|
7130
|
+
|
|
7131
|
+
const lonLat = this.screenToLonLat({ x: screenPos.x, y: screenPos.y });
|
|
7132
|
+
if (!lonLat) return;
|
|
7133
|
+
|
|
7134
|
+
this._mousePos = lonLat;
|
|
7135
|
+
if (this._isMeasuring) {
|
|
7136
|
+
this._updateMeasurement();
|
|
7137
|
+
}
|
|
7138
|
+
}
|
|
7139
|
+
|
|
7140
|
+
_onRightClick() {
|
|
7141
|
+
this._finishMeasurement();
|
|
7142
|
+
}
|
|
7143
|
+
|
|
7144
|
+
_onKeyDown(data) {
|
|
7145
|
+
if (data.key === 'Escape') {
|
|
7146
|
+
this.cancelMeasurement();
|
|
7147
|
+
return;
|
|
7148
|
+
}
|
|
7149
|
+
|
|
7150
|
+
if (data.key === 'Enter') {
|
|
7151
|
+
this._finishMeasurement();
|
|
7152
|
+
return;
|
|
7153
|
+
}
|
|
7154
|
+
|
|
7155
|
+
if (data.key === 'Backspace' && this._isMeasuring && this._positions.length > 0) {
|
|
7156
|
+
this._positions.pop();
|
|
7157
|
+
const lastPoint = this._pointEntities.pop();
|
|
7158
|
+
if (lastPoint) {
|
|
7159
|
+
this.removeTempEntity(lastPoint);
|
|
7160
|
+
}
|
|
7161
|
+
this._updateMeasurement();
|
|
7162
|
+
}
|
|
7163
|
+
}
|
|
7164
|
+
|
|
7165
|
+
/**
|
|
7166
|
+
* 完成当前测量
|
|
7167
|
+
*/
|
|
7168
|
+
_finishMeasurement() {
|
|
7169
|
+
const minPoints = this._measureType === MeasureType.AREA ? 3 : 2;
|
|
7170
|
+
if (this._positions.length < minPoints) return;
|
|
7171
|
+
|
|
7172
|
+
this._isMeasuring = false;
|
|
7173
|
+
this._mousePos = null;
|
|
7174
|
+
this._updateMeasurement();
|
|
7175
|
+
|
|
7176
|
+
const result = this._computeResult(this._positions);
|
|
7177
|
+
this._lastResult = result;
|
|
7178
|
+
|
|
7179
|
+
// 将当前测量结果保留在场景中,并清空工作态以便继续下一次测量
|
|
7180
|
+
this._commitCurrentResult();
|
|
7181
|
+
|
|
7182
|
+
this._emitMeasureComplete(result);
|
|
7183
|
+
}
|
|
7184
|
+
|
|
7185
|
+
/**
|
|
7186
|
+
* 把当前测量图元归档为已完成结果,重置工作态
|
|
7187
|
+
*/
|
|
7188
|
+
_commitCurrentResult() {
|
|
7189
|
+
const finalCartesians = this._previewCartesians.slice();
|
|
7190
|
+
|
|
7191
|
+
// 将动态 CallbackProperty 替换为常量几何,避免归档后随 _previewCartesians 变化而消失
|
|
7192
|
+
if (this._previewLine) {
|
|
7193
|
+
this._previewLine.polyline.positions = finalCartesians.length > 0 ? finalCartesians : [];
|
|
7194
|
+
}
|
|
7195
|
+
if (this._previewPolygon) {
|
|
7196
|
+
this._previewPolygon.polygon.hierarchy = finalCartesians.length >= 3
|
|
7197
|
+
? new Cesium$6.PolygonHierarchy(finalCartesians)
|
|
7198
|
+
: new Cesium$6.PolygonHierarchy([]);
|
|
7199
|
+
}
|
|
7200
|
+
if (this._previewOutline) {
|
|
7201
|
+
this._previewOutline.polyline.positions = finalCartesians.length >= 3
|
|
7202
|
+
? [...finalCartesians, finalCartesians[0]]
|
|
7203
|
+
: [];
|
|
7204
|
+
}
|
|
7205
|
+
|
|
7206
|
+
this._finishedResults.push({
|
|
7207
|
+
pointEntities: this._pointEntities,
|
|
7208
|
+
segmentLabels: this._segmentLabelEntities,
|
|
7209
|
+
totalLabel: this._totalLabelEntity,
|
|
7210
|
+
previewLine: this._previewLine,
|
|
7211
|
+
previewPolygon: this._previewPolygon,
|
|
7212
|
+
previewOutline: this._previewOutline
|
|
7213
|
+
});
|
|
7214
|
+
|
|
7215
|
+
this._positions = [];
|
|
7216
|
+
this._mousePos = null;
|
|
7217
|
+
this._isMeasuring = false;
|
|
7218
|
+
this._previewCartesians = [];
|
|
7219
|
+
|
|
7220
|
+
this._pointEntities = [];
|
|
7221
|
+
this._segmentLabelEntities = [];
|
|
7222
|
+
this._totalLabelEntity = null;
|
|
7223
|
+
this._previewLine = null;
|
|
7224
|
+
this._previewPolygon = null;
|
|
7225
|
+
this._previewOutline = null;
|
|
7226
|
+
}
|
|
7227
|
+
|
|
7228
|
+
/**
|
|
7229
|
+
* 取消当前测量
|
|
7230
|
+
*/
|
|
7231
|
+
cancelMeasurement() {
|
|
7232
|
+
this.clearMeasurements();
|
|
7233
|
+
this._emitMeasureCancel();
|
|
7234
|
+
}
|
|
7235
|
+
|
|
7236
|
+
/**
|
|
7237
|
+
* 清空所有测量结果与临时图元
|
|
7238
|
+
*/
|
|
7239
|
+
clearMeasurements() {
|
|
7240
|
+
this._positions = [];
|
|
7241
|
+
this._mousePos = null;
|
|
7242
|
+
this._isMeasuring = false;
|
|
7243
|
+
this._lastResult = null;
|
|
7244
|
+
this._previewCartesians = [];
|
|
7245
|
+
|
|
7246
|
+
this._pointEntities.forEach(e => this.removeTempEntity(e));
|
|
7247
|
+
this._pointEntities = [];
|
|
7248
|
+
|
|
7249
|
+
this._segmentLabelEntities.forEach(e => this.removeTempEntity(e));
|
|
7250
|
+
this._segmentLabelEntities = [];
|
|
7251
|
+
|
|
7252
|
+
if (this._totalLabelEntity) {
|
|
7253
|
+
this.removeTempEntity(this._totalLabelEntity);
|
|
7254
|
+
this._totalLabelEntity = null;
|
|
7255
|
+
}
|
|
7256
|
+
|
|
7257
|
+
if (this._previewLine) {
|
|
7258
|
+
this.removeTempEntity(this._previewLine);
|
|
7259
|
+
this._previewLine = null;
|
|
7260
|
+
}
|
|
7261
|
+
|
|
7262
|
+
if (this._previewPolygon) {
|
|
7263
|
+
this.removeTempEntity(this._previewPolygon);
|
|
7264
|
+
this._previewPolygon = null;
|
|
7265
|
+
}
|
|
7266
|
+
|
|
7267
|
+
if (this._previewOutline) {
|
|
7268
|
+
this.removeTempEntity(this._previewOutline);
|
|
7269
|
+
this._previewOutline = null;
|
|
7270
|
+
}
|
|
7271
|
+
|
|
7272
|
+
this._finishedResults.forEach(group => {
|
|
7273
|
+
group.pointEntities.forEach(e => this.removeTempEntity(e));
|
|
7274
|
+
group.segmentLabels.forEach(e => this.removeTempEntity(e));
|
|
7275
|
+
if (group.totalLabel) this.removeTempEntity(group.totalLabel);
|
|
7276
|
+
if (group.previewLine) this.removeTempEntity(group.previewLine);
|
|
7277
|
+
if (group.previewPolygon) this.removeTempEntity(group.previewPolygon);
|
|
7278
|
+
if (group.previewOutline) this.removeTempEntity(group.previewOutline);
|
|
7279
|
+
});
|
|
7280
|
+
this._finishedResults = [];
|
|
7281
|
+
}
|
|
7282
|
+
|
|
7283
|
+
/**
|
|
7284
|
+
* 更新预览几何与标注
|
|
7285
|
+
*/
|
|
7286
|
+
_updateMeasurement() {
|
|
7287
|
+
if (this._positions.length === 0) return;
|
|
7288
|
+
|
|
7289
|
+
const positions = [...this._positions];
|
|
7290
|
+
if (this._isMeasuring && this._mousePos) {
|
|
7291
|
+
positions.push(this._mousePos);
|
|
7292
|
+
}
|
|
7293
|
+
|
|
7294
|
+
if (this._measureType === MeasureType.DISTANCE) {
|
|
7295
|
+
this._updateDistancePreview(positions);
|
|
7296
|
+
} else {
|
|
7297
|
+
this._updateAreaPreview(positions);
|
|
7298
|
+
}
|
|
7299
|
+
|
|
7300
|
+
if (this._isMeasuring) {
|
|
7301
|
+
this._emitMeasureProgress(this._computeResult(positions));
|
|
7302
|
+
}
|
|
7303
|
+
}
|
|
7304
|
+
|
|
7305
|
+
_updateDistancePreview(positions) {
|
|
7306
|
+
const cartesians = positions.length >= 2
|
|
7307
|
+
? positions.map(p => Cesium$6.Cartesian3.fromDegrees(...p))
|
|
7308
|
+
: [];
|
|
7309
|
+
this._previewCartesians = cartesians;
|
|
7310
|
+
|
|
7311
|
+
// 预览线
|
|
7312
|
+
if (!this._previewLine) {
|
|
7313
|
+
this._previewLine = this.createTempEntity(this.generateId('measure_line'), {
|
|
7314
|
+
polyline: {
|
|
7315
|
+
positions: new Cesium$6.CallbackProperty(() => this._previewCartesians, false),
|
|
7316
|
+
material: Cesium$6.Color.YELLOW,
|
|
7317
|
+
width: 2,
|
|
7318
|
+
clampToGround: true
|
|
7319
|
+
}
|
|
7320
|
+
});
|
|
7321
|
+
}
|
|
7322
|
+
this._previewLine.show = cartesians.length >= 2;
|
|
7323
|
+
|
|
7324
|
+
// 每段标注
|
|
7325
|
+
const segmentCount = Math.max(0, positions.length - 1);
|
|
7326
|
+
this._ensureSegmentLabels(segmentCount);
|
|
7327
|
+
|
|
7328
|
+
let total = 0;
|
|
7329
|
+
for (let i = 0; i < segmentCount; i++) {
|
|
7330
|
+
const p1 = positions[i];
|
|
7331
|
+
const p2 = positions[i + 1];
|
|
7332
|
+
const dist = GeoCalcUtil.calcDistance(p1, p2);
|
|
7333
|
+
total += dist;
|
|
7334
|
+
|
|
7335
|
+
const mid = Cesium$6.Cartesian3.midpoint(
|
|
7336
|
+
Cesium$6.Cartesian3.fromDegrees(...p1),
|
|
7337
|
+
Cesium$6.Cartesian3.fromDegrees(...p2),
|
|
7338
|
+
new Cesium$6.Cartesian3()
|
|
7339
|
+
);
|
|
7340
|
+
|
|
7341
|
+
const label = this._segmentLabelEntities[i];
|
|
7342
|
+
label.position = mid;
|
|
7343
|
+
label.label.text = this._formatDistance(dist).text;
|
|
7344
|
+
label.show = true;
|
|
7345
|
+
}
|
|
7346
|
+
|
|
7347
|
+
// 总距离标注
|
|
7348
|
+
const lastCartesian = cartesians[cartesians.length - 1];
|
|
7349
|
+
if (positions.length >= 2) {
|
|
7350
|
+
if (!this._totalLabelEntity) {
|
|
7351
|
+
this._totalLabelEntity = this._createLabelEntity(
|
|
7352
|
+
this.generateId('measure_total'),
|
|
7353
|
+
lastCartesian,
|
|
7354
|
+
`总长:${this._formatDistance(total).text}`
|
|
7355
|
+
);
|
|
7356
|
+
} else {
|
|
7357
|
+
this._totalLabelEntity.position = lastCartesian;
|
|
7358
|
+
this._totalLabelEntity.label.text = `总长:${this._formatDistance(total).text}`;
|
|
7359
|
+
this._totalLabelEntity.show = true;
|
|
7360
|
+
}
|
|
7361
|
+
} else if (this._totalLabelEntity) {
|
|
7362
|
+
this._totalLabelEntity.show = false;
|
|
7363
|
+
}
|
|
7364
|
+
}
|
|
7365
|
+
|
|
7366
|
+
_updateAreaPreview(positions) {
|
|
7367
|
+
const cartesians = positions.map(p => Cesium$6.Cartesian3.fromDegrees(...p));
|
|
7368
|
+
this._previewCartesians = cartesians;
|
|
7369
|
+
|
|
7370
|
+
if (positions.length >= 3) {
|
|
7371
|
+
// 显示面 + 闭合轮廓
|
|
7372
|
+
if (!this._previewPolygon) {
|
|
7373
|
+
this._previewPolygon = this.createTempEntity(this.generateId('measure_polygon'), {
|
|
7374
|
+
polygon: {
|
|
7375
|
+
hierarchy: new Cesium$6.CallbackProperty(() => new Cesium$6.PolygonHierarchy(this._previewCartesians), false),
|
|
7376
|
+
material: Cesium$6.Color.YELLOW.withAlpha(0.2),
|
|
7377
|
+
outline: false
|
|
7378
|
+
}
|
|
7379
|
+
});
|
|
7380
|
+
this._previewOutline = this.createTempEntity(this.generateId('measure_outline'), {
|
|
7381
|
+
polyline: {
|
|
7382
|
+
positions: new Cesium$6.CallbackProperty(() => this._previewCartesians.length > 0
|
|
7383
|
+
? [...this._previewCartesians, this._previewCartesians[0]]
|
|
7384
|
+
: [], false),
|
|
7385
|
+
material: Cesium$6.Color.YELLOW,
|
|
7386
|
+
width: 2,
|
|
7387
|
+
clampToGround: true
|
|
7388
|
+
}
|
|
7389
|
+
});
|
|
7390
|
+
}
|
|
7391
|
+
this._previewPolygon.show = true;
|
|
7392
|
+
this._previewOutline.show = true;
|
|
7393
|
+
if (this._previewLine) {
|
|
7394
|
+
this._previewLine.show = false;
|
|
7395
|
+
}
|
|
7396
|
+
|
|
7397
|
+
const area = GeoCalcUtil.calcArea(positions);
|
|
7398
|
+
const centroid = this._computeCentroid(cartesians);
|
|
7399
|
+
|
|
7400
|
+
if (!this._totalLabelEntity) {
|
|
7401
|
+
this._totalLabelEntity = this._createLabelEntity(
|
|
7402
|
+
this.generateId('measure_area'),
|
|
7403
|
+
centroid,
|
|
7404
|
+
`面积:${this._formatArea(area).text}`
|
|
7405
|
+
);
|
|
7406
|
+
} else {
|
|
7407
|
+
this._totalLabelEntity.position = centroid;
|
|
7408
|
+
this._totalLabelEntity.label.text = `面积:${this._formatArea(area).text}`;
|
|
7409
|
+
this._totalLabelEntity.show = true;
|
|
7410
|
+
}
|
|
7411
|
+
} else {
|
|
7412
|
+
// 不足 3 点时只显示连线,并隐藏已有的面、轮廓、面积标注
|
|
7413
|
+
if (this._previewPolygon) {
|
|
7414
|
+
this._previewPolygon.show = false;
|
|
7415
|
+
}
|
|
7416
|
+
if (this._previewOutline) {
|
|
7417
|
+
this._previewOutline.show = false;
|
|
7418
|
+
}
|
|
7419
|
+
if (this._totalLabelEntity) {
|
|
7420
|
+
this._totalLabelEntity.show = false;
|
|
7421
|
+
}
|
|
7422
|
+
|
|
7423
|
+
if (!this._previewLine) {
|
|
7424
|
+
this._previewLine = this.createTempEntity(this.generateId('measure_line'), {
|
|
7425
|
+
polyline: {
|
|
7426
|
+
positions: new Cesium$6.CallbackProperty(() => this._previewCartesians, false),
|
|
7427
|
+
material: Cesium$6.Color.YELLOW,
|
|
7428
|
+
width: 2,
|
|
7429
|
+
clampToGround: true
|
|
7430
|
+
}
|
|
7431
|
+
});
|
|
7432
|
+
}
|
|
7433
|
+
this._previewLine.show = positions.length >= 2;
|
|
7434
|
+
}
|
|
7435
|
+
}
|
|
7436
|
+
|
|
7437
|
+
_ensureSegmentLabels(count) {
|
|
7438
|
+
// 移除多余的标注
|
|
7439
|
+
while (this._segmentLabelEntities.length > count) {
|
|
7440
|
+
const label = this._segmentLabelEntities.pop();
|
|
7441
|
+
this.removeTempEntity(label);
|
|
7442
|
+
}
|
|
7443
|
+
|
|
7444
|
+
// 创建缺少的标注
|
|
7445
|
+
while (this._segmentLabelEntities.length < count) {
|
|
7446
|
+
const label = this._createLabelEntity(
|
|
7447
|
+
this.generateId('measure_segment'),
|
|
7448
|
+
Cesium$6.Cartesian3.ZERO,
|
|
7449
|
+
''
|
|
7450
|
+
);
|
|
7451
|
+
this._segmentLabelEntities.push(label);
|
|
7452
|
+
}
|
|
7453
|
+
}
|
|
7454
|
+
|
|
7455
|
+
_createLabelEntity(id, position, text) {
|
|
7456
|
+
return this.createTempEntity(id, {
|
|
7457
|
+
position,
|
|
7458
|
+
label: {
|
|
7459
|
+
text,
|
|
7460
|
+
font: '14px Microsoft YaHei',
|
|
7461
|
+
fillColor: Cesium$6.Color.WHITE,
|
|
7462
|
+
outlineColor: Cesium$6.Color.BLACK,
|
|
7463
|
+
outlineWidth: 2,
|
|
7464
|
+
style: Cesium$6.LabelStyle.FILL_AND_OUTLINE,
|
|
7465
|
+
verticalOrigin: Cesium$6.VerticalOrigin.BOTTOM,
|
|
7466
|
+
horizontalOrigin: Cesium$6.HorizontalOrigin.CENTER,
|
|
7467
|
+
heightReference: Cesium$6.HeightReference.CLAMP_TO_GROUND,
|
|
7468
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
7469
|
+
pixelOffset: new Cesium$6.Cartesian2(0, -10)
|
|
7470
|
+
}
|
|
7471
|
+
});
|
|
7472
|
+
}
|
|
7473
|
+
|
|
7474
|
+
_addPointMarker(lonLat) {
|
|
7475
|
+
const point = this.createTempEntity(this.generateId('measure_point'), {
|
|
7476
|
+
position: Cesium$6.Cartesian3.fromDegrees(...lonLat),
|
|
7477
|
+
point: {
|
|
7478
|
+
color: Cesium$6.Color.YELLOW,
|
|
7479
|
+
pixelSize: 8,
|
|
7480
|
+
outlineColor: Cesium$6.Color.BLACK,
|
|
7481
|
+
outlineWidth: 1,
|
|
7482
|
+
heightReference: Cesium$6.HeightReference.CLAMP_TO_GROUND,
|
|
7483
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
7484
|
+
}
|
|
7485
|
+
});
|
|
7486
|
+
this._pointEntities.push(point);
|
|
7487
|
+
}
|
|
7488
|
+
|
|
7489
|
+
_computeResult(positions) {
|
|
7490
|
+
if (this._measureType === MeasureType.DISTANCE) {
|
|
7491
|
+
let total = 0;
|
|
7492
|
+
for (let i = 0; i < positions.length - 1; i++) {
|
|
7493
|
+
total += GeoCalcUtil.calcDistance(positions[i], positions[i + 1]);
|
|
7494
|
+
}
|
|
7495
|
+
const fmt = this._formatDistance(total);
|
|
7496
|
+
return {
|
|
7497
|
+
type: MeasureType.DISTANCE,
|
|
7498
|
+
value: total,
|
|
7499
|
+
unit: fmt.unit,
|
|
7500
|
+
formatted: fmt.text,
|
|
7501
|
+
positions: positions.slice()
|
|
7502
|
+
};
|
|
7503
|
+
}
|
|
7504
|
+
|
|
7505
|
+
const area = GeoCalcUtil.calcArea(positions);
|
|
7506
|
+
const fmt = this._formatArea(area);
|
|
7507
|
+
return {
|
|
7508
|
+
type: MeasureType.AREA,
|
|
7509
|
+
value: area,
|
|
7510
|
+
unit: fmt.unit,
|
|
7511
|
+
formatted: fmt.text,
|
|
7512
|
+
positions: positions.slice()
|
|
7513
|
+
};
|
|
7514
|
+
}
|
|
7515
|
+
|
|
7516
|
+
_computeCentroid(cartesians) {
|
|
7517
|
+
const center = new Cesium$6.Cartesian3(0, 0, 0);
|
|
7518
|
+
for (const c of cartesians) {
|
|
7519
|
+
Cesium$6.Cartesian3.add(center, c, center);
|
|
7520
|
+
}
|
|
7521
|
+
return Cesium$6.Cartesian3.multiplyByScalar(center, 1 / cartesians.length, center);
|
|
7522
|
+
}
|
|
7523
|
+
|
|
7524
|
+
_formatDistance(meters) {
|
|
7525
|
+
if (meters >= 1000) {
|
|
7526
|
+
return { text: `${(meters / 1000).toFixed(2)} km`, unit: 'km' };
|
|
7527
|
+
}
|
|
7528
|
+
return { text: `${meters.toFixed(2)} m`, unit: 'm' };
|
|
7529
|
+
}
|
|
7530
|
+
|
|
7531
|
+
_formatArea(squareMeters) {
|
|
7532
|
+
if (squareMeters >= 1000000) {
|
|
7533
|
+
return { text: `${(squareMeters / 1000000).toFixed(3)} km²`, unit: 'km²' };
|
|
7534
|
+
}
|
|
7535
|
+
return { text: `${squareMeters.toFixed(2)} m²`, unit: 'm²' };
|
|
7536
|
+
}
|
|
7537
|
+
|
|
7538
|
+
_emitMeasureProgress(result) {
|
|
7539
|
+
if (this._options.onMeasureProgress) {
|
|
7540
|
+
this._options.onMeasureProgress(result);
|
|
7541
|
+
}
|
|
7542
|
+
}
|
|
7543
|
+
|
|
7544
|
+
_emitMeasureComplete(result) {
|
|
7545
|
+
if (this._options.onMeasureComplete) {
|
|
7546
|
+
this._options.onMeasureComplete(result);
|
|
7547
|
+
}
|
|
7548
|
+
}
|
|
7549
|
+
|
|
7550
|
+
_emitMeasureCancel() {
|
|
7551
|
+
if (this._options.onMeasureCancel) {
|
|
7552
|
+
this._options.onMeasureCancel();
|
|
7553
|
+
}
|
|
7554
|
+
}
|
|
7555
|
+
}
|
|
7556
|
+
|
|
7557
|
+
/**
|
|
7558
|
+
* 工具名称枚举
|
|
7559
|
+
*/
|
|
7560
|
+
const ToolName = {
|
|
7561
|
+
DRAW: 'draw',
|
|
7562
|
+
EDIT: 'edit',
|
|
7563
|
+
SELECT: 'select',
|
|
7564
|
+
DELETE: 'delete',
|
|
7565
|
+
MEASURE: 'measure'
|
|
7566
|
+
};
|
|
7567
|
+
|
|
7568
|
+
/**
|
|
7569
|
+
* 编辑器模块
|
|
7570
|
+
* 负责工具的注册、切换、激活管理
|
|
7571
|
+
*/
|
|
7572
|
+
class EditorModule {
|
|
7573
|
+
constructor(viewer, options = {}) {
|
|
7574
|
+
this.viewer = viewer;
|
|
7575
|
+
this.config = Config.getInstance().getConfig();
|
|
7576
|
+
this.graphicModule = null; // 依赖注入
|
|
7577
|
+
this.eventModule = null; // 依赖注入
|
|
7578
|
+
this.toolMap = new Map(); // 工具缓存
|
|
7579
|
+
this.currentTool = null; // 当前激活的工具
|
|
7580
|
+
this.currentToolName = null;
|
|
7581
|
+
this._isActive = false;
|
|
7582
|
+
}
|
|
7583
|
+
|
|
7584
|
+
/**
|
|
7585
|
+
* 设置依赖模块
|
|
7586
|
+
* @param {object} deps 依赖模块 { graphicModule, eventModule }
|
|
7587
|
+
*/
|
|
7588
|
+
setDependencies(deps) {
|
|
7589
|
+
this.graphicModule = deps.graphicModule;
|
|
7590
|
+
this.eventModule = deps.eventModule;
|
|
7591
|
+
return this;
|
|
7592
|
+
}
|
|
7593
|
+
|
|
7594
|
+
/**
|
|
7595
|
+
* 初始化编辑器,注册所有内置工具
|
|
7596
|
+
*/
|
|
7597
|
+
init() {
|
|
7598
|
+
// 注册内置工具
|
|
7599
|
+
this.registerTool(ToolName.DRAW, new DrawTool(this));
|
|
7600
|
+
this.registerTool(ToolName.EDIT, new EditTool(this));
|
|
7601
|
+
this.registerTool(ToolName.SELECT, new SelectTool(this));
|
|
7602
|
+
this.registerTool(ToolName.DELETE, new DeleteTool(this));
|
|
7603
|
+
this.registerTool(ToolName.MEASURE, new MeasureTool(this));
|
|
7604
|
+
|
|
7605
|
+
return this;
|
|
7606
|
+
}
|
|
7607
|
+
|
|
7608
|
+
/**
|
|
7609
|
+
* 注册工具
|
|
7610
|
+
* @param {string} name 工具名称
|
|
7611
|
+
* @param {BaseTool} tool 工具实例
|
|
7612
|
+
* @returns {EditorModule}
|
|
7613
|
+
*/
|
|
7614
|
+
registerTool(name, tool) {
|
|
7615
|
+
this.toolMap.set(name, tool);
|
|
7616
|
+
return this;
|
|
7617
|
+
}
|
|
7618
|
+
|
|
7619
|
+
/**
|
|
7620
|
+
* 获取工具
|
|
7621
|
+
* @param {string} name 工具名称
|
|
7622
|
+
* @returns {BaseTool|undefined}
|
|
6825
7623
|
*/
|
|
6826
7624
|
getTool(name) {
|
|
6827
7625
|
return this.toolMap.get(name);
|
|
@@ -6937,6 +7735,39 @@ class EditorModule {
|
|
|
6937
7735
|
return this.activateTool(ToolName.DELETE);
|
|
6938
7736
|
}
|
|
6939
7737
|
|
|
7738
|
+
/**
|
|
7739
|
+
* 激活测量工具并设置类型
|
|
7740
|
+
* @param {string} type 测量类型 MeasureType
|
|
7741
|
+
* @returns {EditorModule}
|
|
7742
|
+
*/
|
|
7743
|
+
activateMeasureTool(type = MeasureType.DISTANCE) {
|
|
7744
|
+
const measureTool = this.toolMap.get(ToolName.MEASURE);
|
|
7745
|
+
if (!measureTool) {
|
|
7746
|
+
return this;
|
|
7747
|
+
}
|
|
7748
|
+
|
|
7749
|
+
// 已经处于测量工具时:不要 deactivate(避免清空历史结果),
|
|
7750
|
+
// 直接切换类型并把正在进行的测量提交为已完成结果。
|
|
7751
|
+
if (this.currentToolName === ToolName.MEASURE) {
|
|
7752
|
+
measureTool.setMeasureType(type);
|
|
7753
|
+
if (measureTool._isMeasuring) {
|
|
7754
|
+
measureTool._finishMeasurement();
|
|
7755
|
+
}
|
|
7756
|
+
return this;
|
|
7757
|
+
}
|
|
7758
|
+
|
|
7759
|
+
measureTool.setMeasureType(type);
|
|
7760
|
+
return this.activateTool(ToolName.MEASURE);
|
|
7761
|
+
}
|
|
7762
|
+
|
|
7763
|
+
/**
|
|
7764
|
+
* 获取测量工具(快捷方法)
|
|
7765
|
+
* @returns {MeasureTool}
|
|
7766
|
+
*/
|
|
7767
|
+
getMeasureTool() {
|
|
7768
|
+
return this.toolMap.get(ToolName.MEASURE);
|
|
7769
|
+
}
|
|
7770
|
+
|
|
6940
7771
|
/**
|
|
6941
7772
|
* 获取绘制工具(快捷方法)
|
|
6942
7773
|
* @returns {DrawTool}
|
|
@@ -7043,6 +7874,33 @@ class EditorModule {
|
|
|
7043
7874
|
return this;
|
|
7044
7875
|
}
|
|
7045
7876
|
|
|
7877
|
+
/**
|
|
7878
|
+
* 设置测量进度回调
|
|
7879
|
+
* @param {Function} callback
|
|
7880
|
+
*/
|
|
7881
|
+
onMeasureProgress(callback) {
|
|
7882
|
+
this.getMeasureTool()._options.onMeasureProgress = callback;
|
|
7883
|
+
return this;
|
|
7884
|
+
}
|
|
7885
|
+
|
|
7886
|
+
/**
|
|
7887
|
+
* 设置测量完成回调
|
|
7888
|
+
* @param {Function} callback
|
|
7889
|
+
*/
|
|
7890
|
+
onMeasureComplete(callback) {
|
|
7891
|
+
this.getMeasureTool()._options.onMeasureComplete = callback;
|
|
7892
|
+
return this;
|
|
7893
|
+
}
|
|
7894
|
+
|
|
7895
|
+
/**
|
|
7896
|
+
* 设置测量取消回调
|
|
7897
|
+
* @param {Function} callback
|
|
7898
|
+
*/
|
|
7899
|
+
onMeasureCancel(callback) {
|
|
7900
|
+
this.getMeasureTool()._options.onMeasureCancel = callback;
|
|
7901
|
+
return this;
|
|
7902
|
+
}
|
|
7903
|
+
|
|
7046
7904
|
/**
|
|
7047
7905
|
* 设置删除前回调
|
|
7048
7906
|
* @param {Function} callback
|
|
@@ -7382,7 +8240,7 @@ class BaseControl {
|
|
|
7382
8240
|
_destroy() { }
|
|
7383
8241
|
}
|
|
7384
8242
|
|
|
7385
|
-
const Cesium$
|
|
8243
|
+
const Cesium$5 = getCesium();
|
|
7386
8244
|
|
|
7387
8245
|
/**
|
|
7388
8246
|
* 状态栏控件
|
|
@@ -7462,7 +8320,7 @@ class LocationBar extends BaseControl {
|
|
|
7462
8320
|
const rect = this._viewer.scene.canvas.getBoundingClientRect();
|
|
7463
8321
|
const x = e.clientX - rect.left;
|
|
7464
8322
|
const y = e.clientY - rect.top;
|
|
7465
|
-
const screenPos = new Cesium$
|
|
8323
|
+
const screenPos = new Cesium$5.Cartesian2(x, y);
|
|
7466
8324
|
|
|
7467
8325
|
let cartesian = null;
|
|
7468
8326
|
|
|
@@ -7478,10 +8336,10 @@ class LocationBar extends BaseControl {
|
|
|
7478
8336
|
}
|
|
7479
8337
|
|
|
7480
8338
|
if (cartesian) {
|
|
7481
|
-
const cartographic = Cesium$
|
|
8339
|
+
const cartographic = Cesium$5.Cartographic.fromCartesian(cartesian);
|
|
7482
8340
|
this._lastMouseData = {
|
|
7483
|
-
lng: Cesium$
|
|
7484
|
-
lat: Cesium$
|
|
8341
|
+
lng: Cesium$5.Math.toDegrees(cartographic.longitude).toFixed(this._lngDecimal),
|
|
8342
|
+
lat: Cesium$5.Math.toDegrees(cartographic.latitude).toFixed(this._latDecimal),
|
|
7485
8343
|
alt: cartographic.height.toFixed(2)
|
|
7486
8344
|
};
|
|
7487
8345
|
} else {
|
|
@@ -7501,8 +8359,8 @@ class LocationBar extends BaseControl {
|
|
|
7501
8359
|
const positionCartographic = camera.positionCartographic;
|
|
7502
8360
|
|
|
7503
8361
|
this._lastCameraData = {
|
|
7504
|
-
heading: Cesium$
|
|
7505
|
-
pitch: Cesium$
|
|
8362
|
+
heading: Cesium$5.Math.toDegrees(camera.heading).toFixed(2),
|
|
8363
|
+
pitch: Cesium$5.Math.toDegrees(camera.pitch).toFixed(2),
|
|
7506
8364
|
cameraHeight: positionCartographic.height.toFixed(2),
|
|
7507
8365
|
level: this._getZoomLevel().toFixed(0)
|
|
7508
8366
|
};
|
|
@@ -7528,12 +8386,12 @@ class LocationBar extends BaseControl {
|
|
|
7528
8386
|
const positionCartographic = camera.positionCartographic;
|
|
7529
8387
|
|
|
7530
8388
|
// 计算相机到正下方地表点的距离(视高),而不是到自己位置的距离
|
|
7531
|
-
const surfaceCartesian = Cesium$
|
|
8389
|
+
const surfaceCartesian = Cesium$5.Cartesian3.fromRadians(
|
|
7532
8390
|
positionCartographic.longitude,
|
|
7533
8391
|
positionCartographic.latitude,
|
|
7534
8392
|
0
|
|
7535
8393
|
);
|
|
7536
|
-
const distance = Cesium$
|
|
8394
|
+
const distance = Cesium$5.Cartesian3.distance(camera.position, surfaceCartesian);
|
|
7537
8395
|
|
|
7538
8396
|
if (!distance || distance <= 0 || !Number.isFinite(distance)) return 0;
|
|
7539
8397
|
|
|
@@ -7565,136 +8423,140 @@ class LocationBar extends BaseControl {
|
|
|
7565
8423
|
}
|
|
7566
8424
|
}
|
|
7567
8425
|
|
|
7568
|
-
const Cesium$
|
|
7569
|
-
|
|
7570
|
-
/**
|
|
7571
|
-
* 缩放控件
|
|
7572
|
-
* 提供放大/缩小两个按钮,默认挂到 SDK 统一工具栏(xs3d-viewer-toolbar)。
|
|
7573
|
-
*/
|
|
7574
|
-
class Zoom extends BaseControl {
|
|
7575
|
-
/**
|
|
7576
|
-
* @param {object} options
|
|
7577
|
-
* @param {number} [options.duration=0.5] 缩放动画时长(秒)
|
|
7578
|
-
*/
|
|
7579
|
-
constructor(options = {}) {
|
|
7580
|
-
super({
|
|
7581
|
-
type: 'zoom',
|
|
7582
|
-
...options
|
|
7583
|
-
});
|
|
7584
|
-
|
|
7585
|
-
this._duration = options.duration ?? 0.5;
|
|
7586
|
-
}
|
|
7587
|
-
|
|
7588
|
-
_createContainer() {
|
|
7589
|
-
const div = super._createContainer();
|
|
7590
|
-
div.className += ' xs3d-zoom';
|
|
7591
|
-
|
|
7592
|
-
|
|
7593
|
-
|
|
7594
|
-
|
|
7595
|
-
|
|
7596
|
-
|
|
7597
|
-
|
|
7598
|
-
|
|
7599
|
-
|
|
7600
|
-
|
|
7601
|
-
|
|
7602
|
-
|
|
7603
|
-
this.
|
|
7604
|
-
|
|
7605
|
-
|
|
7606
|
-
|
|
7607
|
-
|
|
7608
|
-
|
|
7609
|
-
this.
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
|
|
7613
|
-
|
|
7614
|
-
|
|
7615
|
-
|
|
7616
|
-
|
|
7617
|
-
btn
|
|
7618
|
-
btn.
|
|
7619
|
-
btn.
|
|
7620
|
-
btn.
|
|
7621
|
-
btn.
|
|
7622
|
-
btn.style.
|
|
7623
|
-
btn.style.
|
|
7624
|
-
btn.style.
|
|
7625
|
-
btn.style.
|
|
7626
|
-
btn.style.
|
|
7627
|
-
|
|
7628
|
-
btn.style.
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
|
|
7642
|
-
|
|
7643
|
-
|
|
7644
|
-
|
|
7645
|
-
|
|
7646
|
-
}
|
|
7647
|
-
|
|
7648
|
-
|
|
7649
|
-
this._zoomBy(
|
|
7650
|
-
}
|
|
7651
|
-
|
|
7652
|
-
|
|
7653
|
-
|
|
7654
|
-
|
|
7655
|
-
|
|
7656
|
-
|
|
7657
|
-
|
|
7658
|
-
|
|
7659
|
-
|
|
7660
|
-
|
|
7661
|
-
const
|
|
7662
|
-
|
|
7663
|
-
|
|
7664
|
-
|
|
7665
|
-
|
|
7666
|
-
|
|
7667
|
-
|
|
7668
|
-
|
|
7669
|
-
|
|
7670
|
-
|
|
7671
|
-
|
|
7672
|
-
|
|
7673
|
-
|
|
7674
|
-
|
|
7675
|
-
|
|
7676
|
-
|
|
7677
|
-
|
|
7678
|
-
|
|
7679
|
-
|
|
7680
|
-
|
|
7681
|
-
|
|
7682
|
-
|
|
7683
|
-
|
|
7684
|
-
|
|
7685
|
-
|
|
7686
|
-
|
|
7687
|
-
|
|
7688
|
-
|
|
7689
|
-
|
|
7690
|
-
|
|
7691
|
-
|
|
7692
|
-
|
|
7693
|
-
|
|
7694
|
-
|
|
8426
|
+
const Cesium$4 = getCesium();
|
|
8427
|
+
|
|
8428
|
+
/**
|
|
8429
|
+
* 缩放控件
|
|
8430
|
+
* 提供放大/缩小两个按钮,默认挂到 SDK 统一工具栏(xs3d-viewer-toolbar)。
|
|
8431
|
+
*/
|
|
8432
|
+
class Zoom extends BaseControl {
|
|
8433
|
+
/**
|
|
8434
|
+
* @param {object} options
|
|
8435
|
+
* @param {number} [options.duration=0.5] 缩放动画时长(秒)
|
|
8436
|
+
*/
|
|
8437
|
+
constructor(options = {}) {
|
|
8438
|
+
super({
|
|
8439
|
+
type: 'zoom',
|
|
8440
|
+
...options
|
|
8441
|
+
});
|
|
8442
|
+
|
|
8443
|
+
this._duration = options.duration ?? 0.5;
|
|
8444
|
+
}
|
|
8445
|
+
|
|
8446
|
+
_createContainer() {
|
|
8447
|
+
const div = super._createContainer();
|
|
8448
|
+
div.className += ' xs3d-zoom';
|
|
8449
|
+
// 只有在统一工具栏内才使用 display: contents,让按钮直接参与工具栏 flex 布局;
|
|
8450
|
+
// 自定义容器挂载时保留正常 absolute 定位,支持 top/left/right/bottom。
|
|
8451
|
+
if (this._parentContainer?.classList?.contains('xs3d-viewer-toolbar')) {
|
|
8452
|
+
div.style.display = 'contents';
|
|
8453
|
+
}
|
|
8454
|
+
return div;
|
|
8455
|
+
}
|
|
8456
|
+
|
|
8457
|
+
_getParentContainer() {
|
|
8458
|
+
if (this._options.container) {
|
|
8459
|
+
return super._getParentContainer();
|
|
8460
|
+
}
|
|
8461
|
+
return this._getOrCreateToolbar();
|
|
8462
|
+
}
|
|
8463
|
+
|
|
8464
|
+
_mount() {
|
|
8465
|
+
this._clearAbsolutePositionIfInToolbar();
|
|
8466
|
+
|
|
8467
|
+
this._zoomInBtn = this._createButton('+', '放大');
|
|
8468
|
+
this._zoomOutBtn = this._createButton('-', '缩小');
|
|
8469
|
+
|
|
8470
|
+
this._container.appendChild(this._zoomInBtn);
|
|
8471
|
+
this._container.appendChild(this._zoomOutBtn);
|
|
8472
|
+
}
|
|
8473
|
+
|
|
8474
|
+
_createButton(label, title) {
|
|
8475
|
+
const btn = document.createElement('button');
|
|
8476
|
+
btn.type = 'button';
|
|
8477
|
+
btn.title = title;
|
|
8478
|
+
btn.className = 'cesium-button cesium-toolbar-button xs3d-zoom-button';
|
|
8479
|
+
btn.textContent = label;
|
|
8480
|
+
btn.style.width = '32px';
|
|
8481
|
+
btn.style.height = '32px';
|
|
8482
|
+
btn.style.lineHeight = '1';
|
|
8483
|
+
btn.style.fontSize = '18px';
|
|
8484
|
+
btn.style.fontWeight = 'bold';
|
|
8485
|
+
btn.style.display = 'flex';
|
|
8486
|
+
btn.style.alignItems = 'center';
|
|
8487
|
+
btn.style.justifyContent = 'center';
|
|
8488
|
+
btn.style.cursor = 'pointer';
|
|
8489
|
+
// 在统一工具栏内按 order 排列:指南针 -1,放大 1,缩小 2
|
|
8490
|
+
btn.style.order = label === '+' ? '1' : '2';
|
|
8491
|
+
return btn;
|
|
8492
|
+
}
|
|
8493
|
+
|
|
8494
|
+
_bindEvents() {
|
|
8495
|
+
this._addDomEvent(this._zoomInBtn, 'click', (e) => {
|
|
8496
|
+
e.stopPropagation();
|
|
8497
|
+
this._zoomIn();
|
|
8498
|
+
});
|
|
8499
|
+
|
|
8500
|
+
this._addDomEvent(this._zoomOutBtn, 'click', (e) => {
|
|
8501
|
+
e.stopPropagation();
|
|
8502
|
+
this._zoomOut();
|
|
8503
|
+
});
|
|
8504
|
+
}
|
|
8505
|
+
|
|
8506
|
+
_zoomIn() {
|
|
8507
|
+
this._zoomBy(1);
|
|
8508
|
+
}
|
|
8509
|
+
|
|
8510
|
+
_zoomOut() {
|
|
8511
|
+
this._zoomBy(-1);
|
|
8512
|
+
}
|
|
8513
|
+
|
|
8514
|
+
/**
|
|
8515
|
+
* 按地图层级步进缩放
|
|
8516
|
+
* @param {number} levelDelta 层级变化量,+1 放大一级,-1 缩小一级
|
|
8517
|
+
*/
|
|
8518
|
+
_zoomBy(levelDelta) {
|
|
8519
|
+
const camera = this._viewer.camera;
|
|
8520
|
+
const cartographic = camera.positionCartographic;
|
|
8521
|
+
const currentLevel = this._getZoomLevel();
|
|
8522
|
+
const targetLevel = Math.max(0, Math.min(24, currentLevel + levelDelta));
|
|
8523
|
+
const targetHeight = this._getHeightByZoomLevel(targetLevel);
|
|
8524
|
+
|
|
8525
|
+
camera.flyTo({
|
|
8526
|
+
destination: Cesium$4.Cartesian3.fromRadians(
|
|
8527
|
+
cartographic.longitude,
|
|
8528
|
+
cartographic.latitude,
|
|
8529
|
+
targetHeight
|
|
8530
|
+
),
|
|
8531
|
+
orientation: {
|
|
8532
|
+
heading: camera.heading,
|
|
8533
|
+
pitch: camera.pitch,
|
|
8534
|
+
roll: camera.roll
|
|
8535
|
+
},
|
|
8536
|
+
duration: this._duration
|
|
8537
|
+
});
|
|
8538
|
+
}
|
|
8539
|
+
|
|
8540
|
+
_getZoomLevel() {
|
|
8541
|
+
const positionCartographic = this._viewer.camera.positionCartographic;
|
|
8542
|
+
const surfaceCartesian = Cesium$4.Cartesian3.fromRadians(
|
|
8543
|
+
positionCartographic.longitude,
|
|
8544
|
+
positionCartographic.latitude,
|
|
8545
|
+
0
|
|
8546
|
+
);
|
|
8547
|
+
const distance = Cesium$4.Cartesian3.distance(this._viewer.camera.position, surfaceCartesian);
|
|
8548
|
+
if (!distance || distance <= 0 || !Number.isFinite(distance)) return 0;
|
|
8549
|
+
const equatorCircumference = 6378137 * 2 * Math.PI;
|
|
8550
|
+
return Math.max(0, Math.floor(Math.log2(equatorCircumference / distance)) + 1);
|
|
8551
|
+
}
|
|
8552
|
+
|
|
8553
|
+
_getHeightByZoomLevel(level) {
|
|
8554
|
+
const equatorCircumference = 6378137 * 2 * Math.PI;
|
|
8555
|
+
return equatorCircumference / Math.pow(2, Math.max(0, level - 1));
|
|
8556
|
+
}
|
|
7695
8557
|
}
|
|
7696
8558
|
|
|
7697
|
-
const Cesium$
|
|
8559
|
+
const Cesium$3 = getCesium();
|
|
7698
8560
|
|
|
7699
8561
|
/**
|
|
7700
8562
|
* 指南针控件
|
|
@@ -7845,7 +8707,7 @@ class Compass extends BaseControl {
|
|
|
7845
8707
|
|
|
7846
8708
|
_updateRotation() {
|
|
7847
8709
|
if (!this._outerEl) return;
|
|
7848
|
-
const heading = Cesium$
|
|
8710
|
+
const heading = Cesium$3.Math.toDegrees(this._viewer.camera.heading);
|
|
7849
8711
|
this._outerEl.style.transform = `rotate(${-heading}deg)`;
|
|
7850
8712
|
}
|
|
7851
8713
|
|
|
@@ -7898,7 +8760,7 @@ class Compass extends BaseControl {
|
|
|
7898
8760
|
|
|
7899
8761
|
const camera = this._viewer.camera;
|
|
7900
8762
|
if (this._rotateFrame) {
|
|
7901
|
-
const oldTransform = Cesium$
|
|
8763
|
+
const oldTransform = Cesium$3.Matrix4.clone(camera.transform);
|
|
7902
8764
|
camera.lookAtTransform(this._rotateFrame);
|
|
7903
8765
|
camera.rotateRight(delta);
|
|
7904
8766
|
camera.lookAtTransform(oldTransform);
|
|
@@ -7940,10 +8802,10 @@ class Compass extends BaseControl {
|
|
|
7940
8802
|
if (this._mode !== 'orbit') return;
|
|
7941
8803
|
const deltaY = this._startY - e.clientY;
|
|
7942
8804
|
const sensitivity = 0.004;
|
|
7943
|
-
const newPitch = Cesium$
|
|
8805
|
+
const newPitch = Cesium$3.Math.clamp(
|
|
7944
8806
|
this._startPitch + deltaY * sensitivity,
|
|
7945
|
-
-Cesium$
|
|
7946
|
-
Cesium$
|
|
8807
|
+
-Cesium$3.Math.PI_OVER_TWO + 0.01,
|
|
8808
|
+
Cesium$3.Math.PI_OVER_TWO - 0.01
|
|
7947
8809
|
);
|
|
7948
8810
|
this._viewer.camera.setView({
|
|
7949
8811
|
destination: this._viewer.camera.position,
|
|
@@ -7967,26 +8829,26 @@ class Compass extends BaseControl {
|
|
|
7967
8829
|
_getRotateFrame() {
|
|
7968
8830
|
const scene = this._viewer.scene;
|
|
7969
8831
|
const camera = this._viewer.camera;
|
|
7970
|
-
if (scene.mode === Cesium$
|
|
8832
|
+
if (scene.mode === Cesium$3.SceneMode.MORPHING) return null;
|
|
7971
8833
|
|
|
7972
8834
|
let center;
|
|
7973
8835
|
if (this._viewer.trackedEntity) {
|
|
7974
8836
|
center = this._viewer.trackedEntity.position.getValue(this._viewer.clock.currentTime);
|
|
7975
8837
|
} else {
|
|
7976
|
-
const ray = new Cesium$
|
|
8838
|
+
const ray = new Cesium$3.Ray(camera.positionWC, camera.directionWC);
|
|
7977
8839
|
center = scene.globe.pick(ray, scene);
|
|
7978
8840
|
}
|
|
7979
8841
|
if (!center) {
|
|
7980
8842
|
center = camera.positionWC;
|
|
7981
8843
|
}
|
|
7982
|
-
return Cesium$
|
|
8844
|
+
return Cesium$3.Transforms.eastNorthUpToFixedFrame(center, scene.globe.ellipsoid);
|
|
7983
8845
|
}
|
|
7984
8846
|
|
|
7985
8847
|
_onDoubleClick() {
|
|
7986
8848
|
const camera = this._viewer.camera;
|
|
7987
8849
|
const cartographic = camera.positionCartographic;
|
|
7988
8850
|
camera.flyTo({
|
|
7989
|
-
destination: Cesium$
|
|
8851
|
+
destination: Cesium$3.Cartesian3.fromRadians(
|
|
7990
8852
|
cartographic.longitude,
|
|
7991
8853
|
cartographic.latitude,
|
|
7992
8854
|
cartographic.height
|
|
@@ -8007,7 +8869,7 @@ class Compass extends BaseControl {
|
|
|
8007
8869
|
}
|
|
8008
8870
|
}
|
|
8009
8871
|
|
|
8010
|
-
const Cesium$
|
|
8872
|
+
const Cesium$2 = getCesium();
|
|
8011
8873
|
|
|
8012
8874
|
/**
|
|
8013
8875
|
* 比例尺控件
|
|
@@ -8039,7 +8901,7 @@ class DistanceLegend extends BaseControl {
|
|
|
8039
8901
|
base.forEach(b => this._distances.push(b * factor));
|
|
8040
8902
|
}
|
|
8041
8903
|
|
|
8042
|
-
this._geodesic = new Cesium$
|
|
8904
|
+
this._geodesic = new Cesium$2.EllipsoidGeodesic();
|
|
8043
8905
|
this._lastUpdate = 0;
|
|
8044
8906
|
}
|
|
8045
8907
|
|
|
@@ -8097,8 +8959,8 @@ class DistanceLegend extends BaseControl {
|
|
|
8097
8959
|
const x = Math.floor(width / 2);
|
|
8098
8960
|
const y = Math.max(0, height - 1);
|
|
8099
8961
|
|
|
8100
|
-
const leftRay = camera.getPickRay(new Cesium$
|
|
8101
|
-
const rightRay = camera.getPickRay(new Cesium$
|
|
8962
|
+
const leftRay = camera.getPickRay(new Cesium$2.Cartesian2(x, y));
|
|
8963
|
+
const rightRay = camera.getPickRay(new Cesium$2.Cartesian2(x + 1, y));
|
|
8102
8964
|
if (!leftRay || !rightRay) return;
|
|
8103
8965
|
|
|
8104
8966
|
const leftPosition = scene.globe.pick(leftRay, scene);
|
|
@@ -8337,7 +9199,7 @@ class ControlModule {
|
|
|
8337
9199
|
* 统一管理场景、图元、事件模块的实例
|
|
8338
9200
|
*/
|
|
8339
9201
|
|
|
8340
|
-
const Cesium$
|
|
9202
|
+
const Cesium$1 = getCesium();
|
|
8341
9203
|
|
|
8342
9204
|
class ModuleManager {
|
|
8343
9205
|
static instance = null;
|
|
@@ -8362,13 +9224,19 @@ class ModuleManager {
|
|
|
8362
9224
|
if (this.cesiumViewer) return this.cesiumViewer;
|
|
8363
9225
|
const config = Config.getInstance().getConfig();
|
|
8364
9226
|
|
|
8365
|
-
this.cesiumViewer = new Cesium$
|
|
9227
|
+
this.cesiumViewer = new Cesium$1.Viewer(container, config.scene);
|
|
8366
9228
|
// 隐藏版权信息(可选,对齐平台界面规范)
|
|
8367
9229
|
const creditContainer = this.cesiumViewer.cesiumWidget?.creditContainer;
|
|
8368
9230
|
if (creditContainer) {
|
|
8369
9231
|
creditContainer.style.display = 'none';
|
|
8370
9232
|
}
|
|
8371
9233
|
|
|
9234
|
+
// 禁用画布默认右键菜单,保证 Cesium 右键事件可被正常处理
|
|
9235
|
+
const canvas = this.cesiumViewer.scene?.canvas;
|
|
9236
|
+
if (canvas) {
|
|
9237
|
+
canvas.addEventListener('contextmenu', (e) => e.preventDefault(), false);
|
|
9238
|
+
}
|
|
9239
|
+
|
|
8372
9240
|
// 初始化所有模块(注入 Viewer 实例)
|
|
8373
9241
|
this.registerModule('SceneModule', new SceneModule(this.cesiumViewer));
|
|
8374
9242
|
this.registerModule('GraphicModule', new GraphicModule(this.cesiumViewer));
|
|
@@ -8514,7 +9382,7 @@ class ModuleManager {
|
|
|
8514
9382
|
}
|
|
8515
9383
|
}
|
|
8516
9384
|
|
|
8517
|
-
const Cesium
|
|
9385
|
+
const Cesium = getCesium();
|
|
8518
9386
|
|
|
8519
9387
|
/**
|
|
8520
9388
|
* 坐标转换工具(对齐平台 屏幕/世界/地理坐标转换)
|
|
@@ -8534,12 +9402,12 @@ class CoordinateUtil {
|
|
|
8534
9402
|
if (Array.isArray(coord)) {
|
|
8535
9403
|
if (from === 'scene') {
|
|
8536
9404
|
// 地理坐标转世界坐标
|
|
8537
|
-
sourceCoord = Cesium
|
|
9405
|
+
sourceCoord = Cesium.Cartesian3.fromDegrees(...coord);
|
|
8538
9406
|
} else if (from === 'world') {
|
|
8539
|
-
sourceCoord = new Cesium
|
|
9407
|
+
sourceCoord = new Cesium.Cartesian3(coord[0], coord[1], coord[2]);
|
|
8540
9408
|
} else if (from === 'screen') {
|
|
8541
9409
|
// 屏幕坐标数组需先转为 Cartesian2
|
|
8542
|
-
sourceCoord = new Cesium
|
|
9410
|
+
sourceCoord = new Cesium.Cartesian2(coord[0], coord[1]);
|
|
8543
9411
|
}
|
|
8544
9412
|
}
|
|
8545
9413
|
|
|
@@ -8551,21 +9419,21 @@ class CoordinateUtil {
|
|
|
8551
9419
|
// 屏幕坐标 -> 地理坐标
|
|
8552
9420
|
case 'screen_scene':
|
|
8553
9421
|
const worldCoord = viewer.camera.pickEllipsoid(sourceCoord);
|
|
8554
|
-
const cartographic = Cesium
|
|
9422
|
+
const cartographic = Cesium.Cartographic.fromCartesian(worldCoord);
|
|
8555
9423
|
return [
|
|
8556
|
-
Cesium
|
|
8557
|
-
Cesium
|
|
9424
|
+
Cesium.Math.toDegrees(cartographic.longitude),
|
|
9425
|
+
Cesium.Math.toDegrees(cartographic.latitude),
|
|
8558
9426
|
cartographic.height
|
|
8559
9427
|
];
|
|
8560
9428
|
// 世界坐标 -> 屏幕坐标
|
|
8561
9429
|
case 'world_screen':
|
|
8562
|
-
return Cesium
|
|
9430
|
+
return Cesium.SceneTransforms.wgs84ToWindowCoordinates(viewer.scene, sourceCoord);
|
|
8563
9431
|
// 世界坐标 -> 地理坐标
|
|
8564
9432
|
case 'world_scene':
|
|
8565
|
-
const carto = Cesium
|
|
9433
|
+
const carto = Cesium.Cartographic.fromCartesian(sourceCoord);
|
|
8566
9434
|
return [
|
|
8567
|
-
Cesium
|
|
8568
|
-
Cesium
|
|
9435
|
+
Cesium.Math.toDegrees(carto.longitude),
|
|
9436
|
+
Cesium.Math.toDegrees(carto.latitude),
|
|
8569
9437
|
carto.height
|
|
8570
9438
|
];
|
|
8571
9439
|
// 地理坐标 -> 世界坐标(已在入参处理)
|
|
@@ -8573,111 +9441,13 @@ class CoordinateUtil {
|
|
|
8573
9441
|
return sourceCoord;
|
|
8574
9442
|
// 地理坐标 -> 屏幕坐标
|
|
8575
9443
|
case 'scene_screen':
|
|
8576
|
-
return Cesium
|
|
9444
|
+
return Cesium.SceneTransforms.wgs84ToWindowCoordinates(viewer.scene, sourceCoord);
|
|
8577
9445
|
default:
|
|
8578
9446
|
return sourceCoord;
|
|
8579
9447
|
}
|
|
8580
9448
|
}
|
|
8581
9449
|
}
|
|
8582
9450
|
|
|
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
9451
|
// src/index.js
|
|
8682
9452
|
|
|
8683
9453
|
// 核心 SDK 实例(直接导出,无嵌套)
|
|
@@ -8731,6 +9501,7 @@ const xs3d = {
|
|
|
8731
9501
|
SelectType,
|
|
8732
9502
|
DeleteMode,
|
|
8733
9503
|
ToolName,
|
|
9504
|
+
MeasureType,
|
|
8734
9505
|
LayerType,
|
|
8735
9506
|
PlotGraphicType
|
|
8736
9507
|
};
|