leiting-bim 2.1.52 → 2.1.55
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/leiting-bim.es.js +1 -25503
- package/leiting-bim.umd.js +8 -8
- package/leitingbim.css +1 -1
- package/package.json +1 -1
- package/plugins/cesium-core/dist/components/HtmlOverlayLabelPool.d.ts +152 -152
- package/plugins/cesium-core/dist/components/MarkerEvent.d.ts +38 -38
- package/plugins/cesium-core/dist/components/Material/MaterialManager.d.ts +49 -49
- package/plugins/cesium-core/dist/components/Material/help/PolylineFlowMaterialProperty.d.ts +10 -10
- package/plugins/cesium-core/dist/components/Material/help/dynamicImgMaterial.d.ts +16 -16
- package/plugins/cesium-core/dist/components/Material/index.d.ts +3 -3
- package/plugins/cesium-core/dist/components/TooltipManager.d.ts +11 -11
- package/plugins/cesium-core/dist/components/draw/DrawTool.d.ts +10 -10
- package/plugins/cesium-core/dist/components/draw/handlers/CircleDrawer.d.ts +16 -16
- package/plugins/cesium-core/dist/components/draw/handlers/LineDrawer.d.ts +14 -14
- package/plugins/cesium-core/dist/components/draw/handlers/PointDrawer.d.ts +12 -12
- package/plugins/cesium-core/dist/components/draw/handlers/PolygonDrawer.d.ts +14 -14
- package/plugins/cesium-core/dist/components/draw/handlers/RectangleDrawer.d.ts +13 -13
- package/plugins/cesium-core/dist/components/draw/types.d.ts +29 -29
- package/plugins/cesium-core/dist/components/entity/EntityLayer.d.ts +65 -65
- package/plugins/cesium-core/dist/components/gltf/GLTFManage.d.ts +141 -141
- package/plugins/cesium-core/dist/components/gltf/index.d.ts +1 -1
- package/plugins/cesium-core/dist/components/measurement/MeasurementTool.d.ts +34 -34
- package/plugins/cesium-core/dist/components/measurement/handlers/CoordinateMeasure.d.ts +16 -16
- package/plugins/cesium-core/dist/components/measurement/handlers/TerrainHeightMeasure.d.ts +18 -18
- package/plugins/cesium-core/dist/components/measurement/handlers/VerticalMeasure.d.ts +23 -23
- package/plugins/cesium-core/dist/components/measurement/index.d.ts +13 -13
- package/plugins/cesium-core/dist/components/measurement/types.d.ts +42 -42
- package/plugins/cesium-core/dist/components/primitive/PrimitiveManager.d.ts +50 -50
- package/plugins/cesium-core/dist/components/roaming/CameraRoamTool.d.ts +27 -27
- package/plugins/cesium-core/dist/components/roaming/PathRoamTool.d.ts +23 -23
- package/plugins/cesium-core/dist/components/roaming/index.d.ts +3 -3
- package/plugins/cesium-core/dist/components/roaming/types.d.ts +66 -66
- package/plugins/cesium-core/dist/components/utils/convertGeoJsonToEntityData.d.ts +1 -1
- package/plugins/cesium-core/dist/components/utils/uuid.d.ts +1 -1
- package/plugins/cesium-core/dist/index.d.ts +12 -12
- package/plugins/cesium-core/package.json +27 -27
- package/plugins/cesium-vue/dist/HtmlOverlayLabelPool-B1gUt-p1.js +339 -0
- package/plugins/cesium-vue/dist/HtmlOverlayLabelPool-B1gUt-p1.js.map +1 -0
- package/plugins/cesium-vue/dist/components/basic-audio.js.map +1 -1
- package/plugins/cesium-vue/dist/components/basic-video.js.map +1 -1
- package/plugins/cesium-vue/dist/components/card-carousel.js.map +1 -1
- package/plugins/cesium-vue/dist/components/card-content.js +1 -1
- package/plugins/cesium-vue/dist/components/card-content.js.map +1 -1
- package/plugins/cesium-vue/dist/components/card-page.js.map +1 -1
- package/plugins/cesium-vue/dist/components/carousel-img.js.map +1 -1
- package/plugins/cesium-vue/dist/components/echarts-pro.js +1 -1
- package/plugins/cesium-vue/dist/components/marker-bubble.js.map +1 -1
- package/plugins/cesium-vue/dist/components/marker-default.js.map +1 -1
- package/plugins/cesium-vue/dist/components/marker-html.js.map +1 -1
- package/plugins/cesium-vue/dist/components/marker-manage.js +1324 -457
- package/plugins/cesium-vue/dist/components/marker-manage.js.map +1 -1
- package/plugins/cesium-vue/dist/components/marker-text.js.map +1 -1
- package/plugins/cesium-vue/dist/components/measurement.js +2943 -116
- package/plugins/cesium-vue/dist/components/measurement.js.map +1 -1
- package/plugins/cesium-vue/dist/components/position-picker.js.map +1 -1
- package/plugins/cesium-vue/dist/index-CUs_hd1V.js.map +1 -1
- package/plugins/cesium-vue/dist/index-Kdqw0FJN.js +45856 -0
- package/plugins/cesium-vue/dist/index-Kdqw0FJN.js.map +1 -0
- package/plugins/cesium-vue/dist/index.js +1 -1
- package/plugins/cesium-vue/dist/index.js.map +1 -1
|
@@ -1,7 +1,2834 @@
|
|
|
1
|
-
import { p as
|
|
2
|
-
import { defineComponent as
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { p as Me, c as De, w as Te } from "../create-DynflqE1.js";
|
|
2
|
+
import { defineComponent as Se, ref as ae, inject as Oe, watch as Fe, onMounted as ke, onUnmounted as Re, openBlock as ce, createElementBlock as de, Fragment as pe, withDirectives as He, createElementVNode as K, normalizeClass as ee, unref as U, renderList as _e, createTextVNode as le, toDisplayString as Ne, vShow as ze } from "vue";
|
|
3
|
+
import { H as k, M as Be } from "../HtmlOverlayLabelPool-B1gUt-p1.js";
|
|
4
|
+
class me {
|
|
5
|
+
Cesium;
|
|
6
|
+
viewer;
|
|
7
|
+
handler = null;
|
|
8
|
+
positions = [];
|
|
9
|
+
tempPoints = [];
|
|
10
|
+
segmentEntities = [];
|
|
11
|
+
segmentLabelIds = [];
|
|
12
|
+
previewEntity = null;
|
|
13
|
+
previewGroundEntity = null;
|
|
14
|
+
hoverPos = null;
|
|
15
|
+
htmlLabelPool = null;
|
|
16
|
+
totalLabelId = null;
|
|
17
|
+
previewLabelId = null;
|
|
18
|
+
labelEntity = null;
|
|
19
|
+
firstHeight = null;
|
|
20
|
+
groundLineEntities = [];
|
|
21
|
+
previewPos = null;
|
|
22
|
+
previewGroundPos = null;
|
|
23
|
+
constructor(i, e) {
|
|
24
|
+
this.Cesium = i, this.viewer = e;
|
|
25
|
+
}
|
|
26
|
+
start(i) {
|
|
27
|
+
this.clear();
|
|
28
|
+
const e = this.Cesium, t = this.viewer;
|
|
29
|
+
if (!this.htmlLabelPool) {
|
|
30
|
+
const h = i.overlayContainerId || "html-label-container";
|
|
31
|
+
this.htmlLabelPool = new k(e, t, h), this.htmlLabelPool.registerTheme("measure-horizontal-total", {
|
|
32
|
+
createElement: (s, o) => {
|
|
33
|
+
s.innerHTML = String(o?.data?.text || ""), s.style.background = "rgba(0,0,0,0.6)", s.style.color = "#fff", s.style.font = "14px sans-serif", s.style.padding = "4px 6px", s.style.borderRadius = "4px", s.style.whiteSpace = "pre";
|
|
34
|
+
},
|
|
35
|
+
options: { offset: { x: 0, y: -10 } }
|
|
36
|
+
}), this.htmlLabelPool.registerTheme("measure-horizontal-seg", {
|
|
37
|
+
createElement: (s, o) => {
|
|
38
|
+
s.innerHTML = String(o?.data?.text || ""), s.style.background = "rgba(0,0,0,0.6)", s.style.color = "#fff", s.style.font = "14px sans-serif", s.style.padding = "4px 6px", s.style.borderRadius = "4px", s.style.whiteSpace = "pre";
|
|
39
|
+
},
|
|
40
|
+
options: { offset: { x: 0, y: -10 } }
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((h) => {
|
|
44
|
+
const s = t.scene.pickPosition(h.position);
|
|
45
|
+
if (!s) return;
|
|
46
|
+
const o = e.Cartographic.fromCartesian(s), d = e.Math.toDegrees(o.longitude), n = e.Math.toDegrees(o.latitude);
|
|
47
|
+
this.positions.length === 0 && (this.firstHeight = o.height || 0);
|
|
48
|
+
const r = e.Cartesian3.fromDegrees(d, n, this.firstHeight || 0);
|
|
49
|
+
this.positions.push(r);
|
|
50
|
+
const c = t.entities.add({
|
|
51
|
+
position: r,
|
|
52
|
+
point: {
|
|
53
|
+
pixelSize: 8,
|
|
54
|
+
color: i.pointColor || i.color || e.Color.YELLOW,
|
|
55
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
this.tempPoints.push(c);
|
|
59
|
+
const p = t.scene.globe.getHeight(new e.Cartographic(o.longitude, o.latitude, 0)) || 0, m = e.Cartesian3.fromDegrees(d, n, p), g = (i.dashLineColor || i.lineColor || i.color || e.Color.RED).withAlpha?.(0.9) || e.Color.RED, l = t.entities.add({
|
|
60
|
+
polyline: {
|
|
61
|
+
positions: [m, r],
|
|
62
|
+
width: i.width || 3,
|
|
63
|
+
material: new e.PolylineDashMaterialProperty({
|
|
64
|
+
color: g,
|
|
65
|
+
dashLength: 12,
|
|
66
|
+
dashPattern: 255
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
if (this.groundLineEntities.push(l), this.positions.length >= 2) {
|
|
71
|
+
const a = this.positions[this.positions.length - 2], w = this.positions[this.positions.length - 1], u = e.Cartographic.fromCartesian(a), C = e.Cartographic.fromCartesian(w), L = t.entities.add({
|
|
72
|
+
polyline: {
|
|
73
|
+
positions: [a, w],
|
|
74
|
+
width: i.width || 3,
|
|
75
|
+
material: i.lineColor || i.color || e.Color.YELLOW,
|
|
76
|
+
depthFailMaterial: new e.PolylineDashMaterialProperty({
|
|
77
|
+
color: (i.dashLineColor || i.lineColor || i.color || e.Color.RED).withAlpha?.(0.9) || e.Color.RED,
|
|
78
|
+
dashLength: 12,
|
|
79
|
+
dashPattern: 255
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
this.segmentEntities.push(L);
|
|
84
|
+
const b = new e.EllipsoidGeodesic(u, C).surfaceDistance, y = new e.Cartesian3(
|
|
85
|
+
(a.x + w.x) / 2,
|
|
86
|
+
(a.y + w.y) / 2,
|
|
87
|
+
(a.z + w.z) / 2
|
|
88
|
+
), v = e.Cartographic.fromCartesian(y), E = `measure_horizontal_seg_${this.segmentLabelIds.length}_${Date.now()}`;
|
|
89
|
+
this.segmentLabelIds.push(E), this.htmlLabelPool.add(
|
|
90
|
+
{ text: `${b.toFixed(2)} m` },
|
|
91
|
+
{
|
|
92
|
+
id: E,
|
|
93
|
+
lon: e.Math.toDegrees(v.longitude),
|
|
94
|
+
lat: e.Math.toDegrees(v.latitude),
|
|
95
|
+
height: v.height || this.firstHeight || 0,
|
|
96
|
+
theme: "measure-horizontal-seg",
|
|
97
|
+
show: !0
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
}, e.ScreenSpaceEventType.LEFT_CLICK), this.handler.setInputAction(() => {
|
|
102
|
+
if (this.positions.length < 2) {
|
|
103
|
+
this.stop();
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
this.stop(), this.previewLabelId && (this.htmlLabelPool.removeByIds([this.previewLabelId]), this.previewLabelId = null), this.hoverPos && (this.hoverPos = null), this.previewEntity && (this.viewer.entities.remove(this.previewEntity), this.previewEntity = null), this.previewGroundEntity && (this.viewer.entities.remove(this.previewGroundEntity), this.previewGroundEntity = null);
|
|
107
|
+
let h = 0;
|
|
108
|
+
for (let r = 1; r < this.positions.length; r++) {
|
|
109
|
+
const c = this.positions[r - 1], p = this.positions[r], m = e.Cartographic.fromCartesian(c), g = e.Cartographic.fromCartesian(p), l = new e.EllipsoidGeodesic(m, g);
|
|
110
|
+
h += l.surfaceDistance;
|
|
111
|
+
}
|
|
112
|
+
const s = this.positions[this.positions.length - 1], o = e.Cartographic.fromCartesian(s), d = this.totalLabelId || `measure_horizontal_total_${Date.now()}`;
|
|
113
|
+
this.totalLabelId = d, this.htmlLabelPool.add(
|
|
114
|
+
{ text: `${h.toFixed(2)} m` },
|
|
115
|
+
{
|
|
116
|
+
id: d,
|
|
117
|
+
lon: e.Math.toDegrees(o.longitude),
|
|
118
|
+
lat: e.Math.toDegrees(o.latitude),
|
|
119
|
+
height: o.height || this.firstHeight || 0,
|
|
120
|
+
theme: "measure-horizontal-total",
|
|
121
|
+
show: !0
|
|
122
|
+
}
|
|
123
|
+
), this.labelEntity = this.totalLabelId;
|
|
124
|
+
const n = {
|
|
125
|
+
entity: this.segmentEntities,
|
|
126
|
+
label: this.labelEntity,
|
|
127
|
+
segmentLabels: this.segmentLabelIds,
|
|
128
|
+
positions: this.positions,
|
|
129
|
+
distance: h,
|
|
130
|
+
clear: () => this.clear()
|
|
131
|
+
};
|
|
132
|
+
i.onComplete?.(n);
|
|
133
|
+
}, e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK), this.handler.setInputAction((h) => {
|
|
134
|
+
if (this.positions.length === 0) return;
|
|
135
|
+
const s = t.scene.pickPosition(h.endPosition);
|
|
136
|
+
if (!s) return;
|
|
137
|
+
this.hoverPos = s;
|
|
138
|
+
const o = e.Cartographic.fromCartesian(s), d = e.Math.toDegrees(o.longitude), n = e.Math.toDegrees(o.latitude), r = e.Cartesian3.fromDegrees(d, n, this.firstHeight || 0);
|
|
139
|
+
this.previewPos = r;
|
|
140
|
+
const c = t.scene.globe.getHeight(new e.Cartographic(o.longitude, o.latitude, 0)) || 0, p = e.Cartesian3.fromDegrees(d, n, c);
|
|
141
|
+
this.previewGroundPos = p;
|
|
142
|
+
const m = this.positions[this.positions.length - 1], g = e.Cartographic.fromCartesian(m), l = e.Cartographic.fromCartesian(r), w = new e.EllipsoidGeodesic(g, l).surfaceDistance, u = new e.Cartesian3(
|
|
143
|
+
(m.x + r.x) / 2,
|
|
144
|
+
(m.y + r.y) / 2,
|
|
145
|
+
(m.z + r.z) / 2
|
|
146
|
+
), C = e.Cartographic.fromCartesian(u), L = this.previewLabelId || "measure_horizontal_preview";
|
|
147
|
+
this.previewLabelId = L, this.htmlLabelPool.add(
|
|
148
|
+
{ text: `${w.toFixed(2)} m` },
|
|
149
|
+
{
|
|
150
|
+
id: L,
|
|
151
|
+
lon: e.Math.toDegrees(C.longitude),
|
|
152
|
+
lat: e.Math.toDegrees(C.latitude),
|
|
153
|
+
height: C.height || this.firstHeight || 0,
|
|
154
|
+
theme: "measure-horizontal-seg",
|
|
155
|
+
show: !0
|
|
156
|
+
}
|
|
157
|
+
);
|
|
158
|
+
const f = (i.dashLineColor || i.lineColor || i.color || e.Color.RED).withAlpha?.(0.9) || e.Color.RED;
|
|
159
|
+
this.previewGroundEntity || (this.previewGroundEntity = t.entities.add({
|
|
160
|
+
polyline: {
|
|
161
|
+
positions: new e.CallbackProperty(() => !this.previewPos || !this.previewGroundPos ? [] : [this.previewGroundPos, this.previewPos], !1),
|
|
162
|
+
width: i.width || 3,
|
|
163
|
+
material: new e.PolylineDashMaterialProperty({
|
|
164
|
+
color: f,
|
|
165
|
+
dashLength: 12,
|
|
166
|
+
dashPattern: 255
|
|
167
|
+
})
|
|
168
|
+
}
|
|
169
|
+
})), this.previewEntity || (this.previewEntity = t.entities.add({
|
|
170
|
+
polyline: {
|
|
171
|
+
positions: new e.CallbackProperty(() => !this.previewPos || !this.positions.length ? [] : [this.positions[this.positions.length - 1], this.previewPos], !1),
|
|
172
|
+
width: i.width || 3,
|
|
173
|
+
material: i.lineColor || i.color || e.Color.YELLOW,
|
|
174
|
+
depthFailMaterial: new e.PolylineDashMaterialProperty({
|
|
175
|
+
color: (i.dashLineColor || i.lineColor || i.color || e.Color.RED).withAlpha?.(0.9) || e.Color.RED,
|
|
176
|
+
dashLength: 12,
|
|
177
|
+
dashPattern: 255
|
|
178
|
+
})
|
|
179
|
+
}
|
|
180
|
+
}));
|
|
181
|
+
}, e.ScreenSpaceEventType.MOUSE_MOVE);
|
|
182
|
+
}
|
|
183
|
+
stop() {
|
|
184
|
+
this.handler && (this.handler.destroy(), this.handler = null);
|
|
185
|
+
}
|
|
186
|
+
clear() {
|
|
187
|
+
this.stop(), this.segmentEntities.forEach((i) => this.viewer.entities.remove(i)), this.segmentEntities = [], this.groundLineEntities.forEach((i) => this.viewer.entities.remove(i)), this.groundLineEntities = [], this.tempPoints.forEach((i) => this.viewer.entities.remove(i)), this.tempPoints = [], this.totalLabelId && this.htmlLabelPool && (this.htmlLabelPool.removeByIds([this.totalLabelId]), this.totalLabelId = null), this.previewEntity && (this.viewer.entities.remove(this.previewEntity), this.previewEntity = null), this.previewGroundEntity && (this.viewer.entities.remove(this.previewGroundEntity), this.previewGroundEntity = null), this.previewLabelId && this.htmlLabelPool && (this.htmlLabelPool.removeByIds([this.previewLabelId]), this.previewLabelId = null), this.segmentLabelIds.length && this.htmlLabelPool && this.htmlLabelPool.removeByIds(this.segmentLabelIds.slice()), this.segmentLabelIds = [], this.positions = [], this.hoverPos = null, this.labelEntity = null, this.firstHeight = null, this.previewPos = null, this.previewGroundPos = null;
|
|
188
|
+
}
|
|
189
|
+
rehydrate(i, e) {
|
|
190
|
+
const t = this.Cesium, h = this.viewer, s = i.options || {}, o = s.lineColor || s.color || t.Color.YELLOW, d = (s.dashLineColor || s.lineColor || s.color || t.Color.RED).withAlpha?.(0.9) || t.Color.RED, n = s.width || 3, r = (i.positions || []).map((l) => new t.Cartesian3(l[0], l[1], l[2]));
|
|
191
|
+
if (!r.length) return;
|
|
192
|
+
if (!this.htmlLabelPool) {
|
|
193
|
+
const l = s.overlayContainerId || "html-label-container";
|
|
194
|
+
this.htmlLabelPool = e || new k(t, h, l), this.htmlLabelPool.registerTheme("measure-horizontal-total", {
|
|
195
|
+
createElement: (a, w) => {
|
|
196
|
+
a.innerHTML = String(w?.data?.text || ""), a.style.background = "rgba(0,0,0,0.6)", a.style.color = "#fff", a.style.font = "14px sans-serif", a.style.padding = "4px 6px", a.style.borderRadius = "4px", a.style.whiteSpace = "pre";
|
|
197
|
+
},
|
|
198
|
+
options: { offset: { x: 0, y: -10 } }
|
|
199
|
+
}), this.htmlLabelPool.registerTheme("measure-horizontal-seg", {
|
|
200
|
+
createElement: (a, w) => {
|
|
201
|
+
a.innerHTML = String(w?.data?.text || ""), a.style.background = "rgba(0,0,0,0.6)", a.style.color = "#fff", a.style.font = "14px sans-serif", a.style.padding = "4px 6px", a.style.borderRadius = "4px", a.style.whiteSpace = "pre";
|
|
202
|
+
},
|
|
203
|
+
options: { offset: { x: 0, y: -10 } }
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
for (const l of r) {
|
|
207
|
+
const a = h.entities.add({ position: l, point: { pixelSize: 8, color: s.pointColor || s.color || t.Color.YELLOW, disableDepthTestDistance: Number.POSITIVE_INFINITY } });
|
|
208
|
+
this.tempPoints.push(a);
|
|
209
|
+
const w = t.Cartographic.fromCartesian(l), u = t.Math.toDegrees(w.longitude), C = t.Math.toDegrees(w.latitude), L = h.scene.globe.getHeight(new t.Cartographic(w.longitude, w.latitude, 0)) || 0, f = t.Cartesian3.fromDegrees(u, C, L), b = h.entities.add({
|
|
210
|
+
polyline: {
|
|
211
|
+
positions: [f, l],
|
|
212
|
+
width: n,
|
|
213
|
+
material: new t.PolylineDashMaterialProperty({ color: d, dashLength: 12, dashPattern: 255 })
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
this.groundLineEntities.push(b);
|
|
217
|
+
}
|
|
218
|
+
for (let l = 1; l < r.length; l++) {
|
|
219
|
+
const a = r[l - 1], w = r[l], u = h.entities.add({
|
|
220
|
+
polyline: {
|
|
221
|
+
positions: [a, w],
|
|
222
|
+
width: n,
|
|
223
|
+
material: o,
|
|
224
|
+
depthFailMaterial: new t.PolylineDashMaterialProperty({ color: d, dashLength: 12, dashPattern: 255 })
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
this.segmentEntities.push(u);
|
|
228
|
+
const C = t.Cartographic.fromCartesian(a), L = t.Cartographic.fromCartesian(w), b = new t.EllipsoidGeodesic(C, L).surfaceDistance, y = new t.Cartesian3((a.x + w.x) / 2, (a.y + w.y) / 2, (a.z + w.z) / 2), v = t.Cartographic.fromCartesian(y), E = i.id + `_seg_${l - 1}`;
|
|
229
|
+
this.segmentLabelIds.push(E), this.htmlLabelPool.add({ text: `${b.toFixed(2)} m` }, {
|
|
230
|
+
id: E,
|
|
231
|
+
lon: t.Math.toDegrees(v.longitude),
|
|
232
|
+
lat: t.Math.toDegrees(v.latitude),
|
|
233
|
+
height: v.height || 0,
|
|
234
|
+
theme: "measure-horizontal-seg",
|
|
235
|
+
show: !0,
|
|
236
|
+
style: { pointerEvents: "none", userSelect: "none", cursor: "default" }
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
let c = 0;
|
|
240
|
+
for (let l = 1; l < r.length; l++) {
|
|
241
|
+
const a = t.Cartographic.fromCartesian(r[l - 1]), w = t.Cartographic.fromCartesian(r[l]), u = new t.EllipsoidGeodesic(a, w);
|
|
242
|
+
c += u.surfaceDistance;
|
|
243
|
+
}
|
|
244
|
+
const p = r[r.length - 1], m = t.Cartographic.fromCartesian(p), g = i.id + "_total";
|
|
245
|
+
this.totalLabelId = g, this.htmlLabelPool.add({ text: `${c.toFixed(2)} m` }, {
|
|
246
|
+
id: g,
|
|
247
|
+
lon: t.Math.toDegrees(m.longitude),
|
|
248
|
+
lat: t.Math.toDegrees(m.latitude),
|
|
249
|
+
height: m.height || 0,
|
|
250
|
+
theme: "measure-horizontal-total",
|
|
251
|
+
show: !0,
|
|
252
|
+
style: { pointerEvents: "none", userSelect: "none", cursor: "default" }
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
class ge {
|
|
257
|
+
Cesium;
|
|
258
|
+
viewer;
|
|
259
|
+
handler = null;
|
|
260
|
+
entity = null;
|
|
261
|
+
labelEntity = null;
|
|
262
|
+
positions = [];
|
|
263
|
+
htmlLabelPool = null;
|
|
264
|
+
htmlLabelId = null;
|
|
265
|
+
previewLabelId = null;
|
|
266
|
+
baseCarto = null;
|
|
267
|
+
baseUp = null;
|
|
268
|
+
tempPoints = [];
|
|
269
|
+
previewPointEntity = null;
|
|
270
|
+
previewEntity = null;
|
|
271
|
+
constructor(i, e) {
|
|
272
|
+
this.Cesium = i, this.viewer = e;
|
|
273
|
+
}
|
|
274
|
+
start(i) {
|
|
275
|
+
this.clear();
|
|
276
|
+
const e = this.Cesium, t = this.viewer;
|
|
277
|
+
if (!this.htmlLabelPool) {
|
|
278
|
+
const h = i.overlayContainerId || "html-label-container";
|
|
279
|
+
this.htmlLabelPool = new k(e, t, h), this.htmlLabelPool.registerTheme("measure-vertical", {
|
|
280
|
+
createElement: (s, o) => {
|
|
281
|
+
s.innerHTML = String(o?.data?.text || ""), s.style.background = "rgba(0,0,0,0.6)", s.style.color = "#fff", s.style.font = "14px sans-serif", s.style.padding = "4px 6px", s.style.borderRadius = "4px", s.style.whiteSpace = "pre";
|
|
282
|
+
},
|
|
283
|
+
options: { offset: { x: 0, y: -10 } }
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((h) => {
|
|
287
|
+
const s = t.camera.getPickRay(h.position);
|
|
288
|
+
let o = s ? t.scene.globe.pick(s, t.scene) : null;
|
|
289
|
+
if (o || (o = t.camera.pickEllipsoid(h.position, e.Ellipsoid.WGS84)), o || (o = t.scene.pickPosition(h.position)), !!o)
|
|
290
|
+
if (this.positions.length === 0) {
|
|
291
|
+
const d = e.Cartographic.fromCartesian(o);
|
|
292
|
+
this.baseCarto = new e.Cartographic(d.longitude, d.latitude, 0);
|
|
293
|
+
const n = e.Ellipsoid.WGS84.cartographicToCartesian(this.baseCarto);
|
|
294
|
+
this.baseUp = e.Ellipsoid.WGS84.geodeticSurfaceNormalCartographic(this.baseCarto), this.positions.push(n);
|
|
295
|
+
const r = t.entities.add({
|
|
296
|
+
position: n,
|
|
297
|
+
point: {
|
|
298
|
+
pixelSize: 8,
|
|
299
|
+
color: i.pointColor || i.color || e.Color.YELLOW,
|
|
300
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
this.tempPoints.push(r);
|
|
304
|
+
const c = i.lineColor || i.color || e.Color.CYAN, p = (i.dashLineColor || i.lineColor || i.color || e.Color.RED).withAlpha?.(0.9) || e.Color.RED;
|
|
305
|
+
this.previewEntity = t.entities.add({
|
|
306
|
+
polyline: {
|
|
307
|
+
positions: [n, n],
|
|
308
|
+
width: i.width || 3,
|
|
309
|
+
material: c,
|
|
310
|
+
depthFailMaterial: new e.PolylineDashMaterialProperty({
|
|
311
|
+
color: p,
|
|
312
|
+
dashLength: 12,
|
|
313
|
+
dashPattern: 255
|
|
314
|
+
})
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
} else {
|
|
318
|
+
if (!this.baseCarto || !this.baseUp) return;
|
|
319
|
+
const d = this.positions[0], n = t.camera.getPickRay(h.position);
|
|
320
|
+
if (!n) return;
|
|
321
|
+
const r = n.origin, c = e.Cartesian3.normalize(n.direction, new e.Cartesian3()), p = d, m = this.baseUp, g = e.Cartesian3.subtract(r, p, new e.Cartesian3()), l = e.Cartesian3.dot(c, c), a = -e.Cartesian3.dot(c, m), w = e.Cartesian3.dot(m, m), u = -e.Cartesian3.dot(c, g), C = e.Cartesian3.dot(m, g), L = l * w - a * a;
|
|
322
|
+
if (Math.abs(L) < 1e-6) return;
|
|
323
|
+
const f = (l * C - a * u) / L, b = e.Cartesian3.add(
|
|
324
|
+
p,
|
|
325
|
+
e.Cartesian3.multiplyByScalar(m, f, new e.Cartesian3()),
|
|
326
|
+
new e.Cartesian3()
|
|
327
|
+
);
|
|
328
|
+
this.positions[1] = b, this.stop(), this.previewEntity && (this.viewer.entities.remove(this.previewEntity), this.previewEntity = null), this.previewPointEntity && (this.viewer.entities.remove(this.previewPointEntity), this.previewPointEntity = null);
|
|
329
|
+
const y = i.lineColor || i.color || e.Color.CYAN, v = (i.dashLineColor || i.lineColor || i.color || e.Color.RED).withAlpha?.(0.9) || e.Color.RED;
|
|
330
|
+
this.entity = t.entities.add({
|
|
331
|
+
polyline: {
|
|
332
|
+
positions: [d, b],
|
|
333
|
+
width: i.width || 3,
|
|
334
|
+
material: y,
|
|
335
|
+
depthFailMaterial: new e.PolylineDashMaterialProperty({
|
|
336
|
+
color: v,
|
|
337
|
+
dashLength: 12,
|
|
338
|
+
dashPattern: 255
|
|
339
|
+
})
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
const E = t.entities.add({
|
|
343
|
+
position: b,
|
|
344
|
+
point: {
|
|
345
|
+
pixelSize: 8,
|
|
346
|
+
color: i.pointColor || i.color || e.Color.YELLOW,
|
|
347
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
this.tempPoints.push(E);
|
|
351
|
+
const x = this.baseCarto, D = e.Cartographic.fromCartesian(b), M = Math.abs((D.height || 0) - (x.height || 0)), P = new e.Cartesian3(
|
|
352
|
+
(this.positions[0].x + this.positions[1].x) / 2,
|
|
353
|
+
(this.positions[0].y + this.positions[1].y) / 2,
|
|
354
|
+
(this.positions[0].z + this.positions[1].z) / 2
|
|
355
|
+
), A = e.Cartographic.fromCartesian(P);
|
|
356
|
+
this.previewLabelId && this.htmlLabelPool && (this.htmlLabelPool.removeByIds([this.previewLabelId]), this.previewLabelId = null);
|
|
357
|
+
const I = this.htmlLabelId || `measure_vertical_${Date.now()}`;
|
|
358
|
+
this.htmlLabelId = I, this.htmlLabelPool.add(
|
|
359
|
+
{ text: `${M.toFixed(2)} m` },
|
|
360
|
+
{
|
|
361
|
+
id: I,
|
|
362
|
+
lon: e.Math.toDegrees(A.longitude),
|
|
363
|
+
lat: e.Math.toDegrees(A.latitude),
|
|
364
|
+
height: A.height || 0,
|
|
365
|
+
theme: "measure-vertical",
|
|
366
|
+
show: !0,
|
|
367
|
+
style: { pointerEvents: "none", userSelect: "none", cursor: "default" }
|
|
368
|
+
}
|
|
369
|
+
);
|
|
370
|
+
const S = {
|
|
371
|
+
entity: this.entity,
|
|
372
|
+
label: this.labelEntity,
|
|
373
|
+
positions: this.positions,
|
|
374
|
+
vertical: M,
|
|
375
|
+
clear: () => this.clear()
|
|
376
|
+
};
|
|
377
|
+
i.onComplete?.(S);
|
|
378
|
+
}
|
|
379
|
+
}, e.ScreenSpaceEventType.LEFT_CLICK), this.handler.setInputAction((h) => {
|
|
380
|
+
if (this.positions.length < 1) return;
|
|
381
|
+
if (!this.baseCarto || !this.baseUp) {
|
|
382
|
+
const D = e.Cartographic.fromCartesian(this.positions[0]);
|
|
383
|
+
this.baseCarto = new e.Cartographic(D.longitude, D.latitude, D.height || 0), this.baseUp = e.Ellipsoid.WGS84.geodeticSurfaceNormalCartographic(this.baseCarto);
|
|
384
|
+
}
|
|
385
|
+
const s = this.positions[0], o = t.camera.getPickRay(h.endPosition);
|
|
386
|
+
if (!o) return;
|
|
387
|
+
const d = o.origin, n = e.Cartesian3.normalize(o.direction, new e.Cartesian3()), r = s, c = this.baseUp, p = e.Cartesian3.subtract(d, r, new e.Cartesian3()), m = e.Cartesian3.dot(n, n), g = -e.Cartesian3.dot(n, c), l = e.Cartesian3.dot(c, c), a = -e.Cartesian3.dot(n, p), w = e.Cartesian3.dot(c, p), u = m * l - g * g;
|
|
388
|
+
if (Math.abs(u) < 1e-6) return;
|
|
389
|
+
const C = (m * w - g * a) / u, L = e.Cartesian3.add(
|
|
390
|
+
r,
|
|
391
|
+
e.Cartesian3.multiplyByScalar(c, C, new e.Cartesian3()),
|
|
392
|
+
new e.Cartesian3()
|
|
393
|
+
);
|
|
394
|
+
if (this.positions[1] = L, !this.previewEntity) {
|
|
395
|
+
const D = i.lineColor || i.color || e.Color.CYAN, M = (i.dashLineColor || i.lineColor || i.color || e.Color.RED).withAlpha?.(0.9) || e.Color.RED;
|
|
396
|
+
this.previewEntity = t.entities.add({
|
|
397
|
+
polyline: {
|
|
398
|
+
positions: new e.CallbackProperty(() => this.positions.length < 2 ? [] : [this.positions[0], this.positions[1]], !1),
|
|
399
|
+
width: i.width || 3,
|
|
400
|
+
material: D,
|
|
401
|
+
depthFailMaterial: new e.PolylineDashMaterialProperty({
|
|
402
|
+
color: M,
|
|
403
|
+
dashLength: 12,
|
|
404
|
+
dashPattern: 255
|
|
405
|
+
})
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
this.previewPointEntity ? this.previewPointEntity.position = L : this.previewPointEntity = t.entities.add({
|
|
410
|
+
position: L,
|
|
411
|
+
point: {
|
|
412
|
+
pixelSize: 8,
|
|
413
|
+
color: i.pointColor || i.color || e.Color.YELLOW,
|
|
414
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
const f = this.baseCarto, b = e.Cartographic.fromCartesian(L), y = Math.abs((b.height || 0) - (f.height || 0)), v = new e.Cartesian3(
|
|
418
|
+
(this.positions[0].x + L.x) / 2,
|
|
419
|
+
(this.positions[0].y + L.y) / 2,
|
|
420
|
+
(this.positions[0].z + L.z) / 2
|
|
421
|
+
), E = e.Cartographic.fromCartesian(v), x = this.previewLabelId || "measure_vertical_preview";
|
|
422
|
+
this.previewLabelId = x, this.htmlLabelPool.add(
|
|
423
|
+
{ text: `${y.toFixed(2)} m` },
|
|
424
|
+
{
|
|
425
|
+
id: x,
|
|
426
|
+
lon: e.Math.toDegrees(E.longitude),
|
|
427
|
+
lat: e.Math.toDegrees(E.latitude),
|
|
428
|
+
height: E.height || 0,
|
|
429
|
+
theme: "measure-vertical",
|
|
430
|
+
show: !0,
|
|
431
|
+
style: { pointerEvents: "none", userSelect: "none", cursor: "default" }
|
|
432
|
+
}
|
|
433
|
+
);
|
|
434
|
+
}, e.ScreenSpaceEventType.MOUSE_MOVE);
|
|
435
|
+
}
|
|
436
|
+
stop() {
|
|
437
|
+
this.handler && (this.handler.destroy(), this.handler = null);
|
|
438
|
+
}
|
|
439
|
+
clear() {
|
|
440
|
+
this.stop(), this.entity && (this.viewer.entities.remove(this.entity), this.entity = null), this.labelEntity && (this.viewer.entities.remove(this.labelEntity), this.labelEntity = null), this.tempPoints.forEach((i) => this.viewer.entities.remove(i)), this.tempPoints = [], this.previewPointEntity && (this.viewer.entities.remove(this.previewPointEntity), this.previewPointEntity = null), this.previewEntity && (this.viewer.entities.remove(this.previewEntity), this.previewEntity = null), this.htmlLabelPool && this.htmlLabelId && (this.htmlLabelPool.removeByIds([this.htmlLabelId]), this.htmlLabelId = null), this.previewLabelId && this.htmlLabelPool && (this.htmlLabelPool.removeByIds([this.previewLabelId]), this.previewLabelId = null), this.positions = [];
|
|
441
|
+
}
|
|
442
|
+
rehydrate(i, e) {
|
|
443
|
+
const t = this.Cesium, h = this.viewer, s = i.options || {}, o = s.lineColor || s.color || t.Color.CYAN, d = (s.dashLineColor || s.lineColor || s.color || t.Color.RED).withAlpha?.(0.9) || t.Color.RED, n = s.width || 3, r = (i.positions || []).map((f) => new t.Cartesian3(f[0], f[1], f[2]));
|
|
444
|
+
if (r.length < 2) return;
|
|
445
|
+
if (!this.htmlLabelPool) {
|
|
446
|
+
const f = s.overlayContainerId || "html-label-container";
|
|
447
|
+
this.htmlLabelPool = e || new k(t, h, f), this.htmlLabelPool.registerTheme("measure-vertical", {
|
|
448
|
+
createElement: (b, y) => {
|
|
449
|
+
b.innerHTML = String(y?.data?.text || ""), b.style.background = "rgba(0,0,0,0.6)", b.style.color = "#fff", b.style.font = "14px sans-serif", b.style.padding = "4px 6px", b.style.borderRadius = "4px", b.style.whiteSpace = "pre";
|
|
450
|
+
},
|
|
451
|
+
options: { offset: { x: 0, y: -10 } }
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
const c = r[0], p = r[1], m = h.entities.add({ position: c, point: { pixelSize: 8, color: s.pointColor || s.color || t.Color.YELLOW, disableDepthTestDistance: Number.POSITIVE_INFINITY } }), g = h.entities.add({ position: p, point: { pixelSize: 8, color: s.pointColor || s.color || t.Color.YELLOW, disableDepthTestDistance: Number.POSITIVE_INFINITY } });
|
|
455
|
+
this.tempPoints.push(m), this.tempPoints.push(g), this.entity = h.entities.add({ polyline: { positions: [c, p], width: n, material: o, depthFailMaterial: new t.PolylineDashMaterialProperty({ color: d, dashLength: 12, dashPattern: 255 }) } });
|
|
456
|
+
const l = t.Cartographic.fromCartesian(c), a = t.Cartographic.fromCartesian(p), w = Math.abs((a.height || 0) - (l.height || 0)), u = new t.Cartesian3((c.x + p.x) / 2, (c.y + p.y) / 2, (c.z + p.z) / 2), C = t.Cartographic.fromCartesian(u), L = i.id + "_label";
|
|
457
|
+
this.htmlLabelId = L, this.htmlLabelPool.add({ text: `${w.toFixed(2)} m` }, {
|
|
458
|
+
id: L,
|
|
459
|
+
lon: t.Math.toDegrees(C.longitude),
|
|
460
|
+
lat: t.Math.toDegrees(C.latitude),
|
|
461
|
+
height: C.height || 0,
|
|
462
|
+
theme: "measure-vertical",
|
|
463
|
+
show: !0,
|
|
464
|
+
style: { pointerEvents: "none", userSelect: "none", cursor: "default" }
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
class ue {
|
|
469
|
+
Cesium;
|
|
470
|
+
viewer;
|
|
471
|
+
handler = null;
|
|
472
|
+
positions = [];
|
|
473
|
+
htmlLabelPool = null;
|
|
474
|
+
htmlLabelId = null;
|
|
475
|
+
segmentEntities = [];
|
|
476
|
+
angleMarkerEntities = [];
|
|
477
|
+
pointEntities = [];
|
|
478
|
+
segmentLabelIds = [];
|
|
479
|
+
angleLabelIds = [];
|
|
480
|
+
previewLabelId = null;
|
|
481
|
+
previewSegmentEntities = [];
|
|
482
|
+
previewAngleMarkerEntities = [];
|
|
483
|
+
previewPointEntity = null;
|
|
484
|
+
previewLow = null;
|
|
485
|
+
previewHigh = null;
|
|
486
|
+
previewThird = null;
|
|
487
|
+
previewMarkerP1 = null;
|
|
488
|
+
previewMarkerP2 = null;
|
|
489
|
+
previewMarkerCorner = null;
|
|
490
|
+
constructor(i, e) {
|
|
491
|
+
this.Cesium = i, this.viewer = e;
|
|
492
|
+
}
|
|
493
|
+
start(i) {
|
|
494
|
+
this.clear();
|
|
495
|
+
const e = this.Cesium, t = this.viewer;
|
|
496
|
+
if (!this.htmlLabelPool) {
|
|
497
|
+
const h = i.overlayContainerId || "html-label-container";
|
|
498
|
+
this.htmlLabelPool = new k(e, t, h), this.htmlLabelPool.registerTheme("measure-triangle", {
|
|
499
|
+
createElement: (s, o) => {
|
|
500
|
+
s.innerHTML = String(o?.data?.text || ""), s.style.background = "rgba(0,0,0,0.6)", s.style.color = "#fff", s.style.font = "14px sans-serif", s.style.padding = "4px 6px", s.style.borderRadius = "4px", s.style.whiteSpace = "pre";
|
|
501
|
+
},
|
|
502
|
+
options: { offset: { x: 0, y: -10 } }
|
|
503
|
+
}), this.htmlLabelPool.registerTheme("measure-triangle-seg", {
|
|
504
|
+
createElement: (s, o) => {
|
|
505
|
+
s.innerHTML = String(o?.data?.text || ""), s.style.background = "rgba(0,0,0,0.6)", s.style.color = "#fff", s.style.font = "14px sans-serif", s.style.padding = "4px 6px", s.style.borderRadius = "4px", s.style.whiteSpace = "pre";
|
|
506
|
+
},
|
|
507
|
+
options: { offset: { x: 0, y: -10 } }
|
|
508
|
+
}), this.htmlLabelPool.registerTheme("measure-triangle-angle", {
|
|
509
|
+
createElement: (s, o) => {
|
|
510
|
+
s.innerHTML = String(o?.data?.text || ""), s.style.background = "rgba(0,0,0,0.6)", s.style.color = "#fff", s.style.font = "14px sans-serif", s.style.padding = "4px 6px", s.style.borderRadius = "4px", s.style.whiteSpace = "pre";
|
|
511
|
+
},
|
|
512
|
+
options: { offset: { x: 0, y: -10 } }
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((h) => {
|
|
516
|
+
const s = t.scene.pickPosition(h.position);
|
|
517
|
+
if (!s) return;
|
|
518
|
+
this.positions.push(s);
|
|
519
|
+
const o = t.entities.add({
|
|
520
|
+
position: s,
|
|
521
|
+
point: {
|
|
522
|
+
pixelSize: 8,
|
|
523
|
+
color: i.pointColor || i.color || e.Color.YELLOW,
|
|
524
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
if (this.pointEntities.push(o), this.positions.length === 2) {
|
|
528
|
+
this.stop(), this.previewSegmentEntities.forEach(($) => t.entities.remove($)), this.previewSegmentEntities = [], this.previewAngleMarkerEntities.forEach(($) => t.entities.remove($)), this.previewAngleMarkerEntities = [], this.previewPointEntity && (t.entities.remove(this.previewPointEntity), this.previewPointEntity = null);
|
|
529
|
+
const d = e.Cartographic.fromCartesian(this.positions[0]), n = e.Cartographic.fromCartesian(this.positions[1]), r = d.height || 0, c = n.height || 0, p = r <= c ? this.positions[0] : this.positions[1], m = r > c ? this.positions[0] : this.positions[1], g = e.Cartographic.fromCartesian(p);
|
|
530
|
+
e.Cartographic.fromCartesian(m);
|
|
531
|
+
const l = Math.max(r, c), a = e.Cartesian3.fromDegrees(
|
|
532
|
+
e.Math.toDegrees(g.longitude),
|
|
533
|
+
e.Math.toDegrees(g.latitude),
|
|
534
|
+
l
|
|
535
|
+
), w = i.lineColor || i.color || e.Color.YELLOW, u = (i.dashLineColor || i.lineColor || i.color || e.Color.RED).withAlpha?.(0.9) || e.Color.RED, C = t.entities.add({
|
|
536
|
+
polyline: {
|
|
537
|
+
positions: [p, a],
|
|
538
|
+
width: i.width || 3,
|
|
539
|
+
material: w,
|
|
540
|
+
depthFailMaterial: new e.PolylineDashMaterialProperty({ color: u, dashLength: 12, dashPattern: 255 })
|
|
541
|
+
}
|
|
542
|
+
}), L = t.entities.add({
|
|
543
|
+
polyline: {
|
|
544
|
+
positions: [a, m],
|
|
545
|
+
width: i.width || 3,
|
|
546
|
+
material: w,
|
|
547
|
+
depthFailMaterial: new e.PolylineDashMaterialProperty({ color: u, dashLength: 12, dashPattern: 255 })
|
|
548
|
+
}
|
|
549
|
+
}), f = t.entities.add({
|
|
550
|
+
polyline: {
|
|
551
|
+
positions: [p, m],
|
|
552
|
+
width: i.width || 3,
|
|
553
|
+
material: w,
|
|
554
|
+
depthFailMaterial: new e.PolylineDashMaterialProperty({ color: u, dashLength: 12, dashPattern: 255 })
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
this.segmentEntities.push(C, L, f);
|
|
558
|
+
const b = e.Cartesian3.distance(p, a), y = e.Cartesian3.distance(a, m), v = e.Cartesian3.distance(p, m), E = new e.Cartesian3((p.x + a.x) / 2, (p.y + a.y) / 2, (p.z + a.z) / 2), x = new e.Cartesian3((a.x + m.x) / 2, (a.y + m.y) / 2, (a.z + m.z) / 2), D = new e.Cartesian3((p.x + m.x) / 2, (p.y + m.y) / 2, (p.z + m.z) / 2), M = e.Cartographic.fromCartesian(E), P = e.Cartographic.fromCartesian(x), A = e.Cartographic.fromCartesian(D), I = "measure_triangle_seg_v", S = "measure_triangle_seg_h", R = "measure_triangle_seg_hyp";
|
|
559
|
+
this.segmentLabelIds = [I, S, R], this.htmlLabelPool.add({ text: `${b.toFixed(2)} m` }, { id: I, lon: e.Math.toDegrees(M.longitude), lat: e.Math.toDegrees(M.latitude), height: M.height || 0, theme: "measure-triangle-seg", show: !0, style: { pointerEvents: "none", userSelect: "none", cursor: "default" } }), this.htmlLabelPool.add({ text: `${y.toFixed(2)} m` }, { id: S, lon: e.Math.toDegrees(P.longitude), lat: e.Math.toDegrees(P.latitude), height: P.height || 0, theme: "measure-triangle-seg", show: !0, style: { pointerEvents: "none", userSelect: "none", cursor: "default" } }), this.htmlLabelPool.add({ text: `${v.toFixed(2)} m` }, { id: R, lon: e.Math.toDegrees(A.longitude), lat: e.Math.toDegrees(A.latitude), height: A.height || 0, theme: "measure-triangle-seg", show: !0, style: { pointerEvents: "none", userSelect: "none", cursor: "default" } });
|
|
560
|
+
const O = e.Cartesian3.subtract(m, p, new e.Cartesian3()), F = e.Cartesian3.subtract(a, p, new e.Cartesian3()), N = e.Cartesian3.subtract(a, m, new e.Cartesian3()), z = e.Cartesian3.subtract(p, m, new e.Cartesian3()), Q = e.Cartesian3.dot(O, F), Z = Math.sqrt(e.Cartesian3.dot(O, O)) * Math.sqrt(e.Cartesian3.dot(F, F)), X = e.Cartesian3.dot(N, z), oe = Math.sqrt(e.Cartesian3.dot(N, N)) * Math.sqrt(e.Cartesian3.dot(z, z)), te = Math.acos(Math.min(Math.max(Q / (Z || 1), -1), 1)), ie = Math.acos(Math.min(Math.max(X / (oe || 1), -1), 1)), se = e.Cartographic.fromCartesian(p), H = e.Cartographic.fromCartesian(m), G = "measure_triangle_angle_a", B = "measure_triangle_angle_b";
|
|
561
|
+
this.angleLabelIds = [G, B], this.htmlLabelPool.add({ text: `${(te * 180 / Math.PI).toFixed(2)}°` }, { id: G, lon: e.Math.toDegrees(se.longitude), lat: e.Math.toDegrees(se.latitude), height: se.height || 0, theme: "measure-triangle-angle", show: !0, style: { pointerEvents: "none", userSelect: "none", cursor: "default" } }), this.htmlLabelPool.add({ text: `${(ie * 180 / Math.PI).toFixed(2)}°` }, { id: B, lon: e.Math.toDegrees(H.longitude), lat: e.Math.toDegrees(H.latitude), height: H.height || 0, theme: "measure-triangle-angle", show: !0, style: { pointerEvents: "none", userSelect: "none", cursor: "default" } });
|
|
562
|
+
const j = Math.max(0.01, Math.min(0.5, i.angleMarkerRatio ?? 0.2)), _ = Math.min(b, y) * j;
|
|
563
|
+
if (b > 1e-3 && y > 1e-3) {
|
|
564
|
+
const $ = e.Cartesian3.normalize(
|
|
565
|
+
e.Cartesian3.subtract(p, a, new e.Cartesian3()),
|
|
566
|
+
new e.Cartesian3()
|
|
567
|
+
), J = e.Cartesian3.normalize(
|
|
568
|
+
e.Cartesian3.subtract(m, a, new e.Cartesian3()),
|
|
569
|
+
new e.Cartesian3()
|
|
570
|
+
), Y = new e.Cartesian3(
|
|
571
|
+
a.x + $.x * _,
|
|
572
|
+
a.y + $.y * _,
|
|
573
|
+
a.z + $.z * _
|
|
574
|
+
), V = new e.Cartesian3(
|
|
575
|
+
a.x + J.x * _,
|
|
576
|
+
a.y + J.y * _,
|
|
577
|
+
a.z + J.z * _
|
|
578
|
+
), T = new e.Cartesian3(
|
|
579
|
+
a.x + $.x * _ + J.x * _,
|
|
580
|
+
a.y + $.y * _ + J.y * _,
|
|
581
|
+
a.z + $.z * _ + J.z * _
|
|
582
|
+
), q = t.entities.add({
|
|
583
|
+
polyline: {
|
|
584
|
+
positions: [Y, T],
|
|
585
|
+
width: i.width || 3,
|
|
586
|
+
material: w,
|
|
587
|
+
depthFailMaterial: new e.PolylineDashMaterialProperty({ color: u, dashLength: 12, dashPattern: 255 })
|
|
588
|
+
}
|
|
589
|
+
}), re = t.entities.add({
|
|
590
|
+
polyline: {
|
|
591
|
+
positions: [V, T],
|
|
592
|
+
width: i.width || 3,
|
|
593
|
+
material: w,
|
|
594
|
+
depthFailMaterial: new e.PolylineDashMaterialProperty({ color: u, dashLength: 12, dashPattern: 255 })
|
|
595
|
+
}
|
|
596
|
+
});
|
|
597
|
+
this.angleMarkerEntities.push(q, re);
|
|
598
|
+
}
|
|
599
|
+
this.previewLabelId && this.htmlLabelPool && (this.htmlLabelPool.removeByIds([this.previewLabelId]), this.previewLabelId = null);
|
|
600
|
+
const ne = {
|
|
601
|
+
entity: this.segmentEntities,
|
|
602
|
+
positions: [p, m, a],
|
|
603
|
+
lengths: { vertical: b, horizontal: y, hypotenuse: v },
|
|
604
|
+
angles: { acuteA: te, acuteB: ie },
|
|
605
|
+
clear: () => this.clear()
|
|
606
|
+
};
|
|
607
|
+
i.onComplete?.(ne);
|
|
608
|
+
}
|
|
609
|
+
}, e.ScreenSpaceEventType.LEFT_CLICK), this.handler.setInputAction((h) => {
|
|
610
|
+
if (this.positions.length !== 1) return;
|
|
611
|
+
const s = t.scene.pickPosition(h.endPosition);
|
|
612
|
+
if (!s) return;
|
|
613
|
+
const o = e.Cartographic.fromCartesian(this.positions[0]), d = e.Cartographic.fromCartesian(s), n = o.height || 0, r = d.height || 0, c = n <= r ? this.positions[0] : s, p = n > r ? this.positions[0] : s, m = e.Cartographic.fromCartesian(c), g = Math.max(n, r), l = e.Cartesian3.fromDegrees(
|
|
614
|
+
this.Cesium.Math.toDegrees(m.longitude),
|
|
615
|
+
this.Cesium.Math.toDegrees(m.latitude),
|
|
616
|
+
g
|
|
617
|
+
);
|
|
618
|
+
this.previewLow = c, this.previewHigh = p, this.previewThird = l;
|
|
619
|
+
const a = i.lineColor || i.color || e.Color.YELLOW, w = (i.dashLineColor || i.lineColor || i.color || e.Color.RED).withAlpha?.(0.9) || e.Color.RED;
|
|
620
|
+
if (this.previewPointEntity ? this.previewPointEntity.position = s : this.previewPointEntity = t.entities.add({
|
|
621
|
+
position: s,
|
|
622
|
+
point: {
|
|
623
|
+
pixelSize: 8,
|
|
624
|
+
color: i.pointColor || i.color || e.Color.YELLOW,
|
|
625
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
626
|
+
}
|
|
627
|
+
}), !this.previewSegmentEntities.length) {
|
|
628
|
+
const G = t.entities.add({
|
|
629
|
+
polyline: {
|
|
630
|
+
positions: new e.CallbackProperty(() => !this.previewLow || !this.previewThird ? [] : [this.previewLow, this.previewThird], !1),
|
|
631
|
+
width: i.width || 3,
|
|
632
|
+
material: a,
|
|
633
|
+
depthFailMaterial: new e.PolylineDashMaterialProperty({ color: w, dashLength: 12, dashPattern: 255 })
|
|
634
|
+
}
|
|
635
|
+
}), B = t.entities.add({
|
|
636
|
+
polyline: {
|
|
637
|
+
positions: new e.CallbackProperty(() => !this.previewThird || !this.previewHigh ? [] : [this.previewThird, this.previewHigh], !1),
|
|
638
|
+
width: i.width || 3,
|
|
639
|
+
material: a,
|
|
640
|
+
depthFailMaterial: new e.PolylineDashMaterialProperty({ color: w, dashLength: 12, dashPattern: 255 })
|
|
641
|
+
}
|
|
642
|
+
}), j = t.entities.add({
|
|
643
|
+
polyline: {
|
|
644
|
+
positions: new e.CallbackProperty(() => !this.previewLow || !this.previewHigh ? [] : [this.previewLow, this.previewHigh], !1),
|
|
645
|
+
width: i.width || 3,
|
|
646
|
+
material: a,
|
|
647
|
+
depthFailMaterial: new e.PolylineDashMaterialProperty({ color: w, dashLength: 12, dashPattern: 255 })
|
|
648
|
+
}
|
|
649
|
+
});
|
|
650
|
+
this.previewSegmentEntities.push(G, B, j);
|
|
651
|
+
}
|
|
652
|
+
const u = e.Cartesian3.distance(c, l), C = e.Cartesian3.distance(l, p), L = e.Cartesian3.distance(c, p), f = e.Cartesian3.subtract(p, c, new e.Cartesian3()), b = e.Cartesian3.subtract(l, c, new e.Cartesian3()), y = e.Cartesian3.subtract(l, p, new e.Cartesian3()), v = e.Cartesian3.subtract(c, p, new e.Cartesian3()), E = e.Cartesian3.dot(f, b), x = Math.sqrt(e.Cartesian3.dot(f, f)) * Math.sqrt(e.Cartesian3.dot(b, b)), D = e.Cartesian3.dot(y, v), M = Math.sqrt(e.Cartesian3.dot(y, y)) * Math.sqrt(e.Cartesian3.dot(v, v)), P = Math.acos(Math.min(Math.max(E / (x || 1), -1), 1)), A = Math.acos(Math.min(Math.max(D / (M || 1), -1), 1)), I = new e.Cartesian3((c.x + l.x) / 2, (c.y + l.y) / 2, (c.z + l.z) / 2), S = new e.Cartesian3((l.x + p.x) / 2, (l.y + p.y) / 2, (l.z + p.z) / 2), R = new e.Cartesian3((c.x + p.x) / 2, (c.y + p.y) / 2, (c.z + p.z) / 2), O = e.Cartographic.fromCartesian(I), F = e.Cartographic.fromCartesian(S), N = e.Cartographic.fromCartesian(R), z = e.Cartographic.fromCartesian(c), Q = e.Cartographic.fromCartesian(p), Z = "measure_triangle_seg_v", X = "measure_triangle_seg_h", oe = "measure_triangle_seg_hyp", te = "measure_triangle_angle_a", ie = "measure_triangle_angle_b";
|
|
653
|
+
this.segmentLabelIds.length === 0 && (this.segmentLabelIds = [Z, X, oe]), this.angleLabelIds.length === 0 && (this.angleLabelIds = [te, ie]), this.htmlLabelPool.add({ text: `${u.toFixed(2)} m` }, { id: Z, lon: e.Math.toDegrees(O.longitude), lat: e.Math.toDegrees(O.latitude), height: O.height || 0, theme: "measure-triangle-seg", show: !0, style: { pointerEvents: "none", userSelect: "none", cursor: "default" } }), this.htmlLabelPool.add({ text: `${C.toFixed(2)} m` }, { id: X, lon: e.Math.toDegrees(F.longitude), lat: e.Math.toDegrees(F.latitude), height: F.height || 0, theme: "measure-triangle-seg", show: !0, style: { pointerEvents: "none", userSelect: "none", cursor: "default" } }), this.htmlLabelPool.add({ text: `${L.toFixed(2)} m` }, { id: oe, lon: e.Math.toDegrees(N.longitude), lat: e.Math.toDegrees(N.latitude), height: N.height || 0, theme: "measure-triangle-seg", show: !0, style: { pointerEvents: "none", userSelect: "none", cursor: "default" } }), this.htmlLabelPool.add({ text: `${(P * 180 / Math.PI).toFixed(2)}°` }, { id: te, lon: e.Math.toDegrees(z.longitude), lat: e.Math.toDegrees(z.latitude), height: z.height || 0, theme: "measure-triangle-angle", show: !0, style: { pointerEvents: "none", userSelect: "none", cursor: "default" } }), this.htmlLabelPool.add({ text: `${(A * 180 / Math.PI).toFixed(2)}°` }, { id: ie, lon: e.Math.toDegrees(Q.longitude), lat: e.Math.toDegrees(Q.latitude), height: Q.height || 0, theme: "measure-triangle-angle", show: !0, style: { pointerEvents: "none", userSelect: "none", cursor: "default" } });
|
|
654
|
+
const se = Math.max(0.01, Math.min(0.5, i.angleMarkerRatio ?? 0.2)), H = Math.min(u, C) * se;
|
|
655
|
+
if (u > 1e-3 && C > 1e-3) {
|
|
656
|
+
const G = e.Cartesian3.normalize(
|
|
657
|
+
e.Cartesian3.subtract(c, l, new e.Cartesian3()),
|
|
658
|
+
new e.Cartesian3()
|
|
659
|
+
), B = e.Cartesian3.normalize(
|
|
660
|
+
e.Cartesian3.subtract(p, l, new e.Cartesian3()),
|
|
661
|
+
new e.Cartesian3()
|
|
662
|
+
), j = new e.Cartesian3(
|
|
663
|
+
l.x + G.x * H,
|
|
664
|
+
l.y + G.y * H,
|
|
665
|
+
l.z + G.z * H
|
|
666
|
+
), _ = new e.Cartesian3(
|
|
667
|
+
l.x + B.x * H,
|
|
668
|
+
l.y + B.y * H,
|
|
669
|
+
l.z + B.z * H
|
|
670
|
+
), ne = new e.Cartesian3(
|
|
671
|
+
l.x + G.x * H + B.x * H,
|
|
672
|
+
l.y + G.y * H + B.y * H,
|
|
673
|
+
l.z + G.z * H + B.z * H
|
|
674
|
+
);
|
|
675
|
+
if (this.previewMarkerP1 = j, this.previewMarkerP2 = _, this.previewMarkerCorner = ne, !this.previewAngleMarkerEntities.length) {
|
|
676
|
+
const $ = t.entities.add({
|
|
677
|
+
polyline: {
|
|
678
|
+
positions: new e.CallbackProperty(() => !this.previewMarkerP1 || !this.previewMarkerCorner ? [] : [this.previewMarkerP1, this.previewMarkerCorner], !1),
|
|
679
|
+
width: i.width || 3,
|
|
680
|
+
material: a,
|
|
681
|
+
depthFailMaterial: new e.PolylineDashMaterialProperty({ color: w, dashLength: 12, dashPattern: 255 })
|
|
682
|
+
}
|
|
683
|
+
}), J = t.entities.add({
|
|
684
|
+
polyline: {
|
|
685
|
+
positions: new e.CallbackProperty(() => !this.previewMarkerP2 || !this.previewMarkerCorner ? [] : [this.previewMarkerP2, this.previewMarkerCorner], !1),
|
|
686
|
+
width: i.width || 3,
|
|
687
|
+
material: a,
|
|
688
|
+
depthFailMaterial: new e.PolylineDashMaterialProperty({ color: w, dashLength: 12, dashPattern: 255 })
|
|
689
|
+
}
|
|
690
|
+
});
|
|
691
|
+
this.previewAngleMarkerEntities.push($, J);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
}, e.ScreenSpaceEventType.MOUSE_MOVE);
|
|
695
|
+
}
|
|
696
|
+
stop() {
|
|
697
|
+
this.handler && (this.handler.destroy(), this.handler = null);
|
|
698
|
+
}
|
|
699
|
+
clear() {
|
|
700
|
+
this.stop(), this.segmentEntities.forEach((i) => this.viewer.entities.remove(i)), this.segmentEntities = [], this.angleMarkerEntities.forEach((i) => this.viewer.entities.remove(i)), this.angleMarkerEntities = [], this.pointEntities.forEach((i) => this.viewer.entities.remove(i)), this.pointEntities = [], this.previewSegmentEntities.forEach((i) => this.viewer.entities.remove(i)), this.previewSegmentEntities = [], this.previewAngleMarkerEntities.forEach((i) => this.viewer.entities.remove(i)), this.previewAngleMarkerEntities = [], this.previewPointEntity && (this.viewer.entities.remove(this.previewPointEntity), this.previewPointEntity = null), this.htmlLabelPool && this.htmlLabelId && (this.htmlLabelPool.removeByIds([this.htmlLabelId]), this.htmlLabelId = null), this.previewLabelId && this.htmlLabelPool && (this.htmlLabelPool.removeByIds([this.previewLabelId]), this.previewLabelId = null), this.segmentLabelIds.length && this.htmlLabelPool && this.htmlLabelPool.removeByIds(this.segmentLabelIds.slice()), this.angleLabelIds.length && this.htmlLabelPool && this.htmlLabelPool.removeByIds(this.angleLabelIds.slice()), this.segmentLabelIds = [], this.angleLabelIds = [], this.positions = [];
|
|
701
|
+
}
|
|
702
|
+
rehydrate(i, e) {
|
|
703
|
+
const t = this.Cesium, h = this.viewer, s = i.options || {}, o = s.lineColor || s.color || t.Color.YELLOW, d = (s.dashLineColor || s.lineColor || s.color || t.Color.RED).withAlpha?.(0.9) || t.Color.RED, n = s.width || 3, r = (i.positions || []).map((V) => new t.Cartesian3(V[0], V[1], V[2]));
|
|
704
|
+
if (r.length < 2) return;
|
|
705
|
+
if (!this.htmlLabelPool) {
|
|
706
|
+
const V = s.overlayContainerId || "html-label-container";
|
|
707
|
+
this.htmlLabelPool = e || new k(t, h, V), this.htmlLabelPool.registerTheme("measure-triangle", {
|
|
708
|
+
createElement: (T, q) => {
|
|
709
|
+
T.innerHTML = String(q?.data?.text || ""), T.style.background = "rgba(0,0,0,0.6)", T.style.color = "#fff", T.style.font = "14px sans-serif", T.style.padding = "4px 6px", T.style.borderRadius = "4px", T.style.whiteSpace = "pre";
|
|
710
|
+
},
|
|
711
|
+
options: { offset: { x: 0, y: -10 } }
|
|
712
|
+
}), this.htmlLabelPool.registerTheme("measure-triangle-seg", {
|
|
713
|
+
createElement: (T, q) => {
|
|
714
|
+
T.innerHTML = String(q?.data?.text || ""), T.style.background = "rgba(0,0,0,0.6)", T.style.color = "#fff", T.style.font = "14px sans-serif", T.style.padding = "4px 6px", T.style.borderRadius = "4px", T.style.whiteSpace = "pre";
|
|
715
|
+
},
|
|
716
|
+
options: { offset: { x: 0, y: -10 } }
|
|
717
|
+
}), this.htmlLabelPool.registerTheme("measure-triangle-angle", {
|
|
718
|
+
createElement: (T, q) => {
|
|
719
|
+
T.innerHTML = String(q?.data?.text || ""), T.style.background = "rgba(0,0,0,0.6)", T.style.color = "#fff", T.style.font = "14px sans-serif", T.style.padding = "4px 6px", T.style.borderRadius = "4px", T.style.whiteSpace = "pre";
|
|
720
|
+
},
|
|
721
|
+
options: { offset: { x: 0, y: -10 } }
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
const c = t.Cartographic.fromCartesian(r[0]), p = t.Cartographic.fromCartesian(r[1]), m = c.height || 0, g = p.height || 0, l = m <= g ? r[0] : r[1], a = m > g ? r[0] : r[1], w = h.entities.add({ position: l, point: { pixelSize: 8, color: s.pointColor || s.color || t.Color.YELLOW, disableDepthTestDistance: Number.POSITIVE_INFINITY } }), u = h.entities.add({ position: a, point: { pixelSize: 8, color: s.pointColor || s.color || t.Color.YELLOW, disableDepthTestDistance: Number.POSITIVE_INFINITY } });
|
|
725
|
+
this.pointEntities.push(w, u);
|
|
726
|
+
const C = t.Cartographic.fromCartesian(l), L = Math.max(m, g), f = t.Cartesian3.fromDegrees(
|
|
727
|
+
t.Math.toDegrees(C.longitude),
|
|
728
|
+
t.Math.toDegrees(C.latitude),
|
|
729
|
+
L
|
|
730
|
+
), b = h.entities.add({
|
|
731
|
+
polyline: { positions: [l, f], width: n, material: o, depthFailMaterial: new t.PolylineDashMaterialProperty({ color: d, dashLength: 12, dashPattern: 255 }) }
|
|
732
|
+
}), y = h.entities.add({
|
|
733
|
+
polyline: { positions: [f, a], width: n, material: o, depthFailMaterial: new t.PolylineDashMaterialProperty({ color: d, dashLength: 12, dashPattern: 255 }) }
|
|
734
|
+
}), v = h.entities.add({
|
|
735
|
+
polyline: { positions: [l, a], width: n, material: o, depthFailMaterial: new t.PolylineDashMaterialProperty({ color: d, dashLength: 12, dashPattern: 255 }) }
|
|
736
|
+
});
|
|
737
|
+
this.segmentEntities.push(b, y, v);
|
|
738
|
+
const E = t.Cartesian3.distance(l, f), x = t.Cartesian3.distance(f, a), D = t.Cartesian3.distance(l, a), M = new t.Cartesian3((l.x + f.x) / 2, (l.y + f.y) / 2, (l.z + f.z) / 2), P = new t.Cartesian3((f.x + a.x) / 2, (f.y + a.y) / 2, (f.z + a.z) / 2), A = new t.Cartesian3((l.x + a.x) / 2, (l.y + a.y) / 2, (l.z + a.z) / 2), I = t.Cartographic.fromCartesian(M), S = t.Cartographic.fromCartesian(P), R = t.Cartographic.fromCartesian(A), O = i.id + "_tri_v", F = i.id + "_tri_h", N = i.id + "_tri_hyp";
|
|
739
|
+
this.segmentLabelIds = [O, F, N], this.htmlLabelPool.add({ text: `${E.toFixed(2)} m` }, { id: O, lon: t.Math.toDegrees(I.longitude), lat: t.Math.toDegrees(I.latitude), height: I.height || 0, theme: "measure-triangle-seg", show: !0, style: { pointerEvents: "none", userSelect: "none", cursor: "default" } }), this.htmlLabelPool.add({ text: `${x.toFixed(2)} m` }, { id: F, lon: t.Math.toDegrees(S.longitude), lat: t.Math.toDegrees(S.latitude), height: S.height || 0, theme: "measure-triangle-seg", show: !0, style: { pointerEvents: "none", userSelect: "none", cursor: "default" } }), this.htmlLabelPool.add({ text: `${D.toFixed(2)} m` }, { id: N, lon: t.Math.toDegrees(R.longitude), lat: t.Math.toDegrees(R.latitude), height: R.height || 0, theme: "measure-triangle-seg", show: !0, style: { pointerEvents: "none", userSelect: "none", cursor: "default" } });
|
|
740
|
+
const z = t.Cartesian3.subtract(a, l, new t.Cartesian3()), Q = t.Cartesian3.subtract(f, l, new t.Cartesian3()), Z = t.Cartesian3.subtract(f, a, new t.Cartesian3()), X = t.Cartesian3.subtract(l, a, new t.Cartesian3()), oe = t.Cartesian3.dot(z, Q), te = Math.sqrt(t.Cartesian3.dot(z, z)) * Math.sqrt(t.Cartesian3.dot(Q, Q)), ie = t.Cartesian3.dot(Z, X), se = Math.sqrt(t.Cartesian3.dot(Z, Z)) * Math.sqrt(t.Cartesian3.dot(X, X)), H = Math.acos(Math.min(Math.max(oe / (te || 1), -1), 1)), G = Math.acos(Math.min(Math.max(ie / (se || 1), -1), 1)), B = t.Cartographic.fromCartesian(l), j = t.Cartographic.fromCartesian(a), _ = s.labelText || { angle: "角度" }, ne = i.id + "_tri_angA", $ = i.id + "_tri_angB";
|
|
741
|
+
this.angleLabelIds = [ne, $], this.htmlLabelPool.add({ text: `${_.angle}:${(H * 180 / Math.PI).toFixed(2)}°` }, { id: ne, lon: t.Math.toDegrees(B.longitude), lat: t.Math.toDegrees(B.latitude), height: B.height || 0, theme: "measure-triangle-angle", show: !0, style: { pointerEvents: "none", userSelect: "none", cursor: "default" } }), this.htmlLabelPool.add({ text: `${_.angle}:${(G * 180 / Math.PI).toFixed(2)}°` }, { id: $, lon: t.Math.toDegrees(j.longitude), lat: t.Math.toDegrees(j.latitude), height: j.height || 0, theme: "measure-triangle-angle", show: !0, style: { pointerEvents: "none", userSelect: "none", cursor: "default" } });
|
|
742
|
+
const J = Math.max(0.01, Math.min(0.5, s.angleMarkerRatio ?? 0.2)), Y = Math.min(E, x) * J;
|
|
743
|
+
if (E > 1e-3 && x > 1e-3) {
|
|
744
|
+
const V = t.Cartesian3.normalize(t.Cartesian3.subtract(l, f, new t.Cartesian3()), new t.Cartesian3()), T = t.Cartesian3.normalize(t.Cartesian3.subtract(a, f, new t.Cartesian3()), new t.Cartesian3()), q = new t.Cartesian3(f.x + V.x * Y, f.y + V.y * Y, f.z + V.z * Y), re = new t.Cartesian3(f.x + T.x * Y, f.y + T.y * Y, f.z + T.z * Y), he = new t.Cartesian3(f.x + V.x * Y + T.x * Y, f.y + V.y * Y + T.y * Y, f.z + V.z * Y + T.z * Y), Ie = h.entities.add({ polyline: { positions: [q, he], width: n, material: o, depthFailMaterial: new t.PolylineDashMaterialProperty({ color: d, dashLength: 12, dashPattern: 255 }) } }), xe = h.entities.add({ polyline: { positions: [re, he], width: n, material: o, depthFailMaterial: new t.PolylineDashMaterialProperty({ color: d, dashLength: 12, dashPattern: 255 }) } });
|
|
745
|
+
this.angleMarkerEntities.push(Ie, xe);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
class ye {
|
|
750
|
+
Cesium;
|
|
751
|
+
viewer;
|
|
752
|
+
handler = null;
|
|
753
|
+
entity = null;
|
|
754
|
+
labelEntity = null;
|
|
755
|
+
positions = [];
|
|
756
|
+
tempPoints = [];
|
|
757
|
+
htmlLabelPool = null;
|
|
758
|
+
htmlLabelId = null;
|
|
759
|
+
previewEntity = null;
|
|
760
|
+
previewPos = null;
|
|
761
|
+
previewLabelId = null;
|
|
762
|
+
constructor(i, e) {
|
|
763
|
+
this.Cesium = i, this.viewer = e;
|
|
764
|
+
}
|
|
765
|
+
start(i) {
|
|
766
|
+
this.clear();
|
|
767
|
+
const e = this.Cesium, t = this.viewer;
|
|
768
|
+
if (!this.htmlLabelPool) {
|
|
769
|
+
const h = i.overlayContainerId || "html-label-container";
|
|
770
|
+
this.htmlLabelPool = new k(e, t, h), this.htmlLabelPool.registerTheme("measure-space", {
|
|
771
|
+
createElement: (s, o) => {
|
|
772
|
+
s.innerHTML = String(o?.data?.text || ""), s.style.background = "rgba(0,0,0,0.6)", s.style.color = "#fff", s.style.font = "14px sans-serif", s.style.padding = "4px 6px", s.style.borderRadius = "4px", s.style.whiteSpace = "pre";
|
|
773
|
+
},
|
|
774
|
+
options: { offset: { x: 0, y: -10 } }
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((h) => {
|
|
778
|
+
const s = t.scene.pickPosition(h.position);
|
|
779
|
+
if (!s) return;
|
|
780
|
+
this.positions.push(s);
|
|
781
|
+
const o = t.entities.add({
|
|
782
|
+
position: s,
|
|
783
|
+
point: {
|
|
784
|
+
pixelSize: 8,
|
|
785
|
+
color: i.pointColor || i.color || e.Color.YELLOW,
|
|
786
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
787
|
+
}
|
|
788
|
+
});
|
|
789
|
+
if (this.tempPoints.push(o), this.positions.length === 2) {
|
|
790
|
+
this.stop(), this.previewEntity && (this.viewer.entities.remove(this.previewEntity), this.previewEntity = null), this.previewLabelId && this.htmlLabelPool && (this.htmlLabelPool.removeByIds([this.previewLabelId]), this.previewLabelId = null);
|
|
791
|
+
const d = this.positions[0], n = this.positions[1], r = i.lineColor || i.color || e.Color.YELLOW, c = (i.dashLineColor || i.lineColor || i.color || e.Color.RED).withAlpha?.(0.9) || e.Color.RED;
|
|
792
|
+
this.entity = t.entities.add({
|
|
793
|
+
polyline: {
|
|
794
|
+
positions: [d, n],
|
|
795
|
+
width: i.width || 3,
|
|
796
|
+
material: r,
|
|
797
|
+
depthFailMaterial: new e.PolylineDashMaterialProperty({
|
|
798
|
+
color: c,
|
|
799
|
+
dashLength: 12,
|
|
800
|
+
dashPattern: 255
|
|
801
|
+
})
|
|
802
|
+
}
|
|
803
|
+
});
|
|
804
|
+
const p = e.Cartesian3.distance(d, n), m = n, g = e.Cartographic.fromCartesian(m), l = this.htmlLabelId || `measure_space_${Date.now()}`;
|
|
805
|
+
this.htmlLabelId = l, this.htmlLabelPool.add(
|
|
806
|
+
{ text: `${p.toFixed(2)} m` },
|
|
807
|
+
{
|
|
808
|
+
id: l,
|
|
809
|
+
lon: e.Math.toDegrees(g.longitude),
|
|
810
|
+
lat: e.Math.toDegrees(g.latitude),
|
|
811
|
+
height: g.height || 0,
|
|
812
|
+
theme: "measure-space",
|
|
813
|
+
show: !0,
|
|
814
|
+
style: { pointerEvents: "none", userSelect: "none", cursor: "default" }
|
|
815
|
+
}
|
|
816
|
+
);
|
|
817
|
+
const a = {
|
|
818
|
+
entity: this.entity,
|
|
819
|
+
label: this.labelEntity,
|
|
820
|
+
positions: this.positions,
|
|
821
|
+
distance: p,
|
|
822
|
+
clear: () => this.clear()
|
|
823
|
+
};
|
|
824
|
+
i.onComplete?.(a);
|
|
825
|
+
}
|
|
826
|
+
}, e.ScreenSpaceEventType.LEFT_CLICK), this.handler.setInputAction((h) => {
|
|
827
|
+
if (this.positions.length !== 1) return;
|
|
828
|
+
const s = t.scene.pickPosition(h.endPosition);
|
|
829
|
+
if (!s) return;
|
|
830
|
+
this.previewPos = s;
|
|
831
|
+
const o = this.positions[0], d = e.Cartesian3.distance(o, s), n = new e.Cartesian3(
|
|
832
|
+
(o.x + s.x) / 2,
|
|
833
|
+
(o.y + s.y) / 2,
|
|
834
|
+
(o.z + s.z) / 2
|
|
835
|
+
), r = e.Cartographic.fromCartesian(n), c = this.previewLabelId || "measure_space_preview";
|
|
836
|
+
this.previewLabelId = c, this.htmlLabelPool.add(
|
|
837
|
+
{ text: `${d.toFixed(2)} m` },
|
|
838
|
+
{
|
|
839
|
+
id: c,
|
|
840
|
+
lon: e.Math.toDegrees(r.longitude),
|
|
841
|
+
lat: e.Math.toDegrees(r.latitude),
|
|
842
|
+
height: r.height || 0,
|
|
843
|
+
theme: "measure-space",
|
|
844
|
+
show: !0,
|
|
845
|
+
style: { pointerEvents: "none", userSelect: "none", cursor: "default" }
|
|
846
|
+
}
|
|
847
|
+
);
|
|
848
|
+
const p = i.lineColor || i.color || e.Color.YELLOW, m = (i.dashLineColor || i.lineColor || i.color || e.Color.RED).withAlpha?.(0.9) || e.Color.RED;
|
|
849
|
+
this.previewEntity || (this.previewEntity = t.entities.add({
|
|
850
|
+
polyline: {
|
|
851
|
+
positions: new e.CallbackProperty(() => !this.previewPos || !this.positions.length ? [] : [this.positions[0], this.previewPos], !1),
|
|
852
|
+
width: i.width || 3,
|
|
853
|
+
material: p,
|
|
854
|
+
depthFailMaterial: new e.PolylineDashMaterialProperty({
|
|
855
|
+
color: m,
|
|
856
|
+
dashLength: 12,
|
|
857
|
+
dashPattern: 255
|
|
858
|
+
})
|
|
859
|
+
}
|
|
860
|
+
}));
|
|
861
|
+
}, e.ScreenSpaceEventType.MOUSE_MOVE);
|
|
862
|
+
}
|
|
863
|
+
stop() {
|
|
864
|
+
this.handler && (this.handler.destroy(), this.handler = null);
|
|
865
|
+
}
|
|
866
|
+
clear() {
|
|
867
|
+
this.stop(), this.entity && (this.viewer.entities.remove(this.entity), this.entity = null), this.labelEntity && (this.viewer.entities.remove(this.labelEntity), this.labelEntity = null), this.htmlLabelPool && this.htmlLabelId && (this.htmlLabelPool.removeByIds([this.htmlLabelId]), this.htmlLabelId = null), this.previewEntity && (this.viewer.entities.remove(this.previewEntity), this.previewEntity = null), this.previewLabelId && this.htmlLabelPool && (this.htmlLabelPool.removeByIds([this.previewLabelId]), this.previewLabelId = null), this.tempPoints.forEach((i) => this.viewer.entities.remove(i)), this.tempPoints = [], this.positions = [];
|
|
868
|
+
}
|
|
869
|
+
rehydrate(i, e) {
|
|
870
|
+
const t = this.Cesium, h = this.viewer, s = i.options || {}, o = s.lineColor || s.color || t.Color.YELLOW, d = (s.dashLineColor || s.lineColor || s.color || t.Color.RED).withAlpha?.(0.9) || t.Color.RED, n = s.width || 3, r = (i.positions || []).map((c) => new t.Cartesian3(c[0], c[1], c[2]));
|
|
871
|
+
if (r.length) {
|
|
872
|
+
if (!this.htmlLabelPool) {
|
|
873
|
+
const c = s.overlayContainerId || "html-label-container";
|
|
874
|
+
this.htmlLabelPool = e || new k(t, h, c), this.htmlLabelPool.registerTheme("measure-space", {
|
|
875
|
+
createElement: (p, m) => {
|
|
876
|
+
p.innerHTML = String(m?.data?.text || ""), p.style.background = "rgba(0,0,0,0.6)", p.style.color = "#fff", p.style.font = "14px sans-serif", p.style.padding = "4px 6px", p.style.borderRadius = "4px", p.style.whiteSpace = "pre";
|
|
877
|
+
},
|
|
878
|
+
options: { offset: { x: 0, y: -10 } }
|
|
879
|
+
});
|
|
880
|
+
}
|
|
881
|
+
if (r.length >= 1) {
|
|
882
|
+
const c = h.entities.add({ position: r[0], point: { pixelSize: 8, color: s.pointColor || s.color || t.Color.YELLOW, disableDepthTestDistance: Number.POSITIVE_INFINITY } });
|
|
883
|
+
this.tempPoints.push(c);
|
|
884
|
+
}
|
|
885
|
+
if (r.length >= 2) {
|
|
886
|
+
const c = h.entities.add({ position: r[1], point: { pixelSize: 8, color: s.pointColor || s.color || t.Color.YELLOW, disableDepthTestDistance: Number.POSITIVE_INFINITY } });
|
|
887
|
+
this.tempPoints.push(c), this.entity = h.entities.add({
|
|
888
|
+
polyline: {
|
|
889
|
+
positions: [r[0], r[1]],
|
|
890
|
+
width: n,
|
|
891
|
+
material: o,
|
|
892
|
+
depthFailMaterial: new t.PolylineDashMaterialProperty({ color: d, dashLength: 12, dashPattern: 255 })
|
|
893
|
+
}
|
|
894
|
+
});
|
|
895
|
+
const p = t.Cartesian3.distance(r[0], r[1]), m = t.Cartographic.fromCartesian(r[1]), g = i.id + "_label";
|
|
896
|
+
this.htmlLabelId = g, this.htmlLabelPool.add({ text: `${p.toFixed(2)} m` }, {
|
|
897
|
+
id: g,
|
|
898
|
+
lon: t.Math.toDegrees(m.longitude),
|
|
899
|
+
lat: t.Math.toDegrees(m.latitude),
|
|
900
|
+
height: m.height || 0,
|
|
901
|
+
theme: "measure-space",
|
|
902
|
+
show: !0,
|
|
903
|
+
style: { pointerEvents: "none", userSelect: "none", cursor: "default" }
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
class we {
|
|
910
|
+
Cesium;
|
|
911
|
+
viewer;
|
|
912
|
+
handler = null;
|
|
913
|
+
entity = null;
|
|
914
|
+
labelEntity = null;
|
|
915
|
+
positions = [];
|
|
916
|
+
tempPoints = [];
|
|
917
|
+
primitive = null;
|
|
918
|
+
previewEntity = null;
|
|
919
|
+
previewPos = null;
|
|
920
|
+
edgeEntities = [];
|
|
921
|
+
pointEntities = [];
|
|
922
|
+
previewEdgeEntity = null;
|
|
923
|
+
previewPointEntities = [];
|
|
924
|
+
htmlLabelPool = null;
|
|
925
|
+
htmlLabelId = null;
|
|
926
|
+
previewLabelId = null;
|
|
927
|
+
segmentLabelIds = [];
|
|
928
|
+
angleLabelIds = [];
|
|
929
|
+
constructor(i, e) {
|
|
930
|
+
this.Cesium = i, this.viewer = e;
|
|
931
|
+
}
|
|
932
|
+
start(i) {
|
|
933
|
+
this.clear();
|
|
934
|
+
const e = this.Cesium, t = this.viewer;
|
|
935
|
+
if (!this.htmlLabelPool) {
|
|
936
|
+
const h = i.overlayContainerId || "html-label-container";
|
|
937
|
+
this.htmlLabelPool = new k(e, t, h), this.htmlLabelPool.registerTheme("measure-area", {
|
|
938
|
+
createElement: (s, o) => {
|
|
939
|
+
s.innerHTML = String(o?.data?.text || ""), s.style.background = "rgba(0,0,0,0.6)", s.style.color = "#fff", s.style.font = "14px sans-serif", s.style.padding = "4px 6px", s.style.borderRadius = "4px", s.style.whiteSpace = "pre";
|
|
940
|
+
},
|
|
941
|
+
options: { offset: { x: 0, y: -10 } }
|
|
942
|
+
}), this.htmlLabelPool.registerTheme("measure-area-seg", {
|
|
943
|
+
createElement: (s, o) => {
|
|
944
|
+
s.innerHTML = String(o?.data?.text || ""), s.style.background = "rgba(0,0,0,0.6)", s.style.color = "#fff", s.style.font = "14px sans-serif", s.style.padding = "4px 6px", s.style.borderRadius = "4px", s.style.whiteSpace = "pre";
|
|
945
|
+
},
|
|
946
|
+
options: { offset: { x: 0, y: -10 } }
|
|
947
|
+
}), this.htmlLabelPool.registerTheme("measure-area-angle", {
|
|
948
|
+
createElement: (s, o) => {
|
|
949
|
+
s.innerHTML = String(o?.data?.text || ""), s.style.background = "rgba(0,0,0,0.6)", s.style.color = "#fff", s.style.font = "14px sans-serif", s.style.padding = "4px 6px", s.style.borderRadius = "4px", s.style.whiteSpace = "pre";
|
|
950
|
+
},
|
|
951
|
+
options: { offset: { x: 0, y: -10 } }
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((h) => {
|
|
955
|
+
const s = t.scene.pickPosition(h.position);
|
|
956
|
+
if (!s) return;
|
|
957
|
+
this.positions.push(s);
|
|
958
|
+
const o = t.entities.add({
|
|
959
|
+
position: s,
|
|
960
|
+
point: {
|
|
961
|
+
pixelSize: 8,
|
|
962
|
+
color: i.color || e.Color.YELLOW,
|
|
963
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
964
|
+
}
|
|
965
|
+
});
|
|
966
|
+
this.tempPoints.push(o), this.primitive && (t.scene.primitives.remove(this.primitive), this.primitive = null);
|
|
967
|
+
const d = new e.PolygonHierarchy(this.positions.slice()), n = new e.PolygonGeometry({
|
|
968
|
+
polygonHierarchy: d,
|
|
969
|
+
vertexFormat: e.MaterialAppearance.VERTEX_FORMAT,
|
|
970
|
+
perPositionHeight: !0,
|
|
971
|
+
arcType: e.ArcType.NONE
|
|
972
|
+
}), r = new e.GeometryInstance({ geometry: n }), c = i.color || e.Color.YELLOW.withAlpha(0.4), p = i.color && i.color.withAlpha ? i.color.withAlpha(0.25) : e.Color.RED.withAlpha(0.4);
|
|
973
|
+
if (this.primitive = new e.Primitive({
|
|
974
|
+
geometryInstances: r,
|
|
975
|
+
appearance: new e.MaterialAppearance({
|
|
976
|
+
material: e.Material.fromType("Color", { color: c }),
|
|
977
|
+
translucent: !0,
|
|
978
|
+
closed: !0
|
|
979
|
+
}),
|
|
980
|
+
depthFailAppearance: new e.MaterialAppearance({
|
|
981
|
+
material: e.Material.fromType("Color", { color: p }),
|
|
982
|
+
translucent: !0,
|
|
983
|
+
closed: !0
|
|
984
|
+
})
|
|
985
|
+
}), t.scene.primitives.add(this.primitive), this.positions.length >= 2) {
|
|
986
|
+
if (this.edgeEntities.length) {
|
|
987
|
+
for (const w of this.edgeEntities)
|
|
988
|
+
try {
|
|
989
|
+
t.entities.remove(w);
|
|
990
|
+
} catch {
|
|
991
|
+
}
|
|
992
|
+
this.edgeEntities = [];
|
|
993
|
+
}
|
|
994
|
+
const m = i.lineColor || i.color || e.Color.YELLOW, g = (i.dashLineColor || i.lineColor || i.color || e.Color.RED).withAlpha?.(0.9) || e.Color.RED, l = this.positions.concat([this.positions[0]]), a = t.entities.add({
|
|
995
|
+
polyline: {
|
|
996
|
+
positions: l,
|
|
997
|
+
width: i.width || 2,
|
|
998
|
+
material: m,
|
|
999
|
+
clampToGround: !1,
|
|
1000
|
+
arcType: e.ArcType.NONE,
|
|
1001
|
+
depthFailMaterial: new e.PolylineDashMaterialProperty({
|
|
1002
|
+
color: g,
|
|
1003
|
+
dashLength: 12,
|
|
1004
|
+
dashPattern: 255
|
|
1005
|
+
})
|
|
1006
|
+
}
|
|
1007
|
+
});
|
|
1008
|
+
this.edgeEntities.push(a);
|
|
1009
|
+
}
|
|
1010
|
+
}, e.ScreenSpaceEventType.LEFT_CLICK), this.handler.setInputAction((h) => {
|
|
1011
|
+
if (this.positions.length === 0) return;
|
|
1012
|
+
const s = t.scene.pickPosition(h.endPosition);
|
|
1013
|
+
if (!s) return;
|
|
1014
|
+
this.previewPos = s;
|
|
1015
|
+
const o = this.positions.concat([s]), d = new e.Cartesian3(
|
|
1016
|
+
o.reduce((l, a) => l + a.x, 0) / o.length,
|
|
1017
|
+
o.reduce((l, a) => l + a.y, 0) / o.length,
|
|
1018
|
+
o.reduce((l, a) => l + a.z, 0) / o.length
|
|
1019
|
+
), r = new e.EllipsoidTangentPlane(d, e.Ellipsoid.WGS84).projectPointsOntoPlane(o);
|
|
1020
|
+
let c = 0;
|
|
1021
|
+
for (let l = 0; l < r.length; l++) {
|
|
1022
|
+
const a = (l + 1) % r.length;
|
|
1023
|
+
c += r[l].x * r[a].y - r[a].x * r[l].y;
|
|
1024
|
+
}
|
|
1025
|
+
c = Math.abs(c) / 2;
|
|
1026
|
+
const p = e.Cartographic.fromCartesian(d), m = this.previewLabelId || "measure_area_preview";
|
|
1027
|
+
this.previewLabelId = m;
|
|
1028
|
+
const g = i.labelText || { area: "面积" };
|
|
1029
|
+
if (this.htmlLabelPool.add(
|
|
1030
|
+
{ text: `${g.area}:${c.toFixed(2)} m²` },
|
|
1031
|
+
{
|
|
1032
|
+
id: m,
|
|
1033
|
+
lon: e.Math.toDegrees(p.longitude),
|
|
1034
|
+
lat: e.Math.toDegrees(p.latitude),
|
|
1035
|
+
height: p.height || 0,
|
|
1036
|
+
theme: "measure-area",
|
|
1037
|
+
show: !0
|
|
1038
|
+
}
|
|
1039
|
+
), !this.previewEntity) {
|
|
1040
|
+
const l = i.color || e.Color.YELLOW.withAlpha(0.4);
|
|
1041
|
+
this.previewEntity = t.entities.add({
|
|
1042
|
+
polygon: {
|
|
1043
|
+
hierarchy: new e.CallbackProperty(() => {
|
|
1044
|
+
if (!this.previewPos || !this.positions.length) return;
|
|
1045
|
+
const L = this.positions.concat([this.previewPos]);
|
|
1046
|
+
return new e.PolygonHierarchy(L);
|
|
1047
|
+
}, !1),
|
|
1048
|
+
material: l,
|
|
1049
|
+
perPositionHeight: !0,
|
|
1050
|
+
arcType: e.ArcType.NONE
|
|
1051
|
+
}
|
|
1052
|
+
});
|
|
1053
|
+
const a = i.lineColor || i.color || e.Color.YELLOW, w = (i.dashLineColor || i.lineColor || i.color || e.Color.RED).withAlpha?.(0.9) || e.Color.RED;
|
|
1054
|
+
this.previewEdgeEntity = t.entities.add({
|
|
1055
|
+
polyline: {
|
|
1056
|
+
positions: new e.CallbackProperty(() => !this.previewPos || !this.positions.length ? [] : this.positions.concat([this.previewPos, this.positions[0]]), !1),
|
|
1057
|
+
width: i.width || 2,
|
|
1058
|
+
material: a,
|
|
1059
|
+
clampToGround: !1,
|
|
1060
|
+
arcType: e.ArcType.NONE,
|
|
1061
|
+
depthFailMaterial: new e.PolylineDashMaterialProperty({
|
|
1062
|
+
color: w,
|
|
1063
|
+
dashLength: 12,
|
|
1064
|
+
dashPattern: 255
|
|
1065
|
+
})
|
|
1066
|
+
}
|
|
1067
|
+
});
|
|
1068
|
+
const u = i.pointColor || i.color || e.Color.YELLOW, C = t.entities.add({
|
|
1069
|
+
position: new e.CallbackProperty(() => this.previewPos || this.positions[this.positions.length - 1], !1),
|
|
1070
|
+
point: {
|
|
1071
|
+
pixelSize: 8,
|
|
1072
|
+
color: u,
|
|
1073
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
1074
|
+
}
|
|
1075
|
+
});
|
|
1076
|
+
this.previewPointEntities.push(C);
|
|
1077
|
+
}
|
|
1078
|
+
}, e.ScreenSpaceEventType.MOUSE_MOVE), this.handler.setInputAction(() => {
|
|
1079
|
+
if (this.positions.length < 3) {
|
|
1080
|
+
this.stop();
|
|
1081
|
+
return;
|
|
1082
|
+
}
|
|
1083
|
+
if (this.positions.length >= 3) {
|
|
1084
|
+
this.positions.pop();
|
|
1085
|
+
const g = this.tempPoints.pop();
|
|
1086
|
+
g && this.viewer.entities.remove(g);
|
|
1087
|
+
}
|
|
1088
|
+
if (this.previewEntity && (this.viewer.entities.remove(this.previewEntity), this.previewEntity = null), this.previewEdgeEntity && (this.viewer.entities.remove(this.previewEdgeEntity), this.previewEdgeEntity = null), this.previewPointEntities.length) {
|
|
1089
|
+
for (const g of this.previewPointEntities)
|
|
1090
|
+
try {
|
|
1091
|
+
this.viewer.entities.remove(g);
|
|
1092
|
+
} catch {
|
|
1093
|
+
}
|
|
1094
|
+
this.previewPointEntities = [];
|
|
1095
|
+
}
|
|
1096
|
+
this.previewPos = null, this.stop();
|
|
1097
|
+
const h = new e.Cartesian3(
|
|
1098
|
+
this.positions.reduce((g, l) => g + l.x, 0) / this.positions.length,
|
|
1099
|
+
this.positions.reduce((g, l) => g + l.y, 0) / this.positions.length,
|
|
1100
|
+
this.positions.reduce((g, l) => g + l.z, 0) / this.positions.length
|
|
1101
|
+
), o = new e.EllipsoidTangentPlane(h, e.Ellipsoid.WGS84).projectPointsOntoPlane(this.positions);
|
|
1102
|
+
let d = 0;
|
|
1103
|
+
for (let g = 0; g < o.length; g++) {
|
|
1104
|
+
const l = (g + 1) % o.length;
|
|
1105
|
+
d += o[g].x * o[l].y - o[l].x * o[g].y;
|
|
1106
|
+
}
|
|
1107
|
+
d = Math.abs(d) / 2;
|
|
1108
|
+
const n = e.Cartographic.fromCartesian(h), r = this.htmlLabelId || `measure_area_${Date.now()}`;
|
|
1109
|
+
this.htmlLabelId = r;
|
|
1110
|
+
const c = i.labelText || { area: "面积", side: "边长", angle: "角度" };
|
|
1111
|
+
this.previewLabelId && this.htmlLabelPool && (this.htmlLabelPool.removeByIds([this.previewLabelId]), this.previewLabelId = null), this.htmlLabelPool.add(
|
|
1112
|
+
{ text: `${c.area}:${d.toFixed(2)} m²` },
|
|
1113
|
+
{
|
|
1114
|
+
id: r,
|
|
1115
|
+
lon: e.Math.toDegrees(n.longitude),
|
|
1116
|
+
lat: e.Math.toDegrees(n.latitude),
|
|
1117
|
+
height: n.height || 0,
|
|
1118
|
+
theme: "measure-area",
|
|
1119
|
+
show: !0
|
|
1120
|
+
}
|
|
1121
|
+
), this.labelEntity = this.htmlLabelId;
|
|
1122
|
+
for (let g = 0; g < this.positions.length; g++) {
|
|
1123
|
+
const l = (g + 1) % this.positions.length, a = this.positions[g], w = this.positions[l], u = e.Cartographic.fromCartesian(a), C = e.Cartographic.fromCartesian(w), f = new e.EllipsoidGeodesic(u, C).surfaceDistance, b = new e.Cartesian3((a.x + w.x) / 2, (a.y + w.y) / 2, (a.z + w.z) / 2), y = e.Cartographic.fromCartesian(b), v = `measure_area_seg_${Date.now()}_${g}`;
|
|
1124
|
+
this.segmentLabelIds.push(v), this.htmlLabelPool.add(
|
|
1125
|
+
{ text: `${c.side}:${f.toFixed(2)} m` },
|
|
1126
|
+
{
|
|
1127
|
+
id: v,
|
|
1128
|
+
lon: e.Math.toDegrees(y.longitude),
|
|
1129
|
+
lat: e.Math.toDegrees(y.latitude),
|
|
1130
|
+
height: y.height || 0,
|
|
1131
|
+
theme: "measure-area-seg",
|
|
1132
|
+
show: !0
|
|
1133
|
+
}
|
|
1134
|
+
);
|
|
1135
|
+
}
|
|
1136
|
+
const p = o;
|
|
1137
|
+
for (let g = 0; g < p.length; g++) {
|
|
1138
|
+
const l = p[(g - 1 + p.length) % p.length], a = p[g], w = p[(g + 1) % p.length], u = l.x - a.x, C = l.y - a.y, L = w.x - a.x, f = w.y - a.y, b = Math.sqrt(u * u + C * C), y = Math.sqrt(L * L + f * f);
|
|
1139
|
+
if (!b || !y) continue;
|
|
1140
|
+
const v = u / b * (L / y) + C / b * (f / y), E = Math.acos(Math.min(1, Math.max(-1, v))) * (180 / Math.PI), x = e.Cartographic.fromCartesian(this.positions[g]), D = `measure_area_angle_${Date.now()}_${g}`;
|
|
1141
|
+
this.angleLabelIds.push(D), this.htmlLabelPool.add(
|
|
1142
|
+
{ text: `${c.angle}:${E.toFixed(2)} °` },
|
|
1143
|
+
{
|
|
1144
|
+
id: D,
|
|
1145
|
+
lon: e.Math.toDegrees(x.longitude),
|
|
1146
|
+
lat: e.Math.toDegrees(x.latitude),
|
|
1147
|
+
height: x.height || 0,
|
|
1148
|
+
theme: "measure-area-angle",
|
|
1149
|
+
show: !0
|
|
1150
|
+
}
|
|
1151
|
+
);
|
|
1152
|
+
}
|
|
1153
|
+
const m = {
|
|
1154
|
+
entity: this.primitive,
|
|
1155
|
+
label: this.labelEntity,
|
|
1156
|
+
positions: this.positions,
|
|
1157
|
+
area: d,
|
|
1158
|
+
clear: () => this.clear()
|
|
1159
|
+
};
|
|
1160
|
+
i.onComplete?.(m);
|
|
1161
|
+
}, e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
|
|
1162
|
+
}
|
|
1163
|
+
stop() {
|
|
1164
|
+
this.handler && (this.handler.destroy(), this.handler = null);
|
|
1165
|
+
}
|
|
1166
|
+
clear() {
|
|
1167
|
+
if (this.stop(), this.entity && (this.viewer.entities.remove(this.entity), this.entity = null), this.primitive && (this.viewer.scene.primitives.remove(this.primitive), this.primitive = null), this.edgeEntities.length) {
|
|
1168
|
+
for (const i of this.edgeEntities)
|
|
1169
|
+
try {
|
|
1170
|
+
this.viewer.entities.remove(i);
|
|
1171
|
+
} catch {
|
|
1172
|
+
}
|
|
1173
|
+
this.edgeEntities = [];
|
|
1174
|
+
}
|
|
1175
|
+
if (this.pointEntities.length) {
|
|
1176
|
+
for (const i of this.pointEntities)
|
|
1177
|
+
try {
|
|
1178
|
+
this.viewer.entities.remove(i);
|
|
1179
|
+
} catch {
|
|
1180
|
+
}
|
|
1181
|
+
this.pointEntities = [];
|
|
1182
|
+
}
|
|
1183
|
+
if (this.previewEntity && (this.viewer.entities.remove(this.previewEntity), this.previewEntity = null, this.previewPos = null), this.previewEdgeEntity && (this.viewer.entities.remove(this.previewEdgeEntity), this.previewEdgeEntity = null), this.previewPointEntities.length) {
|
|
1184
|
+
for (const i of this.previewPointEntities)
|
|
1185
|
+
try {
|
|
1186
|
+
this.viewer.entities.remove(i);
|
|
1187
|
+
} catch {
|
|
1188
|
+
}
|
|
1189
|
+
this.previewPointEntities = [];
|
|
1190
|
+
}
|
|
1191
|
+
this.labelEntity && (this.viewer.entities.remove(this.labelEntity), this.labelEntity = null), this.htmlLabelPool && this.htmlLabelId && (this.htmlLabelPool.removeByIds([this.htmlLabelId]), this.htmlLabelId = null), this.previewLabelId && this.htmlLabelPool && (this.htmlLabelPool.removeByIds([this.previewLabelId]), this.previewLabelId = null), this.segmentLabelIds.length && this.htmlLabelPool && this.htmlLabelPool.removeByIds(this.segmentLabelIds.slice()), this.angleLabelIds.length && this.htmlLabelPool && this.htmlLabelPool.removeByIds(this.angleLabelIds.slice()), this.segmentLabelIds = [], this.angleLabelIds = [], this.tempPoints.forEach((i) => this.viewer.entities.remove(i)), this.tempPoints = [], this.positions = [];
|
|
1192
|
+
}
|
|
1193
|
+
rehydrate(i, e) {
|
|
1194
|
+
const t = this.Cesium, h = this.viewer, s = i.options || {}, o = (i.positions || []).map((b) => new t.Cartesian3(b[0], b[1], b[2]));
|
|
1195
|
+
if (o.length < 3) return;
|
|
1196
|
+
if (!this.htmlLabelPool) {
|
|
1197
|
+
const b = s.overlayContainerId || "html-label-container";
|
|
1198
|
+
this.htmlLabelPool = e || new k(t, h, b), this.htmlLabelPool.registerTheme("measure-area", {
|
|
1199
|
+
createElement: (y, v) => {
|
|
1200
|
+
y.innerHTML = String(v?.data?.text || ""), y.style.background = "rgba(0,0,0,0.6)", y.style.color = "#fff", y.style.font = "14px sans-serif", y.style.padding = "4px 6px", y.style.borderRadius = "4px", y.style.whiteSpace = "pre";
|
|
1201
|
+
},
|
|
1202
|
+
options: { offset: { x: 0, y: -10 } }
|
|
1203
|
+
}), this.htmlLabelPool.registerTheme("measure-area-seg", {
|
|
1204
|
+
createElement: (y, v) => {
|
|
1205
|
+
y.innerHTML = String(v?.data?.text || ""), y.style.background = "rgba(0,0,0,0.6)", y.style.color = "#fff", y.style.font = "14px sans-serif", y.style.padding = "4px 6px", y.style.borderRadius = "4px", y.style.whiteSpace = "pre";
|
|
1206
|
+
},
|
|
1207
|
+
options: { offset: { x: 0, y: -10 } }
|
|
1208
|
+
}), this.htmlLabelPool.registerTheme("measure-area-angle", {
|
|
1209
|
+
createElement: (y, v) => {
|
|
1210
|
+
y.innerHTML = String(v?.data?.text || ""), y.style.background = "rgba(0,0,0,0.6)", y.style.color = "#fff", y.style.font = "14px sans-serif", y.style.padding = "4px 6px", y.style.borderRadius = "4px", y.style.whiteSpace = "pre";
|
|
1211
|
+
},
|
|
1212
|
+
options: { offset: { x: 0, y: -10 } }
|
|
1213
|
+
});
|
|
1214
|
+
}
|
|
1215
|
+
for (const b of o) {
|
|
1216
|
+
const y = h.entities.add({ position: b, point: { pixelSize: 8, color: s.color || t.Color.YELLOW, disableDepthTestDistance: Number.POSITIVE_INFINITY } });
|
|
1217
|
+
this.tempPoints.push(y);
|
|
1218
|
+
}
|
|
1219
|
+
const d = new t.Cartesian3(
|
|
1220
|
+
o.reduce((b, y) => b + y.x, 0) / o.length,
|
|
1221
|
+
o.reduce((b, y) => b + y.y, 0) / o.length,
|
|
1222
|
+
o.reduce((b, y) => b + y.z, 0) / o.length
|
|
1223
|
+
), r = new t.EllipsoidTangentPlane(d, t.Ellipsoid.WGS84).projectPointsOntoPlane(o);
|
|
1224
|
+
let c = 0;
|
|
1225
|
+
for (let b = 0; b < r.length; b++) {
|
|
1226
|
+
const y = (b + 1) % r.length;
|
|
1227
|
+
c += r[b].x * r[y].y - r[y].x * r[b].y;
|
|
1228
|
+
}
|
|
1229
|
+
c = Math.abs(c) / 2;
|
|
1230
|
+
const p = t.Cartographic.fromCartesian(d), m = i.id + "_area";
|
|
1231
|
+
this.htmlLabelId = m;
|
|
1232
|
+
const g = s.labelText || { area: "面积", side: "边长", angle: "角度" };
|
|
1233
|
+
this.htmlLabelPool.add({ text: `${g.area}:${c.toFixed(2)} m²` }, {
|
|
1234
|
+
id: m,
|
|
1235
|
+
lon: t.Math.toDegrees(p.longitude),
|
|
1236
|
+
lat: t.Math.toDegrees(p.latitude),
|
|
1237
|
+
height: p.height || 0,
|
|
1238
|
+
theme: "measure-area",
|
|
1239
|
+
show: !0
|
|
1240
|
+
});
|
|
1241
|
+
const l = new t.PolygonHierarchy(o), a = new t.PolygonGeometry({ polygonHierarchy: l, vertexFormat: t.MaterialAppearance.VERTEX_FORMAT, perPositionHeight: !0 }), w = new t.GeometryInstance({ geometry: a }), u = s.color || t.Color.YELLOW.withAlpha(0.4), C = s.color && s.color.withAlpha ? s.color.withAlpha(0.25) : t.Color.RED.withAlpha(0.4), L = new t.Primitive({
|
|
1242
|
+
geometryInstances: w,
|
|
1243
|
+
appearance: new t.MaterialAppearance({ material: t.Material.fromType("Color", { color: u }), translucent: !0, closed: !0 }),
|
|
1244
|
+
depthFailAppearance: new t.MaterialAppearance({ material: t.Material.fromType("Color", { color: C }), translucent: !0, closed: !0 })
|
|
1245
|
+
});
|
|
1246
|
+
h.scene.primitives.add(L), this.primitive = L;
|
|
1247
|
+
for (let b = 0; b < o.length; b++) {
|
|
1248
|
+
const y = (b + 1) % o.length, v = o[b], E = o[y], x = t.Cartographic.fromCartesian(v), D = t.Cartographic.fromCartesian(E), P = new t.EllipsoidGeodesic(x, D).surfaceDistance, A = new t.Cartesian3((v.x + E.x) / 2, (v.y + E.y) / 2, (v.z + E.z) / 2), I = t.Cartographic.fromCartesian(A), S = i.id + `_area_seg_${b}`;
|
|
1249
|
+
this.segmentLabelIds.push(S), this.htmlLabelPool.add({ text: `${g.side}:${P.toFixed(2)} m` }, { id: S, lon: t.Math.toDegrees(I.longitude), lat: t.Math.toDegrees(I.latitude), height: I.height || 0, theme: "measure-area-seg", show: !0 });
|
|
1250
|
+
}
|
|
1251
|
+
const f = r;
|
|
1252
|
+
for (let b = 0; b < f.length; b++) {
|
|
1253
|
+
const y = f[(b - 1 + f.length) % f.length], v = f[b], E = f[(b + 1) % f.length], x = y.x - v.x, D = y.y - v.y, M = E.x - v.x, P = E.y - v.y, A = Math.sqrt(x * x + D * D), I = Math.sqrt(M * M + P * P);
|
|
1254
|
+
if (!A || !I) continue;
|
|
1255
|
+
const S = x / A * (M / I) + D / A * (P / I), R = Math.acos(Math.min(1, Math.max(-1, S))) * (180 / Math.PI), O = t.Cartographic.fromCartesian(o[b]), F = i.id + `_area_angle_${b}`;
|
|
1256
|
+
this.angleLabelIds.push(F), this.htmlLabelPool.add({ text: `${g.angle}:${R.toFixed(2)} °` }, { id: F, lon: t.Math.toDegrees(O.longitude), lat: t.Math.toDegrees(O.latitude), height: O.height || 0, theme: "measure-area-angle", show: !0 });
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
class Ce {
|
|
1261
|
+
Cesium;
|
|
1262
|
+
viewer;
|
|
1263
|
+
handler = null;
|
|
1264
|
+
entity = null;
|
|
1265
|
+
positions = [];
|
|
1266
|
+
currentRadius = 0;
|
|
1267
|
+
labelEntity = null;
|
|
1268
|
+
previewLabel = null;
|
|
1269
|
+
ellipsePrimitive = null;
|
|
1270
|
+
previewEntity = null;
|
|
1271
|
+
isPrimitive = !1;
|
|
1272
|
+
htmlLabelPool = null;
|
|
1273
|
+
htmlLabelId = null;
|
|
1274
|
+
constructor(i, e) {
|
|
1275
|
+
this.Cesium = i, this.viewer = e;
|
|
1276
|
+
}
|
|
1277
|
+
start(i) {
|
|
1278
|
+
this.clear();
|
|
1279
|
+
const e = this.Cesium, t = this.viewer;
|
|
1280
|
+
if (!this.htmlLabelPool) {
|
|
1281
|
+
const h = i.overlayContainerId || "html-label-container";
|
|
1282
|
+
this.htmlLabelPool = new k(e, t, h), this.htmlLabelPool.registerTheme("measure-circle", {
|
|
1283
|
+
createElement: (s, o) => {
|
|
1284
|
+
const d = o?.data?.text || "";
|
|
1285
|
+
s.innerHTML = String(d), s.style.background = "rgba(0,0,0,0.6)", s.style.color = "#fff", s.style.font = "14px sans-serif", s.style.padding = "4px 6px", s.style.borderRadius = "4px", s.style.whiteSpace = "pre";
|
|
1286
|
+
},
|
|
1287
|
+
options: { offset: { x: 0, y: -10 } }
|
|
1288
|
+
});
|
|
1289
|
+
}
|
|
1290
|
+
this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((h) => {
|
|
1291
|
+
const s = t.scene.pickPosition(h.position);
|
|
1292
|
+
if (s && (this.positions.push(s), this.positions.length === 2)) {
|
|
1293
|
+
this.stop();
|
|
1294
|
+
const o = this.positions[0], d = this.positions[1], n = e.Cartesian3.distance(o, d), r = Math.PI * n * n, c = 2 * Math.PI * n, p = i.labelText || { radius: "半径", area: "面积", circumference: "周长" }, m = o;
|
|
1295
|
+
this.labelEntity ? (this.labelEntity.position = m, this.labelEntity.label.text = `${p.radius}:${n.toFixed(2)} m
|
|
1296
|
+
${p.area}:${r.toFixed(2)} m²
|
|
1297
|
+
${p.circumference}:${c.toFixed(2)} m`) : this.labelEntity = t.entities.add({
|
|
1298
|
+
position: m,
|
|
1299
|
+
label: {
|
|
1300
|
+
text: `${p.radius}:${n.toFixed(2)} m
|
|
1301
|
+
${p.area}:${r.toFixed(2)} m²
|
|
1302
|
+
${p.circumference}:${c.toFixed(2)} m`,
|
|
1303
|
+
font: "14px sans-serif",
|
|
1304
|
+
fillColor: e.Color.WHITE,
|
|
1305
|
+
outlineColor: e.Color.BLACK,
|
|
1306
|
+
outlineWidth: 2,
|
|
1307
|
+
style: e.LabelStyle.FILL_AND_OUTLINE,
|
|
1308
|
+
verticalOrigin: e.VerticalOrigin.BOTTOM,
|
|
1309
|
+
pixelOffset: new e.Cartesian2(0, -10),
|
|
1310
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
1311
|
+
eyeOffset: new e.Cartesian3(0, 0, -1e3),
|
|
1312
|
+
showBackground: !0,
|
|
1313
|
+
backgroundColor: e.Color.BLACK.withAlpha(0.6),
|
|
1314
|
+
show: !1
|
|
1315
|
+
}
|
|
1316
|
+
}), this.previewEntity && (t.entities.remove(this.previewEntity), this.previewEntity = null);
|
|
1317
|
+
const g = e.Cartographic.fromCartesian(o), l = new e.EllipseGeometry({
|
|
1318
|
+
center: o,
|
|
1319
|
+
semiMajorAxis: n,
|
|
1320
|
+
semiMinorAxis: n,
|
|
1321
|
+
height: g.height || 0,
|
|
1322
|
+
vertexFormat: e.MaterialAppearance.VERTEX_FORMAT
|
|
1323
|
+
}), a = new e.GeometryInstance({ geometry: l }), w = i.color || e.Color.YELLOW.withAlpha(0.5), u = i.color && i.color.withAlpha ? i.color.withAlpha(0.25) : e.Color.RED.withAlpha(0.4);
|
|
1324
|
+
this.ellipsePrimitive && (t.scene.primitives.remove(this.ellipsePrimitive), this.ellipsePrimitive = null), this.ellipsePrimitive = new e.Primitive({
|
|
1325
|
+
geometryInstances: a,
|
|
1326
|
+
appearance: new e.MaterialAppearance({
|
|
1327
|
+
material: e.Material.fromType("Color", { color: w }),
|
|
1328
|
+
translucent: !0,
|
|
1329
|
+
closed: !0
|
|
1330
|
+
}),
|
|
1331
|
+
depthFailAppearance: new e.MaterialAppearance({
|
|
1332
|
+
material: e.Material.fromType("Color", { color: u }),
|
|
1333
|
+
translucent: !0,
|
|
1334
|
+
closed: !0
|
|
1335
|
+
})
|
|
1336
|
+
}), t.scene.primitives.add(this.ellipsePrimitive), this.entity = this.ellipsePrimitive, this.isPrimitive = !0;
|
|
1337
|
+
const C = e.Cartographic.fromCartesian(o), L = e.Math.toDegrees(C.longitude), f = e.Math.toDegrees(C.latitude), b = C.height || 0, y = this.htmlLabelId || `measure_circle_${Date.now()}`;
|
|
1338
|
+
this.htmlLabelId = y;
|
|
1339
|
+
const v = `${p.radius}:${n.toFixed(2)} m
|
|
1340
|
+
${p.area}:${r.toFixed(2)} m²
|
|
1341
|
+
${p.circumference}:${c.toFixed(2)} m`;
|
|
1342
|
+
this.htmlLabelPool.add({ text: v }, { id: y, lon: L, lat: f, height: b, theme: "measure-circle", show: !0 });
|
|
1343
|
+
const E = {
|
|
1344
|
+
entity: this.entity,
|
|
1345
|
+
label: this.labelEntity,
|
|
1346
|
+
positions: this.positions,
|
|
1347
|
+
radius: n,
|
|
1348
|
+
area: r,
|
|
1349
|
+
perimeter: c,
|
|
1350
|
+
clear: () => this.clear()
|
|
1351
|
+
};
|
|
1352
|
+
i.onComplete?.(E);
|
|
1353
|
+
}
|
|
1354
|
+
}, e.ScreenSpaceEventType.LEFT_CLICK), this.handler.setInputAction((h) => {
|
|
1355
|
+
if (this.positions.length !== 1) return;
|
|
1356
|
+
const s = this.positions[0], o = t.camera.getPickRay(h.endPosition), d = t.scene.globe.pick(o, t.scene);
|
|
1357
|
+
if (!d) return;
|
|
1358
|
+
const n = e.Cartesian3.distance(s, d);
|
|
1359
|
+
this.currentRadius = n;
|
|
1360
|
+
const r = e.Cartographic.fromCartesian(s), c = Math.PI * n * n, p = 2 * Math.PI * n, m = i.labelText || { radius: "半径", area: "面积", circumference: "周长" }, g = s;
|
|
1361
|
+
this.labelEntity ? (this.labelEntity.position = g, this.labelEntity.label.text = `${m.radius}:${n.toFixed(2)} m
|
|
1362
|
+
${m.area}:${c.toFixed(2)} m²
|
|
1363
|
+
${m.circumference}:${p.toFixed(2)} m`) : this.labelEntity = t.entities.add({
|
|
1364
|
+
position: g,
|
|
1365
|
+
label: {
|
|
1366
|
+
text: `${m.radius}:${n.toFixed(2)} m
|
|
1367
|
+
${m.area}:${c.toFixed(2)} m²
|
|
1368
|
+
${m.circumference}:${p.toFixed(2)} m`,
|
|
1369
|
+
font: "14px sans-serif",
|
|
1370
|
+
fillColor: e.Color.WHITE,
|
|
1371
|
+
outlineColor: e.Color.BLACK,
|
|
1372
|
+
outlineWidth: 2,
|
|
1373
|
+
style: e.LabelStyle.FILL_AND_OUTLINE,
|
|
1374
|
+
verticalOrigin: e.VerticalOrigin.BOTTOM,
|
|
1375
|
+
pixelOffset: new e.Cartesian2(0, -10),
|
|
1376
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
1377
|
+
eyeOffset: new e.Cartesian3(0, 0, -1e3),
|
|
1378
|
+
showBackground: !0,
|
|
1379
|
+
backgroundColor: e.Color.BLACK.withAlpha(0.6),
|
|
1380
|
+
show: !1
|
|
1381
|
+
}
|
|
1382
|
+
});
|
|
1383
|
+
const l = e.Cartographic.fromCartesian(s), a = e.Math.toDegrees(l.longitude), w = e.Math.toDegrees(l.latitude), u = l.height || 0, C = this.htmlLabelId || `measure_circle_${Date.now()}`;
|
|
1384
|
+
this.htmlLabelId = C;
|
|
1385
|
+
const L = `${m.radius}:${n.toFixed(2)} m
|
|
1386
|
+
${m.area}:${c.toFixed(2)} m²
|
|
1387
|
+
${m.circumference}:${p.toFixed(2)} m`;
|
|
1388
|
+
if (this.htmlLabelPool.add({ text: L }, { id: C, lon: a, lat: w, height: u, theme: "measure-circle", show: !0 }), !this.previewEntity) {
|
|
1389
|
+
const f = i.color || e.Color.YELLOW.withAlpha(0.5);
|
|
1390
|
+
this.previewEntity = t.entities.add({
|
|
1391
|
+
position: s,
|
|
1392
|
+
ellipse: {
|
|
1393
|
+
semiMajorAxis: new e.CallbackProperty(() => this.currentRadius, !1),
|
|
1394
|
+
semiMinorAxis: new e.CallbackProperty(() => this.currentRadius, !1),
|
|
1395
|
+
height: r.height || 0,
|
|
1396
|
+
material: f
|
|
1397
|
+
}
|
|
1398
|
+
});
|
|
1399
|
+
}
|
|
1400
|
+
}, e.ScreenSpaceEventType.MOUSE_MOVE);
|
|
1401
|
+
}
|
|
1402
|
+
stop() {
|
|
1403
|
+
this.handler && (this.handler.destroy(), this.handler = null);
|
|
1404
|
+
}
|
|
1405
|
+
clear() {
|
|
1406
|
+
this.stop(), this.entity && (this.isPrimitive ? this.viewer.scene.primitives.remove(this.entity) : this.viewer.entities.remove(this.entity), this.entity = null, this.isPrimitive = !1), this.previewEntity && (this.viewer.entities.remove(this.previewEntity), this.previewEntity = null), this.labelEntity && (this.viewer.entities.remove(this.labelEntity), this.labelEntity = null), this.previewLabel && (this.viewer.entities.remove(this.previewLabel), this.previewLabel = null), this.ellipsePrimitive && (this.viewer.scene.primitives.remove(this.ellipsePrimitive), this.ellipsePrimitive = null), this.htmlLabelPool && this.htmlLabelId && (this.htmlLabelPool.removeByIds([this.htmlLabelId]), this.htmlLabelId = null), this.positions = [], this.currentRadius = 0;
|
|
1407
|
+
}
|
|
1408
|
+
rehydrate(i, e) {
|
|
1409
|
+
const t = this.Cesium, h = this.viewer, s = i.options || {}, o = (i.positions || []).map((y) => new t.Cartesian3(y[0], y[1], y[2]));
|
|
1410
|
+
if (o.length < 2) return;
|
|
1411
|
+
if (!this.htmlLabelPool) {
|
|
1412
|
+
const y = s.overlayContainerId || "html-label-container";
|
|
1413
|
+
this.htmlLabelPool = e || new k(t, h, y), this.htmlLabelPool.registerTheme("measure-circle", {
|
|
1414
|
+
createElement: (v, E) => {
|
|
1415
|
+
const x = E?.data?.text || "";
|
|
1416
|
+
v.innerHTML = String(x), v.style.background = "rgba(0,0,0,0.6)", v.style.color = "#fff", v.style.font = "14px sans-serif", v.style.padding = "4px 6px", v.style.borderRadius = "4px", v.style.whiteSpace = "pre";
|
|
1417
|
+
},
|
|
1418
|
+
options: { offset: { x: 0, y: -10 } }
|
|
1419
|
+
});
|
|
1420
|
+
}
|
|
1421
|
+
const d = o[0], n = o[1], r = t.Cartesian3.distance(d, n), c = Math.PI * r * r, p = 2 * Math.PI * r, m = t.Cartographic.fromCartesian(d), g = new t.EllipseGeometry({ center: d, semiMajorAxis: r, semiMinorAxis: r, height: m.height || 0, vertexFormat: t.MaterialAppearance.VERTEX_FORMAT }), l = new t.GeometryInstance({ geometry: g }), a = s.color || t.Color.YELLOW.withAlpha(0.5), w = s.color && s.color.withAlpha ? s.color.withAlpha(0.25) : t.Color.RED.withAlpha(0.4), u = new t.Primitive({
|
|
1422
|
+
geometryInstances: l,
|
|
1423
|
+
appearance: new t.MaterialAppearance({ material: t.Material.fromType("Color", { color: a }), translucent: !0, closed: !0 }),
|
|
1424
|
+
depthFailAppearance: new t.MaterialAppearance({ material: t.Material.fromType("Color", { color: w }), translucent: !0, closed: !0 })
|
|
1425
|
+
});
|
|
1426
|
+
h.scene.primitives.add(u), this.ellipsePrimitive = u, this.entity = u, this.isPrimitive = !0;
|
|
1427
|
+
const C = t.Cartographic.fromCartesian(d), L = i.id + "_circle";
|
|
1428
|
+
this.htmlLabelId = L;
|
|
1429
|
+
const f = s.labelText || { radius: "半径", area: "面积", circumference: "周长" }, b = `${f.radius}:${r.toFixed(2)} m
|
|
1430
|
+
${f.area}:${c.toFixed(2)} m²
|
|
1431
|
+
${f.circumference}:${p.toFixed(2)} m`;
|
|
1432
|
+
this.htmlLabelPool.add({ text: b }, { id: L, lon: t.Math.toDegrees(C.longitude), lat: t.Math.toDegrees(C.latitude), height: C.height || 0, theme: "measure-circle", show: !0 });
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
class fe {
|
|
1436
|
+
Cesium;
|
|
1437
|
+
viewer;
|
|
1438
|
+
handler = null;
|
|
1439
|
+
entity = null;
|
|
1440
|
+
labelEntity = null;
|
|
1441
|
+
positions = [];
|
|
1442
|
+
tempPoints = [];
|
|
1443
|
+
segmentLabels = [];
|
|
1444
|
+
hoverPos = null;
|
|
1445
|
+
previewPos = null;
|
|
1446
|
+
previewLabel = null;
|
|
1447
|
+
previewEntity = null;
|
|
1448
|
+
htmlLabelPool = null;
|
|
1449
|
+
totalLabelId = null;
|
|
1450
|
+
segmentLabelIds = [];
|
|
1451
|
+
previewLabelId = null;
|
|
1452
|
+
constructor(i, e) {
|
|
1453
|
+
this.Cesium = i, this.viewer = e;
|
|
1454
|
+
}
|
|
1455
|
+
start(i) {
|
|
1456
|
+
this.clear();
|
|
1457
|
+
const e = this.Cesium, t = this.viewer;
|
|
1458
|
+
if (!this.htmlLabelPool) {
|
|
1459
|
+
const h = i.overlayContainerId || "html-label-container";
|
|
1460
|
+
this.htmlLabelPool = new k(e, t, h), this.htmlLabelPool.registerTheme("measure-polyline-total", {
|
|
1461
|
+
createElement: (s, o) => {
|
|
1462
|
+
s.innerHTML = String(o?.data?.text || ""), s.style.background = "rgba(0,0,0,0.6)", s.style.color = "#fff", s.style.font = "14px sans-serif", s.style.padding = "4px 6px", s.style.borderRadius = "4px", s.style.whiteSpace = "pre";
|
|
1463
|
+
},
|
|
1464
|
+
options: { offset: { x: 0, y: -10 } }
|
|
1465
|
+
}), this.htmlLabelPool.registerTheme("measure-polyline-seg", {
|
|
1466
|
+
createElement: (s, o) => {
|
|
1467
|
+
s.innerHTML = String(o?.data?.text || ""), s.style.background = "rgba(0,0,0,0.6)", s.style.color = "#fff", s.style.font = "14px sans-serif", s.style.padding = "4px 6px", s.style.borderRadius = "4px", s.style.whiteSpace = "pre";
|
|
1468
|
+
},
|
|
1469
|
+
options: { offset: { x: 0, y: -10 } }
|
|
1470
|
+
});
|
|
1471
|
+
}
|
|
1472
|
+
this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((h) => {
|
|
1473
|
+
const s = t.scene.pickPosition(h.position);
|
|
1474
|
+
if (!s) return;
|
|
1475
|
+
this.positions.push(s);
|
|
1476
|
+
const o = t.entities.add({
|
|
1477
|
+
position: s,
|
|
1478
|
+
point: {
|
|
1479
|
+
pixelSize: 8,
|
|
1480
|
+
color: i.pointColor || i.color || e.Color.YELLOW,
|
|
1481
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
1482
|
+
}
|
|
1483
|
+
});
|
|
1484
|
+
if (this.tempPoints.push(o), this.entity ? this.entity.polyline.positions = this.positions.slice() : this.entity = t.entities.add({
|
|
1485
|
+
polyline: {
|
|
1486
|
+
positions: this.positions.slice(),
|
|
1487
|
+
width: i.width || 3,
|
|
1488
|
+
material: i.lineColor || i.color || e.Color.YELLOW,
|
|
1489
|
+
depthFailMaterial: new e.PolylineDashMaterialProperty({
|
|
1490
|
+
color: (i.dashLineColor || i.lineColor || i.color || e.Color.RED).withAlpha?.(0.9) || e.Color.RED,
|
|
1491
|
+
dashLength: 12,
|
|
1492
|
+
dashPattern: 255
|
|
1493
|
+
})
|
|
1494
|
+
}
|
|
1495
|
+
}), this.positions.length >= 2) {
|
|
1496
|
+
const d = this.positions[this.positions.length - 2], n = this.positions[this.positions.length - 1], r = e.Cartographic.fromCartesian(d), c = e.Cartographic.fromCartesian(n), m = new e.EllipsoidGeodesic(r, c).surfaceDistance, g = new e.Cartesian3(
|
|
1497
|
+
(d.x + n.x) / 2,
|
|
1498
|
+
(d.y + n.y) / 2,
|
|
1499
|
+
(d.z + n.z) / 2
|
|
1500
|
+
), l = e.Cartographic.fromCartesian(g), a = `measure_polyline_seg_${this.segmentLabelIds.length}_${Date.now()}`;
|
|
1501
|
+
this.segmentLabelIds.push(a), this.htmlLabelPool.add(
|
|
1502
|
+
{ text: `${m.toFixed(2)} m` },
|
|
1503
|
+
{
|
|
1504
|
+
id: a,
|
|
1505
|
+
lon: e.Math.toDegrees(l.longitude),
|
|
1506
|
+
lat: e.Math.toDegrees(l.latitude),
|
|
1507
|
+
height: l.height || 0,
|
|
1508
|
+
theme: "measure-polyline-seg",
|
|
1509
|
+
show: !0
|
|
1510
|
+
}
|
|
1511
|
+
);
|
|
1512
|
+
}
|
|
1513
|
+
}, e.ScreenSpaceEventType.LEFT_CLICK), this.handler.setInputAction(() => {
|
|
1514
|
+
if (this.positions.length < 2) {
|
|
1515
|
+
this.stop();
|
|
1516
|
+
return;
|
|
1517
|
+
}
|
|
1518
|
+
if (this.stop(), this.previewLabelId && (this.htmlLabelPool.removeByIds([this.previewLabelId]), this.previewLabelId = null), this.hoverPos && (this.hoverPos = null), this.previewEntity && (this.viewer.entities.remove(this.previewEntity), this.previewEntity = null), this.positions.length >= 2 && this.tempPoints.length >= 2) {
|
|
1519
|
+
const r = this.tempPoints[this.tempPoints.length - 1];
|
|
1520
|
+
this.viewer.entities.remove(r), this.tempPoints.pop();
|
|
1521
|
+
}
|
|
1522
|
+
if (this.segmentLabelIds.length >= 1) {
|
|
1523
|
+
const r = this.segmentLabelIds[this.segmentLabelIds.length - 1];
|
|
1524
|
+
r && (this.htmlLabelPool.removeByIds([r]), this.segmentLabelIds.pop());
|
|
1525
|
+
}
|
|
1526
|
+
this.positions.length >= 2 && this.positions.pop();
|
|
1527
|
+
let h = 0;
|
|
1528
|
+
for (let r = 1; r < this.positions.length; r++) {
|
|
1529
|
+
const c = this.positions[r - 1], p = this.positions[r], m = e.Cartographic.fromCartesian(c), g = e.Cartographic.fromCartesian(p), a = new e.EllipsoidGeodesic(m, g).surfaceDistance;
|
|
1530
|
+
h += a;
|
|
1531
|
+
}
|
|
1532
|
+
const s = this.positions[this.positions.length - 1];
|
|
1533
|
+
this.entity && this.entity.polyline && (this.entity.polyline.positions = this.positions);
|
|
1534
|
+
const o = e.Cartographic.fromCartesian(s), d = this.totalLabelId || `measure_polyline_total_${Date.now()}`;
|
|
1535
|
+
this.totalLabelId = d, this.htmlLabelPool.add(
|
|
1536
|
+
{ text: `${h.toFixed(2)} m` },
|
|
1537
|
+
{
|
|
1538
|
+
id: d,
|
|
1539
|
+
lon: e.Math.toDegrees(o.longitude),
|
|
1540
|
+
lat: e.Math.toDegrees(o.latitude),
|
|
1541
|
+
height: o.height || 0,
|
|
1542
|
+
theme: "measure-polyline-total",
|
|
1543
|
+
show: !0
|
|
1544
|
+
}
|
|
1545
|
+
), this.labelEntity = this.totalLabelId;
|
|
1546
|
+
const n = {
|
|
1547
|
+
entity: this.entity,
|
|
1548
|
+
label: this.labelEntity,
|
|
1549
|
+
segmentLabels: this.segmentLabelIds,
|
|
1550
|
+
positions: this.positions,
|
|
1551
|
+
distance: h,
|
|
1552
|
+
clear: () => this.clear()
|
|
1553
|
+
};
|
|
1554
|
+
i.onComplete?.(n);
|
|
1555
|
+
}, e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK), this.handler.setInputAction((h) => {
|
|
1556
|
+
if (this.positions.length === 0) return;
|
|
1557
|
+
const s = t.scene.pickPosition(h.endPosition);
|
|
1558
|
+
if (!s) return;
|
|
1559
|
+
this.hoverPos = s, this.previewPos = s;
|
|
1560
|
+
const o = this.positions[this.positions.length - 1], d = e.Cartographic.fromCartesian(o), n = e.Cartographic.fromCartesian(s), c = new e.EllipsoidGeodesic(d, n).surfaceDistance, p = new e.Cartesian3(
|
|
1561
|
+
(o.x + s.x) / 2,
|
|
1562
|
+
(o.y + s.y) / 2,
|
|
1563
|
+
(o.z + s.z) / 2
|
|
1564
|
+
), m = e.Cartographic.fromCartesian(p), g = this.previewLabelId || "measure_polyline_preview";
|
|
1565
|
+
this.previewLabelId = g, this.htmlLabelPool.add(
|
|
1566
|
+
{ text: `${c.toFixed(2)} m` },
|
|
1567
|
+
{
|
|
1568
|
+
id: g,
|
|
1569
|
+
lon: e.Math.toDegrees(m.longitude),
|
|
1570
|
+
lat: e.Math.toDegrees(m.latitude),
|
|
1571
|
+
height: m.height || 0,
|
|
1572
|
+
theme: "measure-polyline-seg",
|
|
1573
|
+
show: !0
|
|
1574
|
+
}
|
|
1575
|
+
), this.previewEntity || (this.previewEntity = t.entities.add({
|
|
1576
|
+
polyline: {
|
|
1577
|
+
positions: new e.CallbackProperty(() => !this.previewPos || !this.positions.length ? [] : [this.positions[this.positions.length - 1], this.previewPos], !1),
|
|
1578
|
+
width: i.width || 3,
|
|
1579
|
+
material: i.lineColor || i.color || e.Color.YELLOW,
|
|
1580
|
+
depthFailMaterial: new e.PolylineDashMaterialProperty({
|
|
1581
|
+
color: (i.dashLineColor || i.lineColor || i.color || e.Color.RED).withAlpha?.(0.9) || e.Color.RED,
|
|
1582
|
+
dashLength: 12,
|
|
1583
|
+
dashPattern: 255
|
|
1584
|
+
})
|
|
1585
|
+
}
|
|
1586
|
+
}));
|
|
1587
|
+
}, e.ScreenSpaceEventType.MOUSE_MOVE);
|
|
1588
|
+
}
|
|
1589
|
+
stop() {
|
|
1590
|
+
this.handler && (this.handler.destroy(), this.handler = null);
|
|
1591
|
+
}
|
|
1592
|
+
clear() {
|
|
1593
|
+
this.stop(), this.entity && (this.viewer.entities.remove(this.entity), this.entity = null), this.totalLabelId && this.htmlLabelPool && (this.htmlLabelPool.removeByIds([this.totalLabelId]), this.totalLabelId = null), this.previewEntity && (this.viewer.entities.remove(this.previewEntity), this.previewEntity = null), this.previewLabelId && this.htmlLabelPool && (this.htmlLabelPool.removeByIds([this.previewLabelId]), this.previewLabelId = null), this.hoverPos = null, this.segmentLabelIds.length && this.htmlLabelPool && this.htmlLabelPool.removeByIds(this.segmentLabelIds.slice()), this.segmentLabelIds = [], this.tempPoints.forEach((i) => this.viewer.entities.remove(i)), this.tempPoints = [], this.positions = [];
|
|
1594
|
+
}
|
|
1595
|
+
rehydrate(i, e) {
|
|
1596
|
+
const t = this.Cesium, h = this.viewer, s = i.options || {}, o = s.lineColor || s.color || t.Color.YELLOW, d = (s.dashLineColor || s.lineColor || s.color || t.Color.RED).withAlpha?.(0.9) || t.Color.RED, n = s.width || 3, r = (i.positions || []).map((l) => new t.Cartesian3(l[0], l[1], l[2]));
|
|
1597
|
+
if (r.length < 2) return;
|
|
1598
|
+
if (!this.htmlLabelPool) {
|
|
1599
|
+
const l = s.overlayContainerId || "html-label-container";
|
|
1600
|
+
this.htmlLabelPool = e || new k(t, h, l), this.htmlLabelPool.registerTheme("measure-polyline-total", {
|
|
1601
|
+
createElement: (a, w) => {
|
|
1602
|
+
a.innerHTML = String(w?.data?.text || ""), a.style.background = "rgba(0,0,0,0.6)", a.style.color = "#fff", a.style.font = "14px sans-serif", a.style.padding = "4px 6px", a.style.borderRadius = "4px", a.style.whiteSpace = "pre";
|
|
1603
|
+
},
|
|
1604
|
+
options: { offset: { x: 0, y: -10 } }
|
|
1605
|
+
}), this.htmlLabelPool.registerTheme("measure-polyline-seg", {
|
|
1606
|
+
createElement: (a, w) => {
|
|
1607
|
+
a.innerHTML = String(w?.data?.text || ""), a.style.background = "rgba(0,0,0,0.6)", a.style.color = "#fff", a.style.font = "14px sans-serif", a.style.padding = "4px 6px", a.style.borderRadius = "4px", a.style.whiteSpace = "pre";
|
|
1608
|
+
},
|
|
1609
|
+
options: { offset: { x: 0, y: -10 } }
|
|
1610
|
+
});
|
|
1611
|
+
}
|
|
1612
|
+
for (const l of r) {
|
|
1613
|
+
const a = h.entities.add({ position: l, point: { pixelSize: 8, color: s.pointColor || s.color || t.Color.YELLOW, disableDepthTestDistance: Number.POSITIVE_INFINITY } });
|
|
1614
|
+
this.tempPoints.push(a);
|
|
1615
|
+
}
|
|
1616
|
+
this.entity = h.entities.add({ polyline: { positions: r, width: n, material: o, depthFailMaterial: new t.PolylineDashMaterialProperty({ color: d, dashLength: 12, dashPattern: 255 }) } });
|
|
1617
|
+
let c = 0;
|
|
1618
|
+
for (let l = 1; l < r.length; l++) {
|
|
1619
|
+
const a = t.Cartographic.fromCartesian(r[l - 1]), w = t.Cartographic.fromCartesian(r[l]), u = new t.EllipsoidGeodesic(a, w);
|
|
1620
|
+
c += u.surfaceDistance;
|
|
1621
|
+
const C = r[l - 1], L = r[l], f = new t.Cartesian3((C.x + L.x) / 2, (C.y + L.y) / 2, (C.z + L.z) / 2), b = t.Cartographic.fromCartesian(f), y = i.id + `_seg_${l - 1}`;
|
|
1622
|
+
this.segmentLabelIds.push(y), this.htmlLabelPool.add({ text: `${u.surfaceDistance.toFixed(2)} m` }, {
|
|
1623
|
+
id: y,
|
|
1624
|
+
lon: t.Math.toDegrees(b.longitude),
|
|
1625
|
+
lat: t.Math.toDegrees(b.latitude),
|
|
1626
|
+
height: b.height || 0,
|
|
1627
|
+
theme: "measure-polyline-seg",
|
|
1628
|
+
show: !0,
|
|
1629
|
+
style: { pointerEvents: "none", userSelect: "none", cursor: "default" }
|
|
1630
|
+
});
|
|
1631
|
+
}
|
|
1632
|
+
const p = r[r.length - 1], m = t.Cartographic.fromCartesian(p), g = i.id + "_total";
|
|
1633
|
+
this.totalLabelId = g, this.htmlLabelPool.add({ text: `${c.toFixed(2)} m` }, {
|
|
1634
|
+
id: g,
|
|
1635
|
+
lon: t.Math.toDegrees(m.longitude),
|
|
1636
|
+
lat: t.Math.toDegrees(m.latitude),
|
|
1637
|
+
height: m.height || 0,
|
|
1638
|
+
theme: "measure-polyline-total",
|
|
1639
|
+
show: !0,
|
|
1640
|
+
style: { pointerEvents: "none", userSelect: "none", cursor: "default" }
|
|
1641
|
+
});
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
class be {
|
|
1645
|
+
Cesium;
|
|
1646
|
+
viewer;
|
|
1647
|
+
handler = null;
|
|
1648
|
+
labelEntity = null;
|
|
1649
|
+
htmlLabelPool = null;
|
|
1650
|
+
htmlLabelId = null;
|
|
1651
|
+
topPoint = null;
|
|
1652
|
+
zeroPoint = null;
|
|
1653
|
+
lineEntity = null;
|
|
1654
|
+
constructor(i, e) {
|
|
1655
|
+
this.Cesium = i, this.viewer = e;
|
|
1656
|
+
}
|
|
1657
|
+
start(i) {
|
|
1658
|
+
this.clear();
|
|
1659
|
+
const e = this.Cesium, t = this.viewer;
|
|
1660
|
+
if (!this.htmlLabelPool) {
|
|
1661
|
+
const h = i.overlayContainerId || "html-label-container";
|
|
1662
|
+
this.htmlLabelPool = new k(e, t, h), this.htmlLabelPool.registerTheme("measure-terrainHeight", {
|
|
1663
|
+
createElement: (s, o) => {
|
|
1664
|
+
s.innerHTML = String(o?.data?.text || ""), s.style.background = "rgba(0,0,0,0.6)", s.style.color = "#fff", s.style.font = "14px sans-serif", s.style.padding = "4px 6px", s.style.borderRadius = "4px", s.style.whiteSpace = "pre";
|
|
1665
|
+
},
|
|
1666
|
+
options: { offset: { x: 0, y: -10 } }
|
|
1667
|
+
});
|
|
1668
|
+
}
|
|
1669
|
+
this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((h) => {
|
|
1670
|
+
const s = t.scene.pickPosition(h.position);
|
|
1671
|
+
if (!s) return;
|
|
1672
|
+
const o = e.Cartographic.fromCartesian(s), d = t.scene.globe.getHeight(
|
|
1673
|
+
new e.Cartographic(o.longitude, o.latitude, 0)
|
|
1674
|
+
) || 0, n = e.Math.toDegrees(o.longitude), r = e.Math.toDegrees(o.latitude), c = e.Cartesian3.fromDegrees(n, r, d);
|
|
1675
|
+
this.topPoint = t.entities.add({
|
|
1676
|
+
position: s,
|
|
1677
|
+
point: {
|
|
1678
|
+
pixelSize: 8,
|
|
1679
|
+
color: i.color || e.Color.YELLOW,
|
|
1680
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
1681
|
+
}
|
|
1682
|
+
}), this.zeroPoint = t.entities.add({
|
|
1683
|
+
position: c,
|
|
1684
|
+
point: {
|
|
1685
|
+
pixelSize: 8,
|
|
1686
|
+
color: e.Color.YELLOW,
|
|
1687
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
1688
|
+
}
|
|
1689
|
+
}), this.lineEntity = t.entities.add({
|
|
1690
|
+
polyline: {
|
|
1691
|
+
positions: [c, s],
|
|
1692
|
+
width: i.width || 3,
|
|
1693
|
+
material: i.color || e.Color.YELLOW,
|
|
1694
|
+
depthFailMaterial: new e.PolylineDashMaterialProperty({
|
|
1695
|
+
color: e.Color.RED,
|
|
1696
|
+
dashLength: 12,
|
|
1697
|
+
dashPattern: 255
|
|
1698
|
+
})
|
|
1699
|
+
}
|
|
1700
|
+
});
|
|
1701
|
+
const p = i.labelText || { height: "高差" }, m = (o.height || 0) - d, g = `${p.height}:${m.toFixed(2)} m`, l = this.htmlLabelId || `measure_terrain_${Date.now()}`;
|
|
1702
|
+
this.htmlLabelId = l, this.htmlLabelPool.add(
|
|
1703
|
+
{ text: g },
|
|
1704
|
+
{
|
|
1705
|
+
id: l,
|
|
1706
|
+
lon: n,
|
|
1707
|
+
lat: r,
|
|
1708
|
+
height: o.height || 0,
|
|
1709
|
+
theme: "measure-terrainHeight",
|
|
1710
|
+
show: !0
|
|
1711
|
+
}
|
|
1712
|
+
), this.labelEntity = this.htmlLabelId;
|
|
1713
|
+
const a = {
|
|
1714
|
+
label: this.labelEntity,
|
|
1715
|
+
position: s,
|
|
1716
|
+
zeroPosition: c,
|
|
1717
|
+
line: this.lineEntity,
|
|
1718
|
+
terrainHeight: d,
|
|
1719
|
+
difference: m,
|
|
1720
|
+
clear: () => this.clear()
|
|
1721
|
+
};
|
|
1722
|
+
i.onComplete?.(a), this.stop();
|
|
1723
|
+
}, e.ScreenSpaceEventType.LEFT_CLICK);
|
|
1724
|
+
}
|
|
1725
|
+
stop() {
|
|
1726
|
+
this.handler && (this.handler.destroy(), this.handler = null);
|
|
1727
|
+
}
|
|
1728
|
+
clear() {
|
|
1729
|
+
this.stop(), this.lineEntity && (this.viewer.entities.remove(this.lineEntity), this.lineEntity = null), this.topPoint && (this.viewer.entities.remove(this.topPoint), this.topPoint = null), this.zeroPoint && (this.viewer.entities.remove(this.zeroPoint), this.zeroPoint = null), this.htmlLabelId && this.htmlLabelPool && (this.htmlLabelPool.removeByIds([this.htmlLabelId]), this.htmlLabelId = null);
|
|
1730
|
+
}
|
|
1731
|
+
rehydrate(i, e) {
|
|
1732
|
+
const t = this.Cesium, h = this.viewer, s = i.options || {}, o = (i.positions || []).map((w) => new t.Cartesian3(w[0], w[1], w[2]));
|
|
1733
|
+
if (o.length < 1) {
|
|
1734
|
+
const u = (i.data || {}).position;
|
|
1735
|
+
u && (Array.isArray(u) && u.length === 3 ? o.push(new t.Cartesian3(u[0], u[1], u[2])) : typeof u == "object" && u && "x" in u && "y" in u && "z" in u && o.push(new t.Cartesian3(u.x, u.y, u.z)));
|
|
1736
|
+
}
|
|
1737
|
+
if (o.length < 1) return;
|
|
1738
|
+
if (!this.htmlLabelPool) {
|
|
1739
|
+
const w = s.overlayContainerId || "html-label-container";
|
|
1740
|
+
this.htmlLabelPool = e || new k(t, h, w), this.htmlLabelPool.registerTheme("measure-terrainHeight", {
|
|
1741
|
+
createElement: (u, C) => {
|
|
1742
|
+
u.innerHTML = String(C?.data?.text || ""), u.style.background = "rgba(0,0,0,0.6)", u.style.color = "#fff", u.style.font = "14px sans-serif", u.style.padding = "4px 6px", u.style.borderRadius = "4px", u.style.whiteSpace = "pre";
|
|
1743
|
+
},
|
|
1744
|
+
options: { offset: { x: 0, y: -10 } }
|
|
1745
|
+
});
|
|
1746
|
+
}
|
|
1747
|
+
const d = o[0], n = t.Cartographic.fromCartesian(d), r = h.scene.globe.getHeight(new t.Cartographic(n.longitude, n.latitude, 0)) || 0, c = t.Math.toDegrees(n.longitude), p = t.Math.toDegrees(n.latitude), m = t.Cartesian3.fromDegrees(c, p, r);
|
|
1748
|
+
this.topPoint = h.entities.add({ position: d, point: { pixelSize: 8, color: s.color || t.Color.YELLOW, disableDepthTestDistance: Number.POSITIVE_INFINITY } }), this.zeroPoint = h.entities.add({ position: m, point: { pixelSize: 8, color: t.Color.YELLOW, disableDepthTestDistance: Number.POSITIVE_INFINITY } }), this.lineEntity = h.entities.add({ polyline: { positions: [m, d], width: s.width || 3, material: s.color || t.Color.YELLOW, depthFailMaterial: new t.PolylineDashMaterialProperty({ color: t.Color.RED, dashLength: 12, dashPattern: 255 }) } });
|
|
1749
|
+
const g = s.labelText || { height: "高差" }, l = (n.height || 0) - r, a = i.id + "_terrain";
|
|
1750
|
+
this.htmlLabelId = a, this.htmlLabelPool.add({ text: `${g.height}:${l.toFixed(2)} m` }, { id: a, lon: c, lat: p, height: n.height || 0, theme: "measure-terrainHeight", show: !0 });
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
class ve {
|
|
1754
|
+
Cesium;
|
|
1755
|
+
viewer;
|
|
1756
|
+
handler = null;
|
|
1757
|
+
entity = null;
|
|
1758
|
+
labelEntity = null;
|
|
1759
|
+
htmlLabelPool = null;
|
|
1760
|
+
htmlLabelId = null;
|
|
1761
|
+
constructor(i, e) {
|
|
1762
|
+
this.Cesium = i, this.viewer = e;
|
|
1763
|
+
}
|
|
1764
|
+
start(i) {
|
|
1765
|
+
this.clear();
|
|
1766
|
+
const e = this.Cesium, t = this.viewer;
|
|
1767
|
+
if (!this.htmlLabelPool) {
|
|
1768
|
+
const h = i.overlayContainerId || "html-label-container";
|
|
1769
|
+
this.htmlLabelPool = new k(e, t, h), this.htmlLabelPool.registerTheme("measure-coordinate", {
|
|
1770
|
+
createElement: (s, o) => {
|
|
1771
|
+
s.innerHTML = String(o?.data?.text || ""), s.style.background = "rgba(0,0,0,0.6)", s.style.color = "#fff", s.style.font = "14px sans-serif", s.style.padding = "4px 6px", s.style.borderRadius = "4px", s.style.whiteSpace = "pre";
|
|
1772
|
+
},
|
|
1773
|
+
options: { offset: { x: 0, y: -10 } }
|
|
1774
|
+
});
|
|
1775
|
+
}
|
|
1776
|
+
this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((h) => {
|
|
1777
|
+
const s = t.scene.pickPosition(h.position);
|
|
1778
|
+
if (!s) return;
|
|
1779
|
+
const o = e.Cartographic.fromCartesian(s), d = e.Math.toDegrees(o.longitude), n = e.Math.toDegrees(o.latitude), r = o.height || 0;
|
|
1780
|
+
this.entity = t.entities.add({
|
|
1781
|
+
position: s,
|
|
1782
|
+
point: {
|
|
1783
|
+
pixelSize: 10,
|
|
1784
|
+
color: i.color || e.Color.YELLOW,
|
|
1785
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
1786
|
+
}
|
|
1787
|
+
});
|
|
1788
|
+
const c = this.htmlLabelId || `measure_coordinate_${Date.now()}`;
|
|
1789
|
+
this.htmlLabelId = c;
|
|
1790
|
+
const p = i.labelText || { lng: "经", lat: "纬", height: "高" };
|
|
1791
|
+
this.htmlLabelPool.add(
|
|
1792
|
+
{ text: `${p.lng}:${d.toFixed(6)}
|
|
1793
|
+
${p.lat}:${n.toFixed(6)}
|
|
1794
|
+
${p.height}:${r.toFixed(2)} m` },
|
|
1795
|
+
{
|
|
1796
|
+
id: c,
|
|
1797
|
+
lon: d,
|
|
1798
|
+
lat: n,
|
|
1799
|
+
height: r,
|
|
1800
|
+
theme: "measure-coordinate",
|
|
1801
|
+
show: !0
|
|
1802
|
+
}
|
|
1803
|
+
), this.labelEntity = this.htmlLabelId;
|
|
1804
|
+
const m = {
|
|
1805
|
+
entity: this.entity,
|
|
1806
|
+
label: this.labelEntity,
|
|
1807
|
+
lnglat: { lng: d, lat: n, height: r },
|
|
1808
|
+
clear: () => this.clear()
|
|
1809
|
+
};
|
|
1810
|
+
i.onComplete?.(m), this.stop();
|
|
1811
|
+
}, e.ScreenSpaceEventType.LEFT_CLICK);
|
|
1812
|
+
}
|
|
1813
|
+
stop() {
|
|
1814
|
+
this.handler && (this.handler.destroy(), this.handler = null);
|
|
1815
|
+
}
|
|
1816
|
+
clear() {
|
|
1817
|
+
this.stop(), this.entity && (this.viewer.entities.remove(this.entity), this.entity = null), this.htmlLabelId && this.htmlLabelPool && (this.htmlLabelPool.removeByIds([this.htmlLabelId]), this.htmlLabelId = null);
|
|
1818
|
+
}
|
|
1819
|
+
rehydrate(i, e) {
|
|
1820
|
+
const t = this.Cesium, h = this.viewer, s = i.options || {}, o = (i.positions || []).map((l) => new t.Cartesian3(l[0], l[1], l[2]));
|
|
1821
|
+
if (!o.length) {
|
|
1822
|
+
const l = i.data?.lnglat;
|
|
1823
|
+
if (l && typeof l.lng == "number" && typeof l.lat == "number") {
|
|
1824
|
+
const a = t.Cartesian3.fromDegrees(l.lng, l.lat, l.height || 0);
|
|
1825
|
+
o.push(a);
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
if (!o.length) return;
|
|
1829
|
+
if (!this.htmlLabelPool) {
|
|
1830
|
+
const l = s.overlayContainerId || "html-label-container";
|
|
1831
|
+
this.htmlLabelPool = e || new k(t, h, l), this.htmlLabelPool.registerTheme("measure-coordinate", {
|
|
1832
|
+
createElement: (a, w) => {
|
|
1833
|
+
a.innerHTML = String(w?.data?.text || ""), a.style.background = "rgba(0,0,0,0.6)", a.style.color = "#fff", a.style.font = "14px sans-serif", a.style.padding = "4px 6px", a.style.borderRadius = "4px", a.style.whiteSpace = "pre";
|
|
1834
|
+
},
|
|
1835
|
+
options: { offset: { x: 0, y: -10 } }
|
|
1836
|
+
});
|
|
1837
|
+
}
|
|
1838
|
+
const d = o[0], n = t.Cartographic.fromCartesian(d), r = t.Math.toDegrees(n.longitude), c = t.Math.toDegrees(n.latitude), p = n.height || 0;
|
|
1839
|
+
this.entity = h.entities.add({ position: d, point: { pixelSize: 10, color: s.color || t.Color.YELLOW, disableDepthTestDistance: Number.POSITIVE_INFINITY } });
|
|
1840
|
+
const m = i.id + "_coord";
|
|
1841
|
+
this.htmlLabelId = m;
|
|
1842
|
+
const g = s.labelText || { lng: "经", lat: "纬", height: "高" };
|
|
1843
|
+
this.htmlLabelPool.add({ text: `${g.lng}:${r.toFixed(6)}
|
|
1844
|
+
${g.lat}:${c.toFixed(6)}
|
|
1845
|
+
${g.height}:${p.toFixed(2)} m` }, { id: m, lon: r, lat: c, height: p, theme: "measure-coordinate", show: !0 });
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1848
|
+
class Le {
|
|
1849
|
+
Cesium;
|
|
1850
|
+
viewer;
|
|
1851
|
+
handler = null;
|
|
1852
|
+
startPoint = null;
|
|
1853
|
+
endPoint = null;
|
|
1854
|
+
secondPoint = null;
|
|
1855
|
+
currentCorners = [];
|
|
1856
|
+
edgeEntities = [];
|
|
1857
|
+
pointEntities = [];
|
|
1858
|
+
previewEdgeEntity = null;
|
|
1859
|
+
previewPointEntities = [];
|
|
1860
|
+
entity = null;
|
|
1861
|
+
labelEntity = null;
|
|
1862
|
+
primitive = null;
|
|
1863
|
+
previewEntity = null;
|
|
1864
|
+
htmlLabelPool = null;
|
|
1865
|
+
htmlLabelId = null;
|
|
1866
|
+
segmentLabelIds = [];
|
|
1867
|
+
previewLabelId = null;
|
|
1868
|
+
constructor(i, e) {
|
|
1869
|
+
this.Cesium = i, this.viewer = e;
|
|
1870
|
+
}
|
|
1871
|
+
start(i) {
|
|
1872
|
+
this.clear();
|
|
1873
|
+
const e = this.Cesium, t = this.viewer;
|
|
1874
|
+
if (!this.htmlLabelPool) {
|
|
1875
|
+
const h = i.overlayContainerId || "html-label-container";
|
|
1876
|
+
this.htmlLabelPool = new k(e, t, h), this.htmlLabelPool.registerTheme("measure-rectangle", {
|
|
1877
|
+
createElement: (s, o) => {
|
|
1878
|
+
s.innerHTML = String(o?.data?.text || ""), s.style.background = "rgba(0,0,0,0.6)", s.style.color = "#fff", s.style.font = "14px sans-serif", s.style.padding = "4px 6px", s.style.borderRadius = "4px", s.style.whiteSpace = "pre";
|
|
1879
|
+
},
|
|
1880
|
+
options: { offset: { x: 0, y: -10 } }
|
|
1881
|
+
}), this.htmlLabelPool.registerTheme("measure-rectangle-seg", {
|
|
1882
|
+
createElement: (s, o) => {
|
|
1883
|
+
s.innerHTML = String(o?.data?.text || ""), s.style.background = "rgba(0,0,0,0.6)", s.style.color = "#fff", s.style.font = "14px sans-serif", s.style.padding = "4px 6px", s.style.borderRadius = "4px", s.style.whiteSpace = "pre";
|
|
1884
|
+
},
|
|
1885
|
+
options: { offset: { x: 0, y: -10 } }
|
|
1886
|
+
});
|
|
1887
|
+
}
|
|
1888
|
+
this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((h) => {
|
|
1889
|
+
const s = t.scene.pickPosition(h.position);
|
|
1890
|
+
if (!s) return;
|
|
1891
|
+
if (!this.startPoint) {
|
|
1892
|
+
this.startPoint = s;
|
|
1893
|
+
return;
|
|
1894
|
+
}
|
|
1895
|
+
if (!this.secondPoint) {
|
|
1896
|
+
this.secondPoint = s, this.endPoint = s;
|
|
1897
|
+
return;
|
|
1898
|
+
}
|
|
1899
|
+
const o = s, d = this.computeRectangle(this.startPoint, this.secondPoint, o);
|
|
1900
|
+
if (!d) {
|
|
1901
|
+
this.stop();
|
|
1902
|
+
return;
|
|
1903
|
+
}
|
|
1904
|
+
this.stop();
|
|
1905
|
+
const { corners: n, center: r, width: c, height: p, area: m } = d;
|
|
1906
|
+
this.previewEntity && (t.entities.remove(this.previewEntity), this.previewEntity = null), this.primitive && (t.scene.primitives.remove(this.primitive), this.primitive = null), this.entity && (t.entities.remove(this.entity), this.entity = null);
|
|
1907
|
+
const g = this.htmlLabelId || `measure_rectangle_${Date.now()}`;
|
|
1908
|
+
this.htmlLabelId = g;
|
|
1909
|
+
const l = e.Cartographic.fromCartesian(r), a = i.labelText || { width: "宽", heightLabel: "高", area: "面积", side: "边长" };
|
|
1910
|
+
this.previewLabelId && this.htmlLabelPool && (this.htmlLabelPool.removeByIds([this.previewLabelId]), this.previewLabelId = null), this.htmlLabelPool.add(
|
|
1911
|
+
{ text: `${a.width}:${c.toFixed(2)} m
|
|
1912
|
+
${a.heightLabel}:${p.toFixed(2)} m
|
|
1913
|
+
${a.area}:${m.toFixed(2)} m²` },
|
|
1914
|
+
{
|
|
1915
|
+
id: g,
|
|
1916
|
+
lon: e.Math.toDegrees(l.longitude),
|
|
1917
|
+
lat: e.Math.toDegrees(l.latitude),
|
|
1918
|
+
height: l.height || 0,
|
|
1919
|
+
theme: "measure-rectangle",
|
|
1920
|
+
show: !0
|
|
1921
|
+
}
|
|
1922
|
+
);
|
|
1923
|
+
const w = [
|
|
1924
|
+
[n[0], n[1]],
|
|
1925
|
+
[n[1], n[2]],
|
|
1926
|
+
[n[2], n[3]],
|
|
1927
|
+
[n[3], n[0]]
|
|
1928
|
+
];
|
|
1929
|
+
for (let A = 0; A < w.length; A++) {
|
|
1930
|
+
const [I, S] = w[A], R = A === 0 || A === 2 ? c : p, O = new e.Cartesian3((I.x + S.x) / 2, (I.y + S.y) / 2, (I.z + S.z) / 2), F = e.Cartographic.fromCartesian(O), N = `measure_rectangle_seg_${Date.now()}_${A}`;
|
|
1931
|
+
this.segmentLabelIds.push(N), this.htmlLabelPool.add(
|
|
1932
|
+
{ text: `${a.side}:${Number(R).toFixed(2)} m` },
|
|
1933
|
+
{
|
|
1934
|
+
id: N,
|
|
1935
|
+
lon: e.Math.toDegrees(F.longitude),
|
|
1936
|
+
lat: e.Math.toDegrees(F.latitude),
|
|
1937
|
+
height: F.height || 0,
|
|
1938
|
+
theme: "measure-rectangle-seg",
|
|
1939
|
+
show: !0
|
|
1940
|
+
}
|
|
1941
|
+
);
|
|
1942
|
+
}
|
|
1943
|
+
const u = this.buildSurfaceRectanglePositions(n), C = new e.PolygonHierarchy(u), L = new e.PolygonGeometry({
|
|
1944
|
+
polygonHierarchy: C,
|
|
1945
|
+
vertexFormat: e.MaterialAppearance.VERTEX_FORMAT,
|
|
1946
|
+
perPositionHeight: !0,
|
|
1947
|
+
arcType: e.ArcType.NONE
|
|
1948
|
+
}), f = new e.GeometryInstance({ geometry: L }), b = i.color || e.Color.YELLOW.withAlpha(0.4), y = i.color && i.color.withAlpha ? i.color.withAlpha(0.25) : e.Color.RED.withAlpha(0.4);
|
|
1949
|
+
this.primitive = new e.Primitive({
|
|
1950
|
+
geometryInstances: f,
|
|
1951
|
+
appearance: new e.MaterialAppearance({
|
|
1952
|
+
material: e.Material.fromType("Color", { color: b }),
|
|
1953
|
+
translucent: !0,
|
|
1954
|
+
closed: !0
|
|
1955
|
+
}),
|
|
1956
|
+
depthFailAppearance: new e.MaterialAppearance({
|
|
1957
|
+
material: e.Material.fromType("Color", { color: y }),
|
|
1958
|
+
translucent: !0,
|
|
1959
|
+
closed: !0
|
|
1960
|
+
})
|
|
1961
|
+
}), t.scene.primitives.add(this.primitive);
|
|
1962
|
+
const v = i.lineColor || i.color || e.Color.YELLOW, E = (i.dashLineColor || i.lineColor || i.color || e.Color.RED).withAlpha?.(0.9) || e.Color.RED, x = [...u, u[0]], D = t.entities.add({
|
|
1963
|
+
polyline: {
|
|
1964
|
+
positions: x,
|
|
1965
|
+
width: i.width || 2,
|
|
1966
|
+
material: v,
|
|
1967
|
+
clampToGround: !1,
|
|
1968
|
+
arcType: e.ArcType.NONE,
|
|
1969
|
+
depthFailMaterial: new e.PolylineDashMaterialProperty({
|
|
1970
|
+
color: E,
|
|
1971
|
+
dashLength: 12,
|
|
1972
|
+
dashPattern: 255
|
|
1973
|
+
})
|
|
1974
|
+
}
|
|
1975
|
+
});
|
|
1976
|
+
this.edgeEntities.push(D);
|
|
1977
|
+
const M = i.pointColor || i.color || e.Color.YELLOW;
|
|
1978
|
+
for (const A of n) {
|
|
1979
|
+
const I = t.entities.add({
|
|
1980
|
+
position: A,
|
|
1981
|
+
point: {
|
|
1982
|
+
pixelSize: 8,
|
|
1983
|
+
color: M,
|
|
1984
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
1985
|
+
}
|
|
1986
|
+
});
|
|
1987
|
+
this.pointEntities.push(I);
|
|
1988
|
+
}
|
|
1989
|
+
const P = {
|
|
1990
|
+
entity: this.primitive,
|
|
1991
|
+
label: this.labelEntity,
|
|
1992
|
+
positions: [this.startPoint, this.secondPoint, o],
|
|
1993
|
+
width: c,
|
|
1994
|
+
height: p,
|
|
1995
|
+
area: m,
|
|
1996
|
+
clear: () => this.clear()
|
|
1997
|
+
};
|
|
1998
|
+
i.onComplete?.(P);
|
|
1999
|
+
}, e.ScreenSpaceEventType.LEFT_CLICK), this.handler.setInputAction((h) => {
|
|
2000
|
+
const s = t.scene.pickPosition(h.endPosition);
|
|
2001
|
+
if (!s) return;
|
|
2002
|
+
if (this.startPoint && !this.secondPoint) {
|
|
2003
|
+
if (this.endPoint = s, !this.previewEdgeEntity) {
|
|
2004
|
+
const w = i.lineColor || i.color || e.Color.YELLOW, u = (i.dashLineColor || i.lineColor || i.color || e.Color.RED).withAlpha?.(0.9) || e.Color.RED;
|
|
2005
|
+
this.previewEdgeEntity = t.entities.add({
|
|
2006
|
+
polyline: {
|
|
2007
|
+
positions: new e.CallbackProperty(() => !this.startPoint || !this.endPoint ? [] : [this.startPoint, this.endPoint], !1),
|
|
2008
|
+
width: i.width || 2,
|
|
2009
|
+
material: w,
|
|
2010
|
+
clampToGround: !1,
|
|
2011
|
+
arcType: e.ArcType.NONE,
|
|
2012
|
+
depthFailMaterial: new e.PolylineDashMaterialProperty({
|
|
2013
|
+
color: u,
|
|
2014
|
+
dashLength: 12,
|
|
2015
|
+
dashPattern: 255
|
|
2016
|
+
})
|
|
2017
|
+
}
|
|
2018
|
+
});
|
|
2019
|
+
const C = i.pointColor || i.color || e.Color.YELLOW, L = t.entities.add({
|
|
2020
|
+
position: this.startPoint,
|
|
2021
|
+
point: {
|
|
2022
|
+
pixelSize: 8,
|
|
2023
|
+
color: C,
|
|
2024
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
2025
|
+
}
|
|
2026
|
+
}), f = t.entities.add({
|
|
2027
|
+
position: new e.CallbackProperty(() => this.endPoint || this.startPoint, !1),
|
|
2028
|
+
point: {
|
|
2029
|
+
pixelSize: 8,
|
|
2030
|
+
color: C,
|
|
2031
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
2032
|
+
}
|
|
2033
|
+
});
|
|
2034
|
+
this.previewPointEntities.push(L, f);
|
|
2035
|
+
}
|
|
2036
|
+
return;
|
|
2037
|
+
}
|
|
2038
|
+
if (!this.startPoint || !this.secondPoint) return;
|
|
2039
|
+
const o = this.computeRectangle(this.startPoint, this.secondPoint, s);
|
|
2040
|
+
if (!o) return;
|
|
2041
|
+
const { corners: d, center: n, width: r, height: c, area: p } = o, m = this.buildSurfaceRectanglePositions(d);
|
|
2042
|
+
this.currentCorners = m;
|
|
2043
|
+
const g = e.Cartographic.fromCartesian(n), l = this.previewLabelId || "measure_rectangle_preview";
|
|
2044
|
+
this.previewLabelId = l;
|
|
2045
|
+
const a = i.labelText || { width: "宽", heightLabel: "高", area: "面积" };
|
|
2046
|
+
if (this.htmlLabelPool.add(
|
|
2047
|
+
{ text: `${a.width}:${r.toFixed(2)} m
|
|
2048
|
+
${a.heightLabel}:${c.toFixed(2)} m
|
|
2049
|
+
${a.area}:${p.toFixed(2)} m²` },
|
|
2050
|
+
{
|
|
2051
|
+
id: l,
|
|
2052
|
+
lon: e.Math.toDegrees(g.longitude),
|
|
2053
|
+
lat: e.Math.toDegrees(g.latitude),
|
|
2054
|
+
height: g.height || 0,
|
|
2055
|
+
theme: "measure-rectangle",
|
|
2056
|
+
show: !0
|
|
2057
|
+
}
|
|
2058
|
+
), !this.previewEntity) {
|
|
2059
|
+
const w = i.color || e.Color.YELLOW.withAlpha(0.4);
|
|
2060
|
+
this.previewEntity = t.entities.add({
|
|
2061
|
+
polygon: {
|
|
2062
|
+
hierarchy: new e.CallbackProperty(() => {
|
|
2063
|
+
if (!(!this.startPoint || !this.secondPoint || !this.currentCorners.length))
|
|
2064
|
+
return new e.PolygonHierarchy(this.currentCorners);
|
|
2065
|
+
}, !1),
|
|
2066
|
+
material: w,
|
|
2067
|
+
perPositionHeight: !0,
|
|
2068
|
+
arcType: e.ArcType.NONE
|
|
2069
|
+
}
|
|
2070
|
+
});
|
|
2071
|
+
}
|
|
2072
|
+
}, e.ScreenSpaceEventType.MOUSE_MOVE);
|
|
2073
|
+
}
|
|
2074
|
+
stop() {
|
|
2075
|
+
this.handler && (this.handler.destroy(), this.handler = null);
|
|
2076
|
+
}
|
|
2077
|
+
clear() {
|
|
2078
|
+
if (this.stop(), this.entity && (this.viewer.entities.remove(this.entity), this.entity = null), this.previewEntity && (this.viewer.entities.remove(this.previewEntity), this.previewEntity = null), this.previewEdgeEntity && (this.viewer.entities.remove(this.previewEdgeEntity), this.previewEdgeEntity = null), this.previewPointEntities.length) {
|
|
2079
|
+
for (const i of this.previewPointEntities)
|
|
2080
|
+
try {
|
|
2081
|
+
this.viewer.entities.remove(i);
|
|
2082
|
+
} catch {
|
|
2083
|
+
}
|
|
2084
|
+
this.previewPointEntities = [];
|
|
2085
|
+
}
|
|
2086
|
+
if (this.edgeEntities.length) {
|
|
2087
|
+
for (const i of this.edgeEntities)
|
|
2088
|
+
try {
|
|
2089
|
+
this.viewer.entities.remove(i);
|
|
2090
|
+
} catch {
|
|
2091
|
+
}
|
|
2092
|
+
this.edgeEntities = [];
|
|
2093
|
+
}
|
|
2094
|
+
if (this.pointEntities.length) {
|
|
2095
|
+
for (const i of this.pointEntities)
|
|
2096
|
+
try {
|
|
2097
|
+
this.viewer.entities.remove(i);
|
|
2098
|
+
} catch {
|
|
2099
|
+
}
|
|
2100
|
+
this.pointEntities = [];
|
|
2101
|
+
}
|
|
2102
|
+
this.primitive && (this.viewer.scene.primitives.remove(this.primitive), this.primitive = null), this.htmlLabelId && this.htmlLabelPool && (this.htmlLabelPool.removeByIds([this.htmlLabelId]), this.htmlLabelId = null), this.previewLabelId && this.htmlLabelPool && (this.htmlLabelPool.removeByIds([this.previewLabelId]), this.previewLabelId = null), this.segmentLabelIds.length && this.htmlLabelPool && this.htmlLabelPool.removeByIds(this.segmentLabelIds.slice()), this.segmentLabelIds = [], this.startPoint = null, this.endPoint = null, this.secondPoint = null, this.currentCorners = [];
|
|
2103
|
+
}
|
|
2104
|
+
buildSurfaceRectanglePositions(i) {
|
|
2105
|
+
return !i || !i.length ? [] : i.slice();
|
|
2106
|
+
}
|
|
2107
|
+
rehydrate(i, e) {
|
|
2108
|
+
const t = this.Cesium, h = this.viewer, s = i.options || {}, o = (i.positions || []).map((M) => new t.Cartesian3(M[0], M[1], M[2]));
|
|
2109
|
+
if (o.length < 3) return;
|
|
2110
|
+
if (!this.htmlLabelPool) {
|
|
2111
|
+
const M = s.overlayContainerId || "html-label-container";
|
|
2112
|
+
this.htmlLabelPool = e || new k(t, h, M), this.htmlLabelPool.registerTheme("measure-rectangle", {
|
|
2113
|
+
createElement: (P, A) => {
|
|
2114
|
+
P.innerHTML = String(A?.data?.text || ""), P.style.background = "rgba(0,0,0,0.6)", P.style.color = "#fff", P.style.font = "14px sans-serif", P.style.padding = "4px 6px", P.style.borderRadius = "4px", P.style.whiteSpace = "pre";
|
|
2115
|
+
},
|
|
2116
|
+
options: { offset: { x: 0, y: -10 } }
|
|
2117
|
+
}), this.htmlLabelPool.registerTheme("measure-rectangle-seg", {
|
|
2118
|
+
createElement: (P, A) => {
|
|
2119
|
+
P.innerHTML = String(A?.data?.text || ""), P.style.background = "rgba(0,0,0,0.6)", P.style.color = "#fff", P.style.font = "14px sans-serif", P.style.padding = "4px 6px", P.style.borderRadius = "4px", P.style.whiteSpace = "pre";
|
|
2120
|
+
},
|
|
2121
|
+
options: { offset: { x: 0, y: -10 } }
|
|
2122
|
+
});
|
|
2123
|
+
}
|
|
2124
|
+
const d = this.computeRectangle(o[0], o[1], o[2]);
|
|
2125
|
+
if (!d) return;
|
|
2126
|
+
const n = d.corners, r = d.center, c = d.width, p = d.height, m = d.area, g = t.Cartographic.fromCartesian(r), l = i.id + "_rectangle", a = s.labelText || { width: "宽", heightLabel: "高", area: "面积", side: "边长" };
|
|
2127
|
+
this.htmlLabelId = l, this.htmlLabelPool.add({ text: `${a.width}:${c.toFixed(2)} m
|
|
2128
|
+
${a.heightLabel}:${p.toFixed(2)} m
|
|
2129
|
+
${a.area}:${m.toFixed(2)} m²` }, { id: l, lon: t.Math.toDegrees(g.longitude), lat: t.Math.toDegrees(g.latitude), height: g.height || 0, theme: "measure-rectangle", show: !0 });
|
|
2130
|
+
const w = [
|
|
2131
|
+
[n[0], n[1]],
|
|
2132
|
+
[n[1], n[2]],
|
|
2133
|
+
[n[2], n[3]],
|
|
2134
|
+
[n[3], n[0]]
|
|
2135
|
+
];
|
|
2136
|
+
for (let M = 0; M < w.length; M++) {
|
|
2137
|
+
const [P, A] = w[M], I = M === 0 || M === 2 ? c : p, S = new t.Cartesian3((P.x + A.x) / 2, (P.y + A.y) / 2, (P.z + A.z) / 2), R = t.Cartographic.fromCartesian(S), O = i.id + `_rectangle_seg_${M}`;
|
|
2138
|
+
this.segmentLabelIds.push(O), this.htmlLabelPool.add({ text: `${a.side}:${Number(I).toFixed(2)} m` }, { id: O, lon: t.Math.toDegrees(R.longitude), lat: t.Math.toDegrees(R.latitude), height: R.height || 0, theme: "measure-rectangle-seg", show: !0 });
|
|
2139
|
+
}
|
|
2140
|
+
const u = new t.PolygonHierarchy(n), C = new t.PolygonGeometry({
|
|
2141
|
+
polygonHierarchy: u,
|
|
2142
|
+
vertexFormat: t.MaterialAppearance.VERTEX_FORMAT,
|
|
2143
|
+
perPositionHeight: !0,
|
|
2144
|
+
arcType: t.ArcType.NONE
|
|
2145
|
+
}), L = new t.GeometryInstance({ geometry: C }), f = s.color || t.Color.YELLOW.withAlpha(0.4), b = s.color && s.color.withAlpha ? s.color.withAlpha(0.25) : t.Color.RED.withAlpha(0.4), y = new t.Primitive({
|
|
2146
|
+
geometryInstances: L,
|
|
2147
|
+
appearance: new t.MaterialAppearance({ material: t.Material.fromType("Color", { color: f }), translucent: !0, closed: !0 }),
|
|
2148
|
+
depthFailAppearance: new t.MaterialAppearance({ material: t.Material.fromType("Color", { color: b }), translucent: !0, closed: !0 })
|
|
2149
|
+
});
|
|
2150
|
+
this.primitive = y, h.scene.primitives.add(this.primitive);
|
|
2151
|
+
const v = s.lineColor || f, E = [...n, n[0]], x = h.entities.add({
|
|
2152
|
+
polyline: {
|
|
2153
|
+
positions: E,
|
|
2154
|
+
width: s.width || 2,
|
|
2155
|
+
material: v,
|
|
2156
|
+
clampToGround: !1,
|
|
2157
|
+
arcType: t.ArcType.NONE
|
|
2158
|
+
}
|
|
2159
|
+
});
|
|
2160
|
+
this.edgeEntities.push(x);
|
|
2161
|
+
const D = s.pointColor || f;
|
|
2162
|
+
for (const M of n) {
|
|
2163
|
+
const P = h.entities.add({
|
|
2164
|
+
position: M,
|
|
2165
|
+
point: {
|
|
2166
|
+
pixelSize: 8,
|
|
2167
|
+
color: D,
|
|
2168
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
2169
|
+
}
|
|
2170
|
+
});
|
|
2171
|
+
this.pointEntities.push(P);
|
|
2172
|
+
}
|
|
2173
|
+
}
|
|
2174
|
+
computeRectangle(i, e, t) {
|
|
2175
|
+
const h = this.Cesium, s = new h.EllipsoidTangentPlane(i, h.Ellipsoid.WGS84), o = s.projectPointsOntoPlane([i, e, t]);
|
|
2176
|
+
if (!o || o.length < 3) return null;
|
|
2177
|
+
const d = o[0], n = o[1], r = o[2], c = n.x - d.x, p = n.y - d.y, m = Math.sqrt(c * c + p * p);
|
|
2178
|
+
if (!m) return null;
|
|
2179
|
+
const g = c / m, a = -(p / m), w = g, u = r.x - n.x, C = r.y - n.y, L = u * a + C * w;
|
|
2180
|
+
if (!L) return null;
|
|
2181
|
+
const f = new h.Cartesian2(n.x + a * L, n.y + w * L), b = new h.Cartesian2(d.x + a * L, d.y + w * L), y = s.projectPointsOntoEllipsoid([d, n, f, b]);
|
|
2182
|
+
if (!y || y.length < 4) return null;
|
|
2183
|
+
const v = y, E = v[0], x = v[2], D = Math.abs(m), M = Math.abs(L), P = new h.Cartesian3(
|
|
2184
|
+
(E.x + x.x) / 2,
|
|
2185
|
+
(E.y + x.y) / 2,
|
|
2186
|
+
(E.z + x.z) / 2
|
|
2187
|
+
), I = new h.EllipsoidTangentPlane(P, h.Ellipsoid.WGS84).projectPointsOntoPlane(v);
|
|
2188
|
+
let S = 0;
|
|
2189
|
+
for (let O = 0; O < I.length; O++) {
|
|
2190
|
+
const F = (O + 1) % I.length;
|
|
2191
|
+
S += I[O].x * I[F].y - I[F].x * I[O].y;
|
|
2192
|
+
}
|
|
2193
|
+
const R = Math.abs(S) / 2;
|
|
2194
|
+
return { corners: v, center: P, width: D, height: M, area: R };
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
class Ee {
|
|
2198
|
+
Cesium;
|
|
2199
|
+
viewer;
|
|
2200
|
+
handler = null;
|
|
2201
|
+
entity = null;
|
|
2202
|
+
positions = [];
|
|
2203
|
+
labelEntity = null;
|
|
2204
|
+
currentPoints = [];
|
|
2205
|
+
primitive = null;
|
|
2206
|
+
previewEntity = null;
|
|
2207
|
+
edgeEntities = [];
|
|
2208
|
+
pointEntities = [];
|
|
2209
|
+
previewEdgeEntity = null;
|
|
2210
|
+
previewPointEntities = [];
|
|
2211
|
+
htmlLabelPool = null;
|
|
2212
|
+
htmlLabelId = null;
|
|
2213
|
+
segmentLabelIds = [];
|
|
2214
|
+
previewLabelId = null;
|
|
2215
|
+
constructor(i, e) {
|
|
2216
|
+
this.Cesium = i, this.viewer = e;
|
|
2217
|
+
}
|
|
2218
|
+
start(i) {
|
|
2219
|
+
this.clear();
|
|
2220
|
+
const e = this.Cesium, t = this.viewer, h = Math.max(i.sides || 6, 6);
|
|
2221
|
+
if (!this.htmlLabelPool) {
|
|
2222
|
+
const s = i.overlayContainerId || "html-label-container";
|
|
2223
|
+
this.htmlLabelPool = new k(e, t, s), this.htmlLabelPool.registerTheme("measure-regular", {
|
|
2224
|
+
createElement: (o, d) => {
|
|
2225
|
+
o.innerHTML = String(d?.data?.text || ""), o.style.background = "rgba(0,0,0,0.6)", o.style.color = "#fff", o.style.font = "14px sans-serif", o.style.padding = "4px 6px", o.style.borderRadius = "4px", o.style.whiteSpace = "pre";
|
|
2226
|
+
},
|
|
2227
|
+
options: { offset: { x: 0, y: -10 } }
|
|
2228
|
+
}), this.htmlLabelPool.registerTheme("measure-regular-seg", {
|
|
2229
|
+
createElement: (o, d) => {
|
|
2230
|
+
o.innerHTML = String(d?.data?.text || ""), o.style.background = "rgba(0,0,0,0.6)", o.style.color = "#fff", o.style.font = "14px sans-serif", o.style.padding = "4px 6px", o.style.borderRadius = "4px", o.style.whiteSpace = "pre";
|
|
2231
|
+
},
|
|
2232
|
+
options: { offset: { x: 0, y: -10 } }
|
|
2233
|
+
});
|
|
2234
|
+
}
|
|
2235
|
+
this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((s) => {
|
|
2236
|
+
const o = t.scene.pickPosition(s.position);
|
|
2237
|
+
if (o && (this.positions.push(o), this.positions.length === 2)) {
|
|
2238
|
+
this.stop();
|
|
2239
|
+
const d = this.positions[0], n = this.positions[1], r = e.Cartesian3.distance(d, n), c = this.buildRegularPolygonPoints(d, r, h);
|
|
2240
|
+
this.previewEntity && (t.entities.remove(this.previewEntity), this.previewEntity = null), this.primitive && (t.scene.primitives.remove(this.primitive), this.primitive = null);
|
|
2241
|
+
const p = new e.PolygonHierarchy(c), m = new e.PolygonGeometry({
|
|
2242
|
+
polygonHierarchy: p,
|
|
2243
|
+
vertexFormat: e.MaterialAppearance.VERTEX_FORMAT,
|
|
2244
|
+
perPositionHeight: !0,
|
|
2245
|
+
arcType: e.ArcType.NONE
|
|
2246
|
+
}), g = new e.GeometryInstance({ geometry: m }), l = i.color || e.Color.YELLOW.withAlpha(0.4), a = i.color && i.color.withAlpha ? i.color.withAlpha(0.25) : e.Color.RED.withAlpha(0.4);
|
|
2247
|
+
this.primitive = new e.Primitive({
|
|
2248
|
+
geometryInstances: g,
|
|
2249
|
+
appearance: new e.MaterialAppearance({
|
|
2250
|
+
material: e.Material.fromType("Color", { color: l }),
|
|
2251
|
+
translucent: !0,
|
|
2252
|
+
closed: !0
|
|
2253
|
+
}),
|
|
2254
|
+
depthFailAppearance: new e.MaterialAppearance({
|
|
2255
|
+
material: e.Material.fromType("Color", { color: a }),
|
|
2256
|
+
translucent: !0,
|
|
2257
|
+
closed: !0
|
|
2258
|
+
})
|
|
2259
|
+
}), t.scene.primitives.add(this.primitive);
|
|
2260
|
+
const w = i.lineColor || l, u = (i.dashLineColor || i.lineColor || i.color || e.Color.RED).withAlpha?.(0.9) || e.Color.RED, C = c.slice(), L = t.entities.add({
|
|
2261
|
+
polyline: {
|
|
2262
|
+
positions: C,
|
|
2263
|
+
width: i.width || 2,
|
|
2264
|
+
material: w,
|
|
2265
|
+
clampToGround: !1,
|
|
2266
|
+
arcType: e.ArcType.NONE,
|
|
2267
|
+
depthFailMaterial: new e.PolylineDashMaterialProperty({
|
|
2268
|
+
color: u,
|
|
2269
|
+
dashLength: 12,
|
|
2270
|
+
dashPattern: 255
|
|
2271
|
+
})
|
|
2272
|
+
}
|
|
2273
|
+
});
|
|
2274
|
+
this.edgeEntities.push(L);
|
|
2275
|
+
const f = i.pointColor || l, b = c.slice(0, c.length - 1);
|
|
2276
|
+
for (const P of b) {
|
|
2277
|
+
const A = t.entities.add({
|
|
2278
|
+
position: P,
|
|
2279
|
+
point: {
|
|
2280
|
+
pixelSize: 8,
|
|
2281
|
+
color: f,
|
|
2282
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
2283
|
+
}
|
|
2284
|
+
});
|
|
2285
|
+
this.pointEntities.push(A);
|
|
2286
|
+
}
|
|
2287
|
+
const y = this.computeAreaByPlane(c), v = e.Cartographic.fromCartesian(d), E = this.htmlLabelId || `measure_regular_${Date.now()}`;
|
|
2288
|
+
this.htmlLabelId = E;
|
|
2289
|
+
const x = i.labelText || { sides: "边数", radius: "半径", circumference: "周长", area: "面积", side: "边长" };
|
|
2290
|
+
this.previewLabelId && this.htmlLabelPool && (this.htmlLabelPool.removeByIds([this.previewLabelId]), this.previewLabelId = null);
|
|
2291
|
+
let D = 0;
|
|
2292
|
+
for (let P = 1; P < c.length; P++) {
|
|
2293
|
+
const A = c[P - 1], I = c[P], S = e.Cartographic.fromCartesian(A), R = e.Cartographic.fromCartesian(I), F = new e.EllipsoidGeodesic(S, R).surfaceDistance;
|
|
2294
|
+
D += F;
|
|
2295
|
+
const N = new e.Cartesian3((A.x + I.x) / 2, (A.y + I.y) / 2, (A.z + I.z) / 2), z = e.Cartographic.fromCartesian(N), Q = `measure_regular_seg_${Date.now()}_${P - 1}`;
|
|
2296
|
+
this.segmentLabelIds.push(Q), this.htmlLabelPool.add(
|
|
2297
|
+
{ text: `${x.side}:${F.toFixed(2)} m` },
|
|
2298
|
+
{
|
|
2299
|
+
id: Q,
|
|
2300
|
+
lon: e.Math.toDegrees(z.longitude),
|
|
2301
|
+
lat: e.Math.toDegrees(z.latitude),
|
|
2302
|
+
height: z.height || 0,
|
|
2303
|
+
theme: "measure-regular-seg",
|
|
2304
|
+
show: !0
|
|
2305
|
+
}
|
|
2306
|
+
);
|
|
2307
|
+
}
|
|
2308
|
+
this.htmlLabelPool.add(
|
|
2309
|
+
{ text: `${x.sides}:${h}
|
|
2310
|
+
${x.radius}:${r.toFixed(2)} m
|
|
2311
|
+
${x.circumference}:${D.toFixed(2)} m
|
|
2312
|
+
${x.area}:${y.toFixed(2)} m²` },
|
|
2313
|
+
{
|
|
2314
|
+
id: E,
|
|
2315
|
+
lon: e.Math.toDegrees(v.longitude),
|
|
2316
|
+
lat: e.Math.toDegrees(v.latitude),
|
|
2317
|
+
height: v.height || 0,
|
|
2318
|
+
theme: "measure-regular",
|
|
2319
|
+
show: !0
|
|
2320
|
+
}
|
|
2321
|
+
);
|
|
2322
|
+
const M = {
|
|
2323
|
+
entity: this.primitive,
|
|
2324
|
+
label: this.labelEntity,
|
|
2325
|
+
positions: c,
|
|
2326
|
+
radius: r,
|
|
2327
|
+
sides: h,
|
|
2328
|
+
perimeter: D,
|
|
2329
|
+
area: y,
|
|
2330
|
+
clear: () => this.clear()
|
|
2331
|
+
};
|
|
2332
|
+
i.onComplete?.(M);
|
|
2333
|
+
}
|
|
2334
|
+
}, e.ScreenSpaceEventType.LEFT_CLICK), this.handler.setInputAction((s) => {
|
|
2335
|
+
if (this.positions.length !== 1) return;
|
|
2336
|
+
const o = this.positions[0], d = t.camera.getPickRay(s.endPosition), n = t.scene.globe.pick(d, t.scene);
|
|
2337
|
+
if (!n) return;
|
|
2338
|
+
const r = e.Cartesian3.distance(o, n);
|
|
2339
|
+
if (this.currentPoints = this.buildRegularPolygonPoints(o, r, h), !this.previewEntity) {
|
|
2340
|
+
const a = i.color || e.Color.YELLOW.withAlpha(0.4);
|
|
2341
|
+
this.previewEntity = t.entities.add({
|
|
2342
|
+
polygon: {
|
|
2343
|
+
hierarchy: new e.CallbackProperty(() => {
|
|
2344
|
+
if (!(!this.currentPoints || this.currentPoints.length === 0))
|
|
2345
|
+
return new e.PolygonHierarchy(this.currentPoints);
|
|
2346
|
+
}, !1),
|
|
2347
|
+
material: a,
|
|
2348
|
+
perPositionHeight: !0,
|
|
2349
|
+
arcType: e.ArcType.NONE
|
|
2350
|
+
}
|
|
2351
|
+
});
|
|
2352
|
+
const w = i.lineColor || i.color || e.Color.YELLOW, u = (i.dashLineColor || i.lineColor || i.color || e.Color.RED).withAlpha?.(0.9) || e.Color.RED;
|
|
2353
|
+
this.previewEdgeEntity = t.entities.add({
|
|
2354
|
+
polyline: {
|
|
2355
|
+
positions: new e.CallbackProperty(() => !this.currentPoints || this.currentPoints.length === 0 ? [] : this.currentPoints.slice(), !1),
|
|
2356
|
+
width: i.width || 2,
|
|
2357
|
+
material: w,
|
|
2358
|
+
clampToGround: !1,
|
|
2359
|
+
arcType: e.ArcType.NONE,
|
|
2360
|
+
depthFailMaterial: new e.PolylineDashMaterialProperty({
|
|
2361
|
+
color: u,
|
|
2362
|
+
dashLength: 12,
|
|
2363
|
+
dashPattern: 255
|
|
2364
|
+
})
|
|
2365
|
+
}
|
|
2366
|
+
});
|
|
2367
|
+
const C = i.pointColor || i.color || e.Color.YELLOW, L = t.entities.add({
|
|
2368
|
+
position: o,
|
|
2369
|
+
point: {
|
|
2370
|
+
pixelSize: 8,
|
|
2371
|
+
color: C,
|
|
2372
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
2373
|
+
}
|
|
2374
|
+
}), f = t.entities.add({
|
|
2375
|
+
position: new e.CallbackProperty(() => n || o, !1),
|
|
2376
|
+
point: {
|
|
2377
|
+
pixelSize: 8,
|
|
2378
|
+
color: C,
|
|
2379
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
2380
|
+
}
|
|
2381
|
+
});
|
|
2382
|
+
this.previewPointEntities.push(L, f);
|
|
2383
|
+
}
|
|
2384
|
+
let c = 0;
|
|
2385
|
+
for (let a = 1; a < this.currentPoints.length; a++) {
|
|
2386
|
+
const w = this.currentPoints[a - 1], u = this.currentPoints[a], C = e.Cartographic.fromCartesian(w), L = e.Cartographic.fromCartesian(u), f = new e.EllipsoidGeodesic(C, L);
|
|
2387
|
+
c += f.surfaceDistance;
|
|
2388
|
+
}
|
|
2389
|
+
const p = this.computeAreaByPlane(this.currentPoints), m = e.Cartographic.fromCartesian(o), g = this.previewLabelId || "measure_regular_preview";
|
|
2390
|
+
this.previewLabelId = g;
|
|
2391
|
+
const l = i.labelText || { sides: "边数", radius: "半径", circumference: "周长", area: "面积" };
|
|
2392
|
+
this.htmlLabelPool.add(
|
|
2393
|
+
{ text: `${l.sides}:${h}
|
|
2394
|
+
${l.radius}:${r.toFixed(2)} m
|
|
2395
|
+
${l.circumference}:${c.toFixed(2)} m
|
|
2396
|
+
${l.area}:${p.toFixed(2)} m²` },
|
|
2397
|
+
{
|
|
2398
|
+
id: g,
|
|
2399
|
+
lon: e.Math.toDegrees(m.longitude),
|
|
2400
|
+
lat: e.Math.toDegrees(m.latitude),
|
|
2401
|
+
height: m.height || 0,
|
|
2402
|
+
theme: "measure-regular",
|
|
2403
|
+
show: !0
|
|
2404
|
+
}
|
|
2405
|
+
);
|
|
2406
|
+
}, e.ScreenSpaceEventType.MOUSE_MOVE);
|
|
2407
|
+
}
|
|
2408
|
+
stop() {
|
|
2409
|
+
this.handler && (this.handler.destroy(), this.handler = null);
|
|
2410
|
+
}
|
|
2411
|
+
clear() {
|
|
2412
|
+
if (this.stop(), this.entity && (this.viewer.entities.remove(this.entity), this.entity = null), this.previewEntity && (this.viewer.entities.remove(this.previewEntity), this.previewEntity = null), this.previewEdgeEntity && (this.viewer.entities.remove(this.previewEdgeEntity), this.previewEdgeEntity = null), this.previewPointEntities.length) {
|
|
2413
|
+
for (const i of this.previewPointEntities)
|
|
2414
|
+
try {
|
|
2415
|
+
this.viewer.entities.remove(i);
|
|
2416
|
+
} catch {
|
|
2417
|
+
}
|
|
2418
|
+
this.previewPointEntities = [];
|
|
2419
|
+
}
|
|
2420
|
+
if (this.primitive && (this.viewer.scene.primitives.remove(this.primitive), this.primitive = null), this.edgeEntities.length) {
|
|
2421
|
+
for (const i of this.edgeEntities)
|
|
2422
|
+
try {
|
|
2423
|
+
this.viewer.entities.remove(i);
|
|
2424
|
+
} catch {
|
|
2425
|
+
}
|
|
2426
|
+
this.edgeEntities = [];
|
|
2427
|
+
}
|
|
2428
|
+
if (this.pointEntities.length) {
|
|
2429
|
+
for (const i of this.pointEntities)
|
|
2430
|
+
try {
|
|
2431
|
+
this.viewer.entities.remove(i);
|
|
2432
|
+
} catch {
|
|
2433
|
+
}
|
|
2434
|
+
this.pointEntities = [];
|
|
2435
|
+
}
|
|
2436
|
+
this.labelEntity && (this.viewer.entities.remove(this.labelEntity), this.labelEntity = null), this.htmlLabelPool && this.htmlLabelId && (this.htmlLabelPool.removeByIds([this.htmlLabelId]), this.htmlLabelId = null), this.previewLabelId && this.htmlLabelPool && (this.htmlLabelPool.removeByIds([this.previewLabelId]), this.previewLabelId = null), this.segmentLabelIds.length && this.htmlLabelPool && this.htmlLabelPool.removeByIds(this.segmentLabelIds.slice()), this.segmentLabelIds = [], this.positions = [], this.currentPoints = [];
|
|
2437
|
+
}
|
|
2438
|
+
rehydrate(i, e) {
|
|
2439
|
+
const t = this.Cesium, h = this.viewer, s = i.options || {}, o = i.data?.sides || s.sides || 3, d = (i.positions || []).map((y) => new t.Cartesian3(y[0], y[1], y[2]));
|
|
2440
|
+
if (d.length < 2) return;
|
|
2441
|
+
if (!this.htmlLabelPool) {
|
|
2442
|
+
const y = s.overlayContainerId || "html-label-container";
|
|
2443
|
+
this.htmlLabelPool = e || new k(t, h, y), this.htmlLabelPool.registerTheme("measure-regular", {
|
|
2444
|
+
createElement: (v, E) => {
|
|
2445
|
+
v.innerHTML = String(E?.data?.text || ""), v.style.background = "rgba(0,0,0,0.6)", v.style.color = "#fff", v.style.font = "14px sans-serif", v.style.padding = "4px 6px", v.style.borderRadius = "4px", v.style.whiteSpace = "pre";
|
|
2446
|
+
},
|
|
2447
|
+
options: { offset: { x: 0, y: -10 } }
|
|
2448
|
+
}), this.htmlLabelPool.registerTheme("measure-regular-seg", {
|
|
2449
|
+
createElement: (v, E) => {
|
|
2450
|
+
v.innerHTML = String(E?.data?.text || ""), v.style.background = "rgba(0,0,0,0.6)", v.style.color = "#fff", v.style.font = "14px sans-serif", v.style.padding = "4px 6px", v.style.borderRadius = "4px", v.style.whiteSpace = "pre";
|
|
2451
|
+
},
|
|
2452
|
+
options: { offset: { x: 0, y: -10 } }
|
|
2453
|
+
});
|
|
2454
|
+
}
|
|
2455
|
+
let n = [], r = d[0], c = 0;
|
|
2456
|
+
if (d.length >= 3) {
|
|
2457
|
+
n = d.slice(), r = new t.Cartesian3(
|
|
2458
|
+
n.reduce((v, E) => v + E.x, 0) / n.length,
|
|
2459
|
+
n.reduce((v, E) => v + E.y, 0) / n.length,
|
|
2460
|
+
n.reduce((v, E) => v + E.z, 0) / n.length
|
|
2461
|
+
);
|
|
2462
|
+
const y = n[0];
|
|
2463
|
+
n[Math.floor(n.length / 2)] || n[1], c = t.Cartesian3.distance(r, y);
|
|
2464
|
+
} else {
|
|
2465
|
+
const y = d[1];
|
|
2466
|
+
c = t.Cartesian3.distance(r, y), n = this.buildRegularPolygonPoints(r, c, Math.max(o, 3));
|
|
2467
|
+
}
|
|
2468
|
+
const p = new t.PolygonHierarchy(n), m = new t.PolygonGeometry({ polygonHierarchy: p, vertexFormat: t.MaterialAppearance.VERTEX_FORMAT, perPositionHeight: !0 }), g = new t.GeometryInstance({ geometry: m }), l = s.color || t.Color.YELLOW.withAlpha(0.4), a = s.color && s.color.withAlpha ? s.color.withAlpha(0.25) : t.Color.RED.withAlpha(0.4), w = new t.Primitive({ geometryInstances: g, appearance: new t.MaterialAppearance({ material: t.Material.fromType("Color", { color: l }), translucent: !0, closed: !0 }), depthFailAppearance: new t.MaterialAppearance({ material: t.Material.fromType("Color", { color: a }), translucent: !0, closed: !0 }) });
|
|
2469
|
+
h.scene.primitives.add(w), this.primitive = w;
|
|
2470
|
+
const u = this.computeAreaByPlane(n), C = t.Cartographic.fromCartesian(r), L = i.id + "_regular";
|
|
2471
|
+
this.htmlLabelId = L;
|
|
2472
|
+
const f = s.labelText || { sides: "边数", radius: "半径", circumference: "周长", area: "面积", side: "边长" };
|
|
2473
|
+
let b = 0;
|
|
2474
|
+
for (let y = 1; y < n.length; y++) {
|
|
2475
|
+
const v = n[y - 1], E = n[y], x = t.Cartographic.fromCartesian(v), D = t.Cartographic.fromCartesian(E), P = new t.EllipsoidGeodesic(x, D).surfaceDistance;
|
|
2476
|
+
b += P;
|
|
2477
|
+
const A = new t.Cartesian3((v.x + E.x) / 2, (v.y + E.y) / 2, (v.z + E.z) / 2), I = t.Cartographic.fromCartesian(A), S = i.id + `_regular_seg_${y - 1}`;
|
|
2478
|
+
this.segmentLabelIds.push(S), this.htmlLabelPool.add({ text: `${f.side}:${P.toFixed(2)} m` }, { id: S, lon: t.Math.toDegrees(I.longitude), lat: t.Math.toDegrees(I.latitude), height: I.height || 0, theme: "measure-regular-seg", show: !0 });
|
|
2479
|
+
}
|
|
2480
|
+
this.htmlLabelPool.add({ text: `${f.sides}:${Math.max(o, 3)}
|
|
2481
|
+
${f.radius}:${c.toFixed(2)} m
|
|
2482
|
+
${f.circumference}:${b.toFixed(2)} m
|
|
2483
|
+
${f.area}:${u.toFixed(2)} m²` }, { id: L, lon: t.Math.toDegrees(C.longitude), lat: t.Math.toDegrees(C.latitude), height: C.height || 0, theme: "measure-regular", show: !0 });
|
|
2484
|
+
}
|
|
2485
|
+
buildRegularPolygonPoints(i, e, t) {
|
|
2486
|
+
const h = this.Cesium, s = new h.EllipsoidTangentPlane(i, h.Ellipsoid.WGS84), o = 2 * Math.PI / t, d = [];
|
|
2487
|
+
for (let c = 0; c < t; c++) {
|
|
2488
|
+
const p = c * o, m = e * Math.cos(p), g = e * Math.sin(p);
|
|
2489
|
+
d.push(new h.Cartesian2(m, g));
|
|
2490
|
+
}
|
|
2491
|
+
const r = s.projectPointsOntoEllipsoid(d).slice();
|
|
2492
|
+
return r.push(r[0]), r;
|
|
2493
|
+
}
|
|
2494
|
+
computeAreaByPlane(i) {
|
|
2495
|
+
const e = this.Cesium, t = new e.Cartesian3(
|
|
2496
|
+
i.reduce((d, n) => d + n.x, 0) / i.length,
|
|
2497
|
+
i.reduce((d, n) => d + n.y, 0) / i.length,
|
|
2498
|
+
i.reduce((d, n) => d + n.z, 0) / i.length
|
|
2499
|
+
), s = new e.EllipsoidTangentPlane(t, e.Ellipsoid.WGS84).projectPointsOntoPlane(i);
|
|
2500
|
+
let o = 0;
|
|
2501
|
+
for (let d = 0; d < s.length; d++) {
|
|
2502
|
+
const n = (d + 1) % s.length;
|
|
2503
|
+
o += s[d].x * s[n].y - s[n].x * s[d].y;
|
|
2504
|
+
}
|
|
2505
|
+
return Math.abs(o) / 2;
|
|
2506
|
+
}
|
|
2507
|
+
}
|
|
2508
|
+
class Pe {
|
|
2509
|
+
Cesium;
|
|
2510
|
+
viewer;
|
|
2511
|
+
actives = [];
|
|
2512
|
+
measurements = [];
|
|
2513
|
+
htmlLabelPool = null;
|
|
2514
|
+
recordHandlers = /* @__PURE__ */ new Map();
|
|
2515
|
+
specifiedClear = !1;
|
|
2516
|
+
deleteLabelPool = null;
|
|
2517
|
+
deleteLabelIds = /* @__PURE__ */ new Map();
|
|
2518
|
+
constructor({ Cesium: i, viewer: e }) {
|
|
2519
|
+
this.Cesium = i, this.viewer = e, e.screenSpaceEventHandler.removeInputAction(i.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
|
|
2520
|
+
}
|
|
2521
|
+
measure(i, e) {
|
|
2522
|
+
let t = null;
|
|
2523
|
+
switch (i) {
|
|
2524
|
+
case "horizontal":
|
|
2525
|
+
t = new me(this.Cesium, this.viewer);
|
|
2526
|
+
break;
|
|
2527
|
+
case "vertical":
|
|
2528
|
+
t = new ge(this.Cesium, this.viewer);
|
|
2529
|
+
break;
|
|
2530
|
+
case "triangle":
|
|
2531
|
+
t = new ue(this.Cesium, this.viewer);
|
|
2532
|
+
break;
|
|
2533
|
+
case "space":
|
|
2534
|
+
t = new ye(this.Cesium, this.viewer);
|
|
2535
|
+
break;
|
|
2536
|
+
case "area":
|
|
2537
|
+
t = new we(this.Cesium, this.viewer);
|
|
2538
|
+
break;
|
|
2539
|
+
case "circle":
|
|
2540
|
+
t = new Ce(this.Cesium, this.viewer);
|
|
2541
|
+
break;
|
|
2542
|
+
case "polyline":
|
|
2543
|
+
t = new fe(this.Cesium, this.viewer);
|
|
2544
|
+
break;
|
|
2545
|
+
case "terrainHeight":
|
|
2546
|
+
t = new be(this.Cesium, this.viewer);
|
|
2547
|
+
break;
|
|
2548
|
+
case "coordinate":
|
|
2549
|
+
t = new ve(this.Cesium, this.viewer);
|
|
2550
|
+
break;
|
|
2551
|
+
case "rectangle":
|
|
2552
|
+
t = new Le(this.Cesium, this.viewer);
|
|
2553
|
+
break;
|
|
2554
|
+
case "regularPolygon":
|
|
2555
|
+
t = new Ee(this.Cesium, this.viewer);
|
|
2556
|
+
break;
|
|
2557
|
+
default:
|
|
2558
|
+
throw new Error(`Unsupported measurement type: ${i}`);
|
|
2559
|
+
}
|
|
2560
|
+
if (!t) return;
|
|
2561
|
+
this.actives.push(t);
|
|
2562
|
+
const h = t, s = {
|
|
2563
|
+
...e,
|
|
2564
|
+
onComplete: (o) => {
|
|
2565
|
+
const d = {
|
|
2566
|
+
id: `m_${Date.now()}_${this.measurements.length}`,
|
|
2567
|
+
type: i,
|
|
2568
|
+
options: (() => {
|
|
2569
|
+
const r = { ...e };
|
|
2570
|
+
return "onComplete" in r && delete r.onComplete, r;
|
|
2571
|
+
})(),
|
|
2572
|
+
positions: (() => {
|
|
2573
|
+
if (Array.isArray(o?.positions))
|
|
2574
|
+
return o.positions.map((r) => [r.x, r.y, r.z]);
|
|
2575
|
+
switch (i) {
|
|
2576
|
+
case "terrainHeight": {
|
|
2577
|
+
const r = o?.position;
|
|
2578
|
+
return r ? [[r.x, r.y, r.z]] : void 0;
|
|
2579
|
+
}
|
|
2580
|
+
case "coordinate": {
|
|
2581
|
+
const r = o?.lnglat;
|
|
2582
|
+
if (r && typeof r.lng == "number" && typeof r.lat == "number") {
|
|
2583
|
+
const c = this.Cesium.Cartesian3.fromDegrees(r.lng, r.lat, r.height || 0);
|
|
2584
|
+
return [[c.x, c.y, c.z]];
|
|
2585
|
+
}
|
|
2586
|
+
return;
|
|
2587
|
+
}
|
|
2588
|
+
default:
|
|
2589
|
+
return;
|
|
2590
|
+
}
|
|
2591
|
+
})(),
|
|
2592
|
+
data: this._serializeMetrics(i, o)
|
|
2593
|
+
};
|
|
2594
|
+
this.measurements.push(d), h && this.recordHandlers.set(d.id, h), this.specifiedClear && this._showDeleteLabels("html-label-container"), e.onComplete?.(o);
|
|
2595
|
+
const n = this.actives.indexOf(h);
|
|
2596
|
+
n >= 0 && this.actives.splice(n, 1);
|
|
2597
|
+
}
|
|
2598
|
+
};
|
|
2599
|
+
t.start(s);
|
|
2600
|
+
}
|
|
2601
|
+
clear() {
|
|
2602
|
+
const i = this.actives.pop();
|
|
2603
|
+
i && i.clear(), this._removeAllDeleteLabels(), this.specifiedClear = !1;
|
|
2604
|
+
}
|
|
2605
|
+
cancel() {
|
|
2606
|
+
const i = this.actives.pop();
|
|
2607
|
+
i && i.stop();
|
|
2608
|
+
}
|
|
2609
|
+
disableDefaultSelection({ disableLeftClick: i = !1, disableDoubleClick: e = !0 } = {}) {
|
|
2610
|
+
const t = this.viewer?.cesiumWidget?.screenSpaceEventHandler;
|
|
2611
|
+
t && (e && t.removeInputAction(this.Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK), i && t.removeInputAction(this.Cesium.ScreenSpaceEventType.LEFT_CLICK));
|
|
2612
|
+
}
|
|
2613
|
+
clearAll() {
|
|
2614
|
+
for (; this.actives.length; ) {
|
|
2615
|
+
const i = this.actives.pop();
|
|
2616
|
+
try {
|
|
2617
|
+
i?.clear();
|
|
2618
|
+
} catch {
|
|
2619
|
+
}
|
|
2620
|
+
}
|
|
2621
|
+
for (const [, i] of this.recordHandlers)
|
|
2622
|
+
try {
|
|
2623
|
+
i.clear();
|
|
2624
|
+
} catch {
|
|
2625
|
+
}
|
|
2626
|
+
this.recordHandlers.clear(), this.measurements = [], this._removeAllDeleteLabels(), this.specifiedClear = !1;
|
|
2627
|
+
}
|
|
2628
|
+
getMeasurementsConfig() {
|
|
2629
|
+
return {
|
|
2630
|
+
measurements: this.measurements.map((i) => ({
|
|
2631
|
+
...i,
|
|
2632
|
+
options: i.options ? { ...i.options } : i.options,
|
|
2633
|
+
positions: i.positions ? i.positions.map((e) => [e[0], e[1], e[2]]) : i.positions,
|
|
2634
|
+
data: i.data ? { ...i.data } : i.data
|
|
2635
|
+
}))
|
|
2636
|
+
};
|
|
2637
|
+
}
|
|
2638
|
+
setMeasurementsConfig(i) {
|
|
2639
|
+
if (i?.measurements?.length) {
|
|
2640
|
+
for (const e of i.measurements) {
|
|
2641
|
+
let t = null;
|
|
2642
|
+
switch (e.type) {
|
|
2643
|
+
case "horizontal":
|
|
2644
|
+
t = new me(this.Cesium, this.viewer);
|
|
2645
|
+
break;
|
|
2646
|
+
case "vertical":
|
|
2647
|
+
t = new ge(this.Cesium, this.viewer);
|
|
2648
|
+
break;
|
|
2649
|
+
case "triangle":
|
|
2650
|
+
t = new ue(this.Cesium, this.viewer);
|
|
2651
|
+
break;
|
|
2652
|
+
case "space":
|
|
2653
|
+
t = new ye(this.Cesium, this.viewer);
|
|
2654
|
+
break;
|
|
2655
|
+
case "area":
|
|
2656
|
+
t = new we(this.Cesium, this.viewer);
|
|
2657
|
+
break;
|
|
2658
|
+
case "circle":
|
|
2659
|
+
t = new Ce(this.Cesium, this.viewer);
|
|
2660
|
+
break;
|
|
2661
|
+
case "polyline":
|
|
2662
|
+
t = new fe(this.Cesium, this.viewer);
|
|
2663
|
+
break;
|
|
2664
|
+
case "terrainHeight":
|
|
2665
|
+
t = new be(this.Cesium, this.viewer);
|
|
2666
|
+
break;
|
|
2667
|
+
case "coordinate":
|
|
2668
|
+
t = new ve(this.Cesium, this.viewer);
|
|
2669
|
+
break;
|
|
2670
|
+
case "rectangle":
|
|
2671
|
+
t = new Le(this.Cesium, this.viewer);
|
|
2672
|
+
break;
|
|
2673
|
+
case "regularPolygon":
|
|
2674
|
+
t = new Ee(this.Cesium, this.viewer);
|
|
2675
|
+
break;
|
|
2676
|
+
default:
|
|
2677
|
+
t = null;
|
|
2678
|
+
}
|
|
2679
|
+
t?.rehydrate?.(e, void 0), t && e.id && this.recordHandlers.set(e.id, t), this.measurements.find((s) => s.id === e.id) || this.measurements.push(e);
|
|
2680
|
+
}
|
|
2681
|
+
this.specifiedClear && this._showDeleteLabels("html-label-container");
|
|
2682
|
+
}
|
|
2683
|
+
}
|
|
2684
|
+
_serializeMetrics(i, e) {
|
|
2685
|
+
switch (i) {
|
|
2686
|
+
case "space":
|
|
2687
|
+
return { distance: e?.distance };
|
|
2688
|
+
case "horizontal":
|
|
2689
|
+
return { distance: e?.distance };
|
|
2690
|
+
case "vertical":
|
|
2691
|
+
return { vertical: e?.vertical };
|
|
2692
|
+
case "polyline":
|
|
2693
|
+
return { distance: e?.distance };
|
|
2694
|
+
case "area":
|
|
2695
|
+
return { area: e?.area };
|
|
2696
|
+
case "circle":
|
|
2697
|
+
return { radius: e?.radius, area: e?.area, perimeter: e?.perimeter };
|
|
2698
|
+
case "rectangle":
|
|
2699
|
+
return { width: e?.width, height: e?.height, area: e?.area };
|
|
2700
|
+
case "regularPolygon":
|
|
2701
|
+
return {
|
|
2702
|
+
sides: e?.sides,
|
|
2703
|
+
radius: e?.radius,
|
|
2704
|
+
perimeter: e?.perimeter,
|
|
2705
|
+
area: e?.area
|
|
2706
|
+
};
|
|
2707
|
+
case "triangle":
|
|
2708
|
+
return { lengths: e?.lengths, angles: e?.angles };
|
|
2709
|
+
case "terrainHeight":
|
|
2710
|
+
return {
|
|
2711
|
+
terrainHeight: e?.terrainHeight,
|
|
2712
|
+
difference: e?.difference,
|
|
2713
|
+
position: e?.position,
|
|
2714
|
+
zeroPosition: e?.zeroPosition
|
|
2715
|
+
};
|
|
2716
|
+
case "coordinate":
|
|
2717
|
+
return { lnglat: e?.lnglat };
|
|
2718
|
+
default:
|
|
2719
|
+
return {};
|
|
2720
|
+
}
|
|
2721
|
+
}
|
|
2722
|
+
_toCartesian(i) {
|
|
2723
|
+
const e = this.Cesium;
|
|
2724
|
+
return new e.Cartesian3(i[0], i[1], i[2]);
|
|
2725
|
+
}
|
|
2726
|
+
_removeRecordVisual(i) {
|
|
2727
|
+
const e = this.viewer;
|
|
2728
|
+
this.Cesium;
|
|
2729
|
+
const t = e.entities.values;
|
|
2730
|
+
for (let o = t.length - 1; o >= 0; o--) {
|
|
2731
|
+
const d = t[o];
|
|
2732
|
+
try {
|
|
2733
|
+
e.entities.remove(d);
|
|
2734
|
+
} catch {
|
|
2735
|
+
}
|
|
2736
|
+
}
|
|
2737
|
+
const h = e.scene.primitives, s = [];
|
|
2738
|
+
h._primitives && h._primitives.forEach((o) => s.push(o));
|
|
2739
|
+
for (const o of s)
|
|
2740
|
+
try {
|
|
2741
|
+
e.scene.primitives.remove(o);
|
|
2742
|
+
} catch {
|
|
2743
|
+
}
|
|
2744
|
+
this.htmlLabelPool && this.htmlLabelPool.removeAll();
|
|
2745
|
+
}
|
|
2746
|
+
toggleSpecifiedClear(i) {
|
|
2747
|
+
if (this.specifiedClear)
|
|
2748
|
+
this._removeAllDeleteLabels(), this.specifiedClear = !1;
|
|
2749
|
+
else {
|
|
2750
|
+
if (this.specifiedClear = !0, !this.deleteLabelPool) {
|
|
2751
|
+
const e = i || "html-label-container";
|
|
2752
|
+
this.deleteLabelPool = new k(this.Cesium, this.viewer, e), this.deleteLabelPool.registerTheme("measure-delete-label", {
|
|
2753
|
+
createElement: (t, h) => {
|
|
2754
|
+
t.innerHTML = "删除", t.style.background = "rgba(255,0,0,0.7)", t.style.color = "#fff", t.style.font = "12px sans-serif", t.style.padding = "2px 6px", t.style.borderRadius = "4px", t.style.whiteSpace = "nowrap";
|
|
2755
|
+
},
|
|
2756
|
+
options: { offset: { x: 0, y: -10 } }
|
|
2757
|
+
}), this.deleteLabelPool.eventBus.addListener(
|
|
2758
|
+
Be.Click,
|
|
2759
|
+
{
|
|
2760
|
+
name: "measurement_delete_label_click",
|
|
2761
|
+
fn: (t) => {
|
|
2762
|
+
if (!t || t.theme !== "measure-delete-label") return;
|
|
2763
|
+
const h = t?.data?.recordId;
|
|
2764
|
+
h && this.deleteMeasurement(h);
|
|
2765
|
+
}
|
|
2766
|
+
},
|
|
2767
|
+
!0
|
|
2768
|
+
);
|
|
2769
|
+
}
|
|
2770
|
+
this._showDeleteLabels(i || "html-label-container");
|
|
2771
|
+
}
|
|
2772
|
+
}
|
|
2773
|
+
deleteMeasurement(i) {
|
|
2774
|
+
const e = this.recordHandlers.get(i);
|
|
2775
|
+
if (e)
|
|
2776
|
+
try {
|
|
2777
|
+
e.clear();
|
|
2778
|
+
} catch {
|
|
2779
|
+
}
|
|
2780
|
+
this.recordHandlers.delete(i), this.measurements = this.measurements.filter((h) => h.id !== i);
|
|
2781
|
+
const t = this.deleteLabelIds.get(i);
|
|
2782
|
+
t && this.deleteLabelPool && this.deleteLabelPool.removeByIds([t]), this.deleteLabelIds.delete(i);
|
|
2783
|
+
}
|
|
2784
|
+
_showDeleteLabels(i) {
|
|
2785
|
+
if (!this.deleteLabelPool) return;
|
|
2786
|
+
const e = this.Cesium;
|
|
2787
|
+
for (const t of this.measurements) {
|
|
2788
|
+
const h = "m_del_" + t.id;
|
|
2789
|
+
if (this.deleteLabelIds.has(t.id)) continue;
|
|
2790
|
+
const s = this._computeRecordCenter(t);
|
|
2791
|
+
if (!s) continue;
|
|
2792
|
+
const o = e.Cartographic.fromCartesian(s), d = e.Math.toDegrees(o.longitude), n = e.Math.toDegrees(o.latitude), r = o.height || 0;
|
|
2793
|
+
this.deleteLabelPool.add(
|
|
2794
|
+
{ recordId: t.id },
|
|
2795
|
+
{
|
|
2796
|
+
id: h,
|
|
2797
|
+
lon: d,
|
|
2798
|
+
lat: n,
|
|
2799
|
+
height: r,
|
|
2800
|
+
theme: "measure-delete-label",
|
|
2801
|
+
show: !0,
|
|
2802
|
+
style: { zIndex: "1000" }
|
|
2803
|
+
}
|
|
2804
|
+
), this.deleteLabelIds.set(t.id, h);
|
|
2805
|
+
}
|
|
2806
|
+
}
|
|
2807
|
+
_removeAllDeleteLabels() {
|
|
2808
|
+
if (this.deleteLabelPool) {
|
|
2809
|
+
const i = Array.from(this.deleteLabelIds.values());
|
|
2810
|
+
i.length && this.deleteLabelPool.removeByIds(i);
|
|
2811
|
+
}
|
|
2812
|
+
this.deleteLabelIds.clear();
|
|
2813
|
+
}
|
|
2814
|
+
_computeRecordCenter(i) {
|
|
2815
|
+
const e = this.Cesium, t = (i.positions || []).map((h) => this._toCartesian(h));
|
|
2816
|
+
if (t.length > 0) {
|
|
2817
|
+
const h = t.reduce((d, n) => d + n.x, 0) / t.length, s = t.reduce((d, n) => d + n.y, 0) / t.length, o = t.reduce((d, n) => d + n.z, 0) / t.length;
|
|
2818
|
+
return new e.Cartesian3(h, s, o);
|
|
2819
|
+
}
|
|
2820
|
+
if (i.type === "coordinate" && i.data?.lnglat) {
|
|
2821
|
+
const h = i.data.lnglat.lng, s = i.data.lnglat.lat, o = i.data.lnglat.height || 0;
|
|
2822
|
+
return e.Cartesian3.fromDegrees(h, s, o);
|
|
2823
|
+
}
|
|
2824
|
+
if (i.type === "terrainHeight" && i.data?.position) {
|
|
2825
|
+
const h = i.data.position;
|
|
2826
|
+
return new e.Cartesian3(h.x, h.y, h.z);
|
|
2827
|
+
}
|
|
2828
|
+
return null;
|
|
2829
|
+
}
|
|
2830
|
+
}
|
|
2831
|
+
const $e = {
|
|
5
2832
|
Cesium: {
|
|
6
2833
|
type: Object,
|
|
7
2834
|
required: !1
|
|
@@ -18,154 +2845,154 @@ const G = {
|
|
|
18
2845
|
type: String,
|
|
19
2846
|
default: "cx-measurement-overlay"
|
|
20
2847
|
}
|
|
21
|
-
},
|
|
22
|
-
name: `${
|
|
2848
|
+
}, Ae = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAQ9JREFUOE+dkjESAUEQRe0NOAEiIaEMERluQCYQcAKcACcgFLqBlQn3BsgFbsD7zKixdlbVTtWv7e3/+0937wY5z3lwXCrgJEkTkxIag6NC0MxqsDAG86wGoWk7vYP4vL69xPPq6rUDZ1574z+Pht2La6BioWXm9pmcIOpJBv9u/eE/I1iGUSLiPEQpyQ1eHRbhy5b//AeQTZIHMESw9RgMyG9AH81eGtdART1Qgrz75uGiC1yERtq3AUm1fAZriAnvM576icR9xaZmxrOM5mIN5iReSVABU8gOxe14zPvIvcwaqOVQbVG0JL4Sr1JijdtFUwgQDXjRYrQUfYUx2IFbSlyD0w6GMlBRVfNmONETek2ROovJNQ4AAAAASUVORK5CYII=", Ye = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAATBJREFUOE+lk4FNw0AMRbkJgAlYASYgTABMQNigTECZgDIBHaGdgHYCygZsAEwQ3ot8p2uUFqRasnKO7X/+PjsdDaTrunN+XaMN6lnZoCt0mVLyXCTVBskT7Of4t45ETYEu0W90CshLzisAJC/i5iXfliCDi+A/wZhHzAL/rc4eoLr5HodBO4XYFucr+kDsLAXnd37I72ZfcvZFtVK6EmDK4RE9HZa9CyzofOF/EmDVc0mpGXC2GoHlbrn2qEjJ42Cz5gT4AnXAJ8ZZ/Njgvxj4Z9h3VvAfgA8A8kz0OOQJ0P5Fwf5IYbKPgkEHNdHSbORbHo6a69g5nrHB1xw+SPmGapR9LidybJSdQJ+3DN3YMtmT46CVN0+alvyDuky+QC9bAPE8BnuLCcN1dom21vkXc/+iuK1zLp4AAAAASUVORK5CYII=", Ve = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAPCAYAAADtc08vAAAABHNCSVQICAgIfAhkiAAAAQBJREFUKFONk4EZwTAUhGUDG9AJsAETYAI1iZoEE6gJ2AAT6AjdoP6rpEKbtvm+95F7r5e7a2oG3iqKYs726mMN/xfGmJvDzR9BZvfHAEkMXkAQ1Qg4Xc0DtWYgbSJgZgV+prbMlIeUCmgM+XlRTxqyEVzMSv6EipjNHUECsKNmgI8Ogin9O7VnNjEwju3pJwDZ6Fw8I/mbUoXdyNsUgqzz6Y9lHSqlqQjkaWTl5z0Jvpl577701JPAZbZwIcrT0qpotWHlK8SLMnMEvYP8CZDMqptIw8kKvsomuz6BgpF8yQtlIXxGjXWJlNf/txCD6Tq3reoa1wgEWJlBAv9L1NAbCC98xCsG9JwAAAAASUVORK5CYII=", Ue = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAGZJREFUOE9j/A8EDEiAEQiQ+ehsDPUgAZgmZDYuQzDUowvgsx0mh2IhupOAihoJGFKP4mUQB2pII9DkBkIuAKoFqamHuQIcYKMGDPkwoHpeACYLQompASMpIwsQSokgebx5gdTsDADpy5nxGGvoWgAAAABJRU5ErkJggg==", We = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAABHNCSVQICAgIfAhkiAAAAMVJREFUKFOVkoENwiAQRWUCu4k6gbhBnaB0g47iBtYJdASdQLsJG+D7yUGw0agkP4Xj/7t/R92iWimlwLEDaws/+I7OuVOmOW0gNnzOwIMJXI2g88rOe4QxC0RQ1kDwMqvaqgq4c7dzZuNIQBleyFkIRyI56CVQ9gZy9l0XKHt46idKEK2x4S3TgvAObLt/BSFbWmJp86VCsRQg/t60slrjmnf/YaxKOHHn64fTSLdApTU5LQ80vRtoy8NV85Y9Yf5rjJnzBCCwZhr1an8TAAAAAElFTkSuQmCC", Ge = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAQFJREFUOE+VUzsSAUEQtZEj2FsQysjIyIRKtCmRkgnJyIRCmZURIZRxC07Be6pnq3e2Z5WuejX9mf5OT/QGVRRFIC37fOE+Fc5J86Eghfu+oiy7s+US+iXh0gvYAQPhjziHwA14AkmuZQoS5CGGPs49QHkMnIE1cBf+irPnqvgOTAIwc/OH8wR2JjADMEurJDOdSRugalXA/k6Bsp3zCnbOJ7ECsOe20bN2pn0eamEJQ8cbmO/cgH0B1EItzNS0LWe+Cp91agU4SHl8tpAzW7gA9SyAsUgjmTYHRgeWzczkqeNSZRQZq5zC2gW2QAxwN8hTRzkurLJW6OghvvQv/PudP2fPqPEaEaVuAAAAAElFTkSuQmCC", Qe = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAVCAYAAACg/AXsAAAABHNCSVQICAgIfAhkiAAAAPZJREFUOE/tk0EOwUAUhs0NLCyRLsTa2ooT4ATqRuICWhfA1ik4AYmtBCeo769OUq1pxk7ES740fW/eP2/+aU3NEUmSnCk1c+W2MUa5Upi/iL8nWom5Kx59DO24vFPeaeyPieBHnSPtoAs9fDm5fCl5QvOYxSOYwAUacIMjRIjFRbFUhMaAxxRCuMMcNrCwt5OJqz6AJcQI7tPboaiCkooZhcjuRE3TtMhJLA1yViTIhML8JBITV9AkW5p1DNusY2raIWgjHe05iV1U2ElialqDhPR+yBol8BJVf7FuR82BJvvodoq7+LxXfvY+Am898W3Mr/ueSR4JpmsW0RAzTwAAAABJRU5ErkJggg==", Ke = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAWCAYAAAAb+hYkAAAABHNCSVQICAgIfAhkiAAAAR1JREFUOE+tk6FywkAURVlZ1SIqcK2owCE6g+YLWhwSiQOJI6hKcJXF9R9QqcUEybSmOFyLw4VzmSSThF0SGHbmTjbknXff7lxM5YJl8kwYhg1++0B6+qhtjPlP19mgJQUPaIa6KABqOaHIJaBgTKHH+5R9n32muc3pl8JbJGCA1jAaNVmuM82puEffqFl4JrVjrA6PT1QHWKVdtD9yiiBdgG7wEUjjZtZVoR6t31ENp01ZJ93aBFXzl3DqTBdBQzq+nevkAYzQDePtyp7pAOXjE8O2RNzxcYGekKKkHBamfEbhK/pBzxEk52RlnIiPXP7iQt7V4AWnqhPSBwp9Hkq5umu8L6BuERT/YwVuUSOfP1f2NKbgZelEpEex7fdW8nMXLD81JwAAAABJRU5ErkJggg==", Je = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAANCAYAAACtpZ5jAAAABHNCSVQICAgIfAhkiAAAAN9JREFUOE+1krENwjAUROMNGAEqWtLSkJIONgAmwB2MQAkTwAbABjBBwgYZIRuYd8gWIIHiFLZ0svX/3eX8Y5MlWiaRb5be2DnXJ/0E3I0xdexN0PXgzsADXRV0r8Q0C7YzEKkBK0iXNnMfpvQ60aU76RCMZaaUFuzBEOz+GIsbkm05j8ECLIFuPMC8CcaOwoGCJYWM121pP/oVuhydjI8g10iCseLrqzdQgCvN+S9zP9OR703ZN/4Gqun/SP9+FT6pmkqgkUQtdOIqRA2sxvBlHOXSgZT+HXcIE0VNlvgJ9ttGDjhkGwIAAAAASUVORK5CYII=", je = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAU5JREFUOE+dkjFLQzEURnsRRUW0uDkI3XQo0m6Odms3QRHHjk5SNzfd/Ac66iKKIm0nHf0HduncooibiLo5PM/3SCAvlmL74NDk3uTk3jSWG/FLkmSTLUeQhwMbcX8OQZ89H46FcQWvCGbBxhFssfEGvqCeEfzpz6wVt+jWNInXzOwhFmT7MysPEFwT24BlBD+x4JmE+puGSRYUQwGnzzF/g0tye8rFAtm34RtmYIWFqir9EOzycwUV4o8ZAckCgSdowz68wD0LtckLdCfrsEQ8iQUXBPRISjoV4SHjEygy77ry35mfMm94qQU3v0bw1p9IXPfQhw6xKvM643MoM++EAi3Sy1Lf8yQl8iXros6gBjq1QH7V59MW3NPsMdbbJm+lQDDBWP/MFCzCHfmdWKC+j52gwYLM4+EACdT7p9aEFaYVhLZB42EV/lcwtMJfrJ6SRKgz9VoAAAAASUVORK5CYII=", qe = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAMZJREFUOE9jZACC////JwApeRCbSOAAVGcBxMsZgZpBnP1EakRX9h3ZAEdGRsYDUBf9B7IZsRkKtNAAKH4CiFmBuJskA6CaQa59CMQOQDs+EG0ANs0gF+IMA2Qv4NKMbgA8DJD9jk8zQQMIacZrADGacRpArGasBpCiGcMAoMAHaKoEJSIDYEw8IJRCkaOxEKi4HhS10ERygZBmmAsWABnxUMUfSdEMM+A/VDOINgI6myibYa4DeWEekBMHxHOAmjOIcTayGgDyvZQkMv2X2QAAAABJRU5ErkJggg==", Ze = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAMFJREFUOE+Vk70NwjAQRnMVJekQHRvACBkBNqCkgw0IHV0yAiOxAaGkgg3MuyAjix/nztInpbj34thfpHCsEELFeEMWpCMrcfAFgjPzM3Iia3LxCgLQQURqZC3PW6/gATQiR7IjV7OAN9YAe3IjE4XJ0iRI4H776bkNCnKwirKCITgrsMB/BVb4p8AD94KPeuo9l7EslpaqIK3nBujOVU0tcNzBdz0xeAQdw2Oi3X7VU0T/NtOKZ6Dw/F1PEf0s03oC+SBfAKxisH4AAAAASUVORK5CYII=", Xe = ["onClick"], et = ["src", "alt"], tt = ["src"], it = ["src"], st = ["id"], ot = /* @__PURE__ */ Se({
|
|
2849
|
+
name: `${Me}-measurement`,
|
|
23
2850
|
__name: "Measurement",
|
|
24
|
-
props:
|
|
25
|
-
setup(
|
|
26
|
-
const
|
|
27
|
-
{ key: "horizontal", label: "水平测距", icon:
|
|
28
|
-
{ key: "vertical", label: "垂直测距", icon:
|
|
29
|
-
{ key: "space", label: "空间测距", icon:
|
|
30
|
-
{ key: "triangle", label: "三角测量", icon:
|
|
31
|
-
{ key: "polyline", label: "折线测距", icon:
|
|
32
|
-
{ key: "area", label: "面积测量", icon:
|
|
33
|
-
{ key: "circle", label: "圆形测量", icon:
|
|
34
|
-
{ key: "rectangle", label: "矩形测量", icon:
|
|
35
|
-
{ key: "regularPolygon", label: "正多边形", icon:
|
|
36
|
-
{ key: "terrainHeight", label: "地形高度", icon:
|
|
37
|
-
{ key: "coordinate", label: "坐标查询", icon:
|
|
38
|
-
],
|
|
39
|
-
let
|
|
40
|
-
const c =
|
|
41
|
-
!
|
|
42
|
-
},
|
|
43
|
-
const
|
|
44
|
-
if (!
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
if (!(!
|
|
49
|
-
if (
|
|
50
|
-
|
|
2851
|
+
props: $e,
|
|
2852
|
+
setup(W, { expose: i }) {
|
|
2853
|
+
const e = W, t = De("measurement"), h = e.overlayContainerId || "cx-measurement-overlay", s = [
|
|
2854
|
+
{ key: "horizontal", label: "水平测距", icon: Je },
|
|
2855
|
+
{ key: "vertical", label: "垂直测距", icon: Ke },
|
|
2856
|
+
{ key: "space", label: "空间测距", icon: Ze },
|
|
2857
|
+
{ key: "triangle", label: "三角测量", icon: qe },
|
|
2858
|
+
{ key: "polyline", label: "折线测距", icon: je },
|
|
2859
|
+
{ key: "area", label: "面积测量", icon: Ge },
|
|
2860
|
+
{ key: "circle", label: "圆形测量", icon: We },
|
|
2861
|
+
{ key: "rectangle", label: "矩形测量", icon: Ue },
|
|
2862
|
+
{ key: "regularPolygon", label: "正多边形", icon: Ve },
|
|
2863
|
+
{ key: "terrainHeight", label: "地形高度", icon: Qe },
|
|
2864
|
+
{ key: "coordinate", label: "坐标查询", icon: Ye }
|
|
2865
|
+
], o = ae(""), d = ae(!1), n = ae(null);
|
|
2866
|
+
let r = null;
|
|
2867
|
+
const c = Oe("leitingMethods"), p = (u, C) => {
|
|
2868
|
+
!u || !C || (r = u, n.value = new Pe({ Cesium: u, viewer: C }));
|
|
2869
|
+
}, m = (u) => {
|
|
2870
|
+
const C = U(c);
|
|
2871
|
+
if (!n.value && C) {
|
|
2872
|
+
const L = C.getCesium(), f = C.getViewer();
|
|
2873
|
+
r = L, n.value = new Pe({ Cesium: L, viewer: f });
|
|
2874
|
+
}
|
|
2875
|
+
if (!(!n.value || !r)) {
|
|
2876
|
+
if (u === "clear") {
|
|
2877
|
+
g();
|
|
51
2878
|
return;
|
|
52
2879
|
}
|
|
53
|
-
|
|
54
|
-
overlayContainerId:
|
|
55
|
-
color:
|
|
56
|
-
lineColor:
|
|
57
|
-
dashLineColor:
|
|
58
|
-
pointColor:
|
|
2880
|
+
o.value = u, n.value.measure(u, {
|
|
2881
|
+
overlayContainerId: h,
|
|
2882
|
+
color: r.Color.YELLOW.withAlpha(0.5),
|
|
2883
|
+
lineColor: r.Color.fromCssColorString("#51ff00"),
|
|
2884
|
+
dashLineColor: r.Color.RED,
|
|
2885
|
+
pointColor: r.Color.YELLOW
|
|
59
2886
|
});
|
|
60
2887
|
}
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
},
|
|
66
|
-
|
|
2888
|
+
}, g = () => {
|
|
2889
|
+
n.value && (n.value.clearAll(), o.value = "");
|
|
2890
|
+
}, l = () => {
|
|
2891
|
+
n.value && n.value.toggleSpecifiedClear(h);
|
|
2892
|
+
}, a = (u) => {
|
|
2893
|
+
d.value = u;
|
|
67
2894
|
};
|
|
68
|
-
function
|
|
69
|
-
if (
|
|
70
|
-
const
|
|
71
|
-
(
|
|
2895
|
+
function w() {
|
|
2896
|
+
if (n.value) return n.value;
|
|
2897
|
+
const u = U(c), C = u?.getCesium?.(), L = u?.getViewer?.();
|
|
2898
|
+
(C && L || e.Cesium && e.viewer) && p(C, L);
|
|
72
2899
|
}
|
|
73
|
-
return
|
|
2900
|
+
return Fe(
|
|
74
2901
|
() => c?.value,
|
|
75
|
-
(
|
|
76
|
-
|
|
2902
|
+
(u, C) => {
|
|
2903
|
+
w();
|
|
77
2904
|
},
|
|
78
2905
|
{ deep: !1 }
|
|
79
|
-
),
|
|
80
|
-
|
|
81
|
-
}),
|
|
82
|
-
|
|
83
|
-
}),
|
|
84
|
-
init:
|
|
85
|
-
open:
|
|
86
|
-
tool:
|
|
87
|
-
setMeasurementInfo(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
overlayContainerId:
|
|
91
|
-
color:
|
|
92
|
-
lineColor:
|
|
93
|
-
dashLineColor:
|
|
94
|
-
pointColor:
|
|
2906
|
+
), ke(() => {
|
|
2907
|
+
w();
|
|
2908
|
+
}), Re(() => {
|
|
2909
|
+
n.value && (n.value.clear(), n.value = null);
|
|
2910
|
+
}), i({
|
|
2911
|
+
init: p,
|
|
2912
|
+
open: a,
|
|
2913
|
+
tool: n,
|
|
2914
|
+
setMeasurementInfo(u) {
|
|
2915
|
+
n.value && (u.measurements?.forEach((C) => {
|
|
2916
|
+
C.options = {
|
|
2917
|
+
overlayContainerId: h,
|
|
2918
|
+
color: r.Color.YELLOW,
|
|
2919
|
+
lineColor: r.Color.fromCssColorString("#51ff00"),
|
|
2920
|
+
dashLineColor: r.Color.RED,
|
|
2921
|
+
pointColor: r.Color.YELLOW
|
|
95
2922
|
};
|
|
96
|
-
}),
|
|
2923
|
+
}), n.value.setMeasurementsConfig(u));
|
|
97
2924
|
},
|
|
98
2925
|
getMeasurementInfo() {
|
|
99
|
-
if (
|
|
100
|
-
let
|
|
101
|
-
return
|
|
102
|
-
delete
|
|
103
|
-
}),
|
|
2926
|
+
if (n.value) {
|
|
2927
|
+
let u = n.value.getMeasurementsConfig();
|
|
2928
|
+
return u.measurements?.forEach((C) => {
|
|
2929
|
+
delete C.options;
|
|
2930
|
+
}), u;
|
|
104
2931
|
}
|
|
105
2932
|
return {
|
|
106
2933
|
measurements: []
|
|
107
2934
|
};
|
|
108
2935
|
}
|
|
109
|
-
}), (
|
|
110
|
-
K(
|
|
111
|
-
class:
|
|
2936
|
+
}), (u, C) => (ce(), de(pe, null, [
|
|
2937
|
+
He(K("div", {
|
|
2938
|
+
class: ee([U(t).b("box"), U(t).is("small", e.size === "small")])
|
|
112
2939
|
}, [
|
|
113
|
-
(
|
|
114
|
-
key:
|
|
115
|
-
class:
|
|
116
|
-
onClick: (
|
|
2940
|
+
(ce(), de(pe, null, _e(s, (L) => K("div", {
|
|
2941
|
+
key: L.key,
|
|
2942
|
+
class: ee([U(t).be("box", "btn"), { active: o.value === L.key }]),
|
|
2943
|
+
onClick: (f) => m(L.key)
|
|
117
2944
|
}, [
|
|
118
|
-
|
|
119
|
-
class:
|
|
2945
|
+
K("div", {
|
|
2946
|
+
class: ee(U(t).be("box", "icon"))
|
|
120
2947
|
}, [
|
|
121
|
-
|
|
122
|
-
src:
|
|
123
|
-
alt:
|
|
124
|
-
}, null, 8,
|
|
2948
|
+
K("img", {
|
|
2949
|
+
src: L.icon,
|
|
2950
|
+
alt: L.label
|
|
2951
|
+
}, null, 8, et)
|
|
125
2952
|
], 2),
|
|
126
|
-
|
|
127
|
-
], 10,
|
|
128
|
-
|
|
129
|
-
class:
|
|
130
|
-
onClick:
|
|
2953
|
+
le(" " + Ne(L.label), 1)
|
|
2954
|
+
], 10, Xe)), 64)),
|
|
2955
|
+
K("div", {
|
|
2956
|
+
class: ee(U(t).be("box", "btn")),
|
|
2957
|
+
onClick: l
|
|
131
2958
|
}, [
|
|
132
|
-
|
|
133
|
-
class:
|
|
2959
|
+
K("div", {
|
|
2960
|
+
class: ee(U(t).be("box", "icon"))
|
|
134
2961
|
}, [
|
|
135
|
-
|
|
136
|
-
src:
|
|
2962
|
+
K("img", {
|
|
2963
|
+
src: U(Ae),
|
|
137
2964
|
alt: "指定清除"
|
|
138
|
-
}, null, 8,
|
|
2965
|
+
}, null, 8, tt)
|
|
139
2966
|
], 2),
|
|
140
|
-
|
|
2967
|
+
C[0] || (C[0] = le(" 指定清除 ", -1))
|
|
141
2968
|
], 2),
|
|
142
|
-
|
|
143
|
-
class:
|
|
144
|
-
onClick:
|
|
2969
|
+
K("div", {
|
|
2970
|
+
class: ee(U(t).be("box", "btn")),
|
|
2971
|
+
onClick: g
|
|
145
2972
|
}, [
|
|
146
|
-
|
|
147
|
-
class:
|
|
2973
|
+
K("div", {
|
|
2974
|
+
class: ee(U(t).be("box", "icon"))
|
|
148
2975
|
}, [
|
|
149
|
-
|
|
150
|
-
src:
|
|
2976
|
+
K("img", {
|
|
2977
|
+
src: U(Ae),
|
|
151
2978
|
alt: "清除"
|
|
152
|
-
}, null, 8,
|
|
2979
|
+
}, null, 8, it)
|
|
153
2980
|
], 2),
|
|
154
|
-
|
|
2981
|
+
C[1] || (C[1] = le(" 清除全部 ", -1))
|
|
155
2982
|
], 2)
|
|
156
2983
|
], 2), [
|
|
157
|
-
[
|
|
2984
|
+
[ze, d.value]
|
|
158
2985
|
]),
|
|
159
|
-
|
|
160
|
-
id:
|
|
161
|
-
class:
|
|
162
|
-
}, null, 10,
|
|
2986
|
+
K("div", {
|
|
2987
|
+
id: U(h),
|
|
2988
|
+
class: ee(U(t).be("box", "container"))
|
|
2989
|
+
}, null, 10, st)
|
|
163
2990
|
], 64));
|
|
164
2991
|
}
|
|
165
|
-
}),
|
|
2992
|
+
}), lt = Te(ot);
|
|
166
2993
|
export {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
2994
|
+
lt as CxMeasurement,
|
|
2995
|
+
lt as default,
|
|
2996
|
+
$e as measurementProps
|
|
170
2997
|
};
|
|
171
2998
|
//# sourceMappingURL=measurement.js.map
|