@go-home-early/go-home-early98 0.3.1 → 0.3.3
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/README.md +53 -24
- package/dist/go-home-early.umd.js +5 -5
- package/package.json +4 -18
- package/src/packages/Cesium/DrawMap/DrawJs/CesiumEntityEdit.js +427 -0
- package/src/packages/Cesium/DrawMap/DrawJs/CreatePolygonOnGround.js +202 -0
- package/src/packages/Cesium/DrawMap/DrawJs/DrawAttackArrow.js +477 -0
- package/src/packages/Cesium/DrawMap/DrawJs/DrawBillboard.js +114 -0
- package/src/packages/Cesium/DrawMap/DrawJs/DrawCircle.js +311 -0
- package/src/packages/Cesium/DrawMap/DrawJs/DrawCircleTY.js +237 -0
- package/src/packages/Cesium/DrawMap/DrawJs/DrawCurve.js +256 -0
- package/src/packages/Cesium/DrawMap/DrawJs/DrawPincerArrow.js +584 -0
- package/src/packages/Cesium/DrawMap/DrawJs/DrawPoint.js +158 -0
- package/src/packages/Cesium/DrawMap/DrawJs/DrawPolygon.js +215 -0
- package/src/packages/Cesium/DrawMap/DrawJs/DrawPolyline.js +213 -0
- package/src/packages/Cesium/DrawMap/DrawJs/DrawPolylineJT.js +218 -0
- package/src/packages/Cesium/DrawMap/DrawJs/DrawProFile.js +314 -0
- package/src/packages/Cesium/DrawMap/DrawJs/DrawRectangle.js +215 -0
- package/src/packages/Cesium/DrawMap/DrawJs/DrawstraightArrow.js +364 -0
- package/src/packages/Cesium/DrawMap/DrawJs/MeasurePolygon.js +337 -0
- package/src/packages/Cesium/DrawMap/DrawJs/MeasurePolyline.js +285 -0
- package/src/packages/Cesium/DrawMap/DrawJs/ReminderTip.js +78 -0
- package/src/packages/Cesium/DrawMap/DrawJs/SlopeAspect.js +436 -0
- package/src/packages/Cesium/DrawMap/DrawJs/measureLength.js +177 -0
- package/src/packages/Cesium/DrawMap/index.vue +272 -0
- package/src/packages/Cesium/components/LocationDialog.vue +283 -0
- package/src/packages/Cesium/components/Popup.vue +591 -0
- package/src/packages/Cesium/components/PoumianDialog.vue +200 -0
- package/src/packages/Cesium/imgs/add-off.png +0 -0
- package/src/packages/Cesium/imgs/add.png +0 -0
- package/src/packages/Cesium/imgs/circle.png +0 -0
- package/src/packages/Cesium/imgs/icon-position-blue.png +0 -0
- package/src/packages/Cesium/imgs/line.png +0 -0
- package/src/packages/Cesium/imgs/map-delete.png +0 -0
- package/src/packages/Cesium/imgs/map.png +0 -0
- package/src/packages/Cesium/imgs/orientation-bg.svg +14 -0
- package/src/packages/Cesium/imgs/orientation.svg +21 -0
- package/src/packages/Cesium/imgs/poi.png +0 -0
- package/src/packages/Cesium/imgs/point.png +0 -0
- package/src/packages/Cesium/imgs/polygon.png +0 -0
- package/src/packages/Cesium/imgs/popup/back-popup-img.png +0 -0
- package/src/packages/Cesium/imgs/popup/backimg-btn.png +0 -0
- package/src/packages/Cesium/imgs/popup/dialog-bd.png +0 -0
- package/src/packages/Cesium/imgs/popup/dialog-btn.png +0 -0
- package/src/packages/Cesium/imgs/popup/dialog-ft.png +0 -0
- package/src/packages/Cesium/imgs/popup/dialog-hd.png +0 -0
- package/src/packages/Cesium/imgs/reduce-off.png +0 -0
- package/src/packages/Cesium/index.md +292 -0
- package/src/packages/Cesium/index.vue +3830 -0
- package/src/packages/Cesium/materials/CircularDiffusionMaterialProperty.js +98 -0
- package/src/packages/Cesium/materials/CircularRippleMaterialProperty.js +126 -0
- package/src/packages/Cesium/materials/PolylineArrowMaterialProperty.js +109 -0
- package/src/packages/Cesium/utils/MeasureHeight.js +261 -0
- package/src/packages/Cesium/utils/MeasureTools.js +1188 -0
- package/src/packages/index.js +33 -0
- package/src/packages/utils/charts.js +54 -0
- package/src/packages/utils/index.js +50 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
// DrawPolyline
|
|
2
|
+
/*
|
|
3
|
+
绘制线段箭头
|
|
4
|
+
*/
|
|
5
|
+
class DrawPolylineJT {
|
|
6
|
+
constructor(arg) {
|
|
7
|
+
this.viewer = arg.viewer;
|
|
8
|
+
this.Cesium = arg.Cesium;
|
|
9
|
+
this.Text = arg.data.text || '';
|
|
10
|
+
this.Color = arg.data.color || '#000';
|
|
11
|
+
this.imgUrl = arg.data.imgUrl || '';
|
|
12
|
+
this.FontSize = arg.data.fontSize || 16;
|
|
13
|
+
this.callback = arg.data.callback || null;
|
|
14
|
+
this.pxNum = arg.data.pxNum || 5;
|
|
15
|
+
this.handler = null;
|
|
16
|
+
this._polyline = null; // 活动线
|
|
17
|
+
this._polylineLast = null; // 最后一条线
|
|
18
|
+
this._positions = []; // 活动点
|
|
19
|
+
this._entities_point = []; // 脏数据
|
|
20
|
+
this._entities_line = []; // 脏数据
|
|
21
|
+
this._polylineData = null; // 用于构造线数据
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// 返回最后活动线
|
|
25
|
+
get line() {
|
|
26
|
+
return this._polylineLast;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// 返回线数据用于加载线
|
|
30
|
+
getData() {
|
|
31
|
+
return this._polylineData;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 加载线
|
|
35
|
+
loadPolyline(data) {
|
|
36
|
+
var $this = this;
|
|
37
|
+
for (var i = 0; i < $this._entities_point.length; i++) {
|
|
38
|
+
$this.viewer.entities.remove($this._entities_point[i]);
|
|
39
|
+
}
|
|
40
|
+
var polyline = this.viewer.entities.add({
|
|
41
|
+
polyline: {
|
|
42
|
+
positions: data,
|
|
43
|
+
show: true,
|
|
44
|
+
// material: $this.Cesium.Color.fromCssColorString($this.Color),
|
|
45
|
+
material: new $this.Cesium.PolylineArrowMaterialProperty(
|
|
46
|
+
$this.Cesium.Color.fromCssColorString($this.Color)
|
|
47
|
+
),
|
|
48
|
+
arrowSize: 3600, // 箭头大小
|
|
49
|
+
width: $this.pxNum,
|
|
50
|
+
clampToGround: true
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
return polyline;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// 开始创建
|
|
57
|
+
startCreate() {
|
|
58
|
+
var $this = this;
|
|
59
|
+
this.handler = new this.Cesium.ScreenSpaceEventHandler(
|
|
60
|
+
this.viewer.scene.canvas
|
|
61
|
+
);
|
|
62
|
+
this.handler.setInputAction(function(evt) {
|
|
63
|
+
// 单机开始绘制
|
|
64
|
+
// 屏幕坐标转地形上坐标
|
|
65
|
+
var cartesian = $this.getCatesian3FromPX(evt.position);
|
|
66
|
+
if ($this._positions.length == 0) {
|
|
67
|
+
$this._positions.push(cartesian.clone());
|
|
68
|
+
}
|
|
69
|
+
$this._positions.push(cartesian);
|
|
70
|
+
$this.createPoint(cartesian); // 绘制点
|
|
71
|
+
}, $this.Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
72
|
+
this.handler.setInputAction(function(evt) {
|
|
73
|
+
// 移动时绘制线
|
|
74
|
+
if ($this._positions.length < 1) return;
|
|
75
|
+
var cartesian = $this.getCatesian3FromPX(evt.endPosition);
|
|
76
|
+
if (!$this.Cesium.defined($this._polyline)) {
|
|
77
|
+
$this._polyline = $this.createPolyline();
|
|
78
|
+
}
|
|
79
|
+
if ($this._polyline) {
|
|
80
|
+
$this._positions.pop();
|
|
81
|
+
$this._positions.push(cartesian);
|
|
82
|
+
}
|
|
83
|
+
}, $this.Cesium.ScreenSpaceEventType.MOUSE_MOVE);
|
|
84
|
+
this.handler.setInputAction(function(evt) {
|
|
85
|
+
if (!$this._polyline) return;
|
|
86
|
+
var cartesian = $this.getCatesian3FromPX(evt.position);
|
|
87
|
+
$this._positions.pop();
|
|
88
|
+
$this._positions.push(cartesian);
|
|
89
|
+
$this.createPoint(cartesian); // 绘制点
|
|
90
|
+
$this._polylineData = $this._positions.concat();
|
|
91
|
+
$this.viewer.entities.remove($this._polyline); // 移除
|
|
92
|
+
$this._polyline = null;
|
|
93
|
+
$this._positions = [];
|
|
94
|
+
var line = $this.loadPolyline($this._polylineData); // 加载线
|
|
95
|
+
$this._entities_line.push(line);
|
|
96
|
+
$this._polylineLast = line;
|
|
97
|
+
if (typeof $this.callback == 'function') {
|
|
98
|
+
// 提取多边形层次结构
|
|
99
|
+
var hierarchy = line.polyline.positions.getValue();
|
|
100
|
+
// 从层次结构中提取坐标
|
|
101
|
+
var coordinates = hierarchy.map(function(position) {
|
|
102
|
+
var cartographic = $this.Cesium.Cartographic.fromCartesian(position);
|
|
103
|
+
return [
|
|
104
|
+
$this.Cesium.Math.toDegrees(cartographic.longitude),
|
|
105
|
+
$this.Cesium.Math.toDegrees(cartographic.latitude)
|
|
106
|
+
];
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// 创建GeoJSON对象
|
|
110
|
+
var geojson = {
|
|
111
|
+
type: 'LineString',
|
|
112
|
+
coordinates: coordinates,
|
|
113
|
+
geometry: {
|
|
114
|
+
type: 'LineString'
|
|
115
|
+
},
|
|
116
|
+
properties: {
|
|
117
|
+
isarrow: true,
|
|
118
|
+
color: $this.Color,
|
|
119
|
+
width: $this.pxNum
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
$this.callback(geojson);
|
|
123
|
+
}
|
|
124
|
+
// $this.handler.destroy();
|
|
125
|
+
}, $this.Cesium.ScreenSpaceEventType.RIGHT_CLICK);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// 创建点击删除事件
|
|
129
|
+
creatDeleteClick(isSelect) {
|
|
130
|
+
const $this = this;
|
|
131
|
+
if (isSelect) {
|
|
132
|
+
this.handler = new this.Cesium.ScreenSpaceEventHandler(
|
|
133
|
+
$this.viewer.scene.canvas
|
|
134
|
+
);
|
|
135
|
+
this.handler.setInputAction(function(movement) {
|
|
136
|
+
var pick = $this.viewer.scene.pick(movement.position, 3, 3);
|
|
137
|
+
|
|
138
|
+
if (!pick) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
$this.viewer.entities.removeById(pick.id._id);
|
|
142
|
+
}, $this.Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
143
|
+
} else {
|
|
144
|
+
this.handler.destroy();
|
|
145
|
+
this.handler = null;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// 创建点
|
|
150
|
+
createPoint(cartesian) {
|
|
151
|
+
var $this = this;
|
|
152
|
+
var point = this.viewer.entities.add({
|
|
153
|
+
position: cartesian,
|
|
154
|
+
point: {
|
|
155
|
+
pixelSize: 10,
|
|
156
|
+
color: $this.Cesium.Color.YELLOW
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
$this._entities_point.push(point);
|
|
160
|
+
return point;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// 创建线
|
|
164
|
+
createPolyline() {
|
|
165
|
+
var $this = this;
|
|
166
|
+
var polyline = this.viewer.entities.add({
|
|
167
|
+
polyline: {
|
|
168
|
+
// 使用cesium的peoperty
|
|
169
|
+
positions: new $this.Cesium.CallbackProperty(function() {
|
|
170
|
+
return $this._positions;
|
|
171
|
+
}, false),
|
|
172
|
+
show: true,
|
|
173
|
+
material: new $this.Cesium.PolylineArrowMaterialProperty(
|
|
174
|
+
$this.Cesium.Color.fromCssColorString('#ffffff').withAlpha(0.5)
|
|
175
|
+
),
|
|
176
|
+
arrowSize: 188, // 箭头大小
|
|
177
|
+
width: $this.pxNum,
|
|
178
|
+
clampToGround: true
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
$this._entities_line.push(polyline);
|
|
182
|
+
return polyline;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// 销毁
|
|
186
|
+
destroy() {
|
|
187
|
+
if (this.handler) {
|
|
188
|
+
this.handler.destroy();
|
|
189
|
+
this.handler = null;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// 清空实体对象
|
|
194
|
+
clear() {
|
|
195
|
+
for (let i = 0; i < this._entities_point.length; i++) {
|
|
196
|
+
this.viewer.entities.remove(this._entities_point[i]);
|
|
197
|
+
}
|
|
198
|
+
for (let i = 0; i < this._entities_line.length; i++) {
|
|
199
|
+
this.viewer.entities.remove(this._entities_line[i]);
|
|
200
|
+
}
|
|
201
|
+
this._polyline = null;
|
|
202
|
+
this._positions = [];
|
|
203
|
+
this._entities_point = []; // 脏数据
|
|
204
|
+
this._entities_line = []; // 脏数据
|
|
205
|
+
this._polylineData = null; // 用于构造线数据
|
|
206
|
+
this._polylineLast = null;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
getCatesian3FromPX(px) {
|
|
210
|
+
var cartesian;
|
|
211
|
+
var ray = this.viewer.camera.getPickRay(px);
|
|
212
|
+
if (!ray) return null;
|
|
213
|
+
cartesian = this.viewer.scene.globe.pick(ray, this.viewer.scene);
|
|
214
|
+
return cartesian;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export default DrawPolylineJT;
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
// 绘制坡面
|
|
2
|
+
|
|
3
|
+
class DrawProFile {
|
|
4
|
+
constructor(arg) {
|
|
5
|
+
this.drawName = "DrawProFile";
|
|
6
|
+
this.viewer = arg.viewer;
|
|
7
|
+
this.Cesium = arg.Cesium;
|
|
8
|
+
this.Text = arg.data.text || "";
|
|
9
|
+
this.Color = arg.data.color || "#000";
|
|
10
|
+
this.imgUrl = arg.data.imgUrl || "";
|
|
11
|
+
this.opacityNum = arg.data.opacityNum || 1;
|
|
12
|
+
this.FontSize = arg.data.fontSize || 16;
|
|
13
|
+
this.callback = arg.data.callback || null;
|
|
14
|
+
this.pxNum = arg.data.pxNum || 5;
|
|
15
|
+
this.refData = arg.data.refData;
|
|
16
|
+
this.options = undefined;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/*
|
|
20
|
+
* @Author: Wang JianLei
|
|
21
|
+
* @Date: 2020-04-08 10:55:43
|
|
22
|
+
* @Last Modified by: 宋木桐
|
|
23
|
+
* @Last Modified time: 2024-08-26 15:51:57
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
//剖面分析
|
|
27
|
+
/******************************************* **
|
|
28
|
+
剖面分析直接调用Profile()即可,左键画线,右键停止
|
|
29
|
+
createProfileChart()方法绘制剖面图
|
|
30
|
+
** ****************************************** */
|
|
31
|
+
Profile() {
|
|
32
|
+
var $this = this;
|
|
33
|
+
$this.viewer.scene.globe.depthTestAgainstTerrain = true;
|
|
34
|
+
var handler = new $this.Cesium.ScreenSpaceEventHandler(
|
|
35
|
+
$this.viewer.scene.canvas
|
|
36
|
+
);
|
|
37
|
+
var positions = [];
|
|
38
|
+
var positionsCartographic = [];
|
|
39
|
+
var positions_Inter = [];
|
|
40
|
+
var poly = null;
|
|
41
|
+
var distance = 0;
|
|
42
|
+
var cartesian = null;
|
|
43
|
+
var floatingPoint;
|
|
44
|
+
var DistanceArray = [];
|
|
45
|
+
|
|
46
|
+
var profileItem = [];
|
|
47
|
+
|
|
48
|
+
// let $menuBox = $("#SideBar");
|
|
49
|
+
// let outerW = $menuBox.outerWidth();
|
|
50
|
+
handler.setInputAction((movement) => {
|
|
51
|
+
// movement.endPosition.x = movement.endPosition.x - outerW;
|
|
52
|
+
cartesian = $this.viewer.scene.pickPosition(movement.endPosition);
|
|
53
|
+
if (positions.length >= 2) {
|
|
54
|
+
if (!$this.Cesium.defined(poly)) {
|
|
55
|
+
poly = new PolyLinePrimitive(positions);
|
|
56
|
+
} else {
|
|
57
|
+
positions.pop();
|
|
58
|
+
positions.push(cartesian);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}, $this.Cesium.ScreenSpaceEventType.MOUSE_MOVE);
|
|
62
|
+
|
|
63
|
+
handler.setInputAction((movement) => {
|
|
64
|
+
// movement.position.x = movement.position.x - outerW;
|
|
65
|
+
cartesian = $this.viewer.scene.pickPosition(movement.position);
|
|
66
|
+
if (positions.length == 0) {
|
|
67
|
+
positions.push(cartesian.clone());
|
|
68
|
+
}
|
|
69
|
+
positions.push(cartesian);
|
|
70
|
+
if (poly) {
|
|
71
|
+
//进行插值计算
|
|
72
|
+
interPoints(poly.positions);
|
|
73
|
+
// distance = getSpaceDistance(positions_Inter);
|
|
74
|
+
} else {
|
|
75
|
+
distance = getSpaceDistance(positions);
|
|
76
|
+
var textDisance = distance + "米";
|
|
77
|
+
DistanceArray.push(distance);
|
|
78
|
+
floatingPoint = $this.viewer.entities.add({
|
|
79
|
+
position: positions[positions.length - 1],
|
|
80
|
+
point: {
|
|
81
|
+
pixelSize: 5,
|
|
82
|
+
color: $this.Cesium.Color.RED,
|
|
83
|
+
outlineColor: $this.Cesium.Color.WHITE,
|
|
84
|
+
outlineWidth: 2,
|
|
85
|
+
heightReference: $this.Cesium.HeightReference.NONE,
|
|
86
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY, // 新增,禁用深度
|
|
87
|
+
},
|
|
88
|
+
label: {
|
|
89
|
+
text: textDisance,
|
|
90
|
+
font: "18px sans-serif",
|
|
91
|
+
fillColor: $this.Cesium.Color.GOLD,
|
|
92
|
+
style: $this.Cesium.LabelStyle.FILL_AND_OUTLINE,
|
|
93
|
+
outlineWidth: 2,
|
|
94
|
+
verticalOrigin: $this.Cesium.VerticalOrigin.BOTTOM,
|
|
95
|
+
pixelOffset: new $this.Cesium.Cartesian2(20, -20),
|
|
96
|
+
heightReference: $this.Cesium.HeightReference.NONE,
|
|
97
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY, // 新增,禁用深度
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}, $this.Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
102
|
+
|
|
103
|
+
handler.setInputAction(function (movement) {
|
|
104
|
+
handler.destroy(); //关闭事件句柄
|
|
105
|
+
positions.pop(); //最后一个点无效
|
|
106
|
+
// createProfileChart(profileItem);
|
|
107
|
+
$this.viewer.scene.globe.depthTestAgainstTerrain = false;
|
|
108
|
+
console.log(
|
|
109
|
+
`output->profileItem`,
|
|
110
|
+
|
|
111
|
+
profileItem
|
|
112
|
+
);
|
|
113
|
+
$this.callback({
|
|
114
|
+
type: "profile",
|
|
115
|
+
data: profileItem,
|
|
116
|
+
});
|
|
117
|
+
}, $this.Cesium.ScreenSpaceEventType.RIGHT_CLICK);
|
|
118
|
+
|
|
119
|
+
var PolyLinePrimitive = (function () {
|
|
120
|
+
function _(positions) {
|
|
121
|
+
this.options = {
|
|
122
|
+
polyline: {
|
|
123
|
+
show: true,
|
|
124
|
+
positions: [],
|
|
125
|
+
material: $this.Cesium.Color.CHARTREUSE,
|
|
126
|
+
width: 2,
|
|
127
|
+
clampToGround: true,
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
this.positions = positions;
|
|
131
|
+
this._init();
|
|
132
|
+
}
|
|
133
|
+
_.prototype._init = function () {
|
|
134
|
+
var _self = this;
|
|
135
|
+
var _update = function () {
|
|
136
|
+
return _self.positions;
|
|
137
|
+
};
|
|
138
|
+
//实时更新polyline.positions
|
|
139
|
+
this.options.polyline.positions = new $this.Cesium.CallbackProperty(
|
|
140
|
+
_update,
|
|
141
|
+
false
|
|
142
|
+
);
|
|
143
|
+
$this.viewer.entities.add(this.options);
|
|
144
|
+
};
|
|
145
|
+
return _;
|
|
146
|
+
})();
|
|
147
|
+
|
|
148
|
+
//空间两点距离计算函数
|
|
149
|
+
function getSpaceDistance(positions) {
|
|
150
|
+
profileItem = [
|
|
151
|
+
{
|
|
152
|
+
point: cartesian3ToDegrees(positions[0]),
|
|
153
|
+
distance: 0,
|
|
154
|
+
},
|
|
155
|
+
];
|
|
156
|
+
var distance = 0;
|
|
157
|
+
for (var i = 0; i < positions.length - 1; i++) {
|
|
158
|
+
var point1cartographic = Cesium.Cartographic.fromCartesian(
|
|
159
|
+
positions[i]
|
|
160
|
+
);
|
|
161
|
+
var point2cartographic = Cesium.Cartographic.fromCartesian(
|
|
162
|
+
positions[i + 1]
|
|
163
|
+
);
|
|
164
|
+
/**根据经纬度计算出距离**/
|
|
165
|
+
var geodesic = new $this.Cesium.EllipsoidGeodesic();
|
|
166
|
+
geodesic.setEndPoints(point1cartographic, point2cartographic);
|
|
167
|
+
var s = geodesic.surfaceDistance;
|
|
168
|
+
//返回两点之间的距离
|
|
169
|
+
s = Math.sqrt(
|
|
170
|
+
Math.pow(s, 2) +
|
|
171
|
+
Math.pow(point2cartographic.height - point1cartographic.height, 2)
|
|
172
|
+
);
|
|
173
|
+
distance = distance + s;
|
|
174
|
+
var m_Item = {
|
|
175
|
+
point: cartesian3ToDegrees(positions[i + 1]),
|
|
176
|
+
distance: distance,
|
|
177
|
+
};
|
|
178
|
+
profileItem.push(m_Item);
|
|
179
|
+
}
|
|
180
|
+
return distance.toFixed(2);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function cartesian3ToDegrees(positions) {
|
|
184
|
+
// 假设 positions[0] 是一个 Cartesian3 对象
|
|
185
|
+
var cartographic =
|
|
186
|
+
$this.viewer.scene.globe.ellipsoid.cartesianToCartographic(positions);
|
|
187
|
+
|
|
188
|
+
// 提取经纬度和高度
|
|
189
|
+
var longitude = $this.Cesium.Math.toDegrees(cartographic.longitude);
|
|
190
|
+
var latitude = $this.Cesium.Math.toDegrees(cartographic.latitude);
|
|
191
|
+
var height = cartographic.height;
|
|
192
|
+
|
|
193
|
+
return { x: longitude, y: latitude, z: height };
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
//线段插值点
|
|
197
|
+
async function interPoints(positions) {
|
|
198
|
+
positionsCartographic = [];
|
|
199
|
+
var terrainSamplePositions = [];
|
|
200
|
+
for (let index = 0; index < positions.length - 1; index++) {
|
|
201
|
+
const element = positions[index];
|
|
202
|
+
var ellipsoid = $this.viewer.scene.globe.ellipsoid;
|
|
203
|
+
var cartographic = ellipsoid.cartesianToCartographic(element);
|
|
204
|
+
positionsCartographic.push(cartographic);
|
|
205
|
+
}
|
|
206
|
+
for (let i = 0; i < positionsCartographic.length; i++) {
|
|
207
|
+
const m_Cartographic0 = positionsCartographic[i];
|
|
208
|
+
const m_Cartographic1 = positionsCartographic[i + 1];
|
|
209
|
+
if (m_Cartographic1) {
|
|
210
|
+
var a =
|
|
211
|
+
Math.abs(m_Cartographic0.longitude - m_Cartographic1.longitude) *
|
|
212
|
+
10000000;
|
|
213
|
+
var b =
|
|
214
|
+
Math.abs(m_Cartographic0.latitude - m_Cartographic1.latitude) *
|
|
215
|
+
10000000;
|
|
216
|
+
//等距采样
|
|
217
|
+
if (a > b) b = a;
|
|
218
|
+
var length = parseInt(b / 2);
|
|
219
|
+
if (length > 200) length = 200;
|
|
220
|
+
if (length < 2) length = 2;
|
|
221
|
+
// var length = 4;//等分采样
|
|
222
|
+
for (var j = 0; j < length; j++) {
|
|
223
|
+
terrainSamplePositions.push(
|
|
224
|
+
new $this.Cesium.Cartographic(
|
|
225
|
+
Cesium.Math.lerp(
|
|
226
|
+
m_Cartographic0.longitude,
|
|
227
|
+
m_Cartographic1.longitude,
|
|
228
|
+
j / (length - 1)
|
|
229
|
+
),
|
|
230
|
+
Cesium.Math.lerp(
|
|
231
|
+
m_Cartographic0.latitude,
|
|
232
|
+
m_Cartographic1.latitude,
|
|
233
|
+
j / (length - 1)
|
|
234
|
+
)
|
|
235
|
+
)
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
terrainSamplePositions.pop();
|
|
239
|
+
} else {
|
|
240
|
+
terrainSamplePositions.push(m_Cartographic0);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
positions_Inter = [];
|
|
244
|
+
// await computeHeight(terrainSamplePositions);
|
|
245
|
+
let terrainProvider = $this.viewer.terrainProvider;
|
|
246
|
+
|
|
247
|
+
$this.Cesium.sampleTerrain(
|
|
248
|
+
terrainProvider,
|
|
249
|
+
11,
|
|
250
|
+
terrainSamplePositions
|
|
251
|
+
).then((updatedPositions) => {
|
|
252
|
+
positions_Inter = [];
|
|
253
|
+
for (var n = 0; n < updatedPositions.length; n++) {
|
|
254
|
+
//地理坐标(弧度)转经纬度坐标
|
|
255
|
+
var m_cartographic = terrainSamplePositions[n];
|
|
256
|
+
// console.log('m_cartographic', m_cartographic);
|
|
257
|
+
|
|
258
|
+
var point = $this.Cesium.Cartesian3.fromDegrees(
|
|
259
|
+
(m_cartographic.longitude / Math.PI) * 180,
|
|
260
|
+
(m_cartographic.latitude / Math.PI) * 180,
|
|
261
|
+
m_cartographic.height
|
|
262
|
+
);
|
|
263
|
+
// console.log('point', point);
|
|
264
|
+
positions_Inter.push(point);
|
|
265
|
+
}
|
|
266
|
+
// console.log('positions_Inter', positions_Inter);
|
|
267
|
+
|
|
268
|
+
distance = getSpaceDistance(positions_Inter);
|
|
269
|
+
var textDisance = distance + "米";
|
|
270
|
+
DistanceArray.push(distance);
|
|
271
|
+
floatingPoint = $this.viewer.entities.add({
|
|
272
|
+
position: positions[positions.length - 1],
|
|
273
|
+
point: {
|
|
274
|
+
pixelSize: 5,
|
|
275
|
+
color: $this.Cesium.Color.RED,
|
|
276
|
+
outlineColor: $this.Cesium.Color.WHITE,
|
|
277
|
+
outlineWidth: 2,
|
|
278
|
+
heightReference: $this.Cesium.HeightReference.NONE,
|
|
279
|
+
// disableDepthTestDistance: Number.POSITIVE_INFINITY, // 新增,禁用深度
|
|
280
|
+
},
|
|
281
|
+
label: {
|
|
282
|
+
text: textDisance,
|
|
283
|
+
font: "18px sans-serif",
|
|
284
|
+
fillColor: $this.Cesium.Color.GOLD,
|
|
285
|
+
style: $this.Cesium.LabelStyle.FILL_AND_OUTLINE,
|
|
286
|
+
outlineWidth: 2,
|
|
287
|
+
verticalOrigin: $this.Cesium.VerticalOrigin.BOTTOM,
|
|
288
|
+
pixelOffset: new $this.Cesium.Cartesian2(20, -20),
|
|
289
|
+
heightReference: $this.Cesium.HeightReference.NONE,
|
|
290
|
+
// disableDepthTestDistance: Number.POSITIVE_INFINITY, // 新增,禁用深度
|
|
291
|
+
},
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
// // 这里通过经纬度得到高度,计算很慢,应该调整成为结束绘制后再来计算高度
|
|
296
|
+
// for (var n = 0; n < terrainSamplePositions.length; n++) {
|
|
297
|
+
// //地理坐标(弧度)转经纬度坐标
|
|
298
|
+
// var m_cartographic = terrainSamplePositions[n];
|
|
299
|
+
// // console.log(`output->m_cartographic`, m_cartographic);
|
|
300
|
+
// // var height = $this.viewer.scene.globe.getHeight(m_cartographic);
|
|
301
|
+
// var height = 500;
|
|
302
|
+
// var point = $this.Cesium.Cartesian3.fromDegrees(
|
|
303
|
+
// (m_cartographic.longitude / Math.PI) * 180,
|
|
304
|
+
// (m_cartographic.latitude / Math.PI) * 180,
|
|
305
|
+
// height
|
|
306
|
+
// );
|
|
307
|
+
// positions_Inter.push(point);
|
|
308
|
+
// }
|
|
309
|
+
// console.log(`output->positions_Inter`, positions_Inter);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export default DrawProFile;
|