leiting-bim 2.1.160 → 2.1.161
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 -1
- package/leiting-bim.umd.js +5 -5
- package/leitingbim.css +1 -1
- package/package.json +1 -1
- package/plugins/cesium-core/dist/cesium-core.mjs +1424 -1261
- package/plugins/cesium-core/dist/cesium-core.mjs.map +1 -1
- package/plugins/cesium-core/dist/cesium-core.umd.js +22 -22
- package/plugins/cesium-core/dist/cesium-core.umd.js.map +1 -1
- package/plugins/cesium-core/dist/components/measurement/handlers/AreaMeasure.d.ts +9 -0
- package/plugins/cesium-core/dist/components/measurement/handlers/HorizontalMeasure.d.ts +12 -0
- package/plugins/cesium-core/dist/components/measurement/handlers/PolylineDistanceMeasure.d.ts +8 -0
- package/plugins/cesium-vue/dist/components/measurement.js +900 -722
- package/plugins/cesium-vue/dist/components/measurement.js.map +1 -1
|
@@ -1,7 +1,29 @@
|
|
|
1
|
-
import { p as
|
|
2
|
-
import { defineComponent as
|
|
3
|
-
import { H as
|
|
4
|
-
class
|
|
1
|
+
import { p as Te, c as De, w as Se } from "../create-DynflqE1.js";
|
|
2
|
+
import { defineComponent as ke, ref as ce, inject as Fe, watch as _e, onMounted as He, onUnmounted as Oe, openBlock as ge, createElementBlock as ue, Fragment as ye, withDirectives as Re, createElementVNode as K, normalizeClass as ee, unref as G, renderList as Ne, createTextVNode as de, toDisplayString as ze, vShow as Be } from "vue";
|
|
3
|
+
import { H as _, M as $e } from "../HtmlOverlayLabelPool-CbiNlyAM.js";
|
|
4
|
+
class pe {
|
|
5
|
+
tooltipEl;
|
|
6
|
+
visible = !1;
|
|
7
|
+
offsetX = 10;
|
|
8
|
+
offsetY = -20;
|
|
9
|
+
onMouseMove = null;
|
|
10
|
+
constructor() {
|
|
11
|
+
this.tooltipEl = document.createElement("div"), this.tooltipEl.style.position = "fixed", this.tooltipEl.style.pointerEvents = "none", this.tooltipEl.style.zIndex = "10000", this.tooltipEl.style.padding = "4px 8px", this.tooltipEl.style.borderRadius = "4px", this.tooltipEl.style.background = "rgba(0, 0, 0, 0.7)", this.tooltipEl.style.color = "#fff", this.tooltipEl.style.fontSize = "13px", this.tooltipEl.style.transition = "opacity 0.1s ease", this.tooltipEl.style.opacity = "0", document.body.appendChild(this.tooltipEl), this.onMouseMove = (i) => {
|
|
12
|
+
this.visible && (this.tooltipEl.style.left = `${i.clientX + this.offsetX}px`, this.tooltipEl.style.top = `${i.clientY + this.offsetY}px`);
|
|
13
|
+
}, window.addEventListener("mousemove", this.onMouseMove);
|
|
14
|
+
}
|
|
15
|
+
show(i) {
|
|
16
|
+
this.tooltipEl.innerText = i, this.tooltipEl.style.opacity = "1", this.visible = !0;
|
|
17
|
+
}
|
|
18
|
+
hide() {
|
|
19
|
+
this.tooltipEl.style.opacity = "0", this.visible = !1;
|
|
20
|
+
}
|
|
21
|
+
destroy() {
|
|
22
|
+
this.onMouseMove && (window.removeEventListener("mousemove", this.onMouseMove), this.onMouseMove = null), this.tooltipEl.parentElement && this.tooltipEl.parentElement.removeChild(this.tooltipEl);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
class re {
|
|
26
|
+
static TIP_TEXT = "单击左键添加点,右键撤销,双击左键或Esc结束";
|
|
5
27
|
Cesium;
|
|
6
28
|
viewer;
|
|
7
29
|
handler = null;
|
|
@@ -20,6 +42,12 @@ class me {
|
|
|
20
42
|
groundLineEntities = [];
|
|
21
43
|
previewPos = null;
|
|
22
44
|
previewGroundPos = null;
|
|
45
|
+
tooltip = null;
|
|
46
|
+
moveFrameId = null;
|
|
47
|
+
pendingMove = null;
|
|
48
|
+
lastMoveKey = null;
|
|
49
|
+
keydownHandler = null;
|
|
50
|
+
contextMenuHandler = null;
|
|
23
51
|
constructor(i, e) {
|
|
24
52
|
this.Cesium = i, this.viewer = e;
|
|
25
53
|
}
|
|
@@ -27,8 +55,8 @@ class me {
|
|
|
27
55
|
this.clear();
|
|
28
56
|
const e = this.Cesium, t = this.viewer;
|
|
29
57
|
if (!this.htmlLabelPool) {
|
|
30
|
-
const
|
|
31
|
-
this.htmlLabelPool = new
|
|
58
|
+
const a = i.overlayContainerId || "html-label-container";
|
|
59
|
+
this.htmlLabelPool = new _(e, t, a), this.htmlLabelPool.registerTheme("measure-horizontal-total", {
|
|
32
60
|
createElement: (s, o) => {
|
|
33
61
|
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
62
|
},
|
|
@@ -40,8 +68,8 @@ class me {
|
|
|
40
68
|
options: { offset: { x: 0, y: -10 } }
|
|
41
69
|
});
|
|
42
70
|
}
|
|
43
|
-
this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((
|
|
44
|
-
const s = t.scene.pickPosition(
|
|
71
|
+
this.tooltip = new pe(), this.tooltip.show(re.TIP_TEXT), this._bindGlobalEvents(i, e, t), this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((a) => {
|
|
72
|
+
const s = t.scene.pickPosition(a.position);
|
|
45
73
|
if (!s) return;
|
|
46
74
|
const o = e.Cartographic.fromCartesian(s), d = e.Math.toDegrees(o.longitude), n = e.Math.toDegrees(o.latitude);
|
|
47
75
|
this.positions.length === 0 && (this.firstHeight = o.height || 0);
|
|
@@ -56,21 +84,21 @@ class me {
|
|
|
56
84
|
}
|
|
57
85
|
});
|
|
58
86
|
this.tempPoints.push(c);
|
|
59
|
-
const p =
|
|
87
|
+
const p = s, m = (i.dashLineColor || i.lineColor || i.color || e.Color.RED).withAlpha?.(0.9) || e.Color.RED, g = t.entities.add({
|
|
60
88
|
polyline: {
|
|
61
|
-
positions: [
|
|
89
|
+
positions: [p, r],
|
|
62
90
|
width: i.width || 3,
|
|
63
91
|
material: new e.PolylineDashMaterialProperty({
|
|
64
|
-
color:
|
|
92
|
+
color: m,
|
|
65
93
|
dashLength: 12,
|
|
66
94
|
dashPattern: 255
|
|
67
95
|
})
|
|
68
96
|
}
|
|
69
97
|
});
|
|
70
|
-
if (this.groundLineEntities.push(
|
|
71
|
-
const
|
|
98
|
+
if (this.groundLineEntities.push(g), this.positions.length >= 2) {
|
|
99
|
+
const h = this.positions[this.positions.length - 2], l = this.positions[this.positions.length - 1], w = e.Cartographic.fromCartesian(h), u = e.Cartographic.fromCartesian(l), C = t.entities.add({
|
|
72
100
|
polyline: {
|
|
73
|
-
positions: [
|
|
101
|
+
positions: [h, l],
|
|
74
102
|
width: i.width || 3,
|
|
75
103
|
material: i.lineColor || i.color || e.Color.YELLOW,
|
|
76
104
|
depthFailMaterial: new e.PolylineDashMaterialProperty({
|
|
@@ -80,165 +108,212 @@ class me {
|
|
|
80
108
|
})
|
|
81
109
|
}
|
|
82
110
|
});
|
|
83
|
-
this.segmentEntities.push(
|
|
84
|
-
const
|
|
85
|
-
(
|
|
86
|
-
(
|
|
87
|
-
(
|
|
88
|
-
),
|
|
89
|
-
this.segmentLabelIds.push(
|
|
90
|
-
{ text: `${
|
|
111
|
+
this.segmentEntities.push(C);
|
|
112
|
+
const f = new e.EllipsoidGeodesic(w, u).surfaceDistance, v = new e.Cartesian3(
|
|
113
|
+
(h.x + l.x) / 2,
|
|
114
|
+
(h.y + l.y) / 2,
|
|
115
|
+
(h.z + l.z) / 2
|
|
116
|
+
), y = e.Cartographic.fromCartesian(v), b = `measure_horizontal_seg_${this.segmentLabelIds.length}_${Date.now()}`;
|
|
117
|
+
this.segmentLabelIds.push(b), this.htmlLabelPool.add(
|
|
118
|
+
{ text: `${f.toFixed(2)} m` },
|
|
91
119
|
{
|
|
92
|
-
id:
|
|
93
|
-
lon: e.Math.toDegrees(
|
|
94
|
-
lat: e.Math.toDegrees(
|
|
95
|
-
height:
|
|
120
|
+
id: b,
|
|
121
|
+
lon: e.Math.toDegrees(y.longitude),
|
|
122
|
+
lat: e.Math.toDegrees(y.latitude),
|
|
123
|
+
height: y.height || this.firstHeight || 0,
|
|
96
124
|
theme: "measure-horizontal-seg",
|
|
97
125
|
show: !0
|
|
98
126
|
}
|
|
99
127
|
);
|
|
100
128
|
}
|
|
101
129
|
}, e.ScreenSpaceEventType.LEFT_CLICK), this.handler.setInputAction(() => {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
this.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
-
})
|
|
130
|
+
this._finishMeasurement(i, e);
|
|
131
|
+
}, e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK), this.handler.setInputAction(() => {
|
|
132
|
+
this._undoLastPoint();
|
|
133
|
+
}, e.ScreenSpaceEventType.RIGHT_CLICK), this.handler.setInputAction((a) => {
|
|
134
|
+
this.pendingMove = {
|
|
135
|
+
endPosition: {
|
|
136
|
+
x: a.endPosition?.x,
|
|
137
|
+
y: a.endPosition?.y
|
|
179
138
|
}
|
|
139
|
+
}, this.moveFrameId == null && (this.moveFrameId = window.requestAnimationFrame(() => {
|
|
140
|
+
this.moveFrameId = null;
|
|
141
|
+
const s = this.pendingMove;
|
|
142
|
+
if (this.pendingMove = null, !s?.endPosition) return;
|
|
143
|
+
const o = `${s.endPosition.x}_${s.endPosition.y}`;
|
|
144
|
+
o !== this.lastMoveKey && (this.lastMoveKey = o, this._handlePreviewMove(s, i, e, t));
|
|
180
145
|
}));
|
|
181
146
|
}, e.ScreenSpaceEventType.MOUSE_MOVE);
|
|
182
147
|
}
|
|
148
|
+
_handlePreviewMove(i, e, t, a) {
|
|
149
|
+
if (this.positions.length === 0) return;
|
|
150
|
+
const s = a.scene.pickPosition(i.endPosition);
|
|
151
|
+
if (!s) return;
|
|
152
|
+
this.hoverPos = s;
|
|
153
|
+
const o = t.Cartographic.fromCartesian(s), d = t.Math.toDegrees(o.longitude), n = t.Math.toDegrees(o.latitude), r = t.Cartesian3.fromDegrees(d, n, this.firstHeight || 0);
|
|
154
|
+
this.previewPos = r, this.previewGroundPos = s;
|
|
155
|
+
const c = this.positions[this.positions.length - 1], p = t.Cartographic.fromCartesian(c), m = t.Cartographic.fromCartesian(r), h = new t.EllipsoidGeodesic(p, m).surfaceDistance, l = new t.Cartesian3(
|
|
156
|
+
(c.x + r.x) / 2,
|
|
157
|
+
(c.y + r.y) / 2,
|
|
158
|
+
(c.z + r.z) / 2
|
|
159
|
+
), w = t.Cartographic.fromCartesian(l), u = this.previewLabelId || "measure_horizontal_preview";
|
|
160
|
+
this.previewLabelId = u, this.htmlLabelPool.add(
|
|
161
|
+
{ text: `${h.toFixed(2)} m` },
|
|
162
|
+
{
|
|
163
|
+
id: u,
|
|
164
|
+
lon: t.Math.toDegrees(w.longitude),
|
|
165
|
+
lat: t.Math.toDegrees(w.latitude),
|
|
166
|
+
height: w.height || this.firstHeight || 0,
|
|
167
|
+
theme: "measure-horizontal-seg",
|
|
168
|
+
show: !0
|
|
169
|
+
}
|
|
170
|
+
);
|
|
171
|
+
const C = (e.dashLineColor || e.lineColor || e.color || t.Color.RED).withAlpha?.(0.9) || t.Color.RED;
|
|
172
|
+
this.previewGroundEntity || (this.previewGroundEntity = a.entities.add({
|
|
173
|
+
polyline: {
|
|
174
|
+
positions: new t.CallbackProperty(() => !this.previewPos || !this.previewGroundPos ? [] : [this.previewGroundPos, this.previewPos], !1),
|
|
175
|
+
width: e.width || 3,
|
|
176
|
+
material: new t.PolylineDashMaterialProperty({
|
|
177
|
+
color: C,
|
|
178
|
+
dashLength: 12,
|
|
179
|
+
dashPattern: 255
|
|
180
|
+
})
|
|
181
|
+
}
|
|
182
|
+
})), this.previewEntity || (this.previewEntity = a.entities.add({
|
|
183
|
+
polyline: {
|
|
184
|
+
positions: new t.CallbackProperty(() => !this.previewPos || !this.positions.length ? [] : [this.positions[this.positions.length - 1], this.previewPos], !1),
|
|
185
|
+
width: e.width || 3,
|
|
186
|
+
material: e.lineColor || e.color || t.Color.YELLOW,
|
|
187
|
+
depthFailMaterial: new t.PolylineDashMaterialProperty({
|
|
188
|
+
color: (e.dashLineColor || e.lineColor || e.color || t.Color.RED).withAlpha?.(0.9) || t.Color.RED,
|
|
189
|
+
dashLength: 12,
|
|
190
|
+
dashPattern: 255
|
|
191
|
+
})
|
|
192
|
+
}
|
|
193
|
+
}));
|
|
194
|
+
}
|
|
195
|
+
_clearPreviewState() {
|
|
196
|
+
this.previewLabelId && this.htmlLabelPool && (this.htmlLabelPool.removeByIds([this.previewLabelId]), this.previewLabelId = null), this.previewEntity && (this.viewer.entities.remove(this.previewEntity), this.previewEntity = null), this.previewGroundEntity && (this.viewer.entities.remove(this.previewGroundEntity), this.previewGroundEntity = null), this.previewPos = null, this.previewGroundPos = null, this.hoverPos = null;
|
|
197
|
+
}
|
|
198
|
+
_undoLastPoint() {
|
|
199
|
+
if (!this.positions.length) return;
|
|
200
|
+
this.positions.pop();
|
|
201
|
+
const i = this.tempPoints.pop();
|
|
202
|
+
i && this.viewer.entities.remove(i);
|
|
203
|
+
const e = this.groundLineEntities.pop();
|
|
204
|
+
if (e && this.viewer.entities.remove(e), this.segmentEntities.length > this.positions.length - 1) {
|
|
205
|
+
const t = this.segmentEntities.pop();
|
|
206
|
+
t && this.viewer.entities.remove(t);
|
|
207
|
+
}
|
|
208
|
+
if (this.segmentLabelIds.length > this.positions.length - 1 && this.htmlLabelPool) {
|
|
209
|
+
const t = this.segmentLabelIds.pop();
|
|
210
|
+
t && this.htmlLabelPool.removeByIds([t]);
|
|
211
|
+
}
|
|
212
|
+
if (!this.positions.length) {
|
|
213
|
+
this.firstHeight = null, this._clearPreviewState();
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
this.totalLabelId && this.htmlLabelPool && (this.htmlLabelPool.removeByIds([this.totalLabelId]), this.totalLabelId = null), this.previewLabelId && this.htmlLabelPool && (this.htmlLabelPool.removeByIds([this.previewLabelId]), this.previewLabelId = null);
|
|
217
|
+
}
|
|
218
|
+
_finishMeasurement(i, e) {
|
|
219
|
+
if (this.positions.length < 2) {
|
|
220
|
+
this.clear();
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
this.stop(), this._clearPreviewState();
|
|
224
|
+
let t = 0;
|
|
225
|
+
for (let n = 1; n < this.positions.length; n++) {
|
|
226
|
+
const r = this.positions[n - 1], c = this.positions[n], p = e.Cartographic.fromCartesian(r), m = e.Cartographic.fromCartesian(c), g = new e.EllipsoidGeodesic(p, m);
|
|
227
|
+
t += g.surfaceDistance;
|
|
228
|
+
}
|
|
229
|
+
const a = this.positions[this.positions.length - 1], s = e.Cartographic.fromCartesian(a), o = this.totalLabelId || `measure_horizontal_total_${Date.now()}`;
|
|
230
|
+
this.totalLabelId = o, this.htmlLabelPool.add(
|
|
231
|
+
{ text: `${t.toFixed(2)} m` },
|
|
232
|
+
{
|
|
233
|
+
id: o,
|
|
234
|
+
lon: e.Math.toDegrees(s.longitude),
|
|
235
|
+
lat: e.Math.toDegrees(s.latitude),
|
|
236
|
+
height: s.height || this.firstHeight || 0,
|
|
237
|
+
theme: "measure-horizontal-total",
|
|
238
|
+
show: !0
|
|
239
|
+
}
|
|
240
|
+
), this.labelEntity = this.totalLabelId;
|
|
241
|
+
const d = {
|
|
242
|
+
entity: this.segmentEntities,
|
|
243
|
+
label: this.labelEntity,
|
|
244
|
+
segmentLabels: this.segmentLabelIds,
|
|
245
|
+
positions: this.positions,
|
|
246
|
+
distance: t,
|
|
247
|
+
clear: () => this.clear()
|
|
248
|
+
};
|
|
249
|
+
i.onComplete?.(d);
|
|
250
|
+
}
|
|
251
|
+
_bindGlobalEvents(i, e, t) {
|
|
252
|
+
this.keydownHandler = (a) => {
|
|
253
|
+
a.key === "Escape" && (a.preventDefault(), this._finishMeasurement(i, e));
|
|
254
|
+
}, window.addEventListener("keydown", this.keydownHandler), this.contextMenuHandler = (a) => {
|
|
255
|
+
a.preventDefault();
|
|
256
|
+
}, t.canvas.addEventListener("contextmenu", this.contextMenuHandler);
|
|
257
|
+
}
|
|
183
258
|
stop() {
|
|
184
|
-
this.handler && (this.handler.destroy(), this.handler = null);
|
|
259
|
+
this.moveFrameId != null && (cancelAnimationFrame(this.moveFrameId), this.moveFrameId = null), this.pendingMove = null, this.lastMoveKey = null, this.keydownHandler && (window.removeEventListener("keydown", this.keydownHandler), this.keydownHandler = null), this.contextMenuHandler && (this.viewer.canvas.removeEventListener("contextmenu", this.contextMenuHandler), this.contextMenuHandler = null), this.handler && (this.handler.destroy(), this.handler = null), this.tooltip && (this.tooltip.destroy(), this.tooltip = null);
|
|
185
260
|
}
|
|
186
261
|
clear() {
|
|
187
262
|
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
263
|
}
|
|
189
264
|
rehydrate(i, e) {
|
|
190
|
-
const t = this.Cesium,
|
|
265
|
+
const t = this.Cesium, a = 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((h) => new t.Cartesian3(h[0], h[1], h[2]));
|
|
191
266
|
if (!r.length) return;
|
|
192
267
|
if (!this.htmlLabelPool) {
|
|
193
|
-
const
|
|
194
|
-
this.htmlLabelPool = e || new
|
|
195
|
-
createElement: (
|
|
196
|
-
|
|
268
|
+
const h = s.overlayContainerId || "html-label-container";
|
|
269
|
+
this.htmlLabelPool = e || new _(t, a, h), this.htmlLabelPool.registerTheme("measure-horizontal-total", {
|
|
270
|
+
createElement: (l, w) => {
|
|
271
|
+
l.innerHTML = String(w?.data?.text || ""), l.style.background = "rgba(0,0,0,0.6)", l.style.color = "#fff", l.style.font = "14px sans-serif", l.style.padding = "4px 6px", l.style.borderRadius = "4px", l.style.whiteSpace = "pre";
|
|
197
272
|
},
|
|
198
273
|
options: { offset: { x: 0, y: -10 } }
|
|
199
274
|
}), this.htmlLabelPool.registerTheme("measure-horizontal-seg", {
|
|
200
|
-
createElement: (
|
|
201
|
-
|
|
275
|
+
createElement: (l, w) => {
|
|
276
|
+
l.innerHTML = String(w?.data?.text || ""), l.style.background = "rgba(0,0,0,0.6)", l.style.color = "#fff", l.style.font = "14px sans-serif", l.style.padding = "4px 6px", l.style.borderRadius = "4px", l.style.whiteSpace = "pre";
|
|
202
277
|
},
|
|
203
278
|
options: { offset: { x: 0, y: -10 } }
|
|
204
279
|
});
|
|
205
280
|
}
|
|
206
|
-
for (const
|
|
207
|
-
const
|
|
208
|
-
this.tempPoints.push(
|
|
209
|
-
const w = t.Cartographic.fromCartesian(
|
|
281
|
+
for (const h of r) {
|
|
282
|
+
const l = a.entities.add({ position: h, point: { pixelSize: 8, color: s.pointColor || s.color || t.Color.YELLOW, disableDepthTestDistance: Number.POSITIVE_INFINITY } });
|
|
283
|
+
this.tempPoints.push(l);
|
|
284
|
+
const w = t.Cartographic.fromCartesian(h), u = t.Math.toDegrees(w.longitude), C = t.Math.toDegrees(w.latitude), L = a.scene.globe.getHeight(new t.Cartographic(w.longitude, w.latitude, 0)) || 0, f = t.Cartesian3.fromDegrees(u, C, L), v = a.entities.add({
|
|
210
285
|
polyline: {
|
|
211
|
-
positions: [f,
|
|
286
|
+
positions: [f, h],
|
|
212
287
|
width: n,
|
|
213
288
|
material: new t.PolylineDashMaterialProperty({ color: d, dashLength: 12, dashPattern: 255 })
|
|
214
289
|
}
|
|
215
290
|
});
|
|
216
|
-
this.groundLineEntities.push(
|
|
291
|
+
this.groundLineEntities.push(v);
|
|
217
292
|
}
|
|
218
|
-
for (let
|
|
219
|
-
const
|
|
293
|
+
for (let h = 1; h < r.length; h++) {
|
|
294
|
+
const l = r[h - 1], w = r[h], u = a.entities.add({
|
|
220
295
|
polyline: {
|
|
221
|
-
positions: [
|
|
296
|
+
positions: [l, w],
|
|
222
297
|
width: n,
|
|
223
298
|
material: o,
|
|
224
299
|
depthFailMaterial: new t.PolylineDashMaterialProperty({ color: d, dashLength: 12, dashPattern: 255 })
|
|
225
300
|
}
|
|
226
301
|
});
|
|
227
302
|
this.segmentEntities.push(u);
|
|
228
|
-
const C = t.Cartographic.fromCartesian(
|
|
229
|
-
this.segmentLabelIds.push(E), this.htmlLabelPool.add({ text: `${
|
|
303
|
+
const C = t.Cartographic.fromCartesian(l), L = t.Cartographic.fromCartesian(w), v = new t.EllipsoidGeodesic(C, L).surfaceDistance, y = new t.Cartesian3((l.x + w.x) / 2, (l.y + w.y) / 2, (l.z + w.z) / 2), b = t.Cartographic.fromCartesian(y), E = i.id + `_seg_${h - 1}`;
|
|
304
|
+
this.segmentLabelIds.push(E), this.htmlLabelPool.add({ text: `${v.toFixed(2)} m` }, {
|
|
230
305
|
id: E,
|
|
231
|
-
lon: t.Math.toDegrees(
|
|
232
|
-
lat: t.Math.toDegrees(
|
|
233
|
-
height:
|
|
306
|
+
lon: t.Math.toDegrees(b.longitude),
|
|
307
|
+
lat: t.Math.toDegrees(b.latitude),
|
|
308
|
+
height: b.height || 0,
|
|
234
309
|
theme: "measure-horizontal-seg",
|
|
235
310
|
show: !0,
|
|
236
311
|
style: { pointerEvents: "none", userSelect: "none", cursor: "default" }
|
|
237
312
|
});
|
|
238
313
|
}
|
|
239
314
|
let c = 0;
|
|
240
|
-
for (let
|
|
241
|
-
const
|
|
315
|
+
for (let h = 1; h < r.length; h++) {
|
|
316
|
+
const l = t.Cartographic.fromCartesian(r[h - 1]), w = t.Cartographic.fromCartesian(r[h]), u = new t.EllipsoidGeodesic(l, w);
|
|
242
317
|
c += u.surfaceDistance;
|
|
243
318
|
}
|
|
244
319
|
const p = r[r.length - 1], m = t.Cartographic.fromCartesian(p), g = i.id + "_total";
|
|
@@ -253,7 +328,7 @@ class me {
|
|
|
253
328
|
});
|
|
254
329
|
}
|
|
255
330
|
}
|
|
256
|
-
class
|
|
331
|
+
class we {
|
|
257
332
|
Cesium;
|
|
258
333
|
viewer;
|
|
259
334
|
handler = null;
|
|
@@ -275,18 +350,18 @@ class ge {
|
|
|
275
350
|
this.clear();
|
|
276
351
|
const e = this.Cesium, t = this.viewer;
|
|
277
352
|
if (!this.htmlLabelPool) {
|
|
278
|
-
const
|
|
279
|
-
this.htmlLabelPool = new
|
|
353
|
+
const a = i.overlayContainerId || "html-label-container";
|
|
354
|
+
this.htmlLabelPool = new _(e, t, a), this.htmlLabelPool.registerTheme("measure-vertical", {
|
|
280
355
|
createElement: (s, o) => {
|
|
281
356
|
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
357
|
},
|
|
283
358
|
options: { offset: { x: 0, y: -10 } }
|
|
284
359
|
});
|
|
285
360
|
}
|
|
286
|
-
this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((
|
|
287
|
-
const s = t.camera.getPickRay(
|
|
361
|
+
this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((a) => {
|
|
362
|
+
const s = t.camera.getPickRay(a.position);
|
|
288
363
|
let o = s ? t.scene.globe.pick(s, t.scene) : null;
|
|
289
|
-
if (o || (o = t.camera.pickEllipsoid(
|
|
364
|
+
if (o || (o = t.camera.pickEllipsoid(a.position, e.Ellipsoid.WGS84)), o || (o = t.scene.pickPosition(a.position)), !!o)
|
|
290
365
|
if (this.positions.length === 0) {
|
|
291
366
|
const d = e.Cartographic.fromCartesian(o);
|
|
292
367
|
this.baseCarto = new e.Cartographic(d.longitude, d.latitude, 0);
|
|
@@ -316,31 +391,31 @@ class ge {
|
|
|
316
391
|
});
|
|
317
392
|
} else {
|
|
318
393
|
if (!this.baseCarto || !this.baseUp) return;
|
|
319
|
-
const d = this.positions[0], n = t.camera.getPickRay(
|
|
394
|
+
const d = this.positions[0], n = t.camera.getPickRay(a.position);
|
|
320
395
|
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()),
|
|
396
|
+
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()), h = e.Cartesian3.dot(c, c), l = -e.Cartesian3.dot(c, m), w = e.Cartesian3.dot(m, m), u = -e.Cartesian3.dot(c, g), C = e.Cartesian3.dot(m, g), L = h * w - l * l;
|
|
322
397
|
if (Math.abs(L) < 1e-6) return;
|
|
323
|
-
const f = (
|
|
398
|
+
const f = (h * C - l * u) / L, v = e.Cartesian3.add(
|
|
324
399
|
p,
|
|
325
400
|
e.Cartesian3.multiplyByScalar(m, f, new e.Cartesian3()),
|
|
326
401
|
new e.Cartesian3()
|
|
327
402
|
);
|
|
328
|
-
this.positions[1] =
|
|
329
|
-
const y = i.lineColor || i.color || e.Color.CYAN,
|
|
403
|
+
this.positions[1] = v, this.stop(), this.previewEntity && (this.viewer.entities.remove(this.previewEntity), this.previewEntity = null), this.previewPointEntity && (this.viewer.entities.remove(this.previewPointEntity), this.previewPointEntity = null);
|
|
404
|
+
const y = i.lineColor || i.color || e.Color.CYAN, b = (i.dashLineColor || i.lineColor || i.color || e.Color.RED).withAlpha?.(0.9) || e.Color.RED;
|
|
330
405
|
this.entity = t.entities.add({
|
|
331
406
|
polyline: {
|
|
332
|
-
positions: [d,
|
|
407
|
+
positions: [d, v],
|
|
333
408
|
width: i.width || 3,
|
|
334
409
|
material: y,
|
|
335
410
|
depthFailMaterial: new e.PolylineDashMaterialProperty({
|
|
336
|
-
color:
|
|
411
|
+
color: b,
|
|
337
412
|
dashLength: 12,
|
|
338
413
|
dashPattern: 255
|
|
339
414
|
})
|
|
340
415
|
}
|
|
341
416
|
});
|
|
342
417
|
const E = t.entities.add({
|
|
343
|
-
position:
|
|
418
|
+
position: v,
|
|
344
419
|
point: {
|
|
345
420
|
pixelSize: 8,
|
|
346
421
|
color: i.pointColor || i.color || e.Color.YELLOW,
|
|
@@ -348,7 +423,7 @@ class ge {
|
|
|
348
423
|
}
|
|
349
424
|
});
|
|
350
425
|
this.tempPoints.push(E);
|
|
351
|
-
const x = this.baseCarto,
|
|
426
|
+
const x = this.baseCarto, T = e.Cartographic.fromCartesian(v), M = Math.abs((T.height || 0) - (x.height || 0)), P = new e.Cartesian3(
|
|
352
427
|
(this.positions[0].x + this.positions[1].x) / 2,
|
|
353
428
|
(this.positions[0].y + this.positions[1].y) / 2,
|
|
354
429
|
(this.positions[0].z + this.positions[1].z) / 2
|
|
@@ -376,28 +451,28 @@ class ge {
|
|
|
376
451
|
};
|
|
377
452
|
i.onComplete?.(S);
|
|
378
453
|
}
|
|
379
|
-
}, e.ScreenSpaceEventType.LEFT_CLICK), this.handler.setInputAction((
|
|
454
|
+
}, e.ScreenSpaceEventType.LEFT_CLICK), this.handler.setInputAction((a) => {
|
|
380
455
|
if (this.positions.length < 1) return;
|
|
381
456
|
if (!this.baseCarto || !this.baseUp) {
|
|
382
|
-
const
|
|
383
|
-
this.baseCarto = new e.Cartographic(
|
|
457
|
+
const T = e.Cartographic.fromCartesian(this.positions[0]);
|
|
458
|
+
this.baseCarto = new e.Cartographic(T.longitude, T.latitude, T.height || 0), this.baseUp = e.Ellipsoid.WGS84.geodeticSurfaceNormalCartographic(this.baseCarto);
|
|
384
459
|
}
|
|
385
|
-
const s = this.positions[0], o = t.camera.getPickRay(
|
|
460
|
+
const s = this.positions[0], o = t.camera.getPickRay(a.endPosition);
|
|
386
461
|
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),
|
|
462
|
+
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), h = e.Cartesian3.dot(c, c), l = -e.Cartesian3.dot(n, p), w = e.Cartesian3.dot(c, p), u = m * h - g * g;
|
|
388
463
|
if (Math.abs(u) < 1e-6) return;
|
|
389
|
-
const C = (m * w - g *
|
|
464
|
+
const C = (m * w - g * l) / u, L = e.Cartesian3.add(
|
|
390
465
|
r,
|
|
391
466
|
e.Cartesian3.multiplyByScalar(c, C, new e.Cartesian3()),
|
|
392
467
|
new e.Cartesian3()
|
|
393
468
|
);
|
|
394
469
|
if (this.positions[1] = L, !this.previewEntity) {
|
|
395
|
-
const
|
|
470
|
+
const T = i.lineColor || i.color || e.Color.CYAN, M = (i.dashLineColor || i.lineColor || i.color || e.Color.RED).withAlpha?.(0.9) || e.Color.RED;
|
|
396
471
|
this.previewEntity = t.entities.add({
|
|
397
472
|
polyline: {
|
|
398
473
|
positions: new e.CallbackProperty(() => this.positions.length < 2 ? [] : [this.positions[0], this.positions[1]], !1),
|
|
399
474
|
width: i.width || 3,
|
|
400
|
-
material:
|
|
475
|
+
material: T,
|
|
401
476
|
depthFailMaterial: new e.PolylineDashMaterialProperty({
|
|
402
477
|
color: M,
|
|
403
478
|
dashLength: 12,
|
|
@@ -414,11 +489,11 @@ class ge {
|
|
|
414
489
|
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
415
490
|
}
|
|
416
491
|
});
|
|
417
|
-
const f = this.baseCarto,
|
|
492
|
+
const f = this.baseCarto, v = e.Cartographic.fromCartesian(L), y = Math.abs((v.height || 0) - (f.height || 0)), b = new e.Cartesian3(
|
|
418
493
|
(this.positions[0].x + L.x) / 2,
|
|
419
494
|
(this.positions[0].y + L.y) / 2,
|
|
420
495
|
(this.positions[0].z + L.z) / 2
|
|
421
|
-
), E = e.Cartographic.fromCartesian(
|
|
496
|
+
), E = e.Cartographic.fromCartesian(b), x = this.previewLabelId || "measure_vertical_preview";
|
|
422
497
|
this.previewLabelId = x, this.htmlLabelPool.add(
|
|
423
498
|
{ text: `${y.toFixed(2)} m` },
|
|
424
499
|
{
|
|
@@ -440,20 +515,20 @@ class ge {
|
|
|
440
515
|
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
516
|
}
|
|
442
517
|
rehydrate(i, e) {
|
|
443
|
-
const t = this.Cesium,
|
|
518
|
+
const t = this.Cesium, a = 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
519
|
if (r.length < 2) return;
|
|
445
520
|
if (!this.htmlLabelPool) {
|
|
446
521
|
const f = s.overlayContainerId || "html-label-container";
|
|
447
|
-
this.htmlLabelPool = e || new
|
|
448
|
-
createElement: (
|
|
449
|
-
|
|
522
|
+
this.htmlLabelPool = e || new _(t, a, f), this.htmlLabelPool.registerTheme("measure-vertical", {
|
|
523
|
+
createElement: (v, y) => {
|
|
524
|
+
v.innerHTML = String(y?.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";
|
|
450
525
|
},
|
|
451
526
|
options: { offset: { x: 0, y: -10 } }
|
|
452
527
|
});
|
|
453
528
|
}
|
|
454
|
-
const c = r[0], p = r[1], m =
|
|
455
|
-
this.tempPoints.push(m), this.tempPoints.push(g), this.entity =
|
|
456
|
-
const
|
|
529
|
+
const c = r[0], p = r[1], m = a.entities.add({ position: c, point: { pixelSize: 8, color: s.pointColor || s.color || t.Color.YELLOW, disableDepthTestDistance: Number.POSITIVE_INFINITY } }), g = a.entities.add({ position: p, point: { pixelSize: 8, color: s.pointColor || s.color || t.Color.YELLOW, disableDepthTestDistance: Number.POSITIVE_INFINITY } });
|
|
530
|
+
this.tempPoints.push(m), this.tempPoints.push(g), this.entity = a.entities.add({ polyline: { positions: [c, p], width: n, material: o, depthFailMaterial: new t.PolylineDashMaterialProperty({ color: d, dashLength: 12, dashPattern: 255 }) } });
|
|
531
|
+
const h = t.Cartographic.fromCartesian(c), l = t.Cartographic.fromCartesian(p), w = Math.abs((l.height || 0) - (h.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
532
|
this.htmlLabelId = L, this.htmlLabelPool.add({ text: `${w.toFixed(2)} m` }, {
|
|
458
533
|
id: L,
|
|
459
534
|
lon: t.Math.toDegrees(C.longitude),
|
|
@@ -465,7 +540,7 @@ class ge {
|
|
|
465
540
|
});
|
|
466
541
|
}
|
|
467
542
|
}
|
|
468
|
-
class
|
|
543
|
+
class fe {
|
|
469
544
|
Cesium;
|
|
470
545
|
viewer;
|
|
471
546
|
handler = null;
|
|
@@ -494,8 +569,8 @@ class ue {
|
|
|
494
569
|
this.clear();
|
|
495
570
|
const e = this.Cesium, t = this.viewer;
|
|
496
571
|
if (!this.htmlLabelPool) {
|
|
497
|
-
const
|
|
498
|
-
this.htmlLabelPool = new
|
|
572
|
+
const a = i.overlayContainerId || "html-label-container";
|
|
573
|
+
this.htmlLabelPool = new _(e, t, a), this.htmlLabelPool.registerTheme("measure-triangle", {
|
|
499
574
|
createElement: (s, o) => {
|
|
500
575
|
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
576
|
},
|
|
@@ -512,8 +587,8 @@ class ue {
|
|
|
512
587
|
options: { offset: { x: 0, y: -10 } }
|
|
513
588
|
});
|
|
514
589
|
}
|
|
515
|
-
this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((
|
|
516
|
-
const s = t.scene.pickPosition(
|
|
590
|
+
this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((a) => {
|
|
591
|
+
const s = t.scene.pickPosition(a.position);
|
|
517
592
|
if (!s) return;
|
|
518
593
|
this.positions.push(s);
|
|
519
594
|
const o = t.entities.add({
|
|
@@ -528,20 +603,20 @@ class ue {
|
|
|
528
603
|
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
604
|
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
605
|
e.Cartographic.fromCartesian(m);
|
|
531
|
-
const
|
|
606
|
+
const h = Math.max(r, c), l = e.Cartesian3.fromDegrees(
|
|
532
607
|
e.Math.toDegrees(g.longitude),
|
|
533
608
|
e.Math.toDegrees(g.latitude),
|
|
534
|
-
|
|
609
|
+
h
|
|
535
610
|
), 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
611
|
polyline: {
|
|
537
|
-
positions: [p,
|
|
612
|
+
positions: [p, l],
|
|
538
613
|
width: i.width || 3,
|
|
539
614
|
material: w,
|
|
540
615
|
depthFailMaterial: new e.PolylineDashMaterialProperty({ color: u, dashLength: 12, dashPattern: 255 })
|
|
541
616
|
}
|
|
542
617
|
}), L = t.entities.add({
|
|
543
618
|
polyline: {
|
|
544
|
-
positions: [
|
|
619
|
+
positions: [l, m],
|
|
545
620
|
width: i.width || 3,
|
|
546
621
|
material: w,
|
|
547
622
|
depthFailMaterial: new e.PolylineDashMaterialProperty({ color: u, dashLength: 12, dashPattern: 255 })
|
|
@@ -555,68 +630,68 @@ class ue {
|
|
|
555
630
|
}
|
|
556
631
|
});
|
|
557
632
|
this.segmentEntities.push(C, L, f);
|
|
558
|
-
const
|
|
559
|
-
this.segmentLabelIds = [I, S,
|
|
560
|
-
const
|
|
561
|
-
this.angleLabelIds = [
|
|
562
|
-
const j = Math.max(0.01, Math.min(0.5, i.angleMarkerRatio ?? 0.2)),
|
|
563
|
-
if (
|
|
633
|
+
const v = e.Cartesian3.distance(p, l), y = e.Cartesian3.distance(l, m), b = e.Cartesian3.distance(p, m), E = new e.Cartesian3((p.x + l.x) / 2, (p.y + l.y) / 2, (p.z + l.z) / 2), x = new e.Cartesian3((l.x + m.x) / 2, (l.y + m.y) / 2, (l.z + m.z) / 2), T = 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(T), I = "measure_triangle_seg_v", S = "measure_triangle_seg_h", H = "measure_triangle_seg_hyp";
|
|
634
|
+
this.segmentLabelIds = [I, S, H], this.htmlLabelPool.add({ text: `${v.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: `${b.toFixed(2)} m` }, { id: H, 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" } });
|
|
635
|
+
const k = e.Cartesian3.subtract(m, p, new e.Cartesian3()), F = e.Cartesian3.subtract(l, p, new e.Cartesian3()), N = e.Cartesian3.subtract(l, m, new e.Cartesian3()), z = e.Cartesian3.subtract(p, m, new e.Cartesian3()), W = e.Cartesian3.dot(k, F), X = Math.sqrt(e.Cartesian3.dot(k, k)) * Math.sqrt(e.Cartesian3.dot(F, F)), Z = 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(W / (X || 1), -1), 1)), ie = Math.acos(Math.min(Math.max(Z / (oe || 1), -1), 1)), se = e.Cartographic.fromCartesian(p), O = e.Cartographic.fromCartesian(m), U = "measure_triangle_angle_a", B = "measure_triangle_angle_b";
|
|
636
|
+
this.angleLabelIds = [U, B], this.htmlLabelPool.add({ text: `${(te * 180 / Math.PI).toFixed(2)}°` }, { id: U, 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(O.longitude), lat: e.Math.toDegrees(O.latitude), height: O.height || 0, theme: "measure-triangle-angle", show: !0, style: { pointerEvents: "none", userSelect: "none", cursor: "default" } });
|
|
637
|
+
const j = Math.max(0.01, Math.min(0.5, i.angleMarkerRatio ?? 0.2)), R = Math.min(v, y) * j;
|
|
638
|
+
if (v > 1e-3 && y > 1e-3) {
|
|
564
639
|
const $ = e.Cartesian3.normalize(
|
|
565
|
-
e.Cartesian3.subtract(p,
|
|
640
|
+
e.Cartesian3.subtract(p, l, new e.Cartesian3()),
|
|
566
641
|
new e.Cartesian3()
|
|
567
642
|
), J = e.Cartesian3.normalize(
|
|
568
|
-
e.Cartesian3.subtract(m,
|
|
643
|
+
e.Cartesian3.subtract(m, l, new e.Cartesian3()),
|
|
569
644
|
new e.Cartesian3()
|
|
570
645
|
), Y = new e.Cartesian3(
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
646
|
+
l.x + $.x * R,
|
|
647
|
+
l.y + $.y * R,
|
|
648
|
+
l.z + $.z * R
|
|
574
649
|
), V = new e.Cartesian3(
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
),
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
650
|
+
l.x + J.x * R,
|
|
651
|
+
l.y + J.y * R,
|
|
652
|
+
l.z + J.z * R
|
|
653
|
+
), D = new e.Cartesian3(
|
|
654
|
+
l.x + $.x * R + J.x * R,
|
|
655
|
+
l.y + $.y * R + J.y * R,
|
|
656
|
+
l.z + $.z * R + J.z * R
|
|
582
657
|
), q = t.entities.add({
|
|
583
658
|
polyline: {
|
|
584
|
-
positions: [Y,
|
|
659
|
+
positions: [Y, D],
|
|
585
660
|
width: i.width || 3,
|
|
586
661
|
material: w,
|
|
587
662
|
depthFailMaterial: new e.PolylineDashMaterialProperty({ color: u, dashLength: 12, dashPattern: 255 })
|
|
588
663
|
}
|
|
589
|
-
}),
|
|
664
|
+
}), he = t.entities.add({
|
|
590
665
|
polyline: {
|
|
591
|
-
positions: [V,
|
|
666
|
+
positions: [V, D],
|
|
592
667
|
width: i.width || 3,
|
|
593
668
|
material: w,
|
|
594
669
|
depthFailMaterial: new e.PolylineDashMaterialProperty({ color: u, dashLength: 12, dashPattern: 255 })
|
|
595
670
|
}
|
|
596
671
|
});
|
|
597
|
-
this.angleMarkerEntities.push(q,
|
|
672
|
+
this.angleMarkerEntities.push(q, he);
|
|
598
673
|
}
|
|
599
674
|
this.previewLabelId && this.htmlLabelPool && (this.htmlLabelPool.removeByIds([this.previewLabelId]), this.previewLabelId = null);
|
|
600
675
|
const ne = {
|
|
601
676
|
entity: this.segmentEntities,
|
|
602
|
-
positions: [p, m,
|
|
603
|
-
lengths: { vertical:
|
|
677
|
+
positions: [p, m, l],
|
|
678
|
+
lengths: { vertical: v, horizontal: y, hypotenuse: b },
|
|
604
679
|
angles: { acuteA: te, acuteB: ie },
|
|
605
680
|
clear: () => this.clear()
|
|
606
681
|
};
|
|
607
682
|
i.onComplete?.(ne);
|
|
608
683
|
}
|
|
609
|
-
}, e.ScreenSpaceEventType.LEFT_CLICK), this.handler.setInputAction((
|
|
684
|
+
}, e.ScreenSpaceEventType.LEFT_CLICK), this.handler.setInputAction((a) => {
|
|
610
685
|
if (this.positions.length !== 1) return;
|
|
611
|
-
const s = t.scene.pickPosition(
|
|
686
|
+
const s = t.scene.pickPosition(a.endPosition);
|
|
612
687
|
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),
|
|
688
|
+
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), h = e.Cartesian3.fromDegrees(
|
|
614
689
|
this.Cesium.Math.toDegrees(m.longitude),
|
|
615
690
|
this.Cesium.Math.toDegrees(m.latitude),
|
|
616
691
|
g
|
|
617
692
|
);
|
|
618
|
-
this.previewLow = c, this.previewHigh = p, this.previewThird =
|
|
619
|
-
const
|
|
693
|
+
this.previewLow = c, this.previewHigh = p, this.previewThird = h;
|
|
694
|
+
const l = i.lineColor || i.color || e.Color.YELLOW, w = (i.dashLineColor || i.lineColor || i.color || e.Color.RED).withAlpha?.(0.9) || e.Color.RED;
|
|
620
695
|
if (this.previewPointEntity ? this.previewPointEntity.position = s : this.previewPointEntity = t.entities.add({
|
|
621
696
|
position: s,
|
|
622
697
|
point: {
|
|
@@ -625,66 +700,66 @@ class ue {
|
|
|
625
700
|
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
626
701
|
}
|
|
627
702
|
}), !this.previewSegmentEntities.length) {
|
|
628
|
-
const
|
|
703
|
+
const U = t.entities.add({
|
|
629
704
|
polyline: {
|
|
630
705
|
positions: new e.CallbackProperty(() => !this.previewLow || !this.previewThird ? [] : [this.previewLow, this.previewThird], !1),
|
|
631
706
|
width: i.width || 3,
|
|
632
|
-
material:
|
|
707
|
+
material: l,
|
|
633
708
|
depthFailMaterial: new e.PolylineDashMaterialProperty({ color: w, dashLength: 12, dashPattern: 255 })
|
|
634
709
|
}
|
|
635
710
|
}), B = t.entities.add({
|
|
636
711
|
polyline: {
|
|
637
712
|
positions: new e.CallbackProperty(() => !this.previewThird || !this.previewHigh ? [] : [this.previewThird, this.previewHigh], !1),
|
|
638
713
|
width: i.width || 3,
|
|
639
|
-
material:
|
|
714
|
+
material: l,
|
|
640
715
|
depthFailMaterial: new e.PolylineDashMaterialProperty({ color: w, dashLength: 12, dashPattern: 255 })
|
|
641
716
|
}
|
|
642
717
|
}), j = t.entities.add({
|
|
643
718
|
polyline: {
|
|
644
719
|
positions: new e.CallbackProperty(() => !this.previewLow || !this.previewHigh ? [] : [this.previewLow, this.previewHigh], !1),
|
|
645
720
|
width: i.width || 3,
|
|
646
|
-
material:
|
|
721
|
+
material: l,
|
|
647
722
|
depthFailMaterial: new e.PolylineDashMaterialProperty({ color: w, dashLength: 12, dashPattern: 255 })
|
|
648
723
|
}
|
|
649
724
|
});
|
|
650
|
-
this.previewSegmentEntities.push(
|
|
725
|
+
this.previewSegmentEntities.push(U, B, j);
|
|
651
726
|
}
|
|
652
|
-
const u = e.Cartesian3.distance(c,
|
|
653
|
-
this.segmentLabelIds.length === 0 && (this.segmentLabelIds = [
|
|
654
|
-
const se = Math.max(0.01, Math.min(0.5, i.angleMarkerRatio ?? 0.2)),
|
|
727
|
+
const u = e.Cartesian3.distance(c, h), C = e.Cartesian3.distance(h, p), L = e.Cartesian3.distance(c, p), f = e.Cartesian3.subtract(p, c, new e.Cartesian3()), v = e.Cartesian3.subtract(h, c, new e.Cartesian3()), y = e.Cartesian3.subtract(h, p, new e.Cartesian3()), b = e.Cartesian3.subtract(c, p, new e.Cartesian3()), E = e.Cartesian3.dot(f, v), x = Math.sqrt(e.Cartesian3.dot(f, f)) * Math.sqrt(e.Cartesian3.dot(v, v)), T = e.Cartesian3.dot(y, b), M = Math.sqrt(e.Cartesian3.dot(y, y)) * Math.sqrt(e.Cartesian3.dot(b, b)), P = Math.acos(Math.min(Math.max(E / (x || 1), -1), 1)), A = Math.acos(Math.min(Math.max(T / (M || 1), -1), 1)), I = new e.Cartesian3((c.x + h.x) / 2, (c.y + h.y) / 2, (c.z + h.z) / 2), S = new e.Cartesian3((h.x + p.x) / 2, (h.y + p.y) / 2, (h.z + p.z) / 2), H = new e.Cartesian3((c.x + p.x) / 2, (c.y + p.y) / 2, (c.z + p.z) / 2), k = e.Cartographic.fromCartesian(I), F = e.Cartographic.fromCartesian(S), N = e.Cartographic.fromCartesian(H), z = e.Cartographic.fromCartesian(c), W = e.Cartographic.fromCartesian(p), X = "measure_triangle_seg_v", Z = "measure_triangle_seg_h", oe = "measure_triangle_seg_hyp", te = "measure_triangle_angle_a", ie = "measure_triangle_angle_b";
|
|
728
|
+
this.segmentLabelIds.length === 0 && (this.segmentLabelIds = [X, Z, oe]), this.angleLabelIds.length === 0 && (this.angleLabelIds = [te, ie]), this.htmlLabelPool.add({ text: `${u.toFixed(2)} m` }, { id: X, lon: e.Math.toDegrees(k.longitude), lat: e.Math.toDegrees(k.latitude), height: k.height || 0, theme: "measure-triangle-seg", show: !0, style: { pointerEvents: "none", userSelect: "none", cursor: "default" } }), this.htmlLabelPool.add({ text: `${C.toFixed(2)} m` }, { id: Z, 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(W.longitude), lat: e.Math.toDegrees(W.latitude), height: W.height || 0, theme: "measure-triangle-angle", show: !0, style: { pointerEvents: "none", userSelect: "none", cursor: "default" } });
|
|
729
|
+
const se = Math.max(0.01, Math.min(0.5, i.angleMarkerRatio ?? 0.2)), O = Math.min(u, C) * se;
|
|
655
730
|
if (u > 1e-3 && C > 1e-3) {
|
|
656
|
-
const
|
|
657
|
-
e.Cartesian3.subtract(c,
|
|
731
|
+
const U = e.Cartesian3.normalize(
|
|
732
|
+
e.Cartesian3.subtract(c, h, new e.Cartesian3()),
|
|
658
733
|
new e.Cartesian3()
|
|
659
734
|
), B = e.Cartesian3.normalize(
|
|
660
|
-
e.Cartesian3.subtract(p,
|
|
735
|
+
e.Cartesian3.subtract(p, h, new e.Cartesian3()),
|
|
661
736
|
new e.Cartesian3()
|
|
662
737
|
), j = new e.Cartesian3(
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
),
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
738
|
+
h.x + U.x * O,
|
|
739
|
+
h.y + U.y * O,
|
|
740
|
+
h.z + U.z * O
|
|
741
|
+
), R = new e.Cartesian3(
|
|
742
|
+
h.x + B.x * O,
|
|
743
|
+
h.y + B.y * O,
|
|
744
|
+
h.z + B.z * O
|
|
670
745
|
), ne = new e.Cartesian3(
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
746
|
+
h.x + U.x * O + B.x * O,
|
|
747
|
+
h.y + U.y * O + B.y * O,
|
|
748
|
+
h.z + U.z * O + B.z * O
|
|
674
749
|
);
|
|
675
|
-
if (this.previewMarkerP1 = j, this.previewMarkerP2 =
|
|
750
|
+
if (this.previewMarkerP1 = j, this.previewMarkerP2 = R, this.previewMarkerCorner = ne, !this.previewAngleMarkerEntities.length) {
|
|
676
751
|
const $ = t.entities.add({
|
|
677
752
|
polyline: {
|
|
678
753
|
positions: new e.CallbackProperty(() => !this.previewMarkerP1 || !this.previewMarkerCorner ? [] : [this.previewMarkerP1, this.previewMarkerCorner], !1),
|
|
679
754
|
width: i.width || 3,
|
|
680
|
-
material:
|
|
755
|
+
material: l,
|
|
681
756
|
depthFailMaterial: new e.PolylineDashMaterialProperty({ color: w, dashLength: 12, dashPattern: 255 })
|
|
682
757
|
}
|
|
683
758
|
}), J = t.entities.add({
|
|
684
759
|
polyline: {
|
|
685
760
|
positions: new e.CallbackProperty(() => !this.previewMarkerP2 || !this.previewMarkerCorner ? [] : [this.previewMarkerP2, this.previewMarkerCorner], !1),
|
|
686
761
|
width: i.width || 3,
|
|
687
|
-
material:
|
|
762
|
+
material: l,
|
|
688
763
|
depthFailMaterial: new e.PolylineDashMaterialProperty({ color: w, dashLength: 12, dashPattern: 255 })
|
|
689
764
|
}
|
|
690
765
|
});
|
|
@@ -700,53 +775,53 @@ class ue {
|
|
|
700
775
|
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
776
|
}
|
|
702
777
|
rehydrate(i, e) {
|
|
703
|
-
const t = this.Cesium,
|
|
778
|
+
const t = this.Cesium, a = 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
779
|
if (r.length < 2) return;
|
|
705
780
|
if (!this.htmlLabelPool) {
|
|
706
781
|
const V = s.overlayContainerId || "html-label-container";
|
|
707
|
-
this.htmlLabelPool = e || new
|
|
708
|
-
createElement: (
|
|
709
|
-
|
|
782
|
+
this.htmlLabelPool = e || new _(t, a, V), this.htmlLabelPool.registerTheme("measure-triangle", {
|
|
783
|
+
createElement: (D, q) => {
|
|
784
|
+
D.innerHTML = String(q?.data?.text || ""), D.style.background = "rgba(0,0,0,0.6)", D.style.color = "#fff", D.style.font = "14px sans-serif", D.style.padding = "4px 6px", D.style.borderRadius = "4px", D.style.whiteSpace = "pre";
|
|
710
785
|
},
|
|
711
786
|
options: { offset: { x: 0, y: -10 } }
|
|
712
787
|
}), this.htmlLabelPool.registerTheme("measure-triangle-seg", {
|
|
713
|
-
createElement: (
|
|
714
|
-
|
|
788
|
+
createElement: (D, q) => {
|
|
789
|
+
D.innerHTML = String(q?.data?.text || ""), D.style.background = "rgba(0,0,0,0.6)", D.style.color = "#fff", D.style.font = "14px sans-serif", D.style.padding = "4px 6px", D.style.borderRadius = "4px", D.style.whiteSpace = "pre";
|
|
715
790
|
},
|
|
716
791
|
options: { offset: { x: 0, y: -10 } }
|
|
717
792
|
}), this.htmlLabelPool.registerTheme("measure-triangle-angle", {
|
|
718
|
-
createElement: (
|
|
719
|
-
|
|
793
|
+
createElement: (D, q) => {
|
|
794
|
+
D.innerHTML = String(q?.data?.text || ""), D.style.background = "rgba(0,0,0,0.6)", D.style.color = "#fff", D.style.font = "14px sans-serif", D.style.padding = "4px 6px", D.style.borderRadius = "4px", D.style.whiteSpace = "pre";
|
|
720
795
|
},
|
|
721
796
|
options: { offset: { x: 0, y: -10 } }
|
|
722
797
|
});
|
|
723
798
|
}
|
|
724
|
-
const c = t.Cartographic.fromCartesian(r[0]), p = t.Cartographic.fromCartesian(r[1]), m = c.height || 0, g = p.height || 0,
|
|
799
|
+
const c = t.Cartographic.fromCartesian(r[0]), p = t.Cartographic.fromCartesian(r[1]), m = c.height || 0, g = p.height || 0, h = m <= g ? r[0] : r[1], l = m > g ? r[0] : r[1], w = a.entities.add({ position: h, point: { pixelSize: 8, color: s.pointColor || s.color || t.Color.YELLOW, disableDepthTestDistance: Number.POSITIVE_INFINITY } }), u = a.entities.add({ position: l, point: { pixelSize: 8, color: s.pointColor || s.color || t.Color.YELLOW, disableDepthTestDistance: Number.POSITIVE_INFINITY } });
|
|
725
800
|
this.pointEntities.push(w, u);
|
|
726
|
-
const C = t.Cartographic.fromCartesian(
|
|
801
|
+
const C = t.Cartographic.fromCartesian(h), L = Math.max(m, g), f = t.Cartesian3.fromDegrees(
|
|
727
802
|
t.Math.toDegrees(C.longitude),
|
|
728
803
|
t.Math.toDegrees(C.latitude),
|
|
729
804
|
L
|
|
730
|
-
),
|
|
731
|
-
polyline: { positions: [
|
|
732
|
-
}), y =
|
|
733
|
-
polyline: { positions: [f,
|
|
734
|
-
}),
|
|
735
|
-
polyline: { positions: [
|
|
805
|
+
), v = a.entities.add({
|
|
806
|
+
polyline: { positions: [h, f], width: n, material: o, depthFailMaterial: new t.PolylineDashMaterialProperty({ color: d, dashLength: 12, dashPattern: 255 }) }
|
|
807
|
+
}), y = a.entities.add({
|
|
808
|
+
polyline: { positions: [f, l], width: n, material: o, depthFailMaterial: new t.PolylineDashMaterialProperty({ color: d, dashLength: 12, dashPattern: 255 }) }
|
|
809
|
+
}), b = a.entities.add({
|
|
810
|
+
polyline: { positions: [h, l], width: n, material: o, depthFailMaterial: new t.PolylineDashMaterialProperty({ color: d, dashLength: 12, dashPattern: 255 }) }
|
|
736
811
|
});
|
|
737
|
-
this.segmentEntities.push(
|
|
738
|
-
const E = t.Cartesian3.distance(
|
|
739
|
-
this.segmentLabelIds = [
|
|
740
|
-
const z = t.Cartesian3.subtract(
|
|
741
|
-
this.angleLabelIds = [ne, $], this.htmlLabelPool.add({ text: `${
|
|
812
|
+
this.segmentEntities.push(v, y, b);
|
|
813
|
+
const E = t.Cartesian3.distance(h, f), x = t.Cartesian3.distance(f, l), T = t.Cartesian3.distance(h, l), M = new t.Cartesian3((h.x + f.x) / 2, (h.y + f.y) / 2, (h.z + f.z) / 2), P = new t.Cartesian3((f.x + l.x) / 2, (f.y + l.y) / 2, (f.z + l.z) / 2), A = new t.Cartesian3((h.x + l.x) / 2, (h.y + l.y) / 2, (h.z + l.z) / 2), I = t.Cartographic.fromCartesian(M), S = t.Cartographic.fromCartesian(P), H = t.Cartographic.fromCartesian(A), k = i.id + "_tri_v", F = i.id + "_tri_h", N = i.id + "_tri_hyp";
|
|
814
|
+
this.segmentLabelIds = [k, F, N], this.htmlLabelPool.add({ text: `${E.toFixed(2)} m` }, { id: k, 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: `${T.toFixed(2)} m` }, { id: N, lon: t.Math.toDegrees(H.longitude), lat: t.Math.toDegrees(H.latitude), height: H.height || 0, theme: "measure-triangle-seg", show: !0, style: { pointerEvents: "none", userSelect: "none", cursor: "default" } });
|
|
815
|
+
const z = t.Cartesian3.subtract(l, h, new t.Cartesian3()), W = t.Cartesian3.subtract(f, h, new t.Cartesian3()), X = t.Cartesian3.subtract(f, l, new t.Cartesian3()), Z = t.Cartesian3.subtract(h, l, new t.Cartesian3()), oe = t.Cartesian3.dot(z, W), te = Math.sqrt(t.Cartesian3.dot(z, z)) * Math.sqrt(t.Cartesian3.dot(W, W)), ie = t.Cartesian3.dot(X, Z), se = Math.sqrt(t.Cartesian3.dot(X, X)) * Math.sqrt(t.Cartesian3.dot(Z, Z)), O = Math.acos(Math.min(Math.max(oe / (te || 1), -1), 1)), U = Math.acos(Math.min(Math.max(ie / (se || 1), -1), 1)), B = t.Cartographic.fromCartesian(h), j = t.Cartographic.fromCartesian(l), R = s.labelText || { angle: "角度" }, ne = i.id + "_tri_angA", $ = i.id + "_tri_angB";
|
|
816
|
+
this.angleLabelIds = [ne, $], this.htmlLabelPool.add({ text: `${R.angle}:${(O * 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: `${R.angle}:${(U * 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
817
|
const J = Math.max(0.01, Math.min(0.5, s.angleMarkerRatio ?? 0.2)), Y = Math.min(E, x) * J;
|
|
743
818
|
if (E > 1e-3 && x > 1e-3) {
|
|
744
|
-
const V = t.Cartesian3.normalize(t.Cartesian3.subtract(
|
|
745
|
-
this.angleMarkerEntities.push(
|
|
819
|
+
const V = t.Cartesian3.normalize(t.Cartesian3.subtract(h, f, new t.Cartesian3()), new t.Cartesian3()), D = t.Cartesian3.normalize(t.Cartesian3.subtract(l, 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), he = new t.Cartesian3(f.x + D.x * Y, f.y + D.y * Y, f.z + D.z * Y), me = new t.Cartesian3(f.x + V.x * Y + D.x * Y, f.y + V.y * Y + D.y * Y, f.z + V.z * Y + D.z * Y), xe = a.entities.add({ polyline: { positions: [q, me], width: n, material: o, depthFailMaterial: new t.PolylineDashMaterialProperty({ color: d, dashLength: 12, dashPattern: 255 }) } }), Me = a.entities.add({ polyline: { positions: [he, me], width: n, material: o, depthFailMaterial: new t.PolylineDashMaterialProperty({ color: d, dashLength: 12, dashPattern: 255 }) } });
|
|
820
|
+
this.angleMarkerEntities.push(xe, Me);
|
|
746
821
|
}
|
|
747
822
|
}
|
|
748
823
|
}
|
|
749
|
-
class
|
|
824
|
+
class Ce {
|
|
750
825
|
Cesium;
|
|
751
826
|
viewer;
|
|
752
827
|
handler = null;
|
|
@@ -766,16 +841,16 @@ class ye {
|
|
|
766
841
|
this.clear();
|
|
767
842
|
const e = this.Cesium, t = this.viewer;
|
|
768
843
|
if (!this.htmlLabelPool) {
|
|
769
|
-
const
|
|
770
|
-
this.htmlLabelPool = new
|
|
844
|
+
const a = i.overlayContainerId || "html-label-container";
|
|
845
|
+
this.htmlLabelPool = new _(e, t, a), this.htmlLabelPool.registerTheme("measure-space", {
|
|
771
846
|
createElement: (s, o) => {
|
|
772
847
|
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
848
|
},
|
|
774
849
|
options: { offset: { x: 0, y: -10 } }
|
|
775
850
|
});
|
|
776
851
|
}
|
|
777
|
-
this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((
|
|
778
|
-
const s = t.scene.pickPosition(
|
|
852
|
+
this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((a) => {
|
|
853
|
+
const s = t.scene.pickPosition(a.position);
|
|
779
854
|
if (!s) return;
|
|
780
855
|
this.positions.push(s);
|
|
781
856
|
const o = t.entities.add({
|
|
@@ -801,11 +876,11 @@ class ye {
|
|
|
801
876
|
})
|
|
802
877
|
}
|
|
803
878
|
});
|
|
804
|
-
const p = e.Cartesian3.distance(d, n), m = n, g = e.Cartographic.fromCartesian(m),
|
|
805
|
-
this.htmlLabelId =
|
|
879
|
+
const p = e.Cartesian3.distance(d, n), m = n, g = e.Cartographic.fromCartesian(m), h = this.htmlLabelId || `measure_space_${Date.now()}`;
|
|
880
|
+
this.htmlLabelId = h, this.htmlLabelPool.add(
|
|
806
881
|
{ text: `${p.toFixed(2)} m` },
|
|
807
882
|
{
|
|
808
|
-
id:
|
|
883
|
+
id: h,
|
|
809
884
|
lon: e.Math.toDegrees(g.longitude),
|
|
810
885
|
lat: e.Math.toDegrees(g.latitude),
|
|
811
886
|
height: g.height || 0,
|
|
@@ -814,18 +889,18 @@ class ye {
|
|
|
814
889
|
style: { pointerEvents: "none", userSelect: "none", cursor: "default" }
|
|
815
890
|
}
|
|
816
891
|
);
|
|
817
|
-
const
|
|
892
|
+
const l = {
|
|
818
893
|
entity: this.entity,
|
|
819
894
|
label: this.labelEntity,
|
|
820
895
|
positions: this.positions,
|
|
821
896
|
distance: p,
|
|
822
897
|
clear: () => this.clear()
|
|
823
898
|
};
|
|
824
|
-
i.onComplete?.(
|
|
899
|
+
i.onComplete?.(l);
|
|
825
900
|
}
|
|
826
|
-
}, e.ScreenSpaceEventType.LEFT_CLICK), this.handler.setInputAction((
|
|
901
|
+
}, e.ScreenSpaceEventType.LEFT_CLICK), this.handler.setInputAction((a) => {
|
|
827
902
|
if (this.positions.length !== 1) return;
|
|
828
|
-
const s = t.scene.pickPosition(
|
|
903
|
+
const s = t.scene.pickPosition(a.endPosition);
|
|
829
904
|
if (!s) return;
|
|
830
905
|
this.previewPos = s;
|
|
831
906
|
const o = this.positions[0], d = e.Cartesian3.distance(o, s), n = new e.Cartesian3(
|
|
@@ -867,11 +942,11 @@ class ye {
|
|
|
867
942
|
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
943
|
}
|
|
869
944
|
rehydrate(i, e) {
|
|
870
|
-
const t = this.Cesium,
|
|
945
|
+
const t = this.Cesium, a = 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
946
|
if (r.length) {
|
|
872
947
|
if (!this.htmlLabelPool) {
|
|
873
948
|
const c = s.overlayContainerId || "html-label-container";
|
|
874
|
-
this.htmlLabelPool = e || new
|
|
949
|
+
this.htmlLabelPool = e || new _(t, a, c), this.htmlLabelPool.registerTheme("measure-space", {
|
|
875
950
|
createElement: (p, m) => {
|
|
876
951
|
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
952
|
},
|
|
@@ -879,12 +954,12 @@ class ye {
|
|
|
879
954
|
});
|
|
880
955
|
}
|
|
881
956
|
if (r.length >= 1) {
|
|
882
|
-
const c =
|
|
957
|
+
const c = a.entities.add({ position: r[0], point: { pixelSize: 8, color: s.pointColor || s.color || t.Color.YELLOW, disableDepthTestDistance: Number.POSITIVE_INFINITY } });
|
|
883
958
|
this.tempPoints.push(c);
|
|
884
959
|
}
|
|
885
960
|
if (r.length >= 2) {
|
|
886
|
-
const c =
|
|
887
|
-
this.tempPoints.push(c), this.entity =
|
|
961
|
+
const c = a.entities.add({ position: r[1], point: { pixelSize: 8, color: s.pointColor || s.color || t.Color.YELLOW, disableDepthTestDistance: Number.POSITIVE_INFINITY } });
|
|
962
|
+
this.tempPoints.push(c), this.entity = a.entities.add({
|
|
888
963
|
polyline: {
|
|
889
964
|
positions: [r[0], r[1]],
|
|
890
965
|
width: n,
|
|
@@ -906,7 +981,8 @@ class ye {
|
|
|
906
981
|
}
|
|
907
982
|
}
|
|
908
983
|
}
|
|
909
|
-
class
|
|
984
|
+
class ae {
|
|
985
|
+
static TIP_TEXT = "单击左键添加点,右键撤销,双击左键或Esc结束";
|
|
910
986
|
Cesium;
|
|
911
987
|
viewer;
|
|
912
988
|
handler = null;
|
|
@@ -926,6 +1002,9 @@ class we {
|
|
|
926
1002
|
previewLabelId = null;
|
|
927
1003
|
segmentLabelIds = [];
|
|
928
1004
|
angleLabelIds = [];
|
|
1005
|
+
tooltip = null;
|
|
1006
|
+
keydownHandler = null;
|
|
1007
|
+
contextMenuHandler = null;
|
|
929
1008
|
constructor(i, e) {
|
|
930
1009
|
this.Cesium = i, this.viewer = e;
|
|
931
1010
|
}
|
|
@@ -933,8 +1012,8 @@ class we {
|
|
|
933
1012
|
this.clear();
|
|
934
1013
|
const e = this.Cesium, t = this.viewer;
|
|
935
1014
|
if (!this.htmlLabelPool) {
|
|
936
|
-
const
|
|
937
|
-
this.htmlLabelPool = new
|
|
1015
|
+
const a = i.overlayContainerId || "html-label-container";
|
|
1016
|
+
this.htmlLabelPool = new _(e, t, a), this.htmlLabelPool.registerTheme("measure-area", {
|
|
938
1017
|
createElement: (s, o) => {
|
|
939
1018
|
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
1019
|
},
|
|
@@ -951,8 +1030,8 @@ class we {
|
|
|
951
1030
|
options: { offset: { x: 0, y: -10 } }
|
|
952
1031
|
});
|
|
953
1032
|
}
|
|
954
|
-
this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((
|
|
955
|
-
const s = t.scene.pickPosition(
|
|
1033
|
+
this.tooltip = new pe(), this.tooltip.show(ae.TIP_TEXT), this._bindGlobalEvents(i, e, t), this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((a) => {
|
|
1034
|
+
const s = t.scene.pickPosition(a.position);
|
|
956
1035
|
if (!s) return;
|
|
957
1036
|
this.positions.push(s);
|
|
958
1037
|
const o = t.entities.add({
|
|
@@ -991,9 +1070,9 @@ class we {
|
|
|
991
1070
|
}
|
|
992
1071
|
this.edgeEntities = [];
|
|
993
1072
|
}
|
|
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,
|
|
1073
|
+
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, h = this.positions.concat([this.positions[0]]), l = t.entities.add({
|
|
995
1074
|
polyline: {
|
|
996
|
-
positions:
|
|
1075
|
+
positions: h,
|
|
997
1076
|
width: i.width || 2,
|
|
998
1077
|
material: m,
|
|
999
1078
|
clampToGround: !1,
|
|
@@ -1005,22 +1084,22 @@ class we {
|
|
|
1005
1084
|
})
|
|
1006
1085
|
}
|
|
1007
1086
|
});
|
|
1008
|
-
this.edgeEntities.push(
|
|
1087
|
+
this.edgeEntities.push(l);
|
|
1009
1088
|
}
|
|
1010
|
-
}, e.ScreenSpaceEventType.LEFT_CLICK), this.handler.setInputAction((
|
|
1089
|
+
}, e.ScreenSpaceEventType.LEFT_CLICK), this.handler.setInputAction((a) => {
|
|
1011
1090
|
if (this.positions.length === 0) return;
|
|
1012
|
-
const s = t.scene.pickPosition(
|
|
1091
|
+
const s = t.scene.pickPosition(a.endPosition);
|
|
1013
1092
|
if (!s) return;
|
|
1014
1093
|
this.previewPos = s;
|
|
1015
1094
|
const o = this.positions.concat([s]), d = new e.Cartesian3(
|
|
1016
|
-
o.reduce((
|
|
1017
|
-
o.reduce((
|
|
1018
|
-
o.reduce((
|
|
1095
|
+
o.reduce((h, l) => h + l.x, 0) / o.length,
|
|
1096
|
+
o.reduce((h, l) => h + l.y, 0) / o.length,
|
|
1097
|
+
o.reduce((h, l) => h + l.z, 0) / o.length
|
|
1019
1098
|
), r = new e.EllipsoidTangentPlane(d, e.Ellipsoid.WGS84).projectPointsOntoPlane(o);
|
|
1020
1099
|
let c = 0;
|
|
1021
|
-
for (let
|
|
1022
|
-
const
|
|
1023
|
-
c += r[
|
|
1100
|
+
for (let h = 0; h < r.length; h++) {
|
|
1101
|
+
const l = (h + 1) % r.length;
|
|
1102
|
+
c += r[h].x * r[l].y - r[l].x * r[h].y;
|
|
1024
1103
|
}
|
|
1025
1104
|
c = Math.abs(c) / 2;
|
|
1026
1105
|
const p = e.Cartographic.fromCartesian(d), m = this.previewLabelId || "measure_area_preview";
|
|
@@ -1037,7 +1116,7 @@ class we {
|
|
|
1037
1116
|
show: !0
|
|
1038
1117
|
}
|
|
1039
1118
|
), !this.previewEntity) {
|
|
1040
|
-
const
|
|
1119
|
+
const h = i.color || e.Color.YELLOW.withAlpha(0.4);
|
|
1041
1120
|
this.previewEntity = t.entities.add({
|
|
1042
1121
|
polygon: {
|
|
1043
1122
|
hierarchy: new e.CallbackProperty(() => {
|
|
@@ -1045,17 +1124,17 @@ class we {
|
|
|
1045
1124
|
const L = this.positions.concat([this.previewPos]);
|
|
1046
1125
|
return new e.PolygonHierarchy(L);
|
|
1047
1126
|
}, !1),
|
|
1048
|
-
material:
|
|
1127
|
+
material: h,
|
|
1049
1128
|
perPositionHeight: !0,
|
|
1050
1129
|
arcType: e.ArcType.NONE
|
|
1051
1130
|
}
|
|
1052
1131
|
});
|
|
1053
|
-
const
|
|
1132
|
+
const l = i.lineColor || i.color || e.Color.YELLOW, w = (i.dashLineColor || i.lineColor || i.color || e.Color.RED).withAlpha?.(0.9) || e.Color.RED;
|
|
1054
1133
|
this.previewEdgeEntity = t.entities.add({
|
|
1055
1134
|
polyline: {
|
|
1056
1135
|
positions: new e.CallbackProperty(() => !this.previewPos || !this.positions.length ? [] : this.positions.concat([this.previewPos, this.positions[0]]), !1),
|
|
1057
1136
|
width: i.width || 2,
|
|
1058
|
-
material:
|
|
1137
|
+
material: l,
|
|
1059
1138
|
clampToGround: !1,
|
|
1060
1139
|
arcType: e.ArcType.NONE,
|
|
1061
1140
|
depthFailMaterial: new e.PolylineDashMaterialProperty({
|
|
@@ -1076,92 +1155,13 @@ class we {
|
|
|
1076
1155
|
this.previewPointEntities.push(C);
|
|
1077
1156
|
}
|
|
1078
1157
|
}, e.ScreenSpaceEventType.MOUSE_MOVE), this.handler.setInputAction(() => {
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
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);
|
|
1158
|
+
this._finishMeasurement(i, e, !0);
|
|
1159
|
+
}, e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK), this.handler.setInputAction(() => {
|
|
1160
|
+
this._undoLastPoint(i, e, t);
|
|
1161
|
+
}, e.ScreenSpaceEventType.RIGHT_CLICK);
|
|
1162
1162
|
}
|
|
1163
1163
|
stop() {
|
|
1164
|
-
this.handler && (this.handler.destroy(), this.handler = null);
|
|
1164
|
+
this.keydownHandler && (window.removeEventListener("keydown", this.keydownHandler), this.keydownHandler = null), this.contextMenuHandler && (this.viewer.canvas.removeEventListener("contextmenu", this.contextMenuHandler), this.contextMenuHandler = null), this.handler && (this.handler.destroy(), this.handler = null), this.tooltip && (this.tooltip.destroy(), this.tooltip = null);
|
|
1165
1165
|
}
|
|
1166
1166
|
clear() {
|
|
1167
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) {
|
|
@@ -1190,41 +1190,187 @@ class we {
|
|
|
1190
1190
|
}
|
|
1191
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
1192
|
}
|
|
1193
|
+
_clearPreviewState() {
|
|
1194
|
+
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) {
|
|
1195
|
+
for (const i of this.previewPointEntities)
|
|
1196
|
+
try {
|
|
1197
|
+
this.viewer.entities.remove(i);
|
|
1198
|
+
} catch {
|
|
1199
|
+
}
|
|
1200
|
+
this.previewPointEntities = [];
|
|
1201
|
+
}
|
|
1202
|
+
this.previewLabelId && this.htmlLabelPool && (this.htmlLabelPool.removeByIds([this.previewLabelId]), this.previewLabelId = null), this.previewPos = null;
|
|
1203
|
+
}
|
|
1204
|
+
_rebuildShape(i, e, t) {
|
|
1205
|
+
if (this.primitive && (t.scene.primitives.remove(this.primitive), this.primitive = null), this.edgeEntities.length) {
|
|
1206
|
+
for (const r of this.edgeEntities)
|
|
1207
|
+
try {
|
|
1208
|
+
t.entities.remove(r);
|
|
1209
|
+
} catch {
|
|
1210
|
+
}
|
|
1211
|
+
this.edgeEntities = [];
|
|
1212
|
+
}
|
|
1213
|
+
if (!this.positions.length) return;
|
|
1214
|
+
const a = new e.PolygonHierarchy(this.positions.slice()), s = new e.PolygonGeometry({
|
|
1215
|
+
polygonHierarchy: a,
|
|
1216
|
+
vertexFormat: e.MaterialAppearance.VERTEX_FORMAT,
|
|
1217
|
+
perPositionHeight: !0,
|
|
1218
|
+
arcType: e.ArcType.NONE
|
|
1219
|
+
}), o = new e.GeometryInstance({ geometry: s }), d = i.color || e.Color.YELLOW.withAlpha(0.4), n = i.color && i.color.withAlpha ? i.color.withAlpha(0.25) : e.Color.RED.withAlpha(0.4);
|
|
1220
|
+
if (this.primitive = new e.Primitive({
|
|
1221
|
+
geometryInstances: o,
|
|
1222
|
+
appearance: new e.MaterialAppearance({
|
|
1223
|
+
material: e.Material.fromType("Color", { color: d }),
|
|
1224
|
+
translucent: !0,
|
|
1225
|
+
closed: !0
|
|
1226
|
+
}),
|
|
1227
|
+
depthFailAppearance: new e.MaterialAppearance({
|
|
1228
|
+
material: e.Material.fromType("Color", { color: n }),
|
|
1229
|
+
translucent: !0,
|
|
1230
|
+
closed: !0
|
|
1231
|
+
})
|
|
1232
|
+
}), t.scene.primitives.add(this.primitive), this.positions.length >= 2) {
|
|
1233
|
+
const r = i.lineColor || i.color || e.Color.YELLOW, c = (i.dashLineColor || i.lineColor || i.color || e.Color.RED).withAlpha?.(0.9) || e.Color.RED, p = this.positions.concat([this.positions[0]]), m = t.entities.add({
|
|
1234
|
+
polyline: {
|
|
1235
|
+
positions: p,
|
|
1236
|
+
width: i.width || 2,
|
|
1237
|
+
material: r,
|
|
1238
|
+
clampToGround: !1,
|
|
1239
|
+
arcType: e.ArcType.NONE,
|
|
1240
|
+
depthFailMaterial: new e.PolylineDashMaterialProperty({
|
|
1241
|
+
color: c,
|
|
1242
|
+
dashLength: 12,
|
|
1243
|
+
dashPattern: 255
|
|
1244
|
+
})
|
|
1245
|
+
}
|
|
1246
|
+
});
|
|
1247
|
+
this.edgeEntities.push(m);
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
_undoLastPoint(i, e, t) {
|
|
1251
|
+
if (!this.positions.length) return;
|
|
1252
|
+
this.positions.pop();
|
|
1253
|
+
const a = this.tempPoints.pop();
|
|
1254
|
+
a && t.entities.remove(a), this._clearPreviewState(), this._rebuildShape(i, e, t);
|
|
1255
|
+
}
|
|
1256
|
+
_finishMeasurement(i, e, t) {
|
|
1257
|
+
if (t && this.positions.length >= 3) {
|
|
1258
|
+
this.positions.pop();
|
|
1259
|
+
const g = this.tempPoints.pop();
|
|
1260
|
+
g && this.viewer.entities.remove(g);
|
|
1261
|
+
}
|
|
1262
|
+
if (this.positions.length < 3) {
|
|
1263
|
+
this.clear();
|
|
1264
|
+
return;
|
|
1265
|
+
}
|
|
1266
|
+
this._clearPreviewState(), this.stop();
|
|
1267
|
+
const a = new e.Cartesian3(
|
|
1268
|
+
this.positions.reduce((g, h) => g + h.x, 0) / this.positions.length,
|
|
1269
|
+
this.positions.reduce((g, h) => g + h.y, 0) / this.positions.length,
|
|
1270
|
+
this.positions.reduce((g, h) => g + h.z, 0) / this.positions.length
|
|
1271
|
+
), o = new e.EllipsoidTangentPlane(a, e.Ellipsoid.WGS84).projectPointsOntoPlane(this.positions);
|
|
1272
|
+
let d = 0;
|
|
1273
|
+
for (let g = 0; g < o.length; g++) {
|
|
1274
|
+
const h = (g + 1) % o.length;
|
|
1275
|
+
d += o[g].x * o[h].y - o[h].x * o[g].y;
|
|
1276
|
+
}
|
|
1277
|
+
d = Math.abs(d) / 2;
|
|
1278
|
+
const n = e.Cartographic.fromCartesian(a), r = this.htmlLabelId || `measure_area_${Date.now()}`;
|
|
1279
|
+
this.htmlLabelId = r;
|
|
1280
|
+
const c = i.labelText || { area: "面积", side: "边长", angle: "角度" };
|
|
1281
|
+
this.htmlLabelPool.add(
|
|
1282
|
+
{ text: `${c.area}:${d.toFixed(2)} m²` },
|
|
1283
|
+
{
|
|
1284
|
+
id: r,
|
|
1285
|
+
lon: e.Math.toDegrees(n.longitude),
|
|
1286
|
+
lat: e.Math.toDegrees(n.latitude),
|
|
1287
|
+
height: n.height || 0,
|
|
1288
|
+
theme: "measure-area",
|
|
1289
|
+
show: !0
|
|
1290
|
+
}
|
|
1291
|
+
), this.labelEntity = this.htmlLabelId;
|
|
1292
|
+
for (let g = 0; g < this.positions.length; g++) {
|
|
1293
|
+
const h = (g + 1) % this.positions.length, l = this.positions[g], w = this.positions[h], u = e.Cartographic.fromCartesian(l), C = e.Cartographic.fromCartesian(w), f = new e.EllipsoidGeodesic(u, C).surfaceDistance, v = new e.Cartesian3((l.x + w.x) / 2, (l.y + w.y) / 2, (l.z + w.z) / 2), y = e.Cartographic.fromCartesian(v), b = `measure_area_seg_${Date.now()}_${g}`;
|
|
1294
|
+
this.segmentLabelIds.push(b), this.htmlLabelPool.add(
|
|
1295
|
+
{ text: `${c.side}:${f.toFixed(2)} m` },
|
|
1296
|
+
{
|
|
1297
|
+
id: b,
|
|
1298
|
+
lon: e.Math.toDegrees(y.longitude),
|
|
1299
|
+
lat: e.Math.toDegrees(y.latitude),
|
|
1300
|
+
height: y.height || 0,
|
|
1301
|
+
theme: "measure-area-seg",
|
|
1302
|
+
show: !0
|
|
1303
|
+
}
|
|
1304
|
+
);
|
|
1305
|
+
}
|
|
1306
|
+
const p = o;
|
|
1307
|
+
for (let g = 0; g < p.length; g++) {
|
|
1308
|
+
const h = p[(g - 1 + p.length) % p.length], l = p[g], w = p[(g + 1) % p.length], u = h.x - l.x, C = h.y - l.y, L = w.x - l.x, f = w.y - l.y, v = Math.sqrt(u * u + C * C), y = Math.sqrt(L * L + f * f);
|
|
1309
|
+
if (!v || !y) continue;
|
|
1310
|
+
const b = u / v * (L / y) + C / v * (f / y), E = Math.acos(Math.min(1, Math.max(-1, b))) * (180 / Math.PI), x = e.Cartographic.fromCartesian(this.positions[g]), T = `measure_area_angle_${Date.now()}_${g}`;
|
|
1311
|
+
this.angleLabelIds.push(T), this.htmlLabelPool.add(
|
|
1312
|
+
{ text: `${c.angle}:${E.toFixed(2)} °` },
|
|
1313
|
+
{
|
|
1314
|
+
id: T,
|
|
1315
|
+
lon: e.Math.toDegrees(x.longitude),
|
|
1316
|
+
lat: e.Math.toDegrees(x.latitude),
|
|
1317
|
+
height: x.height || 0,
|
|
1318
|
+
theme: "measure-area-angle",
|
|
1319
|
+
show: !0
|
|
1320
|
+
}
|
|
1321
|
+
);
|
|
1322
|
+
}
|
|
1323
|
+
const m = {
|
|
1324
|
+
entity: this.primitive,
|
|
1325
|
+
label: this.labelEntity,
|
|
1326
|
+
positions: this.positions,
|
|
1327
|
+
area: d,
|
|
1328
|
+
clear: () => this.clear()
|
|
1329
|
+
};
|
|
1330
|
+
i.onComplete?.(m);
|
|
1331
|
+
}
|
|
1332
|
+
_bindGlobalEvents(i, e, t) {
|
|
1333
|
+
this.keydownHandler = (a) => {
|
|
1334
|
+
a.key === "Escape" && (a.preventDefault(), this._finishMeasurement(i, e, !1));
|
|
1335
|
+
}, window.addEventListener("keydown", this.keydownHandler), this.contextMenuHandler = (a) => {
|
|
1336
|
+
a.preventDefault();
|
|
1337
|
+
}, t.canvas.addEventListener("contextmenu", this.contextMenuHandler);
|
|
1338
|
+
}
|
|
1193
1339
|
rehydrate(i, e) {
|
|
1194
|
-
const t = this.Cesium,
|
|
1340
|
+
const t = this.Cesium, a = this.viewer, s = i.options || {}, o = (i.positions || []).map((v) => new t.Cartesian3(v[0], v[1], v[2]));
|
|
1195
1341
|
if (o.length < 3) return;
|
|
1196
1342
|
if (!this.htmlLabelPool) {
|
|
1197
|
-
const
|
|
1198
|
-
this.htmlLabelPool = e || new
|
|
1199
|
-
createElement: (y,
|
|
1200
|
-
y.innerHTML = String(
|
|
1343
|
+
const v = s.overlayContainerId || "html-label-container";
|
|
1344
|
+
this.htmlLabelPool = e || new _(t, a, v), this.htmlLabelPool.registerTheme("measure-area", {
|
|
1345
|
+
createElement: (y, b) => {
|
|
1346
|
+
y.innerHTML = String(b?.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
1347
|
},
|
|
1202
1348
|
options: { offset: { x: 0, y: -10 } }
|
|
1203
1349
|
}), this.htmlLabelPool.registerTheme("measure-area-seg", {
|
|
1204
|
-
createElement: (y,
|
|
1205
|
-
y.innerHTML = String(
|
|
1350
|
+
createElement: (y, b) => {
|
|
1351
|
+
y.innerHTML = String(b?.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
1352
|
},
|
|
1207
1353
|
options: { offset: { x: 0, y: -10 } }
|
|
1208
1354
|
}), this.htmlLabelPool.registerTheme("measure-area-angle", {
|
|
1209
|
-
createElement: (y,
|
|
1210
|
-
y.innerHTML = String(
|
|
1355
|
+
createElement: (y, b) => {
|
|
1356
|
+
y.innerHTML = String(b?.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
1357
|
},
|
|
1212
1358
|
options: { offset: { x: 0, y: -10 } }
|
|
1213
1359
|
});
|
|
1214
1360
|
}
|
|
1215
|
-
for (const
|
|
1216
|
-
const y =
|
|
1361
|
+
for (const v of o) {
|
|
1362
|
+
const y = a.entities.add({ position: v, point: { pixelSize: 8, color: s.color || t.Color.YELLOW, disableDepthTestDistance: Number.POSITIVE_INFINITY } });
|
|
1217
1363
|
this.tempPoints.push(y);
|
|
1218
1364
|
}
|
|
1219
1365
|
const d = new t.Cartesian3(
|
|
1220
|
-
o.reduce((
|
|
1221
|
-
o.reduce((
|
|
1222
|
-
o.reduce((
|
|
1366
|
+
o.reduce((v, y) => v + y.x, 0) / o.length,
|
|
1367
|
+
o.reduce((v, y) => v + y.y, 0) / o.length,
|
|
1368
|
+
o.reduce((v, y) => v + y.z, 0) / o.length
|
|
1223
1369
|
), r = new t.EllipsoidTangentPlane(d, t.Ellipsoid.WGS84).projectPointsOntoPlane(o);
|
|
1224
1370
|
let c = 0;
|
|
1225
|
-
for (let
|
|
1226
|
-
const y = (
|
|
1227
|
-
c += r[
|
|
1371
|
+
for (let v = 0; v < r.length; v++) {
|
|
1372
|
+
const y = (v + 1) % r.length;
|
|
1373
|
+
c += r[v].x * r[y].y - r[y].x * r[v].y;
|
|
1228
1374
|
}
|
|
1229
1375
|
c = Math.abs(c) / 2;
|
|
1230
1376
|
const p = t.Cartographic.fromCartesian(d), m = i.id + "_area";
|
|
@@ -1238,26 +1384,26 @@ class we {
|
|
|
1238
1384
|
theme: "measure-area",
|
|
1239
1385
|
show: !0
|
|
1240
1386
|
});
|
|
1241
|
-
const
|
|
1387
|
+
const h = new t.PolygonHierarchy(o), l = new t.PolygonGeometry({ polygonHierarchy: h, vertexFormat: t.MaterialAppearance.VERTEX_FORMAT, perPositionHeight: !0 }), w = new t.GeometryInstance({ geometry: l }), 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
1388
|
geometryInstances: w,
|
|
1243
1389
|
appearance: new t.MaterialAppearance({ material: t.Material.fromType("Color", { color: u }), translucent: !0, closed: !0 }),
|
|
1244
1390
|
depthFailAppearance: new t.MaterialAppearance({ material: t.Material.fromType("Color", { color: C }), translucent: !0, closed: !0 })
|
|
1245
1391
|
});
|
|
1246
|
-
|
|
1247
|
-
for (let
|
|
1248
|
-
const y = (
|
|
1392
|
+
a.scene.primitives.add(L), this.primitive = L;
|
|
1393
|
+
for (let v = 0; v < o.length; v++) {
|
|
1394
|
+
const y = (v + 1) % o.length, b = o[v], E = o[y], x = t.Cartographic.fromCartesian(b), T = t.Cartographic.fromCartesian(E), P = new t.EllipsoidGeodesic(x, T).surfaceDistance, A = new t.Cartesian3((b.x + E.x) / 2, (b.y + E.y) / 2, (b.z + E.z) / 2), I = t.Cartographic.fromCartesian(A), S = i.id + `_area_seg_${v}`;
|
|
1249
1395
|
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
1396
|
}
|
|
1251
1397
|
const f = r;
|
|
1252
|
-
for (let
|
|
1253
|
-
const y = f[(
|
|
1398
|
+
for (let v = 0; v < f.length; v++) {
|
|
1399
|
+
const y = f[(v - 1 + f.length) % f.length], b = f[v], E = f[(v + 1) % f.length], x = y.x - b.x, T = y.y - b.y, M = E.x - b.x, P = E.y - b.y, A = Math.sqrt(x * x + T * T), I = Math.sqrt(M * M + P * P);
|
|
1254
1400
|
if (!A || !I) continue;
|
|
1255
|
-
const S = x / A * (M / I) +
|
|
1256
|
-
this.angleLabelIds.push(F), this.htmlLabelPool.add({ text: `${g.angle}:${
|
|
1401
|
+
const S = x / A * (M / I) + T / A * (P / I), H = Math.acos(Math.min(1, Math.max(-1, S))) * (180 / Math.PI), k = t.Cartographic.fromCartesian(o[v]), F = i.id + `_area_angle_${v}`;
|
|
1402
|
+
this.angleLabelIds.push(F), this.htmlLabelPool.add({ text: `${g.angle}:${H.toFixed(2)} °` }, { id: F, lon: t.Math.toDegrees(k.longitude), lat: t.Math.toDegrees(k.latitude), height: k.height || 0, theme: "measure-area-angle", show: !0 });
|
|
1257
1403
|
}
|
|
1258
1404
|
}
|
|
1259
1405
|
}
|
|
1260
|
-
class
|
|
1406
|
+
class ve {
|
|
1261
1407
|
Cesium;
|
|
1262
1408
|
viewer;
|
|
1263
1409
|
handler = null;
|
|
@@ -1278,8 +1424,8 @@ class Ce {
|
|
|
1278
1424
|
this.clear();
|
|
1279
1425
|
const e = this.Cesium, t = this.viewer;
|
|
1280
1426
|
if (!this.htmlLabelPool) {
|
|
1281
|
-
const
|
|
1282
|
-
this.htmlLabelPool = new
|
|
1427
|
+
const a = i.overlayContainerId || "html-label-container";
|
|
1428
|
+
this.htmlLabelPool = new _(e, t, a), this.htmlLabelPool.registerTheme("measure-circle", {
|
|
1283
1429
|
createElement: (s, o) => {
|
|
1284
1430
|
const d = o?.data?.text || "";
|
|
1285
1431
|
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";
|
|
@@ -1287,8 +1433,8 @@ class Ce {
|
|
|
1287
1433
|
options: { offset: { x: 0, y: -10 } }
|
|
1288
1434
|
});
|
|
1289
1435
|
}
|
|
1290
|
-
this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((
|
|
1291
|
-
const s = t.scene.pickPosition(
|
|
1436
|
+
this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((a) => {
|
|
1437
|
+
const s = t.scene.pickPosition(a.position);
|
|
1292
1438
|
if (s && (this.positions.push(s), this.positions.length === 2)) {
|
|
1293
1439
|
this.stop();
|
|
1294
1440
|
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;
|
|
@@ -1314,15 +1460,15 @@ ${p.circumference}:${c.toFixed(2)} m`,
|
|
|
1314
1460
|
show: !1
|
|
1315
1461
|
}
|
|
1316
1462
|
}), this.previewEntity && (t.entities.remove(this.previewEntity), this.previewEntity = null);
|
|
1317
|
-
const g = e.Cartographic.fromCartesian(o),
|
|
1463
|
+
const g = e.Cartographic.fromCartesian(o), h = new e.EllipseGeometry({
|
|
1318
1464
|
center: o,
|
|
1319
1465
|
semiMajorAxis: n,
|
|
1320
1466
|
semiMinorAxis: n,
|
|
1321
1467
|
height: g.height || 0,
|
|
1322
1468
|
vertexFormat: e.MaterialAppearance.VERTEX_FORMAT
|
|
1323
|
-
}),
|
|
1469
|
+
}), l = new e.GeometryInstance({ geometry: h }), 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
1470
|
this.ellipsePrimitive && (t.scene.primitives.remove(this.ellipsePrimitive), this.ellipsePrimitive = null), this.ellipsePrimitive = new e.Primitive({
|
|
1325
|
-
geometryInstances:
|
|
1471
|
+
geometryInstances: l,
|
|
1326
1472
|
appearance: new e.MaterialAppearance({
|
|
1327
1473
|
material: e.Material.fromType("Color", { color: w }),
|
|
1328
1474
|
translucent: !0,
|
|
@@ -1334,12 +1480,12 @@ ${p.circumference}:${c.toFixed(2)} m`,
|
|
|
1334
1480
|
closed: !0
|
|
1335
1481
|
})
|
|
1336
1482
|
}), 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),
|
|
1483
|
+
const C = e.Cartographic.fromCartesian(o), L = e.Math.toDegrees(C.longitude), f = e.Math.toDegrees(C.latitude), v = C.height || 0, y = this.htmlLabelId || `measure_circle_${Date.now()}`;
|
|
1338
1484
|
this.htmlLabelId = y;
|
|
1339
|
-
const
|
|
1485
|
+
const b = `${p.radius}:${n.toFixed(2)} m
|
|
1340
1486
|
${p.area}:${r.toFixed(2)} m²
|
|
1341
1487
|
${p.circumference}:${c.toFixed(2)} m`;
|
|
1342
|
-
this.htmlLabelPool.add({ text:
|
|
1488
|
+
this.htmlLabelPool.add({ text: b }, { id: y, lon: L, lat: f, height: v, theme: "measure-circle", show: !0 });
|
|
1343
1489
|
const E = {
|
|
1344
1490
|
entity: this.entity,
|
|
1345
1491
|
label: this.labelEntity,
|
|
@@ -1351,9 +1497,9 @@ ${p.circumference}:${c.toFixed(2)} m`;
|
|
|
1351
1497
|
};
|
|
1352
1498
|
i.onComplete?.(E);
|
|
1353
1499
|
}
|
|
1354
|
-
}, e.ScreenSpaceEventType.LEFT_CLICK), this.handler.setInputAction((
|
|
1500
|
+
}, e.ScreenSpaceEventType.LEFT_CLICK), this.handler.setInputAction((a) => {
|
|
1355
1501
|
if (this.positions.length !== 1) return;
|
|
1356
|
-
const s = this.positions[0], o = t.camera.getPickRay(
|
|
1502
|
+
const s = this.positions[0], o = t.camera.getPickRay(a.endPosition), d = t.scene.globe.pick(o, t.scene);
|
|
1357
1503
|
if (!d) return;
|
|
1358
1504
|
const n = e.Cartesian3.distance(s, d);
|
|
1359
1505
|
this.currentRadius = n;
|
|
@@ -1380,12 +1526,12 @@ ${m.circumference}:${p.toFixed(2)} m`,
|
|
|
1380
1526
|
show: !1
|
|
1381
1527
|
}
|
|
1382
1528
|
});
|
|
1383
|
-
const
|
|
1529
|
+
const h = e.Cartographic.fromCartesian(s), l = e.Math.toDegrees(h.longitude), w = e.Math.toDegrees(h.latitude), u = h.height || 0, C = this.htmlLabelId || `measure_circle_${Date.now()}`;
|
|
1384
1530
|
this.htmlLabelId = C;
|
|
1385
1531
|
const L = `${m.radius}:${n.toFixed(2)} m
|
|
1386
1532
|
${m.area}:${c.toFixed(2)} m²
|
|
1387
1533
|
${m.circumference}:${p.toFixed(2)} m`;
|
|
1388
|
-
if (this.htmlLabelPool.add({ text: L }, { id: C, lon:
|
|
1534
|
+
if (this.htmlLabelPool.add({ text: L }, { id: C, lon: l, lat: w, height: u, theme: "measure-circle", show: !0 }), !this.previewEntity) {
|
|
1389
1535
|
const f = i.color || e.Color.YELLOW.withAlpha(0.5);
|
|
1390
1536
|
this.previewEntity = t.entities.add({
|
|
1391
1537
|
position: s,
|
|
@@ -1406,33 +1552,34 @@ ${m.circumference}:${p.toFixed(2)} m`;
|
|
|
1406
1552
|
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
1553
|
}
|
|
1408
1554
|
rehydrate(i, e) {
|
|
1409
|
-
const t = this.Cesium,
|
|
1555
|
+
const t = this.Cesium, a = this.viewer, s = i.options || {}, o = (i.positions || []).map((y) => new t.Cartesian3(y[0], y[1], y[2]));
|
|
1410
1556
|
if (o.length < 2) return;
|
|
1411
1557
|
if (!this.htmlLabelPool) {
|
|
1412
1558
|
const y = s.overlayContainerId || "html-label-container";
|
|
1413
|
-
this.htmlLabelPool = e || new
|
|
1414
|
-
createElement: (
|
|
1559
|
+
this.htmlLabelPool = e || new _(t, a, y), this.htmlLabelPool.registerTheme("measure-circle", {
|
|
1560
|
+
createElement: (b, E) => {
|
|
1415
1561
|
const x = E?.data?.text || "";
|
|
1416
|
-
|
|
1562
|
+
b.innerHTML = String(x), 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";
|
|
1417
1563
|
},
|
|
1418
1564
|
options: { offset: { x: 0, y: -10 } }
|
|
1419
1565
|
});
|
|
1420
1566
|
}
|
|
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 }),
|
|
1422
|
-
geometryInstances:
|
|
1423
|
-
appearance: new t.MaterialAppearance({ material: t.Material.fromType("Color", { color:
|
|
1567
|
+
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 }), h = new t.GeometryInstance({ geometry: g }), l = 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({
|
|
1568
|
+
geometryInstances: h,
|
|
1569
|
+
appearance: new t.MaterialAppearance({ material: t.Material.fromType("Color", { color: l }), translucent: !0, closed: !0 }),
|
|
1424
1570
|
depthFailAppearance: new t.MaterialAppearance({ material: t.Material.fromType("Color", { color: w }), translucent: !0, closed: !0 })
|
|
1425
1571
|
});
|
|
1426
|
-
|
|
1572
|
+
a.scene.primitives.add(u), this.ellipsePrimitive = u, this.entity = u, this.isPrimitive = !0;
|
|
1427
1573
|
const C = t.Cartographic.fromCartesian(d), L = i.id + "_circle";
|
|
1428
1574
|
this.htmlLabelId = L;
|
|
1429
|
-
const f = s.labelText || { radius: "半径", area: "面积", circumference: "周长" },
|
|
1575
|
+
const f = s.labelText || { radius: "半径", area: "面积", circumference: "周长" }, v = `${f.radius}:${r.toFixed(2)} m
|
|
1430
1576
|
${f.area}:${c.toFixed(2)} m²
|
|
1431
1577
|
${f.circumference}:${p.toFixed(2)} m`;
|
|
1432
|
-
this.htmlLabelPool.add({ text:
|
|
1578
|
+
this.htmlLabelPool.add({ text: v }, { id: L, lon: t.Math.toDegrees(C.longitude), lat: t.Math.toDegrees(C.latitude), height: C.height || 0, theme: "measure-circle", show: !0 });
|
|
1433
1579
|
}
|
|
1434
1580
|
}
|
|
1435
|
-
class
|
|
1581
|
+
class le {
|
|
1582
|
+
static TIP_TEXT = "单击左键添加点,右键撤销,双击左键或Esc结束";
|
|
1436
1583
|
Cesium;
|
|
1437
1584
|
viewer;
|
|
1438
1585
|
handler = null;
|
|
@@ -1449,6 +1596,9 @@ class fe {
|
|
|
1449
1596
|
totalLabelId = null;
|
|
1450
1597
|
segmentLabelIds = [];
|
|
1451
1598
|
previewLabelId = null;
|
|
1599
|
+
tooltip = null;
|
|
1600
|
+
keydownHandler = null;
|
|
1601
|
+
contextMenuHandler = null;
|
|
1452
1602
|
constructor(i, e) {
|
|
1453
1603
|
this.Cesium = i, this.viewer = e;
|
|
1454
1604
|
}
|
|
@@ -1456,8 +1606,8 @@ class fe {
|
|
|
1456
1606
|
this.clear();
|
|
1457
1607
|
const e = this.Cesium, t = this.viewer;
|
|
1458
1608
|
if (!this.htmlLabelPool) {
|
|
1459
|
-
const
|
|
1460
|
-
this.htmlLabelPool = new
|
|
1609
|
+
const a = i.overlayContainerId || "html-label-container";
|
|
1610
|
+
this.htmlLabelPool = new _(e, t, a), this.htmlLabelPool.registerTheme("measure-polyline-total", {
|
|
1461
1611
|
createElement: (s, o) => {
|
|
1462
1612
|
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
1613
|
},
|
|
@@ -1469,8 +1619,8 @@ class fe {
|
|
|
1469
1619
|
options: { offset: { x: 0, y: -10 } }
|
|
1470
1620
|
});
|
|
1471
1621
|
}
|
|
1472
|
-
this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((
|
|
1473
|
-
const s = t.scene.pickPosition(
|
|
1622
|
+
this.tooltip = new pe(), this.tooltip.show(le.TIP_TEXT), this._bindGlobalEvents(i, e, t), this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((a) => {
|
|
1623
|
+
const s = t.scene.pickPosition(a.position);
|
|
1474
1624
|
if (!s) return;
|
|
1475
1625
|
this.positions.push(s);
|
|
1476
1626
|
const o = t.entities.add({
|
|
@@ -1497,64 +1647,26 @@ class fe {
|
|
|
1497
1647
|
(d.x + n.x) / 2,
|
|
1498
1648
|
(d.y + n.y) / 2,
|
|
1499
1649
|
(d.z + n.z) / 2
|
|
1500
|
-
),
|
|
1501
|
-
this.segmentLabelIds.push(
|
|
1650
|
+
), h = e.Cartographic.fromCartesian(g), l = `measure_polyline_seg_${this.segmentLabelIds.length}_${Date.now()}`;
|
|
1651
|
+
this.segmentLabelIds.push(l), this.htmlLabelPool.add(
|
|
1502
1652
|
{ text: `${m.toFixed(2)} m` },
|
|
1503
1653
|
{
|
|
1504
|
-
id:
|
|
1505
|
-
lon: e.Math.toDegrees(
|
|
1506
|
-
lat: e.Math.toDegrees(
|
|
1507
|
-
height:
|
|
1654
|
+
id: l,
|
|
1655
|
+
lon: e.Math.toDegrees(h.longitude),
|
|
1656
|
+
lat: e.Math.toDegrees(h.latitude),
|
|
1657
|
+
height: h.height || 0,
|
|
1508
1658
|
theme: "measure-polyline-seg",
|
|
1509
1659
|
show: !0
|
|
1510
1660
|
}
|
|
1511
1661
|
);
|
|
1512
1662
|
}
|
|
1513
1663
|
}, e.ScreenSpaceEventType.LEFT_CLICK), this.handler.setInputAction(() => {
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
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) => {
|
|
1664
|
+
this._finishMeasurement(i, e, !0);
|
|
1665
|
+
}, e.ScreenSpaceEventType.LEFT_DOUBLE_CLICK), this.handler.setInputAction(() => {
|
|
1666
|
+
this._undoLastPoint();
|
|
1667
|
+
}, e.ScreenSpaceEventType.RIGHT_CLICK), this.handler.setInputAction((a) => {
|
|
1556
1668
|
if (this.positions.length === 0) return;
|
|
1557
|
-
const s = t.scene.pickPosition(
|
|
1669
|
+
const s = t.scene.pickPosition(a.endPosition);
|
|
1558
1670
|
if (!s) return;
|
|
1559
1671
|
this.hoverPos = s, this.previewPos = s;
|
|
1560
1672
|
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(
|
|
@@ -1587,43 +1699,109 @@ class fe {
|
|
|
1587
1699
|
}, e.ScreenSpaceEventType.MOUSE_MOVE);
|
|
1588
1700
|
}
|
|
1589
1701
|
stop() {
|
|
1590
|
-
this.handler && (this.handler.destroy(), this.handler = null);
|
|
1702
|
+
this.keydownHandler && (window.removeEventListener("keydown", this.keydownHandler), this.keydownHandler = null), this.contextMenuHandler && (this.viewer.canvas.removeEventListener("contextmenu", this.contextMenuHandler), this.contextMenuHandler = null), this.handler && (this.handler.destroy(), this.handler = null), this.tooltip && (this.tooltip.destroy(), this.tooltip = null);
|
|
1591
1703
|
}
|
|
1592
1704
|
clear() {
|
|
1593
1705
|
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
1706
|
}
|
|
1707
|
+
_clearPreviewState() {
|
|
1708
|
+
this.previewEntity && (this.viewer.entities.remove(this.previewEntity), this.previewEntity = null), this.previewLabelId && this.htmlLabelPool && (this.htmlLabelPool.removeByIds([this.previewLabelId]), this.previewLabelId = null), this.previewPos = null, this.hoverPos = null;
|
|
1709
|
+
}
|
|
1710
|
+
_undoLastPoint() {
|
|
1711
|
+
if (!this.positions.length) return;
|
|
1712
|
+
this.positions.pop();
|
|
1713
|
+
const i = this.tempPoints.pop();
|
|
1714
|
+
if (i && this.viewer.entities.remove(i), this.segmentLabelIds.length > this.positions.length - 1 && this.htmlLabelPool) {
|
|
1715
|
+
const e = this.segmentLabelIds.pop();
|
|
1716
|
+
e && this.htmlLabelPool.removeByIds([e]);
|
|
1717
|
+
}
|
|
1718
|
+
this.entity?.polyline && (this.entity.polyline.positions = this.positions.slice()), this.positions.length ? this.previewLabelId && this.htmlLabelPool && (this.htmlLabelPool.removeByIds([this.previewLabelId]), this.previewLabelId = null) : (this.entity && (this.viewer.entities.remove(this.entity), this.entity = null), this._clearPreviewState());
|
|
1719
|
+
}
|
|
1720
|
+
_finishMeasurement(i, e, t) {
|
|
1721
|
+
if (t) {
|
|
1722
|
+
if (this.positions.length >= 2 && this.tempPoints.length >= 2) {
|
|
1723
|
+
const r = this.tempPoints[this.tempPoints.length - 1];
|
|
1724
|
+
this.viewer.entities.remove(r), this.tempPoints.pop();
|
|
1725
|
+
}
|
|
1726
|
+
if (this.segmentLabelIds.length >= 1) {
|
|
1727
|
+
const r = this.segmentLabelIds[this.segmentLabelIds.length - 1];
|
|
1728
|
+
r && (this.htmlLabelPool.removeByIds([r]), this.segmentLabelIds.pop());
|
|
1729
|
+
}
|
|
1730
|
+
this.positions.length >= 2 && this.positions.pop();
|
|
1731
|
+
}
|
|
1732
|
+
if (this.positions.length < 2) {
|
|
1733
|
+
this.clear();
|
|
1734
|
+
return;
|
|
1735
|
+
}
|
|
1736
|
+
this.stop(), this._clearPreviewState();
|
|
1737
|
+
let a = 0;
|
|
1738
|
+
for (let r = 1; r < this.positions.length; r++) {
|
|
1739
|
+
const c = this.positions[r - 1], p = this.positions[r], m = e.Cartographic.fromCartesian(c), g = e.Cartographic.fromCartesian(p), h = new e.EllipsoidGeodesic(m, g);
|
|
1740
|
+
a += h.surfaceDistance;
|
|
1741
|
+
}
|
|
1742
|
+
const s = this.positions[this.positions.length - 1];
|
|
1743
|
+
this.entity && this.entity.polyline && (this.entity.polyline.positions = this.positions);
|
|
1744
|
+
const o = e.Cartographic.fromCartesian(s), d = this.totalLabelId || `measure_polyline_total_${Date.now()}`;
|
|
1745
|
+
this.totalLabelId = d, this.htmlLabelPool.add(
|
|
1746
|
+
{ text: `${a.toFixed(2)} m` },
|
|
1747
|
+
{
|
|
1748
|
+
id: d,
|
|
1749
|
+
lon: e.Math.toDegrees(o.longitude),
|
|
1750
|
+
lat: e.Math.toDegrees(o.latitude),
|
|
1751
|
+
height: o.height || 0,
|
|
1752
|
+
theme: "measure-polyline-total",
|
|
1753
|
+
show: !0
|
|
1754
|
+
}
|
|
1755
|
+
), this.labelEntity = this.totalLabelId;
|
|
1756
|
+
const n = {
|
|
1757
|
+
entity: this.entity,
|
|
1758
|
+
label: this.labelEntity,
|
|
1759
|
+
segmentLabels: this.segmentLabelIds,
|
|
1760
|
+
positions: this.positions,
|
|
1761
|
+
distance: a,
|
|
1762
|
+
clear: () => this.clear()
|
|
1763
|
+
};
|
|
1764
|
+
i.onComplete?.(n);
|
|
1765
|
+
}
|
|
1766
|
+
_bindGlobalEvents(i, e, t) {
|
|
1767
|
+
this.keydownHandler = (a) => {
|
|
1768
|
+
a.key === "Escape" && (a.preventDefault(), this._finishMeasurement(i, e, !1));
|
|
1769
|
+
}, window.addEventListener("keydown", this.keydownHandler), this.contextMenuHandler = (a) => {
|
|
1770
|
+
a.preventDefault();
|
|
1771
|
+
}, t.canvas.addEventListener("contextmenu", this.contextMenuHandler);
|
|
1772
|
+
}
|
|
1595
1773
|
rehydrate(i, e) {
|
|
1596
|
-
const t = this.Cesium,
|
|
1774
|
+
const t = this.Cesium, a = 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((h) => new t.Cartesian3(h[0], h[1], h[2]));
|
|
1597
1775
|
if (r.length < 2) return;
|
|
1598
1776
|
if (!this.htmlLabelPool) {
|
|
1599
|
-
const
|
|
1600
|
-
this.htmlLabelPool = e || new
|
|
1601
|
-
createElement: (
|
|
1602
|
-
|
|
1777
|
+
const h = s.overlayContainerId || "html-label-container";
|
|
1778
|
+
this.htmlLabelPool = e || new _(t, a, h), this.htmlLabelPool.registerTheme("measure-polyline-total", {
|
|
1779
|
+
createElement: (l, w) => {
|
|
1780
|
+
l.innerHTML = String(w?.data?.text || ""), l.style.background = "rgba(0,0,0,0.6)", l.style.color = "#fff", l.style.font = "14px sans-serif", l.style.padding = "4px 6px", l.style.borderRadius = "4px", l.style.whiteSpace = "pre";
|
|
1603
1781
|
},
|
|
1604
1782
|
options: { offset: { x: 0, y: -10 } }
|
|
1605
1783
|
}), this.htmlLabelPool.registerTheme("measure-polyline-seg", {
|
|
1606
|
-
createElement: (
|
|
1607
|
-
|
|
1784
|
+
createElement: (l, w) => {
|
|
1785
|
+
l.innerHTML = String(w?.data?.text || ""), l.style.background = "rgba(0,0,0,0.6)", l.style.color = "#fff", l.style.font = "14px sans-serif", l.style.padding = "4px 6px", l.style.borderRadius = "4px", l.style.whiteSpace = "pre";
|
|
1608
1786
|
},
|
|
1609
1787
|
options: { offset: { x: 0, y: -10 } }
|
|
1610
1788
|
});
|
|
1611
1789
|
}
|
|
1612
|
-
for (const
|
|
1613
|
-
const
|
|
1614
|
-
this.tempPoints.push(
|
|
1790
|
+
for (const h of r) {
|
|
1791
|
+
const l = a.entities.add({ position: h, point: { pixelSize: 8, color: s.pointColor || s.color || t.Color.YELLOW, disableDepthTestDistance: Number.POSITIVE_INFINITY } });
|
|
1792
|
+
this.tempPoints.push(l);
|
|
1615
1793
|
}
|
|
1616
|
-
this.entity =
|
|
1794
|
+
this.entity = a.entities.add({ polyline: { positions: r, width: n, material: o, depthFailMaterial: new t.PolylineDashMaterialProperty({ color: d, dashLength: 12, dashPattern: 255 }) } });
|
|
1617
1795
|
let c = 0;
|
|
1618
|
-
for (let
|
|
1619
|
-
const
|
|
1796
|
+
for (let h = 1; h < r.length; h++) {
|
|
1797
|
+
const l = t.Cartographic.fromCartesian(r[h - 1]), w = t.Cartographic.fromCartesian(r[h]), u = new t.EllipsoidGeodesic(l, w);
|
|
1620
1798
|
c += u.surfaceDistance;
|
|
1621
|
-
const C = r[
|
|
1799
|
+
const C = r[h - 1], L = r[h], f = new t.Cartesian3((C.x + L.x) / 2, (C.y + L.y) / 2, (C.z + L.z) / 2), v = t.Cartographic.fromCartesian(f), y = i.id + `_seg_${h - 1}`;
|
|
1622
1800
|
this.segmentLabelIds.push(y), this.htmlLabelPool.add({ text: `${u.surfaceDistance.toFixed(2)} m` }, {
|
|
1623
1801
|
id: y,
|
|
1624
|
-
lon: t.Math.toDegrees(
|
|
1625
|
-
lat: t.Math.toDegrees(
|
|
1626
|
-
height:
|
|
1802
|
+
lon: t.Math.toDegrees(v.longitude),
|
|
1803
|
+
lat: t.Math.toDegrees(v.latitude),
|
|
1804
|
+
height: v.height || 0,
|
|
1627
1805
|
theme: "measure-polyline-seg",
|
|
1628
1806
|
show: !0,
|
|
1629
1807
|
style: { pointerEvents: "none", userSelect: "none", cursor: "default" }
|
|
@@ -1658,16 +1836,16 @@ class be {
|
|
|
1658
1836
|
this.clear();
|
|
1659
1837
|
const e = this.Cesium, t = this.viewer;
|
|
1660
1838
|
if (!this.htmlLabelPool) {
|
|
1661
|
-
const
|
|
1662
|
-
this.htmlLabelPool = new
|
|
1839
|
+
const a = i.overlayContainerId || "html-label-container";
|
|
1840
|
+
this.htmlLabelPool = new _(e, t, a), this.htmlLabelPool.registerTheme("measure-terrainHeight", {
|
|
1663
1841
|
createElement: (s, o) => {
|
|
1664
1842
|
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
1843
|
},
|
|
1666
1844
|
options: { offset: { x: 0, y: -10 } }
|
|
1667
1845
|
});
|
|
1668
1846
|
}
|
|
1669
|
-
this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((
|
|
1670
|
-
const s = t.scene.pickPosition(
|
|
1847
|
+
this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((a) => {
|
|
1848
|
+
const s = t.scene.pickPosition(a.position);
|
|
1671
1849
|
if (!s) return;
|
|
1672
1850
|
const o = e.Cartographic.fromCartesian(s), d = t.scene.globe.getHeight(
|
|
1673
1851
|
new e.Cartographic(o.longitude, o.latitude, 0)
|
|
@@ -1698,11 +1876,11 @@ class be {
|
|
|
1698
1876
|
})
|
|
1699
1877
|
}
|
|
1700
1878
|
});
|
|
1701
|
-
const p = i.labelText || { height: "高差" }, m = (o.height || 0) - d, g = `${p.height}:${m.toFixed(2)} m`,
|
|
1702
|
-
this.htmlLabelId =
|
|
1879
|
+
const p = i.labelText || { height: "高差" }, m = (o.height || 0) - d, g = `${p.height}:${m.toFixed(2)} m`, h = this.htmlLabelId || `measure_terrain_${Date.now()}`;
|
|
1880
|
+
this.htmlLabelId = h, this.htmlLabelPool.add(
|
|
1703
1881
|
{ text: g },
|
|
1704
1882
|
{
|
|
1705
|
-
id:
|
|
1883
|
+
id: h,
|
|
1706
1884
|
lon: n,
|
|
1707
1885
|
lat: r,
|
|
1708
1886
|
height: o.height || 0,
|
|
@@ -1710,7 +1888,7 @@ class be {
|
|
|
1710
1888
|
show: !0
|
|
1711
1889
|
}
|
|
1712
1890
|
), this.labelEntity = this.htmlLabelId;
|
|
1713
|
-
const
|
|
1891
|
+
const l = {
|
|
1714
1892
|
label: this.labelEntity,
|
|
1715
1893
|
position: s,
|
|
1716
1894
|
zeroPosition: c,
|
|
@@ -1719,7 +1897,7 @@ class be {
|
|
|
1719
1897
|
difference: m,
|
|
1720
1898
|
clear: () => this.clear()
|
|
1721
1899
|
};
|
|
1722
|
-
i.onComplete?.(
|
|
1900
|
+
i.onComplete?.(l), this.stop();
|
|
1723
1901
|
}, e.ScreenSpaceEventType.LEFT_CLICK);
|
|
1724
1902
|
}
|
|
1725
1903
|
stop() {
|
|
@@ -1729,7 +1907,7 @@ class be {
|
|
|
1729
1907
|
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
1908
|
}
|
|
1731
1909
|
rehydrate(i, e) {
|
|
1732
|
-
const t = this.Cesium,
|
|
1910
|
+
const t = this.Cesium, a = this.viewer, s = i.options || {}, o = (i.positions || []).map((w) => new t.Cartesian3(w[0], w[1], w[2]));
|
|
1733
1911
|
if (o.length < 1) {
|
|
1734
1912
|
const u = (i.data || {}).position;
|
|
1735
1913
|
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)));
|
|
@@ -1737,20 +1915,20 @@ class be {
|
|
|
1737
1915
|
if (o.length < 1) return;
|
|
1738
1916
|
if (!this.htmlLabelPool) {
|
|
1739
1917
|
const w = s.overlayContainerId || "html-label-container";
|
|
1740
|
-
this.htmlLabelPool = e || new
|
|
1918
|
+
this.htmlLabelPool = e || new _(t, a, w), this.htmlLabelPool.registerTheme("measure-terrainHeight", {
|
|
1741
1919
|
createElement: (u, C) => {
|
|
1742
1920
|
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
1921
|
},
|
|
1744
1922
|
options: { offset: { x: 0, y: -10 } }
|
|
1745
1923
|
});
|
|
1746
1924
|
}
|
|
1747
|
-
const d = o[0], n = t.Cartographic.fromCartesian(d), r =
|
|
1748
|
-
this.topPoint =
|
|
1749
|
-
const g = s.labelText || { height: "高差" },
|
|
1750
|
-
this.htmlLabelId =
|
|
1925
|
+
const d = o[0], n = t.Cartographic.fromCartesian(d), r = a.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);
|
|
1926
|
+
this.topPoint = a.entities.add({ position: d, point: { pixelSize: 8, color: s.color || t.Color.YELLOW, disableDepthTestDistance: Number.POSITIVE_INFINITY } }), this.zeroPoint = a.entities.add({ position: m, point: { pixelSize: 8, color: t.Color.YELLOW, disableDepthTestDistance: Number.POSITIVE_INFINITY } }), this.lineEntity = a.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 }) } });
|
|
1927
|
+
const g = s.labelText || { height: "高差" }, h = (n.height || 0) - r, l = i.id + "_terrain";
|
|
1928
|
+
this.htmlLabelId = l, this.htmlLabelPool.add({ text: `${g.height}:${h.toFixed(2)} m` }, { id: l, lon: c, lat: p, height: n.height || 0, theme: "measure-terrainHeight", show: !0 });
|
|
1751
1929
|
}
|
|
1752
1930
|
}
|
|
1753
|
-
class
|
|
1931
|
+
class Le {
|
|
1754
1932
|
Cesium;
|
|
1755
1933
|
viewer;
|
|
1756
1934
|
handler = null;
|
|
@@ -1765,16 +1943,16 @@ class ve {
|
|
|
1765
1943
|
this.clear();
|
|
1766
1944
|
const e = this.Cesium, t = this.viewer;
|
|
1767
1945
|
if (!this.htmlLabelPool) {
|
|
1768
|
-
const
|
|
1769
|
-
this.htmlLabelPool = new
|
|
1946
|
+
const a = i.overlayContainerId || "html-label-container";
|
|
1947
|
+
this.htmlLabelPool = new _(e, t, a), this.htmlLabelPool.registerTheme("measure-coordinate", {
|
|
1770
1948
|
createElement: (s, o) => {
|
|
1771
1949
|
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
1950
|
},
|
|
1773
1951
|
options: { offset: { x: 0, y: -10 } }
|
|
1774
1952
|
});
|
|
1775
1953
|
}
|
|
1776
|
-
this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((
|
|
1777
|
-
const s = t.scene.pickPosition(
|
|
1954
|
+
this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((a) => {
|
|
1955
|
+
const s = t.scene.pickPosition(a.position);
|
|
1778
1956
|
if (!s) return;
|
|
1779
1957
|
const o = e.Cartographic.fromCartesian(s), d = e.Math.toDegrees(o.longitude), n = e.Math.toDegrees(o.latitude), r = o.height || 0;
|
|
1780
1958
|
this.entity = t.entities.add({
|
|
@@ -1817,26 +1995,26 @@ ${p.height}:${r.toFixed(2)} m` },
|
|
|
1817
1995
|
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
1996
|
}
|
|
1819
1997
|
rehydrate(i, e) {
|
|
1820
|
-
const t = this.Cesium,
|
|
1998
|
+
const t = this.Cesium, a = this.viewer, s = i.options || {}, o = (i.positions || []).map((h) => new t.Cartesian3(h[0], h[1], h[2]));
|
|
1821
1999
|
if (!o.length) {
|
|
1822
|
-
const
|
|
1823
|
-
if (
|
|
1824
|
-
const
|
|
1825
|
-
o.push(
|
|
2000
|
+
const h = i.data?.lnglat;
|
|
2001
|
+
if (h && typeof h.lng == "number" && typeof h.lat == "number") {
|
|
2002
|
+
const l = t.Cartesian3.fromDegrees(h.lng, h.lat, h.height || 0);
|
|
2003
|
+
o.push(l);
|
|
1826
2004
|
}
|
|
1827
2005
|
}
|
|
1828
2006
|
if (!o.length) return;
|
|
1829
2007
|
if (!this.htmlLabelPool) {
|
|
1830
|
-
const
|
|
1831
|
-
this.htmlLabelPool = e || new
|
|
1832
|
-
createElement: (
|
|
1833
|
-
|
|
2008
|
+
const h = s.overlayContainerId || "html-label-container";
|
|
2009
|
+
this.htmlLabelPool = e || new _(t, a, h), this.htmlLabelPool.registerTheme("measure-coordinate", {
|
|
2010
|
+
createElement: (l, w) => {
|
|
2011
|
+
l.innerHTML = String(w?.data?.text || ""), l.style.background = "rgba(0,0,0,0.6)", l.style.color = "#fff", l.style.font = "14px sans-serif", l.style.padding = "4px 6px", l.style.borderRadius = "4px", l.style.whiteSpace = "pre";
|
|
1834
2012
|
},
|
|
1835
2013
|
options: { offset: { x: 0, y: -10 } }
|
|
1836
2014
|
});
|
|
1837
2015
|
}
|
|
1838
2016
|
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 =
|
|
2017
|
+
this.entity = a.entities.add({ position: d, point: { pixelSize: 10, color: s.color || t.Color.YELLOW, disableDepthTestDistance: Number.POSITIVE_INFINITY } });
|
|
1840
2018
|
const m = i.id + "_coord";
|
|
1841
2019
|
this.htmlLabelId = m;
|
|
1842
2020
|
const g = s.labelText || { lng: "经", lat: "纬", height: "高" };
|
|
@@ -1845,7 +2023,7 @@ ${g.lat}:${c.toFixed(6)}
|
|
|
1845
2023
|
${g.height}:${p.toFixed(2)} m` }, { id: m, lon: r, lat: c, height: p, theme: "measure-coordinate", show: !0 });
|
|
1846
2024
|
}
|
|
1847
2025
|
}
|
|
1848
|
-
class
|
|
2026
|
+
class Ee {
|
|
1849
2027
|
Cesium;
|
|
1850
2028
|
viewer;
|
|
1851
2029
|
handler = null;
|
|
@@ -1872,8 +2050,8 @@ class Le {
|
|
|
1872
2050
|
this.clear();
|
|
1873
2051
|
const e = this.Cesium, t = this.viewer;
|
|
1874
2052
|
if (!this.htmlLabelPool) {
|
|
1875
|
-
const
|
|
1876
|
-
this.htmlLabelPool = new
|
|
2053
|
+
const a = i.overlayContainerId || "html-label-container";
|
|
2054
|
+
this.htmlLabelPool = new _(e, t, a), this.htmlLabelPool.registerTheme("measure-rectangle", {
|
|
1877
2055
|
createElement: (s, o) => {
|
|
1878
2056
|
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
2057
|
},
|
|
@@ -1885,8 +2063,8 @@ class Le {
|
|
|
1885
2063
|
options: { offset: { x: 0, y: -10 } }
|
|
1886
2064
|
});
|
|
1887
2065
|
}
|
|
1888
|
-
this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((
|
|
1889
|
-
const s = t.scene.pickPosition(
|
|
2066
|
+
this.handler = new e.ScreenSpaceEventHandler(t.canvas), this.handler.setInputAction((a) => {
|
|
2067
|
+
const s = t.scene.pickPosition(a.position);
|
|
1890
2068
|
if (!s) return;
|
|
1891
2069
|
if (!this.startPoint) {
|
|
1892
2070
|
this.startPoint = s;
|
|
@@ -1906,16 +2084,16 @@ class Le {
|
|
|
1906
2084
|
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
2085
|
const g = this.htmlLabelId || `measure_rectangle_${Date.now()}`;
|
|
1908
2086
|
this.htmlLabelId = g;
|
|
1909
|
-
const
|
|
2087
|
+
const h = e.Cartographic.fromCartesian(r), l = i.labelText || { width: "宽", heightLabel: "高", area: "面积", side: "边长" };
|
|
1910
2088
|
this.previewLabelId && this.htmlLabelPool && (this.htmlLabelPool.removeByIds([this.previewLabelId]), this.previewLabelId = null), this.htmlLabelPool.add(
|
|
1911
|
-
{ text: `${
|
|
1912
|
-
${
|
|
1913
|
-
${
|
|
2089
|
+
{ text: `${l.width}:${c.toFixed(2)} m
|
|
2090
|
+
${l.heightLabel}:${p.toFixed(2)} m
|
|
2091
|
+
${l.area}:${m.toFixed(2)} m²` },
|
|
1914
2092
|
{
|
|
1915
2093
|
id: g,
|
|
1916
|
-
lon: e.Math.toDegrees(
|
|
1917
|
-
lat: e.Math.toDegrees(
|
|
1918
|
-
height:
|
|
2094
|
+
lon: e.Math.toDegrees(h.longitude),
|
|
2095
|
+
lat: e.Math.toDegrees(h.latitude),
|
|
2096
|
+
height: h.height || 0,
|
|
1919
2097
|
theme: "measure-rectangle",
|
|
1920
2098
|
show: !0
|
|
1921
2099
|
}
|
|
@@ -1927,9 +2105,9 @@ ${a.area}:${m.toFixed(2)} m²` },
|
|
|
1927
2105
|
[n[3], n[0]]
|
|
1928
2106
|
];
|
|
1929
2107
|
for (let A = 0; A < w.length; A++) {
|
|
1930
|
-
const [I, S] = w[A],
|
|
2108
|
+
const [I, S] = w[A], H = A === 0 || A === 2 ? c : p, k = new e.Cartesian3((I.x + S.x) / 2, (I.y + S.y) / 2, (I.z + S.z) / 2), F = e.Cartographic.fromCartesian(k), N = `measure_rectangle_seg_${Date.now()}_${A}`;
|
|
1931
2109
|
this.segmentLabelIds.push(N), this.htmlLabelPool.add(
|
|
1932
|
-
{ text: `${
|
|
2110
|
+
{ text: `${l.side}:${Number(H).toFixed(2)} m` },
|
|
1933
2111
|
{
|
|
1934
2112
|
id: N,
|
|
1935
2113
|
lon: e.Math.toDegrees(F.longitude),
|
|
@@ -1945,11 +2123,11 @@ ${a.area}:${m.toFixed(2)} m²` },
|
|
|
1945
2123
|
vertexFormat: e.MaterialAppearance.VERTEX_FORMAT,
|
|
1946
2124
|
perPositionHeight: !0,
|
|
1947
2125
|
arcType: e.ArcType.NONE
|
|
1948
|
-
}), f = new e.GeometryInstance({ geometry: L }),
|
|
2126
|
+
}), f = new e.GeometryInstance({ geometry: L }), v = 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
2127
|
this.primitive = new e.Primitive({
|
|
1950
2128
|
geometryInstances: f,
|
|
1951
2129
|
appearance: new e.MaterialAppearance({
|
|
1952
|
-
material: e.Material.fromType("Color", { color:
|
|
2130
|
+
material: e.Material.fromType("Color", { color: v }),
|
|
1953
2131
|
translucent: !0,
|
|
1954
2132
|
closed: !0
|
|
1955
2133
|
}),
|
|
@@ -1959,11 +2137,11 @@ ${a.area}:${m.toFixed(2)} m²` },
|
|
|
1959
2137
|
closed: !0
|
|
1960
2138
|
})
|
|
1961
2139
|
}), t.scene.primitives.add(this.primitive);
|
|
1962
|
-
const
|
|
2140
|
+
const b = 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]], T = t.entities.add({
|
|
1963
2141
|
polyline: {
|
|
1964
2142
|
positions: x,
|
|
1965
2143
|
width: i.width || 2,
|
|
1966
|
-
material:
|
|
2144
|
+
material: b,
|
|
1967
2145
|
clampToGround: !1,
|
|
1968
2146
|
arcType: e.ArcType.NONE,
|
|
1969
2147
|
depthFailMaterial: new e.PolylineDashMaterialProperty({
|
|
@@ -1973,7 +2151,7 @@ ${a.area}:${m.toFixed(2)} m²` },
|
|
|
1973
2151
|
})
|
|
1974
2152
|
}
|
|
1975
2153
|
});
|
|
1976
|
-
this.edgeEntities.push(
|
|
2154
|
+
this.edgeEntities.push(T);
|
|
1977
2155
|
const M = i.pointColor || i.color || e.Color.YELLOW;
|
|
1978
2156
|
for (const A of n) {
|
|
1979
2157
|
const I = t.entities.add({
|
|
@@ -1996,8 +2174,8 @@ ${a.area}:${m.toFixed(2)} m²` },
|
|
|
1996
2174
|
clear: () => this.clear()
|
|
1997
2175
|
};
|
|
1998
2176
|
i.onComplete?.(P);
|
|
1999
|
-
}, e.ScreenSpaceEventType.LEFT_CLICK), this.handler.setInputAction((
|
|
2000
|
-
const s = t.scene.pickPosition(
|
|
2177
|
+
}, e.ScreenSpaceEventType.LEFT_CLICK), this.handler.setInputAction((a) => {
|
|
2178
|
+
const s = t.scene.pickPosition(a.endPosition);
|
|
2001
2179
|
if (!s) return;
|
|
2002
2180
|
if (this.startPoint && !this.secondPoint) {
|
|
2003
2181
|
if (this.endPoint = s, !this.previewEdgeEntity) {
|
|
@@ -2040,15 +2218,15 @@ ${a.area}:${m.toFixed(2)} m²` },
|
|
|
2040
2218
|
if (!o) return;
|
|
2041
2219
|
const { corners: d, center: n, width: r, height: c, area: p } = o, m = this.buildSurfaceRectanglePositions(d);
|
|
2042
2220
|
this.currentCorners = m;
|
|
2043
|
-
const g = e.Cartographic.fromCartesian(n),
|
|
2044
|
-
this.previewLabelId =
|
|
2045
|
-
const
|
|
2221
|
+
const g = e.Cartographic.fromCartesian(n), h = this.previewLabelId || "measure_rectangle_preview";
|
|
2222
|
+
this.previewLabelId = h;
|
|
2223
|
+
const l = i.labelText || { width: "宽", heightLabel: "高", area: "面积" };
|
|
2046
2224
|
if (this.htmlLabelPool.add(
|
|
2047
|
-
{ text: `${
|
|
2048
|
-
${
|
|
2049
|
-
${
|
|
2225
|
+
{ text: `${l.width}:${r.toFixed(2)} m
|
|
2226
|
+
${l.heightLabel}:${c.toFixed(2)} m
|
|
2227
|
+
${l.area}:${p.toFixed(2)} m²` },
|
|
2050
2228
|
{
|
|
2051
|
-
id:
|
|
2229
|
+
id: h,
|
|
2052
2230
|
lon: e.Math.toDegrees(g.longitude),
|
|
2053
2231
|
lat: e.Math.toDegrees(g.latitude),
|
|
2054
2232
|
height: g.height || 0,
|
|
@@ -2105,11 +2283,11 @@ ${a.area}:${p.toFixed(2)} m²` },
|
|
|
2105
2283
|
return !i || !i.length ? [] : i.slice();
|
|
2106
2284
|
}
|
|
2107
2285
|
rehydrate(i, e) {
|
|
2108
|
-
const t = this.Cesium,
|
|
2286
|
+
const t = this.Cesium, a = this.viewer, s = i.options || {}, o = (i.positions || []).map((M) => new t.Cartesian3(M[0], M[1], M[2]));
|
|
2109
2287
|
if (o.length < 3) return;
|
|
2110
2288
|
if (!this.htmlLabelPool) {
|
|
2111
2289
|
const M = s.overlayContainerId || "html-label-container";
|
|
2112
|
-
this.htmlLabelPool = e || new
|
|
2290
|
+
this.htmlLabelPool = e || new _(t, a, M), this.htmlLabelPool.registerTheme("measure-rectangle", {
|
|
2113
2291
|
createElement: (P, A) => {
|
|
2114
2292
|
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
2293
|
},
|
|
@@ -2123,10 +2301,10 @@ ${a.area}:${p.toFixed(2)} m²` },
|
|
|
2123
2301
|
}
|
|
2124
2302
|
const d = this.computeRectangle(o[0], o[1], o[2]);
|
|
2125
2303
|
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),
|
|
2127
|
-
this.htmlLabelId =
|
|
2128
|
-
${
|
|
2129
|
-
${
|
|
2304
|
+
const n = d.corners, r = d.center, c = d.width, p = d.height, m = d.area, g = t.Cartographic.fromCartesian(r), h = i.id + "_rectangle", l = s.labelText || { width: "宽", heightLabel: "高", area: "面积", side: "边长" };
|
|
2305
|
+
this.htmlLabelId = h, this.htmlLabelPool.add({ text: `${l.width}:${c.toFixed(2)} m
|
|
2306
|
+
${l.heightLabel}:${p.toFixed(2)} m
|
|
2307
|
+
${l.area}:${m.toFixed(2)} m²` }, { id: h, lon: t.Math.toDegrees(g.longitude), lat: t.Math.toDegrees(g.latitude), height: g.height || 0, theme: "measure-rectangle", show: !0 });
|
|
2130
2308
|
const w = [
|
|
2131
2309
|
[n[0], n[1]],
|
|
2132
2310
|
[n[1], n[2]],
|
|
@@ -2134,37 +2312,37 @@ ${a.area}:${m.toFixed(2)} m²` }, { id: l, lon: t.Math.toDegrees(g.longitude), l
|
|
|
2134
2312
|
[n[3], n[0]]
|
|
2135
2313
|
];
|
|
2136
2314
|
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),
|
|
2138
|
-
this.segmentLabelIds.push(
|
|
2315
|
+
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), H = t.Cartographic.fromCartesian(S), k = i.id + `_rectangle_seg_${M}`;
|
|
2316
|
+
this.segmentLabelIds.push(k), this.htmlLabelPool.add({ text: `${l.side}:${Number(I).toFixed(2)} m` }, { id: k, lon: t.Math.toDegrees(H.longitude), lat: t.Math.toDegrees(H.latitude), height: H.height || 0, theme: "measure-rectangle-seg", show: !0 });
|
|
2139
2317
|
}
|
|
2140
2318
|
const u = new t.PolygonHierarchy(n), C = new t.PolygonGeometry({
|
|
2141
2319
|
polygonHierarchy: u,
|
|
2142
2320
|
vertexFormat: t.MaterialAppearance.VERTEX_FORMAT,
|
|
2143
2321
|
perPositionHeight: !0,
|
|
2144
2322
|
arcType: t.ArcType.NONE
|
|
2145
|
-
}), L = new t.GeometryInstance({ geometry: C }), f = s.color || t.Color.YELLOW.withAlpha(0.4),
|
|
2323
|
+
}), L = new t.GeometryInstance({ geometry: C }), f = s.color || t.Color.YELLOW.withAlpha(0.4), v = s.color && s.color.withAlpha ? s.color.withAlpha(0.25) : t.Color.RED.withAlpha(0.4), y = new t.Primitive({
|
|
2146
2324
|
geometryInstances: L,
|
|
2147
2325
|
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:
|
|
2326
|
+
depthFailAppearance: new t.MaterialAppearance({ material: t.Material.fromType("Color", { color: v }), translucent: !0, closed: !0 })
|
|
2149
2327
|
});
|
|
2150
|
-
this.primitive = y,
|
|
2151
|
-
const
|
|
2328
|
+
this.primitive = y, a.scene.primitives.add(this.primitive);
|
|
2329
|
+
const b = s.lineColor || f, E = [...n, n[0]], x = a.entities.add({
|
|
2152
2330
|
polyline: {
|
|
2153
2331
|
positions: E,
|
|
2154
2332
|
width: s.width || 2,
|
|
2155
|
-
material:
|
|
2333
|
+
material: b,
|
|
2156
2334
|
clampToGround: !1,
|
|
2157
2335
|
arcType: t.ArcType.NONE
|
|
2158
2336
|
}
|
|
2159
2337
|
});
|
|
2160
2338
|
this.edgeEntities.push(x);
|
|
2161
|
-
const
|
|
2339
|
+
const T = s.pointColor || f;
|
|
2162
2340
|
for (const M of n) {
|
|
2163
|
-
const P =
|
|
2341
|
+
const P = a.entities.add({
|
|
2164
2342
|
position: M,
|
|
2165
2343
|
point: {
|
|
2166
2344
|
pixelSize: 8,
|
|
2167
|
-
color:
|
|
2345
|
+
color: T,
|
|
2168
2346
|
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
2169
2347
|
}
|
|
2170
2348
|
});
|
|
@@ -2172,29 +2350,29 @@ ${a.area}:${m.toFixed(2)} m²` }, { id: l, lon: t.Math.toDegrees(g.longitude), l
|
|
|
2172
2350
|
}
|
|
2173
2351
|
}
|
|
2174
2352
|
computeRectangle(i, e, t) {
|
|
2175
|
-
const
|
|
2353
|
+
const a = this.Cesium, s = new a.EllipsoidTangentPlane(i, a.Ellipsoid.WGS84), o = s.projectPointsOntoPlane([i, e, t]);
|
|
2176
2354
|
if (!o || o.length < 3) return null;
|
|
2177
2355
|
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
2356
|
if (!m) return null;
|
|
2179
|
-
const g = c / m,
|
|
2357
|
+
const g = c / m, l = -(p / m), w = g, u = r.x - n.x, C = r.y - n.y, L = u * l + C * w;
|
|
2180
2358
|
if (!L) return null;
|
|
2181
|
-
const f = new
|
|
2359
|
+
const f = new a.Cartesian2(n.x + l * L, n.y + w * L), v = new a.Cartesian2(d.x + l * L, d.y + w * L), y = s.projectPointsOntoEllipsoid([d, n, f, v]);
|
|
2182
2360
|
if (!y || y.length < 4) return null;
|
|
2183
|
-
const
|
|
2361
|
+
const b = y, E = b[0], x = b[2], T = Math.abs(m), M = Math.abs(L), P = new a.Cartesian3(
|
|
2184
2362
|
(E.x + x.x) / 2,
|
|
2185
2363
|
(E.y + x.y) / 2,
|
|
2186
2364
|
(E.z + x.z) / 2
|
|
2187
|
-
), I = new
|
|
2365
|
+
), I = new a.EllipsoidTangentPlane(P, a.Ellipsoid.WGS84).projectPointsOntoPlane(b);
|
|
2188
2366
|
let S = 0;
|
|
2189
|
-
for (let
|
|
2190
|
-
const F = (
|
|
2191
|
-
S += I[
|
|
2367
|
+
for (let k = 0; k < I.length; k++) {
|
|
2368
|
+
const F = (k + 1) % I.length;
|
|
2369
|
+
S += I[k].x * I[F].y - I[F].x * I[k].y;
|
|
2192
2370
|
}
|
|
2193
|
-
const
|
|
2194
|
-
return { corners:
|
|
2371
|
+
const H = Math.abs(S) / 2;
|
|
2372
|
+
return { corners: b, center: P, width: T, height: M, area: H };
|
|
2195
2373
|
}
|
|
2196
2374
|
}
|
|
2197
|
-
class
|
|
2375
|
+
class Pe {
|
|
2198
2376
|
Cesium;
|
|
2199
2377
|
viewer;
|
|
2200
2378
|
handler = null;
|
|
@@ -2217,10 +2395,10 @@ class Ee {
|
|
|
2217
2395
|
}
|
|
2218
2396
|
start(i) {
|
|
2219
2397
|
this.clear();
|
|
2220
|
-
const e = this.Cesium, t = this.viewer,
|
|
2398
|
+
const e = this.Cesium, t = this.viewer, a = Math.max(i.sides || 6, 6);
|
|
2221
2399
|
if (!this.htmlLabelPool) {
|
|
2222
2400
|
const s = i.overlayContainerId || "html-label-container";
|
|
2223
|
-
this.htmlLabelPool = new
|
|
2401
|
+
this.htmlLabelPool = new _(e, t, s), this.htmlLabelPool.registerTheme("measure-regular", {
|
|
2224
2402
|
createElement: (o, d) => {
|
|
2225
2403
|
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
2404
|
},
|
|
@@ -2236,28 +2414,28 @@ class Ee {
|
|
|
2236
2414
|
const o = t.scene.pickPosition(s.position);
|
|
2237
2415
|
if (o && (this.positions.push(o), this.positions.length === 2)) {
|
|
2238
2416
|
this.stop();
|
|
2239
|
-
const d = this.positions[0], n = this.positions[1], r = e.Cartesian3.distance(d, n), c = this.buildRegularPolygonPoints(d, r,
|
|
2417
|
+
const d = this.positions[0], n = this.positions[1], r = e.Cartesian3.distance(d, n), c = this.buildRegularPolygonPoints(d, r, a);
|
|
2240
2418
|
this.previewEntity && (t.entities.remove(this.previewEntity), this.previewEntity = null), this.primitive && (t.scene.primitives.remove(this.primitive), this.primitive = null);
|
|
2241
2419
|
const p = new e.PolygonHierarchy(c), m = new e.PolygonGeometry({
|
|
2242
2420
|
polygonHierarchy: p,
|
|
2243
2421
|
vertexFormat: e.MaterialAppearance.VERTEX_FORMAT,
|
|
2244
2422
|
perPositionHeight: !0,
|
|
2245
2423
|
arcType: e.ArcType.NONE
|
|
2246
|
-
}), g = new e.GeometryInstance({ geometry: m }),
|
|
2424
|
+
}), g = new e.GeometryInstance({ geometry: m }), h = i.color || e.Color.YELLOW.withAlpha(0.4), l = i.color && i.color.withAlpha ? i.color.withAlpha(0.25) : e.Color.RED.withAlpha(0.4);
|
|
2247
2425
|
this.primitive = new e.Primitive({
|
|
2248
2426
|
geometryInstances: g,
|
|
2249
2427
|
appearance: new e.MaterialAppearance({
|
|
2250
|
-
material: e.Material.fromType("Color", { color:
|
|
2428
|
+
material: e.Material.fromType("Color", { color: h }),
|
|
2251
2429
|
translucent: !0,
|
|
2252
2430
|
closed: !0
|
|
2253
2431
|
}),
|
|
2254
2432
|
depthFailAppearance: new e.MaterialAppearance({
|
|
2255
|
-
material: e.Material.fromType("Color", { color:
|
|
2433
|
+
material: e.Material.fromType("Color", { color: l }),
|
|
2256
2434
|
translucent: !0,
|
|
2257
2435
|
closed: !0
|
|
2258
2436
|
})
|
|
2259
2437
|
}), t.scene.primitives.add(this.primitive);
|
|
2260
|
-
const w = i.lineColor ||
|
|
2438
|
+
const w = i.lineColor || h, u = (i.dashLineColor || i.lineColor || i.color || e.Color.RED).withAlpha?.(0.9) || e.Color.RED, C = c.slice(), L = t.entities.add({
|
|
2261
2439
|
polyline: {
|
|
2262
2440
|
positions: C,
|
|
2263
2441
|
width: i.width || 2,
|
|
@@ -2272,8 +2450,8 @@ class Ee {
|
|
|
2272
2450
|
}
|
|
2273
2451
|
});
|
|
2274
2452
|
this.edgeEntities.push(L);
|
|
2275
|
-
const f = i.pointColor ||
|
|
2276
|
-
for (const P of
|
|
2453
|
+
const f = i.pointColor || h, v = c.slice(0, c.length - 1);
|
|
2454
|
+
for (const P of v) {
|
|
2277
2455
|
const A = t.entities.add({
|
|
2278
2456
|
position: P,
|
|
2279
2457
|
point: {
|
|
@@ -2284,19 +2462,19 @@ class Ee {
|
|
|
2284
2462
|
});
|
|
2285
2463
|
this.pointEntities.push(A);
|
|
2286
2464
|
}
|
|
2287
|
-
const y = this.computeAreaByPlane(c),
|
|
2465
|
+
const y = this.computeAreaByPlane(c), b = e.Cartographic.fromCartesian(d), E = this.htmlLabelId || `measure_regular_${Date.now()}`;
|
|
2288
2466
|
this.htmlLabelId = E;
|
|
2289
2467
|
const x = i.labelText || { sides: "边数", radius: "半径", circumference: "周长", area: "面积", side: "边长" };
|
|
2290
2468
|
this.previewLabelId && this.htmlLabelPool && (this.htmlLabelPool.removeByIds([this.previewLabelId]), this.previewLabelId = null);
|
|
2291
|
-
let
|
|
2469
|
+
let T = 0;
|
|
2292
2470
|
for (let P = 1; P < c.length; P++) {
|
|
2293
|
-
const A = c[P - 1], I = c[P], S = e.Cartographic.fromCartesian(A),
|
|
2294
|
-
|
|
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),
|
|
2296
|
-
this.segmentLabelIds.push(
|
|
2471
|
+
const A = c[P - 1], I = c[P], S = e.Cartographic.fromCartesian(A), H = e.Cartographic.fromCartesian(I), F = new e.EllipsoidGeodesic(S, H).surfaceDistance;
|
|
2472
|
+
T += F;
|
|
2473
|
+
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), W = `measure_regular_seg_${Date.now()}_${P - 1}`;
|
|
2474
|
+
this.segmentLabelIds.push(W), this.htmlLabelPool.add(
|
|
2297
2475
|
{ text: `${x.side}:${F.toFixed(2)} m` },
|
|
2298
2476
|
{
|
|
2299
|
-
id:
|
|
2477
|
+
id: W,
|
|
2300
2478
|
lon: e.Math.toDegrees(z.longitude),
|
|
2301
2479
|
lat: e.Math.toDegrees(z.latitude),
|
|
2302
2480
|
height: z.height || 0,
|
|
@@ -2306,15 +2484,15 @@ class Ee {
|
|
|
2306
2484
|
);
|
|
2307
2485
|
}
|
|
2308
2486
|
this.htmlLabelPool.add(
|
|
2309
|
-
{ text: `${x.sides}:${
|
|
2487
|
+
{ text: `${x.sides}:${a}
|
|
2310
2488
|
${x.radius}:${r.toFixed(2)} m
|
|
2311
|
-
${x.circumference}:${
|
|
2489
|
+
${x.circumference}:${T.toFixed(2)} m
|
|
2312
2490
|
${x.area}:${y.toFixed(2)} m²` },
|
|
2313
2491
|
{
|
|
2314
2492
|
id: E,
|
|
2315
|
-
lon: e.Math.toDegrees(
|
|
2316
|
-
lat: e.Math.toDegrees(
|
|
2317
|
-
height:
|
|
2493
|
+
lon: e.Math.toDegrees(b.longitude),
|
|
2494
|
+
lat: e.Math.toDegrees(b.latitude),
|
|
2495
|
+
height: b.height || 0,
|
|
2318
2496
|
theme: "measure-regular",
|
|
2319
2497
|
show: !0
|
|
2320
2498
|
}
|
|
@@ -2324,8 +2502,8 @@ ${x.area}:${y.toFixed(2)} m²` },
|
|
|
2324
2502
|
label: this.labelEntity,
|
|
2325
2503
|
positions: c,
|
|
2326
2504
|
radius: r,
|
|
2327
|
-
sides:
|
|
2328
|
-
perimeter:
|
|
2505
|
+
sides: a,
|
|
2506
|
+
perimeter: T,
|
|
2329
2507
|
area: y,
|
|
2330
2508
|
clear: () => this.clear()
|
|
2331
2509
|
};
|
|
@@ -2336,15 +2514,15 @@ ${x.area}:${y.toFixed(2)} m²` },
|
|
|
2336
2514
|
const o = this.positions[0], d = t.camera.getPickRay(s.endPosition), n = t.scene.globe.pick(d, t.scene);
|
|
2337
2515
|
if (!n) return;
|
|
2338
2516
|
const r = e.Cartesian3.distance(o, n);
|
|
2339
|
-
if (this.currentPoints = this.buildRegularPolygonPoints(o, r,
|
|
2340
|
-
const
|
|
2517
|
+
if (this.currentPoints = this.buildRegularPolygonPoints(o, r, a), !this.previewEntity) {
|
|
2518
|
+
const l = i.color || e.Color.YELLOW.withAlpha(0.4);
|
|
2341
2519
|
this.previewEntity = t.entities.add({
|
|
2342
2520
|
polygon: {
|
|
2343
2521
|
hierarchy: new e.CallbackProperty(() => {
|
|
2344
2522
|
if (!(!this.currentPoints || this.currentPoints.length === 0))
|
|
2345
2523
|
return new e.PolygonHierarchy(this.currentPoints);
|
|
2346
2524
|
}, !1),
|
|
2347
|
-
material:
|
|
2525
|
+
material: l,
|
|
2348
2526
|
perPositionHeight: !0,
|
|
2349
2527
|
arcType: e.ArcType.NONE
|
|
2350
2528
|
}
|
|
@@ -2382,18 +2560,18 @@ ${x.area}:${y.toFixed(2)} m²` },
|
|
|
2382
2560
|
this.previewPointEntities.push(L, f);
|
|
2383
2561
|
}
|
|
2384
2562
|
let c = 0;
|
|
2385
|
-
for (let
|
|
2386
|
-
const w = this.currentPoints[
|
|
2563
|
+
for (let l = 1; l < this.currentPoints.length; l++) {
|
|
2564
|
+
const w = this.currentPoints[l - 1], u = this.currentPoints[l], C = e.Cartographic.fromCartesian(w), L = e.Cartographic.fromCartesian(u), f = new e.EllipsoidGeodesic(C, L);
|
|
2387
2565
|
c += f.surfaceDistance;
|
|
2388
2566
|
}
|
|
2389
2567
|
const p = this.computeAreaByPlane(this.currentPoints), m = e.Cartographic.fromCartesian(o), g = this.previewLabelId || "measure_regular_preview";
|
|
2390
2568
|
this.previewLabelId = g;
|
|
2391
|
-
const
|
|
2569
|
+
const h = i.labelText || { sides: "边数", radius: "半径", circumference: "周长", area: "面积" };
|
|
2392
2570
|
this.htmlLabelPool.add(
|
|
2393
|
-
{ text: `${
|
|
2394
|
-
${
|
|
2395
|
-
${
|
|
2396
|
-
${
|
|
2571
|
+
{ text: `${h.sides}:${a}
|
|
2572
|
+
${h.radius}:${r.toFixed(2)} m
|
|
2573
|
+
${h.circumference}:${c.toFixed(2)} m
|
|
2574
|
+
${h.area}:${p.toFixed(2)} m²` },
|
|
2397
2575
|
{
|
|
2398
2576
|
id: g,
|
|
2399
2577
|
lon: e.Math.toDegrees(m.longitude),
|
|
@@ -2436,18 +2614,18 @@ ${l.area}:${p.toFixed(2)} m²` },
|
|
|
2436
2614
|
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
2615
|
}
|
|
2438
2616
|
rehydrate(i, e) {
|
|
2439
|
-
const t = this.Cesium,
|
|
2617
|
+
const t = this.Cesium, a = 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
2618
|
if (d.length < 2) return;
|
|
2441
2619
|
if (!this.htmlLabelPool) {
|
|
2442
2620
|
const y = s.overlayContainerId || "html-label-container";
|
|
2443
|
-
this.htmlLabelPool = e || new
|
|
2444
|
-
createElement: (
|
|
2445
|
-
|
|
2621
|
+
this.htmlLabelPool = e || new _(t, a, y), this.htmlLabelPool.registerTheme("measure-regular", {
|
|
2622
|
+
createElement: (b, E) => {
|
|
2623
|
+
b.innerHTML = String(E?.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";
|
|
2446
2624
|
},
|
|
2447
2625
|
options: { offset: { x: 0, y: -10 } }
|
|
2448
2626
|
}), this.htmlLabelPool.registerTheme("measure-regular-seg", {
|
|
2449
|
-
createElement: (
|
|
2450
|
-
|
|
2627
|
+
createElement: (b, E) => {
|
|
2628
|
+
b.innerHTML = String(E?.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";
|
|
2451
2629
|
},
|
|
2452
2630
|
options: { offset: { x: 0, y: -10 } }
|
|
2453
2631
|
});
|
|
@@ -2455,9 +2633,9 @@ ${l.area}:${p.toFixed(2)} m²` },
|
|
|
2455
2633
|
let n = [], r = d[0], c = 0;
|
|
2456
2634
|
if (d.length >= 3) {
|
|
2457
2635
|
n = d.slice(), r = new t.Cartesian3(
|
|
2458
|
-
n.reduce((
|
|
2459
|
-
n.reduce((
|
|
2460
|
-
n.reduce((
|
|
2636
|
+
n.reduce((b, E) => b + E.x, 0) / n.length,
|
|
2637
|
+
n.reduce((b, E) => b + E.y, 0) / n.length,
|
|
2638
|
+
n.reduce((b, E) => b + E.z, 0) / n.length
|
|
2461
2639
|
);
|
|
2462
2640
|
const y = n[0];
|
|
2463
2641
|
n[Math.floor(n.length / 2)] || n[1], c = t.Cartesian3.distance(r, y);
|
|
@@ -2465,28 +2643,28 @@ ${l.area}:${p.toFixed(2)} m²` },
|
|
|
2465
2643
|
const y = d[1];
|
|
2466
2644
|
c = t.Cartesian3.distance(r, y), n = this.buildRegularPolygonPoints(r, c, Math.max(o, 3));
|
|
2467
2645
|
}
|
|
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 }),
|
|
2469
|
-
|
|
2646
|
+
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 }), h = s.color || t.Color.YELLOW.withAlpha(0.4), l = 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: h }), translucent: !0, closed: !0 }), depthFailAppearance: new t.MaterialAppearance({ material: t.Material.fromType("Color", { color: l }), translucent: !0, closed: !0 }) });
|
|
2647
|
+
a.scene.primitives.add(w), this.primitive = w;
|
|
2470
2648
|
const u = this.computeAreaByPlane(n), C = t.Cartographic.fromCartesian(r), L = i.id + "_regular";
|
|
2471
2649
|
this.htmlLabelId = L;
|
|
2472
2650
|
const f = s.labelText || { sides: "边数", radius: "半径", circumference: "周长", area: "面积", side: "边长" };
|
|
2473
|
-
let
|
|
2651
|
+
let v = 0;
|
|
2474
2652
|
for (let y = 1; y < n.length; y++) {
|
|
2475
|
-
const
|
|
2476
|
-
|
|
2477
|
-
const A = new t.Cartesian3((
|
|
2653
|
+
const b = n[y - 1], E = n[y], x = t.Cartographic.fromCartesian(b), T = t.Cartographic.fromCartesian(E), P = new t.EllipsoidGeodesic(x, T).surfaceDistance;
|
|
2654
|
+
v += P;
|
|
2655
|
+
const A = new t.Cartesian3((b.x + E.x) / 2, (b.y + E.y) / 2, (b.z + E.z) / 2), I = t.Cartographic.fromCartesian(A), S = i.id + `_regular_seg_${y - 1}`;
|
|
2478
2656
|
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
2657
|
}
|
|
2480
2658
|
this.htmlLabelPool.add({ text: `${f.sides}:${Math.max(o, 3)}
|
|
2481
2659
|
${f.radius}:${c.toFixed(2)} m
|
|
2482
|
-
${f.circumference}:${
|
|
2660
|
+
${f.circumference}:${v.toFixed(2)} m
|
|
2483
2661
|
${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
2662
|
}
|
|
2485
2663
|
buildRegularPolygonPoints(i, e, t) {
|
|
2486
|
-
const
|
|
2664
|
+
const a = this.Cesium, s = new a.EllipsoidTangentPlane(i, a.Ellipsoid.WGS84), o = 2 * Math.PI / t, d = [];
|
|
2487
2665
|
for (let c = 0; c < t; c++) {
|
|
2488
2666
|
const p = c * o, m = e * Math.cos(p), g = e * Math.sin(p);
|
|
2489
|
-
d.push(new
|
|
2667
|
+
d.push(new a.Cartesian2(m, g));
|
|
2490
2668
|
}
|
|
2491
2669
|
const r = s.projectPointsOntoEllipsoid(d).slice();
|
|
2492
2670
|
return r.push(r[0]), r;
|
|
@@ -2505,7 +2683,7 @@ ${f.area}:${u.toFixed(2)} m²` }, { id: L, lon: t.Math.toDegrees(C.longitude), l
|
|
|
2505
2683
|
return Math.abs(o) / 2;
|
|
2506
2684
|
}
|
|
2507
2685
|
}
|
|
2508
|
-
class
|
|
2686
|
+
class Ae {
|
|
2509
2687
|
Cesium;
|
|
2510
2688
|
viewer;
|
|
2511
2689
|
actives = [];
|
|
@@ -2522,44 +2700,44 @@ class Pe {
|
|
|
2522
2700
|
let t = null;
|
|
2523
2701
|
switch (i) {
|
|
2524
2702
|
case "horizontal":
|
|
2525
|
-
t = new
|
|
2703
|
+
t = new re(this.Cesium, this.viewer);
|
|
2526
2704
|
break;
|
|
2527
2705
|
case "vertical":
|
|
2528
|
-
t = new
|
|
2706
|
+
t = new we(this.Cesium, this.viewer);
|
|
2529
2707
|
break;
|
|
2530
2708
|
case "triangle":
|
|
2531
|
-
t = new
|
|
2709
|
+
t = new fe(this.Cesium, this.viewer);
|
|
2532
2710
|
break;
|
|
2533
2711
|
case "space":
|
|
2534
|
-
t = new
|
|
2712
|
+
t = new Ce(this.Cesium, this.viewer);
|
|
2535
2713
|
break;
|
|
2536
2714
|
case "area":
|
|
2537
|
-
t = new
|
|
2715
|
+
t = new ae(this.Cesium, this.viewer);
|
|
2538
2716
|
break;
|
|
2539
2717
|
case "circle":
|
|
2540
|
-
t = new
|
|
2718
|
+
t = new ve(this.Cesium, this.viewer);
|
|
2541
2719
|
break;
|
|
2542
2720
|
case "polyline":
|
|
2543
|
-
t = new
|
|
2721
|
+
t = new le(this.Cesium, this.viewer);
|
|
2544
2722
|
break;
|
|
2545
2723
|
case "terrainHeight":
|
|
2546
2724
|
t = new be(this.Cesium, this.viewer);
|
|
2547
2725
|
break;
|
|
2548
2726
|
case "coordinate":
|
|
2549
|
-
t = new
|
|
2727
|
+
t = new Le(this.Cesium, this.viewer);
|
|
2550
2728
|
break;
|
|
2551
2729
|
case "rectangle":
|
|
2552
|
-
t = new
|
|
2730
|
+
t = new Ee(this.Cesium, this.viewer);
|
|
2553
2731
|
break;
|
|
2554
2732
|
case "regularPolygon":
|
|
2555
|
-
t = new
|
|
2733
|
+
t = new Pe(this.Cesium, this.viewer);
|
|
2556
2734
|
break;
|
|
2557
2735
|
default:
|
|
2558
2736
|
throw new Error(`Unsupported measurement type: ${i}`);
|
|
2559
2737
|
}
|
|
2560
2738
|
if (!t) return;
|
|
2561
2739
|
this.actives.push(t);
|
|
2562
|
-
const
|
|
2740
|
+
const a = t, s = {
|
|
2563
2741
|
...e,
|
|
2564
2742
|
onComplete: (o) => {
|
|
2565
2743
|
const d = {
|
|
@@ -2591,8 +2769,8 @@ class Pe {
|
|
|
2591
2769
|
})(),
|
|
2592
2770
|
data: this._serializeMetrics(i, o)
|
|
2593
2771
|
};
|
|
2594
|
-
this.measurements.push(d),
|
|
2595
|
-
const n = this.actives.indexOf(
|
|
2772
|
+
this.measurements.push(d), a && this.recordHandlers.set(d.id, a), this.specifiedClear && this._showDeleteLabels("html-label-container"), e.onComplete?.(o);
|
|
2773
|
+
const n = this.actives.indexOf(a);
|
|
2596
2774
|
n >= 0 && this.actives.splice(n, 1);
|
|
2597
2775
|
}
|
|
2598
2776
|
};
|
|
@@ -2641,37 +2819,37 @@ class Pe {
|
|
|
2641
2819
|
let t = null;
|
|
2642
2820
|
switch (e.type) {
|
|
2643
2821
|
case "horizontal":
|
|
2644
|
-
t = new
|
|
2822
|
+
t = new re(this.Cesium, this.viewer);
|
|
2645
2823
|
break;
|
|
2646
2824
|
case "vertical":
|
|
2647
|
-
t = new
|
|
2825
|
+
t = new we(this.Cesium, this.viewer);
|
|
2648
2826
|
break;
|
|
2649
2827
|
case "triangle":
|
|
2650
|
-
t = new
|
|
2828
|
+
t = new fe(this.Cesium, this.viewer);
|
|
2651
2829
|
break;
|
|
2652
2830
|
case "space":
|
|
2653
|
-
t = new
|
|
2831
|
+
t = new Ce(this.Cesium, this.viewer);
|
|
2654
2832
|
break;
|
|
2655
2833
|
case "area":
|
|
2656
|
-
t = new
|
|
2834
|
+
t = new ae(this.Cesium, this.viewer);
|
|
2657
2835
|
break;
|
|
2658
2836
|
case "circle":
|
|
2659
|
-
t = new
|
|
2837
|
+
t = new ve(this.Cesium, this.viewer);
|
|
2660
2838
|
break;
|
|
2661
2839
|
case "polyline":
|
|
2662
|
-
t = new
|
|
2840
|
+
t = new le(this.Cesium, this.viewer);
|
|
2663
2841
|
break;
|
|
2664
2842
|
case "terrainHeight":
|
|
2665
2843
|
t = new be(this.Cesium, this.viewer);
|
|
2666
2844
|
break;
|
|
2667
2845
|
case "coordinate":
|
|
2668
|
-
t = new
|
|
2846
|
+
t = new Le(this.Cesium, this.viewer);
|
|
2669
2847
|
break;
|
|
2670
2848
|
case "rectangle":
|
|
2671
|
-
t = new
|
|
2849
|
+
t = new Ee(this.Cesium, this.viewer);
|
|
2672
2850
|
break;
|
|
2673
2851
|
case "regularPolygon":
|
|
2674
|
-
t = new
|
|
2852
|
+
t = new Pe(this.Cesium, this.viewer);
|
|
2675
2853
|
break;
|
|
2676
2854
|
default:
|
|
2677
2855
|
t = null;
|
|
@@ -2734,8 +2912,8 @@ class Pe {
|
|
|
2734
2912
|
} catch {
|
|
2735
2913
|
}
|
|
2736
2914
|
}
|
|
2737
|
-
const
|
|
2738
|
-
|
|
2915
|
+
const a = e.scene.primitives, s = [];
|
|
2916
|
+
a._primitives && a._primitives.forEach((o) => s.push(o));
|
|
2739
2917
|
for (const o of s)
|
|
2740
2918
|
try {
|
|
2741
2919
|
e.scene.primitives.remove(o);
|
|
@@ -2749,19 +2927,19 @@ class Pe {
|
|
|
2749
2927
|
else {
|
|
2750
2928
|
if (this.specifiedClear = !0, !this.deleteLabelPool) {
|
|
2751
2929
|
const e = i || "html-label-container";
|
|
2752
|
-
this.deleteLabelPool = new
|
|
2753
|
-
createElement: (t,
|
|
2930
|
+
this.deleteLabelPool = new _(this.Cesium, this.viewer, e), this.deleteLabelPool.registerTheme("measure-delete-label", {
|
|
2931
|
+
createElement: (t, a) => {
|
|
2754
2932
|
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
2933
|
},
|
|
2756
2934
|
options: { offset: { x: 0, y: -10 } }
|
|
2757
2935
|
}), this.deleteLabelPool.eventBus.addListener(
|
|
2758
|
-
|
|
2936
|
+
$e.Click,
|
|
2759
2937
|
{
|
|
2760
2938
|
name: "measurement_delete_label_click",
|
|
2761
2939
|
fn: (t) => {
|
|
2762
2940
|
if (!t || t.theme !== "measure-delete-label") return;
|
|
2763
|
-
const
|
|
2764
|
-
|
|
2941
|
+
const a = t?.data?.recordId;
|
|
2942
|
+
a && this.deleteMeasurement(a);
|
|
2765
2943
|
}
|
|
2766
2944
|
},
|
|
2767
2945
|
!0
|
|
@@ -2777,7 +2955,7 @@ class Pe {
|
|
|
2777
2955
|
e.clear();
|
|
2778
2956
|
} catch {
|
|
2779
2957
|
}
|
|
2780
|
-
this.recordHandlers.delete(i), this.measurements = this.measurements.filter((
|
|
2958
|
+
this.recordHandlers.delete(i), this.measurements = this.measurements.filter((a) => a.id !== i);
|
|
2781
2959
|
const t = this.deleteLabelIds.get(i);
|
|
2782
2960
|
t && this.deleteLabelPool && this.deleteLabelPool.removeByIds([t]), this.deleteLabelIds.delete(i);
|
|
2783
2961
|
}
|
|
@@ -2785,7 +2963,7 @@ class Pe {
|
|
|
2785
2963
|
if (!this.deleteLabelPool) return;
|
|
2786
2964
|
const e = this.Cesium;
|
|
2787
2965
|
for (const t of this.measurements) {
|
|
2788
|
-
const
|
|
2966
|
+
const a = "m_del_" + t.id;
|
|
2789
2967
|
if (this.deleteLabelIds.has(t.id)) continue;
|
|
2790
2968
|
const s = this._computeRecordCenter(t);
|
|
2791
2969
|
if (!s) continue;
|
|
@@ -2793,7 +2971,7 @@ class Pe {
|
|
|
2793
2971
|
this.deleteLabelPool.add(
|
|
2794
2972
|
{ recordId: t.id },
|
|
2795
2973
|
{
|
|
2796
|
-
id:
|
|
2974
|
+
id: a,
|
|
2797
2975
|
lon: d,
|
|
2798
2976
|
lat: n,
|
|
2799
2977
|
height: r,
|
|
@@ -2801,7 +2979,7 @@ class Pe {
|
|
|
2801
2979
|
show: !0,
|
|
2802
2980
|
style: { zIndex: "1000" }
|
|
2803
2981
|
}
|
|
2804
|
-
), this.deleteLabelIds.set(t.id,
|
|
2982
|
+
), this.deleteLabelIds.set(t.id, a);
|
|
2805
2983
|
}
|
|
2806
2984
|
}
|
|
2807
2985
|
_removeAllDeleteLabels() {
|
|
@@ -2812,23 +2990,23 @@ class Pe {
|
|
|
2812
2990
|
this.deleteLabelIds.clear();
|
|
2813
2991
|
}
|
|
2814
2992
|
_computeRecordCenter(i) {
|
|
2815
|
-
const e = this.Cesium, t = (i.positions || []).map((
|
|
2993
|
+
const e = this.Cesium, t = (i.positions || []).map((a) => this._toCartesian(a));
|
|
2816
2994
|
if (t.length > 0) {
|
|
2817
|
-
const
|
|
2818
|
-
return new e.Cartesian3(
|
|
2995
|
+
const a = 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;
|
|
2996
|
+
return new e.Cartesian3(a, s, o);
|
|
2819
2997
|
}
|
|
2820
2998
|
if (i.type === "coordinate" && i.data?.lnglat) {
|
|
2821
|
-
const
|
|
2822
|
-
return e.Cartesian3.fromDegrees(
|
|
2999
|
+
const a = i.data.lnglat.lng, s = i.data.lnglat.lat, o = i.data.lnglat.height || 0;
|
|
3000
|
+
return e.Cartesian3.fromDegrees(a, s, o);
|
|
2823
3001
|
}
|
|
2824
3002
|
if (i.type === "terrainHeight" && i.data?.position) {
|
|
2825
|
-
const
|
|
2826
|
-
return new e.Cartesian3(
|
|
3003
|
+
const a = i.data.position;
|
|
3004
|
+
return new e.Cartesian3(a.x, a.y, a.z);
|
|
2827
3005
|
}
|
|
2828
3006
|
return null;
|
|
2829
3007
|
}
|
|
2830
3008
|
}
|
|
2831
|
-
const
|
|
3009
|
+
const Ye = {
|
|
2832
3010
|
Cesium: {
|
|
2833
3011
|
type: Object,
|
|
2834
3012
|
required: !1
|
|
@@ -2845,32 +3023,32 @@ const $e = {
|
|
|
2845
3023
|
type: String,
|
|
2846
3024
|
default: "cx-measurement-overlay"
|
|
2847
3025
|
}
|
|
2848
|
-
},
|
|
2849
|
-
name: `${
|
|
3026
|
+
}, Ie = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAQ9JREFUOE+dkjESAUEQRe0NOAEiIaEMERluQCYQcAKcACcgFLqBlQn3BsgFbsD7zKixdlbVTtWv7e3/+0937wY5z3lwXCrgJEkTkxIag6NC0MxqsDAG86wGoWk7vYP4vL69xPPq6rUDZ1574z+Pht2La6BioWXm9pmcIOpJBv9u/eE/I1iGUSLiPEQpyQ1eHRbhy5b//AeQTZIHMESw9RgMyG9AH81eGtdART1Qgrz75uGiC1yERtq3AUm1fAZriAnvM576icR9xaZmxrOM5mIN5iReSVABU8gOxe14zPvIvcwaqOVQbVG0JL4Sr1JijdtFUwgQDXjRYrQUfYUx2IFbSlyD0w6GMlBRVfNmONETek2ROovJNQ4AAAAASUVORK5CYII=", Ve = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAATBJREFUOE+lk4FNw0AMRbkJgAlYASYgTABMQNigTECZgDIBHaGdgHYCygZsAEwQ3ot8p2uUFqRasnKO7X/+PjsdDaTrunN+XaMN6lnZoCt0mVLyXCTVBskT7Of4t45ETYEu0W90CshLzisAJC/i5iXfliCDi+A/wZhHzAL/rc4eoLr5HodBO4XYFucr+kDsLAXnd37I72ZfcvZFtVK6EmDK4RE9HZa9CyzofOF/EmDVc0mpGXC2GoHlbrn2qEjJ42Cz5gT4AnXAJ8ZZ/Njgvxj4Z9h3VvAfgA8A8kz0OOQJ0P5Fwf5IYbKPgkEHNdHSbORbHo6a69g5nrHB1xw+SPmGapR9LidybJSdQJ+3DN3YMtmT46CVN0+alvyDuky+QC9bAPE8BnuLCcN1dom21vkXc/+iuK1zLp4AAAAASUVORK5CYII=", Ge = "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", Qe = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAQFJREFUOE+VUzsSAUEQtZEj2FsQysjIyIRKtCmRkgnJyIRCmZURIZRxC07Be6pnq3e2Z5WuejX9mf5OT/QGVRRFIC37fOE+Fc5J86Eghfu+oiy7s+US+iXh0gvYAQPhjziHwA14AkmuZQoS5CGGPs49QHkMnIE1cBf+irPnqvgOTAIwc/OH8wR2JjADMEurJDOdSRugalXA/k6Bsp3zCnbOJ7ECsOe20bN2pn0eamEJQ8cbmO/cgH0B1EItzNS0LWe+Cp91agU4SHl8tpAzW7gA9SyAsUgjmTYHRgeWzczkqeNSZRQZq5zC2gW2QAxwN8hTRzkurLJW6OghvvQv/PudP2fPqPEaEaVuAAAAAElFTkSuQmCC", Ke = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAVCAYAAACg/AXsAAAABHNCSVQICAgIfAhkiAAAAPZJREFUOE/tk0EOwUAUhs0NLCyRLsTa2ooT4ATqRuICWhfA1ik4AYmtBCeo769OUq1pxk7ES740fW/eP2/+aU3NEUmSnCk1c+W2MUa5Upi/iL8nWom5Kx59DO24vFPeaeyPieBHnSPtoAs9fDm5fCl5QvOYxSOYwAUacIMjRIjFRbFUhMaAxxRCuMMcNrCwt5OJqz6AJcQI7tPboaiCkooZhcjuRE3TtMhJLA1yViTIhML8JBITV9AkW5p1DNusY2raIWgjHe05iV1U2ElialqDhPR+yBol8BJVf7FuR82BJvvodoq7+LxXfvY+Am898W3Mr/ueSR4JpmsW0RAzTwAAAABJRU5ErkJggg==", Je = "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=", qe = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAU5JREFUOE+dkjFLQzEURnsRRUW0uDkI3XQo0m6Odms3QRHHjk5SNzfd/Ac66iKKIm0nHf0HduncooibiLo5PM/3SCAvlmL74NDk3uTk3jSWG/FLkmSTLUeQhwMbcX8OQZ89H46FcQWvCGbBxhFssfEGvqCeEfzpz6wVt+jWNInXzOwhFmT7MysPEFwT24BlBD+x4JmE+puGSRYUQwGnzzF/g0tye8rFAtm34RtmYIWFqir9EOzycwUV4o8ZAckCgSdowz68wD0LtckLdCfrsEQ8iQUXBPRISjoV4SHjEygy77ry35mfMm94qQU3v0bw1p9IXPfQhw6xKvM643MoM++EAi3Sy1Lf8yQl8iXros6gBjq1QH7V59MW3NPsMdbbJm+lQDDBWP/MFCzCHfmdWKC+j52gwYLM4+EACdT7p9aEFaYVhLZB42EV/lcwtMJfrJ6SRKgz9VoAAAAASUVORK5CYII=", Xe = "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=", et = ["onClick"], tt = ["src", "alt"], it = ["src"], st = ["src"], ot = ["id"], nt = /* @__PURE__ */ ke({
|
|
3027
|
+
name: `${Te}-measurement`,
|
|
2850
3028
|
__name: "Measurement",
|
|
2851
|
-
props:
|
|
2852
|
-
setup(
|
|
2853
|
-
const e =
|
|
2854
|
-
{ key: "horizontal", label: "水平测距", icon:
|
|
2855
|
-
{ key: "vertical", label: "垂直测距", icon:
|
|
3029
|
+
props: Ye,
|
|
3030
|
+
setup(Q, { expose: i }) {
|
|
3031
|
+
const e = Q, t = De("measurement"), a = e.overlayContainerId || "cx-measurement-overlay", s = [
|
|
3032
|
+
{ key: "horizontal", label: "水平测距", icon: je },
|
|
3033
|
+
{ key: "vertical", label: "垂直测距", icon: Je },
|
|
2856
3034
|
{ key: "space", label: "空间测距", icon: Ze },
|
|
2857
|
-
{ key: "triangle", label: "三角测量", icon:
|
|
2858
|
-
{ key: "polyline", label: "折线测距", icon:
|
|
2859
|
-
{ key: "area", label: "面积测量", icon:
|
|
3035
|
+
{ key: "triangle", label: "三角测量", icon: Xe },
|
|
3036
|
+
{ key: "polyline", label: "折线测距", icon: qe },
|
|
3037
|
+
{ key: "area", label: "面积测量", icon: Qe },
|
|
2860
3038
|
{ key: "circle", label: "圆形测量", icon: We },
|
|
2861
3039
|
{ key: "rectangle", label: "矩形测量", icon: Ue },
|
|
2862
|
-
{ key: "regularPolygon", label: "正多边形", icon:
|
|
2863
|
-
{ key: "terrainHeight", label: "地形高度", icon:
|
|
2864
|
-
{ key: "coordinate", label: "坐标查询", icon:
|
|
2865
|
-
], o =
|
|
3040
|
+
{ key: "regularPolygon", label: "正多边形", icon: Ge },
|
|
3041
|
+
{ key: "terrainHeight", label: "地形高度", icon: Ke },
|
|
3042
|
+
{ key: "coordinate", label: "坐标查询", icon: Ve }
|
|
3043
|
+
], o = ce(""), d = ce(!1), n = ce(null);
|
|
2866
3044
|
let r = null;
|
|
2867
|
-
const c =
|
|
2868
|
-
!u || !C || (r = u, n.value = new
|
|
3045
|
+
const c = Fe("leitingMethods"), p = (u, C) => {
|
|
3046
|
+
!u || !C || (r = u, n.value = new Ae({ Cesium: u, viewer: C }));
|
|
2869
3047
|
}, m = (u) => {
|
|
2870
|
-
const C =
|
|
3048
|
+
const C = G(c);
|
|
2871
3049
|
if (!n.value && C) {
|
|
2872
3050
|
const L = C.getCesium(), f = C.getViewer();
|
|
2873
|
-
r = L, n.value = new
|
|
3051
|
+
r = L, n.value = new Ae({ Cesium: L, viewer: f });
|
|
2874
3052
|
}
|
|
2875
3053
|
if (!(!n.value || !r)) {
|
|
2876
3054
|
if (u === "clear") {
|
|
@@ -2878,7 +3056,7 @@ const $e = {
|
|
|
2878
3056
|
return;
|
|
2879
3057
|
}
|
|
2880
3058
|
o.value = u, n.value.measure(u, {
|
|
2881
|
-
overlayContainerId:
|
|
3059
|
+
overlayContainerId: a,
|
|
2882
3060
|
color: r.Color.YELLOW.withAlpha(0.5),
|
|
2883
3061
|
lineColor: r.Color.fromCssColorString("#51ff00"),
|
|
2884
3062
|
dashLineColor: r.Color.RED,
|
|
@@ -2887,34 +3065,34 @@ const $e = {
|
|
|
2887
3065
|
}
|
|
2888
3066
|
}, g = () => {
|
|
2889
3067
|
n.value && (n.value.clearAll(), o.value = "");
|
|
2890
|
-
},
|
|
2891
|
-
n.value && n.value.toggleSpecifiedClear(
|
|
2892
|
-
},
|
|
3068
|
+
}, h = () => {
|
|
3069
|
+
n.value && n.value.toggleSpecifiedClear(a);
|
|
3070
|
+
}, l = (u) => {
|
|
2893
3071
|
d.value = u;
|
|
2894
3072
|
};
|
|
2895
3073
|
function w() {
|
|
2896
3074
|
if (n.value) return n.value;
|
|
2897
|
-
const u =
|
|
3075
|
+
const u = G(c), C = u?.getCesium?.(), L = u?.getViewer?.();
|
|
2898
3076
|
(C && L || e.Cesium && e.viewer) && p(C, L);
|
|
2899
3077
|
}
|
|
2900
|
-
return
|
|
3078
|
+
return _e(
|
|
2901
3079
|
() => c?.value,
|
|
2902
3080
|
(u, C) => {
|
|
2903
3081
|
w();
|
|
2904
3082
|
},
|
|
2905
3083
|
{ deep: !1 }
|
|
2906
|
-
),
|
|
3084
|
+
), He(() => {
|
|
2907
3085
|
w();
|
|
2908
|
-
}),
|
|
3086
|
+
}), Oe(() => {
|
|
2909
3087
|
n.value && (n.value.clear(), n.value = null);
|
|
2910
3088
|
}), i({
|
|
2911
3089
|
init: p,
|
|
2912
|
-
open:
|
|
3090
|
+
open: l,
|
|
2913
3091
|
tool: n,
|
|
2914
3092
|
setMeasurementInfo(u) {
|
|
2915
3093
|
n.value && (u.measurements?.forEach((C) => {
|
|
2916
3094
|
C.options = {
|
|
2917
|
-
overlayContainerId:
|
|
3095
|
+
overlayContainerId: a,
|
|
2918
3096
|
color: r.Color.YELLOW,
|
|
2919
3097
|
lineColor: r.Color.fromCssColorString("#51ff00"),
|
|
2920
3098
|
dashLineColor: r.Color.RED,
|
|
@@ -2933,66 +3111,66 @@ const $e = {
|
|
|
2933
3111
|
measurements: []
|
|
2934
3112
|
};
|
|
2935
3113
|
}
|
|
2936
|
-
}), (u, C) => (
|
|
2937
|
-
|
|
2938
|
-
class: ee([
|
|
3114
|
+
}), (u, C) => (ge(), ue(ye, null, [
|
|
3115
|
+
Re(K("div", {
|
|
3116
|
+
class: ee([G(t).b("box"), G(t).is("small", e.size === "small")])
|
|
2939
3117
|
}, [
|
|
2940
|
-
(
|
|
3118
|
+
(ge(), ue(ye, null, Ne(s, (L) => K("div", {
|
|
2941
3119
|
key: L.key,
|
|
2942
|
-
class: ee([
|
|
3120
|
+
class: ee([G(t).be("box", "btn"), { active: o.value === L.key }]),
|
|
2943
3121
|
onClick: (f) => m(L.key)
|
|
2944
3122
|
}, [
|
|
2945
3123
|
K("div", {
|
|
2946
|
-
class: ee(
|
|
3124
|
+
class: ee(G(t).be("box", "icon"))
|
|
2947
3125
|
}, [
|
|
2948
3126
|
K("img", {
|
|
2949
3127
|
src: L.icon,
|
|
2950
3128
|
alt: L.label
|
|
2951
|
-
}, null, 8,
|
|
3129
|
+
}, null, 8, tt)
|
|
2952
3130
|
], 2),
|
|
2953
|
-
|
|
2954
|
-
], 10,
|
|
3131
|
+
de(" " + ze(L.label), 1)
|
|
3132
|
+
], 10, et)), 64)),
|
|
2955
3133
|
K("div", {
|
|
2956
|
-
class: ee(
|
|
2957
|
-
onClick:
|
|
3134
|
+
class: ee(G(t).be("box", "btn")),
|
|
3135
|
+
onClick: h
|
|
2958
3136
|
}, [
|
|
2959
3137
|
K("div", {
|
|
2960
|
-
class: ee(
|
|
3138
|
+
class: ee(G(t).be("box", "icon"))
|
|
2961
3139
|
}, [
|
|
2962
3140
|
K("img", {
|
|
2963
|
-
src:
|
|
3141
|
+
src: G(Ie),
|
|
2964
3142
|
alt: "指定清除"
|
|
2965
|
-
}, null, 8,
|
|
3143
|
+
}, null, 8, it)
|
|
2966
3144
|
], 2),
|
|
2967
|
-
C[0] || (C[0] =
|
|
3145
|
+
C[0] || (C[0] = de(" 指定清除 ", -1))
|
|
2968
3146
|
], 2),
|
|
2969
3147
|
K("div", {
|
|
2970
|
-
class: ee(
|
|
3148
|
+
class: ee(G(t).be("box", "btn")),
|
|
2971
3149
|
onClick: g
|
|
2972
3150
|
}, [
|
|
2973
3151
|
K("div", {
|
|
2974
|
-
class: ee(
|
|
3152
|
+
class: ee(G(t).be("box", "icon"))
|
|
2975
3153
|
}, [
|
|
2976
3154
|
K("img", {
|
|
2977
|
-
src:
|
|
3155
|
+
src: G(Ie),
|
|
2978
3156
|
alt: "清除"
|
|
2979
|
-
}, null, 8,
|
|
3157
|
+
}, null, 8, st)
|
|
2980
3158
|
], 2),
|
|
2981
|
-
C[1] || (C[1] =
|
|
3159
|
+
C[1] || (C[1] = de(" 清除全部 ", -1))
|
|
2982
3160
|
], 2)
|
|
2983
3161
|
], 2), [
|
|
2984
|
-
[
|
|
3162
|
+
[Be, d.value]
|
|
2985
3163
|
]),
|
|
2986
3164
|
K("div", {
|
|
2987
|
-
id:
|
|
2988
|
-
class: ee(
|
|
2989
|
-
}, null, 10,
|
|
3165
|
+
id: G(a),
|
|
3166
|
+
class: ee(G(t).be("box", "container"))
|
|
3167
|
+
}, null, 10, ot)
|
|
2990
3168
|
], 64));
|
|
2991
3169
|
}
|
|
2992
|
-
}),
|
|
3170
|
+
}), ht = Se(nt);
|
|
2993
3171
|
export {
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
3172
|
+
ht as CxMeasurement,
|
|
3173
|
+
ht as default,
|
|
3174
|
+
Ye as measurementProps
|
|
2997
3175
|
};
|
|
2998
3176
|
//# sourceMappingURL=measurement.js.map
|